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

Unified Diff: ppapi/proxy/ppp_video_decoder_proxy.cc

Issue 7545014: Implement PPAPI VideoDecode out-of-process support (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 9 years, 5 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/ppp_video_decoder_proxy.cc
diff --git a/ppapi/proxy/ppp_video_decoder_proxy.cc b/ppapi/proxy/ppp_video_decoder_proxy.cc
new file mode 100644
index 0000000000000000000000000000000000000000..baf0a051ceb0b727d9f7c4c0a2b813e3ca6558f1
--- /dev/null
+++ b/ppapi/proxy/ppp_video_decoder_proxy.cc
@@ -0,0 +1,173 @@
+// Copyright (c) 2011 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/ppp_video_decoder_proxy.h"
+
+#include "ppapi/proxy/host_dispatcher.h"
+#include "ppapi/proxy/ppapi_messages.h"
+#include "ppapi/proxy/ppb_video_decoder_proxy.h"
+#include "ppapi/thunk/enter.h"
+#include "ppapi/thunk/ppb_video_decoder_api.h"
+#include "ppapi/thunk/thunk.h"
+
+using ::ppapi::thunk::PPB_VideoDecoder_API;
+
+namespace pp {
+namespace proxy {
+
+namespace {
+
+void ProvidePictureBuffers(PP_Instance instance, PP_Resource decoder,
+ uint32_t req_num_of_bufs, PP_Size dimensions) {
+ HostResource decoder_resource;
+ decoder_resource.SetHostResource(instance, decoder);
+
+ HostDispatcher::GetForInstance(instance)->Send(
+ new PpapiMsg_PPPVideoDecoder_ProvidePictureBuffers(
+ INTERFACE_ID_PPP_VIDEO_DECODER_DEV,
+ decoder_resource, req_num_of_bufs, dimensions));
+}
+
+void DismissPictureBuffer(PP_Instance instance, PP_Resource decoder,
+ int32_t picture_buffer_id) {
+ HostResource decoder_resource;
+ decoder_resource.SetHostResource(instance, decoder);
+
+ HostDispatcher::GetForInstance(instance)->Send(
+ new PpapiMsg_PPPVideoDecoder_DismissPictureBuffer(
+ INTERFACE_ID_PPP_VIDEO_DECODER_DEV,
+ decoder_resource, picture_buffer_id));
+}
+
+void PictureReady(PP_Instance instance, PP_Resource decoder,
+ PP_Picture_Dev picture) {
+ HostResource decoder_resource;
+ decoder_resource.SetHostResource(instance, decoder);
+
+ HostDispatcher::GetForInstance(instance)->Send(
+ new PpapiMsg_PPPVideoDecoder_PictureReady(
+ INTERFACE_ID_PPP_VIDEO_DECODER_DEV, decoder_resource, picture));
+}
+
+void EndOfStream(PP_Instance instance, PP_Resource decoder) {
+ HostResource decoder_resource;
+ decoder_resource.SetHostResource(instance, decoder);
+
+ HostDispatcher::GetForInstance(instance)->Send(
+ new PpapiMsg_PPPVideoDecoder_NotifyEndOfStream(
+ INTERFACE_ID_PPP_VIDEO_DECODER_DEV, decoder_resource));
+}
+
+void NotifyError(PP_Instance instance, PP_Resource decoder,
+ PP_VideoDecodeError_Dev error) {
+ HostResource decoder_resource;
+ decoder_resource.SetHostResource(instance, decoder);
+
+ HostDispatcher::GetForInstance(instance)->Send(
+ new PpapiMsg_PPPVideoDecoder_NotifyError(
+ INTERFACE_ID_PPP_VIDEO_DECODER_DEV, decoder_resource, error));
+}
+
+static const PPP_VideoDecoder_Dev video_decoder_interface = {
+ &ProvidePictureBuffers,
+ &DismissPictureBuffer,
+ &PictureReady,
+ &EndOfStream,
+ &NotifyError
+};
+
+InterfaceProxy* CreateVideoDecoderPPPProxy(
+ Dispatcher* dispatcher, const void* target_interface) {
+ return new PPP_VideoDecoder_Proxy(dispatcher, target_interface);
+}
+
+} // namespace
+
+PPP_VideoDecoder_Proxy::PPP_VideoDecoder_Proxy(
+ Dispatcher* dispatcher, const void* target_interface)
+ : InterfaceProxy(dispatcher, target_interface) {
+}
+
+PPP_VideoDecoder_Proxy::~PPP_VideoDecoder_Proxy() {
+}
+
+// static
+const InterfaceProxy::Info* PPP_VideoDecoder_Proxy::GetInfo() {
+ static const Info info = {
+ &video_decoder_interface,
+ PPP_VIDEODECODER_DEV_INTERFACE,
+ INTERFACE_ID_PPP_VIDEO_DECODER_DEV,
+ false,
+ &CreateVideoDecoderPPPProxy,
+ };
+ return &info;
+}
+
+bool PPP_VideoDecoder_Proxy::OnMessageReceived(const IPC::Message& msg) {
+ bool handled = true;
+ IPC_BEGIN_MESSAGE_MAP(PPP_VideoDecoder_Proxy, msg)
+ IPC_MESSAGE_HANDLER(PpapiMsg_PPPVideoDecoder_ProvidePictureBuffers,
+ OnMsgProvidePictureBuffers)
+ IPC_MESSAGE_HANDLER(PpapiMsg_PPPVideoDecoder_DismissPictureBuffer,
+ OnMsgDismissPictureBuffer)
+ IPC_MESSAGE_HANDLER(PpapiMsg_PPPVideoDecoder_PictureReady,
+ OnMsgPictureReady)
+ IPC_MESSAGE_HANDLER(PpapiMsg_PPPVideoDecoder_NotifyEndOfStream,
+ OnMsgNotifyEndOfStream)
+ IPC_MESSAGE_HANDLER(PpapiMsg_PPPVideoDecoder_NotifyError,
+ OnMsgNotifyError)
+ IPC_MESSAGE_UNHANDLED(handled = false)
+ IPC_END_MESSAGE_MAP()
+ DCHECK(handled);
+ return handled;
+}
+
+void PPP_VideoDecoder_Proxy::OnMsgProvidePictureBuffers(
+ const HostResource& decoder, uint32_t req_num_of_bufs,
+ const PP_Size& dimensions) {
+ if (!ppp_video_decoder_target())
brettw 2011/08/03 20:33:14 You don't need to check this, the proxy won't crea
Ami GONE FROM CHROMIUM 2011/08/03 20:37:36 I meant dispatcher-for-instance, not instance. Sp
brettw 2011/08/03 20:39:03 Oh yeah, we do need to check those cases. The user
vrk (LEFT CHROMIUM) 2011/08/03 22:05:22 Hooray! Done for this and in the pp*b* version.
vrk (LEFT CHROMIUM) 2011/08/03 22:05:22 SGTM, though I think in PPB_VideoDecoder_Impl::Cre
+ return;
+
+ ppp_video_decoder_target()->ProvidePictureBuffers(
+ decoder.instance(), decoder.host_resource(), req_num_of_bufs, dimensions);
+}
+
+void PPP_VideoDecoder_Proxy::OnMsgDismissPictureBuffer(
+ const HostResource& decoder, int32_t picture_id) {
+ if (!ppp_video_decoder_target())
+ return;
+
+ ppp_video_decoder_target()->DismissPictureBuffer(
+ decoder.instance(), decoder.host_resource(), picture_id);
+}
+
+void PPP_VideoDecoder_Proxy::OnMsgPictureReady(
+ const HostResource& decoder, const PP_Picture_Dev& picture) {
+ if (!ppp_video_decoder_target())
+ return;
+
+ ppp_video_decoder_target()->PictureReady(
+ decoder.instance(), decoder.host_resource(), picture);
+}
+
+void PPP_VideoDecoder_Proxy::OnMsgNotifyEndOfStream(
+ const HostResource& decoder) {
+ if (!ppp_video_decoder_target())
+ return;
+
+ ppp_video_decoder_target()->EndOfStream(
+ decoder.instance(), decoder.host_resource());
+}
+
+void PPP_VideoDecoder_Proxy::OnMsgNotifyError(
+ const HostResource& decoder, PP_VideoDecodeError_Dev error) {
+ if (!ppp_video_decoder_target())
+ return;
+
+ ppp_video_decoder_target()->NotifyError(
+ decoder.instance(), decoder.host_resource(), error);
+}
+
+} // namespace proxy
+} // namespace pp

Powered by Google App Engine
This is Rietveld 408576698