Commit dfb0d06f authored by bbudge@chromium.org's avatar bbudge@chromium.org

Implement Pepper PPB_VideoDecoder interface.

Adds resource and host, unit test for the resource, and an example plugin.
Implements only the hardware accelerated case. Software fallback will be
in a follow-on CL.

Adds two new PP_Error codes:
PP_ERROR_UNREADABLE_INPUT
PP_ERROR_PLATFORM_FAILED

BUG=281689
R=dmichael@chromium.org, fischman@chromium.org, jar@chromium.org, piman@chromium.org, tsepez@chromium.org

Review URL: https://codereview.chromium.org/270213004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@273920 0039d316-1c4b-4281-b951-d872f2087c98
parent b0f8d6dc
......@@ -68,6 +68,7 @@
#include "ppapi/c/ppb_var_array.h"
#include "ppapi/c/ppb_var_array_buffer.h"
#include "ppapi/c/ppb_var_dictionary.h"
#include "ppapi/c/ppb_video_decoder.h"
#include "ppapi/c/ppb_video_frame.h"
#include "ppapi/c/ppb_view.h"
#include "ppapi/c/ppb_websocket.h"
......
......@@ -516,6 +516,8 @@
'renderer/pepper/pepper_url_loader_host.h',
'renderer/pepper/pepper_video_capture_host.cc',
'renderer/pepper/pepper_video_capture_host.h',
'renderer/pepper/pepper_video_decoder_host.cc',
'renderer/pepper/pepper_video_decoder_host.h',
'renderer/pepper/pepper_webplugin_impl.cc',
'renderer/pepper/pepper_webplugin_impl.h',
'renderer/pepper/pepper_websocket_host.cc',
......
......@@ -18,6 +18,7 @@
#include "content/renderer/pepper/pepper_truetype_font_host.h"
#include "content/renderer/pepper/pepper_url_loader_host.h"
#include "content/renderer/pepper/pepper_video_capture_host.h"
#include "content/renderer/pepper/pepper_video_decoder_host.h"
#include "content/renderer/pepper/pepper_video_destination_host.h"
#include "content/renderer/pepper/pepper_video_source_host.h"
#include "content/renderer/pepper/pepper_websocket_host.h"
......@@ -123,6 +124,9 @@ scoped_ptr<ResourceHost> ContentRendererPepperHostFactory::CreateResourceHost(
case PpapiHostMsg_URLLoader_Create::ID:
return scoped_ptr<ResourceHost>(new PepperURLLoaderHost(
host_, false, instance, params.pp_resource()));
case PpapiHostMsg_VideoDecoder_Create::ID:
return scoped_ptr<ResourceHost>(
new PepperVideoDecoderHost(host_, instance, params.pp_resource()));
case PpapiHostMsg_WebSocket_Create::ID:
return scoped_ptr<ResourceHost>(
new PepperWebSocketHost(host_, instance, params.pp_resource()));
......
This diff is collapsed.
// Copyright (c) 2014 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.
#ifndef CONTENT_RENDERER_PEPPER_PEPPER_VIDEO_DECODER_HOST_H_
#define CONTENT_RENDERER_PEPPER_PEPPER_VIDEO_DECODER_HOST_H_
#include <map>
#include <vector>
#include "base/basictypes.h"
#include "base/containers/hash_tables.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/scoped_vector.h"
#include "content/common/content_export.h"
#include "gpu/command_buffer/common/mailbox.h"
#include "media/video/video_decode_accelerator.h"
#include "ppapi/c/pp_codecs.h"
#include "ppapi/host/host_message_context.h"
#include "ppapi/host/resource_host.h"
#include "ppapi/proxy/resource_message_params.h"
namespace base {
class SharedMemory;
}
namespace content {
class PPB_Graphics3D_Impl;
class RendererPpapiHost;
class RenderViewImpl;
class CONTENT_EXPORT PepperVideoDecoderHost
: public ppapi::host::ResourceHost,
public media::VideoDecodeAccelerator::Client {
public:
PepperVideoDecoderHost(RendererPpapiHost* host,
PP_Instance instance,
PP_Resource resource);
virtual ~PepperVideoDecoderHost();
private:
struct PendingDecode {
PendingDecode(uint32_t shm_id,
const ppapi::host::ReplyMessageContext& reply_context);
~PendingDecode();
const uint32_t shm_id;
const ppapi::host::ReplyMessageContext reply_context;
};
// ResourceHost implementation.
virtual int32_t OnResourceMessageReceived(
const IPC::Message& msg,
ppapi::host::HostMessageContext* context) OVERRIDE;
// media::VideoDecodeAccelerator::Client implementation.
virtual void ProvidePictureBuffers(uint32 requested_num_of_buffers,
const gfx::Size& dimensions,
uint32 texture_target) OVERRIDE;
virtual void DismissPictureBuffer(int32 picture_buffer_id) OVERRIDE;
virtual void PictureReady(const media::Picture& picture) OVERRIDE;
virtual void NotifyError(media::VideoDecodeAccelerator::Error error) OVERRIDE;
virtual void NotifyFlushDone() OVERRIDE;
virtual void NotifyEndOfBitstreamBuffer(int32 bitstream_buffer_id) OVERRIDE;
virtual void NotifyResetDone() OVERRIDE;
int32_t OnHostMsgInitialize(ppapi::host::HostMessageContext* context,
const ppapi::HostResource& graphics_context,
PP_VideoProfile profile,
bool allow_software_fallback);
int32_t OnHostMsgGetShm(ppapi::host::HostMessageContext* context,
uint32_t shm_id,
uint32_t shm_size);
int32_t OnHostMsgDecode(ppapi::host::HostMessageContext* context,
uint32_t shm_id,
uint32_t size,
int32_t decode_id);
int32_t OnHostMsgAssignTextures(ppapi::host::HostMessageContext* context,
const PP_Size& size,
const std::vector<uint32_t>& texture_ids);
int32_t OnHostMsgRecyclePicture(ppapi::host::HostMessageContext* context,
uint32_t picture_id);
int32_t OnHostMsgFlush(ppapi::host::HostMessageContext* context);
int32_t OnHostMsgReset(ppapi::host::HostMessageContext* context);
// Non-owning pointer.
RendererPpapiHost* renderer_ppapi_host_;
scoped_ptr<media::VideoDecodeAccelerator> decoder_;
scoped_refptr<PPB_Graphics3D_Impl> graphics3d_;
// A vector holding our shm buffers, in sync with a similar vector in the
// resource. We use a buffer's index in these vectors as its id on both sides
// of the proxy. Only add buffers or update them in place so as not to
// invalidate these ids.
ScopedVector<base::SharedMemory> shm_buffers_;
// A vector of true/false indicating if a shm buffer is in use by the decoder.
// This is parallel to |shm_buffers_|.
std::vector<uint8_t> shm_buffer_busy_;
// Maps decode uid to PendingDecode info.
typedef base::hash_map<int32_t, PendingDecode> PendingDecodeMap;
PendingDecodeMap pending_decodes_;
ppapi::host::ReplyMessageContext flush_reply_context_;
ppapi::host::ReplyMessageContext reset_reply_context_;
bool initialized_;
DISALLOW_COPY_AND_ASSIGN(PepperVideoDecoderHost);
};
} // namespace content
#endif // CONTENT_RENDERER_PEPPER_PEPPER_VIDEO_DECODER_HOST_H_
......@@ -91,6 +91,7 @@
#include "ppapi/c/ppb_var_array.h"
#include "ppapi/c/ppb_var_array_buffer.h"
#include "ppapi/c/ppb_var_dictionary.h"
#include "ppapi/c/ppb_video_decoder.h"
#include "ppapi/c/ppb_video_frame.h"
#include "ppapi/c/ppb_view.h"
#include "ppapi/c/ppp.h"
......
......@@ -295,7 +295,11 @@ PP_Resource ResourceCreationImpl::CreateUDPSocketPrivate(PP_Instance instance) {
}
PP_Resource ResourceCreationImpl::CreateVideoCapture(PP_Instance instance) {
return 0; // VideoCapture is not supported in process now.
return 0; // Not supported in-process.
}
PP_Resource ResourceCreationImpl::CreateVideoDecoder(PP_Instance instance) {
return 0; // Not supported in-process.
}
PP_Resource ResourceCreationImpl::CreateVideoDecoderDev(
......
......@@ -126,6 +126,7 @@ class ResourceCreationImpl : public ppapi::thunk::ResourceCreationAPI {
virtual PP_Resource CreateUDPSocket(PP_Instance instance) OVERRIDE;
virtual PP_Resource CreateUDPSocketPrivate(PP_Instance instance) OVERRIDE;
virtual PP_Resource CreateVideoCapture(PP_Instance instance) OVERRIDE;
virtual PP_Resource CreateVideoDecoder(PP_Instance instance) OVERRIDE;
virtual PP_Resource CreateVideoDecoderDev(PP_Instance instance,
PP_Resource graphics3d_id,
PP_VideoDecoder_Profile profile)
......
......@@ -290,6 +290,11 @@ PP_Resource ResourceCreationImpl::CreateUDPSocketPrivate(
return 0;
}
PP_Resource ResourceCreationImpl::CreateVideoDecoder(PP_Instance instance) {
NOTIMPLEMENTED();
return 0;
}
PP_Resource ResourceCreationImpl::CreateVideoDestination(
PP_Instance instance) {
NOTIMPLEMENTED();
......
......@@ -133,6 +133,7 @@ class ResourceCreationImpl : public ppapi::thunk::ResourceCreationAPI {
virtual PP_Resource CreateTCPSocketPrivate(PP_Instance instance) OVERRIDE;
virtual PP_Resource CreateUDPSocket(PP_Instance instance) OVERRIDE;
virtual PP_Resource CreateUDPSocketPrivate(PP_Instance instance) OVERRIDE;
virtual PP_Resource CreateVideoDecoder(PP_Instance instance) OVERRIDE;
virtual PP_Resource CreateVideoDestination(PP_Instance instance) OVERRIDE;
virtual PP_Resource CreateVideoSource(PP_Instance instance) OVERRIDE;
virtual PP_Resource CreateWebSocket(PP_Instance instance) OVERRIDE;
......
......@@ -85,6 +85,17 @@
* input events, and there are reentrancy and deadlock issues).
*/
PP_ERROR_BLOCKS_MAIN_THREAD = -13,
/**
* This value indicates that the plugin sent bad input data to a resource,
* leaving it in an invalid state. The resource can't be used after returning
* this error and should be released.
*/
PP_ERROR_MALFORMED_INPUT = -14,
/**
* This value indicates that a resource has failed. The resource can't be
* used after returning this error and should be released.
*/
PP_ERROR_RESOURCE_FAILED = -15,
/** This value indicates failure due to a file that does not exist. */
PP_ERROR_FILENOTFOUND = -20,
......@@ -129,6 +140,7 @@
* thread.
*/
PP_ERROR_WRONG_THREAD = -52,
/**
* This value indicates that the connection was closed. For TCP sockets, it
* corresponds to a TCP FIN.
......
......@@ -3,7 +3,7 @@
* found in the LICENSE file.
*/
/* From pp_errors.idl modified Thu Jun 13 13:02:05 2013. */
/* From pp_errors.idl modified Thu May 15 16:12:26 2014. */
#ifndef PPAPI_C_PP_ERRORS_H_
#define PPAPI_C_PP_ERRORS_H_
......@@ -86,6 +86,17 @@ enum {
* input events, and there are reentrancy and deadlock issues).
*/
PP_ERROR_BLOCKS_MAIN_THREAD = -13,
/**
* This value indicates that the plugin sent bad input data to a resource,
* leaving it in an invalid state. The resource can't be used after returning
* this error and should be released.
*/
PP_ERROR_MALFORMED_INPUT = -14,
/**
* This value indicates that a resource has failed. The resource can't be
* used after returning this error and should be released.
*/
PP_ERROR_RESOURCE_FAILED = -15,
/** This value indicates failure due to a file that does not exist. */
PP_ERROR_FILENOTFOUND = -20,
/** This value indicates failure due to a file that already exists. */
......
This diff is collapsed.
<!DOCTYPE html>
<html>
<!--
Copyright (c) 2014 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.
-->
<head>
<title>Video Decode Example</title>
</head>
<body>
<embed id="plugin" type="application/x-ppapi-example-video-decode"
width="640" height="480"/>
</body>
</html>
......@@ -226,6 +226,8 @@
'proxy/var_serialization_rules.h',
'proxy/video_capture_resource.cc',
'proxy/video_capture_resource.h',
'proxy/video_decoder_resource.cc',
'proxy/video_decoder_resource.h',
'proxy/video_destination_resource.cc',
'proxy/video_destination_resource.h',
'proxy/video_frame_resource.cc',
......
......@@ -272,6 +272,7 @@
'thunk/ppb_video_decoder_api.h',
'thunk/ppb_video_decoder_dev_api.h',
'thunk/ppb_video_decoder_dev_thunk.cc',
'thunk/ppb_video_decoder_thunk.cc',
'thunk/ppb_video_destination_private_api.h',
'thunk/ppb_video_destination_private_thunk.cc',
'thunk/ppb_video_frame_api.h',
......
......@@ -175,6 +175,7 @@
'proxy/raw_var_data_unittest.cc',
'proxy/serialized_var_unittest.cc',
'proxy/talk_resource_unittest.cc',
'proxy/video_decoder_resource_unittest.cc',
'proxy/websocket_resource_unittest.cc',
'shared_impl/media_stream_buffer_manager_unittest.cc',
'shared_impl/media_stream_video_track_shared_unittest.cc',
......@@ -450,8 +451,7 @@
'lib/gl/include',
],
'sources': [
# TODO(bbudge) Change to new example when implementation lands.
'examples/video_decode/video_decode_dev.cc',
'examples/video_decode/video_decode.cc',
'examples/video_decode/testdata.h',
],
# TODO(jschuh): crbug.com/167187 fix size_t to int truncations.
......
......@@ -65,6 +65,7 @@
#include "ppapi/c/ppb_var_array.h"
#include "ppapi/c/ppb_var_array_buffer.h"
#include "ppapi/c/ppb_var_dictionary.h"
#include "ppapi/c/ppb_video_decoder.h"
#include "ppapi/c/ppb_video_frame.h"
#include "ppapi/c/ppb_view.h"
#include "ppapi/c/pp_errors.h"
......
......@@ -15,6 +15,7 @@
#include "base/sync_socket.h"
#include "base/values.h"
#include "gpu/command_buffer/common/command_buffer.h"
#include "gpu/command_buffer/common/mailbox.h"
#include "gpu/ipc/gpu_command_buffer_traits.h"
#include "ipc/ipc_channel_handle.h"
#include "ipc/ipc_message_macros.h"
......@@ -26,6 +27,7 @@
#include "ppapi/c/dev/ppb_url_util_dev.h"
#include "ppapi/c/dev/ppp_printing_dev.h"
#include "ppapi/c/pp_bool.h"
#include "ppapi/c/pp_codecs.h"
#include "ppapi/c/pp_file_info.h"
#include "ppapi/c/pp_instance.h"
#include "ppapi/c/pp_module.h"
......@@ -121,6 +123,7 @@ IPC_ENUM_TRAITS_MAX_VALUE(PP_UDPSocket_Option,
IPC_ENUM_TRAITS(PP_VideoDecodeError_Dev)
IPC_ENUM_TRAITS(PP_VideoDecoder_Profile)
IPC_ENUM_TRAITS_MAX_VALUE(PP_VideoFrame_Format, PP_VIDEOFRAME_FORMAT_LAST)
IPC_ENUM_TRAITS_MAX_VALUE(PP_VideoProfile, PP_VIDEOPROFILE_MAX)
IPC_STRUCT_TRAITS_BEGIN(PP_Point)
IPC_STRUCT_TRAITS_MEMBER(x)
......@@ -1814,6 +1817,47 @@ IPC_MESSAGE_CONTROL2(PpapiPluginMsg_OutputProtection_QueryStatusReply,
uint32_t /* link_mask */,
uint32_t /* protection_mask */)
// VideoDecoder ------------------------------------------------------
IPC_MESSAGE_CONTROL0(PpapiHostMsg_VideoDecoder_Create)
IPC_MESSAGE_CONTROL3(PpapiHostMsg_VideoDecoder_Initialize,
ppapi::HostResource /* graphics_context */,
PP_VideoProfile /* profile */,
bool /* allow_software_fallback */)
IPC_MESSAGE_CONTROL0(PpapiPluginMsg_VideoDecoder_InitializeReply)
IPC_MESSAGE_CONTROL2(PpapiHostMsg_VideoDecoder_GetShm,
uint32_t /* shm_id */,
uint32_t /* shm_size */)
// On success, a shm handle is passed in the ReplyParams struct.
IPC_MESSAGE_CONTROL1(PpapiPluginMsg_VideoDecoder_GetShmReply,
uint32_t /* shm_size */)
IPC_MESSAGE_CONTROL3(PpapiHostMsg_VideoDecoder_Decode,
uint32_t /* shm_id */,
uint32_t /* size */,
int32_t /* decode_id */)
IPC_MESSAGE_CONTROL1(PpapiPluginMsg_VideoDecoder_DecodeReply,
uint32_t /* shm_id */)
IPC_MESSAGE_CONTROL3(PpapiPluginMsg_VideoDecoder_RequestTextures,
uint32_t /* num_textures */,
PP_Size /* size */,
uint32_t /* texture_target */)
IPC_MESSAGE_CONTROL2(PpapiHostMsg_VideoDecoder_AssignTextures,
PP_Size /* size */,
std::vector<uint32_t> /* texture_ids */)
IPC_MESSAGE_CONTROL2(PpapiPluginMsg_VideoDecoder_PictureReady,
int32_t /* decode_id */,
uint32_t /* texture_id */)
IPC_MESSAGE_CONTROL1(PpapiHostMsg_VideoDecoder_RecyclePicture,
uint32_t /* texture_id */)
IPC_MESSAGE_CONTROL1(PpapiPluginMsg_VideoDecoder_DismissPicture,
uint32_t /* texture_id */)
IPC_MESSAGE_CONTROL0(PpapiHostMsg_VideoDecoder_Flush)
IPC_MESSAGE_CONTROL0(PpapiPluginMsg_VideoDecoder_FlushReply)
IPC_MESSAGE_CONTROL0(PpapiHostMsg_VideoDecoder_Reset)
IPC_MESSAGE_CONTROL0(PpapiPluginMsg_VideoDecoder_ResetReply)
IPC_MESSAGE_CONTROL1(PpapiPluginMsg_VideoDecoder_NotifyError,
int32_t /* error */)
#if !defined(OS_NACL) && !defined(NACL_WIN64)
// Audio input.
......
......@@ -12,6 +12,7 @@
#include "ppapi/c/pp_graphics_3d.h"
#include "ppapi/c/pp_instance.h"
#include "ppapi/proxy/interface_proxy.h"
#include "ppapi/proxy/ppapi_proxy_export.h"
#include "ppapi/proxy/proxy_completion_callback_factory.h"
#include "ppapi/shared_impl/ppb_graphics_3d_shared.h"
#include "ppapi/shared_impl/resource.h"
......@@ -26,7 +27,7 @@ namespace proxy {
class SerializedHandle;
class PpapiCommandBufferProxy;
class Graphics3D : public PPB_Graphics3D_Shared {
class PPAPI_PROXY_EXPORT Graphics3D : public PPB_Graphics3D_Shared {
public:
explicit Graphics3D(const HostResource& resource);
virtual ~Graphics3D();
......
......@@ -47,6 +47,7 @@
#include "ppapi/proxy/url_request_info_resource.h"
#include "ppapi/proxy/url_response_info_resource.h"
#include "ppapi/proxy/video_capture_resource.h"
#include "ppapi/proxy/video_decoder_resource.h"
#include "ppapi/proxy/video_destination_resource.h"
#include "ppapi/proxy/video_source_resource.h"
#include "ppapi/proxy/websocket_resource.h"
......@@ -369,6 +370,10 @@ PP_Resource ResourceCreationProxy::CreateUDPSocketPrivate(
GetConnection(), instance))->GetReference();
}
PP_Resource ResourceCreationProxy::CreateVideoDecoder(PP_Instance instance) {
return (new VideoDecoderResource(GetConnection(), instance))->GetReference();
}
PP_Resource ResourceCreationProxy::CreateVideoDestination(
PP_Instance instance) {
return (new VideoDestinationResource(GetConnection(),
......
......@@ -151,6 +151,7 @@ class ResourceCreationProxy : public InterfaceProxy,
virtual PP_Resource CreateTCPSocketPrivate(PP_Instance instance) OVERRIDE;
virtual PP_Resource CreateUDPSocket(PP_Instance instance) OVERRIDE;
virtual PP_Resource CreateUDPSocketPrivate(PP_Instance instance) OVERRIDE;
virtual PP_Resource CreateVideoDecoder(PP_Instance instance) OVERRIDE;
virtual PP_Resource CreateVideoDestination(PP_Instance instance) OVERRIDE;
virtual PP_Resource CreateVideoSource(PP_Instance instance) OVERRIDE;
virtual PP_Resource CreateWebSocket(PP_Instance instance) OVERRIDE;
......
// Copyright (c) 2014 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.
#ifndef PPAPI_PROXY_VIDEO_DECODER_CONSTANTS_H_
#define PPAPI_PROXY_VIDEO_DECODER_CONSTANTS_H_
namespace ppapi {
namespace proxy {
// These constants are shared by the video decoder resource and host.
enum {
// Maximum number of concurrent decodes which can be pending.
kMaximumPendingDecodes = 8,
// Minimum size of shared-memory buffers (100 KB). Make them large since we
// try to reuse them.
kMinimumBitstreamBufferSize = 100 << 10,
// Maximum size of shared-memory buffers (4 MB). This should be enough even
// for 4K video at reasonable compression levels.
kMaximumBitstreamBufferSize = 4 << 20
};
} // namespace proxy
} // namespace ppapi
#endif // PPAPI_PROXY_VIDEO_DECODER_CONSTANTS_H_
This diff is collapsed.
// Copyright (c) 2014 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.
#ifndef PPAPI_PROXY_VIDEO_DECODER_RESOURCE_H_
#define PPAPI_PROXY_VIDEO_DECODER_RESOURCE_H_
#include <queue>
#include "base/containers/hash_tables.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/scoped_vector.h"
#include "ppapi/proxy/connection.h"
#include "ppapi/proxy/plugin_resource.h"
#include "ppapi/proxy/ppapi_proxy_export.h"
#include "ppapi/shared_impl/resource.h"
#include "ppapi/shared_impl/scoped_pp_resource.h"
#include "ppapi/thunk/ppb_video_decoder_api.h"
namespace gpu {
namespace gles2 {
class GLES2Implementation;
}
}
namespace ppapi {
class PPB_Graphics3D_Shared;
class TrackedCallback;
namespace proxy {
class PPAPI_PROXY_EXPORT VideoDecoderResource
: public PluginResource,
public thunk::PPB_VideoDecoder_API {
public:
VideoDecoderResource(Connection connection, PP_Instance instance);
virtual ~VideoDecoderResource();
// Resource overrides.
virtual thunk::PPB_VideoDecoder_API* AsPPB_VideoDecoder_API() OVERRIDE;
// PPB_VideoDecoder_API implementation.
virtual int32_t Initialize(PP_Resource graphics_context,
PP_VideoProfile profile,
PP_Bool allow_software_fallback,
scoped_refptr<TrackedCallback> callback) OVERRIDE;
virtual int32_t Decode(uint32_t decode_id,
uint32_t size,
const void* buffer,
scoped_refptr<TrackedCallback> callback) OVERRIDE;
virtual int32_t GetPicture(PP_VideoPicture* picture,
scoped_refptr<TrackedCallback> callback) OVERRIDE;
virtual void RecyclePicture(const PP_VideoPicture* picture) OVERRIDE;
virtual int32_t Flush(scoped_refptr<TrackedCallback> callback) OVERRIDE;
virtual int32_t Reset(scoped_refptr<TrackedCallback> callback) OVERRIDE;
// PluginResource implementation.
virtual void OnReplyReceived(const ResourceMessageReplyParams& params,
const IPC::Message& msg) OVERRIDE;
// Called only by unit tests. This bypasses Graphics3D setup, which doesn't
// work in ppapi::proxy::PluginProxyTest.
void SetForTest();
private:
// Struct to hold a shared memory buffer.
struct ShmBuffer {
ShmBuffer(scoped_ptr<base::SharedMemory> shm,
uint32_t size,
uint32_t shm_id);
~ShmBuffer();
const scoped_ptr<base::SharedMemory> shm;
void* addr;
// Index into shm_buffers_ vector, used as an id. This should map 1:1 to
// the index on the host side of the proxy.
const uint32_t shm_id;
};
// Struct to hold texture information.
struct Texture {
Texture(uint32_t texture_target, const PP_Size& size);
~Texture();
const uint32_t texture_target;
const PP_Size size;
};
// Struct to hold a picture received from the decoder.
struct Picture {
Picture(int32_t decode_id, uint32_t texture_id);
~Picture();
int32_t decode_id;
uint32_t texture_id;
};
int32_t InitializeInternal(PP_Resource graphics_context,
PP_VideoProfile profile,
PP_Bool allow_software_fallback,
scoped_refptr<TrackedCallback> callback,
bool testing);
// Unsolicited reply message handlers.
void OnPluginMsgRequestTextures(const ResourceMessageReplyParams& params,
uint32_t num_textures,
const PP_Size& size,
uint32_t texture_target);
void OnPluginMsgPictureReady(const ResourceMessageReplyParams& params,
int32_t decode_id,
uint32_t texture_id);
void OnPluginMsgDismissPicture(const ResourceMessageReplyParams& params,
uint32_t texture_id);
void OnPluginMsgNotifyError(const ResourceMessageReplyParams& params,
int32_t error);
// Reply message handlers for operations that are done in the host.
void OnPluginMsgInitializeComplete(const ResourceMessageReplyParams& params);
void OnPluginMsgDecodeComplete(const ResourceMessageReplyParams& params,
uint32_t shm_id);
void OnPluginMsgFlushComplete(const ResourceMessageReplyParams& params);
void OnPluginMsgResetComplete(const ResourceMessageReplyParams& params);
void RunCallbackWithError(scoped_refptr<TrackedCallback>* callback);
void DeleteGLTexture(uint32_t texture_id);
void WriteNextPicture(PP_VideoPicture* picture);
// ScopedVector to own the shared memory buffers.
ScopedVector<ShmBuffer> shm_buffers_;
// List of available shared memory buffers.
typedef std::vector<ShmBuffer*> ShmBufferList;
ShmBufferList available_shm_buffers_;
// Map of GL texture id to texture info.
typedef base::hash_map<uint32_t, Texture> TextureMap;
TextureMap textures_;
// Queue of received pictures.
typedef std::queue<Picture> PictureQueue;
PictureQueue received_pictures_;
// Pending callbacks.
scoped_refptr<TrackedCallback> initialize_callback_;
scoped_refptr<TrackedCallback> decode_callback_;
scoped_refptr<TrackedCallback> get_picture_callback_;
scoped_refptr<TrackedCallback> flush_callback_;
scoped_refptr<TrackedCallback> reset_callback_;
// Number of Decode calls made, mod 2^31, to serve as a uid for each decode.
int32_t num_decodes_;
// The maximum delay (in Decode calls) before we receive a picture. If we
// haven't received a picture from a Decode call after this many successive
// calls to Decode, then we will never receive a picture from the call.
// Note that this isn't guaranteed by H264 or other codecs. In practice, this
// number is less than 16. Make it much larger just to be safe.
// NOTE: because we count decodes mod 2^31, this value must be a power of 2.
static const int kMaximumPictureDelay = 128;
uint32_t decode_ids_[kMaximumPictureDelay];
// State for pending get_picture_callback_.
PP_VideoPicture* get_picture_;
ScopedPPResource graphics3d_;
gpu::gles2::GLES2Implementation* gles2_impl_;
bool initialized_;
bool testing_;
int32_t decoder_last_error_;
DISALLOW_COPY_AND_ASSIGN(VideoDecoderResource);
};
} // namespace proxy
} // namespace ppapi
#endif // PPAPI_PROXY_VIDEO_DECODER_RESOURCE_H_
This diff is collapsed.
......@@ -80,6 +80,7 @@
F(PPB_URLRequestInfo_API) \
F(PPB_URLResponseInfo_API) \
F(PPB_VideoCapture_API) \
F(PPB_VideoDecoder_API) \
F(PPB_VideoDecoder_Dev_API) \
F(PPB_VideoDestination_Private_API) \
F(PPB_VideoFrame_API) \
......
......@@ -9,5 +9,6 @@
// Interfaces go here.
PROXIED_IFACE(PPB_FILEMAPPING_INTERFACE_0_1, PPB_FileMapping_0_1)
PROXIED_IFACE(PPB_VIDEODECODER_INTERFACE_0_1, PPB_VideoDecoder_0_1)
#include "ppapi/thunk/interfaces_postamble.h"
......@@ -160,6 +160,7 @@ class ResourceCreationAPI {
virtual PP_Resource CreateTCPSocketPrivate(PP_Instance instace) = 0;
virtual PP_Resource CreateUDPSocket(PP_Instance instace) = 0;
virtual PP_Resource CreateUDPSocketPrivate(PP_Instance instace) = 0;
virtual PP_Resource CreateVideoDecoder(PP_Instance instance) = 0;
virtual PP_Resource CreateVideoDestination(PP_Instance instance) = 0;
virtual PP_Resource CreateVideoSource(PP_Instance instance) = 0;
virtual PP_Resource CreateWebSocket(PP_Instance instance) = 0;
......
......@@ -40466,6 +40466,7 @@ Therefore, the affected-histogram name has to have at least one dot in it.
<int value="1260990020" label="PPB_Ext_Socket(Dev);0.2"/>
<int value="1262240942" label="PPB_FileIO;1.1"/>
<int value="1272679676" label="PPB_TCPSocket_Private;0.5"/>
<int value="1296231808" label="PPB_VideoDecoder;0.1"/>
<int value="1316246754" label="PPB_KeyboardInputEvent;1.0"/>
<int value="1316320941" label="PPB_Graphics2D(Dev);0.1"/>
<int value="1321620067" label="PPB_Instance;1.0"/>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment