| 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..5acc78fd226c1f87aa0fe98b9bbe0ad8f0e8524a 100644
|
| --- a/content/renderer/pepper/pepper_video_destination_host.cc
|
| +++ b/content/renderer/pepper/pepper_video_destination_host.cc
|
| @@ -51,8 +51,15 @@ 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.
|
| +
|
| + content::FrameWriterInterface* frame_writer = NULL;
|
| + if (!VideoDestinationHandler::Open(NULL /* factory */,
|
| + NULL /* registry */,
|
| + gurl.spec(),
|
| + &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 +69,35 @@ 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;
|
| +
|
| + // Convert PP_TimeTicks (a double, in seconds) to time delta in microseconds,
|
| + // and then to a timestamp in nanoseconds.
|
| + base::TimeDelta time(base::Time::FromDoubleT(timestamp) - base::Time());
|
| + int64_t timestamp_ns =
|
| + time.InMicroseconds() * base::Time::kNanosecondsPerMicrosecond;
|
| + 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;
|
| }
|
|
|
|
|