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

Side by Side Diff: content/renderer/pepper/pepper_video_destination_host.cc

Issue 14968002: Glue code to connect PPAPI proxy to MediaStream sources and destinations. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 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 | Annotate | Revision Log
OLDNEW
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 "content/public/renderer/renderer_ppapi_host.h" 7 #include "content/public/renderer/renderer_ppapi_host.h"
8 #include "ppapi/c/pp_errors.h" 8 #include "ppapi/c/pp_errors.h"
9 #include "ppapi/host/dispatch_host_message.h" 9 #include "ppapi/host/dispatch_host_message.h"
10 #include "ppapi/host/host_message_context.h" 10 #include "ppapi/host/host_message_context.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 IPC_END_MESSAGE_MAP() 44 IPC_END_MESSAGE_MAP()
45 return PP_ERROR_FAILED; 45 return PP_ERROR_FAILED;
46 } 46 }
47 47
48 int32_t PepperVideoDestinationHost::OnHostMsgOpen( 48 int32_t PepperVideoDestinationHost::OnHostMsgOpen(
49 HostMessageContext* context, 49 HostMessageContext* context,
50 const std::string& stream_url) { 50 const std::string& stream_url) {
51 GURL gurl(stream_url); 51 GURL gurl(stream_url);
52 if (!gurl.is_valid()) 52 if (!gurl.is_valid())
53 return PP_ERROR_BADARGUMENT; 53 return PP_ERROR_BADARGUMENT;
54 // TODO(ronghuawu) Check that gurl is a valid MediaStream video track URL. 54
55 // TODO(ronghuawu) Open a MediaStream video track. 55 stream_url_ = gurl.spec();
Ronghua Wu (Left Chromium) 2013/05/05 15:39:35 stream_url_ doesn't seem be used anywhere else out
bbudge 2013/05/06 04:02:15 Done. I removed it since it isn't needed after ope
56 content::FrameWriterInterface* frame_writer = NULL;
57 if (!VideoDestinationHandler::Open(NULL /* factory */,
58 NULL /* registry */,
59 stream_url_,
60 &frame_writer))
61 return PP_ERROR_FAILED;
62 frame_writer_.reset(frame_writer);
63
56 ReplyMessageContext reply_context = context->MakeReplyMessageContext(); 64 ReplyMessageContext reply_context = context->MakeReplyMessageContext();
57 reply_context.params.set_result(PP_OK); 65 reply_context.params.set_result(PP_OK);
58 host()->SendReply(reply_context, 66 host()->SendReply(reply_context,
59 PpapiPluginMsg_VideoDestination_OpenReply()); 67 PpapiPluginMsg_VideoDestination_OpenReply());
60 return PP_OK_COMPLETIONPENDING; 68 return PP_OK_COMPLETIONPENDING;
61 } 69 }
62 70
63 int32_t PepperVideoDestinationHost::OnHostMsgPutFrame( 71 int32_t PepperVideoDestinationHost::OnHostMsgPutFrame(
64 HostMessageContext* context, 72 HostMessageContext* context,
65 const ppapi::HostResource& image_data, 73 const ppapi::HostResource& image_data_resource,
66 PP_TimeTicks timestamp) { 74 PP_TimeTicks timestamp) {
67 ppapi::thunk::EnterResourceNoLock<ppapi::thunk::PPB_ImageData_API> enter( 75 ppapi::thunk::EnterResourceNoLock<ppapi::thunk::PPB_ImageData_API> enter(
68 image_data.host_resource(), true); 76 image_data_resource.host_resource(), true);
69 if (enter.failed()) 77 if (enter.failed())
70 return PP_ERROR_BADRESOURCE; 78 return PP_ERROR_BADRESOURCE;
71 webkit::ppapi::PPB_ImageData_Impl* image_resource = 79 webkit::ppapi::PPB_ImageData_Impl* image_data_impl =
72 static_cast<webkit::ppapi::PPB_ImageData_Impl*>(enter.object()); 80 static_cast<webkit::ppapi::PPB_ImageData_Impl*>(enter.object());
73 81
74 if (!webkit::ppapi::PPB_ImageData_Impl::IsImageDataFormatSupported( 82 if (!webkit::ppapi::PPB_ImageData_Impl::IsImageDataFormatSupported(
75 image_resource->format())) 83 image_data_impl->format()))
76 return PP_ERROR_BADARGUMENT; 84 return PP_ERROR_BADARGUMENT;
77 85
78 // TODO(ronghuawu) write image data to MediaStream video track. 86 if (!frame_writer_.get())
87 return PP_ERROR_FAILED;
88
89 int64_t timestamp_ns =
90 static_cast<int64_t>(timestamp) * talk_base::kNumNanosecsPerSec;
Ronghua Wu (Left Chromium) 2013/05/05 15:39:35 Can you confirm the |timestamp|'s unit is second?
bbudge 2013/05/06 04:02:15 The value is in seconds, but held in a double so f
Ronghua Wu (Left Chromium) 2013/05/06 04:42:07 Then you probably want to do the cast after conver
bbudge 2013/05/06 19:27:50 Good catch. Done.
91 frame_writer_->PutFrame(image_data_impl, timestamp_ns);
92
79 return PP_OK; 93 return PP_OK;
80 } 94 }
81 95
82 int32_t PepperVideoDestinationHost::OnHostMsgClose( 96 int32_t PepperVideoDestinationHost::OnHostMsgClose(
83 HostMessageContext* context) { 97 HostMessageContext* context) {
84 // TODO(ronghuawu) Close the video stream. 98 frame_writer_.reset(NULL);
85 return PP_OK; 99 return PP_OK;
86 } 100 }
87 101
88 } // namespace content 102 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698