| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/renderer/pepper/ppb_video_decoder_impl.h" | 5 #include "content/renderer/pepper/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/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 | 169 |
| 170 void PPB_VideoDecoder_Impl::AssignPictureBuffers( | 170 void PPB_VideoDecoder_Impl::AssignPictureBuffers( |
| 171 uint32_t no_of_buffers, | 171 uint32_t no_of_buffers, |
| 172 const PP_PictureBuffer_Dev* buffers) { | 172 const PP_PictureBuffer_Dev* buffers) { |
| 173 if (!decoder_) | 173 if (!decoder_) |
| 174 return; | 174 return; |
| 175 UMA_HISTOGRAM_COUNTS_100("Media.PepperVideoDecoderPictureCount", | 175 UMA_HISTOGRAM_COUNTS_100("Media.PepperVideoDecoderPictureCount", |
| 176 no_of_buffers); | 176 no_of_buffers); |
| 177 | 177 |
| 178 std::vector<media::PictureBuffer> wrapped_buffers; | 178 std::vector<media::PictureBuffer> wrapped_buffers; |
| 179 for (uint32 i = 0; i < no_of_buffers; i++) { | 179 for (uint32_t i = 0; i < no_of_buffers; i++) { |
| 180 PP_PictureBuffer_Dev in_buf = buffers[i]; | 180 PP_PictureBuffer_Dev in_buf = buffers[i]; |
| 181 DCHECK_GE(in_buf.id, 0); | 181 DCHECK_GE(in_buf.id, 0); |
| 182 media::PictureBuffer buffer( | 182 media::PictureBuffer buffer( |
| 183 in_buf.id, | 183 in_buf.id, |
| 184 gfx::Size(in_buf.size.width, in_buf.size.height), | 184 gfx::Size(in_buf.size.width, in_buf.size.height), |
| 185 in_buf.texture_id); | 185 in_buf.texture_id); |
| 186 wrapped_buffers.push_back(buffer); | 186 wrapped_buffers.push_back(buffer); |
| 187 UMA_HISTOGRAM_COUNTS_10000("Media.PepperVideoDecoderPictureHeight", | 187 UMA_HISTOGRAM_COUNTS_10000("Media.PepperVideoDecoderPictureHeight", |
| 188 in_buf.size.height); | 188 in_buf.size.height); |
| 189 } | 189 } |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 void PPB_VideoDecoder_Impl::Destroy() { | 227 void PPB_VideoDecoder_Impl::Destroy() { |
| 228 FlushCommandBuffer(); | 228 FlushCommandBuffer(); |
| 229 | 229 |
| 230 decoder_.reset(); | 230 decoder_.reset(); |
| 231 ppp_videodecoder_ = NULL; | 231 ppp_videodecoder_ = NULL; |
| 232 | 232 |
| 233 ::ppapi::PPB_VideoDecoder_Shared::Destroy(); | 233 ::ppapi::PPB_VideoDecoder_Shared::Destroy(); |
| 234 } | 234 } |
| 235 | 235 |
| 236 void PPB_VideoDecoder_Impl::ProvidePictureBuffers( | 236 void PPB_VideoDecoder_Impl::ProvidePictureBuffers( |
| 237 uint32 requested_num_of_buffers, | 237 uint32_t requested_num_of_buffers, |
| 238 const gfx::Size& dimensions, | 238 const gfx::Size& dimensions, |
| 239 uint32 texture_target) { | 239 uint32_t texture_target) { |
| 240 DCHECK(RenderThreadImpl::current()); | 240 DCHECK(RenderThreadImpl::current()); |
| 241 if (!GetPPP()) | 241 if (!GetPPP()) |
| 242 return; | 242 return; |
| 243 | 243 |
| 244 PP_Size out_dim = PP_MakeSize(dimensions.width(), dimensions.height()); | 244 PP_Size out_dim = PP_MakeSize(dimensions.width(), dimensions.height()); |
| 245 GetPPP()->ProvidePictureBuffers(pp_instance(), pp_resource(), | 245 GetPPP()->ProvidePictureBuffers(pp_instance(), pp_resource(), |
| 246 requested_num_of_buffers, &out_dim, | 246 requested_num_of_buffers, &out_dim, |
| 247 texture_target); | 247 texture_target); |
| 248 } | 248 } |
| 249 | 249 |
| 250 void PPB_VideoDecoder_Impl::PictureReady(const media::Picture& picture) { | 250 void PPB_VideoDecoder_Impl::PictureReady(const media::Picture& picture) { |
| 251 // So far picture.visible_rect is not used. If used, visible_rect should | 251 // So far picture.visible_rect is not used. If used, visible_rect should |
| 252 // be validated since it comes from GPU process and may not be trustworthy. | 252 // be validated since it comes from GPU process and may not be trustworthy. |
| 253 DCHECK(RenderThreadImpl::current()); | 253 DCHECK(RenderThreadImpl::current()); |
| 254 if (!GetPPP()) | 254 if (!GetPPP()) |
| 255 return; | 255 return; |
| 256 | 256 |
| 257 PP_Picture_Dev output; | 257 PP_Picture_Dev output; |
| 258 output.picture_buffer_id = picture.picture_buffer_id(); | 258 output.picture_buffer_id = picture.picture_buffer_id(); |
| 259 output.bitstream_buffer_id = picture.bitstream_buffer_id(); | 259 output.bitstream_buffer_id = picture.bitstream_buffer_id(); |
| 260 GetPPP()->PictureReady(pp_instance(), pp_resource(), &output); | 260 GetPPP()->PictureReady(pp_instance(), pp_resource(), &output); |
| 261 } | 261 } |
| 262 | 262 |
| 263 void PPB_VideoDecoder_Impl::DismissPictureBuffer(int32 picture_buffer_id) { | 263 void PPB_VideoDecoder_Impl::DismissPictureBuffer(int32_t picture_buffer_id) { |
| 264 DCHECK(RenderThreadImpl::current()); | 264 DCHECK(RenderThreadImpl::current()); |
| 265 if (!GetPPP()) | 265 if (!GetPPP()) |
| 266 return; | 266 return; |
| 267 GetPPP()->DismissPictureBuffer(pp_instance(), pp_resource(), | 267 GetPPP()->DismissPictureBuffer(pp_instance(), pp_resource(), |
| 268 picture_buffer_id); | 268 picture_buffer_id); |
| 269 } | 269 } |
| 270 | 270 |
| 271 void PPB_VideoDecoder_Impl::NotifyError( | 271 void PPB_VideoDecoder_Impl::NotifyError( |
| 272 media::VideoDecodeAccelerator::Error error) { | 272 media::VideoDecodeAccelerator::Error error) { |
| 273 DCHECK(RenderThreadImpl::current()); | 273 DCHECK(RenderThreadImpl::current()); |
| 274 if (!GetPPP()) | 274 if (!GetPPP()) |
| 275 return; | 275 return; |
| 276 | 276 |
| 277 PP_VideoDecodeError_Dev pp_error = MediaToPPError(error); | 277 PP_VideoDecodeError_Dev pp_error = MediaToPPError(error); |
| 278 GetPPP()->NotifyError(pp_instance(), pp_resource(), pp_error); | 278 GetPPP()->NotifyError(pp_instance(), pp_resource(), pp_error); |
| 279 UMA_HISTOGRAM_ENUMERATION("Media.PepperVideoDecoderError", | 279 UMA_HISTOGRAM_ENUMERATION("Media.PepperVideoDecoderError", |
| 280 error, | 280 error, |
| 281 media::VideoDecodeAccelerator::LARGEST_ERROR_ENUM); | 281 media::VideoDecodeAccelerator::LARGEST_ERROR_ENUM); |
| 282 } | 282 } |
| 283 | 283 |
| 284 void PPB_VideoDecoder_Impl::NotifyResetDone() { | 284 void PPB_VideoDecoder_Impl::NotifyResetDone() { |
| 285 DCHECK(RenderThreadImpl::current()); | 285 DCHECK(RenderThreadImpl::current()); |
| 286 RunResetCallback(PP_OK); | 286 RunResetCallback(PP_OK); |
| 287 } | 287 } |
| 288 | 288 |
| 289 void PPB_VideoDecoder_Impl::NotifyEndOfBitstreamBuffer( | 289 void PPB_VideoDecoder_Impl::NotifyEndOfBitstreamBuffer( |
| 290 int32 bitstream_buffer_id) { | 290 int32_t bitstream_buffer_id) { |
| 291 DCHECK(RenderThreadImpl::current()); | 291 DCHECK(RenderThreadImpl::current()); |
| 292 RunBitstreamBufferCallback(bitstream_buffer_id, PP_OK); | 292 RunBitstreamBufferCallback(bitstream_buffer_id, PP_OK); |
| 293 } | 293 } |
| 294 | 294 |
| 295 void PPB_VideoDecoder_Impl::NotifyFlushDone() { | 295 void PPB_VideoDecoder_Impl::NotifyFlushDone() { |
| 296 DCHECK(RenderThreadImpl::current()); | 296 DCHECK(RenderThreadImpl::current()); |
| 297 RunFlushCallback(PP_OK); | 297 RunFlushCallback(PP_OK); |
| 298 } | 298 } |
| 299 | 299 |
| 300 } // namespace content | 300 } // namespace content |
| OLD | NEW |