Chromium Code Reviews| Index: content/renderer/pepper/pepper_video_decoder_host.cc |
| diff --git a/content/renderer/pepper/pepper_video_decoder_host.cc b/content/renderer/pepper/pepper_video_decoder_host.cc |
| index d97aed8be2e70c314b38573fa7dcd2c70cce1ddc..561bf20731e66c9b25f82bf513727c5ad5b92647 100644 |
| --- a/content/renderer/pepper/pepper_video_decoder_host.cc |
| +++ b/content/renderer/pepper/pepper_video_decoder_host.cc |
| @@ -8,11 +8,14 @@ |
| #include "base/memory/shared_memory.h" |
| #include "content/common/gpu/client/command_buffer_proxy_impl.h" |
| #include "content/common/pepper_file_util.h" |
| +#include "content/public/common/content_client.h" |
| +#include "content/public/renderer/content_renderer_client.h" |
| #include "content/public/renderer/render_thread.h" |
| #include "content/public/renderer/renderer_ppapi_host.h" |
| #include "content/renderer/pepper/gfx_conversion.h" |
| #include "content/renderer/pepper/ppb_graphics_3d_impl.h" |
| #include "content/renderer/pepper/video_decoder_shim.h" |
| +#include "media/base/limits.h" |
| #include "media/video/video_decode_accelerator.h" |
| #include "ppapi/c/pp_completion_callback.h" |
| #include "ppapi/c/pp_errors.h" |
| @@ -31,6 +34,11 @@ namespace content { |
| 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 constant of the same name in test_video_decoder.cc. |
| +const uint32_t kMaximumPictureCount = 100; |
|
bbudge
2015/08/19 18:47:06
I forgot that we had a place for constants like th
lpique
2015/08/19 19:42:17
Sure. I saw it when looking for a location to shar
|
| + |
| media::VideoCodecProfile PepperToMediaVideoProfile(PP_VideoProfile profile) { |
| switch (profile) { |
| case PP_VIDEOPROFILE_H264BASELINE: |
| @@ -81,6 +89,7 @@ PepperVideoDecoderHost::PepperVideoDecoderHost(RendererPpapiHost* host, |
| PP_Resource resource) |
| : ResourceHost(host->GetPpapiHost(), instance, resource), |
| renderer_ppapi_host_(host), |
| + min_picture_count_(0), |
| initialized_(false) { |
| } |
| @@ -113,9 +122,12 @@ int32_t PepperVideoDecoderHost::OnHostMsgInitialize( |
| ppapi::host::HostMessageContext* context, |
| const ppapi::HostResource& graphics_context, |
| PP_VideoProfile profile, |
| - PP_HardwareAcceleration acceleration) { |
| + PP_HardwareAcceleration acceleration, |
| + uint32_t min_picture_count) { |
| if (initialized_) |
| return PP_ERROR_FAILED; |
| + if (min_picture_count > kMaximumPictureCount) |
| + return PP_ERROR_BADARGUMENT; |
| EnterResourceNoLock<PPB_Graphics3D_API> enter_graphics( |
| graphics_context.host_resource(), true); |
| @@ -130,6 +142,17 @@ int32_t PepperVideoDecoderHost::OnHostMsgInitialize( |
| media::VideoCodecProfile media_profile = PepperToMediaVideoProfile(profile); |
| + // Check for Dev API use |
| + // TODO(lpique): remove check when PPB_VideoDecoder_1_1 reaches beta/stable. |
| + // https://crbug.com/520323 |
| + if (min_picture_count != 0) { |
| + ContentRendererClient* client = GetContentClient()->renderer(); |
| + bool allowed = client->IsPluginAllowedToUseDevChannelAPIs(); |
| + if (!allowed) |
| + return PP_ERROR_NOTSUPPORTED; |
| + } |
| + min_picture_count_ = min_picture_count; |
| + |
| if (acceleration != PP_HARDWAREACCELERATION_NONE) { |
| // This is not synchronous, but subsequent IPC messages will be buffered, so |
| // it is okay to immediately send IPC messages. |
| @@ -146,7 +169,10 @@ int32_t PepperVideoDecoderHost::OnHostMsgInitialize( |
| #if defined(OS_ANDROID) |
| return PP_ERROR_NOTSUPPORTED; |
| #else |
| - decoder_.reset(new VideoDecoderShim(this)); |
| + uint32_t shim_texture_pool_size = media::limits::kMaxVideoFrames + 1; |
| + shim_texture_pool_size = std::max(shim_texture_pool_size, |
| + min_picture_count_); |
| + decoder_.reset(new VideoDecoderShim(this, shim_texture_pool_size)); |
| initialize_reply_context_ = context->MakeReplyMessageContext(); |
| decoder_->Initialize(media_profile, this); |
| @@ -317,7 +343,7 @@ void PepperVideoDecoderHost::ProvidePictureBuffers( |
| uint32 requested_num_of_buffers, |
| const gfx::Size& dimensions, |
| uint32 texture_target) { |
| - RequestTextures(requested_num_of_buffers, |
| + RequestTextures(std::max(min_picture_count_, requested_num_of_buffers), |
| dimensions, |
| texture_target, |
| std::vector<gpu::Mailbox>()); |