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 <memory> | 9 #include <memory> |
10 | 10 |
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
495 | 495 |
496 NOTIMPLEMENTED(); | 496 NOTIMPLEMENTED(); |
497 NotifyInitializationComplete(false); | 497 NotifyInitializationComplete(false); |
498 | 498 |
499 #endif // !defined(ENABLE_MOJO_MEDIA_IN_GPU_PROCESS) | 499 #endif // !defined(ENABLE_MOJO_MEDIA_IN_GPU_PROCESS) |
500 } | 500 } |
501 | 501 |
502 void AndroidVideoDecodeAccelerator::DoIOTask(bool start_timer) { | 502 void AndroidVideoDecodeAccelerator::DoIOTask(bool start_timer) { |
503 DCHECK(thread_checker_.CalledOnValidThread()); | 503 DCHECK(thread_checker_.CalledOnValidThread()); |
504 TRACE_EVENT0("media", "AVDA::DoIOTask"); | 504 TRACE_EVENT0("media", "AVDA::DoIOTask"); |
505 if (state_ == ERROR || state_ == WAITING_FOR_CODEC) { | 505 if (state_ == ERROR || state_ == WAITING_FOR_CODEC) |
506 return; | 506 return; |
507 } | |
508 | 507 |
508 strategy_->MaybeRenderEarly(pictures_out_for_display_); | |
509 bool did_work = QueueInput(); | 509 bool did_work = QueueInput(); |
510 while (DequeueOutput()) | 510 while (DequeueOutput()) |
511 did_work = true; | 511 did_work = true; |
512 strategy_->MaybeRenderEarly(pictures_out_for_display_); | |
liberato (no reviews please)
2016/04/22 00:51:05
i see why you'd want to call this periodically, bu
DaleCurtis
2016/04/22 01:33:58
I was thinking that there may be work after Dequeu
| |
512 | 513 |
513 ManageTimer(did_work || start_timer); | 514 ManageTimer(did_work || start_timer); |
514 } | 515 } |
515 | 516 |
516 bool AndroidVideoDecodeAccelerator::QueueInput() { | 517 bool AndroidVideoDecodeAccelerator::QueueInput() { |
517 DCHECK(thread_checker_.CalledOnValidThread()); | 518 DCHECK(thread_checker_.CalledOnValidThread()); |
518 TRACE_EVENT0("media", "AVDA::QueueInput"); | 519 TRACE_EVENT0("media", "AVDA::QueueInput"); |
519 base::AutoReset<bool> auto_reset(&defer_errors_, true); | 520 base::AutoReset<bool> auto_reset(&defer_errors_, true); |
520 if (bitstreams_notified_in_advance_.size() > kMaxBitstreamsNotifiedInAdvance) | 521 if (bitstreams_notified_in_advance_.size() > kMaxBitstreamsNotifiedInAdvance) |
521 return false; | 522 return false; |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
812 free_picture_ids_.pop(); | 813 free_picture_ids_.pop(); |
813 TRACE_COUNTER1("media", "AVDA::FreePictureIds", free_picture_ids_.size()); | 814 TRACE_COUNTER1("media", "AVDA::FreePictureIds", free_picture_ids_.size()); |
814 | 815 |
815 const auto& i = output_picture_buffers_.find(picture_buffer_id); | 816 const auto& i = output_picture_buffers_.find(picture_buffer_id); |
816 if (i == output_picture_buffers_.end()) { | 817 if (i == output_picture_buffers_.end()) { |
817 POST_ERROR(PLATFORM_FAILURE, | 818 POST_ERROR(PLATFORM_FAILURE, |
818 "Can't find PictureBuffer id: " << picture_buffer_id); | 819 "Can't find PictureBuffer id: " << picture_buffer_id); |
819 return; | 820 return; |
820 } | 821 } |
821 | 822 |
823 pictures_out_for_display_.push_back(picture_buffer_id); | |
824 | |
822 bool size_changed = false; | 825 bool size_changed = false; |
823 if (i->second.size() != size_) { | 826 if (i->second.size() != size_) { |
824 // Size may have changed due to resolution change since the last time this | 827 // Size may have changed due to resolution change since the last time this |
825 // PictureBuffer was used. | 828 // PictureBuffer was used. |
826 strategy_->UpdatePictureBufferSize(&i->second, size_); | 829 strategy_->UpdatePictureBufferSize(&i->second, size_); |
827 size_changed = true; | 830 size_changed = true; |
828 } | 831 } |
829 | 832 |
830 // Connect the PictureBuffer to the decoded frame, via whatever | 833 // Connect the PictureBuffer to the decoded frame, via whatever |
831 // mechanism the strategy likes. | 834 // mechanism the strategy likes. |
832 strategy_->UseCodecBufferForPictureBuffer(codec_buffer_index, i->second); | 835 strategy_->UseCodecBufferForPictureBuffer(codec_buffer_index, i->second, |
836 pictures_out_for_display_); | |
833 | 837 |
834 const bool allow_overlay = strategy_->ArePicturesOverlayable(); | 838 const bool allow_overlay = strategy_->ArePicturesOverlayable(); |
835 | 839 |
836 media::Picture picture(picture_buffer_id, bitstream_id, gfx::Rect(size_), | 840 media::Picture picture(picture_buffer_id, bitstream_id, gfx::Rect(size_), |
837 allow_overlay); | 841 allow_overlay); |
838 picture.set_size_changed(size_changed); | 842 picture.set_size_changed(size_changed); |
839 | 843 |
840 base::MessageLoop::current()->PostTask( | 844 base::MessageLoop::current()->PostTask( |
841 FROM_HERE, base::Bind(&AndroidVideoDecodeAccelerator::NotifyPictureReady, | 845 FROM_HERE, base::Bind(&AndroidVideoDecodeAccelerator::NotifyPictureReady, |
842 weak_this_factory_.GetWeakPtr(), picture)); | 846 weak_this_factory_.GetWeakPtr(), picture)); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
911 } | 915 } |
912 TRACE_COUNTER1("media", "AVDA::FreePictureIds", free_picture_ids_.size()); | 916 TRACE_COUNTER1("media", "AVDA::FreePictureIds", free_picture_ids_.size()); |
913 DoIOTask(true); | 917 DoIOTask(true); |
914 } | 918 } |
915 | 919 |
916 void AndroidVideoDecodeAccelerator::ReusePictureBuffer( | 920 void AndroidVideoDecodeAccelerator::ReusePictureBuffer( |
917 int32_t picture_buffer_id) { | 921 int32_t picture_buffer_id) { |
918 DCHECK(thread_checker_.CalledOnValidThread()); | 922 DCHECK(thread_checker_.CalledOnValidThread()); |
919 | 923 |
920 free_picture_ids_.push(picture_buffer_id); | 924 free_picture_ids_.push(picture_buffer_id); |
925 pictures_out_for_display_.erase( | |
926 std::remove(pictures_out_for_display_.begin(), | |
927 pictures_out_for_display_.end(), picture_buffer_id), | |
928 pictures_out_for_display_.end()); | |
921 TRACE_COUNTER1("media", "AVDA::FreePictureIds", free_picture_ids_.size()); | 929 TRACE_COUNTER1("media", "AVDA::FreePictureIds", free_picture_ids_.size()); |
922 | 930 |
923 OutputBufferMap::const_iterator i = | 931 OutputBufferMap::const_iterator i = |
924 output_picture_buffers_.find(picture_buffer_id); | 932 output_picture_buffers_.find(picture_buffer_id); |
925 if (i == output_picture_buffers_.end()) { | 933 if (i == output_picture_buffers_.end()) { |
926 POST_ERROR(PLATFORM_FAILURE, "Can't find PictureBuffer id " | 934 POST_ERROR(PLATFORM_FAILURE, "Can't find PictureBuffer id " |
927 << picture_buffer_id); | 935 << picture_buffer_id); |
928 return; | 936 return; |
929 } | 937 } |
930 | 938 |
931 strategy_->ReuseOnePictureBuffer(i->second); | 939 strategy_->ReuseOnePictureBuffer(i->second, pictures_out_for_display_); |
932 DoIOTask(true); | 940 DoIOTask(true); |
933 } | 941 } |
934 | 942 |
935 void AndroidVideoDecodeAccelerator::Flush() { | 943 void AndroidVideoDecodeAccelerator::Flush() { |
936 DCHECK(thread_checker_.CalledOnValidThread()); | 944 DCHECK(thread_checker_.CalledOnValidThread()); |
937 | 945 |
938 DecodeBuffer(media::BitstreamBuffer(-1, base::SharedMemoryHandle(), 0)); | 946 DecodeBuffer(media::BitstreamBuffer(-1, base::SharedMemoryHandle(), 0)); |
939 } | 947 } |
940 | 948 |
941 void AndroidVideoDecodeAccelerator::ConfigureMediaCodecAsynchronously() { | 949 void AndroidVideoDecodeAccelerator::ConfigureMediaCodecAsynchronously() { |
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1354 if (media::MediaCodecUtil::IsSurfaceViewOutputSupported()) { | 1362 if (media::MediaCodecUtil::IsSurfaceViewOutputSupported()) { |
1355 capabilities.flags |= media::VideoDecodeAccelerator::Capabilities:: | 1363 capabilities.flags |= media::VideoDecodeAccelerator::Capabilities:: |
1356 SUPPORTS_EXTERNAL_OUTPUT_SURFACE; | 1364 SUPPORTS_EXTERNAL_OUTPUT_SURFACE; |
1357 } | 1365 } |
1358 } | 1366 } |
1359 | 1367 |
1360 return capabilities; | 1368 return capabilities; |
1361 } | 1369 } |
1362 | 1370 |
1363 } // namespace content | 1371 } // namespace content |
OLD | NEW |