Chromium Code Reviews| Index: content/renderer/pepper/pepper_video_destination_host.cc |
| diff --git a/content/renderer/pepper/pepper_video_destination_host.cc b/content/renderer/pepper/pepper_video_destination_host.cc |
| index 13760d6864dbdf24b704dbeb275e4ebaed1680d8..487dba98ccb28bc788bd9a45af693002fe2278f2 100644 |
| --- a/content/renderer/pepper/pepper_video_destination_host.cc |
| +++ b/content/renderer/pepper/pepper_video_destination_host.cc |
| @@ -51,8 +51,16 @@ int32_t PepperVideoDestinationHost::OnHostMsgOpen( |
| GURL gurl(stream_url); |
| if (!gurl.is_valid()) |
| return PP_ERROR_BADARGUMENT; |
| - // TODO(ronghuawu) Check that gurl is a valid MediaStream video track URL. |
| - // TODO(ronghuawu) Open a MediaStream video track. |
| + |
| + 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
|
| + content::FrameWriterInterface* frame_writer = NULL; |
| + if (!VideoDestinationHandler::Open(NULL /* factory */, |
| + NULL /* registry */, |
| + stream_url_, |
| + &frame_writer)) |
| + return PP_ERROR_FAILED; |
| + frame_writer_.reset(frame_writer); |
| + |
| ReplyMessageContext reply_context = context->MakeReplyMessageContext(); |
| reply_context.params.set_result(PP_OK); |
| host()->SendReply(reply_context, |
| @@ -62,26 +70,32 @@ int32_t PepperVideoDestinationHost::OnHostMsgOpen( |
| int32_t PepperVideoDestinationHost::OnHostMsgPutFrame( |
| HostMessageContext* context, |
| - const ppapi::HostResource& image_data, |
| + const ppapi::HostResource& image_data_resource, |
| PP_TimeTicks timestamp) { |
| ppapi::thunk::EnterResourceNoLock<ppapi::thunk::PPB_ImageData_API> enter( |
| - image_data.host_resource(), true); |
| + image_data_resource.host_resource(), true); |
| if (enter.failed()) |
| return PP_ERROR_BADRESOURCE; |
| - webkit::ppapi::PPB_ImageData_Impl* image_resource = |
| + webkit::ppapi::PPB_ImageData_Impl* image_data_impl = |
| static_cast<webkit::ppapi::PPB_ImageData_Impl*>(enter.object()); |
| if (!webkit::ppapi::PPB_ImageData_Impl::IsImageDataFormatSupported( |
| - image_resource->format())) |
| + image_data_impl->format())) |
| return PP_ERROR_BADARGUMENT; |
| - // TODO(ronghuawu) write image data to MediaStream video track. |
| + if (!frame_writer_.get()) |
| + return PP_ERROR_FAILED; |
| + |
| + int64_t timestamp_ns = |
| + 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.
|
| + frame_writer_->PutFrame(image_data_impl, timestamp_ns); |
| + |
| return PP_OK; |
| } |
| int32_t PepperVideoDestinationHost::OnHostMsgClose( |
| HostMessageContext* context) { |
| - // TODO(ronghuawu) Close the video stream. |
| + frame_writer_.reset(NULL); |
| return PP_OK; |
| } |