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/c/dev/ppp_video_decoder_dev.h" | |
| 8 #include "ppapi/proxy/host_dispatcher.h" | |
| 9 #include "ppapi/proxy/ppapi_messages.h" | |
| 10 #include "ppapi/proxy/ppb_video_decoder_proxy.h" | |
| 11 #include "ppapi/thunk/enter.h" | |
| 12 #include "ppapi/thunk/ppb_video_decoder_api.h" | |
| 13 #include "ppapi/thunk/thunk.h" | |
| 14 | |
| 15 using ::ppapi::thunk::PPB_VideoDecoder_API; | |
| 16 | |
| 17 namespace pp { | |
| 18 namespace proxy { | |
| 19 | |
| 20 namespace { | |
| 21 | |
| 22 void ProvidePictureBuffers(PP_Instance instance, PP_Resource decoder, | |
| 23 uint32_t req_num_of_bufs, PP_Size dimensions) { | |
| 24 HostResource decoder_resource; | |
| 25 decoder_resource.SetHostResource(instance, decoder); | |
| 26 | |
| 27 HostDispatcher::GetForInstance(instance)->Send( | |
| 28 new PpapiMsg_PPPVideoDecoder_ProvidePictureBuffers( | |
| 29 INTERFACE_ID_PPP_VIDEO_DECODER_DEV, | |
| 30 decoder_resource, req_num_of_bufs, dimensions)); | |
| 31 } | |
| 32 | |
| 33 void DismissPictureBuffer(PP_Instance instance, PP_Resource decoder, | |
| 34 int32_t picture_buffer_id) { | |
| 35 HostResource decoder_resource; | |
| 36 decoder_resource.SetHostResource(instance, decoder); | |
| 37 | |
| 38 HostDispatcher::GetForInstance(instance)->Send( | |
| 39 new PpapiMsg_PPPVideoDecoder_DismissPictureBuffer( | |
| 40 INTERFACE_ID_PPP_VIDEO_DECODER_DEV, | |
| 41 decoder_resource, picture_buffer_id)); | |
| 42 } | |
| 43 | |
| 44 void PictureReady(PP_Instance instance, PP_Resource decoder, | |
| 45 PP_Picture_Dev picture) { | |
| 46 HostResource decoder_resource; | |
| 47 decoder_resource.SetHostResource(instance, decoder); | |
| 48 | |
| 49 HostDispatcher::GetForInstance(instance)->Send( | |
| 50 new PpapiMsg_PPPVideoDecoder_PictureReady( | |
| 51 INTERFACE_ID_PPP_VIDEO_DECODER_DEV, | |
| 52 decoder_resource, picture.picture_buffer_id, | |
| 53 picture.bitstream_buffer_id)); | |
| 54 } | |
| 55 | |
| 56 void EndOfStream(PP_Instance instance, PP_Resource decoder) { | |
| 57 HostResource decoder_resource; | |
| 58 decoder_resource.SetHostResource(instance, decoder); | |
| 59 | |
| 60 HostDispatcher::GetForInstance(instance)->Send( | |
| 61 new PpapiMsg_PPPVideoDecoder_NotifyEndOfStream( | |
| 62 INTERFACE_ID_PPP_VIDEO_DECODER_DEV, decoder_resource)); | |
| 63 } | |
| 64 | |
| 65 void NotifyError(PP_Instance instance, PP_Resource decoder, | |
| 66 PP_VideoDecodeError_Dev error) { | |
| 67 HostResource decoder_resource; | |
| 68 decoder_resource.SetHostResource(instance, decoder); | |
| 69 | |
| 70 HostDispatcher::GetForInstance(instance)->Send( | |
| 71 new PpapiMsg_PPPVideoDecoder_NotifyError( | |
| 72 INTERFACE_ID_PPP_VIDEO_DECODER_DEV, decoder_resource, error)); | |
| 73 } | |
| 74 | |
| 75 static const PPP_VideoDecoder_Dev video_decoder_interface = { | |
| 76 &ProvidePictureBuffers, | |
| 77 &DismissPictureBuffer, | |
| 78 &PictureReady, | |
| 79 &EndOfStream, | |
| 80 &NotifyError | |
| 81 }; | |
| 82 | |
| 83 InterfaceProxy* CreateVideoDecoderPPPProxy(Dispatcher* dispatcher, | |
| 84 const void* target_interface) { | |
| 85 return new PPP_VideoDecoder_Proxy(dispatcher, target_interface); | |
| 86 } | |
| 87 | |
| 88 } // namespace | |
| 89 | |
| 90 PPP_VideoDecoder_Proxy::PPP_VideoDecoder_Proxy(Dispatcher* dispatcher, | |
| 91 const void* target_interface) | |
| 92 : InterfaceProxy(dispatcher, target_interface) { | |
| 93 } | |
| 94 | |
| 95 PPP_VideoDecoder_Proxy::~PPP_VideoDecoder_Proxy() { | |
| 96 } | |
| 97 | |
| 98 // static | |
| 99 const InterfaceProxy::Info* PPP_VideoDecoder_Proxy::GetInfo() { | |
| 100 static const Info info = { | |
| 101 &video_decoder_interface, | |
| 102 PPP_VIDEODECODER_DEV_INTERFACE, | |
| 103 INTERFACE_ID_PPP_VIDEO_DECODER_DEV, | |
| 104 false, | |
| 105 &CreateVideoDecoderPPPProxy, | |
| 106 }; | |
| 107 return &info; | |
| 108 } | |
| 109 | |
| 110 bool PPP_VideoDecoder_Proxy::OnMessageReceived(const IPC::Message& msg) { | |
| 111 bool handled = true; | |
| 112 IPC_BEGIN_MESSAGE_MAP(PPP_VideoDecoder_Proxy, msg) | |
| 113 IPC_MESSAGE_HANDLER(PpapiMsg_PPPVideoDecoder_ProvidePictureBuffers, | |
| 114 OnMsgProvidePictureBuffers) | |
| 115 IPC_MESSAGE_HANDLER(PpapiMsg_PPPVideoDecoder_DismissPictureBuffer, | |
| 116 OnMsgDismissPictureBuffer) | |
| 117 IPC_MESSAGE_HANDLER(PpapiMsg_PPPVideoDecoder_PictureReady, | |
| 118 OnMsgPictureReady) | |
| 119 IPC_MESSAGE_HANDLER(PpapiMsg_PPPVideoDecoder_NotifyEndOfStream, | |
| 120 OnMsgNotifyEndOfStream) | |
| 121 IPC_MESSAGE_HANDLER(PpapiMsg_PPPVideoDecoder_NotifyError, | |
| 122 OnMsgNotifyError) | |
| 123 IPC_MESSAGE_UNHANDLED(handled = false) | |
| 124 IPC_END_MESSAGE_MAP() | |
| 125 return handled; | |
|
Ami GONE FROM CHROMIUM
2011/08/02 00:49:08
DCHECK(handled)?
vrk (LEFT CHROMIUM)
2011/08/03 19:04:30
Done.
| |
| 126 } | |
| 127 | |
| 128 void PPP_VideoDecoder_Proxy::OnMsgProvidePictureBuffers( | |
| 129 HostResource decoder, uint32_t req_num_of_bufs, const PP_Size& dimensions) { | |
| 130 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.
| |
| 131 ppp_video_decoder_target()->ProvidePictureBuffers( | |
| 132 decoder.instance(), decoder.host_resource(), req_num_of_bufs, | |
| 133 dimensions); | |
| 134 } | |
| 135 } | |
| 136 | |
| 137 void PPP_VideoDecoder_Proxy::OnMsgDismissPictureBuffer( | |
| 138 HostResource decoder, int32_t picture_id) { | |
| 139 if (ppp_video_decoder_target()) { | |
| 140 ppp_video_decoder_target()->DismissPictureBuffer( | |
| 141 decoder.instance(), decoder.host_resource(), picture_id); | |
| 142 } | |
| 143 } | |
| 144 | |
| 145 void PPP_VideoDecoder_Proxy::OnMsgPictureReady( | |
| 146 HostResource decoder, int32_t picture_id, int32_t bitstream_id) { | |
| 147 if (ppp_video_decoder_target()) { | |
| 148 PP_Picture_Dev picture = { picture_id, bitstream_id }; | |
| 149 ppp_video_decoder_target()->PictureReady( | |
| 150 decoder.instance(), decoder.host_resource(), picture); | |
| 151 } | |
| 152 } | |
| 153 | |
| 154 void PPP_VideoDecoder_Proxy::OnMsgNotifyEndOfStream(HostResource decoder) { | |
| 155 if (ppp_video_decoder_target()) { | |
| 156 ppp_video_decoder_target()->EndOfStream( | |
| 157 decoder.instance(), decoder.host_resource()); | |
| 158 } | |
| 159 } | |
| 160 | |
| 161 void PPP_VideoDecoder_Proxy::OnMsgNotifyError( | |
| 162 HostResource decoder, uint32_t error) { | |
| 163 if (ppp_video_decoder_target()) { | |
| 164 ppp_video_decoder_target()->NotifyError( | |
| 165 decoder.instance(), decoder.host_resource(), | |
| 166 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.
| |
| 167 } | |
| 168 } | |
| 169 | |
| 170 } // namespace proxy | |
| 171 } // namespace pp | |
| OLD | NEW |