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

Side by Side Diff: webkit/plugins/ppapi/ppb_video_decoder_impl.cc

Issue 7474006: PPB_VideoDecoder_Dev::Initialize is now synchronous! (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 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 | 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 "webkit/plugins/ppapi/ppb_video_decoder_impl.h" 5 #include "webkit/plugins/ppapi/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.h" 10 #include "base/message_loop.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 46
47 PPB_VideoDecoder_Impl::~PPB_VideoDecoder_Impl() { 47 PPB_VideoDecoder_Impl::~PPB_VideoDecoder_Impl() {
48 } 48 }
49 49
50 PPB_VideoDecoder_API* PPB_VideoDecoder_Impl::AsPPB_VideoDecoder_API() { 50 PPB_VideoDecoder_API* PPB_VideoDecoder_Impl::AsPPB_VideoDecoder_API() {
51 return this; 51 return this;
52 } 52 }
53 53
54 int32_t PPB_VideoDecoder_Impl::Initialize( 54 int32_t PPB_VideoDecoder_Impl::Initialize(
55 PP_Resource context_id, 55 PP_Resource context_id,
56 const PP_VideoConfigElement* decoder_config, 56 const PP_VideoConfigElement* decoder_config) {
57 PP_CompletionCallback callback) {
58 if (!callback.func)
59 return PP_ERROR_BADARGUMENT;
60
61 if (!instance()) 57 if (!instance())
62 return PP_ERROR_FAILED; 58 return PP_ERROR_FAILED;
63 59
64 EnterResourceNoLock<PPB_Context3D_API> enter(context_id, true); 60 EnterResourceNoLock<PPB_Context3D_API> enter(context_id, true);
65 if (enter.failed()) 61 if (enter.failed())
66 return PP_ERROR_BADRESOURCE; 62 return PP_ERROR_BADRESOURCE;
67 PPB_Context3D_Impl* context3d = 63 PPB_Context3D_Impl* context3d =
68 static_cast<PPB_Context3D_Impl*>(enter.object()); 64 static_cast<PPB_Context3D_Impl*>(enter.object());
69 65
70 context3d_id_ = context_id; 66 context3d_id_ = context_id;
(...skipping 20 matching lines...) Expand all
91 // VideoAttributeKey have identical enum values. There is no compiler 87 // VideoAttributeKey have identical enum values. There is no compiler
92 // assert to guarantee this. We either need to add such asserts or 88 // assert to guarantee this. We either need to add such asserts or
93 // merge PP_VideoAttributeDictionary and VideoAttributeKey. 89 // merge PP_VideoAttributeDictionary and VideoAttributeKey.
94 for (const PP_VideoConfigElement* current = decoder_config; 90 for (const PP_VideoConfigElement* current = decoder_config;
95 *current != PP_VIDEOATTR_DICTIONARY_TERMINATOR; ++current) { 91 *current != PP_VIDEOATTR_DICTIONARY_TERMINATOR; ++current) {
96 copied.push_back(static_cast<uint32>(*current)); 92 copied.push_back(static_cast<uint32>(*current));
97 } 93 }
98 94
99 FlushCommandBuffer(); 95 FlushCommandBuffer();
100 if (platform_video_decoder_->Initialize(copied)) { 96 if (platform_video_decoder_->Initialize(copied)) {
101 initialization_callback_ = callback; 97 return PP_OK;
102 return PP_OK_COMPLETIONPENDING;
103 } else { 98 } else {
104 return PP_ERROR_FAILED; 99 return PP_ERROR_FAILED;
105 } 100 }
106 } 101 }
107 102
108 int32_t PPB_VideoDecoder_Impl::Decode( 103 int32_t PPB_VideoDecoder_Impl::Decode(
109 const PP_VideoBitstreamBuffer_Dev* bitstream_buffer, 104 const PP_VideoBitstreamBuffer_Dev* bitstream_buffer,
110 PP_CompletionCallback callback) { 105 PP_CompletionCallback callback) {
111 if (!platform_video_decoder_) 106 if (!platform_video_decoder_)
112 return PP_ERROR_BADRESOURCE; 107 return PP_ERROR_BADRESOURCE;
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 264
270 void PPB_VideoDecoder_Impl::NotifyFlushDone() { 265 void PPB_VideoDecoder_Impl::NotifyFlushDone() {
271 if (flush_callback_.func == NULL) 266 if (flush_callback_.func == NULL)
272 return; 267 return;
273 268
274 // Call the callback that was stored to be called when Flush is done. 269 // Call the callback that was stored to be called when Flush is done.
275 PP_RunAndClearCompletionCallback(&flush_callback_, PP_OK); 270 PP_RunAndClearCompletionCallback(&flush_callback_, PP_OK);
276 } 271 }
277 272
278 void PPB_VideoDecoder_Impl::NotifyInitializeDone() { 273 void PPB_VideoDecoder_Impl::NotifyInitializeDone() {
279 if (initialization_callback_.func == NULL) 274 NOTREACHED() << "PlatformVideoDecoder::Initialize() is synchronous!";
280 return;
281
282 PP_RunAndClearCompletionCallback(&initialization_callback_, PP_OK);
283 } 275 }
284 276
285 void PPB_VideoDecoder_Impl::FlushCommandBuffer() { 277 void PPB_VideoDecoder_Impl::FlushCommandBuffer() {
286 // For the out-of-process case, |gles2_impl_| will be NULL in the renderer 278 // For the out-of-process case, |gles2_impl_| will be NULL in the renderer
287 // process. The VideoDecoder_Proxy is charged with the responsibility of 279 // process. The VideoDecoder_Proxy is charged with the responsibility of
288 // doing this Flush() in the analogous places in the plugin process. 280 // doing this Flush() in the analogous places in the plugin process.
289 if (gles2_impl_) 281 if (gles2_impl_)
290 gles2_impl_->Flush(); 282 gles2_impl_->Flush();
291 } 283 }
292 284
293 } // namespace ppapi 285 } // namespace ppapi
294 } // namespace webkit 286 } // namespace webkit
OLDNEW
« ppapi/c/dev/ppb_video_decoder_dev.h ('K') | « webkit/plugins/ppapi/ppb_video_decoder_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698