| 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..98be9758317964ac5da775caeda79c5c297438f5
|
| --- /dev/null
|
| +++ b/ppapi/proxy/ppp_video_decoder_proxy.cc
|
| @@ -0,0 +1,197 @@
|
| +// 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) {
|
| + ppapi::thunk::EnterResourceNoLock<PPB_VideoDecoder_API>
|
| + enter_decoder(decoder, false);
|
| + if (enter_decoder.failed())
|
| + return;
|
| + VideoDecoder* ppb_decoder =
|
| + static_cast<VideoDecoder*>(enter_decoder.object());
|
| + HostResource decoder_resource = ppb_decoder->host_resource();
|
| +
|
| + HostDispatcher::GetForInstance(instance)->Send(
|
| + new PpapiMsg_PPPVideoDecoder_ProvidePictureBuffers(
|
| + INTERFACE_ID_PPP_VIDEO_DECODER_DEV,
|
| + instance, decoder_resource, req_num_of_bufs, dimensions));
|
| +}
|
| +
|
| +void DismissPictureBuffer(PP_Instance instance, PP_Resource decoder,
|
| + int32_t picture_buffer_id) {
|
| + ppapi::thunk::EnterResourceNoLock<PPB_VideoDecoder_API>
|
| + enter_decoder(decoder, false);
|
| + if (enter_decoder.failed())
|
| + return;
|
| + VideoDecoder* ppb_decoder =
|
| + static_cast<VideoDecoder*>(enter_decoder.object());
|
| + HostResource decoder_resource = ppb_decoder->host_resource();
|
| +
|
| + HostDispatcher::GetForInstance(instance)->Send(
|
| + new PpapiMsg_PPPVideoDecoder_DismissPictureBuffer(
|
| + INTERFACE_ID_PPP_VIDEO_DECODER_DEV,
|
| + instance, decoder_resource, picture_buffer_id));
|
| +}
|
| +
|
| +void PictureReady(PP_Instance instance, PP_Resource decoder,
|
| + PP_Picture_Dev picture) {
|
| + ppapi::thunk::EnterResourceNoLock<PPB_VideoDecoder_API>
|
| + enter_decoder(decoder, false);
|
| + if (enter_decoder.failed())
|
| + return;
|
| + VideoDecoder* ppb_decoder =
|
| + static_cast<VideoDecoder*>(enter_decoder.object());
|
| + HostResource decoder_resource = ppb_decoder->host_resource();
|
| +
|
| + HostDispatcher::GetForInstance(instance)->Send(
|
| + new PpapiMsg_PPPVideoDecoder_PictureReady(
|
| + INTERFACE_ID_PPP_VIDEO_DECODER_DEV,
|
| + instance, decoder_resource, picture.picture_buffer_id,
|
| + picture.bitstream_buffer_id));
|
| +}
|
| +
|
| +void EndOfStream(PP_Instance instance, PP_Resource decoder) {
|
| + ppapi::thunk::EnterResourceNoLock<PPB_VideoDecoder_API>
|
| + enter_decoder(decoder, false);
|
| + if (enter_decoder.failed())
|
| + return;
|
| + VideoDecoder* ppb_decoder =
|
| + static_cast<VideoDecoder*>(enter_decoder.object());
|
| + HostResource decoder_resource = ppb_decoder->host_resource();
|
| +
|
| + HostDispatcher::GetForInstance(instance)->Send(
|
| + new PpapiMsg_PPPVideoDecoder_NotifyEndOfStream(
|
| + INTERFACE_ID_PPP_VIDEO_DECODER_DEV, instance, decoder_resource));
|
| +}
|
| +
|
| +void NotifyError(PP_Instance instance, PP_Resource decoder,
|
| + PP_VideoDecodeError_Dev error) {
|
| + ppapi::thunk::EnterResourceNoLock<PPB_VideoDecoder_API>
|
| + enter_decoder(decoder, false);
|
| + if (enter_decoder.failed())
|
| + return;
|
| + VideoDecoder* ppb_decoder =
|
| + static_cast<VideoDecoder*>(enter_decoder.object());
|
| + HostResource decoder_resource = ppb_decoder->host_resource();
|
| +
|
| + HostDispatcher::GetForInstance(instance)->Send(
|
| + new PpapiMsg_PPPVideoDecoder_NotifyError(
|
| + INTERFACE_ID_PPP_VIDEO_DECODER_DEV, instance, 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;
|
| +}
|
| +
|
| +void PPP_VideoDecoder_Proxy::OnMsgProvidePictureBuffers(
|
| + PP_Instance instance, HostResource decoder, uint32_t req_num_of_bufs,
|
| + const PP_Size& dimensions) {
|
| + if (ppp_video_decoder_target()) {
|
| + ppp_video_decoder_target()->ProvidePictureBuffers(
|
| + instance, decoder.host_resource(), req_num_of_bufs, dimensions);
|
| + }
|
| +}
|
| +
|
| +void PPP_VideoDecoder_Proxy::OnMsgDismissPictureBuffer(
|
| + PP_Instance instance, HostResource decoder, int32_t picture_id) {
|
| + if (ppp_video_decoder_target()) {
|
| + ppp_video_decoder_target()->DismissPictureBuffer(
|
| + instance, decoder.host_resource(), picture_id);
|
| + }
|
| +}
|
| +
|
| +void PPP_VideoDecoder_Proxy::OnMsgPictureReady(
|
| + PP_Instance instance, 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(
|
| + instance, decoder.host_resource(), picture);
|
| + }
|
| +}
|
| +
|
| +void PPP_VideoDecoder_Proxy::OnMsgNotifyEndOfStream(
|
| + PP_Instance instance, HostResource decoder) {
|
| + if (ppp_video_decoder_target())
|
| + ppp_video_decoder_target()->EndOfStream(instance, decoder.host_resource());
|
| +}
|
| +
|
| +void PPP_VideoDecoder_Proxy::OnMsgNotifyError(
|
| + PP_Instance instance, HostResource decoder, uint32_t error) {
|
| + if (ppp_video_decoder_target()) {
|
| + ppp_video_decoder_target()->NotifyError(
|
| + instance, decoder.host_resource(),
|
| + static_cast<PP_VideoDecodeError_Dev>(error));
|
| + }
|
| +}
|
| +
|
| +} // namespace proxy
|
| +} // namespace pp
|
|
|