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

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: Add lock. 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 content::FrameWriterInterface* frame_writer = NULL;
56 if (!VideoDestinationHandler::Open(NULL /* factory */,
57 NULL /* registry */,
58 gurl.spec(),
59 &frame_writer))
60 return PP_ERROR_FAILED;
61 frame_writer_.reset(frame_writer);
62
56 ReplyMessageContext reply_context = context->MakeReplyMessageContext(); 63 ReplyMessageContext reply_context = context->MakeReplyMessageContext();
57 reply_context.params.set_result(PP_OK); 64 reply_context.params.set_result(PP_OK);
58 host()->SendReply(reply_context, 65 host()->SendReply(reply_context,
59 PpapiPluginMsg_VideoDestination_OpenReply()); 66 PpapiPluginMsg_VideoDestination_OpenReply());
60 return PP_OK_COMPLETIONPENDING; 67 return PP_OK_COMPLETIONPENDING;
61 } 68 }
62 69
63 int32_t PepperVideoDestinationHost::OnHostMsgPutFrame( 70 int32_t PepperVideoDestinationHost::OnHostMsgPutFrame(
64 HostMessageContext* context, 71 HostMessageContext* context,
65 const ppapi::HostResource& image_data, 72 const ppapi::HostResource& image_data_resource,
66 PP_TimeTicks timestamp) { 73 PP_TimeTicks timestamp) {
67 ppapi::thunk::EnterResourceNoLock<ppapi::thunk::PPB_ImageData_API> enter( 74 ppapi::thunk::EnterResourceNoLock<ppapi::thunk::PPB_ImageData_API> enter(
68 image_data.host_resource(), true); 75 image_data_resource.host_resource(), true);
69 if (enter.failed()) 76 if (enter.failed())
70 return PP_ERROR_BADRESOURCE; 77 return PP_ERROR_BADRESOURCE;
71 webkit::ppapi::PPB_ImageData_Impl* image_resource = 78 webkit::ppapi::PPB_ImageData_Impl* image_data_impl =
72 static_cast<webkit::ppapi::PPB_ImageData_Impl*>(enter.object()); 79 static_cast<webkit::ppapi::PPB_ImageData_Impl*>(enter.object());
73 80
74 if (!webkit::ppapi::PPB_ImageData_Impl::IsImageDataFormatSupported( 81 if (!webkit::ppapi::PPB_ImageData_Impl::IsImageDataFormatSupported(
75 image_resource->format())) 82 image_data_impl->format()))
76 return PP_ERROR_BADARGUMENT; 83 return PP_ERROR_BADARGUMENT;
77 84
78 // TODO(ronghuawu) write image data to MediaStream video track. 85 if (!frame_writer_.get())
86 return PP_ERROR_FAILED;
87
88 int64_t timestamp_ns =
89 static_cast<int64_t>(timestamp) * talk_base::kNumNanosecsPerSec;
yzshen1 2013/05/06 16:47:28 nit: Shall we use Time::kNanosecondsPerSecond in b
Tom Sepez 2013/05/06 17:19:35 How do we know what the epoch is for PP_Timeticks
bbudge 2013/05/06 19:27:50 Done.
90 frame_writer_->PutFrame(image_data_impl, timestamp_ns);
91
79 return PP_OK; 92 return PP_OK;
80 } 93 }
81 94
82 int32_t PepperVideoDestinationHost::OnHostMsgClose( 95 int32_t PepperVideoDestinationHost::OnHostMsgClose(
83 HostMessageContext* context) { 96 HostMessageContext* context) {
84 // TODO(ronghuawu) Close the video stream. 97 frame_writer_.reset(NULL);
85 return PP_OK; 98 return PP_OK;
86 } 99 }
87 100
88 } // namespace content 101 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698