Chromium Code Reviews| Index: media/mojo/services/mojo_video_frame.h |
| diff --git a/media/mojo/services/mojo_video_frame.h b/media/mojo/services/mojo_video_frame.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..dac7c3d49f6332fae218a0387a0769c1f8ec6c4c |
| --- /dev/null |
| +++ b/media/mojo/services/mojo_video_frame.h |
| @@ -0,0 +1,86 @@ |
| +// 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_SERVICES_MOJO_VIDEO_FRAME_H_ |
| +#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.
|
| + |
| +#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
|
| + |
| +#include "base/macros.h" |
| +#include "media/base/media_export.h" |
| +#include "media/base/video_frame.h" |
| +#include "mojo/public/cpp/system/buffer.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); |
|
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
|
| + |
| + // 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::ScopedSharedBufferHandle 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; |
|
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
|
| + |
| + // Returns the size of the shared memory. |
| + size_t mapped_size() const; |
|
xhwang
2016/02/23 21:27:36
ditto
|
| + |
| + // 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; |
| + |
| + 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.
|
| + int32_t u_stride, |
| + int32_t v_stride, |
| + size_t y_offset, |
| + size_t u_offset, |
| + size_t v_offset); |
| + |
| + 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
|
| + |
| + mojo::ScopedSharedBufferHandle shared_buffer_handle_; |
| + size_t shared_buffer_size_; |
| + size_t offsets_[kMaxPlanes]; |
| + |
| + 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
|
| +}; |
| + |
| +} // namespace media |
| + |
| +#endif // MEDIA_MOJO_SERVICES_MOJO_VIDEO_FRAME_H_ |