Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(56)

Side by Side Diff: ppapi/proxy/video_encoder_resource.cc

Issue 956893002: content: pepper: VideoEncoder: add software encoder support (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Another android dep fix Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ppapi/examples/video_encode/video_encode.html ('k') | ppapi/tests/test_video_encoder.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/memory/shared_memory.h" 5 #include "base/memory/shared_memory.h"
6 #include "base/numerics/safe_conversions.h" 6 #include "base/numerics/safe_conversions.h"
7 #include "ppapi/c/pp_array_output.h" 7 #include "ppapi/c/pp_array_output.h"
8 #include "ppapi/proxy/ppapi_messages.h" 8 #include "ppapi/proxy/ppapi_messages.h"
9 #include "ppapi/proxy/video_encoder_resource.h" 9 #include "ppapi/proxy/video_encoder_resource.h"
10 #include "ppapi/proxy/video_frame_resource.h" 10 #include "ppapi/proxy/video_frame_resource.h"
11 #include "ppapi/shared_impl/array_writer.h"
11 #include "ppapi/shared_impl/media_stream_buffer.h" 12 #include "ppapi/shared_impl/media_stream_buffer.h"
12 #include "ppapi/shared_impl/media_stream_buffer_manager.h" 13 #include "ppapi/shared_impl/media_stream_buffer_manager.h"
13 #include "ppapi/thunk/enter.h" 14 #include "ppapi/thunk/enter.h"
14 15
15 using ppapi::proxy::SerializedHandle; 16 using ppapi::proxy::SerializedHandle;
16 using ppapi::thunk::EnterResourceNoLock; 17 using ppapi::thunk::EnterResourceNoLock;
17 using ppapi::thunk::PPB_VideoEncoder_API; 18 using ppapi::thunk::PPB_VideoEncoder_API;
18 19
19 namespace ppapi { 20 namespace ppapi {
20 namespace proxy { 21 namespace proxy {
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 OnPluginMsgNotifyError) 243 OnPluginMsgNotifyError)
243 PPAPI_DISPATCH_PLUGIN_RESOURCE_CALL_UNHANDLED( 244 PPAPI_DISPATCH_PLUGIN_RESOURCE_CALL_UNHANDLED(
244 PluginResource::OnReplyReceived(params, msg)) 245 PluginResource::OnReplyReceived(params, msg))
245 PPAPI_END_MESSAGE_MAP() 246 PPAPI_END_MESSAGE_MAP()
246 } 247 }
247 248
248 void VideoEncoderResource::OnPluginMsgGetSupportedProfilesReply( 249 void VideoEncoderResource::OnPluginMsgGetSupportedProfilesReply(
249 const PP_ArrayOutput& output, 250 const PP_ArrayOutput& output,
250 const ResourceMessageReplyParams& params, 251 const ResourceMessageReplyParams& params,
251 const std::vector<PP_VideoProfileDescription>& profiles) { 252 const std::vector<PP_VideoProfileDescription>& profiles) {
252 void* ptr = output.GetDataBuffer( 253 int32_t error = params.result();
253 output.user_data, 254 if (error) {
254 base::checked_cast<uint32_t>(profiles.size()), 255 NotifyError(error);
255 base::checked_cast<uint32_t>(sizeof(PP_VideoProfileDescription))); 256 return;
257 }
256 258
257 if (!ptr) { 259 ArrayWriter writer(output);
260 if (!writer.is_valid()) {
261 RunCallback(&get_supported_profiles_callback_, PP_ERROR_BADARGUMENT);
262 return;
263 }
264
265 if (!writer.StoreVector(profiles)) {
258 RunCallback(&get_supported_profiles_callback_, PP_ERROR_FAILED); 266 RunCallback(&get_supported_profiles_callback_, PP_ERROR_FAILED);
259 return; 267 return;
260 } 268 }
261 269
262 if (profiles.size() > 0)
263 memcpy(ptr, &profiles[0],
264 profiles.size() * sizeof(PP_VideoProfileDescription));
265 RunCallback(&get_supported_profiles_callback_, PP_OK); 270 RunCallback(&get_supported_profiles_callback_, PP_OK);
266 } 271 }
267 272
268 void VideoEncoderResource::OnPluginMsgInitializeReply( 273 void VideoEncoderResource::OnPluginMsgInitializeReply(
269 const ResourceMessageReplyParams& params, 274 const ResourceMessageReplyParams& params,
270 uint32_t input_frame_count, 275 uint32_t input_frame_count,
271 const PP_Size& input_coded_size) { 276 const PP_Size& input_coded_size) {
272 DCHECK(!initialized_); 277 DCHECK(!initialized_);
273 278
274 encoder_last_error_ = params.result(); 279 encoder_last_error_ = params.result();
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 for (VideoFrameMap::iterator it = video_frames_.begin(); 423 for (VideoFrameMap::iterator it = video_frames_.begin();
419 it != video_frames_.end(); ++it) { 424 it != video_frames_.end(); ++it) {
420 it->second->Invalidate(); 425 it->second->Invalidate();
421 it->second = nullptr; 426 it->second = nullptr;
422 } 427 }
423 video_frames_.clear(); 428 video_frames_.clear();
424 } 429 }
425 430
426 } // namespace proxy 431 } // namespace proxy
427 } // namespace ppapi 432 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/examples/video_encode/video_encode.html ('k') | ppapi/tests/test_video_encoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698