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 is being muted. After this callback, no more | |
wuchengli
2014/09/09 05:53:22
s/is being/has/
Owen Lin
2014/09/11 06:17:59
Done.
| |
221 // OnIncomingCapturedData() will be called. | |
wuchengli
2014/09/09 05:53:21
Explain OnMute and OnUnmute are called when image
Owen Lin
2014/09/11 06:17:59
Done.
| |
222 virtual void OnMute() {} | |
223 | |
224 // The video stream is being resumed. | |
wuchengli
2014/09/09 05:53:22
s/is being/has/
Owen Lin
2014/09/11 06:18:00
Done.
| |
225 virtual void OnUnmute() {} | |
226 }; | |
227 | |
228 class MEDIA_EXPORT ImageClient { | |
229 public: | |
230 virtual ~ImageClient() {} | |
231 | |
232 // Callback function to notify the client the caputred image is available. | |
233 virtual void OnIncomingCapturedData(const uint8* data, | |
234 int length, | |
235 const ImageCaptureFormat& format, | |
236 int rotation, | |
237 base::TimeTicks timestamp) = 0; | |
238 | |
239 // Callback function to notify client the failure of the image capturing. | |
240 // The VideoCaptureDevice must be StopAndDeAllocate()-ed. |reason| is a | |
wuchengli
2014/09/09 05:53:22
s/StopAndDeAllocate/CloseImageCapture/
Owen Lin
2014/09/11 06:17:59
I do mean StopAndDeallocate. In the current implem
| |
241 // text description of the error. | |
242 virtual void OnError(const std::string& reason) = 0; | |
219 }; | 243 }; |
220 | 244 |
221 // Creates a VideoCaptureDevice object. | 245 // Creates a VideoCaptureDevice object. |
222 // Return NULL if the hardware is not available. | 246 // Return NULL if the hardware is not available. |
223 static VideoCaptureDevice* Create( | 247 static VideoCaptureDevice* Create( |
224 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, | 248 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, |
225 const Name& device_name); | 249 const Name& device_name); |
226 virtual ~VideoCaptureDevice(); | 250 virtual ~VideoCaptureDevice(); |
227 | 251 |
228 // Gets the names of all video capture devices connected to this computer. | 252 // Gets the names of all video capture devices connected to this computer. |
229 static void GetDeviceNames(Names* device_names); | 253 static void GetDeviceNames(Names* device_names); |
230 | 254 |
231 // Gets the supported formats of a particular device attached to the system. | 255 // 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 | 256 // 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 | 257 // case format enumeration is not supported, or there was a problem, the |
234 // formats array will be empty. | 258 // formats array will be empty. |
235 static void GetDeviceSupportedFormats(const Name& device, | 259 static void GetDeviceSupportedFormats(const Name& device, |
236 VideoCaptureFormats* supported_formats); | 260 VideoCaptureFormats* supported_formats); |
237 | 261 |
262 // Gets the supported formats for still image of a particular device attached | |
263 // to the system. | |
264 static void GetDeviceSupportedImageFormats( | |
265 const Name& device, | |
266 ImageCaptureFormats* supported_formats); | |
267 | |
238 // Prepares the camera for use. After this function has been called no other | 268 // Prepares the camera for use. After this function has been called no other |
239 // applications can use the camera. StopAndDeAllocate() must be called before | 269 // applications can use the camera. StopAndDeAllocate() must be called before |
240 // the object is deleted. | 270 // the object is deleted. |
241 virtual void AllocateAndStart(const VideoCaptureParams& params, | 271 virtual void AllocateAndStart(const VideoCaptureParams& params, |
242 scoped_ptr<Client> client) = 0; | 272 scoped_ptr<Client> client) = 0; |
243 | 273 |
244 // Deallocates the camera, possibly asynchronously. | 274 // Deallocates the camera, possibly asynchronously. |
245 // | 275 // |
246 // This call requires the device to do the following things, eventually: put | 276 // 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 | 277 // camera hardware into a state where other applications could use it, free |
248 // the memory associated with capture, and delete the |client| pointer passed | 278 // the memory associated with capture, and delete the |client| pointer passed |
249 // into AllocateAndStart. | 279 // into AllocateAndStart. |
250 // | 280 // |
251 // If deallocation is done asynchronously, then the device implementation must | 281 // If deallocation is done asynchronously, then the device implementation must |
252 // ensure that a subsequent AllocateAndStart() operation targeting the same ID | 282 // ensure that a subsequent AllocateAndStart() operation targeting the same ID |
253 // would be sequenced through the same task runner, so that deallocation | 283 // would be sequenced through the same task runner, so that deallocation |
254 // happens first. | 284 // happens first. |
255 virtual void StopAndDeAllocate() = 0; | 285 virtual void StopAndDeAllocate() = 0; |
256 | 286 |
257 // Gets the power line frequency from the current system time zone if this is | 287 // Gets the power line frequency from the current system time zone if this is |
258 // defined, otherwise returns 0. | 288 // defined, otherwise returns 0. |
259 int GetPowerLineFrequencyForLocation() const; | 289 int GetPowerLineFrequencyForLocation() const; |
260 | 290 |
291 // Initializes the device for still image capture for the given image format. | |
292 // This function is used to allocate resources. | |
wuchengli
2014/09/09 05:53:22
Does the caller require to start the video stream
Owen Lin
2014/09/11 06:17:59
Yes. Comment added.
| |
293 virtual void InitializeImageCapture(const ImageCaptureFormat& image_format, | |
wuchengli
2014/09/09 05:53:22
Using AllocateImageCapture and DeAllocateImageCapt
Owen Lin
2014/09/11 06:17:59
The problem is we may not really allocate resource
| |
294 scoped_ptr<ImageClient> client); | |
295 | |
296 // Releases used resources for image capture. | |
wuchengli
2014/09/09 05:53:22
s/used//
Does CloseImageCapture have to be called
Owen Lin
2014/09/11 06:18:00
Command added. It has to be called before StopAndD
| |
297 virtual void CloseImageCapture() {} | |
298 | |
299 // Gets one image from the device. It will returne the picture by the | |
wuchengli
2014/09/09 05:53:21
s/returne/return/. s/picture/image/.
Owen Lin
2014/09/11 06:18:00
Done.
| |
300 // ImageClient's OnIncomingCapturedData() callback. | |
wuchengli
2014/09/09 05:53:21
ImageClient::OnIncomingCapturedData(). Also mentio
Owen Lin
2014/09/11 06:17:59
Done.
| |
301 // | |
302 // This function must be called between InitializeImageCapture() and | |
303 // CloseImageCapture(). | |
304 virtual void CaptureImage() {} | |
305 | |
261 protected: | 306 protected: |
262 static const int kPowerLine50Hz = 50; | 307 static const int kPowerLine50Hz = 50; |
263 static const int kPowerLine60Hz = 60; | 308 static const int kPowerLine60Hz = 60; |
264 }; | 309 }; |
265 | 310 |
266 } // namespace media | 311 } // namespace media |
267 | 312 |
268 #endif // MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURE_DEVICE_H_ | 313 #endif // MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURE_DEVICE_H_ |
OLD | NEW |