/// <summary> /// Starts a capture. /// </summary> /// <param name="camera">The camera to capture from.</param> /// <exception cref="ArgumentNullException">A null reference is passed as an argument.</exception> /// <exception cref="Win32Exception">Failed to load the DirectShow utilities dll.</exception> /// <exception cref="DirectShowException">Failed to run a video capture graph.</exception> public void StartCapture(WebCameraId camera) { if (camera == null) { throw new ArgumentNullException(); } if (!_captureGraphInitialized) { InitializeCaptureGraph(); _captureGraphInitialized = true; } if (_isCapturing) { if (_currentCamera == camera) { return; } StopCapture(); } if (_currentCamera != null) { Proxy.ResetCaptureGraph(); _currentCamera = null; } Proxy.AddCaptureFilter(camera.DevicePath); _currentCamera = camera; try { Proxy.Start(); _isCapturing = true; } catch (DirectShowException) { Proxy.ResetCaptureGraph(); _currentCamera = null; throw; } }