| 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 #include "ppapi/proxy/video_encoder_resource.h" | 5 #include "ppapi/proxy/video_encoder_resource.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <memory> |
| 9 #include <utility> | 10 #include <utility> |
| 11 #include <vector> |
| 10 | 12 |
| 11 #include "base/memory/shared_memory.h" | 13 #include "base/memory/shared_memory.h" |
| 12 #include "base/process/process.h" | 14 #include "base/process/process.h" |
| 13 #include "base/synchronization/waitable_event.h" | 15 #include "base/synchronization/waitable_event.h" |
| 14 #include "ppapi/c/pp_codecs.h" | 16 #include "ppapi/c/pp_codecs.h" |
| 15 #include "ppapi/c/pp_errors.h" | 17 #include "ppapi/c/pp_errors.h" |
| 16 #include "ppapi/c/ppb_video_encoder.h" | 18 #include "ppapi/c/ppb_video_encoder.h" |
| 17 #include "ppapi/c/ppb_video_frame.h" | 19 #include "ppapi/c/ppb_video_frame.h" |
| 18 #include "ppapi/proxy/locking_resource_releaser.h" | 20 #include "ppapi/proxy/locking_resource_releaser.h" |
| 19 #include "ppapi/proxy/plugin_message_filter.h" | 21 #include "ppapi/proxy/plugin_message_filter.h" |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 int32_t success, | 285 int32_t success, |
| 284 uint32_t input_frame_count, | 286 uint32_t input_frame_count, |
| 285 const PP_Size& input_coded_size) { | 287 const PP_Size& input_coded_size) { |
| 286 SendReply(params, success, PpapiPluginMsg_VideoEncoder_InitializeReply( | 288 SendReply(params, success, PpapiPluginMsg_VideoEncoder_InitializeReply( |
| 287 input_frame_count, input_coded_size)); | 289 input_frame_count, input_coded_size)); |
| 288 } | 290 } |
| 289 | 291 |
| 290 void SendBitstreamBuffers(const ResourceMessageCallParams& params, | 292 void SendBitstreamBuffers(const ResourceMessageCallParams& params, |
| 291 uint32_t buffer_length) { | 293 uint32_t buffer_length) { |
| 292 std::vector<SerializedHandle> handles; | 294 std::vector<SerializedHandle> handles; |
| 293 for (base::SharedMemory* mem : shared_memory_bitstreams_) { | 295 for (const auto& mem : shared_memory_bitstreams_) { |
| 294 ASSERT_EQ(mem->requested_size(), buffer_length); | 296 ASSERT_EQ(mem->requested_size(), buffer_length); |
| 295 base::SharedMemoryHandle handle = mem->handle().Duplicate(); | 297 base::SharedMemoryHandle handle = mem->handle().Duplicate(); |
| 296 ASSERT_TRUE(handle.IsValid()); | 298 ASSERT_TRUE(handle.IsValid()); |
| 297 handles.push_back(SerializedHandle(handle, buffer_length)); | 299 handles.push_back(SerializedHandle(handle, buffer_length)); |
| 298 } | 300 } |
| 299 SendReplyWithHandles( | 301 SendReplyWithHandles( |
| 300 params, PP_OK, | 302 params, PP_OK, |
| 301 PpapiPluginMsg_VideoEncoder_BitstreamBuffers(buffer_length), handles); | 303 PpapiPluginMsg_VideoEncoder_BitstreamBuffers(buffer_length), handles); |
| 302 } | 304 } |
| 303 | 305 |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 416 video_frame, &frame_size) == PP_TRUE; | 418 video_frame, &frame_size) == PP_TRUE; |
| 417 } | 419 } |
| 418 | 420 |
| 419 private: | 421 private: |
| 420 // MediaStreamBufferManager::Delegate: | 422 // MediaStreamBufferManager::Delegate: |
| 421 void OnNewBufferEnqueued() override {} | 423 void OnNewBufferEnqueued() override {} |
| 422 | 424 |
| 423 const PPB_VideoEncoder_0_2* encoder_iface_; | 425 const PPB_VideoEncoder_0_2* encoder_iface_; |
| 424 const PPB_VideoEncoder_0_1* encoder_iface_0_1_; | 426 const PPB_VideoEncoder_0_1* encoder_iface_0_1_; |
| 425 | 427 |
| 426 ScopedVector<base::SharedMemory> shared_memory_bitstreams_; | 428 std::vector<std::unique_ptr<base::SharedMemory>> shared_memory_bitstreams_; |
| 427 | 429 |
| 428 MediaStreamBufferManager video_frames_manager_; | 430 MediaStreamBufferManager video_frames_manager_; |
| 429 }; | 431 }; |
| 430 | 432 |
| 431 void* ForwardUserData(void* user_data, | 433 void* ForwardUserData(void* user_data, |
| 432 uint32_t element_count, | 434 uint32_t element_count, |
| 433 uint32_t element_size) { | 435 uint32_t element_size) { |
| 434 return user_data; | 436 return user_data; |
| 435 } | 437 } |
| 436 | 438 |
| (...skipping 709 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1146 ResourceMessageCallParams params; | 1148 ResourceMessageCallParams params; |
| 1147 uint32_t frame_id; | 1149 uint32_t frame_id; |
| 1148 bool force_frame; | 1150 bool force_frame; |
| 1149 ASSERT_TRUE(CheckEncodeMsg(¶ms, &frame_id, &force_frame)); | 1151 ASSERT_TRUE(CheckEncodeMsg(¶ms, &frame_id, &force_frame)); |
| 1150 SendEncodeReply(params, frame_id); | 1152 SendEncodeReply(params, frame_id); |
| 1151 } | 1153 } |
| 1152 } | 1154 } |
| 1153 | 1155 |
| 1154 } // namespace proxy | 1156 } // namespace proxy |
| 1155 } // namespace ppapi | 1157 } // namespace ppapi |
| OLD | NEW |