| 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 23 matching lines...) Expand all Loading... |
| 34 // VideoCaptureDevice::GetDeviceNames to do this for you and if you need to | 34 // VideoCaptureDevice::GetDeviceNames to do this for you and if you need to |
| 35 // cache your own copy of a name, you can do so via the copy constructor. | 35 // cache your own copy of a name, you can do so via the copy constructor. |
| 36 // The reason for this is that a device name might contain platform specific | 36 // The reason for this is that a device name might contain platform specific |
| 37 // settings that are relevant only to the platform specific implementation of | 37 // settings that are relevant only to the platform specific implementation of |
| 38 // VideoCaptureDevice::Create. | 38 // VideoCaptureDevice::Create. |
| 39 class MEDIA_EXPORT Name { | 39 class MEDIA_EXPORT Name { |
| 40 public: | 40 public: |
| 41 Name(); | 41 Name(); |
| 42 Name(const std::string& name, const std::string& id); | 42 Name(const std::string& name, const std::string& id); |
| 43 | 43 |
| 44 #if defined(OS_LINUX) | 44 #if defined(OS_WIN) |
| 45 // Linux/CrOS targets Capture Api type: it can only be set on construction. | |
| 46 enum CaptureApiType { | |
| 47 V4L2_SINGLE_PLANE, | |
| 48 V4L2_MULTI_PLANE, | |
| 49 API_TYPE_UNKNOWN | |
| 50 }; | |
| 51 #elif defined(OS_WIN) | |
| 52 // Windows targets Capture Api type: it can only be set on construction. | 45 // Windows targets Capture Api type: it can only be set on construction. |
| 53 enum CaptureApiType { | 46 enum CaptureApiType { |
| 54 MEDIA_FOUNDATION, | 47 MEDIA_FOUNDATION, |
| 55 DIRECT_SHOW, | 48 DIRECT_SHOW, |
| 56 DIRECT_SHOW_WDM_CROSSBAR, | 49 DIRECT_SHOW_WDM_CROSSBAR, |
| 57 API_TYPE_UNKNOWN | 50 API_TYPE_UNKNOWN |
| 58 }; | 51 }; |
| 59 #elif defined(OS_MACOSX) | 52 #endif |
| 53 #if defined(OS_MACOSX) |
| 60 // Mac targets Capture Api type: it can only be set on construction. | 54 // Mac targets Capture Api type: it can only be set on construction. |
| 61 enum CaptureApiType { | 55 enum CaptureApiType { |
| 62 AVFOUNDATION, | 56 AVFOUNDATION, |
| 63 QTKIT, | 57 QTKIT, |
| 64 DECKLINK, | 58 DECKLINK, |
| 65 API_TYPE_UNKNOWN | 59 API_TYPE_UNKNOWN |
| 66 }; | 60 }; |
| 67 // For AVFoundation Api, identify devices that are built-in or USB. | 61 // For AVFoundation Api, identify devices that are built-in or USB. |
| 68 enum TransportType { | 62 enum TransportType { |
| 69 USB_OR_BUILT_IN, | 63 USB_OR_BUILT_IN, |
| 70 OTHER_TRANSPORT | 64 OTHER_TRANSPORT |
| 71 }; | 65 }; |
| 72 #endif | 66 #endif |
| 73 #if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_LINUX) | 67 #if defined(OS_WIN) || defined(OS_MACOSX) |
| 74 Name(const std::string& name, | 68 Name(const std::string& name, |
| 75 const std::string& id, | 69 const std::string& id, |
| 76 const CaptureApiType api_type); | 70 const CaptureApiType api_type); |
| 77 #endif | 71 #endif |
| 78 #if defined(OS_MACOSX) | 72 #if defined(OS_MACOSX) |
| 79 Name(const std::string& name, | 73 Name(const std::string& name, |
| 80 const std::string& id, | 74 const std::string& id, |
| 81 const CaptureApiType api_type, | 75 const CaptureApiType api_type, |
| 82 const TransportType transport_type); | 76 const TransportType transport_type); |
| 83 #endif | 77 #endif |
| (...skipping 17 matching lines...) Expand all Loading... |
| 101 // These operators are needed due to storing the name in an STL container. | 95 // These operators are needed due to storing the name in an STL container. |
| 102 // In the shared build, all methods from the STL container will be exported | 96 // In the shared build, all methods from the STL container will be exported |
| 103 // so even though they're not used, they're still depended upon. | 97 // so even though they're not used, they're still depended upon. |
| 104 bool operator==(const Name& other) const { | 98 bool operator==(const Name& other) const { |
| 105 return other.id() == unique_id_; | 99 return other.id() == unique_id_; |
| 106 } | 100 } |
| 107 bool operator<(const Name& other) const { | 101 bool operator<(const Name& other) const { |
| 108 return unique_id_ < other.id(); | 102 return unique_id_ < other.id(); |
| 109 } | 103 } |
| 110 | 104 |
| 111 #if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_LINUX) | 105 #if defined(OS_WIN) || defined(OS_MACOSX) |
| 112 CaptureApiType capture_api_type() const { | 106 CaptureApiType capture_api_type() const { |
| 113 return capture_api_class_.capture_api_type(); | 107 return capture_api_class_.capture_api_type(); |
| 114 } | 108 } |
| 115 const char* GetCaptureApiTypeString() const; | 109 const char* GetCaptureApiTypeString() const; |
| 116 #endif | 110 #endif |
| 117 #if defined(OS_WIN) | 111 #if defined(OS_WIN) |
| 118 // Certain devices need an ID different from the |unique_id_| for | 112 // Certain devices need an ID different from the |unique_id_| for |
| 119 // capabilities retrieval. | 113 // capabilities retrieval. |
| 120 const std::string& capabilities_id() const { | 114 const std::string& capabilities_id() const { |
| 121 return capabilities_id_; | 115 return capabilities_id_; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 132 return is_blacklisted_; | 126 return is_blacklisted_; |
| 133 } | 127 } |
| 134 void set_is_blacklisted(bool is_blacklisted) { | 128 void set_is_blacklisted(bool is_blacklisted) { |
| 135 is_blacklisted_ = is_blacklisted; | 129 is_blacklisted_ = is_blacklisted; |
| 136 } | 130 } |
| 137 #endif // if defined(OS_WIN) | 131 #endif // if defined(OS_WIN) |
| 138 | 132 |
| 139 private: | 133 private: |
| 140 std::string device_name_; | 134 std::string device_name_; |
| 141 std::string unique_id_; | 135 std::string unique_id_; |
| 142 #if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_LINUX) | 136 #if defined(OS_WIN) || defined(OS_MACOSX) |
| 143 // This class wraps the CaptureApiType to give it a by default value if not | 137 // This class wraps the CaptureApiType to give it a by default value if not |
| 144 // initialized. | 138 // initialized. |
| 145 class CaptureApiClass { | 139 class CaptureApiClass { |
| 146 public: | 140 public: |
| 147 CaptureApiClass(): capture_api_type_(API_TYPE_UNKNOWN) {} | 141 CaptureApiClass(): capture_api_type_(API_TYPE_UNKNOWN) {} |
| 148 CaptureApiClass(const CaptureApiType api_type) | 142 CaptureApiClass(const CaptureApiType api_type) |
| 149 : capture_api_type_(api_type) {} | 143 : capture_api_type_(api_type) {} |
| 150 CaptureApiType capture_api_type() const { | 144 CaptureApiType capture_api_type() const { |
| 151 DCHECK_NE(capture_api_type_, API_TYPE_UNKNOWN); | 145 DCHECK_NE(capture_api_type_, API_TYPE_UNKNOWN); |
| 152 return capture_api_type_; | 146 return capture_api_type_; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 | 188 |
| 195 // Captured a new video frame, data for which is pointed to by |data|. | 189 // Captured a new video frame, data for which is pointed to by |data|. |
| 196 // | 190 // |
| 197 // The format of the frame is described by |frame_format|, and is assumed to | 191 // The format of the frame is described by |frame_format|, and is assumed to |
| 198 // be tightly packed. This method will try to reserve an output buffer and | 192 // be tightly packed. This method will try to reserve an output buffer and |
| 199 // copy from |data| into the output buffer. If no output buffer is | 193 // copy from |data| into the output buffer. If no output buffer is |
| 200 // available, the frame will be silently dropped. | 194 // available, the frame will be silently dropped. |
| 201 virtual void OnIncomingCapturedData(const uint8* data, | 195 virtual void OnIncomingCapturedData(const uint8* data, |
| 202 int length, | 196 int length, |
| 203 const VideoCaptureFormat& frame_format, | 197 const VideoCaptureFormat& frame_format, |
| 204 int clockwise_rotation, | 198 int rotation, // Clockwise. |
| 205 const base::TimeTicks& timestamp) = 0; | 199 const base::TimeTicks& timestamp) = 0; |
| 206 | 200 |
| 207 // Captured a 3 planar YUV frame. Planes are possibly disjoint. | |
| 208 // |frame_format| must indicate I420. | |
| 209 virtual void OnIncomingCapturedYuvData( | |
| 210 const uint8* y_data, | |
| 211 const uint8* u_data, | |
| 212 const uint8* v_data, | |
| 213 size_t y_stride, | |
| 214 size_t u_stride, | |
| 215 size_t v_stride, | |
| 216 const VideoCaptureFormat& frame_format, | |
| 217 int clockwise_rotation, | |
| 218 const base::TimeTicks& timestamp) = 0; | |
| 219 | |
| 220 // Reserve an output buffer into which contents can be captured directly. | 201 // Reserve an output buffer into which contents can be captured directly. |
| 221 // The returned Buffer will always be allocated with a memory size suitable | 202 // The returned Buffer will always be allocated with a memory size suitable |
| 222 // for holding a packed video frame with pixels of |format| format, of | 203 // for holding a packed video frame with pixels of |format| format, of |
| 223 // |dimensions| frame dimensions. It is permissible for |dimensions| to be | 204 // |dimensions| frame dimensions. It is permissible for |dimensions| to be |
| 224 // zero; in which case the returned Buffer does not guarantee memory | 205 // zero; in which case the returned Buffer does not guarantee memory |
| 225 // backing, but functions as a reservation for external input for the | 206 // backing, but functions as a reservation for external input for the |
| 226 // purposes of buffer throttling. | 207 // purposes of buffer throttling. |
| 227 // | 208 // |
| 228 // The output buffer stays reserved for use until the Buffer object is | 209 // The output buffer stays reserved for use until the Buffer object is |
| 229 // destroyed. | 210 // destroyed. |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 int GetPowerLineFrequencyForLocation() const; | 256 int GetPowerLineFrequencyForLocation() const; |
| 276 | 257 |
| 277 protected: | 258 protected: |
| 278 static const int kPowerLine50Hz = 50; | 259 static const int kPowerLine50Hz = 50; |
| 279 static const int kPowerLine60Hz = 60; | 260 static const int kPowerLine60Hz = 60; |
| 280 }; | 261 }; |
| 281 | 262 |
| 282 } // namespace media | 263 } // namespace media |
| 283 | 264 |
| 284 #endif // MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURE_DEVICE_H_ | 265 #endif // MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURE_DEVICE_H_ |
| OLD | NEW |