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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef MEDIA_MOJO_COMMON_MOJO_VIDEO_FRAME_H_
6 #define MEDIA_MOJO_COMMON_MOJO_VIDEO_FRAME_H_
7
8 #include <stddef.h>
9 #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
10
11 #include "base/macros.h"
12 #include "base/memory/ref_counted.h"
13 #include "media/base/media_export.h"
14 #include "media/base/video_frame.h"
15 #include "mojo/public/cpp/system/buffer.h"
16 #include "ui/gfx/geometry/rect.h"
17 #include "ui/gfx/geometry/size.h"
18
19 namespace media {
20
21 // A derived class of media::VideoFrame holding a mojo::SharedBuffer which is
22 // mapped on constructor and remains so for the lifetime of the MojoVideoFrame.
23 // MojoVideoFrames frames are ref-counted.
24 class MEDIA_EXPORT MojoVideoFrame : public VideoFrame {
25 public:
26 // Creates a MojoVideoFrame or returns nullptr. This will create and own
27 // the shared memory. The format is I420, and coded_size() == natural_size()
28 // == visible_rect().
29 static scoped_refptr<MojoVideoFrame> Create(const gfx::Size& dimensions,
30 base::TimeDelta timestamp);
31
32 // Creates a MojoVideoFrame that uses the memory in |handle|. This will make
33 // a duplicate of |handle|, so the caller can continue to use it.
34 static scoped_refptr<MojoVideoFrame> Create(VideoPixelFormat format,
35 const gfx::Size& coded_size,
36 const gfx::Rect& visible_rect,
37 const gfx::Size& natural_size,
38 mojo::SharedBufferHandle handle,
39 size_t mapped_size,
40 size_t y_offset,
41 size_t u_offset,
42 size_t v_offset,
43 int32_t y_stride,
44 int32_t u_stride,
45 int32_t v_stride,
46 base::TimeDelta timestamp);
47
48 // Returns the mojo shared memory handle, if present. This object continues
49 // to own the handle. Caller should call duplicate the handle if they want
50 // to keep a copy of the shared memory.
51 mojo::SharedBufferHandle handle() const;
mcasas 2016/02/25 15:12:35 ScopedSharedBufferHandle::get() signature (and imp
jrummell 2016/02/25 21:51:48 Done.
52
53 // Returns the size of the shared memory.
54 size_t mapped_size() const;
55
56 // Returns the offsets relative to the start of |shared_buffer| for the
57 // |plane| specified.
58 size_t plane_offset(size_t plane) const;
59
60 private:
61 MojoVideoFrame(VideoPixelFormat format,
62 StorageType storage_type,
63 const gfx::Size& coded_size,
64 const gfx::Rect& visible_rect,
65 const gfx::Size& natural_size,
66 mojo::ScopedSharedBufferHandle handle,
67 size_t mapped_size,
68 base::TimeDelta timestamp);
69 ~MojoVideoFrame() override;
70
71 // Initializes the MojoVideoFrame by creating a mapping onto the shared
72 // memory, and then setting the strides and offsets as specified.
73 bool Init(int32_t y_stride,
74 int32_t u_stride,
75 int32_t v_stride,
76 size_t y_offset,
77 size_t u_offset,
78 size_t v_offset);
79
80 mojo::ScopedSharedBufferHandle shared_buffer_handle_;
81 size_t shared_buffer_size_;
82 size_t offsets_[kMaxPlanes];
83
84 DISALLOW_COPY_AND_ASSIGN(MojoVideoFrame);
85 };
86
87 } // namespace media
88
89 #endif // MEDIA_MOJO_COMMON_MOJO_VIDEO_FRAME_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698