Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1316)

Unified Diff: media/video/capture/video_capture_device.h

Issue 545053002: Add still image capture interface for VideoCaptureDevice. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address review comments Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | media/video/capture/video_capture_types.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..5e05ca90581e526753516e4cfd07a67f546bae05 100644
--- a/media/video/capture/video_capture_device.h
+++ b/media/video/capture/video_capture_device.h
@@ -216,6 +216,40 @@ 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
Pawel Osciak 2014/09/23 08:15:57 s/captured/is captured/ So the design is that we
Pawel Osciak 2014/09/23 08:15:58 s/has called/has been called/
Owen Lin 2014/09/24 05:20:03 1. Same as the JS interface. 2. We need preview r
Pawel Osciak 2014/09/25 02:16:20 We should tailor APIs to features/devices they exp
Owen Lin 2014/09/25 05:53:53 Sorry, I still prefer the current design. Let me t
Pawel Osciak 2014/09/29 00:13:36 My suggestion would not be adding new features. Th
+ // will get notified by OnUnmute() and the video stream will be resumed.
+ virtual void OnMute() {}
+
+ // The video stream has resumed.
+ virtual void OnUnmute() {}
+ };
+
+ class MEDIA_EXPORT ImageClient {
Pawel Osciak 2014/09/23 08:15:57 Please add documentation what this class is for.
Owen Lin 2014/09/24 05:20:02 Done.
+ public:
+ virtual ~ImageClient() {}
+
+ // Callback function to notify the client the captured image is available.
Pawel Osciak 2014/09/23 08:15:57 s/the/a/
Owen Lin 2014/09/24 05:20:03 Done.
+ //
+ // The captured still image is stored at address |data| and of |length|
Pawel Osciak 2014/09/23 08:15:57 s/of/is of/
Owen Lin 2014/09/24 05:20:02 Done.
+ // bytes. The format of the frame is described by |format|, and is assumed
+ // to be tightly/ packed. The still image should be rotated for |rotation|
wuchengli 2014/09/23 07:09:22 remove extra / after tightly
Pawel Osciak 2014/09/23 08:15:57 s/should/is/ I think? s/for//
Owen Lin 2014/09/24 05:20:02 Done.
Owen Lin 2014/09/24 05:20:03 There is no rotation information in the raw data.
Pawel Osciak 2014/09/25 02:16:20 So you mean the image doesn't contain EXIF informa
Owen Lin 2014/09/25 05:53:53 It's YUV so there is no rotation info. The rotatio
Pawel Osciak 2014/09/29 00:13:37 Sorry, what should we do? If there is no rotation
+ // degrees clockwise for viewing.
+ //
+ // Note that the content in |data| would be freed after this callback.
Pawel Osciak 2014/09/23 08:15:57 s/would be freed/will not be valid/ s/callback/cal
Owen Lin 2014/09/24 05:20:02 Done.
+ // Copy the content to use it later.
+ virtual void OnIncomingCapturedData(const uint8* data,
+ int length,
Pawel Osciak 2014/09/23 08:15:57 s/int/size_t/
Owen Lin 2014/09/24 05:20:02 For consistency with Client::OnIncomingCaptureData
Pawel Osciak 2014/09/25 02:16:21 I don't believe we need this consistency. We have
Owen Lin 2014/09/25 05:53:53 Done.
+ const ImageCaptureFormat& format,
+ int rotation, // Clockwise
Pawel Osciak 2014/09/23 08:15:57 Perhaps remove the comment, it's already in the do
Owen Lin 2014/09/24 05:20:03 Done.
+ base::TimeTicks timestamp) = 0;
+
+ // Callback function to notify client the failure of the image capture.
Pawel Osciak 2014/09/23 08:15:57 s/client/the client/ s/the failure/about a failure
Owen Lin 2014/09/24 05:20:03 Done.
+ // The VideoCaptureDevice must be StopAndDeAllocate()-ed. |reason| is a
Pawel Osciak 2014/09/23 08:15:57 s/is/contains/
Owen Lin 2014/09/24 05:20:03 Done.
+ // text description of the error.
+ virtual void OnError(const std::string& reason) = 0;
};
// Creates a VideoCaptureDevice object.
@@ -235,6 +269,12 @@ class MEDIA_EXPORT VideoCaptureDevice {
static void GetDeviceSupportedFormats(const Name& device,
VideoCaptureFormats* supported_formats);
+ // Gets the supported formats for still image of a particular device attached
Pawel Osciak 2014/09/23 08:15:56 Gets formats for still image capture supported by
Owen Lin 2014/09/24 05:20:03 Done.
+ // 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 +298,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().
Pawel Osciak 2014/09/23 08:15:57 Why do we have this requirement?
Owen Lin 2014/09/24 05:20:02 We need the preview on before taking a picture to
Pawel Osciak 2014/09/29 00:13:36 What will happen if it's called at a wrong time (i
+ virtual void InitializeImageCapture(const ImageCaptureFormat& image_format,
Pawel Osciak 2014/09/23 08:15:57 I think we need to have a bool return in case this
Owen Lin 2014/09/24 05:20:03 Fail will be reported by ImageClient::onError().
Pawel Osciak 2014/09/25 02:16:20 I'm assuming you need Initialize to be asynchronou
Owen Lin 2014/09/25 05:53:53 Good point. Let me make this synchronous.
+ scoped_ptr<ImageClient> client) {}
+
+ // Releases resources for image capture.
+ //
+ // The ImageClient passed from InitializeImageCapture would be freed. This
Pawel Osciak 2014/09/23 08:15:57 s/would/will/
+ // method must be called between InitializeImageCapture() and
Pawel Osciak 2014/09/29 00:13:37 What will happen if it's called at a wrong time (i
+ // StopAndDeAllocate().
+ virtual void ReleaseImageCapture() {}
+
+ // Gets one image from the device asynchronously.
Pawel Osciak 2014/09/23 08:15:57 Asynchronously to what?
Owen Lin 2014/09/24 05:20:03 Did I misuse it ? Asynchronously to this function.
Pawel Osciak 2014/09/25 02:16:20 You should probably say Request instead of Get.
Owen Lin 2014/09/25 05:53:53 Thanks.
+ //
+ // It will return the image by the ImageClient::OnIncomingCapturedData()
Pawel Osciak 2014/09/23 08:15:56 s/It will return the image by/The image will be re
Owen Lin 2014/09/25 05:53:53 Done.
+ // 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
Pawel Osciak 2014/09/23 08:15:57 Why this requirement?
Owen Lin 2014/09/24 05:20:03 It's the life time of the image_client instance.
Pawel Osciak 2014/09/29 00:13:36 What will happen if that's not the case (in terms
+ // ReleaseImageCapture().
+ virtual void CaptureImage() {}
+
protected:
static const int kPowerLine50Hz = 50;
static const int kPowerLine60Hz = 60;
« no previous file with comments | « no previous file | media/video/capture/video_capture_types.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698