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_ |
11 #pragma once | 11 #pragma once |
12 | 12 |
13 // Avoid including strsafe.h via dshow as it will cause build warnings. | 13 // Avoid including strsafe.h via dshow as it will cause build warnings. |
14 #define NO_DSHOW_STRSAFE | 14 #define NO_DSHOW_STRSAFE |
15 #include <dshow.h> | 15 #include <dshow.h> |
16 | 16 |
17 #include <map> | 17 #include <map> |
18 #include <string> | 18 #include <string> |
19 | 19 |
20 #include "base/threading/non_thread_safe.h" | |
20 #include "base/threading/thread.h" | 21 #include "base/threading/thread.h" |
21 #include "base/win/scoped_com_initializer.h" | |
22 #include "base/win/scoped_comptr.h" | 22 #include "base/win/scoped_comptr.h" |
23 #include "media/video/capture/video_capture_device.h" | 23 #include "media/video/capture/video_capture_device.h" |
24 #include "media/video/capture/video_capture_types.h" | 24 #include "media/video/capture/video_capture_types.h" |
25 #include "media/video/capture/win/sink_filter_win.h" | 25 #include "media/video/capture/win/sink_filter_win.h" |
26 #include "media/video/capture/win/sink_input_pin_win.h" | 26 #include "media/video/capture/win/sink_input_pin_win.h" |
27 | 27 |
28 namespace media { | 28 namespace media { |
29 | 29 |
30 // All the APIs in the class can only be run on a COM initialized thread. | |
tommi (sloooow) - chröme
2012/07/04 13:46:48
s/APIs/methods
no longer working on chromium
2012/07/04 14:31:39
Done.
| |
30 class VideoCaptureDeviceWin | 31 class VideoCaptureDeviceWin |
31 : public VideoCaptureDevice, | 32 : public base::NonThreadSafe, |
33 public VideoCaptureDevice, | |
32 public SinkFilterObserver { | 34 public SinkFilterObserver { |
33 public: | 35 public: |
34 explicit VideoCaptureDeviceWin(const Name& device_name); | 36 explicit VideoCaptureDeviceWin(const Name& device_name); |
35 virtual ~VideoCaptureDeviceWin(); | 37 virtual ~VideoCaptureDeviceWin(); |
36 // Opens the device driver for this device. | 38 // Opens the device driver for this device. |
37 // This function is used by the static VideoCaptureDevice::Create function. | 39 // This function is used by the static VideoCaptureDevice::Create function. |
38 bool Init(); | 40 bool Init(); |
39 | 41 |
40 // VideoCaptureDevice implementation. | 42 // VideoCaptureDevice implementation. |
41 virtual void Allocate(int width, | 43 virtual void Allocate(int width, |
(...skipping 15 matching lines...) Expand all Loading... | |
57 }; | 59 }; |
58 typedef std::map<int, VideoCaptureCapability> CapabilityMap; | 60 typedef std::map<int, VideoCaptureCapability> CapabilityMap; |
59 | 61 |
60 // Implements SinkFilterObserver. | 62 // Implements SinkFilterObserver. |
61 virtual void FrameReceived(const uint8* buffer, int length); | 63 virtual void FrameReceived(const uint8* buffer, int length); |
62 | 64 |
63 bool CreateCapabilityMap(); | 65 bool CreateCapabilityMap(); |
64 int GetBestMatchedCapability(int width, int height, int frame_rate); | 66 int GetBestMatchedCapability(int width, int height, int frame_rate); |
65 void SetErrorState(const char* reason); | 67 void SetErrorState(const char* reason); |
66 | 68 |
67 base::win::ScopedCOMInitializer initialize_com_; | |
68 | |
69 Name device_name_; | 69 Name device_name_; |
70 InternalState state_; | 70 InternalState state_; |
71 VideoCaptureDevice::EventHandler* observer_; | 71 VideoCaptureDevice::EventHandler* observer_; |
72 | 72 |
73 base::win::ScopedComPtr<IBaseFilter> capture_filter_; | 73 base::win::ScopedComPtr<IBaseFilter> capture_filter_; |
74 base::win::ScopedComPtr<IGraphBuilder> graph_builder_; | 74 base::win::ScopedComPtr<IGraphBuilder> graph_builder_; |
75 base::win::ScopedComPtr<IMediaControl> media_control_; | 75 base::win::ScopedComPtr<IMediaControl> media_control_; |
76 base::win::ScopedComPtr<IPin> input_sink_pin_; | 76 base::win::ScopedComPtr<IPin> input_sink_pin_; |
77 base::win::ScopedComPtr<IPin> output_capture_pin_; | 77 base::win::ScopedComPtr<IPin> output_capture_pin_; |
78 // Used when using a MJPEG decoder. | 78 // Used when using a MJPEG decoder. |
79 base::win::ScopedComPtr<IBaseFilter> mjpg_filter_; | 79 base::win::ScopedComPtr<IBaseFilter> mjpg_filter_; |
80 base::win::ScopedComPtr<IPin> input_mjpg_pin_; | 80 base::win::ScopedComPtr<IPin> input_mjpg_pin_; |
81 base::win::ScopedComPtr<IPin> output_mjpg_pin_; | 81 base::win::ScopedComPtr<IPin> output_mjpg_pin_; |
82 | 82 |
83 scoped_refptr<SinkFilter> sink_filter_; | 83 scoped_refptr<SinkFilter> sink_filter_; |
84 | 84 |
85 // Map of all capabilities this device support. | 85 // Map of all capabilities this device support. |
86 CapabilityMap capabilities_; | 86 CapabilityMap capabilities_; |
87 | 87 |
88 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoCaptureDeviceWin); | 88 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoCaptureDeviceWin); |
89 }; | 89 }; |
90 | 90 |
91 } // namespace media | 91 } // namespace media |
92 | 92 |
93 #endif // MEDIA_VIDEO_CAPTURE_WIN_VIDEO_CAPTURE_DEVICE_WIN_H_ | 93 #endif // MEDIA_VIDEO_CAPTURE_WIN_VIDEO_CAPTURE_DEVICE_WIN_H_ |
OLD | NEW |