| 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 "media/base/android/media_source_player.h" | 5 #include "media/base/android/media_source_player.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 872 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 883 configs.audio_extra_data.insert(configs.audio_extra_data.begin(), | 883 configs.audio_extra_data.insert(configs.audio_extra_data.begin(), |
| 884 invalid_codec_data, invalid_codec_data + 4); | 884 invalid_codec_data, invalid_codec_data + 4); |
| 885 Start(configs); | 885 Start(configs); |
| 886 | 886 |
| 887 // Decoder is not created after data is received. | 887 // Decoder is not created after data is received. |
| 888 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForAudio(0)); | 888 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForAudio(0)); |
| 889 EXPECT_FALSE(GetMediaCodecBridge(true)); | 889 EXPECT_FALSE(GetMediaCodecBridge(true)); |
| 890 } | 890 } |
| 891 | 891 |
| 892 TEST_F(MediaSourcePlayerTest, StartVideoCodecWithValidSurface) { | 892 TEST_F(MediaSourcePlayerTest, StartVideoCodecWithValidSurface) { |
| 893 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); | 893 // crbug.com/604602 and crbug.com/597836 |
| 894 SKIP_TEST_IF_VP8_DECODER_IS_NOT_SUPPORTED(); |
| 894 | 895 |
| 895 // Test video codec will not be created until data is received. | 896 // Test video codec will not be created until data is received. |
| 896 StartVideoDecoderJob(); | 897 StartVideoDecoderJob(); |
| 897 | 898 |
| 898 // Set both an initial and a later video surface without receiving any | 899 // Set both an initial and a later video surface without receiving any |
| 899 // demuxed data yet. | 900 // demuxed data yet. |
| 900 CreateNextTextureAndSetVideoSurface(); | 901 CreateNextTextureAndSetVideoSurface(); |
| 901 EXPECT_FALSE(GetMediaCodecBridge(false)); | 902 EXPECT_FALSE(GetMediaCodecBridge(false)); |
| 902 CreateNextTextureAndSetVideoSurface(); | 903 CreateNextTextureAndSetVideoSurface(); |
| 903 EXPECT_FALSE(GetMediaCodecBridge(false)); | 904 EXPECT_FALSE(GetMediaCodecBridge(false)); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 935 | 936 |
| 936 TEST_F(MediaSourcePlayerTest, ReadFromDemuxerAfterSeek) { | 937 TEST_F(MediaSourcePlayerTest, ReadFromDemuxerAfterSeek) { |
| 937 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); | 938 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); |
| 938 | 939 |
| 939 // Test decoder job will resend a ReadFromDemuxer request after seek. | 940 // Test decoder job will resend a ReadFromDemuxer request after seek. |
| 940 StartAudioDecoderJob(); | 941 StartAudioDecoderJob(); |
| 941 SeekPlayerWithAbort(true, base::TimeDelta()); | 942 SeekPlayerWithAbort(true, base::TimeDelta()); |
| 942 } | 943 } |
| 943 | 944 |
| 944 TEST_F(MediaSourcePlayerTest, SetSurfaceWhileSeeking) { | 945 TEST_F(MediaSourcePlayerTest, SetSurfaceWhileSeeking) { |
| 945 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); | 946 // crbug.com/604602 and crbug.com/597836 |
| 947 SKIP_TEST_IF_VP8_DECODER_IS_NOT_SUPPORTED(); |
| 946 | 948 |
| 947 // Test SetVideoSurface() will not cause an extra seek while the player is | 949 // Test SetVideoSurface() will not cause an extra seek while the player is |
| 948 // waiting for demuxer to indicate seek is done. | 950 // waiting for demuxer to indicate seek is done. |
| 949 player_.OnDemuxerConfigsAvailable( | 951 player_.OnDemuxerConfigsAvailable( |
| 950 CreateVideoDemuxerConfigs(false)); | 952 CreateVideoDemuxerConfigs(false)); |
| 951 | 953 |
| 952 // Initiate a seek. Skip requesting element seek of renderer. | 954 // Initiate a seek. Skip requesting element seek of renderer. |
| 953 // Instead behave as if the renderer has asked us to seek. | 955 // Instead behave as if the renderer has asked us to seek. |
| 954 player_.SeekTo(base::TimeDelta()); | 956 player_.SeekTo(base::TimeDelta()); |
| 955 EXPECT_EQ(1, demuxer_->num_seek_requests()); | 957 EXPECT_EQ(1, demuxer_->num_seek_requests()); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 966 EXPECT_TRUE(GetMediaCodecBridge(false)); | 968 EXPECT_TRUE(GetMediaCodecBridge(false)); |
| 967 | 969 |
| 968 // Reconfirm exactly 1 seek request has been made of demuxer, and that it | 970 // Reconfirm exactly 1 seek request has been made of demuxer, and that it |
| 969 // was not a browser seek request. | 971 // was not a browser seek request. |
| 970 EXPECT_EQ(1, demuxer_->num_seek_requests()); | 972 EXPECT_EQ(1, demuxer_->num_seek_requests()); |
| 971 EXPECT_EQ(0, demuxer_->num_browser_seek_requests()); | 973 EXPECT_EQ(0, demuxer_->num_browser_seek_requests()); |
| 972 WaitForVideoDecodeDone(); | 974 WaitForVideoDecodeDone(); |
| 973 } | 975 } |
| 974 | 976 |
| 975 TEST_F(MediaSourcePlayerTest, ChangeMultipleSurfaceWhileDecoding) { | 977 TEST_F(MediaSourcePlayerTest, ChangeMultipleSurfaceWhileDecoding) { |
| 976 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); | 978 // crbug.com/604602 and crbug.com/597836 |
| 979 SKIP_TEST_IF_VP8_DECODER_IS_NOT_SUPPORTED(); |
| 977 | 980 |
| 978 // Test MediaSourcePlayer can switch multiple surfaces during decoding. | 981 // Test MediaSourcePlayer can switch multiple surfaces during decoding. |
| 979 CreateNextTextureAndSetVideoSurface(); | 982 CreateNextTextureAndSetVideoSurface(); |
| 980 StartVideoDecoderJob(); | 983 StartVideoDecoderJob(); |
| 981 EXPECT_EQ(0, demuxer_->num_seek_requests()); | 984 EXPECT_EQ(0, demuxer_->num_seek_requests()); |
| 982 | 985 |
| 983 // Send the first input chunk. | 986 // Send the first input chunk. |
| 984 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForVideo(false)); | 987 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForVideo(false)); |
| 985 | 988 |
| 986 // While the decoder is decoding, change multiple surfaces. Pass an empty | 989 // While the decoder is decoding, change multiple surfaces. Pass an empty |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1007 EXPECT_FALSE(GetMediaCodecBridge(false)); | 1010 EXPECT_FALSE(GetMediaCodecBridge(false)); |
| 1008 EXPECT_EQ(3, demuxer_->num_data_requests()); | 1011 EXPECT_EQ(3, demuxer_->num_data_requests()); |
| 1009 EXPECT_EQ(1, demuxer_->num_seek_requests()); | 1012 EXPECT_EQ(1, demuxer_->num_seek_requests()); |
| 1010 | 1013 |
| 1011 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForVideo(false)); | 1014 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForVideo(false)); |
| 1012 EXPECT_TRUE(GetMediaCodecBridge(false)); | 1015 EXPECT_TRUE(GetMediaCodecBridge(false)); |
| 1013 WaitForVideoDecodeDone(); | 1016 WaitForVideoDecodeDone(); |
| 1014 } | 1017 } |
| 1015 | 1018 |
| 1016 TEST_F(MediaSourcePlayerTest, SetEmptySurfaceAndStarveWhileDecoding) { | 1019 TEST_F(MediaSourcePlayerTest, SetEmptySurfaceAndStarveWhileDecoding) { |
| 1017 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); | 1020 // crbug.com/604602 and crbug.com/597836 |
| 1021 SKIP_TEST_IF_VP8_DECODER_IS_NOT_SUPPORTED(); |
| 1018 | 1022 |
| 1019 // Test player pauses if an empty surface is passed. | 1023 // Test player pauses if an empty surface is passed. |
| 1020 CreateNextTextureAndSetVideoSurface(); | 1024 CreateNextTextureAndSetVideoSurface(); |
| 1021 StartVideoDecoderJob(); | 1025 StartVideoDecoderJob(); |
| 1022 EXPECT_EQ(1, demuxer_->num_data_requests()); | 1026 EXPECT_EQ(1, demuxer_->num_data_requests()); |
| 1023 | 1027 |
| 1024 // Send the first input chunk. | 1028 // Send the first input chunk. |
| 1025 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForVideo(false)); | 1029 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForVideo(false)); |
| 1026 | 1030 |
| 1027 // While the decoder is decoding, pass an empty surface. | 1031 // While the decoder is decoding, pass an empty surface. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1042 | 1046 |
| 1043 // Playback resumes once a non-empty surface is passed. | 1047 // Playback resumes once a non-empty surface is passed. |
| 1044 CreateNextTextureAndSetVideoSurface(); | 1048 CreateNextTextureAndSetVideoSurface(); |
| 1045 EXPECT_EQ(0, demuxer_->num_browser_seek_requests()); | 1049 EXPECT_EQ(0, demuxer_->num_browser_seek_requests()); |
| 1046 while(demuxer_->num_browser_seek_requests() != 1) | 1050 while(demuxer_->num_browser_seek_requests() != 1) |
| 1047 message_loop_.RunUntilIdle(); | 1051 message_loop_.RunUntilIdle(); |
| 1048 WaitForVideoDecodeDone(); | 1052 WaitForVideoDecodeDone(); |
| 1049 } | 1053 } |
| 1050 | 1054 |
| 1051 TEST_F(MediaSourcePlayerTest, ReleaseVideoDecoderResourcesWhileDecoding) { | 1055 TEST_F(MediaSourcePlayerTest, ReleaseVideoDecoderResourcesWhileDecoding) { |
| 1052 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); | 1056 // crbug.com/604602 and crbug.com/597836 |
| 1057 SKIP_TEST_IF_VP8_DECODER_IS_NOT_SUPPORTED(); |
| 1053 | 1058 |
| 1054 // Test that if video decoder is released while decoding, the resources will | 1059 // Test that if video decoder is released while decoding, the resources will |
| 1055 // not be immediately released. | 1060 // not be immediately released. |
| 1056 CreateNextTextureAndSetVideoSurface(); | 1061 CreateNextTextureAndSetVideoSurface(); |
| 1057 StartVideoDecoderJob(); | 1062 StartVideoDecoderJob(); |
| 1058 ReleasePlayer(); | 1063 ReleasePlayer(); |
| 1059 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForVideo(false)); | 1064 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForVideo(false)); |
| 1060 | 1065 |
| 1061 // Recreate the video decoder. | 1066 // Recreate the video decoder. |
| 1062 CreateNextTextureAndSetVideoSurface(); | 1067 CreateNextTextureAndSetVideoSurface(); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 1092 | 1097 |
| 1093 // Reconfirm exactly 1 seek request has been made of demuxer. | 1098 // Reconfirm exactly 1 seek request has been made of demuxer. |
| 1094 EXPECT_EQ(1, demuxer_->num_seek_requests()); | 1099 EXPECT_EQ(1, demuxer_->num_seek_requests()); |
| 1095 | 1100 |
| 1096 // Decoder is created after data is received. | 1101 // Decoder is created after data is received. |
| 1097 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForAudio(0)); | 1102 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForAudio(0)); |
| 1098 EXPECT_TRUE(GetMediaCodecBridge(true)); | 1103 EXPECT_TRUE(GetMediaCodecBridge(true)); |
| 1099 } | 1104 } |
| 1100 | 1105 |
| 1101 TEST_F(MediaSourcePlayerTest, VideoOnlyStartAfterSeekFinish) { | 1106 TEST_F(MediaSourcePlayerTest, VideoOnlyStartAfterSeekFinish) { |
| 1102 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); | 1107 // crbug.com/604602 and crbug.com/597836 |
| 1108 SKIP_TEST_IF_VP8_DECODER_IS_NOT_SUPPORTED(); |
| 1103 | 1109 |
| 1104 // Test video decoder job will not start until pending seek event is handled. | 1110 // Test video decoder job will not start until pending seek event is handled. |
| 1105 CreateNextTextureAndSetVideoSurface(); | 1111 CreateNextTextureAndSetVideoSurface(); |
| 1106 DemuxerConfigs configs = CreateVideoDemuxerConfigs(false); | 1112 DemuxerConfigs configs = CreateVideoDemuxerConfigs(false); |
| 1107 player_.OnDemuxerConfigsAvailable(configs); | 1113 player_.OnDemuxerConfigsAvailable(configs); |
| 1108 | 1114 |
| 1109 // Initiate a seek. Skip requesting element seek of renderer. | 1115 // Initiate a seek. Skip requesting element seek of renderer. |
| 1110 // Instead behave as if the renderer has asked us to seek. | 1116 // Instead behave as if the renderer has asked us to seek. |
| 1111 player_.SeekTo(base::TimeDelta()); | 1117 player_.SeekTo(base::TimeDelta()); |
| 1112 EXPECT_EQ(1, demuxer_->num_seek_requests()); | 1118 EXPECT_EQ(1, demuxer_->num_seek_requests()); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1154 EXPECT_EQ(decoder_job, GetMediaDecoderJob(true)); | 1160 EXPECT_EQ(decoder_job, GetMediaDecoderJob(true)); |
| 1155 | 1161 |
| 1156 while (GetMediaDecoderJob(true)->is_decoding()) | 1162 while (GetMediaDecoderJob(true)->is_decoding()) |
| 1157 message_loop_.RunUntilIdle(); | 1163 message_loop_.RunUntilIdle(); |
| 1158 // The decoder job should finish and wait for data. | 1164 // The decoder job should finish and wait for data. |
| 1159 EXPECT_EQ(2, demuxer_->num_data_requests()); | 1165 EXPECT_EQ(2, demuxer_->num_data_requests()); |
| 1160 EXPECT_TRUE(IsRequestingDemuxerData(true)); | 1166 EXPECT_TRUE(IsRequestingDemuxerData(true)); |
| 1161 } | 1167 } |
| 1162 | 1168 |
| 1163 TEST_F(MediaSourcePlayerTest, DecoderJobsCannotStartWithoutAudio) { | 1169 TEST_F(MediaSourcePlayerTest, DecoderJobsCannotStartWithoutAudio) { |
| 1164 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); | 1170 // crbug.com/604602 and crbug.com/597836 |
| 1171 SKIP_TEST_IF_VP8_DECODER_IS_NOT_SUPPORTED(); |
| 1165 | 1172 |
| 1166 // Test that when Start() is called, video decoder job will wait for audio | 1173 // Test that when Start() is called, video decoder job will wait for audio |
| 1167 // decoder job before start decoding the data. | 1174 // decoder job before start decoding the data. |
| 1168 CreateNextTextureAndSetVideoSurface(); | 1175 CreateNextTextureAndSetVideoSurface(); |
| 1169 Start(CreateAudioVideoDemuxerConfigs()); | 1176 Start(CreateAudioVideoDemuxerConfigs()); |
| 1170 MediaDecoderJob* audio_decoder_job = GetMediaDecoderJob(true); | 1177 MediaDecoderJob* audio_decoder_job = GetMediaDecoderJob(true); |
| 1171 MediaDecoderJob* video_decoder_job = GetMediaDecoderJob(false); | 1178 MediaDecoderJob* video_decoder_job = GetMediaDecoderJob(false); |
| 1172 | 1179 |
| 1173 EXPECT_FALSE(audio_decoder_job->is_decoding()); | 1180 EXPECT_FALSE(audio_decoder_job->is_decoding()); |
| 1174 EXPECT_FALSE(video_decoder_job->is_decoding()); | 1181 EXPECT_FALSE(video_decoder_job->is_decoding()); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1207 // Send new data to the decoder so it can finish prefetching. This should | 1214 // Send new data to the decoder so it can finish prefetching. This should |
| 1208 // reset the start time ticks. | 1215 // reset the start time ticks. |
| 1209 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForAudio(3)); | 1216 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForAudio(3)); |
| 1210 EXPECT_TRUE(StartTimeTicks() != previous); | 1217 EXPECT_TRUE(StartTimeTicks() != previous); |
| 1211 | 1218 |
| 1212 base::TimeTicks current = StartTimeTicks(); | 1219 base::TimeTicks current = StartTimeTicks(); |
| 1213 EXPECT_LE(0, (current - previous).InMillisecondsF()); | 1220 EXPECT_LE(0, (current - previous).InMillisecondsF()); |
| 1214 } | 1221 } |
| 1215 | 1222 |
| 1216 TEST_F(MediaSourcePlayerTest, V_SecondAccessUnitIsEOSAndResumePlayAfterSeek) { | 1223 TEST_F(MediaSourcePlayerTest, V_SecondAccessUnitIsEOSAndResumePlayAfterSeek) { |
| 1217 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); | 1224 // crbug.com/604602 and crbug.com/597836 |
| 1225 SKIP_TEST_IF_VP8_DECODER_IS_NOT_SUPPORTED(); |
| 1218 | 1226 |
| 1219 // Test MediaSourcePlayer can replay video after input EOS is reached. | 1227 // Test MediaSourcePlayer can replay video after input EOS is reached. |
| 1220 CreateNextTextureAndSetVideoSurface(); | 1228 CreateNextTextureAndSetVideoSurface(); |
| 1221 StartVideoDecoderJob(); | 1229 StartVideoDecoderJob(); |
| 1222 | 1230 |
| 1223 // Send the first input chunk. | 1231 // Send the first input chunk. |
| 1224 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForVideo(false)); | 1232 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForVideo(false)); |
| 1225 WaitForVideoDecodeDone(); | 1233 WaitForVideoDecodeDone(); |
| 1226 | 1234 |
| 1227 VerifyPlaybackCompletesOnEOSDecode(true, false); | 1235 VerifyPlaybackCompletesOnEOSDecode(true, false); |
| 1228 VerifyCompletedPlaybackResumesOnSeekPlusStart(false, true); | 1236 VerifyCompletedPlaybackResumesOnSeekPlusStart(false, true); |
| 1229 } | 1237 } |
| 1230 | 1238 |
| 1231 TEST_F(MediaSourcePlayerTest, A_FirstAccessUnitIsEOSAndResumePlayAfterSeek) { | 1239 TEST_F(MediaSourcePlayerTest, A_FirstAccessUnitIsEOSAndResumePlayAfterSeek) { |
| 1232 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); | 1240 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); |
| 1233 | 1241 |
| 1234 // Test decode of audio EOS buffer without any prior decode. See also | 1242 // Test decode of audio EOS buffer without any prior decode. See also |
| 1235 // http://b/11696552. | 1243 // http://b/11696552. |
| 1236 // Also tests that seeking+Start() after completing audio playback resumes | 1244 // Also tests that seeking+Start() after completing audio playback resumes |
| 1237 // playback. | 1245 // playback. |
| 1238 Start(CreateAudioDemuxerConfigs(kCodecAAC, false)); | 1246 Start(CreateAudioDemuxerConfigs(kCodecAAC, false)); |
| 1239 VerifyPlaybackCompletesOnEOSDecode(true, true); | 1247 VerifyPlaybackCompletesOnEOSDecode(true, true); |
| 1240 VerifyCompletedPlaybackResumesOnSeekPlusStart(true, false); | 1248 VerifyCompletedPlaybackResumesOnSeekPlusStart(true, false); |
| 1241 } | 1249 } |
| 1242 | 1250 |
| 1243 TEST_F(MediaSourcePlayerTest, V_FirstAccessUnitAfterSeekIsEOS) { | 1251 TEST_F(MediaSourcePlayerTest, V_FirstAccessUnitAfterSeekIsEOS) { |
| 1244 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); | 1252 // crbug.com/604602 and crbug.com/597836 |
| 1253 SKIP_TEST_IF_VP8_DECODER_IS_NOT_SUPPORTED(); |
| 1245 | 1254 |
| 1246 // Test decode of video EOS buffer, just after seeking, without any prior | 1255 // Test decode of video EOS buffer, just after seeking, without any prior |
| 1247 // decode (other than the simulated |kAborted| resulting from the seek | 1256 // decode (other than the simulated |kAborted| resulting from the seek |
| 1248 // process.) | 1257 // process.) |
| 1249 CreateNextTextureAndSetVideoSurface(); | 1258 CreateNextTextureAndSetVideoSurface(); |
| 1250 StartVideoDecoderJob(); | 1259 StartVideoDecoderJob(); |
| 1251 SeekPlayerWithAbort(false, base::TimeDelta()); | 1260 SeekPlayerWithAbort(false, base::TimeDelta()); |
| 1252 VerifyPlaybackCompletesOnEOSDecode(true, false); | 1261 VerifyPlaybackCompletesOnEOSDecode(true, false); |
| 1253 } | 1262 } |
| 1254 | 1263 |
| 1255 TEST_F(MediaSourcePlayerTest, A_FirstAccessUnitAfterSeekIsEOS) { | 1264 TEST_F(MediaSourcePlayerTest, A_FirstAccessUnitAfterSeekIsEOS) { |
| 1256 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); | 1265 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); |
| 1257 | 1266 |
| 1258 // Test decode of audio EOS buffer, just after seeking, without any prior | 1267 // Test decode of audio EOS buffer, just after seeking, without any prior |
| 1259 // decode (other than the simulated |kAborted| resulting from the seek | 1268 // decode (other than the simulated |kAborted| resulting from the seek |
| 1260 // process.) See also http://b/11696552. | 1269 // process.) See also http://b/11696552. |
| 1261 Start(CreateAudioDemuxerConfigs(kCodecAAC, false)); | 1270 Start(CreateAudioDemuxerConfigs(kCodecAAC, false)); |
| 1262 SeekPlayerWithAbort(true, base::TimeDelta()); | 1271 SeekPlayerWithAbort(true, base::TimeDelta()); |
| 1263 VerifyPlaybackCompletesOnEOSDecode(true, true); | 1272 VerifyPlaybackCompletesOnEOSDecode(true, true); |
| 1264 } | 1273 } |
| 1265 | 1274 |
| 1266 TEST_F(MediaSourcePlayerTest, AV_PlaybackCompletionAcrossConfigChange) { | 1275 TEST_F(MediaSourcePlayerTest, AV_PlaybackCompletionAcrossConfigChange) { |
| 1267 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); | 1276 // crbug.com/604602 and crbug.com/597836 |
| 1277 SKIP_TEST_IF_VP8_DECODER_IS_NOT_SUPPORTED(); |
| 1268 | 1278 |
| 1269 // Test that if one stream (audio) has completed decode of EOS and the other | 1279 // Test that if one stream (audio) has completed decode of EOS and the other |
| 1270 // stream (video) processes config change, that subsequent video EOS completes | 1280 // stream (video) processes config change, that subsequent video EOS completes |
| 1271 // A/V playback. | 1281 // A/V playback. |
| 1272 // Also tests that seeking+Start() after completing playback resumes playback. | 1282 // Also tests that seeking+Start() after completing playback resumes playback. |
| 1273 CreateNextTextureAndSetVideoSurface(); | 1283 CreateNextTextureAndSetVideoSurface(); |
| 1274 Start(CreateAudioVideoDemuxerConfigs()); | 1284 Start(CreateAudioVideoDemuxerConfigs()); |
| 1275 | 1285 |
| 1276 player_.OnDemuxerDataAvailable(CreateEOSAck(true)); // Audio EOS | 1286 player_.OnDemuxerDataAvailable(CreateEOSAck(true)); // Audio EOS |
| 1277 DemuxerConfigs configs = CreateVideoDemuxerConfigs(true); | 1287 DemuxerConfigs configs = CreateVideoDemuxerConfigs(true); |
| 1278 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckWithConfigChanged( | 1288 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckWithConfigChanged( |
| 1279 false, 0, configs)); // Video |kConfigChanged| as first unit. | 1289 false, 0, configs)); // Video |kConfigChanged| as first unit. |
| 1280 | 1290 |
| 1281 WaitForAudioVideoDecodeDone(); | 1291 WaitForAudioVideoDecodeDone(); |
| 1282 | 1292 |
| 1283 EXPECT_EQ(3, demuxer_->num_data_requests()); | 1293 EXPECT_EQ(3, demuxer_->num_data_requests()); |
| 1284 | 1294 |
| 1285 // At no time after completing audio EOS decode, above, should the | 1295 // At no time after completing audio EOS decode, above, should the |
| 1286 // audio decoder job resume decoding. Send and decode video EOS. | 1296 // audio decoder job resume decoding. Send and decode video EOS. |
| 1287 VerifyPlaybackCompletesOnEOSDecode(true, false); | 1297 VerifyPlaybackCompletesOnEOSDecode(true, false); |
| 1288 VerifyCompletedPlaybackResumesOnSeekPlusStart(true, true); | 1298 VerifyCompletedPlaybackResumesOnSeekPlusStart(true, true); |
| 1289 } | 1299 } |
| 1290 | 1300 |
| 1291 TEST_F(MediaSourcePlayerTest, VA_PlaybackCompletionAcrossConfigChange) { | 1301 TEST_F(MediaSourcePlayerTest, VA_PlaybackCompletionAcrossConfigChange) { |
| 1292 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); | 1302 // crbug.com/604602 and crbug.com/597836 |
| 1303 SKIP_TEST_IF_VP8_DECODER_IS_NOT_SUPPORTED(); |
| 1293 | 1304 |
| 1294 // Test that if one stream (video) has completed decode of EOS and the other | 1305 // Test that if one stream (video) has completed decode of EOS and the other |
| 1295 // stream (audio) processes config change, that subsequent audio EOS completes | 1306 // stream (audio) processes config change, that subsequent audio EOS completes |
| 1296 // A/V playback. | 1307 // A/V playback. |
| 1297 // Also tests that seeking+Start() after completing playback resumes playback. | 1308 // Also tests that seeking+Start() after completing playback resumes playback. |
| 1298 CreateNextTextureAndSetVideoSurface(); | 1309 CreateNextTextureAndSetVideoSurface(); |
| 1299 Start(CreateAudioVideoDemuxerConfigs()); | 1310 Start(CreateAudioVideoDemuxerConfigs()); |
| 1300 | 1311 |
| 1301 player_.OnDemuxerDataAvailable(CreateEOSAck(false)); // Video EOS | 1312 player_.OnDemuxerDataAvailable(CreateEOSAck(false)); // Video EOS |
| 1302 // Audio |kConfigChanged| as first unit. | 1313 // Audio |kConfigChanged| as first unit. |
| 1303 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckWithConfigChanged( | 1314 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckWithConfigChanged( |
| 1304 true, 0, CreateAudioDemuxerConfigs(kCodecVorbis, false))); | 1315 true, 0, CreateAudioDemuxerConfigs(kCodecVorbis, false))); |
| 1305 | 1316 |
| 1306 WaitForAudioVideoDecodeDone(); | 1317 WaitForAudioVideoDecodeDone(); |
| 1307 | 1318 |
| 1308 EXPECT_EQ(3, demuxer_->num_data_requests()); | 1319 EXPECT_EQ(3, demuxer_->num_data_requests()); |
| 1309 | 1320 |
| 1310 // At no time after completing video EOS decode, above, should the | 1321 // At no time after completing video EOS decode, above, should the |
| 1311 // video decoder job resume decoding. Send and decode audio EOS. | 1322 // video decoder job resume decoding. Send and decode audio EOS. |
| 1312 VerifyPlaybackCompletesOnEOSDecode(true, true); | 1323 VerifyPlaybackCompletesOnEOSDecode(true, true); |
| 1313 VerifyCompletedPlaybackResumesOnSeekPlusStart(true, true); | 1324 VerifyCompletedPlaybackResumesOnSeekPlusStart(true, true); |
| 1314 } | 1325 } |
| 1315 | 1326 |
| 1316 TEST_F(MediaSourcePlayerTest, AV_NoPrefetchForFinishedVideoOnAudioStarvation) { | 1327 TEST_F(MediaSourcePlayerTest, AV_NoPrefetchForFinishedVideoOnAudioStarvation) { |
| 1317 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); | 1328 // crbug.com/604602 and crbug.com/597836 |
| 1329 SKIP_TEST_IF_VP8_DECODER_IS_NOT_SUPPORTED(); |
| 1318 | 1330 |
| 1319 // Test that if one stream (video) has completed decode of EOS, prefetch | 1331 // Test that if one stream (video) has completed decode of EOS, prefetch |
| 1320 // resulting from player starvation occurs only for the other stream (audio), | 1332 // resulting from player starvation occurs only for the other stream (audio), |
| 1321 // and responding to that prefetch with EOS completes A/V playback, even if | 1333 // and responding to that prefetch with EOS completes A/V playback, even if |
| 1322 // another starvation occurs during the latter EOS's decode. | 1334 // another starvation occurs during the latter EOS's decode. |
| 1323 CreateNextTextureAndSetVideoSurface(); | 1335 CreateNextTextureAndSetVideoSurface(); |
| 1324 Start(CreateAudioVideoDemuxerConfigs()); | 1336 Start(CreateAudioVideoDemuxerConfigs()); |
| 1325 | 1337 |
| 1326 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForAudio(0)); | 1338 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForAudio(0)); |
| 1327 player_.OnDemuxerDataAvailable(CreateEOSAck(false)); // Video EOS | 1339 player_.OnDemuxerDataAvailable(CreateEOSAck(false)); // Video EOS |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1344 player_.OnDemuxerDataAvailable(CreateEOSAck(true)); // Audio EOS | 1356 player_.OnDemuxerDataAvailable(CreateEOSAck(true)); // Audio EOS |
| 1345 EXPECT_FALSE(GetMediaDecoderJob(false)->is_decoding()); | 1357 EXPECT_FALSE(GetMediaDecoderJob(false)->is_decoding()); |
| 1346 EXPECT_TRUE(GetMediaDecoderJob(true)->is_decoding()); | 1358 EXPECT_TRUE(GetMediaDecoderJob(true)->is_decoding()); |
| 1347 | 1359 |
| 1348 // Simulate another decoder underrun to trigger prefetch while decoding EOS. | 1360 // Simulate another decoder underrun to trigger prefetch while decoding EOS. |
| 1349 TriggerPlayerStarvation(); | 1361 TriggerPlayerStarvation(); |
| 1350 VerifyPlaybackCompletesOnEOSDecode(false, true /* ignored */); | 1362 VerifyPlaybackCompletesOnEOSDecode(false, true /* ignored */); |
| 1351 } | 1363 } |
| 1352 | 1364 |
| 1353 TEST_F(MediaSourcePlayerTest, V_StarvationDuringEOSDecode) { | 1365 TEST_F(MediaSourcePlayerTest, V_StarvationDuringEOSDecode) { |
| 1354 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); | 1366 // crbug.com/604602 and crbug.com/597836 |
| 1367 SKIP_TEST_IF_VP8_DECODER_IS_NOT_SUPPORTED(); |
| 1355 | 1368 |
| 1356 // Test that video-only playback completes without further data requested when | 1369 // Test that video-only playback completes without further data requested when |
| 1357 // starvation occurs during EOS decode. | 1370 // starvation occurs during EOS decode. |
| 1358 CreateNextTextureAndSetVideoSurface(); | 1371 CreateNextTextureAndSetVideoSurface(); |
| 1359 StartVideoDecoderJob(); | 1372 StartVideoDecoderJob(); |
| 1360 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForVideo(false)); | 1373 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForVideo(false)); |
| 1361 WaitForVideoDecodeDone(); | 1374 WaitForVideoDecodeDone(); |
| 1362 | 1375 |
| 1363 // Simulate decoder underrun to trigger prefetch while decoding EOS. | 1376 // Simulate decoder underrun to trigger prefetch while decoding EOS. |
| 1364 player_.OnDemuxerDataAvailable(CreateEOSAck(false)); // Video EOS | 1377 player_.OnDemuxerDataAvailable(CreateEOSAck(false)); // Video EOS |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1377 WaitForAudioDecodeDone(); | 1390 WaitForAudioDecodeDone(); |
| 1378 | 1391 |
| 1379 // Simulate decoder underrun to trigger prefetch while decoding EOS. | 1392 // Simulate decoder underrun to trigger prefetch while decoding EOS. |
| 1380 player_.OnDemuxerDataAvailable(CreateEOSAck(true)); // Audio EOS | 1393 player_.OnDemuxerDataAvailable(CreateEOSAck(true)); // Audio EOS |
| 1381 EXPECT_TRUE(GetMediaDecoderJob(true)->is_decoding()); | 1394 EXPECT_TRUE(GetMediaDecoderJob(true)->is_decoding()); |
| 1382 TriggerPlayerStarvation(); | 1395 TriggerPlayerStarvation(); |
| 1383 VerifyPlaybackCompletesOnEOSDecode(false, true /* ignored */); | 1396 VerifyPlaybackCompletesOnEOSDecode(false, true /* ignored */); |
| 1384 } | 1397 } |
| 1385 | 1398 |
| 1386 TEST_F(MediaSourcePlayerTest, AV_SeekDuringEOSDecodePreventsCompletion) { | 1399 TEST_F(MediaSourcePlayerTest, AV_SeekDuringEOSDecodePreventsCompletion) { |
| 1387 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); | 1400 // crbug.com/604602 and crbug.com/597836 |
| 1401 SKIP_TEST_IF_VP8_DECODER_IS_NOT_SUPPORTED(); |
| 1388 | 1402 |
| 1389 // Test that seek supercedes audio+video playback completion on simultaneous | 1403 // Test that seek supercedes audio+video playback completion on simultaneous |
| 1390 // audio and video EOS decode, if SeekTo() occurs during these EOS decodes. | 1404 // audio and video EOS decode, if SeekTo() occurs during these EOS decodes. |
| 1391 VerifySeekDuringEOSDecodePreventsPlaybackCompletion(true, true, true, true); | 1405 VerifySeekDuringEOSDecodePreventsPlaybackCompletion(true, true, true, true); |
| 1392 } | 1406 } |
| 1393 | 1407 |
| 1394 TEST_F(MediaSourcePlayerTest, AV_SeekDuringAudioEOSDecodePreventsCompletion) { | 1408 TEST_F(MediaSourcePlayerTest, AV_SeekDuringAudioEOSDecodePreventsCompletion) { |
| 1395 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); | 1409 // crbug.com/604602 and crbug.com/597836 |
| 1410 SKIP_TEST_IF_VP8_DECODER_IS_NOT_SUPPORTED(); |
| 1396 | 1411 |
| 1397 // Test that seek supercedes audio+video playback completion on simultaneous | 1412 // Test that seek supercedes audio+video playback completion on simultaneous |
| 1398 // audio EOS and video non-EOS decode, if SeekTo() occurs during these | 1413 // audio EOS and video non-EOS decode, if SeekTo() occurs during these |
| 1399 // decodes. | 1414 // decodes. |
| 1400 VerifySeekDuringEOSDecodePreventsPlaybackCompletion(true, true, true, false); | 1415 VerifySeekDuringEOSDecodePreventsPlaybackCompletion(true, true, true, false); |
| 1401 } | 1416 } |
| 1402 | 1417 |
| 1403 TEST_F(MediaSourcePlayerTest, AV_SeekDuringVideoEOSDecodePreventsCompletion) { | 1418 TEST_F(MediaSourcePlayerTest, AV_SeekDuringVideoEOSDecodePreventsCompletion) { |
| 1404 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); | 1419 // crbug.com/604602 and crbug.com/597836 |
| 1420 SKIP_TEST_IF_VP8_DECODER_IS_NOT_SUPPORTED(); |
| 1405 | 1421 |
| 1406 // Test that seek supercedes audio+video playback completion on simultaneous | 1422 // Test that seek supercedes audio+video playback completion on simultaneous |
| 1407 // audio non-EOS and video EOS decode, if SeekTo() occurs during these | 1423 // audio non-EOS and video EOS decode, if SeekTo() occurs during these |
| 1408 // decodes. | 1424 // decodes. |
| 1409 VerifySeekDuringEOSDecodePreventsPlaybackCompletion(true, true, false, true); | 1425 VerifySeekDuringEOSDecodePreventsPlaybackCompletion(true, true, false, true); |
| 1410 } | 1426 } |
| 1411 | 1427 |
| 1412 TEST_F(MediaSourcePlayerTest, V_SeekDuringEOSDecodePreventsCompletion) { | 1428 TEST_F(MediaSourcePlayerTest, V_SeekDuringEOSDecodePreventsCompletion) { |
| 1413 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); | 1429 // crbug.com/604602 and crbug.com/597836 |
| 1430 SKIP_TEST_IF_VP8_DECODER_IS_NOT_SUPPORTED(); |
| 1414 | 1431 |
| 1415 // Test that seek supercedes video-only playback completion on EOS decode, if | 1432 // Test that seek supercedes video-only playback completion on EOS decode, if |
| 1416 // SeekTo() occurs during EOS decode. | 1433 // SeekTo() occurs during EOS decode. |
| 1417 VerifySeekDuringEOSDecodePreventsPlaybackCompletion(false, true, false, true); | 1434 VerifySeekDuringEOSDecodePreventsPlaybackCompletion(false, true, false, true); |
| 1418 } | 1435 } |
| 1419 | 1436 |
| 1420 TEST_F(MediaSourcePlayerTest, A_SeekDuringEOSDecodePreventsCompletion) { | 1437 TEST_F(MediaSourcePlayerTest, A_SeekDuringEOSDecodePreventsCompletion) { |
| 1421 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); | 1438 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); |
| 1422 | 1439 |
| 1423 // Test that seek supercedes audio-only playback completion on EOS decode, if | 1440 // Test that seek supercedes audio-only playback completion on EOS decode, if |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1458 EXPECT_FALSE(player_.IsPlaying()); | 1475 EXPECT_FALSE(player_.IsPlaying()); |
| 1459 | 1476 |
| 1460 // No further data should have been requested. | 1477 // No further data should have been requested. |
| 1461 EXPECT_EQ(1, demuxer_->num_data_requests()); | 1478 EXPECT_EQ(1, demuxer_->num_data_requests()); |
| 1462 | 1479 |
| 1463 // No seek requests should have occurred. | 1480 // No seek requests should have occurred. |
| 1464 EXPECT_EQ(0, demuxer_->num_seek_requests()); | 1481 EXPECT_EQ(0, demuxer_->num_seek_requests()); |
| 1465 } | 1482 } |
| 1466 | 1483 |
| 1467 TEST_F(MediaSourcePlayerTest, BrowserSeek_RegularSeekPendsBrowserSeekDone) { | 1484 TEST_F(MediaSourcePlayerTest, BrowserSeek_RegularSeekPendsBrowserSeekDone) { |
| 1468 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); | 1485 // crbug.com/604602 and crbug.com/597836 |
| 1486 SKIP_TEST_IF_VP8_DECODER_IS_NOT_SUPPORTED(); |
| 1469 | 1487 |
| 1470 // Test that a browser seek, once started, delays a newly arrived regular | 1488 // Test that a browser seek, once started, delays a newly arrived regular |
| 1471 // SeekTo() request's demuxer seek until the browser seek is done. | 1489 // SeekTo() request's demuxer seek until the browser seek is done. |
| 1472 BrowserSeekPlayer(false); | 1490 BrowserSeekPlayer(false); |
| 1473 | 1491 |
| 1474 // Simulate renderer requesting a regular seek while browser seek in progress. | 1492 // Simulate renderer requesting a regular seek while browser seek in progress. |
| 1475 player_.SeekTo(base::TimeDelta()); | 1493 player_.SeekTo(base::TimeDelta()); |
| 1476 | 1494 |
| 1477 // Simulate browser seek is done. Confirm player requests the regular seek, | 1495 // Simulate browser seek is done. Confirm player requests the regular seek, |
| 1478 // still has no video codec configured, and has not requested any | 1496 // still has no video codec configured, and has not requested any |
| 1479 // further data since the surface change event became pending in | 1497 // further data since the surface change event became pending in |
| 1480 // BrowserSeekPlayer(). | 1498 // BrowserSeekPlayer(). |
| 1481 EXPECT_EQ(1, demuxer_->num_seek_requests()); | 1499 EXPECT_EQ(1, demuxer_->num_seek_requests()); |
| 1482 player_.OnDemuxerSeekDone(base::TimeDelta()); | 1500 player_.OnDemuxerSeekDone(base::TimeDelta()); |
| 1483 EXPECT_EQ(2, demuxer_->num_seek_requests()); | 1501 EXPECT_EQ(2, demuxer_->num_seek_requests()); |
| 1484 EXPECT_EQ(1, demuxer_->num_browser_seek_requests()); | 1502 EXPECT_EQ(1, demuxer_->num_browser_seek_requests()); |
| 1485 | 1503 |
| 1486 // Simulate regular seek is done and confirm player requests more data for | 1504 // Simulate regular seek is done and confirm player requests more data for |
| 1487 // new video codec. | 1505 // new video codec. |
| 1488 player_.OnDemuxerSeekDone(kNoTimestamp()); | 1506 player_.OnDemuxerSeekDone(kNoTimestamp()); |
| 1489 EXPECT_FALSE(GetMediaCodecBridge(false)); | 1507 EXPECT_FALSE(GetMediaCodecBridge(false)); |
| 1490 EXPECT_EQ(3, demuxer_->num_data_requests()); | 1508 EXPECT_EQ(3, demuxer_->num_data_requests()); |
| 1491 EXPECT_EQ(2, demuxer_->num_seek_requests()); | 1509 EXPECT_EQ(2, demuxer_->num_seek_requests()); |
| 1492 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForVideo(false)); | 1510 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForVideo(false)); |
| 1493 EXPECT_TRUE(GetMediaCodecBridge(false)); | 1511 EXPECT_TRUE(GetMediaCodecBridge(false)); |
| 1494 WaitForVideoDecodeDone(); | 1512 WaitForVideoDecodeDone(); |
| 1495 } | 1513 } |
| 1496 | 1514 |
| 1497 TEST_F(MediaSourcePlayerTest, BrowserSeek_InitialReleaseAndStart) { | 1515 TEST_F(MediaSourcePlayerTest, BrowserSeek_InitialReleaseAndStart) { |
| 1498 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); | 1516 // crbug.com/604602 and crbug.com/597836 |
| 1517 SKIP_TEST_IF_VP8_DECODER_IS_NOT_SUPPORTED(); |
| 1499 | 1518 |
| 1500 // Test that no browser seek is requested if player Release() + Start() occurs | 1519 // Test that no browser seek is requested if player Release() + Start() occurs |
| 1501 // prior to receiving any data. | 1520 // prior to receiving any data. |
| 1502 CreateNextTextureAndSetVideoSurface(); | 1521 CreateNextTextureAndSetVideoSurface(); |
| 1503 StartVideoDecoderJob(); | 1522 StartVideoDecoderJob(); |
| 1504 ReleasePlayer(); | 1523 ReleasePlayer(); |
| 1505 | 1524 |
| 1506 // Pass a new non-empty surface. | 1525 // Pass a new non-empty surface. |
| 1507 CreateNextTextureAndSetVideoSurface(); | 1526 CreateNextTextureAndSetVideoSurface(); |
| 1508 | 1527 |
| 1509 player_.Start(); | 1528 player_.Start(); |
| 1510 | 1529 |
| 1511 // No data request is issued since there is still one pending. | 1530 // No data request is issued since there is still one pending. |
| 1512 EXPECT_EQ(1, demuxer_->num_data_requests()); | 1531 EXPECT_EQ(1, demuxer_->num_data_requests()); |
| 1513 EXPECT_FALSE(GetMediaCodecBridge(false)); | 1532 EXPECT_FALSE(GetMediaCodecBridge(false)); |
| 1514 | 1533 |
| 1515 // No browser seek is needed. | 1534 // No browser seek is needed. |
| 1516 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForVideo(false)); | 1535 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForVideo(false)); |
| 1517 EXPECT_EQ(0, demuxer_->num_browser_seek_requests()); | 1536 EXPECT_EQ(0, demuxer_->num_browser_seek_requests()); |
| 1518 EXPECT_EQ(2, demuxer_->num_data_requests()); | 1537 EXPECT_EQ(2, demuxer_->num_data_requests()); |
| 1519 WaitForVideoDecodeDone(); | 1538 WaitForVideoDecodeDone(); |
| 1520 } | 1539 } |
| 1521 | 1540 |
| 1522 TEST_F(MediaSourcePlayerTest, BrowserSeek_MidStreamReleaseAndStart) { | 1541 TEST_F(MediaSourcePlayerTest, BrowserSeek_MidStreamReleaseAndStart) { |
| 1523 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); | 1542 // crbug.com/604602 and crbug.com/597836 |
| 1543 SKIP_TEST_IF_VP8_DECODER_IS_NOT_SUPPORTED(); |
| 1524 | 1544 |
| 1525 // Test that one browser seek is requested if player Release() + Start(), with | 1545 // Test that one browser seek is requested if player Release() + Start(), with |
| 1526 // video data received between Release() and Start(). | 1546 // video data received between Release() and Start(). |
| 1527 BrowserSeekPlayer(true); | 1547 BrowserSeekPlayer(true); |
| 1528 | 1548 |
| 1529 // Simulate browser seek is done and confirm player requests more data. | 1549 // Simulate browser seek is done and confirm player requests more data. |
| 1530 player_.OnDemuxerSeekDone(base::TimeDelta()); | 1550 player_.OnDemuxerSeekDone(base::TimeDelta()); |
| 1531 EXPECT_EQ(3, demuxer_->num_data_requests()); | 1551 EXPECT_EQ(3, demuxer_->num_data_requests()); |
| 1532 EXPECT_EQ(1, demuxer_->num_seek_requests()); | 1552 EXPECT_EQ(1, demuxer_->num_seek_requests()); |
| 1533 } | 1553 } |
| 1534 | 1554 |
| 1535 TEST_F(MediaSourcePlayerTest, NoBrowserSeekWithKeyFrameInCache) { | 1555 TEST_F(MediaSourcePlayerTest, NoBrowserSeekWithKeyFrameInCache) { |
| 1536 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); | 1556 // crbug.com/604602 and crbug.com/597836 |
| 1557 SKIP_TEST_IF_VP8_DECODER_IS_NOT_SUPPORTED(); |
| 1537 | 1558 |
| 1538 // Test that browser seek is not needed if a key frame is found in data | 1559 // Test that browser seek is not needed if a key frame is found in data |
| 1539 // cache. | 1560 // cache. |
| 1540 CreateNextTextureAndSetVideoSurface(); | 1561 CreateNextTextureAndSetVideoSurface(); |
| 1541 StartVideoDecoderJob(); | 1562 StartVideoDecoderJob(); |
| 1542 DemuxerData data = CreateReadFromDemuxerAckForVideo(false); | 1563 DemuxerData data = CreateReadFromDemuxerAckForVideo(false); |
| 1543 data.access_units[0].is_key_frame = true; | 1564 data.access_units[0].is_key_frame = true; |
| 1544 | 1565 |
| 1545 // Simulate demuxer's response to the video data request. | 1566 // Simulate demuxer's response to the video data request. |
| 1546 player_.OnDemuxerDataAvailable(data); | 1567 player_.OnDemuxerDataAvailable(data); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1566 // Test decoder job will preroll the media to the seek position. | 1587 // Test decoder job will preroll the media to the seek position. |
| 1567 StartAudioDecoderJob(); | 1588 StartAudioDecoderJob(); |
| 1568 | 1589 |
| 1569 SeekPlayerWithAbort(true, base::TimeDelta::FromMilliseconds(100)); | 1590 SeekPlayerWithAbort(true, base::TimeDelta::FromMilliseconds(100)); |
| 1570 EXPECT_TRUE(IsPrerolling(true)); | 1591 EXPECT_TRUE(IsPrerolling(true)); |
| 1571 PrerollDecoderToTime( | 1592 PrerollDecoderToTime( |
| 1572 true, base::TimeDelta(), base::TimeDelta::FromMilliseconds(100), true); | 1593 true, base::TimeDelta(), base::TimeDelta::FromMilliseconds(100), true); |
| 1573 } | 1594 } |
| 1574 | 1595 |
| 1575 TEST_F(MediaSourcePlayerTest, PrerollVideoAfterSeek) { | 1596 TEST_F(MediaSourcePlayerTest, PrerollVideoAfterSeek) { |
| 1576 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); | 1597 // crbug.com/604602 and crbug.com/597836 |
| 1598 SKIP_TEST_IF_VP8_DECODER_IS_NOT_SUPPORTED(); |
| 1577 | 1599 |
| 1578 // Test decoder job will preroll the media to the seek position. | 1600 // Test decoder job will preroll the media to the seek position. |
| 1579 CreateNextTextureAndSetVideoSurface(); | 1601 CreateNextTextureAndSetVideoSurface(); |
| 1580 StartVideoDecoderJob(); | 1602 StartVideoDecoderJob(); |
| 1581 | 1603 |
| 1582 SeekPlayerWithAbort(false, base::TimeDelta::FromMilliseconds(100)); | 1604 SeekPlayerWithAbort(false, base::TimeDelta::FromMilliseconds(100)); |
| 1583 EXPECT_TRUE(IsPrerolling(false)); | 1605 EXPECT_TRUE(IsPrerolling(false)); |
| 1584 PrerollDecoderToTime( | 1606 PrerollDecoderToTime( |
| 1585 false, base::TimeDelta(), base::TimeDelta::FromMilliseconds(100), true); | 1607 false, base::TimeDelta(), base::TimeDelta::FromMilliseconds(100), true); |
| 1586 } | 1608 } |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1710 // In response to data request, simulate that demuxer signals config change by | 1732 // In response to data request, simulate that demuxer signals config change by |
| 1711 // sending an AU with |kConfigChanged|. | 1733 // sending an AU with |kConfigChanged|. |
| 1712 DemuxerData data = CreateReadFromDemuxerAckWithConfigChanged( | 1734 DemuxerData data = CreateReadFromDemuxerAckWithConfigChanged( |
| 1713 true, 0, configs); | 1735 true, 0, configs); |
| 1714 player_.OnDemuxerDataAvailable(data); | 1736 player_.OnDemuxerDataAvailable(data); |
| 1715 PrerollDecoderToTime( | 1737 PrerollDecoderToTime( |
| 1716 true, base::TimeDelta(), base::TimeDelta::FromMilliseconds(100), true); | 1738 true, base::TimeDelta(), base::TimeDelta::FromMilliseconds(100), true); |
| 1717 } | 1739 } |
| 1718 | 1740 |
| 1719 TEST_F(MediaSourcePlayerTest, AudioPrerollFinishesBeforeVideo) { | 1741 TEST_F(MediaSourcePlayerTest, AudioPrerollFinishesBeforeVideo) { |
| 1720 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); | 1742 // crbug.com/604602 and crbug.com/597836 |
| 1743 SKIP_TEST_IF_VP8_DECODER_IS_NOT_SUPPORTED(); |
| 1721 | 1744 |
| 1722 // Test that after audio finishes prerolling, it will wait for video to finish | 1745 // Test that after audio finishes prerolling, it will wait for video to finish |
| 1723 // prerolling before advancing together. | 1746 // prerolling before advancing together. |
| 1724 CreateNextTextureAndSetVideoSurface(); | 1747 CreateNextTextureAndSetVideoSurface(); |
| 1725 Start(CreateAudioVideoDemuxerConfigs()); | 1748 Start(CreateAudioVideoDemuxerConfigs()); |
| 1726 | 1749 |
| 1727 // Initiate a seek. | 1750 // Initiate a seek. |
| 1728 base::TimeDelta seek_position = base::TimeDelta::FromMilliseconds(100); | 1751 base::TimeDelta seek_position = base::TimeDelta::FromMilliseconds(100); |
| 1729 player_.SeekTo(seek_position); | 1752 player_.SeekTo(seek_position); |
| 1730 player_.OnDemuxerDataAvailable(CreateAbortedAck(true)); | 1753 player_.OnDemuxerDataAvailable(CreateAbortedAck(true)); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1762 EXPECT_FALSE(IsPrerolling(false)); | 1785 EXPECT_FALSE(IsPrerolling(false)); |
| 1763 | 1786 |
| 1764 // Both audio and video decoders should start decoding again. | 1787 // Both audio and video decoders should start decoding again. |
| 1765 player_.OnDemuxerDataAvailable(audio_data); | 1788 player_.OnDemuxerDataAvailable(audio_data); |
| 1766 player_.OnDemuxerDataAvailable(video_data); | 1789 player_.OnDemuxerDataAvailable(video_data); |
| 1767 EXPECT_TRUE(GetMediaDecoderJob(true)->is_decoding()); | 1790 EXPECT_TRUE(GetMediaDecoderJob(true)->is_decoding()); |
| 1768 EXPECT_TRUE(GetMediaDecoderJob(false)->is_decoding()); | 1791 EXPECT_TRUE(GetMediaDecoderJob(false)->is_decoding()); |
| 1769 } | 1792 } |
| 1770 | 1793 |
| 1771 TEST_F(MediaSourcePlayerTest, SimultaneousAudioVideoConfigChange) { | 1794 TEST_F(MediaSourcePlayerTest, SimultaneousAudioVideoConfigChange) { |
| 1772 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); | 1795 // crbug.com/604602 and crbug.com/597836 |
| 1796 SKIP_TEST_IF_VP8_DECODER_IS_NOT_SUPPORTED(); |
| 1773 | 1797 |
| 1774 // Test that the player allows simultaneous audio and video config change, | 1798 // Test that the player allows simultaneous audio and video config change, |
| 1775 // such as might occur during OnPrefetchDone() if next access unit for both | 1799 // such as might occur during OnPrefetchDone() if next access unit for both |
| 1776 // audio and video jobs is |kConfigChanged|. | 1800 // audio and video jobs is |kConfigChanged|. |
| 1777 CreateNextTextureAndSetVideoSurface(); | 1801 CreateNextTextureAndSetVideoSurface(); |
| 1778 Start(CreateAudioVideoDemuxerConfigs()); | 1802 Start(CreateAudioVideoDemuxerConfigs()); |
| 1779 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForAudio(0)); | 1803 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForAudio(0)); |
| 1780 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForVideo(false)); | 1804 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForVideo(false)); |
| 1781 EXPECT_TRUE(GetMediaCodecBridge(true)); | 1805 EXPECT_TRUE(GetMediaCodecBridge(true)); |
| 1782 EXPECT_TRUE(GetMediaCodecBridge(false)); | 1806 EXPECT_TRUE(GetMediaCodecBridge(false)); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1803 EXPECT_TRUE(IsDrainingDecoder(true)); | 1827 EXPECT_TRUE(IsDrainingDecoder(true)); |
| 1804 EXPECT_TRUE(IsDrainingDecoder(false)); | 1828 EXPECT_TRUE(IsDrainingDecoder(false)); |
| 1805 | 1829 |
| 1806 // Waiting for decoder to finish draining. | 1830 // Waiting for decoder to finish draining. |
| 1807 while (IsDrainingDecoder(true) || IsDrainingDecoder(false)) | 1831 while (IsDrainingDecoder(true) || IsDrainingDecoder(false)) |
| 1808 message_loop_.RunUntilIdle(); | 1832 message_loop_.RunUntilIdle(); |
| 1809 } | 1833 } |
| 1810 | 1834 |
| 1811 TEST_F(MediaSourcePlayerTest, | 1835 TEST_F(MediaSourcePlayerTest, |
| 1812 SimultaneousAudioVideoConfigChangeWithAdaptivePlayback) { | 1836 SimultaneousAudioVideoConfigChangeWithAdaptivePlayback) { |
| 1813 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); | 1837 // crbug.com/604602 and crbug.com/597836 |
| 1838 SKIP_TEST_IF_VP8_DECODER_IS_NOT_SUPPORTED(); |
| 1814 | 1839 |
| 1815 // Test that the player allows simultaneous audio and video config change with | 1840 // Test that the player allows simultaneous audio and video config change with |
| 1816 // adaptive video playback enabled. | 1841 // adaptive video playback enabled. |
| 1817 CreateNextTextureAndSetVideoSurface(); | 1842 CreateNextTextureAndSetVideoSurface(); |
| 1818 Start(CreateAudioVideoDemuxerConfigs()); | 1843 Start(CreateAudioVideoDemuxerConfigs()); |
| 1819 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForAudio(0)); | 1844 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForAudio(0)); |
| 1820 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForVideo(false)); | 1845 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForVideo(false)); |
| 1821 EXPECT_EQ(4, demuxer_->num_data_requests()); | 1846 EXPECT_EQ(4, demuxer_->num_data_requests()); |
| 1822 EXPECT_TRUE(GetMediaCodecBridge(true)); | 1847 EXPECT_TRUE(GetMediaCodecBridge(true)); |
| 1823 EXPECT_TRUE(GetMediaCodecBridge(false)); | 1848 EXPECT_TRUE(GetMediaCodecBridge(false)); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1887 | 1912 |
| 1888 // Test that the player detects need for and requests demuxer configs if | 1913 // Test that the player detects need for and requests demuxer configs if |
| 1889 // the |kConfigChanged| unit is not the first unit in the set of units | 1914 // the |kConfigChanged| unit is not the first unit in the set of units |
| 1890 // received in OnDemuxerDataAvailable() from data requested ostensibly while | 1915 // received in OnDemuxerDataAvailable() from data requested ostensibly while |
| 1891 // not prefetching. | 1916 // not prefetching. |
| 1892 StartConfigChange(true, false, 1, false); | 1917 StartConfigChange(true, false, 1, false); |
| 1893 WaitForAudioDecodeDone(); | 1918 WaitForAudioDecodeDone(); |
| 1894 } | 1919 } |
| 1895 | 1920 |
| 1896 TEST_F(MediaSourcePlayerTest, BrowserSeek_PrerollAfterBrowserSeek) { | 1921 TEST_F(MediaSourcePlayerTest, BrowserSeek_PrerollAfterBrowserSeek) { |
| 1897 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); | 1922 // crbug.com/604602 and crbug.com/597836 |
| 1923 SKIP_TEST_IF_VP8_DECODER_IS_NOT_SUPPORTED(); |
| 1898 | 1924 |
| 1899 // Test decoder job will preroll the media to the actual seek position | 1925 // Test decoder job will preroll the media to the actual seek position |
| 1900 // resulting from a browser seek. | 1926 // resulting from a browser seek. |
| 1901 BrowserSeekPlayer(false); | 1927 BrowserSeekPlayer(false); |
| 1902 | 1928 |
| 1903 // Simulate browser seek is done, but to a later time than was requested. | 1929 // Simulate browser seek is done, but to a later time than was requested. |
| 1904 EXPECT_LT(player_.GetCurrentTime().InMillisecondsF(), 100); | 1930 EXPECT_LT(player_.GetCurrentTime().InMillisecondsF(), 100); |
| 1905 player_.OnDemuxerSeekDone(base::TimeDelta::FromMilliseconds(100)); | 1931 player_.OnDemuxerSeekDone(base::TimeDelta::FromMilliseconds(100)); |
| 1906 // Because next AU is not I-frame, MediaCodecBridge will not be recreated. | 1932 // Because next AU is not I-frame, MediaCodecBridge will not be recreated. |
| 1907 EXPECT_FALSE(GetMediaCodecBridge(false)); | 1933 EXPECT_FALSE(GetMediaCodecBridge(false)); |
| 1908 EXPECT_EQ(100.0, player_.GetCurrentTime().InMillisecondsF()); | 1934 EXPECT_EQ(100.0, player_.GetCurrentTime().InMillisecondsF()); |
| 1909 EXPECT_EQ(100.0, GetPrerollTimestamp().InMillisecondsF()); | 1935 EXPECT_EQ(100.0, GetPrerollTimestamp().InMillisecondsF()); |
| 1910 EXPECT_EQ(3, demuxer_->num_data_requests()); | 1936 EXPECT_EQ(3, demuxer_->num_data_requests()); |
| 1911 | 1937 |
| 1912 PrerollDecoderToTime( | 1938 PrerollDecoderToTime( |
| 1913 false, base::TimeDelta(), base::TimeDelta::FromMilliseconds(100), true); | 1939 false, base::TimeDelta(), base::TimeDelta::FromMilliseconds(100), true); |
| 1914 } | 1940 } |
| 1915 | 1941 |
| 1916 TEST_F(MediaSourcePlayerTest, VideoDemuxerConfigChange) { | 1942 TEST_F(MediaSourcePlayerTest, VideoDemuxerConfigChange) { |
| 1917 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); | 1943 // crbug.com/604602 and crbug.com/597836 |
| 1944 SKIP_TEST_IF_VP8_DECODER_IS_NOT_SUPPORTED(); |
| 1918 | 1945 |
| 1919 // Test that video config change notification results in creating a new | 1946 // Test that video config change notification results in creating a new |
| 1920 // video codec without any browser seek. | 1947 // video codec without any browser seek. |
| 1921 StartConfigChange(false, true, 1, false); | 1948 StartConfigChange(false, true, 1, false); |
| 1922 | 1949 |
| 1923 // New video codec should have been created and configured, without any | 1950 // New video codec should have been created and configured, without any |
| 1924 // browser seek. | 1951 // browser seek. |
| 1925 EXPECT_TRUE(GetMediaCodecBridge(false)); | 1952 EXPECT_TRUE(GetMediaCodecBridge(false)); |
| 1926 EXPECT_EQ(3, demuxer_->num_data_requests()); | 1953 EXPECT_EQ(3, demuxer_->num_data_requests()); |
| 1927 EXPECT_EQ(0, demuxer_->num_seek_requests()); | 1954 EXPECT_EQ(0, demuxer_->num_seek_requests()); |
| 1928 WaitForVideoDecodeDone(); | 1955 WaitForVideoDecodeDone(); |
| 1929 } | 1956 } |
| 1930 | 1957 |
| 1931 TEST_F(MediaSourcePlayerTest, VideoDemuxerConfigChangeWithAdaptivePlayback) { | 1958 TEST_F(MediaSourcePlayerTest, VideoDemuxerConfigChangeWithAdaptivePlayback) { |
| 1932 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); | 1959 // crbug.com/604602 and crbug.com/597836 |
| 1960 SKIP_TEST_IF_VP8_DECODER_IS_NOT_SUPPORTED(); |
| 1933 | 1961 |
| 1934 // Test that if codec supports adaptive playback, no new codec should be | 1962 // Test that if codec supports adaptive playback, no new codec should be |
| 1935 // created beyond the one used to decode the prefetch media data prior to | 1963 // created beyond the one used to decode the prefetch media data prior to |
| 1936 // the kConfigChanged. | 1964 // the kConfigChanged. |
| 1937 StartConfigChange(false, true, 1, true); | 1965 StartConfigChange(false, true, 1, true); |
| 1938 | 1966 |
| 1939 // No browser seek should be needed. | 1967 // No browser seek should be needed. |
| 1940 EXPECT_TRUE(GetMediaCodecBridge(false)); | 1968 EXPECT_TRUE(GetMediaCodecBridge(false)); |
| 1941 EXPECT_EQ(3, demuxer_->num_data_requests()); | 1969 EXPECT_EQ(3, demuxer_->num_data_requests()); |
| 1942 EXPECT_EQ(0, demuxer_->num_seek_requests()); | 1970 EXPECT_EQ(0, demuxer_->num_seek_requests()); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1975 | 2003 |
| 1976 EXPECT_FALSE(GetMediaCodecBridge(true)); | 2004 EXPECT_FALSE(GetMediaCodecBridge(true)); |
| 1977 EXPECT_FALSE(player_.IsPlaying()); | 2005 EXPECT_FALSE(player_.IsPlaying()); |
| 1978 | 2006 |
| 1979 player_.Start(); | 2007 player_.Start(); |
| 1980 EXPECT_TRUE(player_.IsPlaying()); | 2008 EXPECT_TRUE(player_.IsPlaying()); |
| 1981 EXPECT_EQ(3, demuxer_->num_data_requests()); | 2009 EXPECT_EQ(3, demuxer_->num_data_requests()); |
| 1982 } | 2010 } |
| 1983 | 2011 |
| 1984 TEST_F(MediaSourcePlayerTest, DecoderDrainInterruptedBySurfaceChange) { | 2012 TEST_F(MediaSourcePlayerTest, DecoderDrainInterruptedBySurfaceChange) { |
| 1985 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); | 2013 // crbug.com/604602 and crbug.com/597836 |
| 2014 SKIP_TEST_IF_VP8_DECODER_IS_NOT_SUPPORTED(); |
| 1986 | 2015 |
| 1987 // Test if a video decoder is being drained while surface changes, draining | 2016 // Test if a video decoder is being drained while surface changes, draining |
| 1988 // is canceled. | 2017 // is canceled. |
| 1989 SendConfigChangeToDecoder(false, false, 0, false); | 2018 SendConfigChangeToDecoder(false, false, 0, false); |
| 1990 EXPECT_TRUE(IsDrainingDecoder(false)); | 2019 EXPECT_TRUE(IsDrainingDecoder(false)); |
| 1991 | 2020 |
| 1992 CreateNextTextureAndSetVideoSurface(); | 2021 CreateNextTextureAndSetVideoSurface(); |
| 1993 WaitForVideoDecodeDone(); | 2022 WaitForVideoDecodeDone(); |
| 1994 | 2023 |
| 1995 EXPECT_FALSE(IsDrainingDecoder(false)); | 2024 EXPECT_FALSE(IsDrainingDecoder(false)); |
| 1996 EXPECT_TRUE(player_.IsPlaying()); | 2025 EXPECT_TRUE(player_.IsPlaying()); |
| 1997 | 2026 |
| 1998 // The frame after the config change should always be an iframe, so no browser | 2027 // The frame after the config change should always be an iframe, so no browser |
| 1999 // seek is needed when recreating the video decoder due to surface change. | 2028 // seek is needed when recreating the video decoder due to surface change. |
| 2000 EXPECT_TRUE(GetMediaCodecBridge(false)); | 2029 EXPECT_TRUE(GetMediaCodecBridge(false)); |
| 2001 EXPECT_EQ(4, demuxer_->num_data_requests()); | 2030 EXPECT_EQ(4, demuxer_->num_data_requests()); |
| 2002 EXPECT_EQ(0, demuxer_->num_seek_requests()); | 2031 EXPECT_EQ(0, demuxer_->num_seek_requests()); |
| 2003 } | 2032 } |
| 2004 | 2033 |
| 2005 TEST_F(MediaSourcePlayerTest, | 2034 TEST_F(MediaSourcePlayerTest, |
| 2006 BrowserSeek_DecoderStarvationWhilePendingSurfaceChange) { | 2035 BrowserSeek_DecoderStarvationWhilePendingSurfaceChange) { |
| 2007 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); | 2036 // crbug.com/604602 and crbug.com/597836 |
| 2037 SKIP_TEST_IF_VP8_DECODER_IS_NOT_SUPPORTED(); |
| 2008 | 2038 |
| 2009 // Test video decoder starvation while handling a pending surface change | 2039 // Test video decoder starvation while handling a pending surface change |
| 2010 // should not cause any crashes. | 2040 // should not cause any crashes. |
| 2011 CreateNextTextureAndSetVideoSurface(); | 2041 CreateNextTextureAndSetVideoSurface(); |
| 2012 StartVideoDecoderJob(); | 2042 StartVideoDecoderJob(); |
| 2013 DemuxerData data = CreateReadFromDemuxerAckForVideo(false); | 2043 DemuxerData data = CreateReadFromDemuxerAckForVideo(false); |
| 2014 player_.OnDemuxerDataAvailable(data); | 2044 player_.OnDemuxerDataAvailable(data); |
| 2015 | 2045 |
| 2016 // Trigger a surface change and decoder starvation. | 2046 // Trigger a surface change and decoder starvation. |
| 2017 CreateNextTextureAndSetVideoSurface(); | 2047 CreateNextTextureAndSetVideoSurface(); |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2206 | 2236 |
| 2207 // Player should resume upon Start(), even without further configs supplied. | 2237 // Player should resume upon Start(), even without further configs supplied. |
| 2208 player_.Start(); | 2238 player_.Start(); |
| 2209 EXPECT_TRUE(player_.IsPlaying()); | 2239 EXPECT_TRUE(player_.IsPlaying()); |
| 2210 EXPECT_EQ(3, demuxer_->num_data_requests()); | 2240 EXPECT_EQ(3, demuxer_->num_data_requests()); |
| 2211 EXPECT_EQ(0, demuxer_->num_seek_requests()); | 2241 EXPECT_EQ(0, demuxer_->num_seek_requests()); |
| 2212 WaitForAudioDecodeDone(); | 2242 WaitForAudioDecodeDone(); |
| 2213 } | 2243 } |
| 2214 | 2244 |
| 2215 TEST_F(MediaSourcePlayerTest, BrowserSeek_ThenReleaseThenDemuxerSeekDone) { | 2245 TEST_F(MediaSourcePlayerTest, BrowserSeek_ThenReleaseThenDemuxerSeekDone) { |
| 2216 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); | 2246 // crbug.com/604602 and crbug.com/597836 |
| 2247 SKIP_TEST_IF_VP8_DECODER_IS_NOT_SUPPORTED(); |
| 2217 | 2248 |
| 2218 // Test that Release() after a browser seek's DemuxerSeek IPC request has been | 2249 // Test that Release() after a browser seek's DemuxerSeek IPC request has been |
| 2219 // sent behaves similar to a regular seek: if OnDemuxerSeekDone() occurs | 2250 // sent behaves similar to a regular seek: if OnDemuxerSeekDone() occurs |
| 2220 // before the next Start()+SetVideoSurface(), then the player will resume | 2251 // before the next Start()+SetVideoSurface(), then the player will resume |
| 2221 // correct post-seek preroll upon Start()+SetVideoSurface(). | 2252 // correct post-seek preroll upon Start()+SetVideoSurface(). |
| 2222 BrowserSeekPlayer(false); | 2253 BrowserSeekPlayer(false); |
| 2223 base::TimeDelta expected_preroll_timestamp = player_.GetCurrentTime(); | 2254 base::TimeDelta expected_preroll_timestamp = player_.GetCurrentTime(); |
| 2224 ReleasePlayer(); | 2255 ReleasePlayer(); |
| 2225 | 2256 |
| 2226 player_.OnDemuxerSeekDone(expected_preroll_timestamp); | 2257 player_.OnDemuxerSeekDone(expected_preroll_timestamp); |
| 2227 EXPECT_FALSE(player_.IsPlaying()); | 2258 EXPECT_FALSE(player_.IsPlaying()); |
| 2228 EXPECT_FALSE(GetMediaCodecBridge(false)); | 2259 EXPECT_FALSE(GetMediaCodecBridge(false)); |
| 2229 EXPECT_EQ(expected_preroll_timestamp, GetPrerollTimestamp()); | 2260 EXPECT_EQ(expected_preroll_timestamp, GetPrerollTimestamp()); |
| 2230 | 2261 |
| 2231 // Player should begin prefetch and resume preroll upon Start(). | 2262 // Player should begin prefetch and resume preroll upon Start(). |
| 2232 EXPECT_EQ(2, demuxer_->num_data_requests()); | 2263 EXPECT_EQ(2, demuxer_->num_data_requests()); |
| 2233 CreateNextTextureAndSetVideoSurface(); | 2264 CreateNextTextureAndSetVideoSurface(); |
| 2234 Resume(false, true); | 2265 Resume(false, true); |
| 2235 EXPECT_TRUE(IsPrerolling(false)); | 2266 EXPECT_TRUE(IsPrerolling(false)); |
| 2236 EXPECT_EQ(expected_preroll_timestamp, GetPrerollTimestamp()); | 2267 EXPECT_EQ(expected_preroll_timestamp, GetPrerollTimestamp()); |
| 2237 EXPECT_EQ(expected_preroll_timestamp, player_.GetCurrentTime()); | 2268 EXPECT_EQ(expected_preroll_timestamp, player_.GetCurrentTime()); |
| 2238 | 2269 |
| 2239 // No further seek should have been requested since BrowserSeekPlayer(). | 2270 // No further seek should have been requested since BrowserSeekPlayer(). |
| 2240 EXPECT_EQ(1, demuxer_->num_seek_requests()); | 2271 EXPECT_EQ(1, demuxer_->num_seek_requests()); |
| 2241 } | 2272 } |
| 2242 | 2273 |
| 2243 TEST_F(MediaSourcePlayerTest, BrowserSeek_ThenReleaseThenStart) { | 2274 TEST_F(MediaSourcePlayerTest, BrowserSeek_ThenReleaseThenStart) { |
| 2244 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); | 2275 // crbug.com/604602 and crbug.com/597836 |
| 2276 SKIP_TEST_IF_VP8_DECODER_IS_NOT_SUPPORTED(); |
| 2245 | 2277 |
| 2246 // Test that Release() after a browser seek's DemuxerSeek IPC request has been | 2278 // Test that Release() after a browser seek's DemuxerSeek IPC request has been |
| 2247 // sent behaves similar to a regular seek: if OnDemuxerSeekDone() does not | 2279 // sent behaves similar to a regular seek: if OnDemuxerSeekDone() does not |
| 2248 // occur until after the next Start()+SetVideoSurface(), then the player | 2280 // occur until after the next Start()+SetVideoSurface(), then the player |
| 2249 // remains pending seek done until (and resumes correct post-seek preroll | 2281 // remains pending seek done until (and resumes correct post-seek preroll |
| 2250 // after) OnDemuxerSeekDone(). | 2282 // after) OnDemuxerSeekDone(). |
| 2251 BrowserSeekPlayer(false); | 2283 BrowserSeekPlayer(false); |
| 2252 base::TimeDelta expected_preroll_timestamp = player_.GetCurrentTime(); | 2284 base::TimeDelta expected_preroll_timestamp = player_.GetCurrentTime(); |
| 2253 ReleasePlayer(); | 2285 ReleasePlayer(); |
| 2254 | 2286 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2320 | 2352 |
| 2321 DemuxerConfigs configs = CreateAudioDemuxerConfigs(kCodecVorbis, true); | 2353 DemuxerConfigs configs = CreateAudioDemuxerConfigs(kCodecVorbis, true); |
| 2322 DemuxerData data = CreateReadFromDemuxerAckWithConfigChanged( | 2354 DemuxerData data = CreateReadFromDemuxerAckWithConfigChanged( |
| 2323 true, 0, configs); | 2355 true, 0, configs); |
| 2324 player_.OnDemuxerDataAvailable(data); | 2356 player_.OnDemuxerDataAvailable(data); |
| 2325 WaitForAudioDecodeDone(); | 2357 WaitForAudioDecodeDone(); |
| 2326 DecodeAudioDataUntilOutputBecomesAvailable(); | 2358 DecodeAudioDataUntilOutputBecomesAvailable(); |
| 2327 } | 2359 } |
| 2328 | 2360 |
| 2329 TEST_F(MediaSourcePlayerTest, VideoMetadataChangeAfterConfigChange) { | 2361 TEST_F(MediaSourcePlayerTest, VideoMetadataChangeAfterConfigChange) { |
| 2330 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); | 2362 // crbug.com/604602 and crbug.com/597836 |
| 2363 SKIP_TEST_IF_VP8_DECODER_IS_NOT_SUPPORTED(); |
| 2331 | 2364 |
| 2332 // Test that after a config change, metadata change will be happen | 2365 // Test that after a config change, metadata change will be happen |
| 2333 // after decoder is drained. | 2366 // after decoder is drained. |
| 2334 StartConfigChange(false, true, 2, false); | 2367 StartConfigChange(false, true, 2, false); |
| 2335 EXPECT_EQ(1, manager_.num_metadata_changes()); | 2368 EXPECT_EQ(1, manager_.num_metadata_changes()); |
| 2336 EXPECT_FALSE(IsDrainingDecoder(false)); | 2369 EXPECT_FALSE(IsDrainingDecoder(false)); |
| 2337 | 2370 |
| 2338 // Create video data with new resolutions. | 2371 // Create video data with new resolutions. |
| 2339 DemuxerData data = CreateReadFromDemuxerAckForVideo(true); | 2372 DemuxerData data = CreateReadFromDemuxerAckForVideo(true); |
| 2340 | 2373 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2385 | 2418 |
| 2386 EXPECT_EQ(demuxer_->num_data_requests(), 0); | 2419 EXPECT_EQ(demuxer_->num_data_requests(), 0); |
| 2387 player_.OnDemuxerConfigsAvailable(CreateDemuxerConfigs(true, true)); | 2420 player_.OnDemuxerConfigsAvailable(CreateDemuxerConfigs(true, true)); |
| 2388 | 2421 |
| 2389 manager_.set_allow_play(true); | 2422 manager_.set_allow_play(true); |
| 2390 player_.Start(); | 2423 player_.Start(); |
| 2391 EXPECT_TRUE(player_.IsPlaying()); | 2424 EXPECT_TRUE(player_.IsPlaying()); |
| 2392 } | 2425 } |
| 2393 | 2426 |
| 2394 } // namespace media | 2427 } // namespace media |
| OLD | NEW |