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

Unified 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: Fix casts. Use base::Time for timestamp calculation.x 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 side-by-side diff with in-line comments
Download patch
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;
}

Powered by Google App Engine
This is Rietveld 408576698