Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 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 "content/renderer/pepper/pepper_video_destination_host.h" | 5 #include "content/renderer/pepper/pepper_video_destination_host.h" |
| 6 | 6 |
| 7 #include "base/time/time.h" | 7 #include "base/time/time.h" |
| 8 #include "content/public/renderer/renderer_ppapi_host.h" | 8 #include "content/public/renderer/renderer_ppapi_host.h" |
| 9 #include "content/renderer/pepper/ppb_image_data_impl.h" | 9 #include "content/renderer/pepper/ppb_image_data_impl.h" |
| 10 #include "ppapi/c/pp_errors.h" | 10 #include "ppapi/c/pp_errors.h" |
| 11 #include "ppapi/host/dispatch_host_message.h" | 11 #include "ppapi/host/dispatch_host_message.h" |
| 12 #include "ppapi/host/host_message_context.h" | 12 #include "ppapi/host/host_message_context.h" |
| 13 #include "ppapi/host/ppapi_host.h" | 13 #include "ppapi/host/ppapi_host.h" |
| 14 #include "ppapi/proxy/ppapi_messages.h" | 14 #include "ppapi/proxy/ppapi_messages.h" |
| 15 #include "ppapi/thunk/enter.h" | 15 #include "ppapi/thunk/enter.h" |
| 16 #include "ppapi/thunk/ppb_image_data_api.h" | 16 #include "ppapi/thunk/ppb_image_data_api.h" |
| 17 | 17 |
| 18 using ppapi::host::HostMessageContext; | 18 using ppapi::host::HostMessageContext; |
| 19 using ppapi::host::ReplyMessageContext; | 19 using ppapi::host::ReplyMessageContext; |
| 20 | 20 |
| 21 namespace content { | 21 namespace content { |
| 22 | 22 |
| 23 PepperVideoDestinationHost::PepperVideoDestinationHost( | 23 PepperVideoDestinationHost::PepperVideoDestinationHost(RendererPpapiHost* host, |
| 24 RendererPpapiHost* host, | 24 PP_Instance instance, |
| 25 PP_Instance instance, | 25 PP_Resource resource) |
| 26 PP_Resource resource) | |
| 27 : ResourceHost(host->GetPpapiHost(), instance, resource), | 26 : ResourceHost(host->GetPpapiHost(), instance, resource), |
| 28 renderer_ppapi_host_(host), | 27 renderer_ppapi_host_(host), |
| 29 weak_factory_(this) { | 28 weak_factory_(this) {} |
| 30 } | |
| 31 | 29 |
| 32 PepperVideoDestinationHost::~PepperVideoDestinationHost() { | 30 PepperVideoDestinationHost::~PepperVideoDestinationHost() {} |
| 33 } | |
| 34 | 31 |
| 35 int32_t PepperVideoDestinationHost::OnResourceMessageReceived( | 32 int32_t PepperVideoDestinationHost::OnResourceMessageReceived( |
| 36 const IPC::Message& msg, | 33 const IPC::Message& msg, |
| 37 HostMessageContext* context) { | 34 HostMessageContext* context) { |
| 38 IPC_BEGIN_MESSAGE_MAP(PepperVideoDestinationHost, msg) | 35 IPC_BEGIN_MESSAGE_MAP(PepperVideoDestinationHost, msg) |
| 39 PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_VideoDestination_Open, | 36 PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_VideoDestination_Open, |
| 40 OnHostMsgOpen) | 37 OnHostMsgOpen) |
| 41 PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_VideoDestination_PutFrame, | 38 PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_VideoDestination_PutFrame, |
| 42 OnHostMsgPutFrame) | 39 OnHostMsgPutFrame) |
| 43 PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_VideoDestination_Close, | 40 PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_VideoDestination_Close, |
| 44 OnHostMsgClose) | 41 OnHostMsgClose) |
| 45 IPC_END_MESSAGE_MAP() | 42 IPC_END_MESSAGE_MAP() |
| 46 return PP_ERROR_FAILED; | 43 return PP_ERROR_FAILED; |
| 47 } | 44 } |
| 48 | 45 |
| 49 int32_t PepperVideoDestinationHost::OnHostMsgOpen( | 46 int32_t PepperVideoDestinationHost::OnHostMsgOpen( |
| 50 HostMessageContext* context, | 47 HostMessageContext* context, |
| 51 const std::string& stream_url) { | 48 const std::string& stream_url) { |
| 52 GURL gurl(stream_url); | 49 GURL gurl(stream_url); |
| 53 if (!gurl.is_valid()) | 50 if (!gurl.is_valid()) |
| 54 return PP_ERROR_BADARGUMENT; | 51 return PP_ERROR_BADARGUMENT; |
| 55 | 52 |
| 56 FrameWriterInterface* frame_writer = NULL; | 53 FrameWriterInterface* frame_writer = NULL; |
| 57 if (!VideoDestinationHandler::Open(NULL /* factory */, | 54 if (!VideoDestinationHandler::Open( |
| 58 NULL /* registry */, | 55 NULL /* factory */, NULL /* registry */, gurl.spec(), &frame_writer)) |
|
bbudge
2014/04/07 17:02:17
This is a little less readable.
| |
| 59 gurl.spec(), | |
| 60 &frame_writer)) | |
| 61 return PP_ERROR_FAILED; | 56 return PP_ERROR_FAILED; |
| 62 frame_writer_.reset(frame_writer); | 57 frame_writer_.reset(frame_writer); |
| 63 | 58 |
| 64 ReplyMessageContext reply_context = context->MakeReplyMessageContext(); | 59 ReplyMessageContext reply_context = context->MakeReplyMessageContext(); |
| 65 reply_context.params.set_result(PP_OK); | 60 reply_context.params.set_result(PP_OK); |
| 66 host()->SendReply(reply_context, | 61 host()->SendReply(reply_context, PpapiPluginMsg_VideoDestination_OpenReply()); |
| 67 PpapiPluginMsg_VideoDestination_OpenReply()); | |
| 68 return PP_OK_COMPLETIONPENDING; | 62 return PP_OK_COMPLETIONPENDING; |
| 69 } | 63 } |
| 70 | 64 |
| 71 int32_t PepperVideoDestinationHost::OnHostMsgPutFrame( | 65 int32_t PepperVideoDestinationHost::OnHostMsgPutFrame( |
| 72 HostMessageContext* context, | 66 HostMessageContext* context, |
| 73 const ppapi::HostResource& image_data_resource, | 67 const ppapi::HostResource& image_data_resource, |
| 74 PP_TimeTicks timestamp) { | 68 PP_TimeTicks timestamp) { |
| 75 ppapi::thunk::EnterResourceNoLock<ppapi::thunk::PPB_ImageData_API> enter( | 69 ppapi::thunk::EnterResourceNoLock<ppapi::thunk::PPB_ImageData_API> enter( |
| 76 image_data_resource.host_resource(), true); | 70 image_data_resource.host_resource(), true); |
| 77 if (enter.failed()) | 71 if (enter.failed()) |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 98 return PP_OK; | 92 return PP_OK; |
| 99 } | 93 } |
| 100 | 94 |
| 101 int32_t PepperVideoDestinationHost::OnHostMsgClose( | 95 int32_t PepperVideoDestinationHost::OnHostMsgClose( |
| 102 HostMessageContext* context) { | 96 HostMessageContext* context) { |
| 103 frame_writer_.reset(NULL); | 97 frame_writer_.reset(NULL); |
| 104 return PP_OK; | 98 return PP_OK; |
| 105 } | 99 } |
| 106 | 100 |
| 107 } // namespace content | 101 } // namespace content |
| OLD | NEW |