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(pb.texture_mailbox(), | 448 make_scoped_ptr(new gpu::MailboxHolder( |
449 decoder_texture_target_, 0)), | 449 pb.texture_mailbox(), decoder_texture_target_, 0)), |
450 media::BindToCurrentLoop(base::Bind( | 450 media::BindToCurrentLoop(base::Bind(&RTCVideoDecoder::ReleaseMailbox, |
451 &RTCVideoDecoder::ReleaseMailbox, weak_factory_.GetWeakPtr(), | 451 weak_factory_.GetWeakPtr(), |
452 factories_, picture.picture_buffer_id(), pb.texture_id())), | 452 factories_, |
453 pb.size(), visible_rect, visible_rect.size(), timestamp_ms, | 453 picture.picture_buffer_id(), |
454 base::Bind(&ReadPixelsSync, factories_, pb.texture_id(), visible_rect), | 454 pb.texture_id())), |
455 picture.allow_overlay()); | 455 pb.size(), |
| 456 visible_rect, |
| 457 visible_rect.size(), |
| 458 timestamp_ms, |
| 459 base::Bind(&ReadPixelsSync, factories_, pb.texture_id(), visible_rect)); |
456 } | 460 } |
457 | 461 |
458 void RTCVideoDecoder::NotifyEndOfBitstreamBuffer(int32 id) { | 462 void RTCVideoDecoder::NotifyEndOfBitstreamBuffer(int32 id) { |
459 DVLOG(3) << "NotifyEndOfBitstreamBuffer. id=" << id; | 463 DVLOG(3) << "NotifyEndOfBitstreamBuffer. id=" << id; |
460 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent(); | 464 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent(); |
461 | 465 |
462 std::map<int32, SHMBuffer*>::iterator it = | 466 std::map<int32, SHMBuffer*>::iterator it = |
463 bitstream_buffers_in_decoder_.find(id); | 467 bitstream_buffers_in_decoder_.find(id); |
464 if (it == bitstream_buffers_in_decoder_.end()) { | 468 if (it == bitstream_buffers_in_decoder_.end()) { |
465 NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE); | 469 NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE); |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
805 UMA_HISTOGRAM_BOOLEAN("Media.RTCVideoDecoderInitDecodeSuccess", sample); | 809 UMA_HISTOGRAM_BOOLEAN("Media.RTCVideoDecoderInitDecodeSuccess", sample); |
806 return status; | 810 return status; |
807 } | 811 } |
808 | 812 |
809 void RTCVideoDecoder::DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent() | 813 void RTCVideoDecoder::DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent() |
810 const { | 814 const { |
811 DCHECK(factories_->GetTaskRunner()->BelongsToCurrentThread()); | 815 DCHECK(factories_->GetTaskRunner()->BelongsToCurrentThread()); |
812 } | 816 } |
813 | 817 |
814 } // namespace content | 818 } // namespace content |
OLD | NEW |