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

Unified Diff: ppapi/proxy/media_stream_video_track_resource.cc

Issue 122383002: [WIP][PPAPI] Implement MediaStreamVideoTrackResource. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@io_stream_cl
Patch Set: Update Created 6 years, 12 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
« no previous file with comments | « ppapi/proxy/media_stream_video_track_resource.h ('k') | ppapi/proxy/plugin_var_tracker.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/proxy/media_stream_video_track_resource.cc
diff --git a/ppapi/proxy/media_stream_video_track_resource.cc b/ppapi/proxy/media_stream_video_track_resource.cc
new file mode 100644
index 0000000000000000000000000000000000000000..d56f85195cdaebd6fdfd17c922e89819a7d06697
--- /dev/null
+++ b/ppapi/proxy/media_stream_video_track_resource.cc
@@ -0,0 +1,118 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ppapi/proxy/media_stream_video_track_resource.h"
+
+#include "ppapi/proxy/io_stream_resource.h"
+#include "ppapi/proxy/ppapi_messages.h"
+#include "ppapi/proxy/video_frame_resource.h"
+#include "ppapi/shared_impl/var.h"
+#include "ppapi/shared_impl/video_frame.h"
+#include "ppapi/thunk/enter.h"
+
+namespace ppapi {
+namespace proxy {
+
+MediaStreamVideoTrackResource::MediaStreamVideoTrackResource(
+ Connection connection,
+ PP_Instance instance,
+ int pending_renderer_id,
+ const std::string& id)
+ : IOStreamResource(connection, instance, pending_renderer_id, true),
+ id_(id),
+ current_frame_(NULL),
+ get_frame_output_(NULL) {
+}
+
+MediaStreamVideoTrackResource::~MediaStreamVideoTrackResource() {
+ ppapi::ProxyLock::AssertAcquiredDebugOnly();
+}
+
+thunk::PPB_MediaStreamVideoTrack_API*
+MediaStreamVideoTrackResource::AsPPB_MediaStreamVideoTrack_API() {
+ return this;
+}
+
+PP_Var MediaStreamVideoTrackResource::GetId() {
+ return StringVar::StringToPPVar(id_);
+}
+
+PP_Bool MediaStreamVideoTrackResource::HasEnded() {
+ return PP_FALSE;
+}
+
+int32_t MediaStreamVideoTrackResource::Configure(uint32_t max_buffered_frames) {
+ return PP_OK;
+}
+
+int32_t MediaStreamVideoTrackResource::GetFrame(
+ PP_Resource* frame,
+ const scoped_refptr<ppapi::TrackedCallback>& callback) {
+ if (TrackedCallback::IsPending(get_frame_callback_))
+ return PP_ERROR_INPROGRESS;
+ int32_t result = CreateCurrentFrame();
+ if (result == PP_OK) {
+ *frame = current_frame_->GetReference();
+ } else if (result == PP_OK_COMPLETIONPENDING) {
+ get_frame_output_ = frame;
+ get_frame_callback_ = callback;
+ }
+ return result;
+}
+
+int32_t MediaStreamVideoTrackResource::RecycleFrame(PP_Resource frame) {
+ if (!frame)
+ return PP_ERROR_BADRESOURCE;
+ if (!current_frame_)
+ return PP_ERROR_FAILED;
+ if (current_frame_->pp_resource() != frame)
+ return PP_ERROR_BADARGUMENT;
+
+ Unlock(current_frame_->video_frame());
+ current_frame_->set_video_frame(NULL);
+ PpapiGlobals::Get()->GetResourceTracker()->ReleaseResource(
+ current_frame_->pp_resource());
+ current_frame_ = NULL;
+ return PP_OK;
+}
+
+int32_t MediaStreamVideoTrackResource::Close() {
+ return PP_OK;
+}
+
+void MediaStreamVideoTrackResource::OnReplyReceived(
+ const proxy::ResourceMessageReplyParams& params, const IPC::Message& msg) {
+ IPC_BEGIN_MESSAGE_MAP(MediaStreamVideoTrackResource, msg)
+ PPAPI_DISPATCH_PLUGIN_RESOURCE_CALL_UNHANDLED(
+ IOStreamResource::OnReplyReceived(params, msg))
+ IPC_END_MESSAGE_MAP()
+}
+
+void MediaStreamVideoTrackResource::OnMoreBufferAvailable() {
+ int32_t result = PP_ERROR_FAILED;
+ if (TrackedCallback::IsPending(get_frame_callback_))
+ result = CreateCurrentFrame();
+ if (result == PP_OK) {
+ *get_frame_output_ = current_frame_->GetReference();
+ get_frame_callback_->PostRun(PP_OK);
+ get_frame_output_ = 0;
+ get_frame_callback_ = NULL;
+ }
+}
+
+int32_t MediaStreamVideoTrackResource::CreateCurrentFrame() {
+ if (current_frame_)
+ return PP_ERROR_INPROGRESS;
+ if (!remaining())
+ return PP_OK_COMPLETIONPENDING;
+ VideoFrame* frame = NULL;
+ CHECK(Lock(reinterpret_cast<void **>(&frame), sizeof(VideoFrame)) == PP_OK);
+ CHECK(Relock(frame, sizeof(VideoFrame) + frame->data_size) == PP_OK);
+ current_frame_ = new VideoFrameResource(pp_instance(), frame);
+ current_frame_->GetReference();
+ return PP_OK;
+}
+
+} // namespace proxy
+} // namespace ppapi
« no previous file with comments | « ppapi/proxy/media_stream_video_track_resource.h ('k') | ppapi/proxy/plugin_var_tracker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698