fork(1) download
  1. //インスタンス変数
  2. private IFilterGraph2 _filterGraph;
  3. private IMediaControl _mediaControl;
  4. private IPin _outputPin;
  5. private IPin _inputPin;
  6.  
  7. ///グラフ作成
  8. private void SetupGraph(Control control)
  9. {
  10. //デバイス取得
  11. var capDevices = DsDevice.GetDevicesOfCat(FilterCategory.VideoInputDevice);
  12. filterGraph = new FilterGraph() as IFilterGraph2;
  13. IBaseFilter capFilter;
  14. var hr = filterGraph.AddSourceFilterForMoniker(capDevices[0].Mon, null, capDevices[0].Name, out capFilter);
  15. DsError.ThrowExceptionForHR(hr);
  16.  
  17. outputPin = DsFindPin.ByCategory(capFilter, PinCategory.Capture, 0);
  18. var pRender = new VideoRendererDefault() as IBaseFilter;
  19. hr = filterGraph.AddFilter(pRender, "Renderer");
  20. DsError.ThrowExceptionForHR(hr);
  21. _inputPin = DsFindPin.ByDirection(pRender, PinDirection.Input, 0);
  22. hr = filterGraph.Connect(_outputPin, _inputPin);
  23. DsError.ThrowExceptionForHR(hr);
  24. //このメソッドでコントロールに描画する設定を行います。
  25. ConfigVideoWindow(control);
  26. _mediaControl = _filterGraph as IMediaControl;
  27. _mediaControl.Run();
  28. }
  29.  
  30. //切断
  31. public void Disconnect()
  32. {
  33. _mediaControl.Stop();
  34. var hr= filterGraph.Disconnect(_outputPin);
  35. DsError.ThrowExceptionForHR(hr);
  36. _mediaControl.Run();
  37. }
  38.  
  39. ///再接続
  40. public void Reconnect()
  41. {
  42. _mediaControl.Stop();
  43. var hr= filterGraph.Connect(_outputPin, inputPin);
  44. DsError.ThrowExceptionForHR(hr);
  45. _mediaControl.Run();
  46. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cs(2,23): error CS0116: A namespace can only contain types and namespace declarations
prog.cs(3,23): error CS0116: A namespace can only contain types and namespace declarations
prog.cs(4,14): error CS0116: A namespace can only contain types and namespace declarations
prog.cs(5,14): error CS0116: A namespace can only contain types and namespace declarations
prog.cs(8,14): error CS0116: A namespace can only contain types and namespace declarations
prog.cs(31,13): error CS0116: A namespace can only contain types and namespace declarations
prog.cs(40,13): error CS0116: A namespace can only contain types and namespace declarations
Compilation failed: 7 error(s), 0 warnings
stdout
Standard output is empty