| OLD | NEW |
| 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2014 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/pepper_video_decoder_host.h" | 5 #include "content/renderer/pepper/pepper_video_decoder_host.h" |
| 6 | 6 |
| 7 #include <stddef.h> |
| 8 |
| 7 #include "base/bind.h" | 9 #include "base/bind.h" |
| 8 #include "base/memory/shared_memory.h" | 10 #include "base/memory/shared_memory.h" |
| 11 #include "build/build_config.h" |
| 9 #include "content/common/gpu/client/command_buffer_proxy_impl.h" | 12 #include "content/common/gpu/client/command_buffer_proxy_impl.h" |
| 10 #include "content/common/pepper_file_util.h" | 13 #include "content/common/pepper_file_util.h" |
| 11 #include "content/public/common/content_client.h" | 14 #include "content/public/common/content_client.h" |
| 12 #include "content/public/renderer/content_renderer_client.h" | 15 #include "content/public/renderer/content_renderer_client.h" |
| 13 #include "content/public/renderer/render_thread.h" | 16 #include "content/public/renderer/render_thread.h" |
| 14 #include "content/public/renderer/renderer_ppapi_host.h" | 17 #include "content/public/renderer/renderer_ppapi_host.h" |
| 15 #include "content/renderer/pepper/gfx_conversion.h" | 18 #include "content/renderer/pepper/gfx_conversion.h" |
| 16 #include "content/renderer/pepper/ppb_graphics_3d_impl.h" | 19 #include "content/renderer/pepper/ppb_graphics_3d_impl.h" |
| 17 #include "content/renderer/pepper/video_decoder_shim.h" | 20 #include "content/renderer/pepper/video_decoder_shim.h" |
| 18 #include "media/base/limits.h" | 21 #include "media/base/limits.h" |
| (...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 if (flush_reply_context_.is_valid() || reset_reply_context_.is_valid()) | 338 if (flush_reply_context_.is_valid() || reset_reply_context_.is_valid()) |
| 336 return PP_ERROR_FAILED; | 339 return PP_ERROR_FAILED; |
| 337 | 340 |
| 338 reset_reply_context_ = context->MakeReplyMessageContext(); | 341 reset_reply_context_ = context->MakeReplyMessageContext(); |
| 339 decoder_->Reset(); | 342 decoder_->Reset(); |
| 340 | 343 |
| 341 return PP_OK_COMPLETIONPENDING; | 344 return PP_OK_COMPLETIONPENDING; |
| 342 } | 345 } |
| 343 | 346 |
| 344 void PepperVideoDecoderHost::ProvidePictureBuffers( | 347 void PepperVideoDecoderHost::ProvidePictureBuffers( |
| 345 uint32 requested_num_of_buffers, | 348 uint32_t requested_num_of_buffers, |
| 346 const gfx::Size& dimensions, | 349 const gfx::Size& dimensions, |
| 347 uint32 texture_target) { | 350 uint32_t texture_target) { |
| 348 RequestTextures(std::max(min_picture_count_, requested_num_of_buffers), | 351 RequestTextures(std::max(min_picture_count_, requested_num_of_buffers), |
| 349 dimensions, | 352 dimensions, |
| 350 texture_target, | 353 texture_target, |
| 351 std::vector<gpu::Mailbox>()); | 354 std::vector<gpu::Mailbox>()); |
| 352 } | 355 } |
| 353 | 356 |
| 354 void PepperVideoDecoderHost::PictureReady(const media::Picture& picture) { | 357 void PepperVideoDecoderHost::PictureReady(const media::Picture& picture) { |
| 355 PictureBufferMap::iterator it = | 358 PictureBufferMap::iterator it = |
| 356 picture_buffer_map_.find(picture.picture_buffer_id()); | 359 picture_buffer_map_.find(picture.picture_buffer_id()); |
| 357 DCHECK(it != picture_buffer_map_.end()); | 360 DCHECK(it != picture_buffer_map_.end()); |
| 358 DCHECK(it->second == PictureBufferState::ASSIGNED); | 361 DCHECK(it->second == PictureBufferState::ASSIGNED); |
| 359 it->second = PictureBufferState::IN_USE; | 362 it->second = PictureBufferState::IN_USE; |
| 360 | 363 |
| 361 // Don't bother validating the visible rect, since the plugin process is less | 364 // Don't bother validating the visible rect, since the plugin process is less |
| 362 // trusted than the gpu process. | 365 // trusted than the gpu process. |
| 363 PP_Rect visible_rect = PP_FromGfxRect(picture.visible_rect()); | 366 PP_Rect visible_rect = PP_FromGfxRect(picture.visible_rect()); |
| 364 host()->SendUnsolicitedReply(pp_resource(), | 367 host()->SendUnsolicitedReply(pp_resource(), |
| 365 PpapiPluginMsg_VideoDecoder_PictureReady( | 368 PpapiPluginMsg_VideoDecoder_PictureReady( |
| 366 picture.bitstream_buffer_id(), | 369 picture.bitstream_buffer_id(), |
| 367 picture.picture_buffer_id(), visible_rect)); | 370 picture.picture_buffer_id(), visible_rect)); |
| 368 } | 371 } |
| 369 | 372 |
| 370 void PepperVideoDecoderHost::DismissPictureBuffer(int32 picture_buffer_id) { | 373 void PepperVideoDecoderHost::DismissPictureBuffer(int32_t picture_buffer_id) { |
| 371 PictureBufferMap::iterator it = picture_buffer_map_.find(picture_buffer_id); | 374 PictureBufferMap::iterator it = picture_buffer_map_.find(picture_buffer_id); |
| 372 DCHECK(it != picture_buffer_map_.end()); | 375 DCHECK(it != picture_buffer_map_.end()); |
| 373 | 376 |
| 374 // If the texture is still used by the plugin keep it until the plugin | 377 // If the texture is still used by the plugin keep it until the plugin |
| 375 // recycles it. | 378 // recycles it. |
| 376 if (it->second == PictureBufferState::IN_USE) { | 379 if (it->second == PictureBufferState::IN_USE) { |
| 377 it->second = PictureBufferState::DISMISSED; | 380 it->second = PictureBufferState::DISMISSED; |
| 378 return; | 381 return; |
| 379 } | 382 } |
| 380 | 383 |
| 381 DCHECK(it->second == PictureBufferState::ASSIGNED); | 384 DCHECK(it->second == PictureBufferState::ASSIGNED); |
| 382 picture_buffer_map_.erase(it); | 385 picture_buffer_map_.erase(it); |
| 383 host()->SendUnsolicitedReply( | 386 host()->SendUnsolicitedReply( |
| 384 pp_resource(), | 387 pp_resource(), |
| 385 PpapiPluginMsg_VideoDecoder_DismissPicture(picture_buffer_id)); | 388 PpapiPluginMsg_VideoDecoder_DismissPicture(picture_buffer_id)); |
| 386 } | 389 } |
| 387 | 390 |
| 388 void PepperVideoDecoderHost::NotifyEndOfBitstreamBuffer( | 391 void PepperVideoDecoderHost::NotifyEndOfBitstreamBuffer( |
| 389 int32 bitstream_buffer_id) { | 392 int32_t bitstream_buffer_id) { |
| 390 PendingDecodeList::iterator it = GetPendingDecodeById(bitstream_buffer_id); | 393 PendingDecodeList::iterator it = GetPendingDecodeById(bitstream_buffer_id); |
| 391 if (it == pending_decodes_.end()) { | 394 if (it == pending_decodes_.end()) { |
| 392 NOTREACHED(); | 395 NOTREACHED(); |
| 393 return; | 396 return; |
| 394 } | 397 } |
| 395 host()->SendReply(it->reply_context, | 398 host()->SendReply(it->reply_context, |
| 396 PpapiPluginMsg_VideoDecoder_DecodeReply(it->shm_id)); | 399 PpapiPluginMsg_VideoDecoder_DecodeReply(it->shm_id)); |
| 397 shm_buffer_busy_[it->shm_id] = false; | 400 shm_buffer_busy_[it->shm_id] = false; |
| 398 pending_decodes_.erase(it); | 401 pending_decodes_.erase(it); |
| 399 } | 402 } |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 441 } | 444 } |
| 442 | 445 |
| 443 const uint8_t* PepperVideoDecoderHost::DecodeIdToAddress(uint32_t decode_id) { | 446 const uint8_t* PepperVideoDecoderHost::DecodeIdToAddress(uint32_t decode_id) { |
| 444 PendingDecodeList::const_iterator it = GetPendingDecodeById(decode_id); | 447 PendingDecodeList::const_iterator it = GetPendingDecodeById(decode_id); |
| 445 DCHECK(it != pending_decodes_.end()); | 448 DCHECK(it != pending_decodes_.end()); |
| 446 uint32_t shm_id = it->shm_id; | 449 uint32_t shm_id = it->shm_id; |
| 447 return static_cast<uint8_t*>(shm_buffers_[shm_id]->memory()); | 450 return static_cast<uint8_t*>(shm_buffers_[shm_id]->memory()); |
| 448 } | 451 } |
| 449 | 452 |
| 450 void PepperVideoDecoderHost::RequestTextures( | 453 void PepperVideoDecoderHost::RequestTextures( |
| 451 uint32 requested_num_of_buffers, | 454 uint32_t requested_num_of_buffers, |
| 452 const gfx::Size& dimensions, | 455 const gfx::Size& dimensions, |
| 453 uint32 texture_target, | 456 uint32_t texture_target, |
| 454 const std::vector<gpu::Mailbox>& mailboxes) { | 457 const std::vector<gpu::Mailbox>& mailboxes) { |
| 455 host()->SendUnsolicitedReply( | 458 host()->SendUnsolicitedReply( |
| 456 pp_resource(), | 459 pp_resource(), |
| 457 PpapiPluginMsg_VideoDecoder_RequestTextures( | 460 PpapiPluginMsg_VideoDecoder_RequestTextures( |
| 458 requested_num_of_buffers, | 461 requested_num_of_buffers, |
| 459 PP_MakeSize(dimensions.width(), dimensions.height()), | 462 PP_MakeSize(dimensions.width(), dimensions.height()), |
| 460 texture_target, | 463 texture_target, |
| 461 mailboxes)); | 464 mailboxes)); |
| 462 } | 465 } |
| 463 | 466 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 522 | 525 |
| 523 PepperVideoDecoderHost::PendingDecodeList::iterator | 526 PepperVideoDecoderHost::PendingDecodeList::iterator |
| 524 PepperVideoDecoderHost::GetPendingDecodeById(int32_t decode_id) { | 527 PepperVideoDecoderHost::GetPendingDecodeById(int32_t decode_id) { |
| 525 return std::find_if(pending_decodes_.begin(), pending_decodes_.end(), | 528 return std::find_if(pending_decodes_.begin(), pending_decodes_.end(), |
| 526 [decode_id](const PendingDecode& item) { | 529 [decode_id](const PendingDecode& item) { |
| 527 return item.decode_id == decode_id; | 530 return item.decode_id == decode_id; |
| 528 }); | 531 }); |
| 529 } | 532 } |
| 530 | 533 |
| 531 } // namespace content | 534 } // namespace content |
| OLD | NEW |