Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(55)

Side by Side Diff: media/video/capture/win/video_capture_device_win.h

Issue 546803002: Win Video Capture: add support for WDM capture devices using a WDM Crossbar filter. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Simplified CL to only USB capture devices. Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 base::win::ScopedComPtr<IPin> GetPin(IBaseFilter* filter, 59 static base::win::ScopedComPtr<IPin> GetPin(IBaseFilter* filter,
60 PIN_DIRECTION pin_dir, 60 PIN_DIRECTION pin_dir,
61 REFGUID category); 61 REFGUID category,
62 REFGUID major_type);
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();
67 // Opens the device driver for this device. 68 // Opens the device driver for this device.
68 bool Init(); 69 bool Init();
69 70
70 // VideoCaptureDevice implementation. 71 // VideoCaptureDevice implementation.
71 virtual void AllocateAndStart( 72 virtual void AllocateAndStart(
72 const VideoCaptureParams& params, 73 const VideoCaptureParams& params,
73 scoped_ptr<VideoCaptureDevice::Client> client) OVERRIDE; 74 scoped_ptr<VideoCaptureDevice::Client> client) OVERRIDE;
74 virtual void StopAndDeAllocate() OVERRIDE; 75 virtual void StopAndDeAllocate() OVERRIDE;
75 76
76 private: 77 private:
77 enum InternalState { 78 enum InternalState {
78 kIdle, // The device driver is opened but camera is not in use. 79 kIdle, // The device driver is opened but camera is not in use.
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_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698