Chromium Code Reviews| OLD | NEW |
|---|---|
| (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_SERVICES_MOJO_VIDEO_FRAME_H_ | |
| 6 #define MEDIA_MOJO_SERVICES_MOJO_VIDEO_FRAME_H_ | |
|
xhwang
2016/02/23 21:27:36
Thinking about the future more...
Currently the m
jrummell
2016/02/25 02:18:26
Done.
| |
| 7 | |
| 8 #include <stddef.h> | |
|
xhwang
2016/02/23 21:28:54
What is this used for?
jrummell
2016/02/25 02:18:27
size_t (somebody added this to all media files). A
| |
| 9 | |
| 10 #include "base/macros.h" | |
| 11 #include "media/base/media_export.h" | |
| 12 #include "media/base/video_frame.h" | |
| 13 #include "mojo/public/cpp/system/buffer.h" | |
| 14 | |
| 15 namespace media { | |
| 16 | |
| 17 // A derived class of media::VideoFrame holding a mojo::SharedBuffer which is | |
| 18 // mapped on constructor and remains so for the lifetime of the MojoVideoFrame. | |
| 19 // MojoVideoFrames frames are ref-counted. | |
| 20 class MEDIA_EXPORT MojoVideoFrame : public VideoFrame { | |
| 21 public: | |
| 22 // Creates a MojoVideoFrame or returns nullptr. This will create and own | |
| 23 // the shared memory. The format is I420, and coded_size() == natural_size() | |
| 24 // == visible_rect(). | |
| 25 static scoped_refptr<MojoVideoFrame> Create(const gfx::Size& dimensions, | |
| 26 base::TimeDelta timestamp); | |
|
xhwang
2016/02/23 21:27:36
Add a comment that the shared memory will be creat
jrummell
2016/02/25 02:18:26
Already there? ("This will create and own the shar
| |
| 27 | |
| 28 // Creates a MojoVideoFrame that uses the memory in |handle|. This will make | |
| 29 // a duplicate of |handle|, so the caller can continue to use it. | |
| 30 static scoped_refptr<MojoVideoFrame> Create( | |
| 31 VideoPixelFormat format, | |
| 32 const gfx::Size& coded_size, | |
| 33 const gfx::Rect& visible_rect, | |
| 34 const gfx::Size& natural_size, | |
| 35 mojo::ScopedSharedBufferHandle handle, | |
| 36 size_t mapped_size, | |
| 37 size_t y_offset, | |
| 38 size_t u_offset, | |
| 39 size_t v_offset, | |
| 40 int32_t y_stride, | |
| 41 int32_t u_stride, | |
| 42 int32_t v_stride, | |
| 43 base::TimeDelta timestamp); | |
| 44 | |
| 45 // Returns the mojo shared memory handle, if present. This object continues | |
| 46 // to own the handle. Caller should call duplicate the handle if they want | |
| 47 // to keep a copy of the shared memory. | |
| 48 mojo::SharedBufferHandle handle() const; | |
|
xhwang
2016/02/23 21:27:36
Is this only used by the type converter for serial
jrummell
2016/02/25 02:18:27
It is used in mcasas@'s CL (https://codereview.chr
| |
| 49 | |
| 50 // Returns the size of the shared memory. | |
| 51 size_t mapped_size() const; | |
|
xhwang
2016/02/23 21:27:36
ditto
| |
| 52 | |
| 53 // Returns the offsets relative to the start of |shared_buffer| for the | |
| 54 // |plane| specified. | |
| 55 size_t plane_offset(size_t plane) const; | |
| 56 | |
| 57 private: | |
| 58 MojoVideoFrame(VideoPixelFormat format, | |
| 59 StorageType storage_type, | |
| 60 const gfx::Size& coded_size, | |
| 61 const gfx::Rect& visible_rect, | |
| 62 const gfx::Size& natural_size, | |
| 63 mojo::ScopedSharedBufferHandle handle, | |
| 64 size_t mapped_size, | |
| 65 base::TimeDelta timestamp); | |
| 66 ~MojoVideoFrame() override; | |
| 67 | |
| 68 bool Init(int32_t y_stride, | |
|
xhwang
2016/02/23 21:27:36
comment about what this does?
jrummell
2016/02/25 02:18:27
Done.
| |
| 69 int32_t u_stride, | |
| 70 int32_t v_stride, | |
| 71 size_t y_offset, | |
| 72 size_t u_offset, | |
| 73 size_t v_offset); | |
| 74 | |
| 75 void set_offset(size_t plane, size_t offset); | |
|
xhwang
2016/02/23 21:27:36
will this override the offset set in Init()?
jrummell
2016/02/25 02:18:27
Removed to avoid confusion (since changing the off
| |
| 76 | |
| 77 mojo::ScopedSharedBufferHandle shared_buffer_handle_; | |
| 78 size_t shared_buffer_size_; | |
| 79 size_t offsets_[kMaxPlanes]; | |
| 80 | |
| 81 DISALLOW_IMPLICIT_CONSTRUCTORS(MojoVideoFrame); | |
|
xhwang
2016/02/23 21:27:36
Why not just DISALLOW_COPY_AND_ASSIGN?
jrummell
2016/02/25 02:18:26
Done. This is what is in VideoFrame, so I just cop
| |
| 82 }; | |
| 83 | |
| 84 } // namespace media | |
| 85 | |
| 86 #endif // MEDIA_MOJO_SERVICES_MOJO_VIDEO_FRAME_H_ | |
| OLD | NEW |