public void OnGraphDecomposed(GraphBuilderBase graph) { foreach (IPlugin plugin in this.plugins) { try { plugin.OnGraphDecomposed(graph); } catch (Exception ex) { MessageBox.Show(string.Format(Properties.Resources.PluginException, plugin.Name, ex.ToString())); } } }
public GraphBuilderTV TuneChannel(Channel channel, bool needRebuild, GraphBuilderBase currentGraph, VideoControl hostingControl) { if (needRebuild && currentGraph != null) { ClearGraph(); //OnGraphStop(); //currentGraph.Dispose(); //currentGraph = null; } GraphBuilderTV currentGraphTV = currentGraph as GraphBuilderTV; if (channel is ChannelDVB) { ChannelDVB channelDVB = channel as ChannelDVB; if (needRebuild) { GraphBuilderBDA newGraph = null; switch(this.graphBuilderType) { case GraphBuilderType.BDA: newGraph = new GraphBuilderBDA(hostingControl); break; case GraphBuilderType.BDATimeShifting: newGraph = new GraphBuilderBDATimeShifting(hostingControl); break; case GraphBuilderType.BDAMosaic: newGraph = new GraphBuilderBDAMosaic(hostingControl); break; } newGraph.GraphStarted += new EventHandler(newGraph_GraphStarted); newGraph.GraphEnded += new EventHandler(newGraph_GraphEnded); newGraph.PossibleChanged += new EventHandler<GraphBuilderBase.PossibleEventArgs>(newGraph_PossibleChanged); newGraph.Settings = Settings; currentGraphTV = newGraph; newGraph.ReferenceClock = channelDVB.ReferenceClock; newGraph.AudioDecoderType = channelDVB.AudioDecoderType; DsDevice device; if (!string.IsNullOrEmpty(channelDVB.AudioDecoderDevice)) { if (GraphBuilderBDA.AudioDecoderDevices.TryGetValue(channelDVB.AudioDecoderDevice, out device)) newGraph.AudioDecoderDevice = device; else throw new Exception(string.Format(Properties.Resources.AudioDeviceNotFound, channelDVB.AudioDecoderDevice)); } if (channelDVB.VideoDecoderType == ChannelDVB.VideoType.MPEG2) { if (!string.IsNullOrEmpty(channelDVB.MPEG2DecoderDevice)) { if (GraphBuilderBDA.MPEG2DecoderDevices.TryGetValue(channelDVB.MPEG2DecoderDevice, out device)) newGraph.Mpeg2DecoderDevice = device; else throw new Exception(string.Format(Properties.Resources.MPEG2DecoderDeviceNotFound, channelDVB.MPEG2DecoderDevice)); } } else { if (!string.IsNullOrEmpty(channelDVB.H264DecoderDevice)) { if (GraphBuilderBDA.H264DecoderDevices.TryGetValue(channelDVB.H264DecoderDevice, out device)) newGraph.H264DecoderDevice = device; else throw new Exception(string.Format(Properties.Resources.H264DecoderDeviceNotFound, channelDVB.H264DecoderDevice)); } } if (!string.IsNullOrEmpty(channelDVB.AudioRendererDevice)) { if (GraphBuilderBDA.AudioRendererDevices.TryGetValue(channelDVB.AudioRendererDevice, out device)) newGraph.AudioRendererDevice = device; else throw new Exception(string.Format(Properties.Resources.AudioRendererDeviceNotFound, channelDVB.AudioRendererDevice)); } if (!string.IsNullOrEmpty(channelDVB.TunerDevice)) { if (GraphBuilderBDA.TunerDevices.TryGetValue(channelDVB.TunerDevice, out device)) newGraph.TunerDevice = device; else throw new Exception(string.Format(Properties.Resources.TunerDeviceNotFound, channelDVB.TunerDevice)); } if (!string.IsNullOrEmpty(channelDVB.CaptureDevice)) { if (GraphBuilderBDA.CaptureDevices.TryGetValue(channelDVB.CaptureDevice, out device)) newGraph.CaptureDevice = device; else throw new Exception(string.Format(Properties.Resources.CaptureDeviceNotFound, channelDVB.CaptureDevice)); } IDVBTuningSpace tuningSpace = (IDVBTuningSpace)new DVBTuningSpace(); if (channel is ChannelDVBT) { tuningSpace.put_UniqueName("DVBT TuningSpace"); tuningSpace.put_FriendlyName("DVBT TuningSpace"); tuningSpace.put_NetworkType(CLSID.DVBTNetworkProvider); tuningSpace.put_SystemType(DVBSystemType.Terrestrial); } else if (channel is ChannelDVBC) { tuningSpace.put_UniqueName("DVBC TuningSpace"); tuningSpace.put_FriendlyName("DVBC TuningSpace"); tuningSpace.put_NetworkType(CLSID.DVBCNetworkProvider); tuningSpace.put_SystemType(DVBSystemType.Cable); } else if (channel is ChannelDVBS) { tuningSpace.put_UniqueName("DVBS TuningSpace"); tuningSpace.put_FriendlyName("DVBS TuningSpace"); tuningSpace.put_NetworkType(CLSID.DVBSNetworkProvider); tuningSpace.put_SystemType(DVBSystemType.Satellite); } newGraph.TuningSpace = tuningSpace as ITuningSpace; newGraph.BuildGraph(); } currentGraphTV.SubmitTuneRequest(channel); currentGraphTV.VideoZoomMode = channelDVB.VideoZoomMode; currentGraphTV.VideoKeepAspectRatio = channelDVB.VideoKeepAspectRatio; currentGraphTV.VideoOffset = channelDVB.VideoOffset; currentGraphTV.VideoZoom = channelDVB.VideoZoom; currentGraphTV.VideoAspectRatioFactor = channelDVB.VideoAspectRatioFactor; currentGraphTV.RunGraph(); //currentGraph.VideoResizer(); currentGraphTV.CurrentChannel = channel; } else if (channel is ChannelAnalogic) { ChannelAnalogic channelAnalogic = channel as ChannelAnalogic; if (needRebuild) { GraphBuilderWDM newGraph = new GraphBuilderWDM(hostingControl); newGraph.GraphStarted += new EventHandler(newGraph_GraphStarted); newGraph.GraphEnded += new EventHandler(newGraph_GraphEnded); newGraph.PossibleChanged += new EventHandler<GraphBuilderBase.PossibleEventArgs>(newGraph_PossibleChanged); newGraph.Settings = Settings; currentGraphTV = newGraph; DsDevice device; if (GraphBuilderWDM.AudioRendererDevices.TryGetValue(channelAnalogic.AudioRendererDevice, out device)) newGraph.AudioRendererDevice = device; if (GraphBuilderWDM.VideoInputDevices.TryGetValue(channelAnalogic.VideoCaptureDeviceName, out device)) newGraph.VideoCaptureDevice = device; if (GraphBuilderWDM.AudioInputDevices.TryGetValue(channelAnalogic.AudioCaptureDeviceName, out device)) newGraph.AudioCaptureDevice = device; newGraph.FormatOfCapture = channelAnalogic.FormatOfCapture; newGraph.BuildGraph(); } bool goodTuning = true; try { currentGraphTV.SubmitTuneRequest(channel); } catch (COMException) { goodTuning = false; } if (goodTuning) { currentGraphTV.VideoZoomMode = channelAnalogic.VideoZoomMode; currentGraphTV.VideoKeepAspectRatio = channelAnalogic.VideoKeepAspectRatio; currentGraphTV.VideoOffset = channelAnalogic.VideoOffset; currentGraphTV.VideoZoom = channelAnalogic.VideoZoom; currentGraphTV.VideoAspectRatioFactor = channelAnalogic.VideoAspectRatioFactor; currentGraphTV.RunGraph(); //currentGraph.VideoResizer(); currentGraphTV.CurrentChannel = channel; } else currentGraphTV.CurrentChannel = null; } return currentGraphTV; }
private void openVideoToolStripMenuItem_Click(object sender, EventArgs e) { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.InitialDirectory = this.GetType().Module.FullyQualifiedName; //openFileDialog.Filter = "xml files (*.xml)|*.xml|All files (*.*)|*.*"; openFileDialog.Filter = Properties.Resources.FileDialogAllFiles; openFileDialog.FilterIndex = 1; openFileDialog.RestoreDirectory = true; if (openFileDialog.ShowDialog() == DialogResult.OK) { this.Cursor = Cursors.WaitCursor; try { ClearGraph(); GraphBuilderPlayer newGraph = new GraphBuilderPlayer(this.videoControl); newGraph.GraphStarted += new EventHandler(newGraph_GraphStarted); newGraph.GraphEnded += new EventHandler(newGraph_GraphEnded); newGraph.PossibleChanged += new EventHandler<GraphBuilderBase.PossibleEventArgs>(newGraph_PossibleChanged); newGraph.Settings = Settings; newGraph.FileName = openFileDialog.FileName; this.currentGraphBuilder = newGraph; this.currentGraphBuilder.BuildGraph(); this.currentGraphBuilder.RunGraph(); OnGraphInit(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { this.Cursor = Cursors.Default; } } }
void newGraph_PossibleChanged(object sender, GraphBuilderBase.PossibleEventArgs e) { switch (e.possible) { case "IsPossibleGraphRun": break; case "IsPossibleGraphPause": break; case "IsPossibleGraphStop": break; case "IsPossibleGraphRestart": break; case "IsPossibleGraphRelease": break; case "IsPossibleTimeShiftingPause": this.toolStripButtonPause.Enabled = e.isPossible; break; case "IsPossibleTimeShiftingResume": this.toolStripButtonPlay.Enabled = e.isPossible; break; case "IsPossibleRecorderStart": this.toolStripButtonRecord.Enabled = e.isPossible; break; case "IsPossibleRecorderStop": this.toolStripButtonStop.Enabled = e.isPossible; break; case "IsPossiblePlayerPlay": this.toolStripButtonPlay.Enabled = e.isPossible; break; case "IsPossiblePlayerPause": this.toolStripButtonPause.Enabled = e.isPossible; break; case "IsPossiblePlayerStop": this.toolStripButtonStop.Enabled = e.isPossible; break; case "IsPossibleSetSpeed": this.panelTimeLine.trackBarSpeed.Enabled = e.isPossible; break; case "IsPossibleSetPosition": this.panelTimeLine.trackBarExTimeLine.Enabled = e.isPossible; break; } }
internal bool TuneChannel(Channel channel, bool needRebuild) { this.Cursor = Cursors.WaitCursor; try { if ((this.currentGraphBuilder = TuneChannel(channel, needRebuild, this.currentGraphBuilder, this.videoControl)) != null) { if (needRebuild) OnGraphInit(); OnChannelChange(); return true; } } finally { this.Cursor = Cursors.Default; } return false; }
internal void ClearGraph() { if (this.currentGraphBuilder != null) { //this.currentModeIsMosaic = false; this.currentGraphBuilder.GraphStarted -= new EventHandler(newGraph_GraphStarted); this.currentGraphBuilder.GraphEnded -= new EventHandler(newGraph_GraphEnded); this.currentGraphBuilder.PossibleChanged -= new EventHandler<GraphBuilderBase.PossibleEventArgs>(newGraph_PossibleChanged); this.currentGraphBuilder.Dispose(); OnGraphStop(); this.currentGraphBuilder = null; } }