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

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

Powered by Google App Engine
This is Rietveld 408576698