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

Unified Diff: ppapi/proxy/video_reader_resource.cc

Issue 13771020: Add Pepper VideoReader and VideoWriter plumbing (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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: ppapi/proxy/video_reader_resource.cc
diff --git a/ppapi/proxy/video_reader_resource.cc b/ppapi/proxy/video_reader_resource.cc
new file mode 100644
index 0000000000000000000000000000000000000000..a547fc3991c50e90ee291266705cc4c8cf89a9cd
--- /dev/null
+++ b/ppapi/proxy/video_reader_resource.cc
@@ -0,0 +1,93 @@
+// Copyright (c) 2013 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/video_reader_resource.h"
+
+#include "base/bind.h"
+#include "ipc/ipc_message.h"
+#include "ppapi/c/pp_errors.h"
+#include "ppapi/c/pp_video_frame.h"
+#include "ppapi/proxy/ppapi_messages.h"
+#include "ppapi/shared_impl/array_writer.h"
+#include "ppapi/shared_impl/ppapi_globals.h"
+#include "ppapi/shared_impl/resource_tracker.h"
+#include "ppapi/shared_impl/var.h"
+#include "ppapi/thunk/enter.h"
+
+using ppapi::thunk::EnterResourceNoLock;
+using ppapi::thunk::PPB_VideoReader_API;
+
+namespace {
+
+} // namespace
+
+namespace ppapi {
+namespace proxy {
+
+VideoReaderResource::VideoReaderResource(
+ Connection connection,
+ PP_Instance instance)
+ : PluginResource(connection, instance) {
+ SendCreate(RENDERER, PpapiHostMsg_VideoReader_Create());
+}
+
+VideoReaderResource::~VideoReaderResource() {
+}
+
+PPB_VideoReader_API* VideoReaderResource::AsPPB_VideoReader_API() {
+ return this;
+}
+
+int32_t VideoReaderResource::Open(
+ PP_Var stream_id,
+ scoped_refptr<TrackedCallback> callback) {
+ scoped_refptr<StringVar> stream_id_var = StringVar::FromPPVar(stream_id);
+ const uint32_t kMaxStreamIdSizeInBytes = 16384;
+ if (!stream_id_var || stream_id_var->value().size() > kMaxStreamIdSizeInBytes)
+ return PP_ERROR_BADARGUMENT;
+ Call<PpapiPluginMsg_VideoReader_OpenReply>(RENDERER,
+ PpapiHostMsg_VideoReader_Open(stream_id_var->value()),
+ base::Bind(&VideoReaderResource::OnPluginMsgOpenComplete, this,
+ callback));
+ return PP_OK_COMPLETIONPENDING;
+}
+
+int32_t VideoReaderResource::GetFrame(
+ PP_VideoFrame* frame,
+ scoped_refptr<TrackedCallback> callback) {
+ Call<PpapiPluginMsg_VideoReader_GetFrameReply>(RENDERER,
+ PpapiHostMsg_VideoReader_GetFrame(),
+ base::Bind(&VideoReaderResource::OnPluginMsgGetFrameComplete, this,
+ callback, frame));
+ return PP_OK_COMPLETIONPENDING;
+}
+
+void VideoReaderResource::Close() {
+ Post(RENDERER, PpapiHostMsg_VideoReader_Close());
+}
+
+void VideoReaderResource::OnPluginMsgOpenComplete(
+ scoped_refptr<TrackedCallback> callback,
+ const ResourceMessageReplyParams& params) {
+ int32_t result = params.result();
+ callback->Run(result);
+}
+
+void VideoReaderResource::OnPluginMsgGetFrameComplete(
+ scoped_refptr<TrackedCallback> callback,
+ PP_VideoFrame* frame,
+ const ResourceMessageReplyParams& params,
+ const HostResource& image_data,
+ double timestamp) {
+ int32_t result = params.result();
+ if (result == PP_OK) {
+ frame->timestamp = static_cast<PP_TimeTicks>(timestamp);
+ frame->image_data = image_data.host_resource();
+ }
+
+ callback->Run(result);
+}
+
+} // namespace proxy
+} // namespace ppapi

Powered by Google App Engine
This is Rietveld 408576698