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

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

Issue 1704273002: Add MojoVideoFrame (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: move to media/mojo/common Created 4 years, 10 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_video_frame.h
diff --git a/media/mojo/common/mojo_video_frame.h b/media/mojo/common/mojo_video_frame.h
new file mode 100644
index 0000000000000000000000000000000000000000..c9da389b360e0ae49cfa8791d11da76a99e4d132
--- /dev/null
+++ b/media/mojo/common/mojo_video_frame.h
@@ -0,0 +1,89 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef MEDIA_MOJO_COMMON_MOJO_VIDEO_FRAME_H_
+#define MEDIA_MOJO_COMMON_MOJO_VIDEO_FRAME_H_
+
+#include <stddef.h>
+#include <stdint.h>
mcasas 2016/02/25 15:12:35 These 2 are probably not needed.
jrummell 2016/02/25 21:51:48 https://codereview.chromium.org/1542013004 went th
+
+#include "base/macros.h"
+#include "base/memory/ref_counted.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 media {
+
+// A derived class of media::VideoFrame holding a mojo::SharedBuffer which is
+// mapped on constructor and remains so for the lifetime of the MojoVideoFrame.
+// MojoVideoFrames frames are ref-counted.
+class MEDIA_EXPORT MojoVideoFrame : public VideoFrame {
+ public:
+ // Creates a MojoVideoFrame or returns nullptr. This will create and own
+ // the shared memory. The format is I420, and coded_size() == natural_size()
+ // == visible_rect().
+ static scoped_refptr<MojoVideoFrame> Create(const gfx::Size& dimensions,
+ base::TimeDelta timestamp);
+
+ // Creates a MojoVideoFrame that uses the memory in |handle|. This will make
+ // a duplicate of |handle|, so the caller can continue to use it.
+ static scoped_refptr<MojoVideoFrame> Create(VideoPixelFormat format,
+ const gfx::Size& coded_size,
+ const gfx::Rect& visible_rect,
+ const gfx::Size& natural_size,
+ mojo::SharedBufferHandle handle,
+ size_t mapped_size,
+ size_t y_offset,
+ size_t u_offset,
+ size_t v_offset,
+ int32_t y_stride,
+ int32_t u_stride,
+ int32_t v_stride,
+ base::TimeDelta timestamp);
+
+ // Returns the mojo shared memory handle, if present. This object continues
+ // to own the handle. Caller should call duplicate the handle if they want
+ // to keep a copy of the shared memory.
+ mojo::SharedBufferHandle handle() const;
mcasas 2016/02/25 15:12:35 ScopedSharedBufferHandle::get() signature (and imp
jrummell 2016/02/25 21:51:48 Done.
+
+ // Returns the size of the shared memory.
+ size_t mapped_size() const;
+
+ // Returns the offsets relative to the start of |shared_buffer| for the
+ // |plane| specified.
+ size_t plane_offset(size_t plane) const;
+
+ private:
+ MojoVideoFrame(VideoPixelFormat format,
+ StorageType storage_type,
+ const gfx::Size& coded_size,
+ const gfx::Rect& visible_rect,
+ const gfx::Size& natural_size,
+ mojo::ScopedSharedBufferHandle handle,
+ size_t mapped_size,
+ base::TimeDelta timestamp);
+ ~MojoVideoFrame() override;
+
+ // Initializes the MojoVideoFrame by creating a mapping onto the shared
+ // memory, and then setting the strides and offsets as specified.
+ bool Init(int32_t y_stride,
+ int32_t u_stride,
+ int32_t v_stride,
+ size_t y_offset,
+ size_t u_offset,
+ size_t v_offset);
+
+ mojo::ScopedSharedBufferHandle shared_buffer_handle_;
+ size_t shared_buffer_size_;
+ size_t offsets_[kMaxPlanes];
+
+ DISALLOW_COPY_AND_ASSIGN(MojoVideoFrame);
+};
+
+} // namespace media
+
+#endif // MEDIA_MOJO_COMMON_MOJO_VIDEO_FRAME_H_

Powered by Google App Engine
This is Rietveld 408576698