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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 AM_MEDIA_TYPE** Receive(); | 47 AM_MEDIA_TYPE** Receive(); |
48 | 48 |
49 private: | 49 private: |
50 void FreeMediaType(AM_MEDIA_TYPE* mt); | 50 void FreeMediaType(AM_MEDIA_TYPE* mt); |
51 void DeleteMediaType(AM_MEDIA_TYPE* mt); | 51 void DeleteMediaType(AM_MEDIA_TYPE* mt); |
52 | 52 |
53 AM_MEDIA_TYPE* media_type_; | 53 AM_MEDIA_TYPE* media_type_; |
54 }; | 54 }; |
55 | 55 |
56 static HRESULT GetDeviceFilter(const std::string& device_id, | 56 static HRESULT GetDeviceFilter(const std::string& device_id, |
| 57 const CLSID device_class_id, |
57 IBaseFilter** filter); | 58 IBaseFilter** filter); |
58 static bool PinMatchesCategory(IPin* pin, REFGUID category); | 59 static bool PinMatchesCategory(IPin* pin, REFGUID category); |
59 static base::win::ScopedComPtr<IPin> GetPin(IBaseFilter* filter, | 60 static base::win::ScopedComPtr<IPin> GetPin(IBaseFilter* filter, |
60 PIN_DIRECTION pin_dir, | 61 PIN_DIRECTION pin_dir, |
61 REFGUID category); | 62 REFGUID category); |
62 static VideoPixelFormat TranslateMediaSubtypeToPixelFormat( | 63 static VideoPixelFormat TranslateMediaSubtypeToPixelFormat( |
63 const GUID& sub_type); | 64 const GUID& sub_type); |
64 | 65 |
65 explicit VideoCaptureDeviceWin(const Name& device_name); | 66 explicit VideoCaptureDeviceWin(const Name& device_name); |
66 virtual ~VideoCaptureDeviceWin(); | 67 virtual ~VideoCaptureDeviceWin(); |
(...skipping 12 matching lines...) Expand all Loading... |
79 kCapturing, // Video is being captured. | 80 kCapturing, // Video is being captured. |
80 kError // Error accessing HW functions. | 81 kError // Error accessing HW functions. |
81 // User needs to recover by destroying the object. | 82 // User needs to recover by destroying the object. |
82 }; | 83 }; |
83 | 84 |
84 // Implements SinkFilterObserver. | 85 // Implements SinkFilterObserver. |
85 virtual void FrameReceived(const uint8* buffer, int length); | 86 virtual void FrameReceived(const uint8* buffer, int length); |
86 | 87 |
87 bool CreateCapabilityMap(); | 88 bool CreateCapabilityMap(); |
88 void SetAntiFlickerInCaptureFilter(); | 89 void SetAntiFlickerInCaptureFilter(); |
| 90 HRESULT InstantiateWDMFiltersAndPins(); |
| 91 HRESULT AddWDMCrossbarFilterToGraphAndConnect(); |
89 void SetErrorState(const std::string& reason); | 92 void SetErrorState(const std::string& reason); |
90 | 93 |
91 Name device_name_; | 94 Name device_name_; |
92 InternalState state_; | 95 InternalState state_; |
93 scoped_ptr<VideoCaptureDevice::Client> client_; | 96 scoped_ptr<VideoCaptureDevice::Client> client_; |
94 | 97 |
95 base::win::ScopedComPtr<IBaseFilter> capture_filter_; | 98 base::win::ScopedComPtr<IBaseFilter> capture_filter_; |
96 base::win::ScopedComPtr<IGraphBuilder> graph_builder_; | 99 base::win::ScopedComPtr<IGraphBuilder> graph_builder_; |
97 base::win::ScopedComPtr<IMediaControl> media_control_; | 100 base::win::ScopedComPtr<IMediaControl> media_control_; |
98 base::win::ScopedComPtr<IPin> input_sink_pin_; | 101 base::win::ScopedComPtr<IPin> input_sink_pin_; |
99 base::win::ScopedComPtr<IPin> output_capture_pin_; | 102 base::win::ScopedComPtr<IPin> output_capture_pin_; |
100 // Used when using a MJPEG decoder. | 103 // Used when using a MJPEG decoder. |
101 base::win::ScopedComPtr<IBaseFilter> mjpg_filter_; | 104 base::win::ScopedComPtr<IBaseFilter> mjpg_filter_; |
102 base::win::ScopedComPtr<IPin> input_mjpg_pin_; | 105 base::win::ScopedComPtr<IPin> input_mjpg_pin_; |
103 base::win::ScopedComPtr<IPin> output_mjpg_pin_; | 106 base::win::ScopedComPtr<IPin> output_mjpg_pin_; |
| 107 // Used for WDM devices as specified by |device_name_|. These devices need a |
| 108 // WDM Crossbar Filter upstream from the Capture filter. |
| 109 base::win::ScopedComPtr<IBaseFilter> crossbar_filter_; |
| 110 base::win::ScopedComPtr<IPin> crossbar_video_output_pin_; |
| 111 base::win::ScopedComPtr<IPin> analog_video_input_pin_; |
104 | 112 |
105 scoped_refptr<SinkFilter> sink_filter_; | 113 scoped_refptr<SinkFilter> sink_filter_; |
106 | 114 |
107 // Map of all capabilities this device support. | 115 // Map of all capabilities this device support. |
108 CapabilityList capabilities_; | 116 CapabilityList capabilities_; |
109 VideoCaptureFormat capture_format_; | 117 VideoCaptureFormat capture_format_; |
110 | 118 |
111 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoCaptureDeviceWin); | 119 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoCaptureDeviceWin); |
112 }; | 120 }; |
113 | 121 |
114 } // namespace media | 122 } // namespace media |
115 | 123 |
116 #endif // MEDIA_VIDEO_CAPTURE_WIN_VIDEO_CAPTURE_DEVICE_WIN_H_ | 124 #endif // MEDIA_VIDEO_CAPTURE_WIN_VIDEO_CAPTURE_DEVICE_WIN_H_ |
OLD | NEW |