| OLD | NEW |
| 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 current++; | 56 current++; |
| 57 } | 57 } |
| 58 } | 58 } |
| 59 | 59 |
| 60 } // namespace | 60 } // namespace |
| 61 | 61 |
| 62 PPB_VideoDecoder_Impl::PPB_VideoDecoder_Impl(PluginInstance* instance) | 62 PPB_VideoDecoder_Impl::PPB_VideoDecoder_Impl(PluginInstance* instance) |
| 63 : Resource(instance), | 63 : Resource(instance), |
| 64 callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), | 64 callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), |
| 65 abort_callback_(PP_BlockUntilComplete()), | 65 abort_callback_(PP_BlockUntilComplete()), |
| 66 flush_callback_(PP_BlockUntilComplete()), | 66 flush_callback_(PP_BlockUntilComplete()) { |
| 67 bitstream_buffer_callback_(PP_BlockUntilComplete()) { | |
| 68 ppp_videodecoder_ = | 67 ppp_videodecoder_ = |
| 69 static_cast<const PPP_VideoDecoder_Dev*>(instance->module()-> | 68 static_cast<const PPP_VideoDecoder_Dev*>(instance->module()-> |
| 70 GetPluginInterface(PPP_VIDEODECODER_DEV_INTERFACE)); | 69 GetPluginInterface(PPP_VIDEODECODER_DEV_INTERFACE)); |
| 71 } | 70 } |
| 72 | 71 |
| 73 PPB_VideoDecoder_Impl::~PPB_VideoDecoder_Impl() { | 72 PPB_VideoDecoder_Impl::~PPB_VideoDecoder_Impl() { |
| 74 } | 73 } |
| 75 | 74 |
| 76 // static | 75 // static |
| 77 PP_Resource PPB_VideoDecoder_Impl::Create(PP_Instance pp_instance) { | 76 PP_Resource PPB_VideoDecoder_Impl::Create(PP_Instance pp_instance) { |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 | 158 |
| 160 ::ppapi::thunk::EnterResourceNoLock< ::ppapi::thunk::PPB_Buffer_API> | 159 ::ppapi::thunk::EnterResourceNoLock< ::ppapi::thunk::PPB_Buffer_API> |
| 161 enter(bitstream_buffer->data, true); | 160 enter(bitstream_buffer->data, true); |
| 162 if (enter.failed()) | 161 if (enter.failed()) |
| 163 return PP_ERROR_FAILED; | 162 return PP_ERROR_FAILED; |
| 164 | 163 |
| 165 PPB_Buffer_Impl* buffer = static_cast<PPB_Buffer_Impl*>(enter.object()); | 164 PPB_Buffer_Impl* buffer = static_cast<PPB_Buffer_Impl*>(enter.object()); |
| 166 media::BitstreamBuffer decode_buffer(bitstream_buffer->id, | 165 media::BitstreamBuffer decode_buffer(bitstream_buffer->id, |
| 167 buffer->shared_memory()->handle(), | 166 buffer->shared_memory()->handle(), |
| 168 static_cast<size_t>(buffer->size())); | 167 static_cast<size_t>(buffer->size())); |
| 169 | 168 CHECK(bitstream_buffer_callbacks_.insert(std::make_pair( |
| 170 // Store the callback to inform when bitstream buffer has been processed. | 169 bitstream_buffer->id, callback)).second); |
| 171 // TODO(vmr): handle simultaneous decodes + callbacks. | |
| 172 bitstream_buffer_callback_ = callback; | |
| 173 | 170 |
| 174 if (platform_video_decoder_->Decode(decode_buffer)) | 171 if (platform_video_decoder_->Decode(decode_buffer)) |
| 175 return PP_OK_COMPLETIONPENDING; | 172 return PP_OK_COMPLETIONPENDING; |
| 176 else | 173 else |
| 177 return PP_ERROR_FAILED; | 174 return PP_ERROR_FAILED; |
| 178 } | 175 } |
| 179 | 176 |
| 180 void PPB_VideoDecoder_Impl::AssignGLESBuffers( | 177 void PPB_VideoDecoder_Impl::AssignGLESBuffers( |
| 181 uint32_t no_of_buffers, | 178 uint32_t no_of_buffers, |
| 182 const PP_GLESBuffer_Dev* buffers) { | 179 const PP_GLESBuffer_Dev* buffers) { |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 void PPB_VideoDecoder_Impl::NotifyAbortDone() { | 301 void PPB_VideoDecoder_Impl::NotifyAbortDone() { |
| 305 if (abort_callback_.func == NULL) | 302 if (abort_callback_.func == NULL) |
| 306 return; | 303 return; |
| 307 | 304 |
| 308 // Call the callback that was stored to be called when Abort is done. | 305 // Call the callback that was stored to be called when Abort is done. |
| 309 PP_RunAndClearCompletionCallback(&abort_callback_, PP_OK); | 306 PP_RunAndClearCompletionCallback(&abort_callback_, PP_OK); |
| 310 } | 307 } |
| 311 | 308 |
| 312 void PPB_VideoDecoder_Impl::NotifyEndOfBitstreamBuffer( | 309 void PPB_VideoDecoder_Impl::NotifyEndOfBitstreamBuffer( |
| 313 int32 bitstream_buffer_id) { | 310 int32 bitstream_buffer_id) { |
| 314 if (bitstream_buffer_callback_.func == NULL) | 311 CallbackById::iterator it = |
| 315 return; | 312 bitstream_buffer_callbacks_.find(bitstream_buffer_id); |
| 316 | 313 DCHECK(it != bitstream_buffer_callbacks_.end()); |
| 317 // Call the callback that was stored to be called when bitstream was sent for | 314 PP_CompletionCallback cc = it->second; |
| 318 // decoding. | 315 bitstream_buffer_callbacks_.erase(it); |
| 319 PP_RunAndClearCompletionCallback(&bitstream_buffer_callback_, PP_OK); | 316 PP_RunCompletionCallback(&cc, PP_OK); |
| 320 } | 317 } |
| 321 | 318 |
| 322 void PPB_VideoDecoder_Impl::NotifyFlushDone() { | 319 void PPB_VideoDecoder_Impl::NotifyFlushDone() { |
| 323 if (flush_callback_.func == NULL) | 320 if (flush_callback_.func == NULL) |
| 324 return; | 321 return; |
| 325 | 322 |
| 326 // Call the callback that was stored to be called when Flush is done. | 323 // Call the callback that was stored to be called when Flush is done. |
| 327 PP_RunAndClearCompletionCallback(&flush_callback_, PP_OK); | 324 PP_RunAndClearCompletionCallback(&flush_callback_, PP_OK); |
| 328 } | 325 } |
| 329 | 326 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 } | 359 } |
| 363 | 360 |
| 364 Picture::Picture(const PP_Picture_Dev& picture) | 361 Picture::Picture(const PP_Picture_Dev& picture) |
| 365 : picture_buffer_id_(picture.picture_buffer_id), | 362 : picture_buffer_id_(picture.picture_buffer_id), |
| 366 bitstream_buffer_id_(picture.bitstream_buffer_id), | 363 bitstream_buffer_id_(picture.bitstream_buffer_id), |
| 367 visible_size_(picture.visible_size.width, picture.visible_size.height), | 364 visible_size_(picture.visible_size.width, picture.visible_size.height), |
| 368 decoded_size_(picture.decoded_size.width, picture.decoded_size.height) { | 365 decoded_size_(picture.decoded_size.width, picture.decoded_size.height) { |
| 369 } | 366 } |
| 370 | 367 |
| 371 } // namespace media | 368 } // namespace media |
| OLD | NEW |