| 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 "media/video/picture.h" | 10 #include "media/video/picture.h" |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 &Flush, | 134 &Flush, |
| 135 &Abort, | 135 &Abort, |
| 136 }; | 136 }; |
| 137 | 137 |
| 138 // Utility methods to convert data to and from the ppapi C-types and their | 138 // Utility methods to convert data to and from the ppapi C-types and their |
| 139 // C++ media-namespace equivalents. | 139 // C++ media-namespace equivalents. |
| 140 void CopyToPictureDev(const media::Picture& input, PP_Picture_Dev* output) { | 140 void CopyToPictureDev(const media::Picture& input, PP_Picture_Dev* output) { |
| 141 DCHECK(output); | 141 DCHECK(output); |
| 142 output->picture_buffer_id = input.picture_buffer_id(); | 142 output->picture_buffer_id = input.picture_buffer_id(); |
| 143 output->bitstream_buffer_id = input.bitstream_buffer_id(); | 143 output->bitstream_buffer_id = input.bitstream_buffer_id(); |
| 144 output->visible_size = | |
| 145 PP_MakeSize(input.visible_size().width(), input.visible_size().height()); | |
| 146 output->decoded_size = | |
| 147 PP_MakeSize(input.decoded_size().width(), input.decoded_size().height()); | |
| 148 } | 144 } |
| 149 | 145 |
| 150 void CopyToConfigList( | 146 void CopyToConfigList( |
| 151 const PP_VideoConfigElement* configs, std::vector<uint32>* output) { | 147 const PP_VideoConfigElement* configs, std::vector<uint32>* output) { |
| 152 DCHECK(configs); | 148 DCHECK(configs); |
| 153 DCHECK(output); | 149 DCHECK(output); |
| 154 // TODO(vrk): This is assuming PP_VideoAttributeDictionary and | 150 // TODO(vrk): This is assuming PP_VideoAttributeDictionary and |
| 155 // VideoAttributeKey have identical enum values. There is no compiler | 151 // VideoAttributeKey have identical enum values. There is no compiler |
| 156 // assert to guarantee this. We either need to add such asserts or | 152 // assert to guarantee this. We either need to add such asserts or |
| 157 // merge PP_VideoAttributeDictionary and VideoAttributeKey. | 153 // merge PP_VideoAttributeDictionary and VideoAttributeKey. |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 return false; | 295 return false; |
| 300 | 296 |
| 301 // Store the callback to be called when Abort() is done. | 297 // Store the callback to be called when Abort() is done. |
| 302 // TODO(vmr): Check for current flush/abort operations. | 298 // TODO(vmr): Check for current flush/abort operations. |
| 303 abort_callback_ = callback; | 299 abort_callback_ = callback; |
| 304 | 300 |
| 305 return platform_video_decoder_->Abort(); | 301 return platform_video_decoder_->Abort(); |
| 306 } | 302 } |
| 307 | 303 |
| 308 void PPB_VideoDecoder_Impl::ProvidePictureBuffers( | 304 void PPB_VideoDecoder_Impl::ProvidePictureBuffers( |
| 309 uint32 requested_num_of_buffers, | 305 uint32 requested_num_of_buffers, const gfx::Size& dimensions) { |
| 310 const gfx::Size& dimensions, | |
| 311 media::VideoDecodeAccelerator::MemoryType type) { | |
| 312 if (!ppp_videodecoder_) | 306 if (!ppp_videodecoder_) |
| 313 return; | 307 return; |
| 314 | 308 |
| 315 // TODO(vrk): Compiler assert or use switch statement instead of making | |
| 316 // a blind cast. | |
| 317 PP_PictureBufferType_Dev out_type = | |
| 318 static_cast<PP_PictureBufferType_Dev>(type); | |
| 319 PP_Size out_dim = PP_MakeSize(dimensions.width(), dimensions.height()); | 309 PP_Size out_dim = PP_MakeSize(dimensions.width(), dimensions.height()); |
| 320 ScopedResourceId resource(this); | 310 ScopedResourceId resource(this); |
| 321 ppp_videodecoder_->ProvidePictureBuffers( | 311 ppp_videodecoder_->ProvidePictureBuffers( |
| 322 resource.id, requested_num_of_buffers, out_dim, out_type); | 312 resource.id, requested_num_of_buffers, out_dim); |
| 323 } | 313 } |
| 324 | 314 |
| 325 void PPB_VideoDecoder_Impl::PictureReady(const media::Picture& picture) { | 315 void PPB_VideoDecoder_Impl::PictureReady(const media::Picture& picture) { |
| 326 if (!ppp_videodecoder_) | 316 if (!ppp_videodecoder_) |
| 327 return; | 317 return; |
| 328 | 318 |
| 329 ScopedResourceId resource(this); | 319 ScopedResourceId resource(this); |
| 330 PP_Picture_Dev out_pic; | 320 PP_Picture_Dev out_pic; |
| 331 CopyToPictureDev(picture, &out_pic); | 321 CopyToPictureDev(picture, &out_pic); |
| 332 ppp_videodecoder_->PictureReady(resource.id, out_pic); | 322 ppp_videodecoder_->PictureReady(resource.id, out_pic); |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 417 : info_(buffer.info) { | 407 : info_(buffer.info) { |
| 418 scoped_refptr<webkit::ppapi::PPB_Buffer_Impl> pepper_buffer = | 408 scoped_refptr<webkit::ppapi::PPB_Buffer_Impl> pepper_buffer = |
| 419 webkit::ppapi::Resource::GetAs<webkit::ppapi::PPB_Buffer_Impl>( | 409 webkit::ppapi::Resource::GetAs<webkit::ppapi::PPB_Buffer_Impl>( |
| 420 buffer.data); | 410 buffer.data); |
| 421 assert(pepper_buffer->is_mapped()); | 411 assert(pepper_buffer->is_mapped()); |
| 422 data_ = pepper_buffer->mapped_buffer(); | 412 data_ = pepper_buffer->mapped_buffer(); |
| 423 } | 413 } |
| 424 | 414 |
| 425 Picture::Picture(const PP_Picture_Dev& picture) | 415 Picture::Picture(const PP_Picture_Dev& picture) |
| 426 : picture_buffer_id_(picture.picture_buffer_id), | 416 : picture_buffer_id_(picture.picture_buffer_id), |
| 427 bitstream_buffer_id_(picture.bitstream_buffer_id), | 417 bitstream_buffer_id_(picture.bitstream_buffer_id) { |
| 428 visible_size_(picture.visible_size.width, picture.visible_size.height), | |
| 429 decoded_size_(picture.decoded_size.width, picture.decoded_size.height) { | |
| 430 } | 418 } |
| 431 | 419 |
| 432 } // namespace media | 420 } // namespace media |
| OLD | NEW |