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 "mojo/public/cpp/system/buffer.h" | 15 #include "mojo/public/cpp/system/buffer.h" |
16 #include "ui/gfx/geometry/rect.h" | 16 #include "ui/gfx/geometry/rect.h" |
17 #include "ui/gfx/geometry/size.h" | 17 #include "ui/gfx/geometry/size.h" |
18 | 18 |
19 namespace mojo { | 19 namespace mojo { |
20 template <typename T, typename U> | 20 template <typename T, typename U> |
21 struct TypeConverter; | 21 struct TypeConverter; |
22 template <typename T> | 22 template <typename T> |
23 class StructPtr; | 23 class StructPtr; |
24 }; | 24 }; |
25 | 25 |
26 namespace media { | 26 namespace media { |
27 | 27 |
28 namespace interfaces { | 28 namespace mojom { |
29 class VideoFrame; | 29 class VideoFrame; |
30 } | 30 } |
31 | 31 |
32 // A derived class of media::VideoFrame holding a mojo::SharedBufferHandle | 32 // A derived class of media::VideoFrame holding a mojo::SharedBufferHandle |
33 // which is mapped on constructor and remains so for the lifetime of the | 33 // which is mapped on constructor and remains so for the lifetime of the |
34 // object. These frames are ref-counted. | 34 // object. These frames are ref-counted. |
35 class MojoSharedBufferVideoFrame : public VideoFrame { | 35 class MojoSharedBufferVideoFrame : public VideoFrame { |
36 public: | 36 public: |
37 // Callback called when this object is destructed. Ownership of the shared | 37 // Callback called when this object is destructed. Ownership of the shared |
38 // memory is transferred to the callee. | 38 // memory is transferred to the callee. |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 size_t PlaneOffset(size_t plane) const; | 73 size_t PlaneOffset(size_t plane) const; |
74 | 74 |
75 // Sets the callback to be called to free the shared buffer. If not null, | 75 // Sets the callback to be called to free the shared buffer. If not null, |
76 // it is called on destruction, and is passed ownership of |handle|. | 76 // it is called on destruction, and is passed ownership of |handle|. |
77 void SetMojoSharedBufferDoneCB( | 77 void SetMojoSharedBufferDoneCB( |
78 const MojoSharedBufferDoneCB& mojo_shared_buffer_done_cb); | 78 const MojoSharedBufferDoneCB& mojo_shared_buffer_done_cb); |
79 | 79 |
80 private: | 80 private: |
81 // mojo::TypeConverter added as a friend so that MojoSharedBufferVideoFrame | 81 // mojo::TypeConverter added as a friend so that MojoSharedBufferVideoFrame |
82 // can be transferred across a mojo connection. | 82 // can be transferred across a mojo connection. |
83 friend struct mojo::TypeConverter<mojo::StructPtr<interfaces::VideoFrame>, | 83 friend struct mojo::TypeConverter<mojo::StructPtr<mojom::VideoFrame>, |
84 scoped_refptr<VideoFrame>>; | 84 scoped_refptr<VideoFrame>>; |
85 friend class MojoDecryptorService; | 85 friend class MojoDecryptorService; |
86 | 86 |
87 MojoSharedBufferVideoFrame(VideoPixelFormat format, | 87 MojoSharedBufferVideoFrame(VideoPixelFormat format, |
88 const gfx::Size& coded_size, | 88 const gfx::Size& coded_size, |
89 const gfx::Rect& visible_rect, | 89 const gfx::Rect& visible_rect, |
90 const gfx::Size& natural_size, | 90 const gfx::Size& natural_size, |
91 mojo::ScopedSharedBufferHandle handle, | 91 mojo::ScopedSharedBufferHandle handle, |
92 size_t mapped_size, | 92 size_t mapped_size, |
93 base::TimeDelta timestamp); | 93 base::TimeDelta timestamp); |
(...skipping 21 matching lines...) Expand all Loading... |
115 uint8_t* shared_buffer_data_; | 115 uint8_t* shared_buffer_data_; |
116 size_t offsets_[kMaxPlanes]; | 116 size_t offsets_[kMaxPlanes]; |
117 MojoSharedBufferDoneCB mojo_shared_buffer_done_cb_; | 117 MojoSharedBufferDoneCB mojo_shared_buffer_done_cb_; |
118 | 118 |
119 DISALLOW_COPY_AND_ASSIGN(MojoSharedBufferVideoFrame); | 119 DISALLOW_COPY_AND_ASSIGN(MojoSharedBufferVideoFrame); |
120 }; | 120 }; |
121 | 121 |
122 } // namespace media | 122 } // namespace media |
123 | 123 |
124 #endif // MEDIA_MOJO_COMMON_MOJO_SHARED_BUFFER_VIDEO_FRAME_H_ | 124 #endif // MEDIA_MOJO_COMMON_MOJO_SHARED_BUFFER_VIDEO_FRAME_H_ |
OLD | NEW |