summaryrefslogtreecommitdiffstats
path: root/ppapi
diff options
context:
space:
mode:
authorlpique <lpique@chromium.org>2015-08-19 18:06:53 -0700
committerCommit bot <commit-bot@chromium.org>2015-08-20 01:07:22 +0000
commit9dd55e546c4de8767e83fc4065fa2c8352abb47f (patch)
tree585f418b40761a30611f01d93538288d0405a51b /ppapi
parentfedcd4fdd5a4a0e537a5206713409b855ec15fd9 (diff)
downloadchromium_src-9dd55e546c4de8767e83fc4065fa2c8352abb47f.zip
chromium_src-9dd55e546c4de8767e83fc4065fa2c8352abb47f.tar.gz
chromium_src-9dd55e546c4de8767e83fc4065fa2c8352abb47f.tar.bz2
Introduce a client minimum picture pool size
When using the video decoder PPAPI, the most recent version of the ARC extension requires there to be a certain minimum number of picture buffers in flight (allocated but not released). Without a larger pool, ARC video decoding will stall trying to allocate more decoded picture frames than are available by default. This patch creates a new DEV interface version for the VideoDecoder PPAPI. The new interface simply adds a single new argument to VideoDecoder::Initialize() so that a PPAPI client indicate the minimum number of pictures it needs to function. In order to implement this minium picture count, the meaning of the ProvidePictureBuffers() interface call used by the video decoder implementations has changed slightly. After making the call to ProvidePictureBuffers() with a given picture buffer size, the subsequent callback via AssignPictureBuffers() includes a std::vector of buffers that might be larger than requested. I've adjusted the various implementations to handle this change -- most of them previously assumed and asserted that the count was the same. In particular this meant moving some code around in the V4L2 implementations since they also do some internal allocations based on the number of picture buffers that actually end up being chosen. BUG=485775 Review URL: https://codereview.chromium.org/1207043002 Cr-Commit-Position: refs/heads/master@{#344391}
Diffstat (limited to 'ppapi')
-rw-r--r--ppapi/api/ppb_video_decoder.idl40
-rw-r--r--ppapi/c/pp_macros.h4
-rw-r--r--ppapi/c/ppb_video_decoder.h42
-rw-r--r--ppapi/cpp/video_decoder.cc22
-rw-r--r--ppapi/cpp/video_decoder.h7
-rw-r--r--ppapi/examples/video_decode/video_decode.cc1
-rw-r--r--ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c63
-rw-r--r--ppapi/proxy/ppapi_messages.h5
-rw-r--r--ppapi/proxy/video_decoder_constants.h7
-rw-r--r--ppapi/proxy/video_decoder_resource.cc22
-rw-r--r--ppapi/proxy/video_decoder_resource.h8
-rw-r--r--ppapi/proxy/video_decoder_resource_unittest.cc11
-rw-r--r--ppapi/tests/test_video_decoder.cc45
-rw-r--r--ppapi/tests/test_video_decoder.h3
-rw-r--r--ppapi/thunk/interfaces_ppb_public_dev_channel.h1
-rw-r--r--ppapi/thunk/ppb_video_decoder_api.h5
-rw-r--r--ppapi/thunk/ppb_video_decoder_thunk.cc66
17 files changed, 302 insertions, 50 deletions
diff --git a/ppapi/api/ppb_video_decoder.idl b/ppapi/api/ppb_video_decoder.idl
index c8c6945..e879c20 100644
--- a/ppapi/api/ppb_video_decoder.idl
+++ b/ppapi/api/ppb_video_decoder.idl
@@ -13,7 +13,8 @@ label Chrome {
/** Though not labeled 'channel=dev', 0.1 is a still a 'Dev' only API. */
M36 = 0.1,
M39 = 0.2,
- M40 = 1.0
+ M40 = 1.0,
+ [channel=dev] M46 = 1.1
};
/**
@@ -121,6 +122,43 @@ interface PPB_VideoDecoder {
[in] PP_CompletionCallback callback);
/**
+ * Initializes a video decoder resource. This should be called after Create()
+ * and before any other functions.
+ *
+ * @param[in] video_decoder A <code>PP_Resource</code> identifying the video
+ * decoder.
+ * @param[in] graphics3d_context A <code>PPB_Graphics3D</code> resource to use
+ * during decoding.
+ * @param[in] profile A <code>PP_VideoProfile</code> specifying the video
+ * codec profile.
+ * @param[in] acceleration A <code>PP_HardwareAcceleration</code> specifying
+ * whether to use a hardware accelerated or a software implementation.
+ * @param[in] min_picture_count A count of pictures the plugin would like to
+ * have in flight. This is effectively the number of times the plugin can
+ * call GetPicture() and get a decoded frame without calling
+ * RecyclePicture(). The decoder has its own internal minimum count, and will
+ * take the larger of its internal and this value. A client that doesn't care
+ * can therefore just pass in zero for this argument.
+ * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon
+ * completion.
+ *
+ * @return An int32_t containing an error code from <code>pp_errors.h</code>.
+ * Returns PP_ERROR_NOTSUPPORTED if video decoding is not available, or the
+ * requested profile is not supported. In this case, the client may call
+ * Initialize() again with different parameters to find a good configuration.
+ * Returns PP_ERROR_BADARGUMENT if the requested minimum picture count is
+ * unreasonably large.
+ */
+ [version = 1.1]
+ int32_t Initialize(
+ [in] PP_Resource video_decoder,
+ [in] PP_Resource graphics3d_context,
+ [in] PP_VideoProfile profile,
+ [in] PP_HardwareAcceleration acceleration,
+ [in] uint32_t min_picture_count,
+ [in] PP_CompletionCallback callback);
+
+ /**
* Decodes a bitstream buffer. Copies |size| bytes of data from the plugin's
* |buffer|. The plugin should wait until the decoder signals completion by
* returning PP_OK or by running |callback| before calling Decode() again.
diff --git a/ppapi/c/pp_macros.h b/ppapi/c/pp_macros.h
index 28b6c3a..f92a363 100644
--- a/ppapi/c/pp_macros.h
+++ b/ppapi/c/pp_macros.h
@@ -3,13 +3,13 @@
* found in the LICENSE file.
*/
-/* From pp_macros.idl modified Tue Dec 9 11:24:44 2014. */
+/* From pp_macros.idl modified Mon Jul 13 13:38:33 2015. */
#ifndef PPAPI_C_PP_MACROS_H_
#define PPAPI_C_PP_MACROS_H_
-#define PPAPI_RELEASE 44
+#define PPAPI_RELEASE 46
/**
* @file
diff --git a/ppapi/c/ppb_video_decoder.h b/ppapi/c/ppb_video_decoder.h
index 91b2008..f2c4f18 100644
--- a/ppapi/c/ppb_video_decoder.h
+++ b/ppapi/c/ppb_video_decoder.h
@@ -3,7 +3,7 @@
* found in the LICENSE file.
*/
-/* From ppb_video_decoder.idl modified Wed Nov 5 14:04:14 2014. */
+/* From ppb_video_decoder.idl modified Thu Aug 6 14:15:48 2015. */
#ifndef PPAPI_C_PPB_VIDEO_DECODER_H_
#define PPAPI_C_PPB_VIDEO_DECODER_H_
@@ -22,6 +22,7 @@
#define PPB_VIDEODECODER_INTERFACE_0_1 "PPB_VideoDecoder;0.1"
#define PPB_VIDEODECODER_INTERFACE_0_2 "PPB_VideoDecoder;0.2"
#define PPB_VIDEODECODER_INTERFACE_1_0 "PPB_VideoDecoder;1.0"
+#define PPB_VIDEODECODER_INTERFACE_1_1 "PPB_VideoDecoder;1.1" /* dev */
#define PPB_VIDEODECODER_INTERFACE PPB_VIDEODECODER_INTERFACE_1_0
/**
@@ -57,7 +58,7 @@
* Chrome and ChromeOS: aac, h264.
* ChromeOS: mpeg4.
*/
-struct PPB_VideoDecoder_1_0 {
+struct PPB_VideoDecoder_1_1 { /* dev */
/**
* Creates a new video decoder resource.
*
@@ -90,6 +91,12 @@ struct PPB_VideoDecoder_1_0 {
* codec profile.
* @param[in] acceleration A <code>PP_HardwareAcceleration</code> specifying
* whether to use a hardware accelerated or a software implementation.
+ * @param[in] min_picture_count A count of pictures the plugin would like to
+ * have in flight. This is effectively the number of times the plugin can
+ * call GetPicture() and get a decoded frame without calling
+ * RecyclePicture(). The decoder has its own internal minimum count, and will
+ * take the larger of its internal and this value. A client that doesn't care
+ * can therefore just pass in zero for this argument.
* @param[in] callback A <code>PP_CompletionCallback</code> to be called upon
* completion.
*
@@ -97,11 +104,14 @@ struct PPB_VideoDecoder_1_0 {
* Returns PP_ERROR_NOTSUPPORTED if video decoding is not available, or the
* requested profile is not supported. In this case, the client may call
* Initialize() again with different parameters to find a good configuration.
+ * Returns PP_ERROR_BADARGUMENT if the requested minimum picture count is
+ * unreasonably large.
*/
int32_t (*Initialize)(PP_Resource video_decoder,
PP_Resource graphics3d_context,
PP_VideoProfile profile,
PP_HardwareAcceleration acceleration,
+ uint32_t min_picture_count,
struct PP_CompletionCallback callback);
/**
* Decodes a bitstream buffer. Copies |size| bytes of data from the plugin's
@@ -220,8 +230,6 @@ struct PPB_VideoDecoder_1_0 {
struct PP_CompletionCallback callback);
};
-typedef struct PPB_VideoDecoder_1_0 PPB_VideoDecoder;
-
struct PPB_VideoDecoder_0_1 {
PP_Resource (*Create)(PP_Instance instance);
PP_Bool (*IsVideoDecoder)(PP_Resource resource);
@@ -269,6 +277,32 @@ struct PPB_VideoDecoder_0_2 {
int32_t (*Reset)(PP_Resource video_decoder,
struct PP_CompletionCallback callback);
};
+
+struct PPB_VideoDecoder_1_0 {
+ PP_Resource (*Create)(PP_Instance instance);
+ PP_Bool (*IsVideoDecoder)(PP_Resource resource);
+ int32_t (*Initialize)(PP_Resource video_decoder,
+ PP_Resource graphics3d_context,
+ PP_VideoProfile profile,
+ PP_HardwareAcceleration acceleration,
+ struct PP_CompletionCallback callback);
+ int32_t (*Decode)(PP_Resource video_decoder,
+ uint32_t decode_id,
+ uint32_t size,
+ const void* buffer,
+ struct PP_CompletionCallback callback);
+ int32_t (*GetPicture)(PP_Resource video_decoder,
+ struct PP_VideoPicture* picture,
+ struct PP_CompletionCallback callback);
+ void (*RecyclePicture)(PP_Resource video_decoder,
+ const struct PP_VideoPicture* picture);
+ int32_t (*Flush)(PP_Resource video_decoder,
+ struct PP_CompletionCallback callback);
+ int32_t (*Reset)(PP_Resource video_decoder,
+ struct PP_CompletionCallback callback);
+};
+
+typedef struct PPB_VideoDecoder_1_0 PPB_VideoDecoder;
/**
* @}
*/
diff --git a/ppapi/cpp/video_decoder.cc b/ppapi/cpp/video_decoder.cc
index ea954a6..6881e74 100644
--- a/ppapi/cpp/video_decoder.cc
+++ b/ppapi/cpp/video_decoder.cc
@@ -30,6 +30,11 @@ const char* interface_name<PPB_VideoDecoder_1_0>() {
return PPB_VIDEODECODER_INTERFACE_1_0;
}
+template <>
+const char* interface_name<PPB_VideoDecoder_1_1>() {
+ return PPB_VIDEODECODER_INTERFACE_1_1;
+}
+
// This struct is used to adapt CompletionCallbackWithOutput<PP_VideoPicture> to
// the pre-1.0 APIs, which return PP_VideoPicture_0_1. This struct is allocated
// on the heap, and deleted in CallbackConverter.
@@ -69,7 +74,10 @@ VideoDecoder::VideoDecoder() {
}
VideoDecoder::VideoDecoder(const InstanceHandle& instance) {
- if (has_interface<PPB_VideoDecoder_1_0>()) {
+ if (has_interface<PPB_VideoDecoder_1_1>()) {
+ PassRefFromConstructor(
+ get_interface<PPB_VideoDecoder_1_1>()->Create(instance.pp_instance()));
+ } else if (has_interface<PPB_VideoDecoder_1_0>()) {
PassRefFromConstructor(
get_interface<PPB_VideoDecoder_1_0>()->Create(instance.pp_instance()));
} else if (has_interface<PPB_VideoDecoder_0_2>()) {
@@ -87,18 +95,30 @@ VideoDecoder::VideoDecoder(const VideoDecoder& other) : Resource(other) {
int32_t VideoDecoder::Initialize(const Graphics3D& context,
PP_VideoProfile profile,
PP_HardwareAcceleration acceleration,
+ uint32_t min_picture_count,
const CompletionCallback& cc) {
+ if (has_interface<PPB_VideoDecoder_1_1>()) {
+ return get_interface<PPB_VideoDecoder_1_1>()->Initialize(
+ pp_resource(), context.pp_resource(), profile, acceleration,
+ min_picture_count, cc.pp_completion_callback());
+ }
if (has_interface<PPB_VideoDecoder_1_0>()) {
+ if (min_picture_count != 0)
+ return cc.MayForce(PP_ERROR_NOTSUPPORTED);
return get_interface<PPB_VideoDecoder_1_0>()->Initialize(
pp_resource(), context.pp_resource(), profile, acceleration,
cc.pp_completion_callback());
}
if (has_interface<PPB_VideoDecoder_0_2>()) {
+ if (min_picture_count != 0)
+ return cc.MayForce(PP_ERROR_NOTSUPPORTED);
return get_interface<PPB_VideoDecoder_0_2>()->Initialize(
pp_resource(), context.pp_resource(), profile, acceleration,
cc.pp_completion_callback());
}
if (has_interface<PPB_VideoDecoder_0_1>()) {
+ if (min_picture_count != 0)
+ return cc.MayForce(PP_ERROR_NOTSUPPORTED);
if (acceleration == PP_HARDWAREACCELERATION_NONE)
return cc.MayForce(PP_ERROR_NOTSUPPORTED);
return get_interface<PPB_VideoDecoder_0_1>()->Initialize(
diff --git a/ppapi/cpp/video_decoder.h b/ppapi/cpp/video_decoder.h
index 60be572..50b0ea2 100644
--- a/ppapi/cpp/video_decoder.h
+++ b/ppapi/cpp/video_decoder.h
@@ -65,6 +65,12 @@ class VideoDecoder : public Resource {
/// codec profile.
/// @param[in] acceleration A <code>PP_HardwareAcceleration</code> specifying
/// whether to use a hardware accelerated or a software implementation.
+ /// @param[in] min_picture_count A count of pictures the plugin would like to
+ /// have in flight. This is effectively the number of times the plugin can
+ /// call GetPicture() and get a decoded frame without calling
+ /// RecyclePicture(). The decoder has its own internal minimum count, and will
+ /// take the larger of its internal and this value. A client that doesn't care
+ /// can therefore just pass in zero for this argument.
/// @param[in] callback A <code>PP_CompletionCallback</code> to be called upon
/// completion.
///
@@ -75,6 +81,7 @@ class VideoDecoder : public Resource {
int32_t Initialize(const Graphics3D& graphics3d_context,
PP_VideoProfile profile,
PP_HardwareAcceleration acceleration,
+ uint32_t min_picture_count,
const CompletionCallback& callback);
/// Decodes a bitstream buffer. Copies |size| bytes of data from the plugin's
diff --git a/ppapi/examples/video_decode/video_decode.cc b/ppapi/examples/video_decode/video_decode.cc
index 10e0536..e15ef42 100644
--- a/ppapi/examples/video_decode/video_decode.cc
+++ b/ppapi/examples/video_decode/video_decode.cc
@@ -256,6 +256,7 @@ Decoder::Decoder(MyInstance* instance,
decoder_->Initialize(graphics_3d,
kBitstreamProfile,
PP_HARDWAREACCELERATION_WITHFALLBACK,
+ 0,
callback_factory_.NewCallback(&Decoder::InitializeDone));
}
diff --git a/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c b/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c
index 7e30452..07ba3fc 100644
--- a/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c
+++ b/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c
@@ -145,6 +145,7 @@ static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_VarDictionary_1_0;
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_VideoDecoder_0_1;
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_VideoDecoder_0_2;
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_VideoDecoder_1_0;
+static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_VideoDecoder_1_1;
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_VideoEncoder_0_1;
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_VideoEncoder_0_2;
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_WebSocket_1_0;
@@ -2216,6 +2217,50 @@ static int32_t Pnacl_M40_PPB_VideoDecoder_Reset(PP_Resource video_decoder, struc
/* End wrapper methods for PPB_VideoDecoder_1_0 */
+/* Begin wrapper methods for PPB_VideoDecoder_1_1 */
+
+static PP_Resource Pnacl_M46_PPB_VideoDecoder_Create(PP_Instance instance) {
+ const struct PPB_VideoDecoder_1_1 *iface = Pnacl_WrapperInfo_PPB_VideoDecoder_1_1.real_iface;
+ return iface->Create(instance);
+}
+
+static PP_Bool Pnacl_M46_PPB_VideoDecoder_IsVideoDecoder(PP_Resource resource) {
+ const struct PPB_VideoDecoder_1_1 *iface = Pnacl_WrapperInfo_PPB_VideoDecoder_1_1.real_iface;
+ return iface->IsVideoDecoder(resource);
+}
+
+static int32_t Pnacl_M46_PPB_VideoDecoder_Initialize(PP_Resource video_decoder, PP_Resource graphics3d_context, PP_VideoProfile profile, PP_HardwareAcceleration acceleration, uint32_t min_picture_count, struct PP_CompletionCallback* callback) {
+ const struct PPB_VideoDecoder_1_1 *iface = Pnacl_WrapperInfo_PPB_VideoDecoder_1_1.real_iface;
+ return iface->Initialize(video_decoder, graphics3d_context, profile, acceleration, min_picture_count, *callback);
+}
+
+static int32_t Pnacl_M46_PPB_VideoDecoder_Decode(PP_Resource video_decoder, uint32_t decode_id, uint32_t size, const void* buffer, struct PP_CompletionCallback* callback) {
+ const struct PPB_VideoDecoder_1_1 *iface = Pnacl_WrapperInfo_PPB_VideoDecoder_1_1.real_iface;
+ return iface->Decode(video_decoder, decode_id, size, buffer, *callback);
+}
+
+static int32_t Pnacl_M46_PPB_VideoDecoder_GetPicture(PP_Resource video_decoder, struct PP_VideoPicture* picture, struct PP_CompletionCallback* callback) {
+ const struct PPB_VideoDecoder_1_1 *iface = Pnacl_WrapperInfo_PPB_VideoDecoder_1_1.real_iface;
+ return iface->GetPicture(video_decoder, picture, *callback);
+}
+
+static void Pnacl_M46_PPB_VideoDecoder_RecyclePicture(PP_Resource video_decoder, const struct PP_VideoPicture* picture) {
+ const struct PPB_VideoDecoder_1_1 *iface = Pnacl_WrapperInfo_PPB_VideoDecoder_1_1.real_iface;
+ iface->RecyclePicture(video_decoder, picture);
+}
+
+static int32_t Pnacl_M46_PPB_VideoDecoder_Flush(PP_Resource video_decoder, struct PP_CompletionCallback* callback) {
+ const struct PPB_VideoDecoder_1_1 *iface = Pnacl_WrapperInfo_PPB_VideoDecoder_1_1.real_iface;
+ return iface->Flush(video_decoder, *callback);
+}
+
+static int32_t Pnacl_M46_PPB_VideoDecoder_Reset(PP_Resource video_decoder, struct PP_CompletionCallback* callback) {
+ const struct PPB_VideoDecoder_1_1 *iface = Pnacl_WrapperInfo_PPB_VideoDecoder_1_1.real_iface;
+ return iface->Reset(video_decoder, *callback);
+}
+
+/* End wrapper methods for PPB_VideoDecoder_1_1 */
+
/* Begin wrapper methods for PPB_VideoEncoder_0_1 */
static PP_Resource Pnacl_M42_PPB_VideoEncoder_Create(PP_Instance instance) {
@@ -5107,6 +5152,17 @@ static const struct PPB_VideoDecoder_1_0 Pnacl_Wrappers_PPB_VideoDecoder_1_0 = {
.Reset = (int32_t (*)(PP_Resource video_decoder, struct PP_CompletionCallback callback))&Pnacl_M40_PPB_VideoDecoder_Reset
};
+static const struct PPB_VideoDecoder_1_1 Pnacl_Wrappers_PPB_VideoDecoder_1_1 = {
+ .Create = (PP_Resource (*)(PP_Instance instance))&Pnacl_M46_PPB_VideoDecoder_Create,
+ .IsVideoDecoder = (PP_Bool (*)(PP_Resource resource))&Pnacl_M46_PPB_VideoDecoder_IsVideoDecoder,
+ .Initialize = (int32_t (*)(PP_Resource video_decoder, PP_Resource graphics3d_context, PP_VideoProfile profile, PP_HardwareAcceleration acceleration, uint32_t min_picture_count, struct PP_CompletionCallback callback))&Pnacl_M46_PPB_VideoDecoder_Initialize,
+ .Decode = (int32_t (*)(PP_Resource video_decoder, uint32_t decode_id, uint32_t size, const void* buffer, struct PP_CompletionCallback callback))&Pnacl_M46_PPB_VideoDecoder_Decode,
+ .GetPicture = (int32_t (*)(PP_Resource video_decoder, struct PP_VideoPicture* picture, struct PP_CompletionCallback callback))&Pnacl_M46_PPB_VideoDecoder_GetPicture,
+ .RecyclePicture = (void (*)(PP_Resource video_decoder, const struct PP_VideoPicture* picture))&Pnacl_M46_PPB_VideoDecoder_RecyclePicture,
+ .Flush = (int32_t (*)(PP_Resource video_decoder, struct PP_CompletionCallback callback))&Pnacl_M46_PPB_VideoDecoder_Flush,
+ .Reset = (int32_t (*)(PP_Resource video_decoder, struct PP_CompletionCallback callback))&Pnacl_M46_PPB_VideoDecoder_Reset
+};
+
static const struct PPB_VideoEncoder_0_1 Pnacl_Wrappers_PPB_VideoEncoder_0_1 = {
.Create = (PP_Resource (*)(PP_Instance instance))&Pnacl_M42_PPB_VideoEncoder_Create,
.IsVideoEncoder = (PP_Bool (*)(PP_Resource resource))&Pnacl_M42_PPB_VideoEncoder_IsVideoEncoder,
@@ -6081,6 +6137,12 @@ static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_VideoDecoder_1_0 = {
.real_iface = NULL
};
+static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_VideoDecoder_1_1 = {
+ .iface_macro = PPB_VIDEODECODER_INTERFACE_1_1,
+ .wrapped_iface = (const void *) &Pnacl_Wrappers_PPB_VideoDecoder_1_1,
+ .real_iface = NULL
+};
+
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_VideoEncoder_0_1 = {
.iface_macro = PPB_VIDEOENCODER_INTERFACE_0_1,
.wrapped_iface = (const void *) &Pnacl_Wrappers_PPB_VideoEncoder_0_1,
@@ -6482,6 +6544,7 @@ static struct __PnaclWrapperInfo *s_ppb_wrappers[] = {
&Pnacl_WrapperInfo_PPB_VideoDecoder_0_1,
&Pnacl_WrapperInfo_PPB_VideoDecoder_0_2,
&Pnacl_WrapperInfo_PPB_VideoDecoder_1_0,
+ &Pnacl_WrapperInfo_PPB_VideoDecoder_1_1,
&Pnacl_WrapperInfo_PPB_VideoEncoder_0_1,
&Pnacl_WrapperInfo_PPB_VideoEncoder_0_2,
&Pnacl_WrapperInfo_PPB_WebSocket_1_0,
diff --git a/ppapi/proxy/ppapi_messages.h b/ppapi/proxy/ppapi_messages.h
index 12107c8..7d49d05 100644
--- a/ppapi/proxy/ppapi_messages.h
+++ b/ppapi/proxy/ppapi_messages.h
@@ -1970,10 +1970,11 @@ IPC_MESSAGE_CONTROL2(PpapiPluginMsg_OutputProtection_QueryStatusReply,
// VideoDecoder ------------------------------------------------------
IPC_MESSAGE_CONTROL0(PpapiHostMsg_VideoDecoder_Create)
-IPC_MESSAGE_CONTROL3(PpapiHostMsg_VideoDecoder_Initialize,
+IPC_MESSAGE_CONTROL4(PpapiHostMsg_VideoDecoder_Initialize,
ppapi::HostResource /* graphics_context */,
PP_VideoProfile /* profile */,
- PP_HardwareAcceleration /* acceleration */)
+ PP_HardwareAcceleration /* acceleration */,
+ uint32_t /* min_picture_count */)
IPC_MESSAGE_CONTROL0(PpapiPluginMsg_VideoDecoder_InitializeReply)
IPC_MESSAGE_CONTROL2(PpapiHostMsg_VideoDecoder_GetShm,
uint32_t /* shm_id */,
diff --git a/ppapi/proxy/video_decoder_constants.h b/ppapi/proxy/video_decoder_constants.h
index 666ad46..08ea9c7 100644
--- a/ppapi/proxy/video_decoder_constants.h
+++ b/ppapi/proxy/video_decoder_constants.h
@@ -19,7 +19,12 @@ enum {
// Maximum size of shared-memory buffers (4 MB). This should be enough even
// for 4K video at reasonable compression levels.
- kMaximumBitstreamBufferSize = 4 << 20
+ kMaximumBitstreamBufferSize = 4 << 20,
+
+ // The maximum number of pictures that the client can pass in for
+ // min_picture_count, just as a sanity check on the argument.
+ // This should match the constant of the same name in test_video_decoder.cc.
+ kMaximumPictureCount = 100
};
} // namespace proxy
diff --git a/ppapi/proxy/video_decoder_resource.cc b/ppapi/proxy/video_decoder_resource.cc
index bcc0e6e..0ea624d 100644
--- a/ppapi/proxy/video_decoder_resource.cc
+++ b/ppapi/proxy/video_decoder_resource.cc
@@ -62,6 +62,7 @@ VideoDecoderResource::VideoDecoderResource(Connection connection,
PP_Instance instance)
: PluginResource(connection, instance),
num_decodes_(0),
+ min_picture_count_(0),
get_picture_(NULL),
get_picture_0_1_(NULL),
gles2_impl_(NULL),
@@ -98,6 +99,19 @@ int32_t VideoDecoderResource::Initialize0_1(
allow_software_fallback
? PP_HARDWAREACCELERATION_WITHFALLBACK
: PP_HARDWAREACCELERATION_ONLY,
+ 0,
+ callback);
+}
+
+int32_t VideoDecoderResource::Initialize0_2(
+ PP_Resource graphics_context,
+ PP_VideoProfile profile,
+ PP_HardwareAcceleration acceleration,
+ scoped_refptr<TrackedCallback> callback) {
+ return Initialize(graphics_context,
+ profile,
+ acceleration,
+ 0,
callback);
}
@@ -105,16 +119,21 @@ int32_t VideoDecoderResource::Initialize(
PP_Resource graphics_context,
PP_VideoProfile profile,
PP_HardwareAcceleration acceleration,
+ uint32_t min_picture_count,
scoped_refptr<TrackedCallback> callback) {
if (initialized_)
return PP_ERROR_FAILED;
if (profile < 0 || profile > PP_VIDEOPROFILE_MAX)
return PP_ERROR_BADARGUMENT;
+ if (min_picture_count > kMaximumPictureCount)
+ return PP_ERROR_BADARGUMENT;
if (initialize_callback_.get())
return PP_ERROR_INPROGRESS;
if (!graphics_context)
return PP_ERROR_BADRESOURCE;
+ min_picture_count_ = min_picture_count;
+
HostResource host_resource;
if (!testing_) {
// Create a new Graphics3D resource that can create texture resources to
@@ -144,7 +163,7 @@ int32_t VideoDecoderResource::Initialize(
Call<PpapiPluginMsg_VideoDecoder_InitializeReply>(
RENDERER,
PpapiHostMsg_VideoDecoder_Initialize(
- host_resource, profile, acceleration),
+ host_resource, profile, acceleration, min_picture_count),
base::Bind(&VideoDecoderResource::OnPluginMsgInitializeComplete, this));
return PP_OK_COMPLETIONPENDING;
@@ -359,6 +378,7 @@ void VideoDecoderResource::OnPluginMsgRequestTextures(
uint32_t texture_target,
const std::vector<gpu::Mailbox>& mailboxes) {
DCHECK(num_textures);
+ DCHECK(num_textures >= min_picture_count_);
DCHECK(mailboxes.empty() || mailboxes.size() == num_textures);
std::vector<uint32_t> texture_ids(num_textures);
if (gles2_impl_) {
diff --git a/ppapi/proxy/video_decoder_resource.h b/ppapi/proxy/video_decoder_resource.h
index aaa1b95..bb630c4 100644
--- a/ppapi/proxy/video_decoder_resource.h
+++ b/ppapi/proxy/video_decoder_resource.h
@@ -48,9 +48,15 @@ class PPAPI_PROXY_EXPORT VideoDecoderResource
PP_VideoProfile profile,
PP_Bool allow_software_fallback,
scoped_refptr<TrackedCallback> callback) override;
+ int32_t Initialize0_2(
+ PP_Resource graphics_context,
+ PP_VideoProfile profile,
+ PP_HardwareAcceleration acceleration,
+ scoped_refptr<TrackedCallback> callback) override;
int32_t Initialize(PP_Resource graphics_context,
PP_VideoProfile profile,
PP_HardwareAcceleration acceleration,
+ uint32_t min_picture_count,
scoped_refptr<TrackedCallback> callback) override;
int32_t Decode(uint32_t decode_id,
uint32_t size,
@@ -168,6 +174,8 @@ class PPAPI_PROXY_EXPORT VideoDecoderResource
static const int kMaximumPictureDelay = 128;
uint32_t decode_ids_[kMaximumPictureDelay];
+ uint32_t min_picture_count_;
+
// State for pending get_picture_callback_.
PP_VideoPicture* get_picture_;
PP_VideoPicture_0_1* get_picture_0_1_;
diff --git a/ppapi/proxy/video_decoder_resource_unittest.cc b/ppapi/proxy/video_decoder_resource_unittest.cc
index c07f3b0..5a128d1 100644
--- a/ppapi/proxy/video_decoder_resource_unittest.cc
+++ b/ppapi/proxy/video_decoder_resource_unittest.cc
@@ -60,9 +60,9 @@ class MockCompletionCallback {
class VideoDecoderResourceTest : public PluginProxyTest {
public:
VideoDecoderResourceTest()
- : decoder_iface_(thunk::GetPPB_VideoDecoder_1_0_Thunk()) {}
+ : decoder_iface_(thunk::GetPPB_VideoDecoder_1_1_Thunk()) {}
- const PPB_VideoDecoder_1_0* decoder_iface() const { return decoder_iface_; }
+ const PPB_VideoDecoder_1_1* decoder_iface() const { return decoder_iface_; }
void SendReply(const ResourceMessageCallParams& params,
int32_t result,
@@ -119,6 +119,7 @@ class VideoDecoderResourceTest : public PluginProxyTest {
graphics3d.get(),
PP_VIDEOPROFILE_H264MAIN,
PP_HARDWAREACCELERATION_WITHFALLBACK,
+ 0,
PP_MakeOptionalCompletionCallback(&MockCompletionCallback::Callback,
&cb));
if (result != PP_OK_COMPLETIONPENDING)
@@ -299,7 +300,7 @@ class VideoDecoderResourceTest : public PluginProxyTest {
return true;
}
- const PPB_VideoDecoder_1_0* decoder_iface_;
+ const PPB_VideoDecoder_1_1* decoder_iface_;
char decode_buffer_[kDecodeBufferSize];
};
@@ -316,6 +317,7 @@ TEST_F(VideoDecoderResourceTest, Initialize) {
0 /* invalid 3d graphics */,
PP_VIDEOPROFILE_H264MAIN,
PP_HARDWAREACCELERATION_WITHFALLBACK,
+ 0,
PP_MakeOptionalCompletionCallback(&MockCompletionCallback::Callback,
&cb));
ASSERT_EQ(PP_ERROR_BADRESOURCE, result);
@@ -329,6 +331,7 @@ TEST_F(VideoDecoderResourceTest, Initialize) {
1 /* non-zero resource */,
static_cast<PP_VideoProfile>(-1),
PP_HARDWAREACCELERATION_WITHFALLBACK,
+ 0,
PP_MakeOptionalCompletionCallback(&MockCompletionCallback::Callback,
&cb));
ASSERT_EQ(PP_ERROR_BADARGUMENT, result);
@@ -343,6 +346,7 @@ TEST_F(VideoDecoderResourceTest, Initialize) {
graphics3d.get(),
PP_VIDEOPROFILE_H264MAIN,
PP_HARDWAREACCELERATION_WITHFALLBACK,
+ 0,
PP_MakeOptionalCompletionCallback(&MockCompletionCallback::Callback,
&cb));
ASSERT_EQ(PP_OK_COMPLETIONPENDING, result);
@@ -354,6 +358,7 @@ TEST_F(VideoDecoderResourceTest, Initialize) {
graphics3d.get(),
PP_VIDEOPROFILE_H264MAIN,
PP_HARDWAREACCELERATION_WITHFALLBACK,
+ 0,
PP_MakeOptionalCompletionCallback(&MockCompletionCallback::Callback,
&cb));
ASSERT_EQ(PP_ERROR_INPROGRESS, result);
diff --git a/ppapi/tests/test_video_decoder.cc b/ppapi/tests/test_video_decoder.cc
index f396bda..a6b1ce9 100644
--- a/ppapi/tests/test_video_decoder.cc
+++ b/ppapi/tests/test_video_decoder.cc
@@ -9,18 +9,27 @@
#include "ppapi/lib/gl/gles2/gl2ext_ppapi.h"
#include "ppapi/tests/testing_instance.h"
+namespace {
+
+// The maximum number of pictures that the client can pass in for
+// min_picture_count, just as a sanity check on the argument.
+// This should match the value of kMaximumPictureCount in
+// video_decoder_resource.cc.
+const uint32_t kMaximumPictureCount = 100;
+
+} // namespace
+
REGISTER_TEST_CASE(VideoDecoder);
bool TestVideoDecoder::Init() {
- video_decoder_interface_ = static_cast<const PPB_VideoDecoder_0_1*>(
- pp::Module::Get()->GetBrowserInterface(PPB_VIDEODECODER_INTERFACE_0_1));
const int width = 16;
const int height = 16;
const int32_t attribs[] = {PP_GRAPHICS3DATTRIB_WIDTH, width,
PP_GRAPHICS3DATTRIB_HEIGHT, height,
PP_GRAPHICS3DATTRIB_NONE};
graphics_3d_ = pp::Graphics3D(instance_, attribs);
- return video_decoder_interface_ && CheckTestingInterface();
+ return (pp::Module::Get()->GetBrowserInterface(PPB_VIDEODECODER_INTERFACE) &&
+ CheckTestingInterface());
}
void TestVideoDecoder::RunTests(const std::string& filter) {
@@ -39,6 +48,7 @@ std::string TestVideoDecoder::TestCreate() {
video_decoder.Initialize(null_graphics_3d,
PP_VIDEOPROFILE_VP8_ANY,
PP_HARDWAREACCELERATION_WITHFALLBACK,
+ 0,
callback.GetCallback()));
ASSERT_EQ(PP_ERROR_BADRESOURCE, callback.result());
}
@@ -51,6 +61,7 @@ std::string TestVideoDecoder::TestCreate() {
video_decoder.Initialize(graphics_3d_,
kInvalidProfile,
PP_HARDWAREACCELERATION_WITHFALLBACK,
+ 0,
callback.GetCallback()));
ASSERT_EQ(PP_ERROR_BADARGUMENT, callback.result());
}
@@ -63,9 +74,37 @@ std::string TestVideoDecoder::TestCreate() {
video_decoder.Initialize(graphics_3d_,
PP_VIDEOPROFILE_VP8_ANY,
PP_HARDWAREACCELERATION_WITHFALLBACK,
+ 0,
callback.GetCallback()));
ASSERT_EQ(PP_OK, callback.result());
}
+ // Test that Initialize succeeds with a larger than normal number of requested
+ // picture buffers, if we can create a Graphics3D resource and if we allow
+ // software fallback to VP8, which should always be supported.
+ if (!graphics_3d_.is_null()) {
+ pp::VideoDecoder video_decoder(instance_);
+ TestCompletionCallback callback(instance_->pp_instance(), callback_type());
+ callback.WaitForResult(
+ video_decoder.Initialize(graphics_3d_,
+ PP_VIDEOPROFILE_VP8_ANY,
+ PP_HARDWAREACCELERATION_WITHFALLBACK,
+ kMaximumPictureCount,
+ callback.GetCallback()));
+ ASSERT_EQ(PP_OK, callback.result());
+ }
+ // Test that Initialize fails if we request an unreasonable number of picture
+ // buffers.
+ if (!graphics_3d_.is_null()) {
+ pp::VideoDecoder video_decoder(instance_);
+ TestCompletionCallback callback(instance_->pp_instance(), callback_type());
+ callback.WaitForResult(
+ video_decoder.Initialize(graphics_3d_,
+ PP_VIDEOPROFILE_VP8_ANY,
+ PP_HARDWAREACCELERATION_WITHFALLBACK,
+ kMaximumPictureCount + 1,
+ callback.GetCallback()));
+ ASSERT_EQ(PP_ERROR_BADARGUMENT, callback.result());
+ }
PASS();
}
diff --git a/ppapi/tests/test_video_decoder.h b/ppapi/tests/test_video_decoder.h
index cc6eb11..1fcec03 100644
--- a/ppapi/tests/test_video_decoder.h
+++ b/ppapi/tests/test_video_decoder.h
@@ -23,9 +23,6 @@ class TestVideoDecoder : public TestCase {
std::string TestCreate();
- // Used by the tests that access the C API directly.
- const PPB_VideoDecoder_0_1* video_decoder_interface_;
-
pp::Graphics3D graphics_3d_;
};
diff --git a/ppapi/thunk/interfaces_ppb_public_dev_channel.h b/ppapi/thunk/interfaces_ppb_public_dev_channel.h
index 7e0f91c..8214dcf 100644
--- a/ppapi/thunk/interfaces_ppb_public_dev_channel.h
+++ b/ppapi/thunk/interfaces_ppb_public_dev_channel.h
@@ -12,6 +12,7 @@ PROXIED_IFACE(PPB_COMPOSITOR_INTERFACE_0_1, PPB_Compositor_0_1)
PROXIED_IFACE(PPB_COMPOSITORLAYER_INTERFACE_0_1, PPB_CompositorLayer_0_1)
PROXIED_IFACE(PPB_COMPOSITORLAYER_INTERFACE_0_2, PPB_CompositorLayer_0_2)
PROXIED_IFACE(PPB_VIDEODECODER_INTERFACE_0_1, PPB_VideoDecoder_0_1)
+PROXIED_IFACE(PPB_VIDEODECODER_INTERFACE_1_1, PPB_VideoDecoder_1_1)
PROXIED_IFACE(PPB_VIDEOENCODER_INTERFACE_0_1, PPB_VideoEncoder_0_1)
// Note, PPB_TraceEvent is special. We don't want to actually make it stable,
diff --git a/ppapi/thunk/ppb_video_decoder_api.h b/ppapi/thunk/ppb_video_decoder_api.h
index 5acceaa..1a132d2 100644
--- a/ppapi/thunk/ppb_video_decoder_api.h
+++ b/ppapi/thunk/ppb_video_decoder_api.h
@@ -23,9 +23,14 @@ class PPAPI_THUNK_EXPORT PPB_VideoDecoder_API {
PP_VideoProfile profile,
PP_Bool allow_software_fallback,
scoped_refptr<TrackedCallback> callback) = 0;
+ virtual int32_t Initialize0_2(PP_Resource graphics3d_context,
+ PP_VideoProfile profile,
+ PP_HardwareAcceleration acceleration,
+ scoped_refptr<TrackedCallback> callback) = 0;
virtual int32_t Initialize(PP_Resource graphics3d_context,
PP_VideoProfile profile,
PP_HardwareAcceleration acceleration,
+ uint32_t min_picture_count,
scoped_refptr<TrackedCallback> callback) = 0;
virtual int32_t Decode(uint32_t decode_id,
uint32_t size,
diff --git a/ppapi/thunk/ppb_video_decoder_thunk.cc b/ppapi/thunk/ppb_video_decoder_thunk.cc
index 511e35a..4039c3e 100644
--- a/ppapi/thunk/ppb_video_decoder_thunk.cc
+++ b/ppapi/thunk/ppb_video_decoder_thunk.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-// From ppb_video_decoder.idl modified Thu Jan 29 16:28:15 2015.
+// From ppb_video_decoder.idl modified Wed Aug 12 17:59:47 2015.
#include "ppapi/c/pp_completion_callback.h"
#include "ppapi/c/pp_errors.h"
@@ -44,17 +44,32 @@ int32_t Initialize_0_1(PP_Resource video_decoder,
graphics3d_context, profile, allow_software_fallback, enter.callback()));
}
+int32_t Initialize_0_2(PP_Resource video_decoder,
+ PP_Resource graphics3d_context,
+ PP_VideoProfile profile,
+ PP_HardwareAcceleration acceleration,
+ struct PP_CompletionCallback callback) {
+ VLOG(4) << "PPB_VideoDecoder::Initialize_0_2()";
+ EnterResource<PPB_VideoDecoder_API> enter(video_decoder, callback, true);
+ if (enter.failed())
+ return enter.retval();
+ return enter.SetResult(enter.object()->Initialize0_2(
+ graphics3d_context, profile, acceleration, enter.callback()));
+}
+
int32_t Initialize(PP_Resource video_decoder,
PP_Resource graphics3d_context,
PP_VideoProfile profile,
PP_HardwareAcceleration acceleration,
+ uint32_t min_picture_count,
struct PP_CompletionCallback callback) {
VLOG(4) << "PPB_VideoDecoder::Initialize()";
EnterResource<PPB_VideoDecoder_API> enter(video_decoder, callback, true);
if (enter.failed())
return enter.retval();
- return enter.SetResult(enter.object()->Initialize(
- graphics3d_context, profile, acceleration, enter.callback()));
+ return enter.SetResult(
+ enter.object()->Initialize(graphics3d_context, profile, acceleration,
+ min_picture_count, enter.callback()));
}
int32_t Decode(PP_Resource video_decoder,
@@ -118,32 +133,21 @@ int32_t Reset(PP_Resource video_decoder,
return enter.SetResult(enter.object()->Reset(enter.callback()));
}
-const PPB_VideoDecoder_0_1 g_ppb_videodecoder_thunk_0_1 = {&Create,
- &IsVideoDecoder,
- &Initialize_0_1,
- &Decode,
- &GetPicture_0_1,
- &RecyclePicture,
- &Flush,
- &Reset};
-
-const PPB_VideoDecoder_0_2 g_ppb_videodecoder_thunk_0_2 = {&Create,
- &IsVideoDecoder,
- &Initialize,
- &Decode,
- &GetPicture_0_1,
- &RecyclePicture,
- &Flush,
- &Reset};
-
-const PPB_VideoDecoder_1_0 g_ppb_videodecoder_thunk_1_0 = {&Create,
- &IsVideoDecoder,
- &Initialize,
- &Decode,
- &GetPicture,
- &RecyclePicture,
- &Flush,
- &Reset};
+const PPB_VideoDecoder_0_1 g_ppb_videodecoder_thunk_0_1 = {
+ &Create, &IsVideoDecoder, &Initialize_0_1, &Decode,
+ &GetPicture_0_1, &RecyclePicture, &Flush, &Reset};
+
+const PPB_VideoDecoder_0_2 g_ppb_videodecoder_thunk_0_2 = {
+ &Create, &IsVideoDecoder, &Initialize_0_2, &Decode,
+ &GetPicture_0_1, &RecyclePicture, &Flush, &Reset};
+
+const PPB_VideoDecoder_1_0 g_ppb_videodecoder_thunk_1_0 = {
+ &Create, &IsVideoDecoder, &Initialize_0_2, &Decode,
+ &GetPicture, &RecyclePicture, &Flush, &Reset};
+
+const PPB_VideoDecoder_1_1 g_ppb_videodecoder_thunk_1_1 = {
+ &Create, &IsVideoDecoder, &Initialize, &Decode,
+ &GetPicture, &RecyclePicture, &Flush, &Reset};
} // namespace
@@ -159,5 +163,9 @@ PPAPI_THUNK_EXPORT const PPB_VideoDecoder_1_0* GetPPB_VideoDecoder_1_0_Thunk() {
return &g_ppb_videodecoder_thunk_1_0;
}
+PPAPI_THUNK_EXPORT const PPB_VideoDecoder_1_1* GetPPB_VideoDecoder_1_1_Thunk() {
+ return &g_ppb_videodecoder_thunk_1_1;
+}
+
} // namespace thunk
} // namespace ppapi