| 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 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 size_t v_offset, | 65 size_t v_offset, |
| 66 int32_t y_stride, | 66 int32_t y_stride, |
| 67 int32_t u_stride, | 67 int32_t u_stride, |
| 68 int32_t v_stride, | 68 int32_t v_stride, |
| 69 base::TimeDelta timestamp); | 69 base::TimeDelta timestamp); |
| 70 | 70 |
| 71 // Returns the offsets relative to the start of |shared_buffer| for the | 71 // Returns the offsets relative to the start of |shared_buffer| for the |
| 72 // |plane| specified. | 72 // |plane| specified. |
| 73 size_t PlaneOffset(size_t plane) const; | 73 size_t PlaneOffset(size_t plane) const; |
| 74 | 74 |
| 75 // Returns a reference to the mojo shared memory handle. Caller should |
| 76 // duplicate the handle if they want to extend the lifetime of the buffer. |
| 77 const mojo::SharedBufferHandle& Handle() const; |
| 78 |
| 79 // Returns the size of the shared memory. |
| 80 size_t MappedSize() const; |
| 81 |
| 75 // Sets the callback to be called to free the shared buffer. If not null, | 82 // 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|. | 83 // it is called on destruction, and is passed ownership of |handle|. |
| 77 void SetMojoSharedBufferDoneCB( | 84 void SetMojoSharedBufferDoneCB( |
| 78 const MojoSharedBufferDoneCB& mojo_shared_buffer_done_cb); | 85 const MojoSharedBufferDoneCB& mojo_shared_buffer_done_cb); |
| 79 | 86 |
| 80 private: | 87 private: |
| 81 // mojo::TypeConverter added as a friend so that MojoSharedBufferVideoFrame | 88 // mojo::TypeConverter added as a friend so that MojoSharedBufferVideoFrame |
| 82 // can be transferred across a mojo connection. | 89 // can be transferred across a mojo connection. |
| 83 friend struct mojo::TypeConverter<mojo::StructPtr<mojom::VideoFrame>, | 90 friend struct mojo::TypeConverter<mojo::StructPtr<mojom::VideoFrame>, |
| 84 scoped_refptr<VideoFrame>>; | 91 scoped_refptr<VideoFrame>>; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 95 | 102 |
| 96 // Initializes the MojoSharedBufferVideoFrame by creating a mapping onto | 103 // Initializes the MojoSharedBufferVideoFrame by creating a mapping onto |
| 97 // the shared memory, and then setting the strides and offsets as specified. | 104 // the shared memory, and then setting the strides and offsets as specified. |
| 98 bool Init(int32_t y_stride, | 105 bool Init(int32_t y_stride, |
| 99 int32_t u_stride, | 106 int32_t u_stride, |
| 100 int32_t v_stride, | 107 int32_t v_stride, |
| 101 size_t y_offset, | 108 size_t y_offset, |
| 102 size_t u_offset, | 109 size_t u_offset, |
| 103 size_t v_offset); | 110 size_t v_offset); |
| 104 | 111 |
| 105 // Returns the mojo shared memory handle. This object continues to own the | |
| 106 // handle. Caller should call duplicate the handle if they want to keep a | |
| 107 // copy of the shared memory. | |
| 108 const mojo::SharedBufferHandle& Handle() const; | |
| 109 | |
| 110 // Returns the size of the shared memory. | |
| 111 size_t MappedSize() const; | |
| 112 | |
| 113 uint8_t* shared_buffer_data() { | 112 uint8_t* shared_buffer_data() { |
| 114 return reinterpret_cast<uint8_t*>(shared_buffer_mapping_.get()); | 113 return reinterpret_cast<uint8_t*>(shared_buffer_mapping_.get()); |
| 115 }; | 114 }; |
| 116 | 115 |
| 117 mojo::ScopedSharedBufferHandle shared_buffer_handle_; | 116 mojo::ScopedSharedBufferHandle shared_buffer_handle_; |
| 118 mojo::ScopedSharedBufferMapping shared_buffer_mapping_; | 117 mojo::ScopedSharedBufferMapping shared_buffer_mapping_; |
| 119 size_t shared_buffer_size_; | 118 size_t shared_buffer_size_; |
| 120 size_t offsets_[kMaxPlanes]; | 119 size_t offsets_[kMaxPlanes]; |
| 121 MojoSharedBufferDoneCB mojo_shared_buffer_done_cb_; | 120 MojoSharedBufferDoneCB mojo_shared_buffer_done_cb_; |
| 122 | 121 |
| 123 DISALLOW_COPY_AND_ASSIGN(MojoSharedBufferVideoFrame); | 122 DISALLOW_COPY_AND_ASSIGN(MojoSharedBufferVideoFrame); |
| 124 }; | 123 }; |
| 125 | 124 |
| 126 } // namespace media | 125 } // namespace media |
| 127 | 126 |
| 128 #endif // MEDIA_MOJO_COMMON_MOJO_SHARED_BUFFER_VIDEO_FRAME_H_ | 127 #endif // MEDIA_MOJO_COMMON_MOJO_SHARED_BUFFER_VIDEO_FRAME_H_ |
| OLD | NEW |