OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
Pawel Osciak
2014/09/17 11:29:42
Please add a more detailed explanation to the CL d
Owen Lin
2014/09/18 06:04:15
CL description updated.
I have another CL for add
| |
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. |
11 | 11 |
(...skipping 197 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() has called. After the still image has been captured, the | |
perkj_chrome
2014/09/17 11:25:58
s has been
Pawel Osciak
2014/09/17 11:29:42
s/has called/was called/
Is there any other case t
Owen Lin
2014/09/18 06:04:15
Hi, Pawel, I was thinking if the implementation do
| |
223 // client will get notified by OnUnmute() and the video stream will be | |
224 // resumed. | |
225 virtual void OnMute() {} | |
226 | |
227 // The video stream has resumed. | |
228 virtual void OnUnmute() {} | |
229 }; | |
230 | |
231 class MEDIA_EXPORT ImageClient { | |
Pawel Osciak
2014/09/17 11:29:42
StillImageClient here and everywhere?
wuchengli
2014/09/18 01:26:39
Image is symmetric to video. For example, ImageCap
| |
232 public: | |
233 virtual ~ImageClient() {} | |
234 | |
235 // Callback function to notify the client the caputred image is available. | |
Pawel Osciak
2014/09/17 11:29:42
s/caputred/captured
Owen Lin
2014/09/18 06:04:15
Done.
| |
236 virtual void OnIncomingCapturedData(const uint8* data, | |
Pawel Osciak
2014/09/17 11:29:42
Let's call this differently, in case one class wan
Owen Lin
2014/09/18 06:04:15
It is unlikely to happen. Both function "AllocateA
| |
237 int length, | |
238 const ImageCaptureFormat& format, | |
239 int rotation, | |
Pawel Osciak
2014/09/17 11:29:42
Please specify the parameters in the doc above.
Owen Lin
2014/09/18 06:04:15
Done.
| |
240 base::TimeTicks timestamp) = 0; | |
241 | |
242 // Callback function to notify client the failure of the image capture. | |
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; | |
wuchengli
2014/09/17 06:54:29
OK. Let's keep this for now. PPAPI uses the error
Pawel Osciak
2014/09/17 11:29:42
I'm wondering if we need to have a separate OnErro
wuchengli
2014/09/18 01:26:39
One thing to consider is we'll soon add doAutoFocu
Owen Lin
2014/09/18 06:04:15
Good point. I was thinking that. The main reason I
wuchengli
2014/09/18 08:55:08
I think having ImageClient interface is more consi
| |
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( | |
Pawel Osciak
2014/09/17 11:29:42
StillImageFormats?
Owen Lin
2014/09/18 06:04:15
Let's keep using Image for consistency.
| |
268 const Name& device, | |
269 ImageCaptureFormats* supported_formats); | |
Pawel Osciak
2014/09/17 11:29:42
What is the expectation for lifetime/ownership of
Owen Lin
2014/09/18 06:04:15
ImageCaputreFormats is actullay a vector<ImageCapt
| |
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 // | |
296 // This function must be called between AllocateAndStart() and | |
297 // StopAndDeAllocate(). | |
298 virtual void InitializeImageCapture(const ImageCaptureFormat& image_format, | |
299 scoped_ptr<ImageClient> client) {} | |
300 | |
301 // Releases resources for image capture. | |
302 // | |
303 // The ImageClient passed from InitializeImageCapture would be freed. This | |
304 // method must be called between InitializeImageCapture() and | |
305 // StopAndDeAllocate(). | |
306 virtual void ReleaseImageCapture() {} | |
307 | |
308 // Gets one image from the device asynchronously. | |
309 // | |
310 // It will return the image by the ImageClient::OnIncomingCapturedData() | |
311 // callback. If the video stream has to be stopped to capture the still image, | |
312 // the Client::OnMute() and Client::OnUnmute() will be called. | |
313 // | |
314 // This function must be called between InitializeImageCapture() and | |
315 // ReleaseImageCapture(). | |
316 virtual void CaptureImage() {} | |
317 | |
261 protected: | 318 protected: |
262 static const int kPowerLine50Hz = 50; | 319 static const int kPowerLine50Hz = 50; |
263 static const int kPowerLine60Hz = 60; | 320 static const int kPowerLine60Hz = 60; |
264 }; | 321 }; |
265 | 322 |
266 } // namespace media | 323 } // namespace media |
267 | 324 |
268 #endif // MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURE_DEVICE_H_ | 325 #endif // MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURE_DEVICE_H_ |
OLD | NEW |