OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/thread.h" | 20 #include "base/threading/thread.h" |
21 #include "base/win/scoped_com_initializer.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/win/sink_filter_win.h" | 25 #include "media/video/capture/win/sink_filter_win.h" |
25 #include "media/video/capture/win/sink_input_pin_win.h" | 26 #include "media/video/capture/win/sink_input_pin_win.h" |
26 | 27 |
27 namespace media { | 28 namespace media { |
28 | 29 |
29 class VideoCaptureDeviceWin | 30 class VideoCaptureDeviceWin |
30 : public VideoCaptureDevice, | 31 : public VideoCaptureDevice, |
31 public SinkFilterObserver { | 32 public SinkFilterObserver { |
32 public: | 33 public: |
33 explicit VideoCaptureDeviceWin(const Name& device_name); | 34 explicit VideoCaptureDeviceWin(const Name& device_name); |
(...skipping 13 matching lines...) Expand all Loading... |
47 virtual const Name& device_name() OVERRIDE; | 48 virtual const Name& device_name() OVERRIDE; |
48 | 49 |
49 private: | 50 private: |
50 enum InternalState { | 51 enum InternalState { |
51 kIdle, // The device driver is opened but camera is not in use. | 52 kIdle, // The device driver is opened but camera is not in use. |
52 kAllocated, // The camera has been allocated and can be started. | 53 kAllocated, // The camera has been allocated and can be started. |
53 kCapturing, // Video is being captured. | 54 kCapturing, // Video is being captured. |
54 kError // Error accessing HW functions. | 55 kError // Error accessing HW functions. |
55 // User needs to recover by destroying the object. | 56 // User needs to recover by destroying the object. |
56 }; | 57 }; |
57 typedef std::map<int, Capability> CapabilityMap; | 58 typedef std::map<int, VideoCaptureCapability> CapabilityMap; |
58 | 59 |
59 // Implements SinkFilterObserver. | 60 // Implements SinkFilterObserver. |
60 virtual void FrameReceived(const uint8* buffer, int length); | 61 virtual void FrameReceived(const uint8* buffer, int length); |
61 | 62 |
62 bool CreateCapabilityMap(); | 63 bool CreateCapabilityMap(); |
63 int GetBestMatchedCapability(int width, int height, int frame_rate); | 64 int GetBestMatchedCapability(int width, int height, int frame_rate); |
64 void SetErrorState(const char* reason); | 65 void SetErrorState(const char* reason); |
65 | 66 |
66 base::win::ScopedCOMInitializer initialize_com_; | 67 base::win::ScopedCOMInitializer initialize_com_; |
67 | 68 |
(...skipping 15 matching lines...) Expand all Loading... |
83 | 84 |
84 // Map of all capabilities this device support. | 85 // Map of all capabilities this device support. |
85 CapabilityMap capabilities_; | 86 CapabilityMap capabilities_; |
86 | 87 |
87 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoCaptureDeviceWin); | 88 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoCaptureDeviceWin); |
88 }; | 89 }; |
89 | 90 |
90 } // namespace media | 91 } // namespace media |
91 | 92 |
92 #endif // MEDIA_VIDEO_CAPTURE_WIN_VIDEO_CAPTURE_DEVICE_WIN_H_ | 93 #endif // MEDIA_VIDEO_CAPTURE_WIN_VIDEO_CAPTURE_DEVICE_WIN_H_ |
OLD | NEW |