| 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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 media::BitstreamBuffer decode_buffer(bitstream_buffer->id, | 117 media::BitstreamBuffer decode_buffer(bitstream_buffer->id, |
| 118 buffer->shared_memory()->handle(), | 118 buffer->shared_memory()->handle(), |
| 119 static_cast<size_t>(buffer->size())); | 119 static_cast<size_t>(buffer->size())); |
| 120 CHECK(bitstream_buffer_callbacks_.insert(std::make_pair( | 120 CHECK(bitstream_buffer_callbacks_.insert(std::make_pair( |
| 121 bitstream_buffer->id, callback)).second); | 121 bitstream_buffer->id, callback)).second); |
| 122 | 122 |
| 123 platform_video_decoder_->Decode(decode_buffer); | 123 platform_video_decoder_->Decode(decode_buffer); |
| 124 return PP_OK_COMPLETIONPENDING; | 124 return PP_OK_COMPLETIONPENDING; |
| 125 } | 125 } |
| 126 | 126 |
| 127 void PPB_VideoDecoder_Impl::AssignGLESBuffers( | 127 void PPB_VideoDecoder_Impl::AssignPictureBuffers( |
| 128 uint32_t no_of_buffers, | 128 uint32_t no_of_buffers, |
| 129 const PP_GLESBuffer_Dev* buffers) { | 129 const PP_PictureBuffer_Dev* buffers) { |
| 130 if (!platform_video_decoder_) | 130 if (!platform_video_decoder_) |
| 131 return; | 131 return; |
| 132 | 132 |
| 133 std::vector<media::GLESBuffer> wrapped_buffers; | 133 std::vector<media::PictureBuffer> wrapped_buffers; |
| 134 for (uint32 i = 0; i < no_of_buffers; i++) { | 134 for (uint32 i = 0; i < no_of_buffers; i++) { |
| 135 PP_GLESBuffer_Dev in_buf = buffers[i]; | 135 PP_PictureBuffer_Dev in_buf = buffers[i]; |
| 136 media::GLESBuffer buffer( | 136 media::PictureBuffer buffer( |
| 137 in_buf.info.id, | 137 in_buf.id, |
| 138 gfx::Size(in_buf.info.size.width, in_buf.info.size.height), | 138 gfx::Size(in_buf.size.width, in_buf.size.height), |
| 139 in_buf.texture_id); | 139 in_buf.texture_id); |
| 140 wrapped_buffers.push_back(buffer); | 140 wrapped_buffers.push_back(buffer); |
| 141 } | 141 } |
| 142 platform_video_decoder_->AssignGLESBuffers(wrapped_buffers); | 142 platform_video_decoder_->AssignPictureBuffers(wrapped_buffers); |
| 143 } | 143 } |
| 144 | 144 |
| 145 void PPB_VideoDecoder_Impl::ReusePictureBuffer(int32_t picture_buffer_id) { | 145 void PPB_VideoDecoder_Impl::ReusePictureBuffer(int32_t picture_buffer_id) { |
| 146 if (!platform_video_decoder_) | 146 if (!platform_video_decoder_) |
| 147 return; | 147 return; |
| 148 platform_video_decoder_->ReusePictureBuffer(picture_buffer_id); | 148 platform_video_decoder_->ReusePictureBuffer(picture_buffer_id); |
| 149 } | 149 } |
| 150 | 150 |
| 151 int32_t PPB_VideoDecoder_Impl::Flush(PP_CompletionCallback callback) { | 151 int32_t PPB_VideoDecoder_Impl::Flush(PP_CompletionCallback callback) { |
| 152 if (!platform_video_decoder_) | 152 if (!platform_video_decoder_) |
| (...skipping 19 matching lines...) Expand all Loading... |
| 172 return PP_OK_COMPLETIONPENDING; | 172 return PP_OK_COMPLETIONPENDING; |
| 173 } | 173 } |
| 174 | 174 |
| 175 void PPB_VideoDecoder_Impl::Destroy() { | 175 void PPB_VideoDecoder_Impl::Destroy() { |
| 176 if (!platform_video_decoder_) | 176 if (!platform_video_decoder_) |
| 177 return; | 177 return; |
| 178 platform_video_decoder_->Destroy(); | 178 platform_video_decoder_->Destroy(); |
| 179 } | 179 } |
| 180 | 180 |
| 181 void PPB_VideoDecoder_Impl::ProvidePictureBuffers( | 181 void PPB_VideoDecoder_Impl::ProvidePictureBuffers( |
| 182 uint32 requested_num_of_buffers, | 182 uint32 requested_num_of_buffers, const gfx::Size& dimensions) { |
| 183 const gfx::Size& dimensions, | |
| 184 media::VideoDecodeAccelerator::MemoryType type) { | |
| 185 if (!ppp_videodecoder_) | 183 if (!ppp_videodecoder_) |
| 186 return; | 184 return; |
| 187 | 185 |
| 188 // TODO(vrk): Compiler assert or use switch statement instead of making | |
| 189 // a blind cast. | |
| 190 PP_PictureBufferType_Dev out_type = | |
| 191 static_cast<PP_PictureBufferType_Dev>(type); | |
| 192 PP_Size out_dim = PP_MakeSize(dimensions.width(), dimensions.height()); | 186 PP_Size out_dim = PP_MakeSize(dimensions.width(), dimensions.height()); |
| 193 ppp_videodecoder_->ProvidePictureBuffers( | 187 ppp_videodecoder_->ProvidePictureBuffers( |
| 194 instance()->pp_instance(), requested_num_of_buffers, out_dim, out_type); | 188 instance()->pp_instance(), requested_num_of_buffers, out_dim); |
| 195 } | 189 } |
| 196 | 190 |
| 197 void PPB_VideoDecoder_Impl::PictureReady(const media::Picture& picture) { | 191 void PPB_VideoDecoder_Impl::PictureReady(const media::Picture& picture) { |
| 198 if (!ppp_videodecoder_) | 192 if (!ppp_videodecoder_) |
| 199 return; | 193 return; |
| 200 | 194 |
| 201 PP_Picture_Dev output; | 195 PP_Picture_Dev output; |
| 202 output.picture_buffer_id = picture.picture_buffer_id(); | 196 output.picture_buffer_id = picture.picture_buffer_id(); |
| 203 output.bitstream_buffer_id = picture.bitstream_buffer_id(); | 197 output.bitstream_buffer_id = picture.bitstream_buffer_id(); |
| 204 output.visible_size = PP_MakeSize(picture.visible_size().width(), | |
| 205 picture.visible_size().height()); | |
| 206 output.decoded_size = PP_MakeSize(picture.decoded_size().width(), | |
| 207 picture.decoded_size().height()); | |
| 208 ppp_videodecoder_->PictureReady(instance()->pp_instance(), output); | 198 ppp_videodecoder_->PictureReady(instance()->pp_instance(), output); |
| 209 } | 199 } |
| 210 | 200 |
| 211 void PPB_VideoDecoder_Impl::DismissPictureBuffer(int32 picture_buffer_id) { | 201 void PPB_VideoDecoder_Impl::DismissPictureBuffer(int32 picture_buffer_id) { |
| 212 if (!ppp_videodecoder_) | 202 if (!ppp_videodecoder_) |
| 213 return; | 203 return; |
| 214 | 204 |
| 215 ppp_videodecoder_->DismissPictureBuffer( | 205 ppp_videodecoder_->DismissPictureBuffer( |
| 216 instance()->pp_instance(), picture_buffer_id); | 206 instance()->pp_instance(), picture_buffer_id); |
| 217 } | 207 } |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 | 254 |
| 265 void PPB_VideoDecoder_Impl::NotifyInitializeDone() { | 255 void PPB_VideoDecoder_Impl::NotifyInitializeDone() { |
| 266 if (initialization_callback_.func == NULL) | 256 if (initialization_callback_.func == NULL) |
| 267 return; | 257 return; |
| 268 | 258 |
| 269 PP_RunAndClearCompletionCallback(&initialization_callback_, PP_OK); | 259 PP_RunAndClearCompletionCallback(&initialization_callback_, PP_OK); |
| 270 } | 260 } |
| 271 | 261 |
| 272 } // namespace ppapi | 262 } // namespace ppapi |
| 273 } // namespace webkit | 263 } // namespace webkit |
| OLD | NEW |