| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Windows specific implementation of VideoCaptureDevice. | 5 // Windows specific implementation of VideoCaptureDevice. |
| 6 // DirectShow is used for capturing. DirectShow provide its own threads | 6 // DirectShow is used for capturing. DirectShow provide its own threads |
| 7 // for capturing. | 7 // for capturing. |
| 8 | 8 |
| 9 #ifndef MEDIA_VIDEO_CAPTURE_WIN_VIDEO_CAPTURE_DEVICE_WIN_H_ | 9 #ifndef MEDIA_VIDEO_CAPTURE_WIN_VIDEO_CAPTURE_DEVICE_WIN_H_ |
| 10 #define MEDIA_VIDEO_CAPTURE_WIN_VIDEO_CAPTURE_DEVICE_WIN_H_ | 10 #define MEDIA_VIDEO_CAPTURE_WIN_VIDEO_CAPTURE_DEVICE_WIN_H_ |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 public VideoCaptureDevice, | 33 public VideoCaptureDevice, |
| 34 public SinkFilterObserver { | 34 public SinkFilterObserver { |
| 35 public: | 35 public: |
| 36 explicit VideoCaptureDeviceWin(const Name& device_name); | 36 explicit VideoCaptureDeviceWin(const Name& device_name); |
| 37 virtual ~VideoCaptureDeviceWin(); | 37 virtual ~VideoCaptureDeviceWin(); |
| 38 // Opens the device driver for this device. | 38 // Opens the device driver for this device. |
| 39 // This function is used by the static VideoCaptureDevice::Create function. | 39 // This function is used by the static VideoCaptureDevice::Create function. |
| 40 bool Init(); | 40 bool Init(); |
| 41 | 41 |
| 42 // VideoCaptureDevice implementation. | 42 // VideoCaptureDevice implementation. |
| 43 virtual void AllocateAndStart(const VideoCaptureParams& params, | 43 virtual void AllocateAndStart( |
| 44 scoped_ptr<VideoCaptureDevice::Client> client) | 44 const VideoCaptureParams& params, |
| 45 OVERRIDE; | 45 scoped_ptr<VideoCaptureDevice::Client> client) OVERRIDE; |
| 46 virtual void StopAndDeAllocate() OVERRIDE; | 46 virtual void StopAndDeAllocate() OVERRIDE; |
| 47 | 47 |
| 48 static void GetDeviceNames(Names* device_names); | 48 static void GetDeviceNames(Names* device_names); |
| 49 static void GetDeviceSupportedFormats(const Name& device, | 49 static void GetDeviceSupportedFormats(const Name& device, |
| 50 VideoCaptureFormats* formats); | 50 VideoCaptureFormats* formats); |
| 51 | 51 |
| 52 private: | 52 private: |
| 53 enum InternalState { | 53 enum InternalState { |
| 54 kIdle, // The device driver is opened but camera is not in use. | 54 kIdle, // The device driver is opened but camera is not in use. |
| 55 kCapturing, // Video is being captured. | 55 kCapturing, // Video is being captured. |
| 56 kError // Error accessing HW functions. | 56 kError // Error accessing HW functions. |
| 57 // User needs to recover by destroying the object. | 57 // User needs to recover by destroying the object. |
| 58 }; | 58 }; |
| 59 | 59 |
| 60 // Implements SinkFilterObserver. | 60 // Implements SinkFilterObserver. |
| 61 virtual void FrameReceived(const uint8* buffer, int length); | 61 virtual void FrameReceived(const uint8* buffer, int length); |
| 62 | 62 |
| 63 bool CreateCapabilityMap(); | 63 bool CreateCapabilityMap(); |
| 64 void SetAntiFlickerInCaptureFilter(); |
| 64 void SetErrorState(const std::string& reason); | 65 void SetErrorState(const std::string& reason); |
| 65 | 66 |
| 66 Name device_name_; | 67 Name device_name_; |
| 67 InternalState state_; | 68 InternalState state_; |
| 68 scoped_ptr<VideoCaptureDevice::Client> client_; | 69 scoped_ptr<VideoCaptureDevice::Client> client_; |
| 69 | 70 |
| 70 base::win::ScopedComPtr<IBaseFilter> capture_filter_; | 71 base::win::ScopedComPtr<IBaseFilter> capture_filter_; |
| 71 base::win::ScopedComPtr<IGraphBuilder> graph_builder_; | 72 base::win::ScopedComPtr<IGraphBuilder> graph_builder_; |
| 72 base::win::ScopedComPtr<IMediaControl> media_control_; | 73 base::win::ScopedComPtr<IMediaControl> media_control_; |
| 73 base::win::ScopedComPtr<IPin> input_sink_pin_; | 74 base::win::ScopedComPtr<IPin> input_sink_pin_; |
| 74 base::win::ScopedComPtr<IPin> output_capture_pin_; | 75 base::win::ScopedComPtr<IPin> output_capture_pin_; |
| 75 // Used when using a MJPEG decoder. | 76 // Used when using a MJPEG decoder. |
| 76 base::win::ScopedComPtr<IBaseFilter> mjpg_filter_; | 77 base::win::ScopedComPtr<IBaseFilter> mjpg_filter_; |
| 77 base::win::ScopedComPtr<IPin> input_mjpg_pin_; | 78 base::win::ScopedComPtr<IPin> input_mjpg_pin_; |
| 78 base::win::ScopedComPtr<IPin> output_mjpg_pin_; | 79 base::win::ScopedComPtr<IPin> output_mjpg_pin_; |
| 79 | 80 |
| 80 scoped_refptr<SinkFilter> sink_filter_; | 81 scoped_refptr<SinkFilter> sink_filter_; |
| 81 | 82 |
| 82 // Map of all capabilities this device support. | 83 // Map of all capabilities this device support. |
| 83 CapabilityList capabilities_; | 84 CapabilityList capabilities_; |
| 84 VideoCaptureFormat capture_format_; | 85 VideoCaptureFormat capture_format_; |
| 85 | 86 |
| 86 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoCaptureDeviceWin); | 87 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoCaptureDeviceWin); |
| 87 }; | 88 }; |
| 88 | 89 |
| 89 } // namespace media | 90 } // namespace media |
| 90 | 91 |
| 91 #endif // MEDIA_VIDEO_CAPTURE_WIN_VIDEO_CAPTURE_DEVICE_WIN_H_ | 92 #endif // MEDIA_VIDEO_CAPTURE_WIN_VIDEO_CAPTURE_DEVICE_WIN_H_ |
| OLD | NEW |