Chromium Code Reviews| 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 "ppapi/c/dev/pp_video_dev.h" | 11 #include "ppapi/c/dev/pp_video_dev.h" |
| 11 #include "ppapi/c/dev/ppb_video_decoder_dev.h" | 12 #include "ppapi/c/dev/ppb_video_decoder_dev.h" |
| 13 #include "ppapi/c/dev/ppp_video_decoder_dev.h" | |
| 12 #include "ppapi/c/pp_completion_callback.h" | 14 #include "ppapi/c/pp_completion_callback.h" |
| 13 #include "ppapi/c/pp_errors.h" | 15 #include "ppapi/c/pp_errors.h" |
| 14 #include "webkit/plugins/ppapi/common.h" | 16 #include "webkit/plugins/ppapi/common.h" |
| 17 #include "webkit/plugins/ppapi/plugin_module.h" | |
| 18 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" | |
| 19 #include "webkit/plugins/ppapi/ppb_buffer_impl.h" | |
| 20 #include "webkit/plugins/ppapi/resource_tracker.h" | |
| 15 #include "webkit/plugins/ppapi/var.h" | 21 #include "webkit/plugins/ppapi/var.h" |
| 16 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" | |
| 17 #include "webkit/plugins/ppapi/ppb_file_ref_impl.h" | |
| 18 #include "webkit/plugins/ppapi/resource_tracker.h" | |
| 19 | 22 |
| 20 namespace webkit { | 23 namespace webkit { |
| 21 namespace ppapi { | 24 namespace ppapi { |
| 22 | 25 |
| 23 namespace { | 26 namespace { |
| 24 | 27 |
| 25 PP_Bool GetConfigs(PP_Instance instance_id, | 28 PP_Bool GetConfigs(PP_Instance instance_id, |
| 26 PP_VideoDecoderConfig_Dev* proto_config, | 29 PP_VideoConfigElement* proto_config, |
| 27 PP_VideoDecoderConfig_Dev* matching_configs, | 30 PP_VideoConfigElement* matching_configs, |
| 28 int32_t matching_configs_size, | 31 uint32_t matching_configs_size, |
| 29 int32_t* num_of_matching_configs) { | 32 uint32_t* num_of_matching_configs) { |
| 30 PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id); | 33 PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id); |
| 31 if (!instance) | 34 if (!instance) |
| 32 return PP_FALSE; | 35 return PP_FALSE; |
| 33 | 36 |
| 34 scoped_refptr<PPB_VideoDecoder_Impl> decoder( | 37 scoped_refptr<PPB_VideoDecoder_Impl> decoder( |
| 35 new PPB_VideoDecoder_Impl(instance)); | 38 new PPB_VideoDecoder_Impl(instance)); |
| 36 | 39 |
| 37 return BoolToPPBool(decoder->GetConfigs(proto_config, | 40 return BoolToPPBool(decoder->GetConfigs(proto_config, |
| 38 matching_configs, | 41 matching_configs, |
| 39 matching_configs_size, | 42 matching_configs_size, |
| 40 num_of_matching_configs)); | 43 num_of_matching_configs)); |
| 41 } | 44 } |
| 42 | 45 |
| 43 PP_Resource Create(PP_Instance instance_id, | 46 PP_Resource Create(PP_Instance instance_id, |
| 44 PP_VideoDecoderConfig_Dev* decoder_config) { | 47 PP_VideoConfigElement* decoder_config) { |
| 45 PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id); | 48 PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id); |
| 46 if (!instance) | 49 if (!instance) |
| 47 return 0; | 50 return 0; |
| 48 | 51 |
| 49 scoped_refptr<PPB_VideoDecoder_Impl> decoder( | 52 scoped_refptr<PPB_VideoDecoder_Impl> decoder( |
| 50 new PPB_VideoDecoder_Impl(instance)); | 53 new PPB_VideoDecoder_Impl(instance)); |
| 51 | 54 |
| 52 if (!decoder->Init(const_cast<PP_VideoDecoderConfig_Dev*>(decoder_config))) | 55 if (!decoder->Init(const_cast<PP_VideoConfigElement*>(decoder_config))) |
| 53 return 0; | 56 return 0; |
| 54 | 57 |
| 55 return decoder->GetReference(); | 58 return decoder->GetReference(); |
| 56 } | 59 } |
| 57 | 60 |
| 58 PP_Bool IsVideoDecoder(PP_Resource resource) { | 61 PP_Bool IsVideoDecoder(PP_Resource resource) { |
| 59 return BoolToPPBool(!!Resource::GetAs<PPB_VideoDecoder_Impl>(resource)); | 62 return BoolToPPBool(!!Resource::GetAs<PPB_VideoDecoder_Impl>(resource)); |
| 60 } | 63 } |
| 61 | 64 |
| 62 PP_Bool Decode(PP_Resource decoder_id, | 65 PP_Bool Decode(PP_Resource decoder_id, |
| 63 PP_VideoBitstreamBuffer_Dev* bitstream_buffer, | 66 PP_VideoBitstreamBuffer_Dev* bitstream_buffer, |
| 64 PP_CompletionCallback callback) { | 67 PP_CompletionCallback callback) { |
| 65 scoped_refptr<PPB_VideoDecoder_Impl> decoder( | 68 scoped_refptr<PPB_VideoDecoder_Impl> decoder( |
| 66 Resource::GetAs<PPB_VideoDecoder_Impl>(decoder_id)); | 69 Resource::GetAs<PPB_VideoDecoder_Impl>(decoder_id)); |
| 67 if (!decoder) | 70 if (!decoder) |
| 68 return PP_FALSE; | 71 return PP_FALSE; |
| 69 | 72 |
| 70 return BoolToPPBool(decoder->Decode(bitstream_buffer, callback)); | 73 return BoolToPPBool(decoder->Decode(bitstream_buffer, callback)); |
| 71 } | 74 } |
| 72 | 75 |
| 73 void AssignPictureBuffer(PP_Resource video_decoder, | 76 void AssignGLESBuffers(PP_Resource video_decoder, |
| 74 uint32_t no_of_buffers, | 77 uint32_t no_of_buffers, |
| 75 union PP_PictureData_Dev* picture_buffer) { | 78 struct PP_GLESBuffer_Dev* buffers) { |
|
scherkus (not reviewing)
2011/05/04 00:03:28
did we resolve needing struct keyword or not?
c++
vrk (LEFT CHROMIUM)
2011/05/05 05:57:12
You're right, no struct keyword necessary! Removed
| |
| 76 scoped_refptr<PPB_VideoDecoder_Impl> decoder( | 79 scoped_refptr<PPB_VideoDecoder_Impl> decoder( |
| 77 Resource::GetAs<PPB_VideoDecoder_Impl>(video_decoder)); | 80 Resource::GetAs<PPB_VideoDecoder_Impl>(video_decoder)); |
| 78 if (!decoder) | 81 if (!decoder) |
| 79 return; | 82 return; |
| 80 | 83 |
| 81 decoder->AssignPictureBuffer(no_of_buffers, picture_buffer); | 84 decoder->AssignGLESBuffers(no_of_buffers, buffers); |
| 82 } | 85 } |
| 83 | 86 |
| 84 void ReusePictureBuffer(PP_Resource video_decoder, | 87 void AssignSysmemBuffers(PP_Resource video_decoder, |
| 85 union PP_PictureData_Dev* picture_buffer) { | 88 uint32_t no_of_buffers, |
| 89 struct PP_SysmemBuffer_Dev* buffers) { | |
|
scherkus (not reviewing)
2011/05/04 00:03:28
ditto
vrk (LEFT CHROMIUM)
2011/05/05 05:57:12
Done.
| |
| 86 scoped_refptr<PPB_VideoDecoder_Impl> decoder( | 90 scoped_refptr<PPB_VideoDecoder_Impl> decoder( |
| 87 Resource::GetAs<PPB_VideoDecoder_Impl>(video_decoder)); | 91 Resource::GetAs<PPB_VideoDecoder_Impl>(video_decoder)); |
| 88 if (!decoder) | 92 if (!decoder) |
| 89 return; | 93 return; |
| 90 | 94 |
| 91 decoder->ReusePictureBuffer(picture_buffer); | 95 decoder->AssignSysmemBuffers(no_of_buffers, buffers); |
| 92 } | 96 } |
| 93 | 97 |
| 94 PP_Bool Flush(PP_Resource video_decoder, | 98 void ReusePictureBuffer(PP_Resource video_decoder, int32_t picture_buffer_id) { |
| 95 PP_CompletionCallback callback) { | |
| 96 scoped_refptr<PPB_VideoDecoder_Impl> decoder( | 99 scoped_refptr<PPB_VideoDecoder_Impl> decoder( |
| 97 Resource::GetAs<PPB_VideoDecoder_Impl>(video_decoder)); | 100 Resource::GetAs<PPB_VideoDecoder_Impl>(video_decoder)); |
| 98 if (!decoder) | 101 if (!decoder) |
| 102 return; | |
| 103 | |
| 104 decoder->ReusePictureBuffer(picture_buffer_id); | |
| 105 } | |
| 106 | |
| 107 PP_Bool Flush(PP_Resource video_decoder, PP_CompletionCallback callback) { | |
| 108 scoped_refptr<PPB_VideoDecoder_Impl> decoder( | |
| 109 Resource::GetAs<PPB_VideoDecoder_Impl>(video_decoder)); | |
| 110 if (!decoder) | |
| 99 return PP_FALSE; | 111 return PP_FALSE; |
| 100 | 112 |
| 101 return BoolToPPBool(decoder->Flush(callback)); | 113 return BoolToPPBool(decoder->Flush(callback)); |
| 102 } | 114 } |
| 103 | 115 |
| 104 PP_Bool Abort(PP_Resource video_decoder, | 116 PP_Bool Abort(PP_Resource video_decoder, |
| 105 PP_CompletionCallback callback) { | 117 PP_CompletionCallback callback) { |
| 106 scoped_refptr<PPB_VideoDecoder_Impl> decoder( | 118 scoped_refptr<PPB_VideoDecoder_Impl> decoder( |
| 107 Resource::GetAs<PPB_VideoDecoder_Impl>(video_decoder)); | 119 Resource::GetAs<PPB_VideoDecoder_Impl>(video_decoder)); |
| 108 if (!decoder) | 120 if (!decoder) |
| 109 return PP_FALSE; | 121 return PP_FALSE; |
| 110 | 122 |
| 111 return BoolToPPBool(decoder->Abort(callback)); | 123 return BoolToPPBool(decoder->Abort(callback)); |
| 112 } | 124 } |
| 113 | 125 |
| 114 | 126 |
| 115 const PPB_VideoDecoder_Dev ppb_videodecoder = { | 127 const PPB_VideoDecoder_Dev ppb_videodecoder = { |
| 116 &GetConfigs, | 128 &GetConfigs, |
| 117 &Create, | 129 &Create, |
| 118 &IsVideoDecoder, | 130 &IsVideoDecoder, |
| 119 &Decode, | 131 &Decode, |
| 120 &AssignPictureBuffer, | 132 &AssignGLESBuffers, |
| 133 &AssignSysmemBuffers, | |
| 121 &ReusePictureBuffer, | 134 &ReusePictureBuffer, |
| 122 &Flush, | 135 &Flush, |
| 123 &Abort, | 136 &Abort, |
| 124 }; | 137 }; |
| 125 | 138 |
| 126 } // namespace | 139 } // namespace |
| 127 | 140 |
| 128 PPB_VideoDecoder_Impl::PPB_VideoDecoder_Impl(PluginInstance* instance) | 141 PPB_VideoDecoder_Impl::PPB_VideoDecoder_Impl(PluginInstance* instance) |
| 129 : Resource(instance), | 142 : Resource(instance), |
| 130 callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), | 143 callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), |
| 131 abort_callback_(PP_BlockUntilComplete()), | 144 abort_callback_(PP_BlockUntilComplete()), |
| 132 flush_callback_(PP_BlockUntilComplete()), | 145 flush_callback_(PP_BlockUntilComplete()), |
| 133 bitstream_buffer_callback_(PP_BlockUntilComplete()) { | 146 bitstream_buffer_callback_(PP_BlockUntilComplete()) { |
| 147 ppp_videodecoder_ = | |
| 148 static_cast<const PPP_VideoDecoder_Dev*>(instance->module()-> | |
| 149 GetPluginInterface(PPP_VIDEODECODER_DEV_INTERFACE)); | |
| 134 } | 150 } |
| 135 | 151 |
| 136 PPB_VideoDecoder_Impl::~PPB_VideoDecoder_Impl() { | 152 PPB_VideoDecoder_Impl::~PPB_VideoDecoder_Impl() { |
| 137 } | 153 } |
| 138 | 154 |
| 139 // static | 155 // static |
| 140 const PPB_VideoDecoder_Dev* PPB_VideoDecoder_Impl::GetInterface() { | 156 const PPB_VideoDecoder_Dev* PPB_VideoDecoder_Impl::GetInterface() { |
| 141 return &ppb_videodecoder; | 157 return &ppb_videodecoder; |
| 142 } | 158 } |
| 143 | 159 |
| 144 PPB_VideoDecoder_Impl* PPB_VideoDecoder_Impl::AsPPB_VideoDecoder_Impl() { | 160 PPB_VideoDecoder_Impl* PPB_VideoDecoder_Impl::AsPPB_VideoDecoder_Impl() { |
| 145 return this; | 161 return this; |
| 146 } | 162 } |
| 147 | 163 |
| 148 bool PPB_VideoDecoder_Impl::GetConfigs( | 164 bool PPB_VideoDecoder_Impl::GetConfigs( |
| 149 PP_VideoDecoderConfig_Dev* proto_config, | 165 PP_VideoConfigElement* requested_configs, |
| 150 PP_VideoDecoderConfig_Dev* matching_configs, | 166 PP_VideoConfigElement* matching_configs, |
| 151 int32_t matching_configs_size, | 167 uint32_t matching_configs_size, |
| 152 int32_t* num_of_matching_configs) { | 168 uint32_t* num_of_matching_configs) { |
| 153 if (!instance()) | 169 if (!instance()) |
| 154 return false; | 170 return false; |
| 155 if (!platform_video_decoder_.get()) | 171 if (!platform_video_decoder_.get()) |
| 156 return false; | 172 return false; |
| 173 if (!matching_configs) | |
| 174 return false; | |
| 157 | 175 |
| 158 // TODO(vmr): Implement. | 176 std::vector<uint32> requested; |
| 159 NOTIMPLEMENTED(); | 177 CopyToConfigList(requested_configs, requested); |
| 178 std::vector<uint32> matched; | |
| 179 platform_video_decoder_->GetConfigs(requested, matched); | |
| 160 | 180 |
| 161 return false; | 181 int i; |
| 182 for (i = 0; i < matched.size() && i < matching_configs_size; i++) | |
| 183 matching_configs[i] = matched[i]; | |
| 184 *num_of_matching_configs = i; | |
| 185 | |
| 186 return true; | |
| 162 } | 187 } |
| 163 | 188 |
| 164 bool PPB_VideoDecoder_Impl::Init(PP_VideoDecoderConfig_Dev* decoder_config) { | 189 bool PPB_VideoDecoder_Impl::Init(PP_VideoConfigElement* decoder_config) { |
| 165 if (!instance()) | 190 if (!instance()) |
| 166 return false; | 191 return false; |
| 167 | 192 |
| 168 platform_video_decoder_.reset( | 193 platform_video_decoder_.reset( |
| 169 instance()->delegate()->CreateVideoDecoder(decoder_config)); | 194 instance()->delegate()->CreateVideoDecoder(decoder_config, this)); |
| 170 | 195 |
| 171 return platform_video_decoder_.get()? true : false; | 196 return platform_video_decoder_.get()? true : false; |
| 172 } | 197 } |
| 173 | 198 |
| 174 bool PPB_VideoDecoder_Impl::Decode( | 199 bool PPB_VideoDecoder_Impl::Decode( |
| 175 PP_VideoBitstreamBuffer_Dev* bitstream_buffer, | 200 PP_VideoBitstreamBuffer_Dev* bitstream_buffer, |
| 176 PP_CompletionCallback callback) { | 201 PP_CompletionCallback callback) { |
| 177 if (!platform_video_decoder_.get()) | 202 if (!platform_video_decoder_.get()) |
| 178 return false; | 203 return false; |
| 179 | 204 |
| 180 media::BitstreamBuffer* decode_buffer = NULL; | 205 scoped_refptr<PPB_Buffer_Impl> pepper_buffer = |
| 181 // TODO(vmr): Convert bitstream_buffer to BitstreamBuffer object. | 206 Resource::GetAs<PPB_Buffer_Impl>(bitstream_buffer->bitstream); |
| 182 NOTIMPLEMENTED(); | 207 |
| 208 media::BitstreamBuffer decode_buffer(pepper_buffer->mapped_buffer(), | |
| 209 bitstream_buffer->bitstream_size, | |
| 210 bitstream_buffer->user_handle); | |
| 183 | 211 |
| 184 // Store the callback to inform when bitstream buffer has been processed. | 212 // Store the callback to inform when bitstream buffer has been processed. |
| 185 // TODO(vmr): handle simultaneous decodes + callbacks. | 213 // TODO(vmr): handle simultaneous decodes + callbacks. |
| 186 bitstream_buffer_callback_ = callback; | 214 bitstream_buffer_callback_ = callback; |
| 187 | 215 |
| 188 return platform_video_decoder_->Decode( | 216 return platform_video_decoder_->Decode( |
| 189 decode_buffer, | 217 decode_buffer, |
| 190 callback_factory_.NewCallback( | 218 callback_factory_.NewCallback( |
| 191 &PPB_VideoDecoder_Impl::OnBitstreamBufferProcessed)); | 219 &PPB_VideoDecoder_Impl::OnBitstreamBufferProcessed)); |
| 192 } | 220 } |
| 193 | 221 |
| 194 void PPB_VideoDecoder_Impl::AssignPictureBuffer( | 222 void PPB_VideoDecoder_Impl::AssignGLESBuffers( |
| 195 uint32_t no_of_picture_buffers, | 223 uint32_t no_of_buffers, |
| 196 PP_PictureData_Dev* picture_buffers) { | 224 PP_GLESBuffer_Dev* buffers) { |
| 197 if (!platform_video_decoder_.get()) | 225 if (!platform_video_decoder_.get()) |
| 198 return; | 226 return; |
| 199 | 227 |
| 200 // TODO(vmr): Map PP_PictureData_Dev into PictureBuffer object. | 228 std::vector<media::GLESBuffer> wrapped_buffers; |
| 201 NOTIMPLEMENTED(); | 229 for (uint i = 0; i < no_of_buffers; i++) { |
| 202 | 230 PP_GLESBuffer_Dev in_buf = buffers[i]; |
| 203 media::VideoDecodeAccelerator::PictureBuffer* buffer = NULL; | 231 media::GLESBuffer buffer(in_buf); |
| 204 platform_video_decoder_->ReusePictureBuffer(buffer); | 232 wrapped_buffers.push_back(buffer); |
| 233 } | |
| 234 platform_video_decoder_->AssignGLESBuffers(wrapped_buffers); | |
| 205 } | 235 } |
| 206 | 236 |
| 207 void PPB_VideoDecoder_Impl::ReusePictureBuffer( | 237 void PPB_VideoDecoder_Impl::AssignSysmemBuffers( |
| 208 PP_PictureData_Dev* picture_buffer) { | 238 uint32_t no_of_buffers, |
| 239 PP_SysmemBuffer_Dev* buffers) { | |
| 209 if (!platform_video_decoder_.get()) | 240 if (!platform_video_decoder_.get()) |
| 210 return; | 241 return; |
| 211 | 242 |
| 212 // TODO(vmr): Map PP_PictureData_Dev into PictureBuffer object. | 243 std::vector<media::SysmemBuffer> wrapped_buffers; |
| 213 NOTIMPLEMENTED(); | 244 for (uint i = 0; i < no_of_buffers; i++) { |
| 245 PP_SysmemBuffer_Dev in_buf = buffers[i]; | |
| 246 media::SysmemBuffer buffer(in_buf); | |
| 247 wrapped_buffers.push_back(buffer); | |
| 248 } | |
| 249 platform_video_decoder_->AssignSysmemBuffers(wrapped_buffers); | |
| 250 } | |
| 214 | 251 |
| 215 media::VideoDecodeAccelerator::PictureBuffer* buffer = NULL; | 252 void PPB_VideoDecoder_Impl::ReusePictureBuffer(int32_t picture_buffer_id) { |
| 216 platform_video_decoder_->ReusePictureBuffer(buffer); | 253 if (!platform_video_decoder_.get()) |
| 254 return; | |
| 255 platform_video_decoder_->ReusePictureBuffer(picture_buffer_id); | |
| 217 } | 256 } |
| 218 | 257 |
| 219 bool PPB_VideoDecoder_Impl::Flush(PP_CompletionCallback callback) { | 258 bool PPB_VideoDecoder_Impl::Flush(PP_CompletionCallback callback) { |
| 220 if (!platform_video_decoder_.get()) | 259 if (!platform_video_decoder_.get()) |
| 221 return false; | 260 return false; |
| 222 | 261 |
| 223 // Store the callback to be called when Flush() is done. | 262 // Store the callback to be called when Flush() is done. |
| 224 // TODO(vmr): Check for current flush/abort operations. | 263 // TODO(vmr): Check for current flush/abort operations. |
| 225 flush_callback_ = callback; | 264 flush_callback_ = callback; |
| 226 | 265 |
| 227 return platform_video_decoder_->Flush( | 266 return platform_video_decoder_->Flush( |
| 228 callback_factory_.NewCallback( | 267 callback_factory_.NewCallback( |
| 229 &PPB_VideoDecoder_Impl::OnFlushComplete)); | 268 &PPB_VideoDecoder_Impl::OnFlushComplete)); |
| 230 } | 269 } |
| 231 | 270 |
| 232 bool PPB_VideoDecoder_Impl::Abort(PP_CompletionCallback callback) { | 271 bool PPB_VideoDecoder_Impl::Abort(PP_CompletionCallback callback) { |
| 233 if (!platform_video_decoder_.get()) | 272 if (!platform_video_decoder_.get()) |
| 234 return false; | 273 return false; |
| 235 | 274 |
| 236 // Store the callback to be called when Abort() is done. | 275 // Store the callback to be called when Abort() is done. |
| 237 // TODO(vmr): Check for current flush/abort operations. | 276 // TODO(vmr): Check for current flush/abort operations. |
| 238 abort_callback_ = callback; | 277 abort_callback_ = callback; |
| 239 | 278 |
| 240 return platform_video_decoder_->Abort( | 279 return platform_video_decoder_->Abort( |
| 241 callback_factory_.NewCallback( | 280 callback_factory_.NewCallback( |
| 242 &PPB_VideoDecoder_Impl::OnAbortComplete)); | 281 &PPB_VideoDecoder_Impl::OnAbortComplete)); |
| 243 } | 282 } |
| 244 | 283 |
| 245 void PPB_VideoDecoder_Impl::ProvidePictureBuffers( | 284 void PPB_VideoDecoder_Impl::ProvidePictureBuffers( |
| 246 uint32_t requested_num_of_buffers, | 285 uint32 requested_num_of_buffers, |
| 247 const std::vector<uint32_t>& buffer_properties) { | 286 gfx::Size dimensions, |
| 248 // TODO(vmr): Implement. | 287 media::VideoDecodeAccelerator::MemoryType type) { |
| 249 NOTIMPLEMENTED(); | 288 if (!ppp_videodecoder_) |
| 289 return; | |
| 290 | |
| 291 // TODO(vrk): Compiler assert or use switch statement instead of making | |
| 292 // a blind cast. | |
| 293 PP_PictureBufferType_Dev out_type = | |
| 294 static_cast<PP_PictureBufferType_Dev>(type); | |
| 295 PP_Size out_dim = PP_MakeSize(dimensions.width(), dimensions.height()); | |
| 296 ScopedResourceId resource(this); | |
| 297 ppp_videodecoder_->ProvidePictureBuffers( | |
| 298 resource.id, requested_num_of_buffers, out_dim, out_type); | |
| 250 } | 299 } |
| 251 | 300 |
| 252 void PPB_VideoDecoder_Impl::PictureReady( | 301 void PPB_VideoDecoder_Impl::PictureReady( |
| 253 media::VideoDecodeAccelerator::Picture* picture) { | 302 const media::Picture& picture) { |
| 254 // TODO(vmr): Implement. | 303 if (!ppp_videodecoder_) |
| 255 NOTIMPLEMENTED(); | 304 return; |
| 256 | 305 |
| 257 // Convert the picture. | 306 ScopedResourceId resource(this); |
| 258 // Get plugin's PPP interface function pointers. | 307 PP_Picture_Dev out_pic; |
| 259 // PPP_VideoDecoder* ppp_videodecoder; | 308 CopyToPictureDev(picture, out_pic); |
| 260 // Call ProvidePictureBuffers function pointer and return. | 309 ppp_videodecoder_->PictureReady(resource.id, out_pic); |
| 261 // ppp_videodecoder->PictureReady(resource_decoder, picture, | |
| 262 // pic_buffer_used_again); | |
| 263 } | 310 } |
| 264 | 311 |
| 265 void PPB_VideoDecoder_Impl::DismissPictureBuffer( | 312 void PPB_VideoDecoder_Impl::DismissPictureBuffer(int32 picture_buffer_id) { |
| 266 media::VideoDecodeAccelerator::PictureBuffer* picture_buffer) { | 313 if (!ppp_videodecoder_) |
| 267 // TODO(vmr): Implement. | 314 return; |
| 268 NOTIMPLEMENTED(); | 315 |
| 316 ScopedResourceId resource(this); | |
| 317 ppp_videodecoder_->DismissPictureBuffer(resource.id, picture_buffer_id); | |
| 269 } | 318 } |
| 270 | 319 |
| 271 void PPB_VideoDecoder_Impl::NotifyEndOfStream() { | 320 void PPB_VideoDecoder_Impl::NotifyEndOfStream() { |
| 272 // TODO(vmr): Implement. | 321 if (!ppp_videodecoder_) |
| 273 NOTIMPLEMENTED(); | 322 return; |
| 274 | 323 |
| 275 // Get decoder's resource handle. | 324 ScopedResourceId resource(this); |
| 276 // PP_Resource resource_decoder; | 325 ppp_videodecoder_->EndOfStream(resource.id); |
| 277 // Get plugin's PPP interface function pointers. | |
| 278 // PPP_VideoDecoder* ppp_videodecoder; | |
| 279 // Call EndOfStream function pointer and return. | |
| 280 // ppp_videodecoder->EndOfStream(resource_decoder); | |
| 281 } | 326 } |
| 282 | 327 |
| 283 void PPB_VideoDecoder_Impl::NotifyError( | 328 void PPB_VideoDecoder_Impl::NotifyError( |
| 284 media::VideoDecodeAccelerator::Error error) { | 329 media::VideoDecodeAccelerator::Error error) { |
| 285 // TODO(vmr): Implement. | 330 if (!ppp_videodecoder_) |
| 286 NOTIMPLEMENTED(); | 331 return; |
| 287 | 332 |
| 288 // Get decoder's resource handle. | 333 ScopedResourceId resource(this); |
| 289 // PP_Resource resource_decoder; | 334 // TODO(vrk): This is assuming VideoDecodeAccelerator::Error and |
| 290 // Get plugin's PPP interface function pointers. | 335 // PP_VideoDecodeError_Dev have identical enum values. There is no compiler |
| 291 // PPP_VideoDecoder* ppp_videodecoder; | 336 // assert to guarantee this. We either need to add such asserts or |
| 292 // Call NotifyError function pointer. | 337 // merge these two enums. |
| 293 // ppp_videodecoder->NotifyError(error, error_data, data_size); | 338 ppp_videodecoder_->NotifyError(resource.id, |
| 339 static_cast<PP_VideoDecodeError_Dev>(error)); | |
| 340 } | |
| 341 | |
| 342 bool PPB_VideoDecoder_Impl::CopyToPictureDev( | |
|
Ami GONE FROM CHROMIUM
2011/05/03 23:34:47
IMO this & the next function are better as file-st
vrk (LEFT CHROMIUM)
2011/05/05 05:57:12
Done... well kind of :) I added the functions to t
Ami GONE FROM CHROMIUM
2011/05/05 16:40:53
In media/ code we decided to use static instead of
| |
| 343 const media::Picture& input, PP_Picture_Dev& output) { | |
| 344 output.picture_buffer_id = input.picture_buffer_id(); | |
| 345 output.bitstream_user_handle = input.user_handle(); | |
| 346 output.visible_size = | |
| 347 PP_MakeSize(input.visible_size().width(), input.visible_size().height()); | |
| 348 output.decoded_size = | |
| 349 PP_MakeSize(input.decoded_size().width(), input.decoded_size().height()); | |
| 350 return true; | |
| 351 } | |
| 352 | |
| 353 bool PPB_VideoDecoder_Impl::CopyToConfigList( | |
| 354 const PP_VideoConfigElement* configs, std::vector<uint32>& output) { | |
| 355 // TODO(vrk): This is assuming PP_VideoAttributeDictionary and | |
| 356 // VideoAttributeKey have identical enum values. There is no compiler | |
| 357 // assert to guarantee this. We either need to add such asserts or | |
| 358 // merge PP_VideoAttributeDictionary and VideoAttributeKey. | |
| 359 const PP_VideoConfigElement* current = configs; | |
| 360 while (*current != PP_VIDEOATTR_DICTIONARY_TERMINATOR) { | |
| 361 output.push_back(static_cast<uint32>(*configs)); | |
| 362 current++; | |
| 363 } | |
| 364 return true; | |
| 294 } | 365 } |
| 295 | 366 |
| 296 void PPB_VideoDecoder_Impl::OnAbortComplete() { | 367 void PPB_VideoDecoder_Impl::OnAbortComplete() { |
| 297 if (abort_callback_.func == NULL) | 368 if (abort_callback_.func == NULL) |
| 298 return; | 369 return; |
| 299 | 370 |
| 300 // Call the callback that was stored to be called when Abort is done. | 371 // Call the callback that was stored to be called when Abort is done. |
| 301 PP_CompletionCallback callback = PP_BlockUntilComplete(); | 372 PP_CompletionCallback callback = PP_BlockUntilComplete(); |
| 302 std::swap(callback, abort_callback_); | 373 std::swap(callback, abort_callback_); |
| 303 PP_RunCompletionCallback(&callback, PP_OK); | 374 PP_RunCompletionCallback(&callback, PP_OK); |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 319 return; | 390 return; |
| 320 | 391 |
| 321 // Call the callback that was stored to be called when Flush is done. | 392 // Call the callback that was stored to be called when Flush is done. |
| 322 PP_CompletionCallback callback = PP_BlockUntilComplete(); | 393 PP_CompletionCallback callback = PP_BlockUntilComplete(); |
| 323 std::swap(callback, flush_callback_); | 394 std::swap(callback, flush_callback_); |
| 324 PP_RunCompletionCallback(&callback, PP_OK); | 395 PP_RunCompletionCallback(&callback, PP_OK); |
| 325 } | 396 } |
| 326 | 397 |
| 327 } // namespace ppapi | 398 } // namespace ppapi |
| 328 } // namespace webkit | 399 } // namespace webkit |
| 400 | |
| 401 // These functions are declared in picture.h but are defined here because of | |
| 402 // dependencies (we can't depend on ppapi types from media). | |
| 403 namespace media { | |
| 404 BufferInfo::BufferInfo(const PP_BufferInfo_Dev& info) | |
| 405 : id_(info.id) { | |
|
scherkus (not reviewing)
2011/05/04 00:03:28
indent two more spaces
vrk (LEFT CHROMIUM)
2011/05/05 05:57:12
Done.
| |
| 406 size_ = gfx::Size(info.size.width, info.size.height); | |
| 407 } | |
| 408 | |
| 409 // TODO(vrk): This assigns the PP_Resource context to be | |
| 410 // the context_id. Not sure what it's actually supposed to be. | |
| 411 GLESBuffer::GLESBuffer(const PP_GLESBuffer_Dev& buffer) | |
| 412 : texture_id_(buffer.texture_id), | |
|
scherkus (not reviewing)
2011/05/04 00:03:28
indent two more spaces
vrk (LEFT CHROMIUM)
2011/05/05 05:57:12
Done.
| |
| 413 context_id_(buffer.context), | |
| 414 info_(buffer.info) { | |
| 415 } | |
| 416 | |
| 417 SysmemBuffer::SysmemBuffer(const PP_SysmemBuffer_Dev& buffer) | |
| 418 : info_(buffer.info) { | |
|
scherkus (not reviewing)
2011/05/04 00:03:28
indent two more spaces
vrk (LEFT CHROMIUM)
2011/05/05 05:57:12
Done.
| |
| 419 scoped_refptr<webkit::ppapi::PPB_Buffer_Impl> pepper_buffer = | |
| 420 webkit::ppapi::Resource::GetAs<webkit::ppapi::PPB_Buffer_Impl>( | |
| 421 buffer.data); | |
| 422 assert(pepper_buffer->is_mapped()); | |
| 423 data_ = static_cast<void*>(pepper_buffer->mapped_buffer()); | |
|
Ami GONE FROM CHROMIUM
2011/05/03 23:34:47
Is the cast necessary?
vrk (LEFT CHROMIUM)
2011/05/05 05:57:12
Nope! removed.
| |
| 424 } | |
| 425 | |
| 426 Picture::Picture(const PP_Picture_Dev& picture) | |
| 427 : picture_buffer_id_(picture.picture_buffer_id), | |
|
scherkus (not reviewing)
2011/05/04 00:03:28
indent two more spaces
vrk (LEFT CHROMIUM)
2011/05/05 05:57:12
Done.
| |
| 428 user_handle_(picture.bitstream_user_handle) { | |
| 429 visible_size_ = | |
|
Ami GONE FROM CHROMIUM
2011/05/03 23:34:47
You can avoid the newlines and use initializers in
vrk (LEFT CHROMIUM)
2011/05/05 05:57:12
Changed to use initializers, but not quite in the
| |
| 430 gfx::Size(picture.visible_size.width, picture.visible_size.height); | |
| 431 decoded_size_ = | |
| 432 gfx::Size(picture.decoded_size.width, picture.decoded_size.height); | |
| 433 } | |
| 434 | |
| 435 } // namespace media | |
| OLD | NEW |