private void SetupGraph(Control hWin) { //streamSource = new UdpSource("127.0.0.1", 2001); streamSource = new UdpSource("224.0.0.1", 2002); //streamSource = new Core.Sources.FileSource("test.ts"); streamSource.PacketLength = Constants.TSPacketSize; streamSource.SearchMethod = TSUtils.TSPacketSearch; streamSource.Configure(); if (!streamSource.Require(10)) { throw new Exception("Source is not ready. No data is received."); } Log.Info("Identify the A/V streams"); var streamInfo = new TStreamInfo(streamSource); streamInfo.Configure(); streamSource.Reset(); filterGraph = new FilterGraph() as IFilterGraph2; Ensure.IsNotNull(Log, filterGraph, "graph is null"); if (filterGraph == null) { return; } var pVideoRender = (IBaseFilter) new VideoRendererDefault(); var hr = filterGraph.AddFilter(pVideoRender, "Video Renderer"); DsError.ThrowExceptionForHR(hr); var pAudioRender = (IBaseFilter) new DSoundRender(); hr = filterGraph.AddFilter(pAudioRender, "Audio Render"); DsError.ThrowExceptionForHR(hr); Log.Info("Configure the directshow graph."); configurator = new GraphConfigurator { Source = streamSource, StreamInfo = streamInfo, Graph = filterGraph, VideoRender = pVideoRender, AudioRender = pAudioRender, VideoGrabber = null, AudioGrabber = null }; configurator.Configure(); var videoWindow = pVideoRender as IVideoWindow; ConfigureVideoWindow(videoWindow, hWin); this.mediaControl = this.filterGraph as IMediaControl; }
private void SetupGraph(Control hWin) { //streamSource = new UdpSource("127.0.0.1", 2001); streamSource = new UdpSource("224.0.0.1", 2002); //streamSource = new Core.Sources.FileSource("test.ts"); streamSource.PacketLength = Constants.TSPacketSize; streamSource.SearchMethod = TSUtils.TSPacketSearch; streamSource.Configure(); if (!streamSource.Require(10)) { throw new Exception("Source is not ready. No data is received."); } Log.Info("Identify the A/V streams"); var streamInfo = new TStreamInfo(streamSource); streamInfo.Configure(); streamSource.Reset(); filterGraph = new FilterGraph() as IFilterGraph2; Ensure.IsNotNull(Log, filterGraph, "graph is null"); if (filterGraph == null) return; var pVideoRender = (IBaseFilter)new VideoRendererDefault(); var hr = filterGraph.AddFilter(pVideoRender, "Video Renderer"); DsError.ThrowExceptionForHR(hr); var pAudioRender = (IBaseFilter)new DSoundRender(); hr = filterGraph.AddFilter(pAudioRender, "Audio Render"); DsError.ThrowExceptionForHR(hr); Log.Info("Configure the directshow graph."); configurator = new GraphConfigurator { Source = streamSource, StreamInfo = streamInfo, Graph = filterGraph, VideoRender = pVideoRender, AudioRender = pAudioRender, VideoGrabber = null, AudioGrabber = null }; configurator.Configure(); var videoWindow = pVideoRender as IVideoWindow; ConfigureVideoWindow(videoWindow, hWin); this.mediaControl = this.filterGraph as IMediaControl; }