Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(127)

Side by Side Diff: media/base/android/media_source_player_unittest.cc

Issue 311313006: Fix some MSE tests on devices that don't support VP9 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: removing the codec input param since it is always vp8 Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/logging.h" 8 #include "base/logging.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 EXPECT_EQ(audio_codec, kCodecAAC); 278 EXPECT_EQ(audio_codec, kCodecAAC);
279 279
280 configs.audio_sampling_rate = 48000; 280 configs.audio_sampling_rate = 48000;
281 uint8 aac_extra_data[] = { 0x13, 0x10 }; 281 uint8 aac_extra_data[] = { 0x13, 0x10 };
282 configs.audio_extra_data = std::vector<uint8>( 282 configs.audio_extra_data = std::vector<uint8>(
283 aac_extra_data, 283 aac_extra_data,
284 aac_extra_data + 2); 284 aac_extra_data + 2);
285 return configs; 285 return configs;
286 } 286 }
287 287
288 DemuxerConfigs CreateVideoDemuxerConfigs(VideoCodec video_codec) { 288 DemuxerConfigs CreateVideoDemuxerConfigs(const gfx::Size& size) {
wolenetz 2014/06/05 20:06:47 nit: parallel the "bool use_low_sample_rate" audio
qinmin 2014/06/05 20:42:12 Done.
289 DemuxerConfigs configs; 289 DemuxerConfigs configs;
290 configs.video_codec = video_codec; 290 configs.video_codec = kCodecVP8;
291 configs.video_size = gfx::Size(320, 240); 291 configs.video_size = size;
292 configs.is_video_encrypted = false; 292 configs.is_video_encrypted = false;
293 configs.duration = kDefaultDuration; 293 configs.duration = kDefaultDuration;
294 return configs; 294 return configs;
295 } 295 }
296 296
297 DemuxerConfigs CreateAudioVideoDemuxerConfigs() { 297 DemuxerConfigs CreateAudioVideoDemuxerConfigs() {
298 DemuxerConfigs configs = CreateAudioDemuxerConfigs(kCodecVorbis, false); 298 DemuxerConfigs configs = CreateAudioDemuxerConfigs(kCodecVorbis, false);
299 configs.video_codec = kCodecVP8; 299 configs.video_codec = kCodecVP8;
300 configs.video_size = gfx::Size(320, 240); 300 configs.video_size = gfx::Size(320, 240);
301 configs.is_video_encrypted = false; 301 configs.is_video_encrypted = false;
302 return configs; 302 return configs;
303 } 303 }
304 304
305 DemuxerConfigs CreateDemuxerConfigs(bool have_audio, bool have_video) { 305 DemuxerConfigs CreateDemuxerConfigs(bool have_audio, bool have_video) {
306 DCHECK(have_audio || have_video); 306 DCHECK(have_audio || have_video);
307 307
308 if (have_audio && !have_video) 308 if (have_audio && !have_video)
309 return CreateAudioDemuxerConfigs(kCodecVorbis, false); 309 return CreateAudioDemuxerConfigs(kCodecVorbis, false);
310 310
311 if (have_video && !have_audio) 311 if (have_video && !have_audio)
312 return CreateVideoDemuxerConfigs(kCodecVP8); 312 return CreateVideoDemuxerConfigs(gfx::Size(320, 240));
313 313
314 return CreateAudioVideoDemuxerConfigs(); 314 return CreateAudioVideoDemuxerConfigs();
315 } 315 }
316 316
317 // Starts an audio decoder job. 317 // Starts an audio decoder job.
318 void StartAudioDecoderJob() { 318 void StartAudioDecoderJob() {
319 Start(CreateAudioDemuxerConfigs(kCodecVorbis, false)); 319 Start(CreateAudioDemuxerConfigs(kCodecVorbis, false));
320 } 320 }
321 321
322 // Starts a video decoder job. 322 // Starts a video decoder job.
323 void StartVideoDecoderJob() { 323 void StartVideoDecoderJob() {
324 Start(CreateVideoDemuxerConfigs(kCodecVP8)); 324 Start(CreateVideoDemuxerConfigs(gfx::Size(320, 240)));
325 } 325 }
326 326
327 // Starts decoding the data. 327 // Starts decoding the data.
328 void Start(const DemuxerConfigs& configs) { 328 void Start(const DemuxerConfigs& configs) {
329 EXPECT_EQ(demuxer_->num_data_requests(), 0); 329 EXPECT_EQ(demuxer_->num_data_requests(), 0);
330 player_.OnDemuxerConfigsAvailable(configs); 330 player_.OnDemuxerConfigsAvailable(configs);
331 player_.Start(); 331 player_.Start();
332 332
333 EXPECT_TRUE(player_.IsPlaying()); 333 EXPECT_TRUE(player_.IsPlaying());
334 int expected_num_requests = (player_.HasAudio() ? 1 : 0) + 334 int expected_num_requests = (player_.HasAudio() ? 1 : 0) +
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
637 637
638 WaitForDecodeDone(is_audio, !is_audio); 638 WaitForDecodeDone(is_audio, !is_audio);
639 639
640 // We should have completed the prefetch phase at this point. 640 // We should have completed the prefetch phase at this point.
641 expected_num_data_requests++; 641 expected_num_data_requests++;
642 EXPECT_EQ(expected_num_data_requests, demuxer_->num_data_requests()); 642 EXPECT_EQ(expected_num_data_requests, demuxer_->num_data_requests());
643 } 643 }
644 644
645 DemuxerConfigs configs = is_audio ? 645 DemuxerConfigs configs = is_audio ?
646 CreateAudioDemuxerConfigs(kCodecAAC, false) : 646 CreateAudioDemuxerConfigs(kCodecAAC, false) :
647 CreateVideoDemuxerConfigs(kCodecVP9); 647 CreateVideoDemuxerConfigs(gfx::Size(640, 480));
648 // Feed and decode access units with data for any units prior to 648 // Feed and decode access units with data for any units prior to
649 // |config_unit_index|, and a |kConfigChanged| unit at that index. 649 // |config_unit_index|, and a |kConfigChanged| unit at that index.
650 // Player should prepare to reconfigure the decoder job, and should request 650 // Player should prepare to reconfigure the decoder job, and should request
651 // new demuxer configs. 651 // new demuxer configs.
652 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckWithConfigChanged( 652 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckWithConfigChanged(
653 is_audio, config_unit_index, configs)); 653 is_audio, config_unit_index, configs));
654 654
655 expected_num_data_requests++; 655 expected_num_data_requests++;
656 EXPECT_EQ(expected_num_data_requests, demuxer_->num_data_requests()); 656 EXPECT_EQ(expected_num_data_requests, demuxer_->num_data_requests());
657 if (is_audio) 657 if (is_audio)
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
909 // Test decoder job will resend a ReadFromDemuxer request after seek. 909 // Test decoder job will resend a ReadFromDemuxer request after seek.
910 StartAudioDecoderJob(); 910 StartAudioDecoderJob();
911 SeekPlayerWithAbort(true, base::TimeDelta()); 911 SeekPlayerWithAbort(true, base::TimeDelta());
912 } 912 }
913 913
914 TEST_F(MediaSourcePlayerTest, SetSurfaceWhileSeeking) { 914 TEST_F(MediaSourcePlayerTest, SetSurfaceWhileSeeking) {
915 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); 915 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE();
916 916
917 // Test SetVideoSurface() will not cause an extra seek while the player is 917 // Test SetVideoSurface() will not cause an extra seek while the player is
918 // waiting for demuxer to indicate seek is done. 918 // waiting for demuxer to indicate seek is done.
919 player_.OnDemuxerConfigsAvailable(CreateVideoDemuxerConfigs(kCodecVP8)); 919 player_.OnDemuxerConfigsAvailable(
920 CreateVideoDemuxerConfigs(gfx::Size(320, 240)));
920 921
921 // Initiate a seek. Skip requesting element seek of renderer. 922 // Initiate a seek. Skip requesting element seek of renderer.
922 // Instead behave as if the renderer has asked us to seek. 923 // Instead behave as if the renderer has asked us to seek.
923 player_.SeekTo(base::TimeDelta()); 924 player_.SeekTo(base::TimeDelta());
924 EXPECT_EQ(1, demuxer_->num_seek_requests()); 925 EXPECT_EQ(1, demuxer_->num_seek_requests());
925 926
926 CreateNextTextureAndSetVideoSurface(); 927 CreateNextTextureAndSetVideoSurface();
927 EXPECT_EQ(1, demuxer_->num_seek_requests()); 928 EXPECT_EQ(1, demuxer_->num_seek_requests());
928 player_.Start(); 929 player_.Start();
929 930
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
1066 // Decoder is created after data is received. 1067 // Decoder is created after data is received.
1067 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForAudio(0)); 1068 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForAudio(0));
1068 EXPECT_TRUE(GetMediaCodecBridge(true)); 1069 EXPECT_TRUE(GetMediaCodecBridge(true));
1069 } 1070 }
1070 1071
1071 TEST_F(MediaSourcePlayerTest, VideoOnlyStartAfterSeekFinish) { 1072 TEST_F(MediaSourcePlayerTest, VideoOnlyStartAfterSeekFinish) {
1072 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); 1073 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE();
1073 1074
1074 // Test video decoder job will not start until pending seek event is handled. 1075 // Test video decoder job will not start until pending seek event is handled.
1075 CreateNextTextureAndSetVideoSurface(); 1076 CreateNextTextureAndSetVideoSurface();
1076 DemuxerConfigs configs = CreateVideoDemuxerConfigs(kCodecVP8); 1077 DemuxerConfigs configs = CreateVideoDemuxerConfigs(gfx::Size(320, 240));
1077 player_.OnDemuxerConfigsAvailable(configs); 1078 player_.OnDemuxerConfigsAvailable(configs);
1078 1079
1079 // Initiate a seek. Skip requesting element seek of renderer. 1080 // Initiate a seek. Skip requesting element seek of renderer.
1080 // Instead behave as if the renderer has asked us to seek. 1081 // Instead behave as if the renderer has asked us to seek.
1081 player_.SeekTo(base::TimeDelta()); 1082 player_.SeekTo(base::TimeDelta());
1082 EXPECT_EQ(1, demuxer_->num_seek_requests()); 1083 EXPECT_EQ(1, demuxer_->num_seek_requests());
1083 1084
1084 player_.Start(); 1085 player_.Start();
1085 EXPECT_EQ(0, demuxer_->num_data_requests()); 1086 EXPECT_EQ(0, demuxer_->num_data_requests());
1086 1087
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
1235 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); 1236 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE();
1236 1237
1237 // Test that if one stream (audio) has completed decode of EOS and the other 1238 // Test that if one stream (audio) has completed decode of EOS and the other
1238 // stream (video) processes config change, that subsequent video EOS completes 1239 // stream (video) processes config change, that subsequent video EOS completes
1239 // A/V playback. 1240 // A/V playback.
1240 // Also tests that seeking+Start() after completing playback resumes playback. 1241 // Also tests that seeking+Start() after completing playback resumes playback.
1241 CreateNextTextureAndSetVideoSurface(); 1242 CreateNextTextureAndSetVideoSurface();
1242 Start(CreateAudioVideoDemuxerConfigs()); 1243 Start(CreateAudioVideoDemuxerConfigs());
1243 1244
1244 player_.OnDemuxerDataAvailable(CreateEOSAck(true)); // Audio EOS 1245 player_.OnDemuxerDataAvailable(CreateEOSAck(true)); // Audio EOS
1245 DemuxerConfigs configs = CreateVideoDemuxerConfigs(kCodecVP9); 1246 DemuxerConfigs configs = CreateVideoDemuxerConfigs(gfx::Size(640, 480));
1246 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckWithConfigChanged( 1247 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckWithConfigChanged(
1247 false, 0, configs)); // Video |kConfigChanged| as first unit. 1248 false, 0, configs)); // Video |kConfigChanged| as first unit.
1248 1249
1249 WaitForAudioVideoDecodeDone(); 1250 WaitForAudioVideoDecodeDone();
1250 1251
1251 EXPECT_EQ(3, demuxer_->num_data_requests()); 1252 EXPECT_EQ(3, demuxer_->num_data_requests());
1252 1253
1253 // At no time after completing audio EOS decode, above, should the 1254 // At no time after completing audio EOS decode, above, should the
1254 // audio decoder job resume decoding. Send and decode video EOS. 1255 // audio decoder job resume decoding. Send and decode video EOS.
1255 VerifyPlaybackCompletesOnEOSDecode(true, false); 1256 VerifyPlaybackCompletesOnEOSDecode(true, false);
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
1660 WaitForAudioVideoDecodeDone(); 1661 WaitForAudioVideoDecodeDone();
1661 1662
1662 // Simulate audio |kConfigChanged| prefetched as standalone access unit. 1663 // Simulate audio |kConfigChanged| prefetched as standalone access unit.
1663 DemuxerConfigs audio_configs = CreateAudioDemuxerConfigs(kCodecVorbis, true); 1664 DemuxerConfigs audio_configs = CreateAudioDemuxerConfigs(kCodecVorbis, true);
1664 player_.OnDemuxerDataAvailable( 1665 player_.OnDemuxerDataAvailable(
1665 CreateReadFromDemuxerAckWithConfigChanged(true, 0, audio_configs)); 1666 CreateReadFromDemuxerAckWithConfigChanged(true, 0, audio_configs));
1666 1667
1667 // Simulate video |kConfigChanged| prefetched as standalone access unit. 1668 // Simulate video |kConfigChanged| prefetched as standalone access unit.
1668 player_.OnDemuxerDataAvailable( 1669 player_.OnDemuxerDataAvailable(
1669 CreateReadFromDemuxerAckWithConfigChanged( 1670 CreateReadFromDemuxerAckWithConfigChanged(
1670 false, 0, CreateVideoDemuxerConfigs(kCodecVP9))); 1671 false, 0, CreateVideoDemuxerConfigs(gfx::Size(640, 480))));
1671 EXPECT_EQ(6, demuxer_->num_data_requests()); 1672 EXPECT_EQ(6, demuxer_->num_data_requests());
1672 EXPECT_TRUE(IsDrainingDecoder(true)); 1673 EXPECT_TRUE(IsDrainingDecoder(true));
1673 EXPECT_TRUE(IsDrainingDecoder(false)); 1674 EXPECT_TRUE(IsDrainingDecoder(false));
1674 1675
1675 // Waiting for decoder to finish draining. 1676 // Waiting for decoder to finish draining.
1676 while (IsDrainingDecoder(true) || IsDrainingDecoder(false)) 1677 while (IsDrainingDecoder(true) || IsDrainingDecoder(false))
1677 message_loop_.RunUntilIdle(); 1678 message_loop_.RunUntilIdle();
1678 } 1679 }
1679 1680
1680 TEST_F(MediaSourcePlayerTest, DemuxerConfigRequestedIfInPrefetchUnit0) { 1681 TEST_F(MediaSourcePlayerTest, DemuxerConfigRequestedIfInPrefetchUnit0) {
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
2084 // also verify that the job is successfully created if SetDrmBridge(), Start() 2085 // also verify that the job is successfully created if SetDrmBridge(), Start()
2085 // and eventually OnMediaCrypto() occur. This would increase test coverage of 2086 // and eventually OnMediaCrypto() occur. This would increase test coverage of
2086 // http://crbug.com/313470 and allow us to remove inspection of internal player 2087 // http://crbug.com/313470 and allow us to remove inspection of internal player
2087 // pending event state. See http://crbug.com/313860. 2088 // pending event state. See http://crbug.com/313860.
2088 TEST_F(MediaSourcePlayerTest, SurfaceChangeClearedEvenIfMediaCryptoAbsent) { 2089 TEST_F(MediaSourcePlayerTest, SurfaceChangeClearedEvenIfMediaCryptoAbsent) {
2089 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); 2090 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE();
2090 2091
2091 // Test that |SURFACE_CHANGE_EVENT_PENDING| is not pending after 2092 // Test that |SURFACE_CHANGE_EVENT_PENDING| is not pending after
2092 // SetVideoSurface() for a player configured for encrypted video, when the 2093 // SetVideoSurface() for a player configured for encrypted video, when the
2093 // player has not yet received media crypto. 2094 // player has not yet received media crypto.
2094 DemuxerConfigs configs = CreateVideoDemuxerConfigs(kCodecVP8); 2095 DemuxerConfigs configs = CreateVideoDemuxerConfigs(gfx::Size(320, 240));
2095 configs.is_video_encrypted = true; 2096 configs.is_video_encrypted = true;
2096 2097
2097 player_.OnDemuxerConfigsAvailable(configs); 2098 player_.OnDemuxerConfigsAvailable(configs);
2098 CreateNextTextureAndSetVideoSurface(); 2099 CreateNextTextureAndSetVideoSurface();
2099 EXPECT_FALSE(GetMediaCodecBridge(false)); 2100 EXPECT_FALSE(GetMediaCodecBridge(false));
2100 } 2101 }
2101 2102
2102 TEST_F(MediaSourcePlayerTest, CurrentTimeUpdatedWhileDecoderStarved) { 2103 TEST_F(MediaSourcePlayerTest, CurrentTimeUpdatedWhileDecoderStarved) {
2103 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); 2104 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE();
2104 2105
(...skipping 22 matching lines...) Expand all
2127 2128
2128 DemuxerConfigs configs = CreateAudioDemuxerConfigs(kCodecVorbis, true); 2129 DemuxerConfigs configs = CreateAudioDemuxerConfigs(kCodecVorbis, true);
2129 DemuxerData data = CreateReadFromDemuxerAckWithConfigChanged( 2130 DemuxerData data = CreateReadFromDemuxerAckWithConfigChanged(
2130 true, 0, configs); 2131 true, 0, configs);
2131 player_.OnDemuxerDataAvailable(data); 2132 player_.OnDemuxerDataAvailable(data);
2132 WaitForAudioDecodeDone(); 2133 WaitForAudioDecodeDone();
2133 DecodeAudioDataUntilOutputBecomesAvailable(); 2134 DecodeAudioDataUntilOutputBecomesAvailable();
2134 } 2135 }
2135 2136
2136 } // namespace media 2137 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698