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 // At no time after completing audio EOS decode, above, should the | |
1042 // audio decoder job resume decoding (except after a seek). | |
acolwell GONE FROM CHROMIUM
2013/11/25 21:43:59
nit: The "(except after a seek)" comment here seem
wolenetz
2013/12/04 00:13:29
Done.
| |
1043 EXPECT_FALSE(GetMediaDecoderJob(true)->is_decoding()); | |
1044 player_.OnDemuxerDataAvailable(CreateEOSAck(false)); // Video EOS | |
1045 EXPECT_FALSE(GetMediaDecoderJob(true)->is_decoding()); | |
1046 | |
1047 // Decode the video EOS. Spot-check that audio decode doesn't resume. | |
1048 EXPECT_FALSE(manager_.playback_completed()); | |
1049 do { | |
1050 message_loop_.RunUntilIdle(); | |
1051 EXPECT_FALSE(GetMediaDecoderJob(true)->is_decoding()); | |
1052 } while (GetMediaDecoderJob(false)->is_decoding()); | |
1053 | |
1054 EXPECT_TRUE(manager_.playback_completed()); | |
1055 } | |
1056 | |
1057 TEST_F(MediaSourcePlayerTest, NoPrefetchForAlreadyFinishedStreamOnStarvation) { | |
1058 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); | |
1059 | |
1060 // Test that if one stream (video) has completed decode of EOS, prefetch | |
1061 // resulting from player starvation occurs only for the other stream (audio), | |
1062 // and responding to that prefetch with EOS completes A/V playback. | |
1063 Start(CreateAudioVideoDemuxerConfigs()); | |
1064 CreateNextTextureAndSetVideoSurface(); | |
1065 EXPECT_TRUE(GetMediaDecoderJob(true) && GetMediaDecoderJob(false)); | |
1066 EXPECT_EQ(2, demuxer_->num_data_requests()); | |
1067 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForAudio(0)); | |
1068 player_.OnDemuxerDataAvailable(CreateEOSAck(false)); // Video EOS | |
1069 | |
1070 // Wait until video EOS is processed and more data (assumed to be audio) is | |
1071 // requested. | |
1072 while (demuxer_->num_data_requests() < 3 || | |
1073 GetMediaDecoderJob(false)->is_decoding()) { | |
1074 message_loop_.RunUntilIdle(); | |
1075 } | |
1076 | |
1077 // Simulate decoder underrun to trigger prefetch while still decoding audio. | |
1078 EXPECT_EQ(3, demuxer_->num_data_requests()); | |
1079 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForAudio(1)); | |
1080 EXPECT_TRUE(GetMediaDecoderJob(true)->is_decoding() && | |
1081 !GetMediaDecoderJob(false)->is_decoding()); | |
1082 TriggerPlayerStarvation(); | |
1083 | |
1084 // Complete the audio decode that was in progress when simulated player | |
1085 // starvation was triggered. At no time after completing video EOS decode, | |
1086 // above, should the video decoder job resume decoding (except after a seek). | |
acolwell GONE FROM CHROMIUM
2013/11/25 21:43:59
ditto
wolenetz
2013/12/04 00:13:29
Done.
| |
1087 while (GetMediaDecoderJob(true)->is_decoding()) { | |
1088 EXPECT_FALSE(GetMediaDecoderJob(false)->is_decoding()); | |
1089 message_loop_.RunUntilIdle(); | |
1090 } | |
1091 EXPECT_FALSE(GetMediaDecoderJob(false)->is_decoding()); | |
1092 EXPECT_EQ(4, demuxer_->num_data_requests()); | |
1093 | |
1094 player_.OnDemuxerDataAvailable(CreateEOSAck(true)); // Audio EOS | |
1095 EXPECT_FALSE(GetMediaDecoderJob(false)->is_decoding()); | |
1096 EXPECT_FALSE(manager_.playback_completed()); | |
1097 message_loop_.Run(); | |
1098 EXPECT_TRUE(manager_.playback_completed()); | |
1099 } | |
1100 | |
acolwell GONE FROM CHROMIUM
2013/11/25 21:43:59
Are audio-only and video-only playback_completed c
wolenetz
2013/12/04 00:13:29
Existing tests had partial coverage:
1) ReplayInpu
| |
1016 TEST_F(MediaSourcePlayerTest, NoRequestForDataAfterAbort) { | 1101 TEST_F(MediaSourcePlayerTest, NoRequestForDataAfterAbort) { |
1017 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); | 1102 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); |
1018 | 1103 |
1019 // Test that the decoder will not request new data after receiving an aborted | 1104 // Test that the decoder will not request new data after receiving an aborted |
1020 // access unit. | 1105 // access unit. |
1021 StartAudioDecoderJob(); | 1106 StartAudioDecoderJob(); |
1022 EXPECT_EQ(1, demuxer_->num_data_requests()); | 1107 EXPECT_EQ(1, demuxer_->num_data_requests()); |
1023 | 1108 |
1024 // Send an aborted access unit. | 1109 // Send an aborted access unit. |
1025 player_.OnDemuxerDataAvailable(CreateAbortedAck(true)); | 1110 player_.OnDemuxerDataAvailable(CreateAbortedAck(true)); |
(...skipping 874 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1900 | 1985 |
1901 std::vector<std::string> codec_avc(1, "avc1"); | 1986 std::vector<std::string> codec_avc(1, "avc1"); |
1902 EXPECT_FALSE(IsTypeSupported(invalid_uuid, "L3", kVideoMp4, codec_avc)); | 1987 EXPECT_FALSE(IsTypeSupported(invalid_uuid, "L3", kVideoMp4, codec_avc)); |
1903 EXPECT_FALSE(IsTypeSupported(invalid_uuid, "L1", kVideoMp4, codec_avc)); | 1988 EXPECT_FALSE(IsTypeSupported(invalid_uuid, "L1", kVideoMp4, codec_avc)); |
1904 } | 1989 } |
1905 | 1990 |
1906 // TODO(xhwang): Are these IsTypeSupported tests device specific? | 1991 // TODO(xhwang): Are these IsTypeSupported tests device specific? |
1907 // TODO(xhwang): Add more IsTypeSupported tests. | 1992 // TODO(xhwang): Add more IsTypeSupported tests. |
1908 | 1993 |
1909 } // namespace media | 1994 } // namespace media |
OLD | NEW |