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(); } }
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)); }
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(); }