OLD | NEW |
---|---|
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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
10 #include "media/base/android/media_codec_bridge.h" | 10 #include "media/base/android/media_codec_bridge.h" |
(...skipping 995 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1006 SeekPlayer(true, base::TimeDelta()); | 1006 SeekPlayer(true, base::TimeDelta()); |
1007 EXPECT_EQ(2, demuxer_->num_data_requests()); | 1007 EXPECT_EQ(2, demuxer_->num_data_requests()); |
1008 player_.OnDemuxerDataAvailable(CreateEOSAck(true)); | 1008 player_.OnDemuxerDataAvailable(CreateEOSAck(true)); |
1009 EXPECT_FALSE(manager_.playback_completed()); | 1009 EXPECT_FALSE(manager_.playback_completed()); |
1010 | 1010 |
1011 message_loop_.Run(); | 1011 message_loop_.Run(); |
1012 EXPECT_TRUE(manager_.playback_completed()); | 1012 EXPECT_TRUE(manager_.playback_completed()); |
1013 EXPECT_EQ(2, demuxer_->num_data_requests()); | 1013 EXPECT_EQ(2, demuxer_->num_data_requests()); |
1014 } | 1014 } |
1015 | 1015 |
1016 TEST_F(MediaSourcePlayerTest, PlaybackCompletionAcrossConfigChange) { | |
1017 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); | |
1018 | |
1019 // Test that if one stream (audio) has completed decode of EOS and the other | |
1020 // stream (video) processes config change, that subsequent video EOS completes | |
1021 // A/V playback. | |
1022 Start(CreateAudioVideoDemuxerConfigs()); | |
1023 CreateNextTextureAndSetVideoSurface(); | |
1024 EXPECT_TRUE(GetMediaDecoderJob(true) && GetMediaDecoderJob(false)); | |
1025 EXPECT_EQ(2, demuxer_->num_data_requests()); | |
1026 player_.OnDemuxerDataAvailable(CreateEOSAck(true)); // Audio EoS | |
1027 EXPECT_EQ(0, demuxer_->num_config_requests()); | |
1028 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckWithConfigChanged( | |
1029 false, 0)); // Video |kConfigChanged| as first unit. | |
1030 | |
1031 while (GetMediaDecoderJob(true)->is_decoding() || | |
1032 GetMediaDecoderJob(false)->is_decoding()) { | |
1033 message_loop_.RunUntilIdle(); | |
1034 } | |
1035 | |
1036 EXPECT_EQ(1, demuxer_->num_config_requests()); | |
1037 EXPECT_EQ(2, demuxer_->num_data_requests()); | |
1038 player_.OnDemuxerConfigsAvailable(CreateAudioVideoDemuxerConfigs()); | |
1039 EXPECT_EQ(3, demuxer_->num_data_requests()); | |
1040 | |
1041 player_.OnDemuxerDataAvailable(CreateEOSAck(false)); // Video EoS | |
1042 EXPECT_FALSE(manager_.playback_completed()); | |
1043 message_loop_.Run(); | |
1044 EXPECT_TRUE(manager_.playback_completed()); | |
1045 } | |
1046 | |
1047 TEST_F(MediaSourcePlayerTest, NoPrefetchForAlreadyFinishedStreamOnStarvation) { | |
1048 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); | |
1049 | |
1050 // Test that if one stream (video) has completed decode of EOS, prefetch | |
1051 // resulting from player starvation occurs only for the other stream (audio), | |
1052 // and responding to that prefetch with EoS completes A/V playback. | |
1053 Start(CreateAudioVideoDemuxerConfigs()); | |
1054 CreateNextTextureAndSetVideoSurface(); | |
1055 EXPECT_TRUE(GetMediaDecoderJob(true) && GetMediaDecoderJob(false)); | |
1056 EXPECT_EQ(2, demuxer_->num_data_requests()); | |
1057 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForAudio(0)); | |
1058 player_.OnDemuxerDataAvailable(CreateEOSAck(false)); // Video EoS | |
1059 | |
1060 // Wait until video EoS is processed, and more data (assumed to be audio) is | |
1061 // requested. | |
1062 while (demuxer_->num_data_requests() < 3 || | |
1063 GetMediaDecoderJob(false)->is_decoding()) { | |
1064 message_loop_.RunUntilIdle(); | |
1065 } | |
1066 | |
1067 // Simulate decoder underrun to trigger prefetch while still decoding audio. | |
1068 EXPECT_EQ(3, demuxer_->num_data_requests()); | |
1069 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForAudio(1)); | |
1070 EXPECT_TRUE(GetMediaDecoderJob(true)->is_decoding() && | |
1071 !GetMediaDecoderJob(false)->is_decoding()); | |
1072 TriggerPlayerStarvation(); | |
1073 | |
1074 while (GetMediaDecoderJob(true)->is_decoding() || | |
1075 GetMediaDecoderJob(false)->is_decoding()) { | |
qinmin
2013/11/21 03:25:44
if video is reaching EOS, shouldn't video decoder
wolenetz
2013/11/23 00:10:36
Done.
| |
1076 message_loop_.RunUntilIdle(); | |
1077 } | |
1078 | |
1079 EXPECT_EQ(4, demuxer_->num_data_requests()); | |
1080 player_.OnDemuxerDataAvailable(CreateEOSAck(true)); // Audio EoS | |
1081 EXPECT_FALSE(manager_.playback_completed()); | |
1082 message_loop_.Run(); | |
1083 EXPECT_TRUE(manager_.playback_completed()); | |
1084 } | |
1085 | |
1016 TEST_F(MediaSourcePlayerTest, NoRequestForDataAfterAbort) { | 1086 TEST_F(MediaSourcePlayerTest, NoRequestForDataAfterAbort) { |
1017 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); | 1087 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); |
1018 | 1088 |
1019 // Test that the decoder will not request new data after receiving an aborted | 1089 // Test that the decoder will not request new data after receiving an aborted |
1020 // access unit. | 1090 // access unit. |
1021 StartAudioDecoderJob(); | 1091 StartAudioDecoderJob(); |
1022 EXPECT_EQ(1, demuxer_->num_data_requests()); | 1092 EXPECT_EQ(1, demuxer_->num_data_requests()); |
1023 | 1093 |
1024 // Send an aborted access unit. | 1094 // Send an aborted access unit. |
1025 player_.OnDemuxerDataAvailable(CreateAbortedAck(true)); | 1095 player_.OnDemuxerDataAvailable(CreateAbortedAck(true)); |
(...skipping 874 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1900 | 1970 |
1901 std::vector<std::string> codec_avc(1, "avc1"); | 1971 std::vector<std::string> codec_avc(1, "avc1"); |
1902 EXPECT_FALSE(IsTypeSupported(invalid_uuid, "L3", kVideoMp4, codec_avc)); | 1972 EXPECT_FALSE(IsTypeSupported(invalid_uuid, "L3", kVideoMp4, codec_avc)); |
1903 EXPECT_FALSE(IsTypeSupported(invalid_uuid, "L1", kVideoMp4, codec_avc)); | 1973 EXPECT_FALSE(IsTypeSupported(invalid_uuid, "L1", kVideoMp4, codec_avc)); |
1904 } | 1974 } |
1905 | 1975 |
1906 // TODO(xhwang): Are these IsTypeSupported tests device specific? | 1976 // TODO(xhwang): Are these IsTypeSupported tests device specific? |
1907 // TODO(xhwang): Add more IsTypeSupported tests. | 1977 // TODO(xhwang): Add more IsTypeSupported tests. |
1908 | 1978 |
1909 } // namespace media | 1979 } // namespace media |
OLD | NEW |