OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/common/gpu/media/android_video_decode_accelerator.h" | 5 #include "content/common/gpu/media/android_video_decode_accelerator.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/android/build_info.h" | 9 #include "base/android/build_info.h" |
10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
(...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
612 base::MessageLoop::current()->PostTask( | 612 base::MessageLoop::current()->PostTask( |
613 FROM_HERE, base::Bind(&AndroidVideoDecodeAccelerator::NotifyPictureReady, | 613 FROM_HERE, base::Bind(&AndroidVideoDecodeAccelerator::NotifyPictureReady, |
614 weak_this_factory_.GetWeakPtr(), | 614 weak_this_factory_.GetWeakPtr(), |
615 media::Picture(picture_buffer_id, bitstream_id, | 615 media::Picture(picture_buffer_id, bitstream_id, |
616 gfx::Rect(size_), allow_overlay))); | 616 gfx::Rect(size_), allow_overlay))); |
617 } | 617 } |
618 | 618 |
619 void AndroidVideoDecodeAccelerator::Decode( | 619 void AndroidVideoDecodeAccelerator::Decode( |
620 const media::BitstreamBuffer& bitstream_buffer) { | 620 const media::BitstreamBuffer& bitstream_buffer) { |
621 DCHECK(thread_checker_.CalledOnValidThread()); | 621 DCHECK(thread_checker_.CalledOnValidThread()); |
622 if (bitstream_buffer.id() != -1 && bitstream_buffer.size() == 0) { | 622 |
| 623 if (bitstream_buffer.id() >= 0 && bitstream_buffer.size() > 0) { |
| 624 DecodeBuffer(bitstream_buffer); |
| 625 return; |
| 626 } |
| 627 |
| 628 if (base::SharedMemory::IsHandleValid(bitstream_buffer.handle())) |
| 629 base::SharedMemory::CloseHandle(bitstream_buffer.handle()); |
| 630 |
| 631 if (bitstream_buffer.id() < 0) { |
| 632 POST_ERROR(INVALID_ARGUMENT, |
| 633 "Invalid bistream_buffer, id: " << bitstream_buffer.id()); |
| 634 } else { |
623 base::MessageLoop::current()->PostTask( | 635 base::MessageLoop::current()->PostTask( |
624 FROM_HERE, | 636 FROM_HERE, |
625 base::Bind(&AndroidVideoDecodeAccelerator::NotifyEndOfBitstreamBuffer, | 637 base::Bind(&AndroidVideoDecodeAccelerator::NotifyEndOfBitstreamBuffer, |
626 weak_this_factory_.GetWeakPtr(), bitstream_buffer.id())); | 638 weak_this_factory_.GetWeakPtr(), bitstream_buffer.id())); |
627 return; | |
628 } | 639 } |
| 640 } |
629 | 641 |
| 642 void AndroidVideoDecodeAccelerator::DecodeBuffer( |
| 643 const media::BitstreamBuffer& bitstream_buffer) { |
630 pending_bitstream_buffers_.push( | 644 pending_bitstream_buffers_.push( |
631 std::make_pair(bitstream_buffer, base::Time::Now())); | 645 std::make_pair(bitstream_buffer, base::Time::Now())); |
632 TRACE_COUNTER1("media", "AVDA::PendingBitstreamBufferCount", | 646 TRACE_COUNTER1("media", "AVDA::PendingBitstreamBufferCount", |
633 pending_bitstream_buffers_.size()); | 647 pending_bitstream_buffers_.size()); |
634 | 648 |
635 DoIOTask(); | 649 DoIOTask(); |
636 } | 650 } |
637 | 651 |
638 void AndroidVideoDecodeAccelerator::RequestPictureBuffers() { | 652 void AndroidVideoDecodeAccelerator::RequestPictureBuffers() { |
639 client_->ProvidePictureBuffers(kNumPictureBuffers, size_, | 653 client_->ProvidePictureBuffers(kNumPictureBuffers, size_, |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
697 } | 711 } |
698 | 712 |
699 strategy_->ReuseOnePictureBuffer(i->second); | 713 strategy_->ReuseOnePictureBuffer(i->second); |
700 | 714 |
701 DoIOTask(); | 715 DoIOTask(); |
702 } | 716 } |
703 | 717 |
704 void AndroidVideoDecodeAccelerator::Flush() { | 718 void AndroidVideoDecodeAccelerator::Flush() { |
705 DCHECK(thread_checker_.CalledOnValidThread()); | 719 DCHECK(thread_checker_.CalledOnValidThread()); |
706 | 720 |
707 Decode(media::BitstreamBuffer(-1, base::SharedMemoryHandle(), 0)); | 721 DecodeBuffer(media::BitstreamBuffer(-1, base::SharedMemoryHandle(), 0)); |
708 } | 722 } |
709 | 723 |
710 bool AndroidVideoDecodeAccelerator::ConfigureMediaCodec() { | 724 bool AndroidVideoDecodeAccelerator::ConfigureMediaCodec() { |
711 DCHECK(thread_checker_.CalledOnValidThread()); | 725 DCHECK(thread_checker_.CalledOnValidThread()); |
712 TRACE_EVENT0("media", "AVDA::ConfigureMediaCodec"); | 726 TRACE_EVENT0("media", "AVDA::ConfigureMediaCodec"); |
713 | 727 |
714 jobject media_crypto = media_crypto_ ? media_crypto_->obj() : nullptr; | 728 jobject media_crypto = media_crypto_ ? media_crypto_->obj() : nullptr; |
715 | 729 |
716 // |needs_protected_surface_| implies encrypted stream. | 730 // |needs_protected_surface_| implies encrypted stream. |
717 DCHECK(!needs_protected_surface_ || media_crypto); | 731 DCHECK(!needs_protected_surface_ || media_crypto); |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1014 | 1028 |
1015 if (UseDeferredRenderingStrategy()) { | 1029 if (UseDeferredRenderingStrategy()) { |
1016 capabilities.flags = media::VideoDecodeAccelerator::Capabilities:: | 1030 capabilities.flags = media::VideoDecodeAccelerator::Capabilities:: |
1017 NEEDS_ALL_PICTURE_BUFFERS_TO_DECODE; | 1031 NEEDS_ALL_PICTURE_BUFFERS_TO_DECODE; |
1018 } | 1032 } |
1019 | 1033 |
1020 return capabilities; | 1034 return capabilities; |
1021 } | 1035 } |
1022 | 1036 |
1023 } // namespace content | 1037 } // namespace content |
OLD | NEW |