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

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

Issue 704913002: PPAPI: Make GetProxiedInterface not re-enter the plugin (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Oops, make SimulateInputEvent async again Created 6 years, 1 month 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
« no previous file with comments | « content/renderer/pepper/ppb_video_decoder_impl.h ('k') | ppapi/proxy/host_dispatcher.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/ppb_video_decoder_impl.h" 5 #include "content/renderer/pepper/ppb_video_decoder_impl.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 return PP_VIDEODECODERERROR_ILLEGAL_STATE; 88 return PP_VIDEODECODERERROR_ILLEGAL_STATE;
89 } 89 }
90 } 90 }
91 91
92 } // namespace 92 } // namespace
93 93
94 namespace content { 94 namespace content {
95 95
96 PPB_VideoDecoder_Impl::PPB_VideoDecoder_Impl(PP_Instance instance) 96 PPB_VideoDecoder_Impl::PPB_VideoDecoder_Impl(PP_Instance instance)
97 : PPB_VideoDecoder_Shared(instance), ppp_videodecoder_(NULL) { 97 : PPB_VideoDecoder_Shared(instance), ppp_videodecoder_(NULL) {
98 PluginModule* plugin_module =
99 HostGlobals::Get()->GetInstance(pp_instance())->module();
100 if (plugin_module) {
101 ppp_videodecoder_ = static_cast<const PPP_VideoDecoder_Dev*>(
102 plugin_module->GetPluginInterface(PPP_VIDEODECODER_DEV_INTERFACE));
103 }
104 } 98 }
105 99
106 PPB_VideoDecoder_Impl::~PPB_VideoDecoder_Impl() { Destroy(); } 100 PPB_VideoDecoder_Impl::~PPB_VideoDecoder_Impl() { Destroy(); }
107 101
108 // static 102 // static
109 PP_Resource PPB_VideoDecoder_Impl::Create(PP_Instance instance, 103 PP_Resource PPB_VideoDecoder_Impl::Create(PP_Instance instance,
110 PP_Resource graphics_context, 104 PP_Resource graphics_context,
111 PP_VideoDecoder_Profile profile) { 105 PP_VideoDecoder_Profile profile) {
112 scoped_refptr<PPB_VideoDecoder_Impl> decoder( 106 scoped_refptr<PPB_VideoDecoder_Impl> decoder(
113 new PPB_VideoDecoder_Impl(instance)); 107 new PPB_VideoDecoder_Impl(instance));
(...skipping 19 matching lines...) Expand all
133 FlushCommandBuffer(); 127 FlushCommandBuffer();
134 128
135 // This is not synchronous, but subsequent IPC messages will be buffered, so 129 // This is not synchronous, but subsequent IPC messages will be buffered, so
136 // it is okay to immediately send IPC messages through the returned channel. 130 // it is okay to immediately send IPC messages through the returned channel.
137 GpuChannelHost* channel = graphics_3d->channel(); 131 GpuChannelHost* channel = graphics_3d->channel();
138 DCHECK(channel); 132 DCHECK(channel);
139 decoder_ = channel->CreateVideoDecoder(command_buffer_route_id); 133 decoder_ = channel->CreateVideoDecoder(command_buffer_route_id);
140 return (decoder_ && decoder_->Initialize(PPToMediaProfile(profile), this)); 134 return (decoder_ && decoder_->Initialize(PPToMediaProfile(profile), this));
141 } 135 }
142 136
137 const PPP_VideoDecoder_Dev* PPB_VideoDecoder_Impl::GetPPP() {
138 if (!ppp_videodecoder_) {
139 PluginModule* plugin_module =
140 HostGlobals::Get()->GetInstance(pp_instance())->module();
141 if (plugin_module) {
142 ppp_videodecoder_ = static_cast<const PPP_VideoDecoder_Dev*>(
143 plugin_module->GetPluginInterface(PPP_VIDEODECODER_DEV_INTERFACE));
144 }
145 }
146 return ppp_videodecoder_;
147 }
148
143 int32_t PPB_VideoDecoder_Impl::Decode( 149 int32_t PPB_VideoDecoder_Impl::Decode(
144 const PP_VideoBitstreamBuffer_Dev* bitstream_buffer, 150 const PP_VideoBitstreamBuffer_Dev* bitstream_buffer,
145 scoped_refptr<TrackedCallback> callback) { 151 scoped_refptr<TrackedCallback> callback) {
146 if (!decoder_) 152 if (!decoder_)
147 return PP_ERROR_BADRESOURCE; 153 return PP_ERROR_BADRESOURCE;
148 154
149 EnterResourceNoLock<PPB_Buffer_API> enter(bitstream_buffer->data, true); 155 EnterResourceNoLock<PPB_Buffer_API> enter(bitstream_buffer->data, true);
150 if (enter.failed()) 156 if (enter.failed())
151 return PP_ERROR_FAILED; 157 return PP_ERROR_FAILED;
152 158
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 ppp_videodecoder_ = NULL; 233 ppp_videodecoder_ = NULL;
228 234
229 ::ppapi::PPB_VideoDecoder_Shared::Destroy(); 235 ::ppapi::PPB_VideoDecoder_Shared::Destroy();
230 } 236 }
231 237
232 void PPB_VideoDecoder_Impl::ProvidePictureBuffers( 238 void PPB_VideoDecoder_Impl::ProvidePictureBuffers(
233 uint32 requested_num_of_buffers, 239 uint32 requested_num_of_buffers,
234 const gfx::Size& dimensions, 240 const gfx::Size& dimensions,
235 uint32 texture_target) { 241 uint32 texture_target) {
236 DCHECK(RenderThreadImpl::current()); 242 DCHECK(RenderThreadImpl::current());
237 if (!ppp_videodecoder_) 243 if (!GetPPP())
238 return; 244 return;
239 245
240 PP_Size out_dim = PP_MakeSize(dimensions.width(), dimensions.height()); 246 PP_Size out_dim = PP_MakeSize(dimensions.width(), dimensions.height());
241 ppp_videodecoder_->ProvidePictureBuffers(pp_instance(), 247 GetPPP()->ProvidePictureBuffers(pp_instance(), pp_resource(),
242 pp_resource(), 248 requested_num_of_buffers, &out_dim,
243 requested_num_of_buffers, 249 texture_target);
244 &out_dim,
245 texture_target);
246 } 250 }
247 251
248 void PPB_VideoDecoder_Impl::PictureReady(const media::Picture& picture) { 252 void PPB_VideoDecoder_Impl::PictureReady(const media::Picture& picture) {
249 // So far picture.visible_rect is not used. If used, visible_rect should 253 // So far picture.visible_rect is not used. If used, visible_rect should
250 // be validated since it comes from GPU process and may not be trustworthy. 254 // be validated since it comes from GPU process and may not be trustworthy.
251 DCHECK(RenderThreadImpl::current()); 255 DCHECK(RenderThreadImpl::current());
252 if (!ppp_videodecoder_) 256 if (!GetPPP())
253 return; 257 return;
254 258
255 PP_Picture_Dev output; 259 PP_Picture_Dev output;
256 output.picture_buffer_id = picture.picture_buffer_id(); 260 output.picture_buffer_id = picture.picture_buffer_id();
257 output.bitstream_buffer_id = picture.bitstream_buffer_id(); 261 output.bitstream_buffer_id = picture.bitstream_buffer_id();
258 ppp_videodecoder_->PictureReady(pp_instance(), pp_resource(), &output); 262 GetPPP()->PictureReady(pp_instance(), pp_resource(), &output);
259 } 263 }
260 264
261 void PPB_VideoDecoder_Impl::DismissPictureBuffer(int32 picture_buffer_id) { 265 void PPB_VideoDecoder_Impl::DismissPictureBuffer(int32 picture_buffer_id) {
262 DCHECK(RenderThreadImpl::current()); 266 DCHECK(RenderThreadImpl::current());
263 if (!ppp_videodecoder_) 267 if (!GetPPP())
264 return; 268 return;
265 ppp_videodecoder_->DismissPictureBuffer( 269 GetPPP()->DismissPictureBuffer(pp_instance(), pp_resource(),
266 pp_instance(), pp_resource(), picture_buffer_id); 270 picture_buffer_id);
267 } 271 }
268 272
269 void PPB_VideoDecoder_Impl::NotifyError( 273 void PPB_VideoDecoder_Impl::NotifyError(
270 media::VideoDecodeAccelerator::Error error) { 274 media::VideoDecodeAccelerator::Error error) {
271 DCHECK(RenderThreadImpl::current()); 275 DCHECK(RenderThreadImpl::current());
272 if (!ppp_videodecoder_) 276 if (!GetPPP())
273 return; 277 return;
274 278
275 PP_VideoDecodeError_Dev pp_error = MediaToPPError(error); 279 PP_VideoDecodeError_Dev pp_error = MediaToPPError(error);
276 ppp_videodecoder_->NotifyError(pp_instance(), pp_resource(), pp_error); 280 GetPPP()->NotifyError(pp_instance(), pp_resource(), pp_error);
277 UMA_HISTOGRAM_ENUMERATION("Media.PepperVideoDecoderError", 281 UMA_HISTOGRAM_ENUMERATION("Media.PepperVideoDecoderError",
278 error, 282 error,
279 media::VideoDecodeAccelerator::LARGEST_ERROR_ENUM); 283 media::VideoDecodeAccelerator::LARGEST_ERROR_ENUM);
280 } 284 }
281 285
282 void PPB_VideoDecoder_Impl::NotifyResetDone() { 286 void PPB_VideoDecoder_Impl::NotifyResetDone() {
283 DCHECK(RenderThreadImpl::current()); 287 DCHECK(RenderThreadImpl::current());
284 RunResetCallback(PP_OK); 288 RunResetCallback(PP_OK);
285 } 289 }
286 290
287 void PPB_VideoDecoder_Impl::NotifyEndOfBitstreamBuffer( 291 void PPB_VideoDecoder_Impl::NotifyEndOfBitstreamBuffer(
288 int32 bitstream_buffer_id) { 292 int32 bitstream_buffer_id) {
289 DCHECK(RenderThreadImpl::current()); 293 DCHECK(RenderThreadImpl::current());
290 RunBitstreamBufferCallback(bitstream_buffer_id, PP_OK); 294 RunBitstreamBufferCallback(bitstream_buffer_id, PP_OK);
291 } 295 }
292 296
293 void PPB_VideoDecoder_Impl::NotifyFlushDone() { 297 void PPB_VideoDecoder_Impl::NotifyFlushDone() {
294 DCHECK(RenderThreadImpl::current()); 298 DCHECK(RenderThreadImpl::current());
295 RunFlushCallback(PP_OK); 299 RunFlushCallback(PP_OK);
296 } 300 }
297 301
298 } // namespace content 302 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/pepper/ppb_video_decoder_impl.h ('k') | ppapi/proxy/host_dispatcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698