Index: media/video/capture/video_capture_device.h |
diff --git a/media/video/capture/video_capture_device.h b/media/video/capture/video_capture_device.h |
index 382dad6cdc461d7d6d20bf04ab8e7e91693ae503..d849155952f6d778fda6b732b3e039de41471f13 100644 |
--- a/media/video/capture/video_capture_device.h |
+++ b/media/video/capture/video_capture_device.h |
@@ -216,6 +216,41 @@ class MEDIA_EXPORT VideoCaptureDevice { |
// VideoCaptureDevice requests the |message| to be logged. |
virtual void OnLog(const std::string& message) {} |
+ |
+ // The video stream has been muted. After this callback, no more |
+ // OnIncomingCapturedData() will be called. This may happen when |
+ // CaptureImage() has called. After the still image captured, the client |
+ // will get notified by OnUnmute() and the video stream will be resumed. |
+ virtual void OnMute() {} |
+ |
+ // The video stream has resumed. |
+ virtual void OnUnmute() {} |
+ }; |
+ |
+ // Interface for clients that use VideoCaptureDevice for taking still images. |
+ class MEDIA_EXPORT ImageClient { |
+ public: |
+ virtual ~ImageClient() {} |
+ |
+ // Callback function to notify the client a captured image is available. |
+ // |
+ // The captured still image is stored at address |data| and is of |length| |
+ // bytes. The format of the frame is described by |format|, and is assumed |
+ // to be tightly packed. The still image should be rotated |rotation| |
+ // degrees clockwise for viewing. |
+ // |
+ // Note that the content in |data| will not be valid after this callback |
+ // returns. Copy the content to use it later. |
+ virtual void OnIncomingCapturedData(const uint8* data, |
+ int length, |
+ const ImageCaptureFormat& format, |
+ int rotation, |
+ base::TimeTicks timestamp) = 0; |
+ |
+ // Callback function to notify the client about a failure of the image |
+ // capture. The VideoCaptureDevice must be StopAndDeAllocate()-ed. |
+ // |reason| contains a text description of the error. |
+ virtual void OnError(const std::string& reason) = 0; |
}; |
// Creates a VideoCaptureDevice object. |
@@ -228,13 +263,20 @@ class MEDIA_EXPORT VideoCaptureDevice { |
// Gets the names of all video capture devices connected to this computer. |
static void GetDeviceNames(Names* device_names); |
- // Gets the supported formats of a particular device attached to the system. |
+ // Gets formats for still image capture supported by a particular |device| |
+ // attached to the system. |
// This method should be called before allocating or starting a device. In |
Pawel Osciak
2014/09/29 00:13:37
What will happen if it's called at a wrong time (i
|
// case format enumeration is not supported, or there was a problem, the |
// formats array will be empty. |
static void GetDeviceSupportedFormats(const Name& device, |
VideoCaptureFormats* supported_formats); |
+ // Gets the supported formats for still image of a particular device attached |
+ // to the system. |
+ static void GetDeviceSupportedImageFormats( |
+ const Name& device, |
+ ImageCaptureFormats* supported_formats); |
+ |
// Prepares the camera for use. After this function has been called no other |
// applications can use the camera. StopAndDeAllocate() must be called before |
// the object is deleted. |
@@ -258,6 +300,30 @@ class MEDIA_EXPORT VideoCaptureDevice { |
// defined, otherwise returns 0. |
int GetPowerLineFrequencyForLocation() const; |
+ // Initializes the device for still image capture for the given image format. |
+ // |
+ // This function must be called between AllocateAndStart() and |
+ // StopAndDeAllocate(). |
+ virtual void InitializeImageCapture(const ImageCaptureFormat& image_format, |
+ scoped_ptr<ImageClient> client) {} |
+ |
+ // Releases resources for image capture. |
+ // |
+ // The ImageClient passed from InitializeImageCapture will be freed. This |
+ // method must be called between InitializeImageCapture() and |
+ // StopAndDeAllocate(). |
+ virtual void ReleaseImageCapture() {} |
+ |
+ // Gets one image from the device asynchronously. |
+ // |
+ // The image will be returned via the ImageClient::OnIncomingCapturedData() |
+ // callback. If the video stream has to be stopped to capture the still image, |
+ // the Client::OnMute() and Client::OnUnmute() will be called. |
+ // |
+ // This function must be called between InitializeImageCapture() and |
+ // ReleaseImageCapture(). |
+ virtual void CaptureImage() {} |
+ |
protected: |
static const int kPowerLine50Hz = 50; |
static const int kPowerLine60Hz = 60; |