Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "ppapi/proxy/ppp_video_decoder_proxy.h" | |
| 6 | |
| 7 #include "ppapi/proxy/host_dispatcher.h" | |
| 8 #include "ppapi/proxy/ppapi_messages.h" | |
| 9 #include "ppapi/proxy/ppb_video_decoder_proxy.h" | |
| 10 #include "ppapi/thunk/enter.h" | |
| 11 #include "ppapi/thunk/ppb_video_decoder_api.h" | |
| 12 #include "ppapi/thunk/thunk.h" | |
| 13 | |
| 14 using ::ppapi::thunk::PPB_VideoDecoder_API; | |
| 15 | |
| 16 namespace pp { | |
| 17 namespace proxy { | |
| 18 | |
| 19 namespace { | |
| 20 | |
| 21 void ProvidePictureBuffers(PP_Instance instance, PP_Resource decoder, | |
| 22 uint32_t req_num_of_bufs, PP_Size dimensions) { | |
| 23 HostResource decoder_resource; | |
| 24 decoder_resource.SetHostResource(instance, decoder); | |
| 25 | |
| 26 HostDispatcher::GetForInstance(instance)->Send( | |
| 27 new PpapiMsg_PPPVideoDecoder_ProvidePictureBuffers( | |
| 28 INTERFACE_ID_PPP_VIDEO_DECODER_DEV, | |
| 29 decoder_resource, req_num_of_bufs, dimensions)); | |
| 30 } | |
| 31 | |
| 32 void DismissPictureBuffer(PP_Instance instance, PP_Resource decoder, | |
| 33 int32_t picture_buffer_id) { | |
| 34 HostResource decoder_resource; | |
| 35 decoder_resource.SetHostResource(instance, decoder); | |
| 36 | |
| 37 HostDispatcher::GetForInstance(instance)->Send( | |
| 38 new PpapiMsg_PPPVideoDecoder_DismissPictureBuffer( | |
| 39 INTERFACE_ID_PPP_VIDEO_DECODER_DEV, | |
| 40 decoder_resource, picture_buffer_id)); | |
| 41 } | |
| 42 | |
| 43 void PictureReady(PP_Instance instance, PP_Resource decoder, | |
| 44 PP_Picture_Dev picture) { | |
| 45 HostResource decoder_resource; | |
| 46 decoder_resource.SetHostResource(instance, decoder); | |
| 47 | |
| 48 HostDispatcher::GetForInstance(instance)->Send( | |
| 49 new PpapiMsg_PPPVideoDecoder_PictureReady( | |
| 50 INTERFACE_ID_PPP_VIDEO_DECODER_DEV, decoder_resource, picture)); | |
| 51 } | |
| 52 | |
| 53 void EndOfStream(PP_Instance instance, PP_Resource decoder) { | |
| 54 HostResource decoder_resource; | |
| 55 decoder_resource.SetHostResource(instance, decoder); | |
| 56 | |
| 57 HostDispatcher::GetForInstance(instance)->Send( | |
| 58 new PpapiMsg_PPPVideoDecoder_NotifyEndOfStream( | |
| 59 INTERFACE_ID_PPP_VIDEO_DECODER_DEV, decoder_resource)); | |
| 60 } | |
| 61 | |
| 62 void NotifyError(PP_Instance instance, PP_Resource decoder, | |
| 63 PP_VideoDecodeError_Dev error) { | |
| 64 HostResource decoder_resource; | |
| 65 decoder_resource.SetHostResource(instance, decoder); | |
| 66 | |
| 67 HostDispatcher::GetForInstance(instance)->Send( | |
| 68 new PpapiMsg_PPPVideoDecoder_NotifyError( | |
| 69 INTERFACE_ID_PPP_VIDEO_DECODER_DEV, decoder_resource, error)); | |
| 70 } | |
| 71 | |
| 72 static const PPP_VideoDecoder_Dev video_decoder_interface = { | |
| 73 &ProvidePictureBuffers, | |
| 74 &DismissPictureBuffer, | |
| 75 &PictureReady, | |
| 76 &EndOfStream, | |
| 77 &NotifyError | |
| 78 }; | |
| 79 | |
| 80 InterfaceProxy* CreateVideoDecoderPPPProxy( | |
| 81 Dispatcher* dispatcher, const void* target_interface) { | |
| 82 return new PPP_VideoDecoder_Proxy(dispatcher, target_interface); | |
| 83 } | |
| 84 | |
| 85 } // namespace | |
| 86 | |
| 87 PPP_VideoDecoder_Proxy::PPP_VideoDecoder_Proxy( | |
| 88 Dispatcher* dispatcher, const void* target_interface) | |
| 89 : InterfaceProxy(dispatcher, target_interface) { | |
| 90 } | |
| 91 | |
| 92 PPP_VideoDecoder_Proxy::~PPP_VideoDecoder_Proxy() { | |
| 93 } | |
| 94 | |
| 95 // static | |
| 96 const InterfaceProxy::Info* PPP_VideoDecoder_Proxy::GetInfo() { | |
| 97 static const Info info = { | |
| 98 &video_decoder_interface, | |
| 99 PPP_VIDEODECODER_DEV_INTERFACE, | |
| 100 INTERFACE_ID_PPP_VIDEO_DECODER_DEV, | |
| 101 false, | |
| 102 &CreateVideoDecoderPPPProxy, | |
| 103 }; | |
| 104 return &info; | |
| 105 } | |
| 106 | |
| 107 bool PPP_VideoDecoder_Proxy::OnMessageReceived(const IPC::Message& msg) { | |
| 108 bool handled = true; | |
| 109 IPC_BEGIN_MESSAGE_MAP(PPP_VideoDecoder_Proxy, msg) | |
| 110 IPC_MESSAGE_HANDLER(PpapiMsg_PPPVideoDecoder_ProvidePictureBuffers, | |
| 111 OnMsgProvidePictureBuffers) | |
| 112 IPC_MESSAGE_HANDLER(PpapiMsg_PPPVideoDecoder_DismissPictureBuffer, | |
| 113 OnMsgDismissPictureBuffer) | |
| 114 IPC_MESSAGE_HANDLER(PpapiMsg_PPPVideoDecoder_PictureReady, | |
| 115 OnMsgPictureReady) | |
| 116 IPC_MESSAGE_HANDLER(PpapiMsg_PPPVideoDecoder_NotifyEndOfStream, | |
| 117 OnMsgNotifyEndOfStream) | |
| 118 IPC_MESSAGE_HANDLER(PpapiMsg_PPPVideoDecoder_NotifyError, | |
| 119 OnMsgNotifyError) | |
| 120 IPC_MESSAGE_UNHANDLED(handled = false) | |
| 121 IPC_END_MESSAGE_MAP() | |
| 122 DCHECK(handled); | |
| 123 return handled; | |
| 124 } | |
| 125 | |
| 126 void PPP_VideoDecoder_Proxy::OnMsgProvidePictureBuffers( | |
| 127 const HostResource& decoder, uint32_t req_num_of_bufs, | |
| 128 const PP_Size& dimensions) { | |
| 129 ppp_video_decoder_target()->ProvidePictureBuffers( | |
| 130 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
| |
| 131 } | |
| 132 | |
| 133 void PPP_VideoDecoder_Proxy::OnMsgDismissPictureBuffer( | |
| 134 const HostResource& decoder, int32_t picture_id) { | |
| 135 ppp_video_decoder_target()->DismissPictureBuffer( | |
| 136 decoder.instance(), decoder.host_resource(), picture_id); | |
| 137 } | |
| 138 | |
| 139 void PPP_VideoDecoder_Proxy::OnMsgPictureReady( | |
| 140 const HostResource& decoder, const PP_Picture_Dev& picture) { | |
| 141 ppp_video_decoder_target()->PictureReady( | |
| 142 decoder.instance(), decoder.host_resource(), picture); | |
| 143 } | |
| 144 | |
| 145 void PPP_VideoDecoder_Proxy::OnMsgNotifyEndOfStream( | |
| 146 const HostResource& decoder) { | |
| 147 ppp_video_decoder_target()->EndOfStream( | |
| 148 decoder.instance(), decoder.host_resource()); | |
| 149 } | |
| 150 | |
| 151 void PPP_VideoDecoder_Proxy::OnMsgNotifyError( | |
| 152 const HostResource& decoder, PP_VideoDecodeError_Dev error) { | |
| 153 ppp_video_decoder_target()->NotifyError( | |
| 154 decoder.instance(), decoder.host_resource(), error); | |
| 155 } | |
| 156 | |
| 157 } // namespace proxy | |
| 158 } // namespace pp | |
| OLD | NEW |