Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "ppapi/proxy/video_destination_resource.h" | |
| 6 | |
| 7 #include "base/bind.h" | |
| 8 #include "ipc/ipc_message.h" | |
| 9 #include "ppapi/c/pp_errors.h" | |
| 10 #include "ppapi/c/private/pp_video_frame_private.h" | |
| 11 #include "ppapi/proxy/ppapi_messages.h" | |
| 12 #include "ppapi/shared_impl/array_writer.h" | |
|
yzshen1
2013/05/01 23:18:33
you probably don't need this.
bbudge
2013/05/02 21:39:06
Done.
| |
| 13 #include "ppapi/shared_impl/ppapi_globals.h" | |
| 14 #include "ppapi/shared_impl/resource_tracker.h" | |
| 15 #include "ppapi/shared_impl/var.h" | |
|
yzshen1
2013/05/01 23:18:33
this has been included in the .h file.
bbudge
2013/05/02 21:39:06
Done.
| |
| 16 #include "ppapi/thunk/enter.h" | |
| 17 #include "ppapi/thunk/ppb_image_data_api.h" | |
| 18 | |
| 19 using ppapi::thunk::EnterResourceNoLock; | |
| 20 using ppapi::thunk::PPB_VideoDestination_Private_API; | |
| 21 | |
| 22 namespace { | |
|
yzshen1
2013/05/01 23:18:33
this is not needed.
bbudge
2013/05/02 21:39:06
Done.
| |
| 23 | |
| 24 } // namespace | |
| 25 | |
| 26 namespace ppapi { | |
| 27 namespace proxy { | |
| 28 | |
| 29 VideoDestinationResource::VideoDestinationResource( | |
| 30 Connection connection, | |
| 31 PP_Instance instance) | |
| 32 : PluginResource(connection, instance) { | |
| 33 SendCreate(RENDERER, PpapiHostMsg_VideoDestination_Create()); | |
| 34 } | |
| 35 | |
| 36 VideoDestinationResource::~VideoDestinationResource() { | |
| 37 } | |
| 38 | |
| 39 PPB_VideoDestination_Private_API* | |
| 40 VideoDestinationResource::AsPPB_VideoDestination_Private_API() { | |
| 41 return this; | |
| 42 } | |
| 43 | |
| 44 int32_t VideoDestinationResource::Open( | |
| 45 PP_Var stream_url, | |
| 46 scoped_refptr<TrackedCallback> callback) { | |
| 47 scoped_refptr<StringVar> stream_url_var = StringVar::FromPPVar(stream_url); | |
| 48 const uint32_t kMaxStreamIdSizeInBytes = 16384; | |
| 49 if (!stream_url_var || | |
| 50 stream_url_var->value().size() > kMaxStreamIdSizeInBytes) | |
| 51 return PP_ERROR_BADARGUMENT; | |
| 52 Call<PpapiPluginMsg_VideoDestination_OpenReply>(RENDERER, | |
| 53 PpapiHostMsg_VideoDestination_Open(stream_url_var->value()), | |
| 54 base::Bind(&VideoDestinationResource::OnPluginMsgOpenComplete, | |
| 55 this, | |
| 56 callback)); | |
| 57 return PP_OK_COMPLETIONPENDING; | |
| 58 } | |
| 59 | |
| 60 int32_t VideoDestinationResource::PutFrame( | |
| 61 const PP_VideoFrame_Private& frame) { | |
| 62 thunk::EnterResourceNoLock<thunk::PPB_ImageData_API> enter_image( | |
| 63 frame.image_data, true); | |
| 64 if (enter_image.failed()) | |
| 65 return PP_ERROR_BADRESOURCE; | |
| 66 | |
| 67 // Check that the PP_Instance matches. | |
| 68 Resource* image_object = | |
| 69 PpapiGlobals::Get()->GetResourceTracker()->GetResource(frame.image_data); | |
| 70 if (!image_object || pp_instance() != image_object->pp_instance()) { | |
| 71 Log(PP_LOGLEVEL_ERROR, | |
| 72 "VideoDestinationPrivateResource.PutFrame: Bad image resource."); | |
| 73 return PP_ERROR_BADRESOURCE; | |
| 74 } | |
| 75 | |
| 76 Post(RENDERER, | |
| 77 PpapiHostMsg_VideoDestination_PutFrame(image_object->host_resource(), | |
| 78 frame.timestamp)); | |
| 79 return PP_OK; | |
| 80 } | |
| 81 | |
| 82 void VideoDestinationResource::Close() { | |
| 83 Post(RENDERER, PpapiHostMsg_VideoDestination_Close()); | |
| 84 } | |
| 85 | |
| 86 void VideoDestinationResource::OnPluginMsgOpenComplete( | |
| 87 scoped_refptr<TrackedCallback> callback, | |
| 88 const ResourceMessageReplyParams& params) { | |
| 89 int32_t result = params.result(); | |
| 90 callback->Run(result); | |
| 91 } | |
| 92 | |
| 93 } // namespace proxy | |
| 94 } // namespace ppapi | |
| OLD | NEW |