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..793136f2a661f3ea37a9abed4a5bf1da58c278bd |
--- /dev/null |
+++ b/ppapi/proxy/ppp_video_decoder_proxy.cc |
@@ -0,0 +1,171 @@ |
+// 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/c/dev/ppp_video_decoder_dev.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.picture_buffer_id, |
+ picture.bitstream_buffer_id)); |
+} |
+ |
+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() |
+ return handled; |
Ami GONE FROM CHROMIUM
2011/08/02 00:49:08
DCHECK(handled)?
vrk (LEFT CHROMIUM)
2011/08/03 19:04:30
Done.
|
+} |
+ |
+void PPP_VideoDecoder_Proxy::OnMsgProvidePictureBuffers( |
+ HostResource decoder, uint32_t req_num_of_bufs, const PP_Size& dimensions) { |
+ if (ppp_video_decoder_target()) { |
Ami GONE FROM CHROMIUM
2011/08/02 00:49:08
here and below instead of having the whole body in
Ami GONE FROM CHROMIUM
2011/08/02 00:49:08
When will this fail?
vrk (LEFT CHROMIUM)
2011/08/03 19:04:30
Done.
vrk (LEFT CHROMIUM)
2011/08/03 22:05:22
Won't! Deleted here & everywhere.
|
+ ppp_video_decoder_target()->ProvidePictureBuffers( |
+ decoder.instance(), decoder.host_resource(), req_num_of_bufs, |
+ dimensions); |
+ } |
+} |
+ |
+void PPP_VideoDecoder_Proxy::OnMsgDismissPictureBuffer( |
+ HostResource decoder, int32_t picture_id) { |
+ if (ppp_video_decoder_target()) { |
+ ppp_video_decoder_target()->DismissPictureBuffer( |
+ decoder.instance(), decoder.host_resource(), picture_id); |
+ } |
+} |
+ |
+void PPP_VideoDecoder_Proxy::OnMsgPictureReady( |
+ HostResource decoder, int32_t picture_id, int32_t bitstream_id) { |
+ if (ppp_video_decoder_target()) { |
+ PP_Picture_Dev picture = { picture_id, bitstream_id }; |
+ ppp_video_decoder_target()->PictureReady( |
+ decoder.instance(), decoder.host_resource(), picture); |
+ } |
+} |
+ |
+void PPP_VideoDecoder_Proxy::OnMsgNotifyEndOfStream(HostResource decoder) { |
+ if (ppp_video_decoder_target()) { |
+ ppp_video_decoder_target()->EndOfStream( |
+ decoder.instance(), decoder.host_resource()); |
+ } |
+} |
+ |
+void PPP_VideoDecoder_Proxy::OnMsgNotifyError( |
+ HostResource decoder, uint32_t error) { |
+ if (ppp_video_decoder_target()) { |
+ ppp_video_decoder_target()->NotifyError( |
+ decoder.instance(), decoder.host_resource(), |
+ static_cast<PP_VideoDecodeError_Dev>(error)); |
Ami GONE FROM CHROMIUM
2011/08/02 00:49:08
hopefully can lose this cast by moving to more exp
vrk (LEFT CHROMIUM)
2011/08/03 19:04:30
Done.
|
+ } |
+} |
+ |
+} // namespace proxy |
+} // namespace pp |