protected override void Dispose(bool disposeManaged) { if (_eventListenerRunning == true) { _eventListenerRunning = false; while (_eventThread.IsAlive == true) { Thread.Sleep(1000); } } if (_graphControlClient != null) { _graphControlClient.ChannelScanStarted -= new EventHandler(_graphControlClient_ChannelScanStarted); _graphControlClient.ChannelScanProgressUpdate -= new EventHandler(_graphControlClient_ChannelScanProgressUpdate); _graphControlClient.ChannelScanComplete -= new EventHandler <ChannelScanCompleteEventArgs>(_graphControlClient_ChannelScanComplete); _graphControlClient.Closed -= new EventHandler(_graphControlClient_Closed); _graphControlClient.Dispose(); _graphControlClient = null; } Stop(); if (_netSrc != null) { Marshal.ReleaseComObject(_netSrc); _netSrc = null; } this.ConnectionFaulted = null; dmxMsgReceiveTimer.Stop(); dmxMsgReceiveTimer.Dispose(); dmxMsgReceiveTimer = null; base.Dispose(disposeManaged); }
public override void Render() { _graphControlClient = new FutureConcepts.Media.Client.TVStreamControl(AppUser.Current.ServerAddress); _graphControlClient.Closed += new EventHandler(_graphControlClient_Closed); Message = "Connecting to " + _graphControlClient.ServerAddress + " " + AppUser.Current.ServerSourceName + "..."; ClientConnectRequest clientRequest = new ClientConnectRequest(AppUser.Current.ServerSourceName); _sessionInfo = _graphControlClient.OpenGraph(clientRequest); //attach the event listeners only after successful connection _graphControlClient.ChannelScanStarted += new EventHandler(_graphControlClient_ChannelScanStarted); _graphControlClient.ChannelScanProgressUpdate += new EventHandler(_graphControlClient_ChannelScanProgressUpdate); _graphControlClient.ChannelScanComplete += new EventHandler <ChannelScanCompleteEventArgs>(_graphControlClient_ChannelScanComplete); _graphControlClient.PropertyChanged += new PropertyChangedEventHandler(_graphControlClient_PropertyChanged); this.Connected = ConnectionState.WCFOnly; if (_sessionInfo.TVSessionInfo == null) { throw new Exception("VideoServer Source is not a TV Source"); } if (_sessionInfo.TVSessionInfo.ChannelScanInProgress) { //TODO...is this the best way? //throw new Exception("The TV server is currently in the middle of scanning for channels."); return; } Profile currentProfile = null; foreach (ProfileGroup g in _sessionInfo.ProfileGroups.Items) { foreach (Profile p in g.Items) { if (_sessionInfo.CurrentProfileName.Equals(p.Name)) { currentProfile = p; } } } if (currentProfile != null) { //determine if we have a preferred video decoder for the specified Video codec if (currentProfile.Video != null) { if (currentProfile.Video.CodecType != VideoCodecType.Undefined) { Filter vdFilter = this.GraphConfig.GetFilterForCodec(currentProfile.Video.CodecType, FilterType.VideoDecoder); if (vdFilter != null) { _videoDecoder = FilterGraphTools.AddFilterByName(_graphBuilder, FilterCategory.LegacyAmFilterCategory, vdFilter.Name); } } } //determine if we have a preferred audio decoder for the specified Audio codec if (currentProfile.Audio != null) { if (currentProfile.Audio.CodecType != AudioCodecType.Undefined) { Filter adFilter = this.GraphConfig.GetFilterForCodec(currentProfile.Audio.CodecType, FilterType.AudioDecoder); if (adFilter != null) { _audioDecoder = FilterGraphTools.AddFilterByName(_graphBuilder, FilterCategory.LegacyAmFilterCategory, adFilter.Name); } } } } AddLeadNetSrc(); AddLeadNetDemux(); ConnectFilters(_netSrc, "Output", _netDmx, "Input 01", true); RenderNetDemux(); NotifyPropertyChanged("Channel"); NotifyPropertyChanged("TVMode"); this.Connected = ConnectionState.Full; this.SaveGraphFile(); }