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

Side by Side Diff: ppapi/proxy/ppb_video_decoder_proxy.cc

Issue 7779001: Replace the use of an int32* with a proper struct for decoder configuration. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Replaced struct with explicit profile parameter. Created 9 years, 3 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "ppapi/proxy/ppb_video_decoder_proxy.h" 5 #include "ppapi/proxy/ppb_video_decoder_proxy.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "gpu/command_buffer/client/gles2_implementation.h" 8 #include "gpu/command_buffer/client/gles2_implementation.h"
9 #include "ppapi/proxy/enter_proxy.h" 9 #include "ppapi/proxy/enter_proxy.h"
10 #include "ppapi/proxy/plugin_dispatcher.h" 10 #include "ppapi/proxy/plugin_dispatcher.h"
(...skipping 15 matching lines...) Expand all
26 namespace proxy { 26 namespace proxy {
27 27
28 class VideoDecoder : public Resource, public VideoDecoderImpl { 28 class VideoDecoder : public Resource, public VideoDecoderImpl {
29 public: 29 public:
30 // You must call Init() before using this class. 30 // You must call Init() before using this class.
31 explicit VideoDecoder(const HostResource& resource); 31 explicit VideoDecoder(const HostResource& resource);
32 virtual ~VideoDecoder(); 32 virtual ~VideoDecoder();
33 33
34 static VideoDecoder* Create(const HostResource& resource, 34 static VideoDecoder* Create(const HostResource& resource,
35 PP_Resource graphics_context, 35 PP_Resource graphics_context,
36 const PP_VideoConfigElement* config); 36 PP_VideoDecoder_Profile profile);
37 37
38 // Resource overrides. 38 // Resource overrides.
39 virtual PPB_VideoDecoder_API* AsPPB_VideoDecoder_API() OVERRIDE; 39 virtual PPB_VideoDecoder_API* AsPPB_VideoDecoder_API() OVERRIDE;
40 40
41 // PPB_VideoDecoder_API implementation. 41 // PPB_VideoDecoder_API implementation.
42 virtual int32_t Decode(const PP_VideoBitstreamBuffer_Dev* bitstream_buffer, 42 virtual int32_t Decode(const PP_VideoBitstreamBuffer_Dev* bitstream_buffer,
43 PP_CompletionCallback callback) OVERRIDE; 43 PP_CompletionCallback callback) OVERRIDE;
44 virtual void AssignPictureBuffers( 44 virtual void AssignPictureBuffers(
45 uint32_t no_of_buffers, const PP_PictureBuffer_Dev* buffers) OVERRIDE; 45 uint32_t no_of_buffers, const PP_PictureBuffer_Dev* buffers) OVERRIDE;
46 virtual void ReusePictureBuffer(int32_t picture_buffer_id) OVERRIDE; 46 virtual void ReusePictureBuffer(int32_t picture_buffer_id) OVERRIDE;
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 IPC_MESSAGE_HANDLER(PpapiMsg_PPBVideoDecoder_FlushACK, OnMsgFlushACK) 203 IPC_MESSAGE_HANDLER(PpapiMsg_PPBVideoDecoder_FlushACK, OnMsgFlushACK)
204 IPC_MESSAGE_UNHANDLED(handled = false) 204 IPC_MESSAGE_UNHANDLED(handled = false)
205 IPC_END_MESSAGE_MAP() 205 IPC_END_MESSAGE_MAP()
206 DCHECK(handled); 206 DCHECK(handled);
207 return handled; 207 return handled;
208 } 208 }
209 209
210 PP_Resource PPB_VideoDecoder_Proxy::CreateProxyResource( 210 PP_Resource PPB_VideoDecoder_Proxy::CreateProxyResource(
211 PP_Instance instance, 211 PP_Instance instance,
212 PP_Resource graphics_context, 212 PP_Resource graphics_context,
213 const PP_VideoConfigElement* config) { 213 PP_VideoDecoder_Profile profile) {
214 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); 214 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance);
215 // Dispatcher is null if it cannot find the instance passed to it (i.e. if the 215 // Dispatcher is null if it cannot find the instance passed to it (i.e. if the
216 // client passes in an invalid instance). 216 // client passes in an invalid instance).
217 if (!dispatcher) 217 if (!dispatcher)
218 return 0; 218 return 0;
219 219
220 std::vector<PP_VideoConfigElement> copied;
221 if (!VideoDecoderImpl::CopyConfigsToVector(config, &copied))
222 return 0;
223
224 HostResource host_context; 220 HostResource host_context;
225 gpu::gles2::GLES2Implementation* gles2_impl = NULL; 221 gpu::gles2::GLES2Implementation* gles2_impl = NULL;
226 222
227 EnterResourceNoLock<PPB_Context3D_API> enter_context(graphics_context, false); 223 EnterResourceNoLock<PPB_Context3D_API> enter_context(graphics_context, false);
228 if (enter_context.succeeded()) { 224 if (enter_context.succeeded()) {
229 Context3D* context = static_cast<Context3D*>(enter_context.object()); 225 Context3D* context = static_cast<Context3D*>(enter_context.object());
230 host_context = context->host_resource(); 226 host_context = context->host_resource();
231 gles2_impl = context->gles2_impl(); 227 gles2_impl = context->gles2_impl();
232 } else { 228 } else {
233 EnterResourceNoLock<PPB_Graphics3D_API> enter_context(graphics_context, 229 EnterResourceNoLock<PPB_Graphics3D_API> enter_context(graphics_context,
234 true); 230 true);
235 if (enter_context.failed()) 231 if (enter_context.failed())
236 return 0; 232 return 0;
237 Graphics3D* context = static_cast<Graphics3D*>(enter_context.object()); 233 Graphics3D* context = static_cast<Graphics3D*>(enter_context.object());
238 host_context = context->host_resource(); 234 host_context = context->host_resource();
239 gles2_impl = context->gles2_impl(); 235 gles2_impl = context->gles2_impl();
240 } 236 }
241 237
242 HostResource result; 238 HostResource result;
243 dispatcher->Send(new PpapiHostMsg_PPBVideoDecoder_Create( 239 dispatcher->Send(new PpapiHostMsg_PPBVideoDecoder_Create(
244 INTERFACE_ID_PPB_VIDEO_DECODER_DEV, instance, 240 INTERFACE_ID_PPB_VIDEO_DECODER_DEV, instance,
245 host_context, copied, &result)); 241 host_context, profile, &result));
246 if (result.is_null()) 242 if (result.is_null())
247 return 0; 243 return 0;
248 244
249 // Need a scoped_refptr to keep the object alive during the Init call. 245 // Need a scoped_refptr to keep the object alive during the Init call.
250 scoped_refptr<VideoDecoder> decoder(new VideoDecoder(result)); 246 scoped_refptr<VideoDecoder> decoder(new VideoDecoder(result));
251 decoder->InitCommon(graphics_context, gles2_impl); 247 decoder->InitCommon(graphics_context, gles2_impl);
252 return decoder->GetReference(); 248 return decoder->GetReference();
253 } 249 }
254 250
255 void PPB_VideoDecoder_Proxy::OnMsgCreate( 251 void PPB_VideoDecoder_Proxy::OnMsgCreate(
256 PP_Instance instance, const HostResource& graphics_context, 252 PP_Instance instance, const HostResource& graphics_context,
257 const std::vector<PP_VideoConfigElement>& config, 253 PP_VideoDecoder_Profile profile,
258 HostResource* result) { 254 HostResource* result) {
259 thunk::EnterFunction<thunk::ResourceCreationAPI> resource_creation(instance, 255 thunk::EnterFunction<thunk::ResourceCreationAPI> resource_creation(instance,
260 true); 256 true);
261 if (resource_creation.failed()) 257 if (resource_creation.failed())
262 return; 258 return;
263 259
264 std::vector<PP_VideoConfigElement> copied = config;
265 copied.push_back(PP_VIDEOATTR_DICTIONARY_TERMINATOR);
266
267 // Make the resource and get the API pointer to its interface. 260 // Make the resource and get the API pointer to its interface.
268 result->SetHostResource( 261 result->SetHostResource(
269 instance, resource_creation.functions()->CreateVideoDecoder( 262 instance, resource_creation.functions()->CreateVideoDecoder(
270 instance, graphics_context.host_resource(), &copied.front())); 263 instance, graphics_context.host_resource(), profile));
271 } 264 }
272 265
273 void PPB_VideoDecoder_Proxy::OnMsgDecode( 266 void PPB_VideoDecoder_Proxy::OnMsgDecode(
274 const HostResource& decoder, 267 const HostResource& decoder,
275 const HostResource& buffer, int32 id, int32 size) { 268 const HostResource& buffer, int32 id, int32 size) {
276 pp::CompletionCallback callback = callback_factory_.NewRequiredCallback( 269 pp::CompletionCallback callback = callback_factory_.NewRequiredCallback(
277 &PPB_VideoDecoder_Proxy::SendMsgEndOfBitstreamACKToPlugin, decoder, id); 270 &PPB_VideoDecoder_Proxy::SendMsgEndOfBitstreamACKToPlugin, decoder, id);
278 271
279 PP_VideoBitstreamBuffer_Dev bitstream = { id, buffer.host_resource(), size }; 272 PP_VideoBitstreamBuffer_Dev bitstream = { id, buffer.host_resource(), size };
280 ppb_video_decoder_target()->Decode( 273 ppb_video_decoder_target()->Decode(
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 342
350 void PPB_VideoDecoder_Proxy::OnMsgResetACK( 343 void PPB_VideoDecoder_Proxy::OnMsgResetACK(
351 const HostResource& decoder, int32_t result) { 344 const HostResource& decoder, int32_t result) {
352 EnterPluginFromHostResource<PPB_VideoDecoder_API> enter(decoder); 345 EnterPluginFromHostResource<PPB_VideoDecoder_API> enter(decoder);
353 if (enter.succeeded()) 346 if (enter.succeeded())
354 static_cast<VideoDecoder*>(enter.object())->ResetACK(result); 347 static_cast<VideoDecoder*>(enter.object())->ResetACK(result);
355 } 348 }
356 349
357 } // namespace proxy 350 } // namespace proxy
358 } // namespace ppapi 351 } // namespace ppapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698