private void cklbCameras_ItemCheck(object sender, System.Windows.Forms.ItemCheckEventArgs e) { if(e.NewValue == CheckState.Checked) { // We only support one device at a time for this sample UncheckAllDevices(); // CF1 Select camera // CF2 Initialize - Create filter and internal graph vcg = new VideoCaptureGraph((FilterInfo)cklbCameras.SelectedItem); vcg.RenderLocal(); // CF3 Connect all the filters VideoWindow(); // CF4 Set video window (if you like) vcg.Run(); // CF5 Start graph -> Show video } else // Unchecked { Cleanup(); } }
// CF2 (with some changes for network) private void cklbCameras_ItemCheck(object sender, System.Windows.Forms.ItemCheckEventArgs e) { if(e.NewValue == CheckState.Checked) { UncheckAllDevices(); vcg = new VideoCaptureGraph((FilterInfo)cklbCameras.SelectedItem); // Create filter and internal graph vcg.RenderNetwork(rtpSender); // Add network filter, connect all filters vcg.Run(); // Send data to network } else // Unchecked { DisposeDevice(); } }
public void RenderAndRunVideo(VideoCaptureGraph vcg, bool playIt) { if(playIt) { Log("Playing video (render and run graph) - " + vcg.Source.FriendlyName); vcg.RenderLocal(); VideoCapability.DisableDXVA(vcg.FilgraphManager); // Set device name in the video window and turn off the system menu IVideoWindow iVW = (IVideoWindow)vcg.FilgraphManager; iVW.Caption = vcg.Source.FriendlyName; iVW.WindowStyle &= ~0x00080000; // WS_SYSMENU vcg.Run(); } else { Log("Stop video (stop and unrender graph) - " + vcg.Source.FriendlyName); vcg.Stop(); vcg.RemoveRenderer(); // I have no idea why the video window stays up but this fixes it GC.Collect(); } Log(FilterGraph.Debug(vcg.IFilterGraph)); }
// CF2 (with some changes for network) private void cklbCameras_ItemCheck(object sender, System.Windows.Forms.ItemCheckEventArgs e) { if(e.NewValue == CheckState.Checked) { UncheckAllDevices(); // Create the graph for the device vcg = new VideoCaptureGraph((FilterInfo)cklbCameras.SelectedItem); // Add a compressor and configure it vcg.AddCompressor(VideoCompressor.DefaultFilterInfo()); vcg.VideoCompressor.QualityInfo = VideoCompressor.DefaultQualityInfo; // Add network filter vcg.RenderNetwork(rtpSender); // Send data to network vcg.Run(); } else // Unchecked { DisposeDevice(); } }
private void MDShowInteropForm_Load(object sender, System.EventArgs e) { this.Text = Strings.DirectShowSample; // CF1 Add video devices to UI foreach (FilterInfo fi in VideoSource.Sources()) { cklbCameras.Items.Add(fi); } vcg = new VideoCaptureGraph(VideoSource.Sources()[0]); vcg.RenderLocal(); // CF3 Connect all the filters VideoWindow(); // CF4 Set video window (if you like) vcg.Run(); }