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 // VideoCaptureDevice is the abstract base class for realizing video capture | 5 // VideoCaptureDevice is the abstract base class for realizing video capture |
6 // device support in Chromium. It provides the interface for OS dependent | 6 // device support in Chromium. It provides the interface for OS dependent |
7 // implementations. | 7 // implementations. |
8 // The class is created and functions are invoked on a thread owned by | 8 // The class is created and functions are invoked on a thread owned by |
9 // VideoCaptureManager. Capturing is done on other threads, depending on the OS | 9 // VideoCaptureManager. Capturing is done on other threads, depending on the OS |
10 // specific implementation. | 10 // specific implementation. |
(...skipping 16 matching lines...) Expand all Loading... |
27 // Represents a capture device name and ID. | 27 // Represents a capture device name and ID. |
28 // You should not create an instance of this class directly by e.g. setting | 28 // You should not create an instance of this class directly by e.g. setting |
29 // various properties directly. Instead use | 29 // various properties directly. Instead use |
30 // VideoCaptureDevice::GetDeviceNames to do this for you and if you need to | 30 // VideoCaptureDevice::GetDeviceNames to do this for you and if you need to |
31 // cache your own copy of a name, you can do so via the copy constructor. | 31 // cache your own copy of a name, you can do so via the copy constructor. |
32 // The reason for this is that a device name might contain platform specific | 32 // The reason for this is that a device name might contain platform specific |
33 // settings that are relevant only to the platform specific implementation of | 33 // settings that are relevant only to the platform specific implementation of |
34 // VideoCaptureDevice::Create. | 34 // VideoCaptureDevice::Create. |
35 class MEDIA_EXPORT Name { | 35 class MEDIA_EXPORT Name { |
36 public: | 36 public: |
37 Name() {} | 37 Name(); |
38 Name(const std::string& name, const std::string& id) | 38 Name(const std::string& name, const std::string& id); |
39 : device_name_(name), unique_id_(id) {} | |
40 | 39 |
41 #if defined(OS_WIN) | 40 #if defined(OS_WIN) |
42 // Windows targets Capture Api type: it can only be set on construction. | 41 // Windows targets Capture Api type: it can only be set on construction. |
43 enum CaptureApiType { | 42 enum CaptureApiType { |
44 MEDIA_FOUNDATION, | 43 MEDIA_FOUNDATION, |
45 DIRECT_SHOW, | 44 DIRECT_SHOW, |
46 API_TYPE_UNKNOWN | 45 API_TYPE_UNKNOWN |
47 }; | 46 }; |
48 | 47 |
49 Name(const std::string& name, | 48 Name(const std::string& name, |
50 const std::string& id, | 49 const std::string& id, |
51 const CaptureApiType api_type) | 50 const CaptureApiType api_type) |
52 : device_name_(name), unique_id_(id), capture_api_class_(api_type) {} | 51 : device_name_(name), unique_id_(id), capture_api_class_(api_type) {} |
53 #endif // if defined(OS_WIN) | 52 #endif // if defined(OS_WIN) |
54 ~Name() {} | 53 ~Name(); |
55 | 54 |
56 // Friendly name of a device | 55 // Friendly name of a device |
57 const std::string& name() const { return device_name_; } | 56 const std::string& name() const { return device_name_; } |
58 | 57 |
59 // Unique name of a device. Even if there are multiple devices with the same | 58 // Unique name of a device. Even if there are multiple devices with the same |
60 // friendly name connected to the computer this will be unique. | 59 // friendly name connected to the computer this will be unique. |
61 const std::string& id() const { return unique_id_; } | 60 const std::string& id() const { return unique_id_; } |
62 | 61 |
63 // The unique hardware model identifier of the capture device. Returns | 62 // The unique hardware model identifier of the capture device. Returns |
64 // "[vid]:[pid]" when a USB device is detected, otherwise "". | 63 // "[vid]:[pid]" when a USB device is detected, otherwise "". |
(...skipping 15 matching lines...) Expand all Loading... |
80 | 79 |
81 #if defined(OS_WIN) | 80 #if defined(OS_WIN) |
82 CaptureApiType capture_api_type() const { | 81 CaptureApiType capture_api_type() const { |
83 return capture_api_class_.capture_api_type(); | 82 return capture_api_class_.capture_api_type(); |
84 } | 83 } |
85 #endif // if defined(OS_WIN) | 84 #endif // if defined(OS_WIN) |
86 | 85 |
87 private: | 86 private: |
88 std::string device_name_; | 87 std::string device_name_; |
89 std::string unique_id_; | 88 std::string unique_id_; |
| 89 VideoCaptureCapabilities capture_formats_; |
| 90 |
90 #if defined(OS_WIN) | 91 #if defined(OS_WIN) |
91 // This class wraps the CaptureApiType, so it has a by default value if not | 92 // This class wraps the CaptureApiType, so it has a by default value if not |
92 // inititalized, and I (mcasas) do a DCHECK on reading its value. | 93 // inititalized, and I (mcasas) do a DCHECK on reading its value. |
93 class CaptureApiClass { | 94 class CaptureApiClass { |
94 public: | 95 public: |
95 CaptureApiClass(): capture_api_type_(API_TYPE_UNKNOWN) {} | 96 CaptureApiClass(): capture_api_type_(API_TYPE_UNKNOWN) {} |
96 CaptureApiClass(const CaptureApiType api_type) | 97 CaptureApiClass(const CaptureApiType api_type) |
97 : capture_api_type_(api_type) {} | 98 : capture_api_type_(api_type) {} |
98 CaptureApiType capture_api_type() const { | 99 CaptureApiType capture_api_type() const { |
99 DCHECK_NE(capture_api_type_, API_TYPE_UNKNOWN); | 100 DCHECK_NE(capture_api_type_, API_TYPE_UNKNOWN); |
100 return capture_api_type_; | 101 return capture_api_type_; |
101 } | 102 } |
102 private: | 103 private: |
103 CaptureApiType capture_api_type_; | 104 CaptureApiType capture_api_type_; |
104 }; | 105 }; |
105 | 106 |
106 CaptureApiClass capture_api_class_; | 107 CaptureApiClass capture_api_class_; |
107 #endif // if defined(OS_WIN) | 108 #endif // if defined(OS_WIN) |
| 109 |
108 // Allow generated copy constructor and assignment. | 110 // Allow generated copy constructor and assignment. |
109 }; | 111 }; |
110 | 112 |
111 // Manages a list of Name entries. | 113 // Manages a list of Name entries. |
112 class MEDIA_EXPORT Names | 114 class MEDIA_EXPORT Names |
113 : public NON_EXPORTED_BASE(std::list<Name>) { | 115 : public NON_EXPORTED_BASE(std::list<Name>) { |
114 public: | 116 public: |
115 // Returns NULL if no entry was found by that ID. | 117 // Returns NULL if no entry was found by that ID. |
116 Name* FindById(const std::string& id); | 118 Name* FindById(const std::string& id); |
117 | 119 |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 // If deallocation is done asynchronously, then the device implementation must | 217 // If deallocation is done asynchronously, then the device implementation must |
216 // ensure that a subsequent AllocateAndStart() operation targeting the same ID | 218 // ensure that a subsequent AllocateAndStart() operation targeting the same ID |
217 // would be sequenced through the same task runner, so that deallocation | 219 // would be sequenced through the same task runner, so that deallocation |
218 // happens first. | 220 // happens first. |
219 virtual void StopAndDeAllocate() = 0; | 221 virtual void StopAndDeAllocate() = 0; |
220 }; | 222 }; |
221 | 223 |
222 } // namespace media | 224 } // namespace media |
223 | 225 |
224 #endif // MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURE_DEVICE_H_ | 226 #endif // MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURE_DEVICE_H_ |
OLD | NEW |