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

Unified Diff: media/mojo/common/mojo_shared_buffer_video_frame.h

Issue 1769673002: Transfer media::VideoFrame using mojo shared memory (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: changes Created 4 years, 9 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
Index: media/mojo/common/mojo_shared_buffer_video_frame.h
diff --git a/media/mojo/common/mojo_shared_buffer_video_frame.h b/media/mojo/common/mojo_shared_buffer_video_frame.h
index 9d470fd3a9102dd9323a20fe1673b67f68f996aa..4720d1d0b3539597c204b2853e8395f57cf20de9 100644
--- a/media/mojo/common/mojo_shared_buffer_video_frame.h
+++ b/media/mojo/common/mojo_shared_buffer_video_frame.h
@@ -10,14 +10,26 @@
#include "base/macros.h"
#include "base/memory/ref_counted.h"
+#include "base/memory/scoped_ptr.h"
#include "media/base/media_export.h"
#include "media/base/video_frame.h"
#include "mojo/public/cpp/system/buffer.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/size.h"
+namespace mojo {
+template <typename T, typename U>
+struct TypeConverter;
+template <typename T>
+class StructPtr;
+};
+
namespace media {
+namespace interfaces {
+class VideoFrame;
+}
+
// A derived class of media::VideoFrame holding a mojo::SharedBufferHandle
// which is mapped on constructor and remains so for the lifetime of the
// object. These frames are ref-counted.
@@ -54,6 +66,11 @@ class MEDIA_EXPORT MojoSharedBufferVideoFrame : public VideoFrame {
size_t PlaneOffset(size_t plane) const;
private:
+ // mojo::TypeConverter added as a friend so that MojoSharedBufferVideoFrame
+ // can be transferred across a mojo connection.
+ friend struct mojo::TypeConverter<mojo::StructPtr<interfaces::VideoFrame>,
+ scoped_refptr<VideoFrame>>;
+
MojoSharedBufferVideoFrame(VideoPixelFormat format,
const gfx::Size& coded_size,
const gfx::Rect& visible_rect,
@@ -72,6 +89,14 @@ class MEDIA_EXPORT MojoSharedBufferVideoFrame : public VideoFrame {
size_t u_offset,
size_t v_offset);
+ // Returns the mojo shared memory handle. This object continues to own the
+ // handle. Caller should call duplicate the handle if they want to keep a
+ // copy of the shared memory.
+ const mojo::SharedBufferHandle& Handle() const;
+
+ // Returns the size of the shared memory.
+ size_t MappedSize() const;
+
mojo::ScopedSharedBufferHandle shared_buffer_handle_;
size_t shared_buffer_size_;
uint8_t* shared_buffer_data_;

Powered by Google App Engine
This is Rietveld 408576698