public override bool Connect() { if (!base.Encoder.IsActive) { base.LastError = StreamingServer.STREAMINGERROR.Error_EncoderError; base.LastErrorMessage = "Encoder not active!"; return(false); } if (!base.UseBASS) { if (this._socket != null && this._socket.Connected) { this._socket.Close(); this._socket = null; } this._socket = this.CreateSocket(this.ServerAddress, this.ServerPort); return(this._socket != null && this._socket.Connected); } if (this._isConnected) { return(true); } string content = BassEnc.BASS_ENCODE_TYPE_OGG; if (base.Encoder.EncoderType == BASSChannelType.BASS_CTYPE_STREAM_MP3) { content = BassEnc.BASS_ENCODE_TYPE_MP3; } else if (base.Encoder.EncoderType == BASSChannelType.BASS_CTYPE_STREAM_AAC) { content = BassEnc.BASS_ENCODE_TYPE_AAC; } string pass = this.Password; if (!string.IsNullOrEmpty(this.Username) && this.Username.ToLower() != "source") { pass = this.Username + ":" + this.Password; } if (BassEnc.BASS_Encode_CastInit(base.Encoder.EncoderHandle, string.Format("{0}:{1}{2}", this.ServerAddress, this.ServerPort, this.MountPoint), pass, content, this.StreamName, this.StreamUrl, this.StreamGenre, this.StreamDescription, (this.Quality == null) ? null : string.Format("ice-bitrate: {0}\r\n", this.Quality), (this.Quality == null) ? base.Encoder.EffectiveBitrate : 0, this.PublicFlag)) { this._myNotifyProc = new ENCODENOTIFYPROC(this.EncoderNotifyProc); this._isConnected = BassEnc.BASS_Encode_SetNotify(base.Encoder.EncoderHandle, this._myNotifyProc, IntPtr.Zero); } else { base.LastError = StreamingServer.STREAMINGERROR.Error_EncoderError; base.LastErrorMessage = "Encoder not active or a connction to the server could not be established!"; BASSError basserror = Bass.BASS_ErrorGetCode(); if (basserror <= BASSError.BASS_ERROR_HANDLE) { if (basserror != BASSError.BASS_ERROR_UNKNOWN) { if (basserror != BASSError.BASS_ERROR_FILEOPEN) { if (basserror == BASSError.BASS_ERROR_HANDLE) { base.LastError = StreamingServer.STREAMINGERROR.Error_EncoderError; base.LastErrorMessage = "Encoder not active or invalif Encoder used!"; } } else { base.LastError = StreamingServer.STREAMINGERROR.Error_CreatingConnection; base.LastErrorMessage = "Couldn't connect to the server!"; } } else { base.LastError = StreamingServer.STREAMINGERROR.Error_CreatingConnection; base.LastErrorMessage = "An unknown error occurred!"; } } else if (basserror != BASSError.BASS_ERROR_ALREADY) { if (basserror != BASSError.BASS_ERROR_ILLPARAM) { if (basserror == BASSError.BASS_ERROR_CAST_DENIED) { base.LastError = StreamingServer.STREAMINGERROR.Error_Login; base.LastErrorMessage = "Username or Password incorrect!"; } } else { base.LastError = StreamingServer.STREAMINGERROR.Error_ResolvingServerAddress; base.LastErrorMessage = "Couldn't connect to the server or server doesn't include a port number!"; } } else { base.LastError = StreamingServer.STREAMINGERROR.Error_NotConnected; base.LastErrorMessage = "There is already a cast set on the encoder!"; } this._isConnected = false; } return(this._isConnected); }