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 2e60256a8f121f232b950e750391ac640b9e8484..7734788878da3df5a745f5942a347132ec7411e2 100644 |
--- a/media/video/capture/video_capture_device.h |
+++ b/media/video/capture/video_capture_device.h |
@@ -120,22 +120,36 @@ class MEDIA_EXPORT VideoCaptureDevice { |
class MEDIA_EXPORT Client { |
public: |
+ // Memory buffer returned by Client::ReserveOutputBuffer(). |
+ class Buffer { |
+ public: |
+ Buffer(void* data, size_t size) : data_(data), size_(size) {} |
ncarter (slow)
2013/10/29 18:42:17
Do you expect Buffer to be created directly? If th
sheu
2013/11/05 20:02:10
Done.
|
+ virtual ~Buffer() {} |
+ |
+ void* data() const { return data_; } |
+ size_t size() const { return size_; } |
+ |
+ private: |
+ void* const data_; |
+ const size_t size_; |
+ }; |
+ |
virtual ~Client() {} |
- // Reserve an output buffer into which a video frame can be captured |
- // directly. If all buffers are currently busy, returns NULL. |
+ // Reserve an output buffer into which contents can be captured directly. |
+ // The returned Buffer will always be allocated with a memory size suitable |
+ // for holding a packed video frame of |format| format, of |dimensions| |
+ // dimensions. It is permissible for |dimensions| to be zero; in which |
+ // case the returned Buffer does not guarantee memory backing, but functions |
+ // as a reservation for external input for the purposes of buffer |
+ // throttling. |
// |
- // The returned VideoFrames will always be allocated with a YV12 format and |
- // have dimensions matching |size|. It is the VideoCaptureDevice's |
- // responsibility to obey whatever stride and memory layout are indicated on |
- // the returned VideoFrame object. |
- // |
- // The output buffer stays reserved for use by the calling |
- // VideoCaptureDevice until either the last reference to the VideoFrame is |
- // released, or until the buffer is passed back to the Client's |
- // OnIncomingCapturedFrame() method. |
- virtual scoped_refptr<media::VideoFrame> ReserveOutputBuffer( |
- const gfx::Size& size) = 0; |
+ // The output buffer stays reserved for use until the Buffer object is |
+ // destroyed, or it is passed back to the Client's |
+ // OnIncomingCaptured*Buffer() function. |
+ virtual scoped_ptr<Buffer> ReserveOutputBuffer( |
+ media::VideoFrame::Format format, |
+ const gfx::Size& dimensions) = 0; |
// Captured a new video frame as a raw buffer. The size, color format, and |
// layout are taken from the parameters specified by an earlier call to |
@@ -152,24 +166,18 @@ class MEDIA_EXPORT VideoCaptureDevice { |
bool flip_vert, |
bool flip_horiz) = 0; |
- // Captured a new video frame, held in a VideoFrame container. |
- // |
- // If |frame| was created via the ReserveOutputBuffer() mechanism, then the |
- // frame delivery is guaranteed (it will not be silently dropped), and |
- // delivery will require no additional copies in the browser process. For |
- // such frames, the VideoCaptureDevice's reservation on the output buffer |
- // ends immediately. The VideoCaptureDevice may not read or write the |
- // underlying memory afterwards, and it should release its references to |
- // |frame| as soon as possible, to allow buffer reuse. |
+ // Captured a new video frame, in a raw buffer backed by |buffer|. |
ncarter (slow)
2013/10/29 18:42:17
"in a raw buffer backed by |buffer|" -> "held in |
sheu
2013/11/05 20:02:10
Done.
|
// |
- // If |frame| was NOT created via ReserveOutputBuffer(), then this method |
- // will try to reserve an output buffer and copy from |frame| into the |
- // output buffer. If no output buffer is available, the frame will be |
- // silently dropped. |frame| must be allocated as RGB32, YV12 or I420, and |
- // the size must match that specified by an earlier call to OnFrameInfo(). |
- virtual void OnIncomingCapturedVideoFrame( |
- const scoped_refptr<media::VideoFrame>& frame, |
- base::Time timestamp) = 0; |
+ // As the frame is backed by a reservation returned by |
+ // ReserveOutputBuffer(), delivery is guaranteed and will require no |
+ // additional copies in the browser process. The caller gives up ownership |
+ // of |buffer| and should not retained any cached pointers to its underlying |
+ // memory. |dimensions| indicates the frame width and height of the buffer |
+ // contents; this is assumed to be of |format| format and tightly packed. |
+ virtual void OnIncomingCapturedBuffer(scoped_ptr<Buffer> buffer, |
+ media::VideoFrame::Format format, |
+ const gfx::Size& dimensions, |
+ base::Time timestamp) = 0; |
// An error has occurred that cannot be handled and VideoCaptureDevice must |
// be StopAndDeAllocate()-ed. |