Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(188)

Side by Side Diff: content/renderer/media/rtc_video_decoder.cc

Issue 105743004: Add gpu::MailboxHolder to hold state for a gpu::Mailbox (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: cc2a95fe Android fixes. Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 uint32_t width, 414 uint32_t width,
415 uint32_t height, 415 uint32_t height,
416 size_t size) { 416 size_t size) {
417 gfx::Rect visible_rect(width, height); 417 gfx::Rect visible_rect(width, height);
418 gfx::Size natural_size(width, height); 418 gfx::Size natural_size(width, height);
419 DCHECK(decoder_texture_target_); 419 DCHECK(decoder_texture_target_);
420 // Convert timestamp from 90KHz to ms. 420 // Convert timestamp from 90KHz to ms.
421 base::TimeDelta timestamp_ms = base::TimeDelta::FromInternalValue( 421 base::TimeDelta timestamp_ms = base::TimeDelta::FromInternalValue(
422 base::checked_numeric_cast<uint64_t>(timestamp) * 1000 / 90); 422 base::checked_numeric_cast<uint64_t>(timestamp) * 1000 / 90);
423 return media::VideoFrame::WrapNativeTexture( 423 return media::VideoFrame::WrapNativeTexture(
424 make_scoped_ptr(new media::VideoFrame::MailboxHolder( 424 make_scoped_ptr(new gpu::MailboxHolder(
425 pb.texture_mailbox(), 425 pb.texture_mailbox(), decoder_texture_target_, 0)),
426 0, // sync_point 426 media::BindToCurrentLoop(base::Bind(&RTCVideoDecoder::ReusePictureBuffer,
427 media::BindToCurrentLoop( 427 weak_this_,
428 base::Bind(&RTCVideoDecoder::ReusePictureBuffer, 428 picture.picture_buffer_id())),
429 weak_this_,
430 picture.picture_buffer_id())))),
431 decoder_texture_target_,
432 pb.size(), 429 pb.size(),
433 visible_rect, 430 visible_rect,
434 natural_size, 431 natural_size,
435 timestamp_ms, 432 timestamp_ms,
436 base::Bind(&media::GpuVideoAcceleratorFactories::ReadPixels, 433 base::Bind(&media::GpuVideoAcceleratorFactories::ReadPixels,
437 factories_, 434 factories_,
438 pb.texture_id(), 435 pb.texture_id(),
439 natural_size), 436 natural_size));
440 base::Closure());
441 } 437 }
442 438
443 void RTCVideoDecoder::NotifyEndOfBitstreamBuffer(int32 id) { 439 void RTCVideoDecoder::NotifyEndOfBitstreamBuffer(int32 id) {
444 DVLOG(3) << "NotifyEndOfBitstreamBuffer. id=" << id; 440 DVLOG(3) << "NotifyEndOfBitstreamBuffer. id=" << id;
445 DCHECK(vda_loop_proxy_->BelongsToCurrentThread()); 441 DCHECK(vda_loop_proxy_->BelongsToCurrentThread());
446 442
447 std::map<int32, SHMBuffer*>::iterator it = 443 std::map<int32, SHMBuffer*>::iterator it =
448 bitstream_buffers_in_decoder_.find(id); 444 bitstream_buffers_in_decoder_.find(id);
449 if (it == bitstream_buffers_in_decoder_.end()) { 445 if (it == bitstream_buffers_in_decoder_.end()) {
450 NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE); 446 NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE);
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
634 } 630 }
635 } 631 }
636 632
637 void RTCVideoDecoder::ResetInternal() { 633 void RTCVideoDecoder::ResetInternal() {
638 DCHECK(vda_loop_proxy_->BelongsToCurrentThread()); 634 DCHECK(vda_loop_proxy_->BelongsToCurrentThread());
639 DVLOG(2) << "ResetInternal"; 635 DVLOG(2) << "ResetInternal";
640 if (vda_) 636 if (vda_)
641 vda_->Reset(); 637 vda_->Reset();
642 } 638 }
643 639
644 void RTCVideoDecoder::ReusePictureBuffer(int64 picture_buffer_id, 640 void RTCVideoDecoder::ReusePictureBuffer(
645 uint32 sync_point) { 641 int64 picture_buffer_id,
642 scoped_ptr<gpu::MailboxHolder> mailbox_holder) {
646 DCHECK(vda_loop_proxy_->BelongsToCurrentThread()); 643 DCHECK(vda_loop_proxy_->BelongsToCurrentThread());
647 DVLOG(3) << "ReusePictureBuffer. id=" << picture_buffer_id; 644 DVLOG(3) << "ReusePictureBuffer. id=" << picture_buffer_id;
648 645
649 if (!vda_) 646 if (!vda_)
650 return; 647 return;
651 648
652 CHECK(!picture_buffers_at_display_.empty()); 649 CHECK(!picture_buffers_at_display_.empty());
653 650
654 size_t num_erased = picture_buffers_at_display_.erase(picture_buffer_id); 651 size_t num_erased = picture_buffers_at_display_.erase(picture_buffer_id);
655 DCHECK(num_erased); 652 DCHECK(num_erased);
656 653
657 std::map<int32, media::PictureBuffer>::iterator it = 654 std::map<int32, media::PictureBuffer>::iterator it =
658 assigned_picture_buffers_.find(picture_buffer_id); 655 assigned_picture_buffers_.find(picture_buffer_id);
659 656
660 if (it == assigned_picture_buffers_.end()) { 657 if (it == assigned_picture_buffers_.end()) {
661 // This picture was dismissed while in display, so we postponed deletion. 658 // This picture was dismissed while in display, so we postponed deletion.
662 it = dismissed_picture_buffers_.find(picture_buffer_id); 659 it = dismissed_picture_buffers_.find(picture_buffer_id);
663 DCHECK(it != dismissed_picture_buffers_.end()); 660 DCHECK(it != dismissed_picture_buffers_.end());
664 factories_->DeleteTexture(it->second.texture_id()); 661 factories_->DeleteTexture(it->second.texture_id());
665 dismissed_picture_buffers_.erase(it); 662 dismissed_picture_buffers_.erase(it);
666 return; 663 return;
667 } 664 }
668 665
669 factories_->WaitSyncPoint(sync_point); 666 factories_->WaitSyncPoint(mailbox_holder->sync_point());
670 667
671 vda_->ReusePictureBuffer(picture_buffer_id); 668 vda_->ReusePictureBuffer(picture_buffer_id);
672 } 669 }
673 670
674 void RTCVideoDecoder::DestroyTextures() { 671 void RTCVideoDecoder::DestroyTextures() {
675 DCHECK(vda_loop_proxy_->BelongsToCurrentThread()); 672 DCHECK(vda_loop_proxy_->BelongsToCurrentThread());
676 std::map<int32, media::PictureBuffer>::iterator it; 673 std::map<int32, media::PictureBuffer>::iterator it;
677 674
678 for (it = assigned_picture_buffers_.begin(); 675 for (it = assigned_picture_buffers_.begin();
679 it != assigned_picture_buffers_.end(); 676 it != assigned_picture_buffers_.end();
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
779 776
780 int32_t RTCVideoDecoder::RecordInitDecodeUMA(int32_t status) { 777 int32_t RTCVideoDecoder::RecordInitDecodeUMA(int32_t status) {
781 // Logging boolean is enough to know if HW decoding has been used. Also, 778 // Logging boolean is enough to know if HW decoding has been used. Also,
782 // InitDecode is less likely to return an error so enum is not used here. 779 // InitDecode is less likely to return an error so enum is not used here.
783 bool sample = (status == WEBRTC_VIDEO_CODEC_OK) ? true : false; 780 bool sample = (status == WEBRTC_VIDEO_CODEC_OK) ? true : false;
784 UMA_HISTOGRAM_BOOLEAN("Media.RTCVideoDecoderInitDecodeSuccess", sample); 781 UMA_HISTOGRAM_BOOLEAN("Media.RTCVideoDecoderInitDecodeSuccess", sample);
785 return status; 782 return status;
786 } 783 }
787 784
788 } // namespace content 785 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698