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..9bdde0223f8960459012be38ad1244d26590c1cc |
--- /dev/null |
+++ b/ppapi/proxy/ppp_video_decoder_proxy.cc |
@@ -0,0 +1,158 @@ |
+// 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) { |
+ ppp_video_decoder_target()->ProvidePictureBuffers( |
+ decoder.instance(), decoder.host_resource(), req_num_of_bufs, dimensions); |
brettw
2011/08/04 19:47:30
The use of host_resource() in these functions is w
vrk (LEFT CHROMIUM)
2011/08/04 21:17:09
Ahhh good catch!! Fixed and thanks for pointing th
|
+} |
+ |
+void PPP_VideoDecoder_Proxy::OnMsgDismissPictureBuffer( |
+ const HostResource& decoder, int32_t picture_id) { |
+ 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) { |
+ ppp_video_decoder_target()->PictureReady( |
+ decoder.instance(), decoder.host_resource(), picture); |
+} |
+ |
+void PPP_VideoDecoder_Proxy::OnMsgNotifyEndOfStream( |
+ const HostResource& decoder) { |
+ ppp_video_decoder_target()->EndOfStream( |
+ decoder.instance(), decoder.host_resource()); |
+} |
+ |
+void PPP_VideoDecoder_Proxy::OnMsgNotifyError( |
+ const HostResource& decoder, PP_VideoDecodeError_Dev error) { |
+ ppp_video_decoder_target()->NotifyError( |
+ decoder.instance(), decoder.host_resource(), error); |
+} |
+ |
+} // namespace proxy |
+} // namespace pp |