OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 PPAPI_PROXY_VIDEO_ENCODER_RESOURCE_H_ | 5 #ifndef PPAPI_PROXY_VIDEO_ENCODER_RESOURCE_H_ |
6 #define PPAPI_PROXY_VIDEO_ENCODER_RESOURCE_H_ | 6 #define PPAPI_PROXY_VIDEO_ENCODER_RESOURCE_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <deque> | 10 #include <deque> |
11 #include <memory> | 11 #include <memory> |
| 12 #include <vector> |
12 | 13 |
13 #include "base/macros.h" | 14 #include "base/macros.h" |
14 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
15 #include "base/memory/scoped_vector.h" | |
16 #include "ppapi/proxy/connection.h" | 16 #include "ppapi/proxy/connection.h" |
17 #include "ppapi/proxy/plugin_resource.h" | 17 #include "ppapi/proxy/plugin_resource.h" |
18 #include "ppapi/shared_impl/media_stream_buffer_manager.h" | 18 #include "ppapi/shared_impl/media_stream_buffer_manager.h" |
19 #include "ppapi/shared_impl/resource.h" | 19 #include "ppapi/shared_impl/resource.h" |
20 #include "ppapi/thunk/ppb_video_encoder_api.h" | 20 #include "ppapi/thunk/ppb_video_encoder_api.h" |
21 | 21 |
22 namespace base { | 22 namespace base { |
23 class SharedMemory; | 23 class SharedMemory; |
24 } | 24 } |
25 | 25 |
(...skipping 13 matching lines...) Expand all Loading... |
39 VideoEncoderResource(Connection connection, PP_Instance instance); | 39 VideoEncoderResource(Connection connection, PP_Instance instance); |
40 ~VideoEncoderResource() override; | 40 ~VideoEncoderResource() override; |
41 | 41 |
42 thunk::PPB_VideoEncoder_API* AsPPB_VideoEncoder_API() override; | 42 thunk::PPB_VideoEncoder_API* AsPPB_VideoEncoder_API() override; |
43 | 43 |
44 private: | 44 private: |
45 struct ShmBuffer { | 45 struct ShmBuffer { |
46 ShmBuffer(uint32_t id, std::unique_ptr<base::SharedMemory> shm); | 46 ShmBuffer(uint32_t id, std::unique_ptr<base::SharedMemory> shm); |
47 ~ShmBuffer(); | 47 ~ShmBuffer(); |
48 | 48 |
49 // Index of the buffer in the ScopedVector. Buffers have the same id in | 49 // Index of the buffer in the vector. Buffers have the same id in |
50 // the plugin and the host. | 50 // the plugin and the host. |
51 uint32_t id; | 51 uint32_t id; |
52 std::unique_ptr<base::SharedMemory> shm; | 52 std::unique_ptr<base::SharedMemory> shm; |
53 }; | 53 }; |
54 | 54 |
55 struct BitstreamBuffer { | 55 struct BitstreamBuffer { |
56 BitstreamBuffer(uint32_t id, uint32_t size, bool key_frame); | 56 BitstreamBuffer(uint32_t id, uint32_t size, bool key_frame); |
57 ~BitstreamBuffer(); | 57 ~BitstreamBuffer(); |
58 | 58 |
59 // Index of the buffer in the ScopedVector. Same as ShmBuffer::id. | 59 // Index of the buffer in the vector. Same as ShmBuffer::id. |
60 uint32_t id; | 60 uint32_t id; |
61 uint32_t size; | 61 uint32_t size; |
62 bool key_frame; | 62 bool key_frame; |
63 }; | 63 }; |
64 | 64 |
65 // PPB_VideoEncoder_API implementation. | 65 // PPB_VideoEncoder_API implementation. |
66 int32_t GetSupportedProfiles( | 66 int32_t GetSupportedProfiles( |
67 const PP_ArrayOutput& output, | 67 const PP_ArrayOutput& output, |
68 const scoped_refptr<TrackedCallback>& callback) override; | 68 const scoped_refptr<TrackedCallback>& callback) override; |
69 int32_t GetSupportedProfiles0_1( | 69 int32_t GetSupportedProfiles0_1( |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 | 134 |
135 int32_t input_frame_count_; | 135 int32_t input_frame_count_; |
136 PP_Size input_coded_size_; | 136 PP_Size input_coded_size_; |
137 | 137 |
138 MediaStreamBufferManager buffer_manager_; | 138 MediaStreamBufferManager buffer_manager_; |
139 | 139 |
140 typedef std::map<PP_Resource, scoped_refptr<VideoFrameResource> > | 140 typedef std::map<PP_Resource, scoped_refptr<VideoFrameResource> > |
141 VideoFrameMap; | 141 VideoFrameMap; |
142 VideoFrameMap video_frames_; | 142 VideoFrameMap video_frames_; |
143 | 143 |
144 ScopedVector<ShmBuffer> shm_buffers_; | 144 std::vector<std::unique_ptr<ShmBuffer>> shm_buffers_; |
145 | 145 |
146 std::deque<BitstreamBuffer> available_bitstream_buffers_; | 146 std::deque<BitstreamBuffer> available_bitstream_buffers_; |
147 typedef std::map<void*, uint32_t> BitstreamBufferMap; | 147 typedef std::map<void*, uint32_t> BitstreamBufferMap; |
148 BitstreamBufferMap bitstream_buffer_map_; | 148 BitstreamBufferMap bitstream_buffer_map_; |
149 | 149 |
150 scoped_refptr<TrackedCallback> get_supported_profiles_callback_; | 150 scoped_refptr<TrackedCallback> get_supported_profiles_callback_; |
151 scoped_refptr<TrackedCallback> initialize_callback_; | 151 scoped_refptr<TrackedCallback> initialize_callback_; |
152 scoped_refptr<TrackedCallback> get_video_frame_callback_; | 152 scoped_refptr<TrackedCallback> get_video_frame_callback_; |
153 PP_Resource* get_video_frame_data_; | 153 PP_Resource* get_video_frame_data_; |
154 | 154 |
155 typedef std::map<PP_Resource, scoped_refptr<TrackedCallback> > EncodeMap; | 155 typedef std::map<PP_Resource, scoped_refptr<TrackedCallback> > EncodeMap; |
156 EncodeMap encode_callbacks_; | 156 EncodeMap encode_callbacks_; |
157 | 157 |
158 scoped_refptr<TrackedCallback> get_bitstream_buffer_callback_; | 158 scoped_refptr<TrackedCallback> get_bitstream_buffer_callback_; |
159 PP_BitstreamBuffer* get_bitstream_buffer_data_; | 159 PP_BitstreamBuffer* get_bitstream_buffer_data_; |
160 | 160 |
161 DISALLOW_COPY_AND_ASSIGN(VideoEncoderResource); | 161 DISALLOW_COPY_AND_ASSIGN(VideoEncoderResource); |
162 }; | 162 }; |
163 | 163 |
164 } // namespace proxy | 164 } // namespace proxy |
165 } // namespace ppapi | 165 } // namespace ppapi |
166 | 166 |
167 #endif // PPAPI_PROXY_VIDEO_ENCODER_RESOURCE_H_ | 167 #endif // PPAPI_PROXY_VIDEO_ENCODER_RESOURCE_H_ |
OLD | NEW |