OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/media/rtc_video_decoder.h" | 5 #include "content/renderer/media/rtc_video_decoder.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/message_loop/message_loop_proxy.h" | 10 #include "base/message_loop/message_loop_proxy.h" |
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
438 scoped_refptr<media::VideoFrame> RTCVideoDecoder::CreateVideoFrame( | 438 scoped_refptr<media::VideoFrame> RTCVideoDecoder::CreateVideoFrame( |
439 const media::Picture& picture, | 439 const media::Picture& picture, |
440 const media::PictureBuffer& pb, | 440 const media::PictureBuffer& pb, |
441 uint32_t timestamp) { | 441 uint32_t timestamp) { |
442 gfx::Rect visible_rect(picture.visible_rect()); | 442 gfx::Rect visible_rect(picture.visible_rect()); |
443 DCHECK(decoder_texture_target_); | 443 DCHECK(decoder_texture_target_); |
444 // Convert timestamp from 90KHz to ms. | 444 // Convert timestamp from 90KHz to ms. |
445 base::TimeDelta timestamp_ms = base::TimeDelta::FromInternalValue( | 445 base::TimeDelta timestamp_ms = base::TimeDelta::FromInternalValue( |
446 base::checked_cast<uint64_t>(timestamp) * 1000 / 90); | 446 base::checked_cast<uint64_t>(timestamp) * 1000 / 90); |
447 return media::VideoFrame::WrapNativeTexture( | 447 return media::VideoFrame::WrapNativeTexture( |
448 make_scoped_ptr(new gpu::MailboxHolder( | 448 make_scoped_ptr(new gpu::MailboxHolder(pb.texture_mailbox(), |
449 pb.texture_mailbox(), decoder_texture_target_, 0)), | 449 decoder_texture_target_, 0)), |
450 media::BindToCurrentLoop(base::Bind(&RTCVideoDecoder::ReleaseMailbox, | 450 media::BindToCurrentLoop(base::Bind( |
451 weak_factory_.GetWeakPtr(), | 451 &RTCVideoDecoder::ReleaseMailbox, weak_factory_.GetWeakPtr(), |
452 factories_, | 452 factories_, picture.picture_buffer_id(), pb.texture_id())), |
453 picture.picture_buffer_id(), | 453 pb.size(), visible_rect, visible_rect.size(), timestamp_ms, |
454 pb.texture_id())), | 454 base::Bind(&ReadPixelsSync, factories_, pb.texture_id(), visible_rect), |
455 pb.size(), | 455 picture.allow_overlay()); |
456 visible_rect, | |
457 visible_rect.size(), | |
458 timestamp_ms, | |
459 base::Bind(&ReadPixelsSync, factories_, pb.texture_id(), visible_rect)); | |
460 } | 456 } |
461 | 457 |
462 void RTCVideoDecoder::NotifyEndOfBitstreamBuffer(int32 id) { | 458 void RTCVideoDecoder::NotifyEndOfBitstreamBuffer(int32 id) { |
463 DVLOG(3) << "NotifyEndOfBitstreamBuffer. id=" << id; | 459 DVLOG(3) << "NotifyEndOfBitstreamBuffer. id=" << id; |
464 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent(); | 460 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent(); |
465 | 461 |
466 std::map<int32, SHMBuffer*>::iterator it = | 462 std::map<int32, SHMBuffer*>::iterator it = |
467 bitstream_buffers_in_decoder_.find(id); | 463 bitstream_buffers_in_decoder_.find(id); |
468 if (it == bitstream_buffers_in_decoder_.end()) { | 464 if (it == bitstream_buffers_in_decoder_.end()) { |
469 NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE); | 465 NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE); |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
809 UMA_HISTOGRAM_BOOLEAN("Media.RTCVideoDecoderInitDecodeSuccess", sample); | 805 UMA_HISTOGRAM_BOOLEAN("Media.RTCVideoDecoderInitDecodeSuccess", sample); |
810 return status; | 806 return status; |
811 } | 807 } |
812 | 808 |
813 void RTCVideoDecoder::DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent() | 809 void RTCVideoDecoder::DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent() |
814 const { | 810 const { |
815 DCHECK(factories_->GetTaskRunner()->BelongsToCurrentThread()); | 811 DCHECK(factories_->GetTaskRunner()->BelongsToCurrentThread()); |
816 } | 812 } |
817 | 813 |
818 } // namespace content | 814 } // namespace content |
OLD | NEW |