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 "media/gpu/android_video_decode_accelerator.h" | 5 #include "media/gpu/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 945 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
956 NotifyPictureReady(picture); | 956 NotifyPictureReady(picture); |
957 | 957 |
958 // Connect the PictureBuffer to the decoded frame, via whatever mechanism the | 958 // Connect the PictureBuffer to the decoded frame, via whatever mechanism the |
959 // strategy likes. | 959 // strategy likes. |
960 strategy_->UseCodecBufferForPictureBuffer(codec_buffer_index, i->second); | 960 strategy_->UseCodecBufferForPictureBuffer(codec_buffer_index, i->second); |
961 } | 961 } |
962 | 962 |
963 void AndroidVideoDecodeAccelerator::Decode( | 963 void AndroidVideoDecodeAccelerator::Decode( |
964 const BitstreamBuffer& bitstream_buffer) { | 964 const BitstreamBuffer& bitstream_buffer) { |
965 DCHECK(thread_checker_.CalledOnValidThread()); | 965 DCHECK(thread_checker_.CalledOnValidThread()); |
966 no_decode_timeout_.Stop(); | |
liberato (no reviews please)
2016/07/13 05:25:55
i think that you also need to stop the timer in Re
DaleCurtis
2016/07/13 21:12:21
Done.
| |
966 | 967 |
967 // If we previously deferred a codec restart, take care of it now. This can | 968 // If we previously deferred a codec restart, take care of it now. This can |
968 // happen on older devices where configuration changes require a codec reset. | 969 // happen on older devices where configuration changes require a codec reset. |
969 if (codec_needs_reset_) { | 970 if (codec_needs_reset_) { |
970 DCHECK_EQ(drain_type_, DRAIN_TYPE_NONE); | 971 DCHECK_EQ(drain_type_, DRAIN_TYPE_NONE); |
971 ResetCodecState(); | 972 ResetCodecState(); |
972 } | 973 } |
973 | 974 |
974 if (bitstream_buffer.id() >= 0 && bitstream_buffer.size() > 0) { | 975 if (bitstream_buffer.id() >= 0 && bitstream_buffer.size() > 0) { |
975 DecodeBuffer(bitstream_buffer); | 976 DecodeBuffer(bitstream_buffer); |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1195 | 1196 |
1196 DCHECK(!media_codec_); | 1197 DCHECK(!media_codec_); |
1197 media_codec_ = std::move(media_codec); | 1198 media_codec_ = std::move(media_codec); |
1198 strategy_->CodecChanged(media_codec_.get()); | 1199 strategy_->CodecChanged(media_codec_.get()); |
1199 if (!media_codec_) { | 1200 if (!media_codec_) { |
1200 POST_ERROR(PLATFORM_FAILURE, "Failed to create MediaCodec."); | 1201 POST_ERROR(PLATFORM_FAILURE, "Failed to create MediaCodec."); |
1201 return; | 1202 return; |
1202 } | 1203 } |
1203 | 1204 |
1204 state_ = NO_ERROR; | 1205 state_ = NO_ERROR; |
1205 | 1206 no_decode_timeout_.Start(FROM_HERE, base::TimeDelta::FromSeconds(2), this, |
liberato (no reviews please)
2016/07/13 05:25:55
2 => kSomethingSomething
DaleCurtis
2016/07/13 21:12:21
Done.
| |
1207 &AndroidVideoDecodeAccelerator::CloseIdleCodec); | |
1206 ManageTimer(true); | 1208 ManageTimer(true); |
1207 } | 1209 } |
1208 | 1210 |
1209 void AndroidVideoDecodeAccelerator::StartCodecDrain(DrainType drain_type) { | 1211 void AndroidVideoDecodeAccelerator::StartCodecDrain(DrainType drain_type) { |
1210 DVLOG(2) << __FUNCTION__ << " drain_type:" << drain_type; | 1212 DVLOG(2) << __FUNCTION__ << " drain_type:" << drain_type; |
1211 DCHECK(thread_checker_.CalledOnValidThread()); | 1213 DCHECK(thread_checker_.CalledOnValidThread()); |
1212 | 1214 |
1213 // We assume that DRAIN_FOR_FLUSH and DRAIN_FOR_RESET cannot come while | 1215 // We assume that DRAIN_FOR_FLUSH and DRAIN_FOR_RESET cannot come while |
1214 // another drain request is present, but DRAIN_FOR_DESTROY can. | 1216 // another drain request is present, but DRAIN_FOR_DESTROY can. |
1215 DCHECK_NE(drain_type, DRAIN_TYPE_NONE); | 1217 DCHECK_NE(drain_type, DRAIN_TYPE_NONE); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1304 // state because of a codec error, then it would be okay. Otherwise, it's | 1306 // state because of a codec error, then it would be okay. Otherwise, it's |
1305 // less obvious that we are exiting the error state. Since deferred errors | 1307 // less obvious that we are exiting the error state. Since deferred errors |
1306 // are only intended for fullscreen transitions right now, we take the more | 1308 // are only intended for fullscreen transitions right now, we take the more |
1307 // conservative approach and let the errors post. | 1309 // conservative approach and let the errors post. |
1308 // TODO(liberato): revisit this once we sort out the error state a bit more. | 1310 // TODO(liberato): revisit this once we sort out the error state a bit more. |
1309 | 1311 |
1310 // When the codec is not in error state we can flush() for JB-MR2 and beyond. | 1312 // When the codec is not in error state we can flush() for JB-MR2 and beyond. |
1311 // Prior to JB-MR2, flush() had several bugs (b/8125974, b/8347958) so we must | 1313 // Prior to JB-MR2, flush() had several bugs (b/8125974, b/8347958) so we must |
1312 // delete the MediaCodec and create a new one. The full reconfigure is much | 1314 // delete the MediaCodec and create a new one. The full reconfigure is much |
1313 // slower and may cause visible freezing if done mid-stream. | 1315 // slower and may cause visible freezing if done mid-stream. |
1314 if (!did_codec_error_happen && | 1316 if (!did_codec_error_happen && media_codec_ && |
1315 base::android::BuildInfo::GetInstance()->sdk_int() >= 18) { | 1317 base::android::BuildInfo::GetInstance()->sdk_int() >= 18) { |
1316 DVLOG(3) << __FUNCTION__ << " Flushing MediaCodec."; | 1318 DVLOG(3) << __FUNCTION__ << " Flushing MediaCodec."; |
1317 media_codec_->Flush(); | 1319 media_codec_->Flush(); |
1318 // Since we just flushed all the output buffers, make sure that nothing is | 1320 // Since we just flushed all the output buffers, make sure that nothing is |
1319 // using them. | 1321 // using them. |
1320 strategy_->CodecChanged(media_codec_.get()); | 1322 strategy_->CodecChanged(media_codec_.get()); |
1321 } else { | 1323 } else { |
1322 DVLOG(3) << __FUNCTION__ | 1324 DVLOG(3) << __FUNCTION__ |
1323 << " Deleting the MediaCodec and creating a new one."; | 1325 << " Deleting the MediaCodec and creating a new one."; |
1324 g_avda_timer.Pointer()->StopTimer(this); | 1326 g_avda_timer.Pointer()->StopTimer(this); |
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1779 } | 1781 } |
1780 | 1782 |
1781 bool AndroidVideoDecodeAccelerator::IsMediaCodecSoftwareDecodingForbidden() | 1783 bool AndroidVideoDecodeAccelerator::IsMediaCodecSoftwareDecodingForbidden() |
1782 const { | 1784 const { |
1783 // Prevent MediaCodec from using its internal software decoders when we have | 1785 // Prevent MediaCodec from using its internal software decoders when we have |
1784 // more secure and up to date versions in the renderer process. | 1786 // more secure and up to date versions in the renderer process. |
1785 return !config_.is_encrypted && (codec_config_->codec_ == media::kCodecVP8 || | 1787 return !config_.is_encrypted && (codec_config_->codec_ == media::kCodecVP8 || |
1786 codec_config_->codec_ == media::kCodecVP9); | 1788 codec_config_->codec_ == media::kCodecVP9); |
1787 } | 1789 } |
1788 | 1790 |
1791 void AndroidVideoDecodeAccelerator::CloseIdleCodec() { | |
1792 if (media_codec_) { | |
liberato (no reviews please)
2016/07/13 05:25:55
please consider early out.
DaleCurtis
2016/07/13 21:12:21
Done.
| |
1793 ReleaseMediaCodec(); | |
1794 codec_needs_reset_ = true; | |
1795 } | |
1796 } | |
1797 | |
1789 } // namespace media | 1798 } // namespace media |
OLD | NEW |