| 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" |
| 11 #include "gpu/command_buffer/client/gles2_implementation.h" |
| 11 #include "media/video/picture.h" | 12 #include "media/video/picture.h" |
| 12 #include "ppapi/c/dev/pp_video_dev.h" | 13 #include "ppapi/c/dev/pp_video_dev.h" |
| 13 #include "ppapi/c/dev/ppb_video_decoder_dev.h" | 14 #include "ppapi/c/dev/ppb_video_decoder_dev.h" |
| 14 #include "ppapi/c/dev/ppp_video_decoder_dev.h" | 15 #include "ppapi/c/dev/ppp_video_decoder_dev.h" |
| 15 #include "ppapi/c/pp_completion_callback.h" | 16 #include "ppapi/c/pp_completion_callback.h" |
| 16 #include "ppapi/c/pp_errors.h" | 17 #include "ppapi/c/pp_errors.h" |
| 17 #include "ppapi/thunk/enter.h" | 18 #include "ppapi/thunk/enter.h" |
| 18 #include "webkit/plugins/ppapi/common.h" | 19 #include "webkit/plugins/ppapi/common.h" |
| 19 #include "webkit/plugins/ppapi/plugin_module.h" | 20 #include "webkit/plugins/ppapi/plugin_module.h" |
| 20 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" | 21 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 PPB_Context3D_Impl* context3d = | 121 PPB_Context3D_Impl* context3d = |
| 121 static_cast<PPB_Context3D_Impl*>(enter.object()); | 122 static_cast<PPB_Context3D_Impl*>(enter.object()); |
| 122 | 123 |
| 123 int command_buffer_route_id = | 124 int command_buffer_route_id = |
| 124 context3d->platform_context()->GetCommandBufferRouteId(); | 125 context3d->platform_context()->GetCommandBufferRouteId(); |
| 125 if (command_buffer_route_id == 0) | 126 if (command_buffer_route_id == 0) |
| 126 return PP_ERROR_FAILED; | 127 return PP_ERROR_FAILED; |
| 127 | 128 |
| 128 platform_video_decoder_.reset( | 129 platform_video_decoder_.reset( |
| 129 instance()->delegate()->CreateVideoDecoder( | 130 instance()->delegate()->CreateVideoDecoder( |
| 130 this, command_buffer_route_id)); | 131 this, command_buffer_route_id, context3d->gles2_impl()->helper())); |
| 131 | 132 |
| 132 if (!platform_video_decoder_.get()) | 133 if (!platform_video_decoder_.get()) |
| 133 return PP_ERROR_FAILED; | 134 return PP_ERROR_FAILED; |
| 134 | 135 |
| 135 std::vector<uint32> copied; | 136 std::vector<uint32> copied; |
| 136 // TODO(vrk): Validate configs before copy. | 137 // TODO(vrk): Validate configs before copy. |
| 137 CopyToConfigList(decoder_config, &copied); | 138 CopyToConfigList(decoder_config, &copied); |
| 138 if (platform_video_decoder_->Initialize(copied)) { | 139 if (platform_video_decoder_->Initialize(copied)) { |
| 139 initialization_callback_ = callback; | 140 initialization_callback_ = callback; |
| 140 return PP_OK_COMPLETIONPENDING; | 141 return PP_OK_COMPLETIONPENDING; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 153 if (enter.failed()) | 154 if (enter.failed()) |
| 154 return PP_ERROR_FAILED; | 155 return PP_ERROR_FAILED; |
| 155 | 156 |
| 156 PPB_Buffer_Impl* buffer = static_cast<PPB_Buffer_Impl*>(enter.object()); | 157 PPB_Buffer_Impl* buffer = static_cast<PPB_Buffer_Impl*>(enter.object()); |
| 157 media::BitstreamBuffer decode_buffer(bitstream_buffer->id, | 158 media::BitstreamBuffer decode_buffer(bitstream_buffer->id, |
| 158 buffer->shared_memory()->handle(), | 159 buffer->shared_memory()->handle(), |
| 159 static_cast<size_t>(buffer->size())); | 160 static_cast<size_t>(buffer->size())); |
| 160 CHECK(bitstream_buffer_callbacks_.insert(std::make_pair( | 161 CHECK(bitstream_buffer_callbacks_.insert(std::make_pair( |
| 161 bitstream_buffer->id, callback)).second); | 162 bitstream_buffer->id, callback)).second); |
| 162 | 163 |
| 163 if (platform_video_decoder_->Decode(decode_buffer)) | 164 platform_video_decoder_->Decode(decode_buffer); |
| 164 return PP_OK_COMPLETIONPENDING; | 165 return PP_OK_COMPLETIONPENDING; |
| 165 else | |
| 166 return PP_ERROR_FAILED; | |
| 167 } | 166 } |
| 168 | 167 |
| 169 void PPB_VideoDecoder_Impl::AssignGLESBuffers( | 168 void PPB_VideoDecoder_Impl::AssignGLESBuffers( |
| 170 uint32_t no_of_buffers, | 169 uint32_t no_of_buffers, |
| 171 const PP_GLESBuffer_Dev* buffers) { | 170 const PP_GLESBuffer_Dev* buffers) { |
| 172 if (!platform_video_decoder_.get()) | 171 if (!platform_video_decoder_.get()) |
| 173 return; | 172 return; |
| 174 | 173 |
| 175 std::vector<media::GLESBuffer> wrapped_buffers; | 174 std::vector<media::GLESBuffer> wrapped_buffers; |
| 176 for (uint32 i = 0; i < no_of_buffers; i++) { | 175 for (uint32 i = 0; i < no_of_buffers; i++) { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 203 } | 202 } |
| 204 | 203 |
| 205 int32_t PPB_VideoDecoder_Impl::Flush(PP_CompletionCallback callback) { | 204 int32_t PPB_VideoDecoder_Impl::Flush(PP_CompletionCallback callback) { |
| 206 if (!platform_video_decoder_.get()) | 205 if (!platform_video_decoder_.get()) |
| 207 return PP_ERROR_BADRESOURCE; | 206 return PP_ERROR_BADRESOURCE; |
| 208 | 207 |
| 209 // Store the callback to be called when Flush() is done. | 208 // Store the callback to be called when Flush() is done. |
| 210 // TODO(vmr): Check for current flush/abort operations. | 209 // TODO(vmr): Check for current flush/abort operations. |
| 211 flush_callback_ = callback; | 210 flush_callback_ = callback; |
| 212 | 211 |
| 213 if (platform_video_decoder_->Flush()) | 212 platform_video_decoder_->Flush(); |
| 214 return PP_OK_COMPLETIONPENDING; | 213 return PP_OK_COMPLETIONPENDING; |
| 215 else | |
| 216 return PP_ERROR_FAILED; | |
| 217 } | 214 } |
| 218 | 215 |
| 219 int32_t PPB_VideoDecoder_Impl::Abort(PP_CompletionCallback callback) { | 216 int32_t PPB_VideoDecoder_Impl::Abort(PP_CompletionCallback callback) { |
| 220 if (!platform_video_decoder_.get()) | 217 if (!platform_video_decoder_.get()) |
| 221 return PP_ERROR_BADRESOURCE; | 218 return PP_ERROR_BADRESOURCE; |
| 222 | 219 |
| 223 // Store the callback to be called when Abort() is done. | 220 // Store the callback to be called when Abort() is done. |
| 224 // TODO(vmr): Check for current flush/abort operations. | 221 // TODO(vmr): Check for current flush/abort operations. |
| 225 abort_callback_ = callback; | 222 abort_callback_ = callback; |
| 226 | 223 |
| 227 if (platform_video_decoder_->Abort()) | 224 platform_video_decoder_->Abort(); |
| 228 return PP_OK_COMPLETIONPENDING; | 225 return PP_OK_COMPLETIONPENDING; |
| 229 else | |
| 230 return PP_ERROR_FAILED; | |
| 231 } | 226 } |
| 232 | 227 |
| 233 void PPB_VideoDecoder_Impl::ProvidePictureBuffers( | 228 void PPB_VideoDecoder_Impl::ProvidePictureBuffers( |
| 234 uint32 requested_num_of_buffers, | 229 uint32 requested_num_of_buffers, |
| 235 const gfx::Size& dimensions, | 230 const gfx::Size& dimensions, |
| 236 media::VideoDecodeAccelerator::MemoryType type) { | 231 media::VideoDecodeAccelerator::MemoryType type) { |
| 237 if (!ppp_videodecoder_) | 232 if (!ppp_videodecoder_) |
| 238 return; | 233 return; |
| 239 | 234 |
| 240 // TODO(vrk): Compiler assert or use switch statement instead of making | 235 // TODO(vrk): Compiler assert or use switch statement instead of making |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 354 } | 349 } |
| 355 | 350 |
| 356 Picture::Picture(const PP_Picture_Dev& picture) | 351 Picture::Picture(const PP_Picture_Dev& picture) |
| 357 : picture_buffer_id_(picture.picture_buffer_id), | 352 : picture_buffer_id_(picture.picture_buffer_id), |
| 358 bitstream_buffer_id_(picture.bitstream_buffer_id), | 353 bitstream_buffer_id_(picture.bitstream_buffer_id), |
| 359 visible_size_(picture.visible_size.width, picture.visible_size.height), | 354 visible_size_(picture.visible_size.width, picture.visible_size.height), |
| 360 decoded_size_(picture.decoded_size.width, picture.decoded_size.height) { | 355 decoded_size_(picture.decoded_size.width, picture.decoded_size.height) { |
| 361 } | 356 } |
| 362 | 357 |
| 363 } // namespace media | 358 } // namespace media |
| OLD | NEW |