| 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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 private: | 105 private: |
| 106 CaptureApiType capture_api_type_; | 106 CaptureApiType capture_api_type_; |
| 107 }; | 107 }; |
| 108 | 108 |
| 109 CaptureApiClass capture_api_class_; | 109 CaptureApiClass capture_api_class_; |
| 110 #endif // if defined(OS_WIN) | 110 #endif // if defined(OS_WIN) |
| 111 // Allow generated copy constructor and assignment. | 111 // Allow generated copy constructor and assignment. |
| 112 }; | 112 }; |
| 113 | 113 |
| 114 // Manages a list of Name entries. | 114 // Manages a list of Name entries. |
| 115 class MEDIA_EXPORT Names | 115 typedef std::list<Name> Names; |
| 116 : public NON_EXPORTED_BASE(std::list<Name>) { | |
| 117 public: | |
| 118 // Returns NULL if no entry was found by that ID. | |
| 119 Name* FindById(const std::string& id); | |
| 120 | |
| 121 // Allow generated copy constructor and assignment. | |
| 122 }; | |
| 123 | 116 |
| 124 class MEDIA_EXPORT Client { | 117 class MEDIA_EXPORT Client { |
| 125 public: | 118 public: |
| 126 // Memory buffer returned by Client::ReserveOutputBuffer(). | 119 // Memory buffer returned by Client::ReserveOutputBuffer(). |
| 127 class Buffer : public base::RefCountedThreadSafe<Buffer> { | 120 class Buffer : public base::RefCountedThreadSafe<Buffer> { |
| 128 public: | 121 public: |
| 129 int id() const { return id_; } | 122 int id() const { return id_; } |
| 130 void* data() const { return data_; } | 123 void* data() const { return data_; } |
| 131 size_t size() const { return size_; } | 124 size_t size() const { return size_; } |
| 132 | 125 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 }; | 187 }; |
| 195 | 188 |
| 196 // Creates a VideoCaptureDevice object. | 189 // Creates a VideoCaptureDevice object. |
| 197 // Return NULL if the hardware is not available. | 190 // Return NULL if the hardware is not available. |
| 198 static VideoCaptureDevice* Create(const Name& device_name); | 191 static VideoCaptureDevice* Create(const Name& device_name); |
| 199 virtual ~VideoCaptureDevice(); | 192 virtual ~VideoCaptureDevice(); |
| 200 | 193 |
| 201 // Gets the names of all video capture devices connected to this computer. | 194 // Gets the names of all video capture devices connected to this computer. |
| 202 static void GetDeviceNames(Names* device_names); | 195 static void GetDeviceNames(Names* device_names); |
| 203 | 196 |
| 204 // Gets the capabilities of a particular device attached to the system. This | 197 // Gets the supported formats of a particular device attached to the system. |
| 205 // method should be called before allocating or starting a device. In case | 198 // This method should be called before allocating or starting a device. In |
| 206 // format enumeration is not supported, or there was a problem, the formats | 199 // case format enumeration is not supported, or there was a problem, the |
| 207 // array will be empty. | 200 // formats array will be empty. |
| 208 static void GetDeviceSupportedFormats(const Name& device, | 201 static void GetDeviceSupportedFormats(const Name& device, |
| 209 VideoCaptureCapabilities* formats); | 202 VideoCaptureFormats* supported_formats); |
| 210 | 203 |
| 211 // Prepare the camera for use. After this function has been called no other | 204 // Prepares the camera for use. After this function has been called no other |
| 212 // applications can use the camera. StopAndDeAllocate() must be called before | 205 // applications can use the camera. StopAndDeAllocate() must be called before |
| 213 // the object is deleted. | 206 // the object is deleted. |
| 214 virtual void AllocateAndStart(const VideoCaptureParams& params, | 207 virtual void AllocateAndStart(const VideoCaptureParams& params, |
| 215 scoped_ptr<Client> client) = 0; | 208 scoped_ptr<Client> client) = 0; |
| 216 | 209 |
| 217 // Deallocates the camera, possibly asynchronously. | 210 // Deallocates the camera, possibly asynchronously. |
| 218 // | 211 // |
| 219 // This call requires the device to do the following things, eventually: put | 212 // This call requires the device to do the following things, eventually: put |
| 220 // camera hardware into a state where other applications could use it, free | 213 // camera hardware into a state where other applications could use it, free |
| 221 // the memory associated with capture, and delete the |client| pointer passed | 214 // the memory associated with capture, and delete the |client| pointer passed |
| 222 // into AllocateAndStart. | 215 // into AllocateAndStart. |
| 223 // | 216 // |
| 224 // If deallocation is done asynchronously, then the device implementation must | 217 // If deallocation is done asynchronously, then the device implementation must |
| 225 // ensure that a subsequent AllocateAndStart() operation targeting the same ID | 218 // ensure that a subsequent AllocateAndStart() operation targeting the same ID |
| 226 // would be sequenced through the same task runner, so that deallocation | 219 // would be sequenced through the same task runner, so that deallocation |
| 227 // happens first. | 220 // happens first. |
| 228 virtual void StopAndDeAllocate() = 0; | 221 virtual void StopAndDeAllocate() = 0; |
| 229 }; | 222 }; |
| 230 | 223 |
| 231 } // namespace media | 224 } // namespace media |
| 232 | 225 |
| 233 #endif // MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURE_DEVICE_H_ | 226 #endif // MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURE_DEVICE_H_ |
| OLD | NEW |