Chromium Code Reviews| 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 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 209 const VideoCaptureFormat& buffer_format, | 209 const VideoCaptureFormat& buffer_format, |
| 210 const scoped_refptr<media::VideoFrame>& frame, | 210 const scoped_refptr<media::VideoFrame>& frame, |
| 211 base::TimeTicks timestamp) = 0; | 211 base::TimeTicks timestamp) = 0; |
| 212 | 212 |
| 213 // An error has occurred that cannot be handled and VideoCaptureDevice must | 213 // An error has occurred that cannot be handled and VideoCaptureDevice must |
| 214 // be StopAndDeAllocate()-ed. |reason| is a text description of the error. | 214 // be StopAndDeAllocate()-ed. |reason| is a text description of the error. |
| 215 virtual void OnError(const std::string& reason) = 0; | 215 virtual void OnError(const std::string& reason) = 0; |
| 216 | 216 |
| 217 // VideoCaptureDevice requests the |message| to be logged. | 217 // VideoCaptureDevice requests the |message| to be logged. |
| 218 virtual void OnLog(const std::string& message) {} | 218 virtual void OnLog(const std::string& message) {} |
| 219 | |
| 220 // The video stream has been muted. After this callback, no more | |
| 221 // OnIncomingCapturedData() will be called. This may happen when | |
| 222 // CaptureImage() is being called. After the still image has been | |
|
wuchengli
2014/09/11 08:50:05
s/is being/has/
80 char alignment. Run git cl for
Owen Lin
2014/09/12 09:07:55
I think git cl won't help us on comment.
| |
| 223 // captured, the video stream will be resumed and the client would be | |
|
wuchengli
2014/09/11 08:50:05
Remove the extra space. I think the order should b
Owen Lin
2014/09/12 09:07:55
Done. Thanks.
| |
| 224 // notified by OnUnmute(). | |
| 225 virtual void OnMute() {} | |
| 226 | |
| 227 // The video stream has resumed. | |
| 228 virtual void OnUnmute() {} | |
| 229 }; | |
| 230 | |
| 231 class MEDIA_EXPORT ImageClient { | |
| 232 public: | |
| 233 virtual ~ImageClient() {} | |
| 234 | |
| 235 // Callback function to notify the client the caputred image is available. | |
| 236 virtual void OnIncomingCapturedData(const uint8* data, | |
| 237 int length, | |
| 238 const ImageCaptureFormat& format, | |
| 239 int rotation, | |
| 240 base::TimeTicks timestamp) = 0; | |
| 241 | |
| 242 // Callback function to notify client the failure of the image capturing. | |
| 243 // The VideoCaptureDevice must be StopAndDeAllocate()-ed. |reason| is a | |
| 244 // text description of the error. | |
| 245 virtual void OnError(const std::string& reason) = 0; | |
| 219 }; | 246 }; |
| 220 | 247 |
| 221 // Creates a VideoCaptureDevice object. | 248 // Creates a VideoCaptureDevice object. |
| 222 // Return NULL if the hardware is not available. | 249 // Return NULL if the hardware is not available. |
| 223 static VideoCaptureDevice* Create( | 250 static VideoCaptureDevice* Create( |
| 224 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, | 251 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, |
| 225 const Name& device_name); | 252 const Name& device_name); |
| 226 virtual ~VideoCaptureDevice(); | 253 virtual ~VideoCaptureDevice(); |
| 227 | 254 |
| 228 // Gets the names of all video capture devices connected to this computer. | 255 // Gets the names of all video capture devices connected to this computer. |
| 229 static void GetDeviceNames(Names* device_names); | 256 static void GetDeviceNames(Names* device_names); |
| 230 | 257 |
| 231 // Gets the supported formats of a particular device attached to the system. | 258 // Gets the supported formats of a particular device attached to the system. |
| 232 // This method should be called before allocating or starting a device. In | 259 // This method should be called before allocating or starting a device. In |
| 233 // case format enumeration is not supported, or there was a problem, the | 260 // case format enumeration is not supported, or there was a problem, the |
| 234 // formats array will be empty. | 261 // formats array will be empty. |
| 235 static void GetDeviceSupportedFormats(const Name& device, | 262 static void GetDeviceSupportedFormats(const Name& device, |
| 236 VideoCaptureFormats* supported_formats); | 263 VideoCaptureFormats* supported_formats); |
| 237 | 264 |
| 265 // Gets the supported formats for still image of a particular device attached | |
| 266 // to the system. | |
| 267 static void GetDeviceSupportedImageFormats( | |
|
wuchengli
2014/09/11 08:50:05
Does this compile? You need to implement it somewh
Owen Lin
2014/09/12 09:07:55
Yes. It compiles. I don't need if no one use it.
| |
| 268 const Name& device, | |
| 269 ImageCaptureFormats* supported_formats); | |
| 270 | |
| 238 // Prepares the camera for use. After this function has been called no other | 271 // Prepares the camera for use. After this function has been called no other |
| 239 // applications can use the camera. StopAndDeAllocate() must be called before | 272 // applications can use the camera. StopAndDeAllocate() must be called before |
| 240 // the object is deleted. | 273 // the object is deleted. |
| 241 virtual void AllocateAndStart(const VideoCaptureParams& params, | 274 virtual void AllocateAndStart(const VideoCaptureParams& params, |
| 242 scoped_ptr<Client> client) = 0; | 275 scoped_ptr<Client> client) = 0; |
| 243 | 276 |
| 244 // Deallocates the camera, possibly asynchronously. | 277 // Deallocates the camera, possibly asynchronously. |
| 245 // | 278 // |
| 246 // This call requires the device to do the following things, eventually: put | 279 // This call requires the device to do the following things, eventually: put |
| 247 // camera hardware into a state where other applications could use it, free | 280 // camera hardware into a state where other applications could use it, free |
| 248 // the memory associated with capture, and delete the |client| pointer passed | 281 // the memory associated with capture, and delete the |client| pointer passed |
| 249 // into AllocateAndStart. | 282 // into AllocateAndStart. |
| 250 // | 283 // |
| 251 // If deallocation is done asynchronously, then the device implementation must | 284 // If deallocation is done asynchronously, then the device implementation must |
| 252 // ensure that a subsequent AllocateAndStart() operation targeting the same ID | 285 // ensure that a subsequent AllocateAndStart() operation targeting the same ID |
| 253 // would be sequenced through the same task runner, so that deallocation | 286 // would be sequenced through the same task runner, so that deallocation |
| 254 // happens first. | 287 // happens first. |
| 255 virtual void StopAndDeAllocate() = 0; | 288 virtual void StopAndDeAllocate() = 0; |
| 256 | 289 |
| 257 // Gets the power line frequency from the current system time zone if this is | 290 // Gets the power line frequency from the current system time zone if this is |
| 258 // defined, otherwise returns 0. | 291 // defined, otherwise returns 0. |
| 259 int GetPowerLineFrequencyForLocation() const; | 292 int GetPowerLineFrequencyForLocation() const; |
| 260 | 293 |
| 294 // Initializes the device for still image capture for the given image format. | |
| 295 // This function must be called between AllocateAndStart() and | |
| 296 // StopAndDeAllocate(). | |
| 297 virtual void InitializeImageCapture(const ImageCaptureFormat& image_format, | |
| 298 scoped_ptr<ImageClient> client) {} | |
| 299 | |
| 300 // Releases resources for image capture. The ImageClient passed from | |
| 301 // InitializeImageCapture would be freed. This method must be called between | |
| 302 // InitializeImageCapture() and StopAndDeAllocate(). | |
| 303 virtual void CloseImageCapture() {} | |
|
wuchengli
2014/09/11 08:50:05
s/CloseImageCapture/ReleaseImageCapture/. Close sh
Owen Lin
2014/09/12 09:07:55
Sure. However, I remember this is the name you sug
| |
| 304 | |
| 305 // Gets one image from the device asynchronously. It will return the image | |
|
wuchengli
2014/09/11 08:50:05
More readable to put a blank line after "asynchron
| |
| 306 // by the ImageClient::OnIncomingCapturedData() callback. | |
| 307 // If the video stream has to be stopped to capture the still image, the | |
| 308 // Client::OnMute() and Client::OnUnmute() will be called. | |
|
wuchengli
2014/09/11 08:50:05
s/Client/ImageClient/
Owen Lin
2014/09/12 09:07:55
It's Client. The callback is go to the client of t
| |
| 309 // | |
| 310 // This function must be called between InitializeImageCapture() and | |
| 311 // CloseImageCapture(). | |
| 312 virtual void CaptureImage() {} | |
| 313 | |
| 261 protected: | 314 protected: |
| 262 static const int kPowerLine50Hz = 50; | 315 static const int kPowerLine50Hz = 50; |
| 263 static const int kPowerLine60Hz = 60; | 316 static const int kPowerLine60Hz = 60; |
| 264 }; | 317 }; |
| 265 | 318 |
| 266 } // namespace media | 319 } // namespace media |
| 267 | 320 |
| 268 #endif // MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURE_DEVICE_H_ | 321 #endif // MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURE_DEVICE_H_ |
| OLD | NEW |