Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(299)

Side by Side Diff: content/renderer/pepper/pepper_video_decoder_host.cc

Issue 1207043002: Introduce a client minimum picture pool size (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/pepper/pepper_video_decoder_host.h" 5 #include "content/renderer/pepper/pepper_video_decoder_host.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/memory/shared_memory.h" 8 #include "base/memory/shared_memory.h"
9 #include "content/common/gpu/client/gpu_channel_host.h" 9 #include "content/common/gpu/client/gpu_channel_host.h"
10 #include "content/common/pepper_file_util.h" 10 #include "content/common/pepper_file_util.h"
11 #include "content/public/common/content_client.h"
12 #include "content/public/renderer/content_renderer_client.h"
11 #include "content/public/renderer/render_thread.h" 13 #include "content/public/renderer/render_thread.h"
12 #include "content/public/renderer/renderer_ppapi_host.h" 14 #include "content/public/renderer/renderer_ppapi_host.h"
13 #include "content/renderer/pepper/gfx_conversion.h" 15 #include "content/renderer/pepper/gfx_conversion.h"
14 #include "content/renderer/pepper/ppb_graphics_3d_impl.h" 16 #include "content/renderer/pepper/ppb_graphics_3d_impl.h"
15 #include "content/renderer/pepper/video_decoder_shim.h" 17 #include "content/renderer/pepper/video_decoder_shim.h"
18 #include "media/base/limits.h"
16 #include "media/video/video_decode_accelerator.h" 19 #include "media/video/video_decode_accelerator.h"
17 #include "ppapi/c/pp_completion_callback.h" 20 #include "ppapi/c/pp_completion_callback.h"
18 #include "ppapi/c/pp_errors.h" 21 #include "ppapi/c/pp_errors.h"
19 #include "ppapi/host/dispatch_host_message.h" 22 #include "ppapi/host/dispatch_host_message.h"
20 #include "ppapi/host/ppapi_host.h" 23 #include "ppapi/host/ppapi_host.h"
21 #include "ppapi/proxy/ppapi_messages.h" 24 #include "ppapi/proxy/ppapi_messages.h"
22 #include "ppapi/proxy/video_decoder_constants.h" 25 #include "ppapi/proxy/video_decoder_constants.h"
23 #include "ppapi/thunk/enter.h" 26 #include "ppapi/thunk/enter.h"
24 #include "ppapi/thunk/ppb_graphics_3d_api.h" 27 #include "ppapi/thunk/ppb_graphics_3d_api.h"
25 28
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 } 77 }
75 78
76 PepperVideoDecoderHost::PendingDecode::~PendingDecode() { 79 PepperVideoDecoderHost::PendingDecode::~PendingDecode() {
77 } 80 }
78 81
79 PepperVideoDecoderHost::PepperVideoDecoderHost(RendererPpapiHost* host, 82 PepperVideoDecoderHost::PepperVideoDecoderHost(RendererPpapiHost* host,
80 PP_Instance instance, 83 PP_Instance instance,
81 PP_Resource resource) 84 PP_Resource resource)
82 : ResourceHost(host->GetPpapiHost(), instance, resource), 85 : ResourceHost(host->GetPpapiHost(), instance, resource),
83 renderer_ppapi_host_(host), 86 renderer_ppapi_host_(host),
87 min_picture_count_(0),
84 initialized_(false) { 88 initialized_(false) {
85 } 89 }
86 90
87 PepperVideoDecoderHost::~PepperVideoDecoderHost() { 91 PepperVideoDecoderHost::~PepperVideoDecoderHost() {
88 } 92 }
89 93
90 int32_t PepperVideoDecoderHost::OnResourceMessageReceived( 94 int32_t PepperVideoDecoderHost::OnResourceMessageReceived(
91 const IPC::Message& msg, 95 const IPC::Message& msg,
92 ppapi::host::HostMessageContext* context) { 96 ppapi::host::HostMessageContext* context) {
93 PPAPI_BEGIN_MESSAGE_MAP(PepperVideoDecoderHost, msg) 97 PPAPI_BEGIN_MESSAGE_MAP(PepperVideoDecoderHost, msg)
(...skipping 12 matching lines...) Expand all
106 PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_VideoDecoder_Reset, 110 PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_VideoDecoder_Reset,
107 OnHostMsgReset) 111 OnHostMsgReset)
108 PPAPI_END_MESSAGE_MAP() 112 PPAPI_END_MESSAGE_MAP()
109 return PP_ERROR_FAILED; 113 return PP_ERROR_FAILED;
110 } 114 }
111 115
112 int32_t PepperVideoDecoderHost::OnHostMsgInitialize( 116 int32_t PepperVideoDecoderHost::OnHostMsgInitialize(
113 ppapi::host::HostMessageContext* context, 117 ppapi::host::HostMessageContext* context,
114 const ppapi::HostResource& graphics_context, 118 const ppapi::HostResource& graphics_context,
115 PP_VideoProfile profile, 119 PP_VideoProfile profile,
116 PP_HardwareAcceleration acceleration) { 120 PP_HardwareAcceleration acceleration,
121 uint32_t min_picture_count) {
117 if (initialized_) 122 if (initialized_)
118 return PP_ERROR_FAILED; 123 return PP_ERROR_FAILED;
119 124
120 EnterResourceNoLock<PPB_Graphics3D_API> enter_graphics( 125 EnterResourceNoLock<PPB_Graphics3D_API> enter_graphics(
121 graphics_context.host_resource(), true); 126 graphics_context.host_resource(), true);
122 if (enter_graphics.failed()) 127 if (enter_graphics.failed())
123 return PP_ERROR_FAILED; 128 return PP_ERROR_FAILED;
124 PPB_Graphics3D_Impl* graphics3d = 129 PPB_Graphics3D_Impl* graphics3d =
125 static_cast<PPB_Graphics3D_Impl*>(enter_graphics.object()); 130 static_cast<PPB_Graphics3D_Impl*>(enter_graphics.object());
126 131
127 int command_buffer_route_id = graphics3d->GetCommandBufferRouteId(); 132 int command_buffer_route_id = graphics3d->GetCommandBufferRouteId();
128 if (!command_buffer_route_id) 133 if (!command_buffer_route_id)
129 return PP_ERROR_FAILED; 134 return PP_ERROR_FAILED;
130 135
131 media::VideoCodecProfile media_profile = PepperToMediaVideoProfile(profile); 136 media::VideoCodecProfile media_profile = PepperToMediaVideoProfile(profile);
132 137
138 // Check for Dev API use
139 // TODO(lpique): remove check when PPB_VideoDecoder_1_1 reaches beta/stable.
140 if (min_picture_count != 0) {
141 ContentRendererClient* client = GetContentClient()->renderer();
142 bool allowed = client->IsPluginAllowedToUseDevChannelAPIs();
143 if (!allowed)
144 return PP_ERROR_NOTSUPPORTED;
145 }
146 min_picture_count_ = min_picture_count;
147
133 if (acceleration != PP_HARDWAREACCELERATION_NONE) { 148 if (acceleration != PP_HARDWAREACCELERATION_NONE) {
134 // This is not synchronous, but subsequent IPC messages will be buffered, so 149 // This is not synchronous, but subsequent IPC messages will be buffered, so
135 // it is okay to immediately send IPC messages through the returned channel. 150 // it is okay to immediately send IPC messages through the returned channel.
136 GpuChannelHost* channel = graphics3d->channel(); 151 GpuChannelHost* channel = graphics3d->channel();
137 DCHECK(channel); 152 DCHECK(channel);
138 decoder_ = channel->CreateVideoDecoder(command_buffer_route_id); 153 decoder_ = channel->CreateVideoDecoder(command_buffer_route_id);
139 if (decoder_ && decoder_->Initialize(media_profile, this)) { 154 if (decoder_ && decoder_->Initialize(media_profile, this)) {
140 initialized_ = true; 155 initialized_ = true;
141 return PP_OK; 156 return PP_OK;
142 } 157 }
143 decoder_.reset(); 158 decoder_.reset();
144 if (acceleration == PP_HARDWAREACCELERATION_ONLY) 159 if (acceleration == PP_HARDWAREACCELERATION_ONLY)
145 return PP_ERROR_NOTSUPPORTED; 160 return PP_ERROR_NOTSUPPORTED;
146 } 161 }
147 162
148 #if defined(OS_ANDROID) 163 #if defined(OS_ANDROID)
149 return PP_ERROR_NOTSUPPORTED; 164 return PP_ERROR_NOTSUPPORTED;
150 #else 165 #else
151 decoder_.reset(new VideoDecoderShim(this)); 166 uint32_t shim_texture_pool_size = media::limits::kMaxVideoFrames + 1;
167 shim_texture_pool_size = std::max(shim_texture_pool_size,
168 min_picture_count_);
169 decoder_.reset(new VideoDecoderShim(this, shim_texture_pool_size));
152 initialize_reply_context_ = context->MakeReplyMessageContext(); 170 initialize_reply_context_ = context->MakeReplyMessageContext();
153 decoder_->Initialize(media_profile, this); 171 decoder_->Initialize(media_profile, this);
154 172
155 return PP_OK_COMPLETIONPENDING; 173 return PP_OK_COMPLETIONPENDING;
156 #endif 174 #endif
157 } 175 }
158 176
159 int32_t PepperVideoDecoderHost::OnHostMsgGetShm( 177 int32_t PepperVideoDecoderHost::OnHostMsgGetShm(
160 ppapi::host::HostMessageContext* context, 178 ppapi::host::HostMessageContext* context,
161 uint32_t shm_id, 179 uint32_t shm_id,
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 reset_reply_context_ = context->MakeReplyMessageContext(); 330 reset_reply_context_ = context->MakeReplyMessageContext();
313 decoder_->Reset(); 331 decoder_->Reset();
314 332
315 return PP_OK_COMPLETIONPENDING; 333 return PP_OK_COMPLETIONPENDING;
316 } 334 }
317 335
318 void PepperVideoDecoderHost::ProvidePictureBuffers( 336 void PepperVideoDecoderHost::ProvidePictureBuffers(
319 uint32 requested_num_of_buffers, 337 uint32 requested_num_of_buffers,
320 const gfx::Size& dimensions, 338 const gfx::Size& dimensions,
321 uint32 texture_target) { 339 uint32 texture_target) {
322 RequestTextures(requested_num_of_buffers, 340 RequestTextures(std::max(min_picture_count_, requested_num_of_buffers),
323 dimensions, 341 dimensions,
324 texture_target, 342 texture_target,
325 std::vector<gpu::Mailbox>()); 343 std::vector<gpu::Mailbox>());
326 } 344 }
327 345
328 void PepperVideoDecoderHost::PictureReady(const media::Picture& picture) { 346 void PepperVideoDecoderHost::PictureReady(const media::Picture& picture) {
329 // Don't bother validating the visible rect, since the plugin process is less 347 // Don't bother validating the visible rect, since the plugin process is less
330 // trusted than the gpu process. 348 // trusted than the gpu process.
331 DCHECK(pictures_in_use_.find(picture.picture_buffer_id()) == 349 DCHECK(pictures_in_use_.find(picture.picture_buffer_id()) ==
332 pictures_in_use_.end()); 350 pictures_in_use_.end());
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 host()->SendUnsolicitedReply( 443 host()->SendUnsolicitedReply(
426 pp_resource(), 444 pp_resource(),
427 PpapiPluginMsg_VideoDecoder_RequestTextures( 445 PpapiPluginMsg_VideoDecoder_RequestTextures(
428 requested_num_of_buffers, 446 requested_num_of_buffers,
429 PP_MakeSize(dimensions.width(), dimensions.height()), 447 PP_MakeSize(dimensions.width(), dimensions.height()),
430 texture_target, 448 texture_target,
431 mailboxes)); 449 mailboxes));
432 } 450 }
433 451
434 } // namespace content 452 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698