Index: media/capture/video/video_capture_device.h |
diff --git a/media/capture/video/video_capture_device.h b/media/capture/video/video_capture_device.h |
index 0ac1c3b94b25083d33e3013f4c738d7660979192..f790fc8085fd2ffaa74d6aca6b4a3bb21ba79ad3 100644 |
--- a/media/capture/video/video_capture_device.h |
+++ b/media/capture/video/video_capture_device.h |
@@ -30,6 +30,7 @@ |
#include "media/capture/capture_export.h" |
#include "media/capture/mojo/image_capture.mojom.h" |
#include "media/capture/video/scoped_result_callback.h" |
+#include "media/capture/video/video_capture_buffer_handle.h" |
#include "media/capture/video/video_capture_device_descriptor.h" |
#include "media/capture/video_capture_types.h" |
#include "mojo/public/cpp/bindings/array.h" |
@@ -47,7 +48,6 @@ class CAPTURE_EXPORT FrameBufferPool { |
virtual void SetBufferHold(int buffer_id) = 0; |
virtual void ReleaseBufferHold(int buffer_id) = 0; |
- virtual mojo::ScopedSharedBufferHandle GetHandleForTransit(int buffer_id) = 0; |
}; |
class CAPTURE_EXPORT VideoFrameConsumerFeedbackObserver { |
@@ -87,21 +87,46 @@ class CAPTURE_EXPORT VideoCaptureDevice |
// All clients must implement OnError(). |
class CAPTURE_EXPORT Client { |
public: |
- // Memory buffer returned by Client::ReserveOutputBuffer(). |
- class CAPTURE_EXPORT Buffer { |
+ // Move-only struct representing access to a buffer handle as well as |
+ // read-write permission to its contents. |
+ struct CAPTURE_EXPORT Buffer { |
mcasas
2017/01/05 20:37:02
A struct with private members and accessors and su
chfremer
2017/01/05 22:44:48
Done.
|
public: |
- virtual ~Buffer() = 0; |
- virtual int id() const = 0; |
- virtual int frame_feedback_id() const = 0; |
- virtual gfx::Size dimensions() const = 0; |
- virtual size_t mapped_size() const = 0; |
- virtual void* data(int plane) = 0; |
- void* data() { return data(0); } |
-#if defined(OS_POSIX) && !(defined(OS_MACOSX) && !defined(OS_IOS)) |
- virtual base::FileDescriptor AsPlatformFile() = 0; |
-#endif |
- virtual bool IsBackedByVideoFrame() const = 0; |
- virtual scoped_refptr<VideoFrame> GetVideoFrame() = 0; |
+ // Destructor-only interface for encapsulating scoped access permission to |
+ // a Buffer. |
+ class CAPTURE_EXPORT ScopedAccessPermission { |
+ public: |
+ virtual ~ScopedAccessPermission() {} |
+ }; |
+ |
+ class CAPTURE_EXPORT HandleProvider { |
+ public: |
+ virtual ~HandleProvider() {} |
+ virtual mojo::ScopedSharedBufferHandle |
+ GetHandleForInterProcessTransit() = 0; |
+ virtual std::unique_ptr<VideoCaptureBufferHandle> |
+ GetHandleForInProcessAccess() = 0; |
+ }; |
+ |
+ Buffer(); |
+ Buffer( |
+ int buffer_id, |
+ int frame_feedback_id, |
+ std::unique_ptr<HandleProvider> handle_provider, |
+ std::unique_ptr<ScopedAccessPermission> buffer_read_write_permission); |
mcasas
2017/01/05 20:37:02
s/buffer_read_write_permission/access_permission/
chfremer
2017/01/05 22:44:48
Done.
|
+ ~Buffer(); |
+ Buffer(Buffer&& other); |
+ Buffer& operator=(Buffer&& other); |
+ |
+ bool is_valid() const { return handle_provider != nullptr; } |
+ int id() const { return id_; } |
+ int frame_feedback_id() const { return frame_feedback_id_; } |
+ |
+ std::unique_ptr<HandleProvider> handle_provider; |
+ std::unique_ptr<ScopedAccessPermission> buffer_read_write_permission; |
+ |
+ private: |
+ int id_; |
+ int frame_feedback_id_; |
}; |
mcasas
2017/01/05 20:37:02
I think that to make Buffer uncopyable, we have to
chfremer
2017/01/05 22:44:48
Well, no. It seems that by providing a move constr
|
virtual ~Client() {} |
@@ -139,20 +164,19 @@ class CAPTURE_EXPORT VideoCaptureDevice |
// backing, but functions as a reservation for external input for the |
// purposes of buffer throttling. |
// |
- // The output buffer stays reserved and mapped for use until the Buffer |
- // object is destroyed or returned. |
- virtual std::unique_ptr<Buffer> ReserveOutputBuffer( |
- const gfx::Size& dimensions, |
- VideoPixelFormat format, |
- VideoPixelStorage storage, |
- int frame_feedback_id) = 0; |
+ // The buffer stays reserved for use by the caller as long as it |
+ // holds on to the contained |buffer_read_write_permission|. |
+ virtual Buffer ReserveOutputBuffer(const gfx::Size& dimensions, |
+ VideoPixelFormat format, |
+ VideoPixelStorage storage, |
+ int frame_feedback_id) = 0; |
// Provides VCD::Client with a populated Buffer containing the content of |
// the next video frame. The |buffer| must originate from an earlier call to |
// ReserveOutputBuffer(). |
// See OnIncomingCapturedData for details of |reference_time| and |
// |timestamp|. |
- virtual void OnIncomingCapturedBuffer(std::unique_ptr<Buffer> buffer, |
+ virtual void OnIncomingCapturedBuffer(Buffer buffer, |
const VideoCaptureFormat& format, |
base::TimeTicks reference_time, |
base::TimeDelta timestamp) = 0; |
@@ -160,7 +184,7 @@ class CAPTURE_EXPORT VideoCaptureDevice |
// Extended version of OnIncomingCapturedBuffer() allowing clients to |
// pass a custom |visible_rect| and |additional_metadata|. |
virtual void OnIncomingCapturedBufferExt( |
- std::unique_ptr<Buffer> buffer, |
+ Buffer buffer, |
const VideoCaptureFormat& format, |
base::TimeTicks reference_time, |
base::TimeDelta timestamp, |
@@ -172,11 +196,10 @@ class CAPTURE_EXPORT VideoCaptureDevice |
// of the Buffer has not been preserved, or if the |dimensions|, |format|, |
// or |storage| disagree with how it was reserved via ReserveOutputBuffer(). |
// When this operation fails, nullptr will be returned. |
- virtual std::unique_ptr<Buffer> ResurrectLastOutputBuffer( |
- const gfx::Size& dimensions, |
- VideoPixelFormat format, |
- VideoPixelStorage storage, |
- int new_frame_feedback_id) = 0; |
+ virtual Buffer ResurrectLastOutputBuffer(const gfx::Size& dimensions, |
+ VideoPixelFormat format, |
+ VideoPixelStorage storage, |
+ int new_frame_feedback_id) = 0; |
// An error has occurred that cannot be handled and VideoCaptureDevice must |
// be StopAndDeAllocate()-ed. |reason| is a text description of the error. |