| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef MEDIA_MOJO_COMMON_MOJO_SHARED_BUFFER_VIDEO_FRAME_H_ | 5 #ifndef MEDIA_MOJO_COMMON_MOJO_SHARED_BUFFER_VIDEO_FRAME_H_ |
| 6 #define MEDIA_MOJO_COMMON_MOJO_SHARED_BUFFER_VIDEO_FRAME_H_ | 6 #define MEDIA_MOJO_COMMON_MOJO_SHARED_BUFFER_VIDEO_FRAME_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| 11 #include "base/callback_forward.h" | 11 #include "base/callback_forward.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 14 #include "media/base/video_frame.h" | 14 #include "media/base/video_frame.h" |
| 15 #include "media/base/video_frame_pool.h" |
| 15 #include "mojo/public/cpp/system/buffer.h" | 16 #include "mojo/public/cpp/system/buffer.h" |
| 16 #include "ui/gfx/geometry/rect.h" | 17 #include "ui/gfx/geometry/rect.h" |
| 17 #include "ui/gfx/geometry/size.h" | 18 #include "ui/gfx/geometry/size.h" |
| 18 | 19 |
| 19 namespace mojo { | 20 namespace mojo { |
| 20 template <typename T, typename U> | 21 template <typename T, typename U> |
| 21 struct TypeConverter; | 22 struct TypeConverter; |
| 22 template <typename T> | 23 template <typename T> |
| 23 class StructPtr; | 24 class StructPtr; |
| 24 }; | 25 }; |
| 25 | 26 |
| 26 namespace media { | 27 namespace media { |
| 27 | 28 |
| 28 namespace mojom { | 29 namespace mojom { |
| 29 class VideoFrame; | 30 class VideoFrame; |
| 30 } | 31 } |
| 31 | 32 |
| 33 class MojoVideoFramePoolDelegate final : public VideoFramePoolDelegate { |
| 34 public: |
| 35 ~MojoVideoFramePoolDelegate() override; |
| 36 |
| 37 scoped_refptr<VideoFrame> CreateZeroInitializedFrame( |
| 38 VideoPixelFormat format, |
| 39 const gfx::Size& coded_size, |
| 40 const gfx::Rect& visible_rect, |
| 41 const gfx::Size& natural_size, |
| 42 base::TimeDelta timestamp) override; |
| 43 |
| 44 scoped_refptr<VideoFrame> WrapVideoFrame( |
| 45 const scoped_refptr<VideoFrame>& frame) override; |
| 46 }; |
| 47 |
| 32 // A derived class of media::VideoFrame holding a mojo::SharedBufferHandle | 48 // A derived class of media::VideoFrame holding a mojo::SharedBufferHandle |
| 33 // which is mapped on constructor and remains so for the lifetime of the | 49 // which is mapped on constructor and remains so for the lifetime of the |
| 34 // object. These frames are ref-counted. | 50 // object. These frames are ref-counted. |
| 35 class MojoSharedBufferVideoFrame : public VideoFrame { | 51 class MojoSharedBufferVideoFrame : public VideoFrame { |
| 36 public: | 52 public: |
| 37 // Callback called when this object is destructed. Ownership of the shared | 53 // Callback called when this object is destructed. Ownership of the shared |
| 38 // memory is transferred to the callee. | 54 // memory is transferred to the callee. |
| 39 using MojoSharedBufferDoneCB = | 55 using MojoSharedBufferDoneCB = |
| 40 base::Callback<void(mojo::ScopedSharedBufferHandle buffer, | 56 base::Callback<void(mojo::ScopedSharedBufferHandle buffer, |
| 41 size_t capacity)>; | 57 size_t capacity)>; |
| 42 | 58 |
| 59 static scoped_refptr<MojoSharedBufferVideoFrame> |
| 60 WrapMojoSharedBufferVideoFrame( |
| 61 const scoped_refptr<MojoSharedBufferVideoFrame>& frame); |
| 62 |
| 63 static scoped_refptr<MojoSharedBufferVideoFrame> CreateYUV( |
| 64 VideoPixelFormat format, |
| 65 const gfx::Size& dimensions, |
| 66 base::TimeDelta timestamp); |
| 67 |
| 43 // Creates a new I420 frame in shared memory with provided parameters | 68 // Creates a new I420 frame in shared memory with provided parameters |
| 44 // (coded_size() == natural_size() == visible_rect()), or returns nullptr. | 69 // (coded_size() == natural_size() == visible_rect()), or returns nullptr. |
| 45 // Buffers for the frame are allocated but not initialized. The caller must | 70 // Buffers for the frame are allocated but not initialized. The caller must |
| 46 // not make assumptions about the actual underlying sizes, but check the | 71 // not make assumptions about the actual underlying sizes, but check the |
| 47 // returned VideoFrame instead. | 72 // returned VideoFrame instead. |
| 48 static scoped_refptr<MojoSharedBufferVideoFrame> CreateDefaultI420( | 73 static scoped_refptr<MojoSharedBufferVideoFrame> CreateDefaultI420( |
| 49 const gfx::Size& dimensions, | 74 const gfx::Size& dimensions, |
| 50 base::TimeDelta timestamp); | 75 base::TimeDelta timestamp); |
| 51 | 76 |
| 52 // Creates a MojoSharedBufferVideoFrame that uses the memory in |handle|. | 77 // Creates a MojoSharedBufferVideoFrame that uses the memory in |handle|. |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 size_t shared_buffer_size_; | 144 size_t shared_buffer_size_; |
| 120 size_t offsets_[kMaxPlanes]; | 145 size_t offsets_[kMaxPlanes]; |
| 121 MojoSharedBufferDoneCB mojo_shared_buffer_done_cb_; | 146 MojoSharedBufferDoneCB mojo_shared_buffer_done_cb_; |
| 122 | 147 |
| 123 DISALLOW_COPY_AND_ASSIGN(MojoSharedBufferVideoFrame); | 148 DISALLOW_COPY_AND_ASSIGN(MojoSharedBufferVideoFrame); |
| 124 }; | 149 }; |
| 125 | 150 |
| 126 } // namespace media | 151 } // namespace media |
| 127 | 152 |
| 128 #endif // MEDIA_MOJO_COMMON_MOJO_SHARED_BUFFER_VIDEO_FRAME_H_ | 153 #endif // MEDIA_MOJO_COMMON_MOJO_SHARED_BUFFER_VIDEO_FRAME_H_ |
| OLD | NEW |