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 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
358 EXPECT_FALSE(GetMediaDecoderJob(true)->is_decoding()); | 358 EXPECT_FALSE(GetMediaDecoderJob(true)->is_decoding()); |
359 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForAudio(0)); | 359 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForAudio(0)); |
360 EXPECT_TRUE(GetMediaDecoderJob(true)->is_decoding()); | 360 EXPECT_TRUE(GetMediaDecoderJob(true)->is_decoding()); |
361 player_.SeekTo(seek_time); | 361 player_.SeekTo(seek_time); |
362 EXPECT_EQ(0.0, GetPrerollTimestamp().InMillisecondsF()); | 362 EXPECT_EQ(0.0, GetPrerollTimestamp().InMillisecondsF()); |
363 EXPECT_EQ(1, demuxer_->num_data_requests()); | 363 EXPECT_EQ(1, demuxer_->num_data_requests()); |
364 EXPECT_EQ(0, demuxer_->num_seek_requests()); | 364 EXPECT_EQ(0, demuxer_->num_seek_requests()); |
365 } | 365 } |
366 | 366 |
367 // Seek, including simulated receipt of |kAborted| read between SeekTo() | 367 // Seek, including simulated receipt of |kAborted| read between SeekTo() |
368 // and OnDemuxerSeekDone(). Use this helper method only when the player | 368 // and OnDemuxerSeekDone() if |abort| is true. Use this helper method only |
369 // already has created the decoder job. | 369 // when the player already has created the decoder job. If |abort| is false, |
370 void SeekPlayer(bool is_audio, const base::TimeDelta& seek_time) { | 370 // |is_audio| is ignored. |expected_new_data_requests| is compared to the |
371 // actual increase in data request count due to the seek. | |
372 void SeekPlayer(bool is_audio, const base::TimeDelta& seek_time, bool abort, | |
373 int expected_new_data_requests) { | |
371 EXPECT_TRUE(GetMediaDecoderJob(is_audio)); | 374 EXPECT_TRUE(GetMediaDecoderJob(is_audio)); |
372 | 375 |
373 int original_num_seeks = demuxer_->num_seek_requests(); | 376 int original_num_seeks = demuxer_->num_seek_requests(); |
374 int original_num_data_requests = demuxer_->num_data_requests(); | 377 int original_num_data_requests = demuxer_->num_data_requests(); |
375 | 378 |
376 // Initiate a seek. Skip the round-trip of requesting seek from renderer. | 379 // Initiate a seek. Skip the round-trip of requesting seek from renderer. |
377 // Instead behave as if the renderer has asked us to seek. | 380 // Instead behave as if the renderer has asked us to seek. |
378 player_.SeekTo(seek_time); | 381 player_.SeekTo(seek_time); |
379 | 382 |
380 // Verify that the seek does not occur until previously outstanding data | 383 if (abort) { |
381 // request is satisfied. | 384 // Verify that the seek does not occur until previously outstanding data |
382 EXPECT_EQ(original_num_seeks, demuxer_->num_seek_requests()); | 385 // request is satisfied. |
386 EXPECT_EQ(original_num_seeks, demuxer_->num_seek_requests()); | |
383 | 387 |
384 // Simulate seeking causes the demuxer to abort the outstanding read caused | 388 // Simulate seeking causes the demuxer to abort the outstanding read |
385 // by the seek. | 389 // caused by the seek. |
386 player_.OnDemuxerDataAvailable(CreateAbortedAck(is_audio)); | 390 player_.OnDemuxerDataAvailable(CreateAbortedAck(is_audio)); |
391 } | |
387 | 392 |
388 // Verify that the seek is requested now that the outstanding read is | 393 // Verify that the seek is requested. |
389 // completed by aborted access unit. | |
390 EXPECT_EQ(original_num_seeks + 1, demuxer_->num_seek_requests()); | 394 EXPECT_EQ(original_num_seeks + 1, demuxer_->num_seek_requests()); |
391 | 395 |
392 // Send back the seek done notification. This should trigger the player to | 396 // Send back the seek done notification. This should trigger the player to |
393 // call OnReadFromDemuxer() again. | 397 // call OnReadFromDemuxer() again. |
394 EXPECT_EQ(original_num_data_requests, demuxer_->num_data_requests()); | 398 EXPECT_EQ(original_num_data_requests, demuxer_->num_data_requests()); |
395 player_.OnDemuxerSeekDone(kNoTimestamp()); | 399 player_.OnDemuxerSeekDone(kNoTimestamp()); |
396 EXPECT_EQ(original_num_data_requests + 1, demuxer_->num_data_requests()); | 400 EXPECT_EQ(original_num_data_requests + expected_new_data_requests, |
401 demuxer_->num_data_requests()); | |
397 | 402 |
398 // No other seek should have been requested. | 403 // No other seek should have been requested. |
399 EXPECT_EQ(original_num_seeks + 1, demuxer_->num_seek_requests()); | 404 EXPECT_EQ(original_num_seeks + 1, demuxer_->num_seek_requests()); |
400 } | 405 } |
401 | 406 |
402 DemuxerData CreateReadFromDemuxerAckWithConfigChanged(bool is_audio, | 407 DemuxerData CreateReadFromDemuxerAckWithConfigChanged(bool is_audio, |
403 int config_unit_index) { | 408 int config_unit_index) { |
404 DemuxerData data; | 409 DemuxerData data; |
405 data.type = is_audio ? DemuxerStream::AUDIO : DemuxerStream::VIDEO; | 410 data.type = is_audio ? DemuxerStream::AUDIO : DemuxerStream::VIDEO; |
406 data.access_units.resize(config_unit_index + 1); | 411 data.access_units.resize(config_unit_index + 1); |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
546 } else { | 551 } else { |
547 surface_texture_b_ = new gfx::SurfaceTexture(next_texture_id_++); | 552 surface_texture_b_ = new gfx::SurfaceTexture(next_texture_id_++); |
548 surface_texture = surface_texture_b_.get(); | 553 surface_texture = surface_texture_b_.get(); |
549 } | 554 } |
550 | 555 |
551 surface_texture_a_is_next_ = !surface_texture_a_is_next_; | 556 surface_texture_a_is_next_ = !surface_texture_a_is_next_; |
552 gfx::ScopedJavaSurface surface = gfx::ScopedJavaSurface(surface_texture); | 557 gfx::ScopedJavaSurface surface = gfx::ScopedJavaSurface(surface_texture); |
553 player_.SetVideoSurface(surface.Pass()); | 558 player_.SetVideoSurface(surface.Pass()); |
554 } | 559 } |
555 | 560 |
561 // Starts the appropriate decoder jobs according to |have_audio| and | |
562 // |have_video|. Then starts seek during decode of EOS or non-EOS according to | |
563 // |eos_audio| and |eos_video|. Simulates seek completion and verifies that | |
564 // playback never completed. | |
565 void SeekDuringEOSDecode(bool have_audio, bool have_video, | |
566 bool eos_audio, bool eos_video) { | |
567 EXPECT_TRUE(have_audio || have_video); | |
acolwell GONE FROM CHROMIUM
2013/12/06 18:28:30
These should be DCHECKs since these are verifying
wolenetz
2013/12/09 22:58:27
Done.
| |
568 EXPECT_TRUE(have_audio || !eos_audio); | |
569 EXPECT_TRUE(have_video || !eos_video); | |
570 | |
571 DemuxerConfigs configs; | |
572 int data_request_delta = 1; | |
573 if (have_audio && !have_video) { | |
574 configs = CreateAudioDemuxerConfigs(kCodecVorbis); | |
575 } else if (have_video && !have_audio) { | |
576 configs = CreateVideoDemuxerConfigs(); | |
577 } else { | |
578 configs = CreateAudioVideoDemuxerConfigs(); | |
579 data_request_delta = 2; | |
580 } | |
581 | |
582 if (have_video) | |
583 CreateNextTextureAndSetVideoSurface(); | |
584 Start(configs); | |
585 EXPECT_TRUE((GetMediaDecoderJob(true) != NULL) == have_audio && | |
586 (GetMediaDecoderJob(false) != NULL) == have_video); | |
587 EXPECT_EQ(data_request_delta, demuxer_->num_data_requests()); | |
588 | |
589 if (have_audio) | |
590 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForAudio(0)); | |
591 if (have_video) | |
592 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForVideo()); | |
593 for (int i = data_request_delta + 1; i <= 2 * data_request_delta; i++) { | |
594 message_loop_.Run(); // Loop Quit() occurs on each data request. | |
595 EXPECT_EQ(i, demuxer_->num_data_requests()); | |
596 } | |
597 | |
598 // Simulate seek while decoding EOS or non-EOS for the appropriate | |
599 // stream(s). | |
600 if (eos_audio) { | |
601 player_.OnDemuxerDataAvailable(CreateEOSAck(true)); | |
602 } else if (have_audio) { | |
603 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForAudio(1)); | |
604 } | |
605 if (eos_video) { | |
606 player_.OnDemuxerDataAvailable(CreateEOSAck(false)); | |
607 } else if (have_video) { | |
608 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForVideo()); | |
609 } | |
610 EXPECT_TRUE(!have_audio || GetMediaDecoderJob(true)->is_decoding()); | |
611 EXPECT_TRUE(!have_video || GetMediaDecoderJob(false)->is_decoding()); | |
612 player_.SeekTo(base::TimeDelta()); | |
613 EXPECT_EQ(0, demuxer_->num_seek_requests()); | |
614 while ((have_audio && GetMediaDecoderJob(true)->is_decoding()) || | |
615 (have_video && GetMediaDecoderJob(false)->is_decoding())) { | |
616 message_loop_.RunUntilIdle(); | |
617 } | |
618 | |
619 EXPECT_EQ(1, demuxer_->num_seek_requests()); | |
620 player_.OnDemuxerSeekDone(kNoTimestamp()); | |
621 EXPECT_EQ(3 * data_request_delta, demuxer_->num_data_requests()); | |
622 EXPECT_FALSE(manager_.playback_completed()); | |
623 } | |
624 | |
556 base::TimeTicks StartTimeTicks() { | 625 base::TimeTicks StartTimeTicks() { |
557 return player_.start_time_ticks_; | 626 return player_.start_time_ticks_; |
558 } | 627 } |
559 | 628 |
560 bool IsTypeSupported(const std::vector<uint8>& scheme_uuid, | 629 bool IsTypeSupported(const std::vector<uint8>& scheme_uuid, |
561 const std::string& security_level, | 630 const std::string& security_level, |
562 const std::string& container, | 631 const std::string& container, |
563 const std::vector<std::string>& codecs) { | 632 const std::vector<std::string>& codecs) { |
564 return MediaSourcePlayer::IsTypeSupported( | 633 return MediaSourcePlayer::IsTypeSupported( |
565 scheme_uuid, security_level, container, codecs); | 634 scheme_uuid, security_level, container, codecs); |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
666 EXPECT_EQ(0, demuxer_->num_data_requests()); | 735 EXPECT_EQ(0, demuxer_->num_data_requests()); |
667 } | 736 } |
668 | 737 |
669 TEST_F(MediaSourcePlayerTest, ReadFromDemuxerAfterSeek) { | 738 TEST_F(MediaSourcePlayerTest, ReadFromDemuxerAfterSeek) { |
670 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); | 739 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); |
671 | 740 |
672 // Test decoder job will resend a ReadFromDemuxer request after seek. | 741 // Test decoder job will resend a ReadFromDemuxer request after seek. |
673 StartAudioDecoderJob(); | 742 StartAudioDecoderJob(); |
674 EXPECT_TRUE(GetMediaDecoderJob(true)); | 743 EXPECT_TRUE(GetMediaDecoderJob(true)); |
675 EXPECT_EQ(1, demuxer_->num_data_requests()); | 744 EXPECT_EQ(1, demuxer_->num_data_requests()); |
676 SeekPlayer(true, base::TimeDelta()); | 745 SeekPlayer(true, base::TimeDelta(), true, 1); |
acolwell GONE FROM CHROMIUM
2013/12/06 18:28:30
nit: add and overload or default values so this ty
wolenetz
2013/12/09 22:58:27
Done.
Note http://google-styleguide.googlecode.com
| |
677 EXPECT_EQ(2, demuxer_->num_data_requests()); | 746 EXPECT_EQ(2, demuxer_->num_data_requests()); |
678 } | 747 } |
679 | 748 |
680 TEST_F(MediaSourcePlayerTest, SetSurfaceWhileSeeking) { | 749 TEST_F(MediaSourcePlayerTest, SetSurfaceWhileSeeking) { |
681 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); | 750 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); |
682 | 751 |
683 // Test SetVideoSurface() will not cause an extra seek while the player is | 752 // Test SetVideoSurface() will not cause an extra seek while the player is |
684 // waiting for demuxer to indicate seek is done. | 753 // waiting for demuxer to indicate seek is done. |
685 StartVideoDecoderJob(); | 754 StartVideoDecoderJob(); |
686 // Player is still waiting for SetVideoSurface(), so no request is sent. | 755 // Player is still waiting for SetVideoSurface(), so no request is sent. |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
910 | 979 |
911 // Send new data to the decoder so it can finish prefetching. This should | 980 // Send new data to the decoder so it can finish prefetching. This should |
912 // reset the start time ticks. | 981 // reset the start time ticks. |
913 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForAudio(3)); | 982 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForAudio(3)); |
914 EXPECT_TRUE(StartTimeTicks() != base::TimeTicks()); | 983 EXPECT_TRUE(StartTimeTicks() != base::TimeTicks()); |
915 | 984 |
916 base::TimeTicks current = StartTimeTicks(); | 985 base::TimeTicks current = StartTimeTicks(); |
917 EXPECT_LE(100.0, (current - previous).InMillisecondsF()); | 986 EXPECT_LE(100.0, (current - previous).InMillisecondsF()); |
918 } | 987 } |
919 | 988 |
920 TEST_F(MediaSourcePlayerTest, NoRequestForDataAfterInputEOS) { | 989 TEST_F(MediaSourcePlayerTest, SecondVideoDataIsEOSAndSeekPlusStartResumesPlay) { |
qinmin
2013/12/06 20:34:47
the test name is hard to understand. What about Se
wolenetz
2013/12/09 22:58:27
Done, using {A,V,AV,VA} prefixes across these new/
| |
921 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); | 990 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); |
922 | 991 |
923 // Test MediaSourcePlayer will not request for new data after input EOS is | 992 // Test MediaSourcePlayer can replay video after input EOS is reached. |
924 // reached. | |
925 CreateNextTextureAndSetVideoSurface(); | 993 CreateNextTextureAndSetVideoSurface(); |
926 StartVideoDecoderJob(); | 994 StartVideoDecoderJob(); |
995 | |
927 // Player should not seek the demuxer on setting initial surface. | 996 // Player should not seek the demuxer on setting initial surface. |
928 EXPECT_EQ(0, demuxer_->num_seek_requests()); | 997 EXPECT_EQ(0, demuxer_->num_seek_requests()); |
929 | 998 |
930 EXPECT_EQ(1, demuxer_->num_data_requests()); | 999 EXPECT_EQ(1, demuxer_->num_data_requests()); |
931 // Send the first input chunk. | 1000 // Send the first input chunk. |
932 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForVideo()); | 1001 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForVideo()); |
933 message_loop_.Run(); | 1002 message_loop_.Run(); |
934 EXPECT_EQ(2, demuxer_->num_data_requests()); | 1003 EXPECT_EQ(2, demuxer_->num_data_requests()); |
935 | 1004 |
936 // Send EOS. | 1005 // Send EOS. |
937 player_.OnDemuxerDataAvailable(CreateEOSAck(false)); | 1006 player_.OnDemuxerDataAvailable(CreateEOSAck(false)); |
938 message_loop_.Run(); | 1007 EXPECT_FALSE(manager_.playback_completed()); |
939 // No more request for data should be made. | 1008 message_loop_.Run(); |
940 EXPECT_EQ(2, demuxer_->num_data_requests()); | 1009 EXPECT_TRUE(manager_.playback_completed()); |
941 | 1010 EXPECT_EQ(2, demuxer_->num_data_requests()); |
942 // Reconfirm no seek request has occurred. | 1011 |
943 EXPECT_EQ(0, demuxer_->num_seek_requests()); | 1012 // Playback should resume with further data request following seek and start. |
944 } | 1013 SeekPlayer(false, base::TimeDelta(), false, 0); |
945 | |
946 TEST_F(MediaSourcePlayerTest, ReplayAfterInputEOS) { | |
947 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); | |
948 | |
949 // Test MediaSourcePlayer can replay after input EOS is | |
950 // reached. | |
951 CreateNextTextureAndSetVideoSurface(); | |
952 StartVideoDecoderJob(); | 1014 StartVideoDecoderJob(); |
953 | 1015 EXPECT_EQ(3, demuxer_->num_data_requests()); |
954 // Player should not seek the demuxer on setting initial surface. | 1016 } |
955 EXPECT_EQ(0, demuxer_->num_seek_requests()); | 1017 |
956 | 1018 TEST_F(MediaSourcePlayerTest, FirstAudioDataIsEOSAndSeekPlusStartResumesPlay) { |
957 EXPECT_EQ(1, demuxer_->num_data_requests()); | 1019 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); |
958 // Send the first input chunk. | 1020 |
959 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForVideo()); | 1021 // Test decode of audio EOS buffer without any prior decode. See also |
960 message_loop_.Run(); | |
961 EXPECT_EQ(2, demuxer_->num_data_requests()); | |
962 | |
963 // Send EOS. | |
964 player_.OnDemuxerDataAvailable(CreateEOSAck(false)); | |
965 message_loop_.Run(); | |
966 // No more request for data should be made. | |
967 EXPECT_EQ(2, demuxer_->num_data_requests()); | |
968 | |
969 // Initiate a seek. Skip requesting element seek of renderer. | |
970 // Instead behave as if the renderer has asked us to seek. | |
971 player_.SeekTo(base::TimeDelta()); | |
972 StartVideoDecoderJob(); | |
973 EXPECT_EQ(1, demuxer_->num_seek_requests()); | |
974 player_.OnDemuxerSeekDone(kNoTimestamp()); | |
975 // Seek/Play after EOS should request more data. | |
976 EXPECT_EQ(3, demuxer_->num_data_requests()); | |
977 | |
978 // Reconfirm only 1 seek request has occurred. | |
979 EXPECT_EQ(1, demuxer_->num_seek_requests()); | |
980 } | |
981 | |
982 TEST_F(MediaSourcePlayerTest, FirstDataIsEOS) { | |
983 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); | |
984 | |
985 // Test decode of EOS buffer without any prior decode. See also | |
986 // http://b/11696552. | 1022 // http://b/11696552. |
1023 // Also tests that seeking+Start() after completing audio playback resumes | |
1024 // playback. | |
987 Start(CreateAudioDemuxerConfigs(kCodecAAC)); | 1025 Start(CreateAudioDemuxerConfigs(kCodecAAC)); |
988 EXPECT_TRUE(GetMediaDecoderJob(true)); | 1026 EXPECT_TRUE(GetMediaDecoderJob(true)); |
989 | 1027 |
990 EXPECT_EQ(1, demuxer_->num_data_requests()); | 1028 EXPECT_EQ(1, demuxer_->num_data_requests()); |
991 player_.OnDemuxerDataAvailable(CreateEOSAck(true)); | 1029 player_.OnDemuxerDataAvailable(CreateEOSAck(true)); |
992 EXPECT_FALSE(manager_.playback_completed()); | 1030 EXPECT_FALSE(manager_.playback_completed()); |
993 | |
994 message_loop_.Run(); | 1031 message_loop_.Run(); |
995 EXPECT_TRUE(manager_.playback_completed()); | 1032 EXPECT_TRUE(manager_.playback_completed()); |
996 EXPECT_EQ(1, demuxer_->num_data_requests()); | 1033 EXPECT_EQ(1, demuxer_->num_data_requests()); |
997 } | 1034 |
998 | 1035 // Playback should resume with further data request following seek and start. |
999 TEST_F(MediaSourcePlayerTest, FirstDataAfterSeekIsEOS) { | 1036 SeekPlayer(true, base::TimeDelta(), false, 0); |
1000 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); | 1037 Start(CreateAudioDemuxerConfigs(kCodecAAC)); |
1001 | 1038 EXPECT_EQ(2, demuxer_->num_data_requests()); |
1002 // Test decode of EOS buffer, just after seeking, without any prior decode | 1039 } |
1003 // (other than the simulated |kAborted| resulting from the seek process.) | 1040 |
1004 // See also http://b/11696552. | 1041 TEST_F(MediaSourcePlayerTest, FirstVideoDataAfterSeekIsEOS) { |
1042 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); | |
1043 | |
1044 // Test decode of video EOS buffer, just after seeking, without any prior | |
1045 // decode (other than the simulated |kAborted| resulting from the seek | |
1046 // process.) | |
1047 CreateNextTextureAndSetVideoSurface(); | |
1048 StartVideoDecoderJob(); | |
1049 EXPECT_TRUE(GetMediaDecoderJob(false)); | |
1050 | |
1051 SeekPlayer(false, base::TimeDelta(), true, 1); | |
1052 EXPECT_EQ(2, demuxer_->num_data_requests()); | |
1053 player_.OnDemuxerDataAvailable(CreateEOSAck(false)); | |
1054 EXPECT_FALSE(manager_.playback_completed()); | |
1055 message_loop_.Run(); | |
1056 EXPECT_TRUE(manager_.playback_completed()); | |
1057 EXPECT_EQ(2, demuxer_->num_data_requests()); | |
1058 } | |
1059 | |
1060 TEST_F(MediaSourcePlayerTest, FirstAudioDataAfterSeekIsEOS) { | |
1061 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); | |
1062 | |
1063 // Test decode of audio EOS buffer, just after seeking, without any prior | |
1064 // decode (other than the simulated |kAborted| resulting from the seek | |
1065 // process.) See also http://b/11696552. | |
1005 Start(CreateAudioDemuxerConfigs(kCodecAAC)); | 1066 Start(CreateAudioDemuxerConfigs(kCodecAAC)); |
1006 EXPECT_TRUE(GetMediaDecoderJob(true)); | 1067 EXPECT_TRUE(GetMediaDecoderJob(true)); |
1007 | 1068 |
1008 SeekPlayer(true, base::TimeDelta()); | 1069 SeekPlayer(true, base::TimeDelta(), true, 1); |
1009 EXPECT_EQ(2, demuxer_->num_data_requests()); | 1070 EXPECT_EQ(2, demuxer_->num_data_requests()); |
1010 player_.OnDemuxerDataAvailable(CreateEOSAck(true)); | 1071 player_.OnDemuxerDataAvailable(CreateEOSAck(true)); |
1011 EXPECT_FALSE(manager_.playback_completed()); | 1072 EXPECT_FALSE(manager_.playback_completed()); |
1012 | 1073 message_loop_.Run(); |
1013 message_loop_.Run(); | 1074 EXPECT_TRUE(manager_.playback_completed()); |
1014 EXPECT_TRUE(manager_.playback_completed()); | 1075 EXPECT_EQ(2, demuxer_->num_data_requests()); |
1015 EXPECT_EQ(2, demuxer_->num_data_requests()); | 1076 } |
1077 | |
1078 TEST_F(MediaSourcePlayerTest, AV_PlaybackCompletionAcrossConfigChange) { | |
1079 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); | |
1080 | |
1081 // Test that if one stream (audio) has completed decode of EOS and the other | |
1082 // stream (video) processes config change, that subsequent video EOS completes | |
1083 // A/V playback. | |
1084 // Also tests that seeking+Start() after completing playback resumes playback. | |
1085 Start(CreateAudioVideoDemuxerConfigs()); | |
1086 CreateNextTextureAndSetVideoSurface(); | |
1087 EXPECT_TRUE(GetMediaDecoderJob(true) && GetMediaDecoderJob(false)); | |
1088 EXPECT_EQ(2, demuxer_->num_data_requests()); | |
1089 player_.OnDemuxerDataAvailable(CreateEOSAck(true)); // Audio EOS | |
1090 EXPECT_EQ(0, demuxer_->num_config_requests()); | |
1091 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckWithConfigChanged( | |
1092 false, 0)); // Video |kConfigChanged| as first unit. | |
1093 | |
1094 while (GetMediaDecoderJob(true)->is_decoding() || | |
1095 GetMediaDecoderJob(false)->is_decoding()) { | |
1096 message_loop_.RunUntilIdle(); | |
1097 } | |
1098 | |
1099 EXPECT_EQ(1, demuxer_->num_config_requests()); | |
1100 EXPECT_EQ(2, demuxer_->num_data_requests()); | |
1101 player_.OnDemuxerConfigsAvailable(CreateAudioVideoDemuxerConfigs()); | |
1102 EXPECT_EQ(3, demuxer_->num_data_requests()); | |
1103 | |
1104 // At no time after completing audio EOS decode, above, should the | |
1105 // audio decoder job resume decoding. | |
1106 EXPECT_FALSE(GetMediaDecoderJob(true)->is_decoding()); | |
1107 player_.OnDemuxerDataAvailable(CreateEOSAck(false)); // Video EOS | |
1108 EXPECT_FALSE(GetMediaDecoderJob(true)->is_decoding()); | |
1109 | |
1110 // Decode the video EOS. Spot-check that audio decode doesn't resume. | |
1111 EXPECT_FALSE(manager_.playback_completed()); | |
1112 do { | |
1113 message_loop_.RunUntilIdle(); | |
1114 EXPECT_FALSE(GetMediaDecoderJob(true)->is_decoding()); | |
1115 } while (GetMediaDecoderJob(false)->is_decoding()); | |
1116 | |
1117 EXPECT_TRUE(manager_.playback_completed()); | |
1118 EXPECT_EQ(3, demuxer_->num_data_requests()); | |
1119 | |
1120 // Playback should resume with further data requests following seek and start. | |
1121 SeekPlayer(true /* ignored */, base::TimeDelta(), false, 0); | |
1122 Start(CreateAudioVideoDemuxerConfigs()); | |
1123 EXPECT_EQ(5, demuxer_->num_data_requests()); | |
acolwell GONE FROM CHROMIUM
2013/12/06 18:28:30
nit: Do we really care about how many data request
wolenetz
2013/12/09 22:58:27
I've dropped the checks that are redundant with si
| |
1124 } | |
1125 | |
1126 TEST_F(MediaSourcePlayerTest, VA_PlaybackCompletionAcrossConfigChange) { | |
1127 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); | |
1128 | |
1129 // Test that if one stream (video) has completed decode of EOS and the other | |
1130 // stream (audio) processes config change, that subsequent audio EOS completes | |
1131 // A/V playback. | |
1132 // Also tests that seeking+Start() after completing playback resumes playback. | |
1133 Start(CreateAudioVideoDemuxerConfigs()); | |
1134 CreateNextTextureAndSetVideoSurface(); | |
1135 EXPECT_TRUE(GetMediaDecoderJob(true) && GetMediaDecoderJob(false)); | |
1136 EXPECT_EQ(2, demuxer_->num_data_requests()); | |
1137 player_.OnDemuxerDataAvailable(CreateEOSAck(false)); // Video EOS | |
1138 EXPECT_EQ(0, demuxer_->num_config_requests()); | |
1139 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckWithConfigChanged( | |
1140 true, 0)); // Audio |kConfigChanged| as first unit. | |
1141 | |
1142 while (GetMediaDecoderJob(true)->is_decoding() || | |
acolwell GONE FROM CHROMIUM
2013/12/06 18:28:30
nit: It seems like loops like this should just be
wolenetz
2013/12/09 22:58:27
Good point, I'll add a helper.
| |
1143 GetMediaDecoderJob(false)->is_decoding()) { | |
1144 message_loop_.RunUntilIdle(); | |
1145 } | |
1146 | |
1147 // TODO(wolenetz/qinmin): Prevent redundant demuxer config request and change | |
1148 // expectation to 1 here. See http://crbug.com/325528. | |
1149 EXPECT_EQ(2, demuxer_->num_config_requests()); | |
1150 EXPECT_EQ(2, demuxer_->num_data_requests()); | |
1151 player_.OnDemuxerConfigsAvailable(CreateAudioVideoDemuxerConfigs()); | |
1152 EXPECT_EQ(3, demuxer_->num_data_requests()); | |
1153 | |
1154 // At no time after completing video EOS decode, above, should the | |
1155 // video decoder job resume decoding. | |
1156 EXPECT_FALSE(GetMediaDecoderJob(false)->is_decoding()); | |
1157 player_.OnDemuxerDataAvailable(CreateEOSAck(true)); // Audio EOS | |
1158 EXPECT_FALSE(GetMediaDecoderJob(false)->is_decoding()); | |
1159 | |
1160 // Decode the audio EOS. Spot-check that video decode doesn't resume. | |
1161 EXPECT_FALSE(manager_.playback_completed()); | |
1162 do { | |
1163 message_loop_.RunUntilIdle(); | |
1164 EXPECT_FALSE(GetMediaDecoderJob(false)->is_decoding()); | |
1165 } while (GetMediaDecoderJob(true)->is_decoding()); | |
1166 | |
1167 EXPECT_TRUE(manager_.playback_completed()); | |
1168 EXPECT_EQ(3, demuxer_->num_data_requests()); | |
1169 | |
1170 // Playback should resume with further data requests following seek and start. | |
1171 SeekPlayer(true /* ignored */, base::TimeDelta(), false, 0); | |
1172 Start(CreateAudioVideoDemuxerConfigs()); | |
1173 EXPECT_EQ(5, demuxer_->num_data_requests()); | |
1174 } | |
1175 | |
1176 TEST_F(MediaSourcePlayerTest, AV_NoPrefetchForFinishedVideoOnAudioStarvation) { | |
1177 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); | |
1178 | |
1179 // Test that if one stream (video) has completed decode of EOS, prefetch | |
1180 // resulting from player starvation occurs only for the other stream (audio), | |
1181 // and responding to that prefetch with EOS completes A/V playback, even if | |
1182 // another starvation occurs during the latter EOS's decode. | |
1183 Start(CreateAudioVideoDemuxerConfigs()); | |
1184 CreateNextTextureAndSetVideoSurface(); | |
1185 EXPECT_TRUE(GetMediaDecoderJob(true) && GetMediaDecoderJob(false)); | |
1186 EXPECT_EQ(2, demuxer_->num_data_requests()); | |
1187 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForAudio(0)); | |
1188 player_.OnDemuxerDataAvailable(CreateEOSAck(false)); // Video EOS | |
1189 | |
1190 // Wait until video EOS is processed and more data (assumed to be audio) is | |
1191 // requested. | |
1192 while (demuxer_->num_data_requests() < 3 || | |
1193 GetMediaDecoderJob(false)->is_decoding()) { | |
1194 message_loop_.RunUntilIdle(); | |
1195 } | |
1196 | |
1197 // Simulate decoder underrun to trigger prefetch while still decoding audio. | |
1198 EXPECT_EQ(3, demuxer_->num_data_requests()); | |
1199 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForAudio(1)); | |
1200 EXPECT_TRUE(GetMediaDecoderJob(true)->is_decoding() && | |
1201 !GetMediaDecoderJob(false)->is_decoding()); | |
1202 TriggerPlayerStarvation(); | |
1203 | |
1204 // Complete the audio decode that was in progress when simulated player | |
1205 // starvation was triggered. At no time after completing video EOS decode, | |
1206 // above, should the video decoder job resume decoding. | |
1207 while (GetMediaDecoderJob(true)->is_decoding()) { | |
1208 EXPECT_FALSE(GetMediaDecoderJob(false)->is_decoding()); | |
1209 message_loop_.RunUntilIdle(); | |
1210 } | |
1211 EXPECT_FALSE(GetMediaDecoderJob(false)->is_decoding()); | |
1212 EXPECT_EQ(4, demuxer_->num_data_requests()); | |
1213 | |
1214 player_.OnDemuxerDataAvailable(CreateEOSAck(true)); // Audio EOS | |
1215 EXPECT_FALSE(GetMediaDecoderJob(false)->is_decoding()); | |
1216 | |
1217 // Simulate another decoder underrun to trigger prefetch while decoding EOS. | |
1218 EXPECT_TRUE(GetMediaDecoderJob(true)->is_decoding()); | |
1219 TriggerPlayerStarvation(); | |
1220 | |
1221 EXPECT_FALSE(manager_.playback_completed()); | |
1222 message_loop_.Run(); | |
1223 EXPECT_TRUE(manager_.playback_completed()); | |
1224 EXPECT_EQ(4, demuxer_->num_data_requests()); | |
1225 } | |
1226 | |
1227 TEST_F(MediaSourcePlayerTest, StarvationDuringVideoEOSDecode) { | |
1228 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); | |
1229 | |
1230 // Test that video-only playback completes without further data requested when | |
1231 // starvation occurs during EOS decode. | |
1232 CreateNextTextureAndSetVideoSurface(); | |
1233 StartVideoDecoderJob(); | |
1234 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForVideo()); | |
1235 message_loop_.Run(); | |
1236 EXPECT_EQ(2, demuxer_->num_data_requests()); | |
1237 | |
1238 // Simulate decoder underrun to trigger prefetch while decoding EOS. | |
1239 player_.OnDemuxerDataAvailable(CreateEOSAck(false)); // Video EOS | |
1240 EXPECT_TRUE(GetMediaDecoderJob(false)->is_decoding()); | |
1241 TriggerPlayerStarvation(); | |
1242 EXPECT_FALSE(manager_.playback_completed()); | |
1243 message_loop_.Run(); | |
1244 EXPECT_TRUE(manager_.playback_completed()); | |
1245 EXPECT_EQ(2, demuxer_->num_data_requests()); | |
1246 } | |
1247 | |
1248 TEST_F(MediaSourcePlayerTest, StarvationDuringAudioEOSDecode) { | |
1249 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); | |
1250 | |
1251 // Test that audio-only playback completes without further data requested when | |
1252 // starvation occurs during EOS decode. | |
1253 StartAudioDecoderJob(); | |
1254 EXPECT_TRUE(GetMediaDecoderJob(true)); | |
1255 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForAudio(0)); | |
1256 message_loop_.Run(); | |
1257 EXPECT_EQ(2, demuxer_->num_data_requests()); | |
1258 | |
1259 // Simulate decoder underrun to trigger prefetch while decoding EOS. | |
1260 player_.OnDemuxerDataAvailable(CreateEOSAck(true)); // Audio EOS | |
1261 EXPECT_TRUE(GetMediaDecoderJob(true)->is_decoding()); | |
1262 TriggerPlayerStarvation(); | |
1263 EXPECT_FALSE(manager_.playback_completed()); | |
1264 message_loop_.Run(); | |
1265 EXPECT_TRUE(manager_.playback_completed()); | |
1266 EXPECT_EQ(2, demuxer_->num_data_requests()); | |
1267 } | |
1268 | |
1269 TEST_F(MediaSourcePlayerTest, AV_SeekDuringEOSDecodePreventsCompletion) { | |
1270 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); | |
1271 | |
1272 // Test that seek supercedes audio+video playback completion on simultaneous | |
1273 // audio and video EOS decode, if SeekTo() occurs during these EOS decodes. | |
1274 SeekDuringEOSDecode(true, true, true, true); | |
1275 } | |
1276 | |
1277 TEST_F(MediaSourcePlayerTest, AV_SeekDuringAudioEOSDecodePreventsCompletion) { | |
1278 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); | |
1279 | |
1280 // Test that seek supercedes audio+video playback completion on simultaneous | |
1281 // audio EOS and video non-EOS decode, if SeekTo() occurs during these | |
1282 // decodes. | |
1283 SeekDuringEOSDecode(true, true, true, false); | |
1284 } | |
1285 | |
1286 TEST_F(MediaSourcePlayerTest, AV_SeekDuringVideoEOSDecodePreventsCompletion) { | |
1287 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); | |
1288 | |
1289 // Test that seek supercedes audio+video playback completion on simultaneous | |
1290 // audio non-EOS and video EOS decode, if SeekTo() occurs during these | |
1291 // decodes. | |
1292 SeekDuringEOSDecode(true, true, false , false); | |
wolenetz
2013/12/09 22:58:27
Oops. This configuration mismatched test intent, a
| |
1293 } | |
1294 | |
1295 TEST_F(MediaSourcePlayerTest, SeekDuringVideoEOSDecodePreventsCompletion) { | |
1296 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); | |
1297 | |
1298 // Test that seek supercedes video-only playback completion on EOS decode, if | |
1299 // SeekTo() occurs during EOS decode. | |
1300 SeekDuringEOSDecode(false, true, false, true); | |
1301 } | |
1302 | |
1303 TEST_F(MediaSourcePlayerTest, SeekDuringAudioEOSDecodePreventsCompletion) { | |
1304 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); | |
1305 | |
1306 // Test that seek supercedes audio-only playback completion on EOS decode, if | |
1307 // SeekTo() occurs during EOS decode. | |
1308 SeekDuringEOSDecode(true, false, true, false); | |
1016 } | 1309 } |
1017 | 1310 |
1018 TEST_F(MediaSourcePlayerTest, NoRequestForDataAfterAbort) { | 1311 TEST_F(MediaSourcePlayerTest, NoRequestForDataAfterAbort) { |
1019 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); | 1312 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); |
1020 | 1313 |
1021 // Test that the decoder will not request new data after receiving an aborted | 1314 // Test that the decoder will not request new data after receiving an aborted |
1022 // access unit. | 1315 // access unit. |
1023 StartAudioDecoderJob(); | 1316 StartAudioDecoderJob(); |
1024 EXPECT_EQ(1, demuxer_->num_data_requests()); | 1317 EXPECT_EQ(1, demuxer_->num_data_requests()); |
1025 | 1318 |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1130 } | 1423 } |
1131 | 1424 |
1132 TEST_F(MediaSourcePlayerTest, PrerollAudioAfterSeek) { | 1425 TEST_F(MediaSourcePlayerTest, PrerollAudioAfterSeek) { |
1133 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); | 1426 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); |
1134 | 1427 |
1135 // Test decoder job will preroll the media to the seek position. | 1428 // Test decoder job will preroll the media to the seek position. |
1136 StartAudioDecoderJob(); | 1429 StartAudioDecoderJob(); |
1137 EXPECT_TRUE(GetMediaDecoderJob(true)); | 1430 EXPECT_TRUE(GetMediaDecoderJob(true)); |
1138 EXPECT_EQ(1, demuxer_->num_data_requests()); | 1431 EXPECT_EQ(1, demuxer_->num_data_requests()); |
1139 | 1432 |
1140 SeekPlayer(true, base::TimeDelta::FromMilliseconds(100)); | 1433 SeekPlayer(true, base::TimeDelta::FromMilliseconds(100), true, 1); |
1141 EXPECT_TRUE(IsPrerolling(true)); | 1434 EXPECT_TRUE(IsPrerolling(true)); |
1142 EXPECT_EQ(100.0, GetPrerollTimestamp().InMillisecondsF()); | 1435 EXPECT_EQ(100.0, GetPrerollTimestamp().InMillisecondsF()); |
1143 | 1436 |
1144 // Send some data before the seek position. | 1437 // Send some data before the seek position. |
1145 for (int i = 1; i < 4; ++i) { | 1438 for (int i = 1; i < 4; ++i) { |
1146 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForAudio(i)); | 1439 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForAudio(i)); |
1147 EXPECT_TRUE(GetMediaDecoderJob(true)->is_decoding()); | 1440 EXPECT_TRUE(GetMediaDecoderJob(true)->is_decoding()); |
1148 message_loop_.Run(); | 1441 message_loop_.Run(); |
1149 } | 1442 } |
1150 EXPECT_EQ(100.0, player_.GetCurrentTime().InMillisecondsF()); | 1443 EXPECT_EQ(100.0, player_.GetCurrentTime().InMillisecondsF()); |
(...skipping 10 matching lines...) Expand all Loading... | |
1161 | 1454 |
1162 TEST_F(MediaSourcePlayerTest, PrerollVideoAfterSeek) { | 1455 TEST_F(MediaSourcePlayerTest, PrerollVideoAfterSeek) { |
1163 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); | 1456 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); |
1164 | 1457 |
1165 // Test decoder job will preroll the media to the seek position. | 1458 // Test decoder job will preroll the media to the seek position. |
1166 CreateNextTextureAndSetVideoSurface(); | 1459 CreateNextTextureAndSetVideoSurface(); |
1167 StartVideoDecoderJob(); | 1460 StartVideoDecoderJob(); |
1168 EXPECT_TRUE(GetMediaDecoderJob(false)); | 1461 EXPECT_TRUE(GetMediaDecoderJob(false)); |
1169 EXPECT_EQ(1, demuxer_->num_data_requests()); | 1462 EXPECT_EQ(1, demuxer_->num_data_requests()); |
1170 | 1463 |
1171 SeekPlayer(false, base::TimeDelta::FromMilliseconds(100)); | 1464 SeekPlayer(false, base::TimeDelta::FromMilliseconds(100), true, 1); |
1172 EXPECT_TRUE(IsPrerolling(false)); | 1465 EXPECT_TRUE(IsPrerolling(false)); |
1173 EXPECT_EQ(100.0, GetPrerollTimestamp().InMillisecondsF()); | 1466 EXPECT_EQ(100.0, GetPrerollTimestamp().InMillisecondsF()); |
1174 | 1467 |
1175 // Send some data before the seek position. | 1468 // Send some data before the seek position. |
1176 DemuxerData data; | 1469 DemuxerData data; |
1177 for (int i = 1; i < 4; ++i) { | 1470 for (int i = 1; i < 4; ++i) { |
1178 data = CreateReadFromDemuxerAckForVideo(); | 1471 data = CreateReadFromDemuxerAckForVideo(); |
1179 data.access_units[0].timestamp = base::TimeDelta::FromMilliseconds(i * 30); | 1472 data.access_units[0].timestamp = base::TimeDelta::FromMilliseconds(i * 30); |
1180 player_.OnDemuxerDataAvailable(data); | 1473 player_.OnDemuxerDataAvailable(data); |
1181 EXPECT_TRUE(GetMediaDecoderJob(false)->is_decoding()); | 1474 EXPECT_TRUE(GetMediaDecoderJob(false)->is_decoding()); |
(...skipping 28 matching lines...) Expand all Loading... | |
1210 | 1503 |
1211 // Complete the initial preroll by feeding data to the decoder. | 1504 // Complete the initial preroll by feeding data to the decoder. |
1212 for (int i = 0; i < 4; ++i) { | 1505 for (int i = 0; i < 4; ++i) { |
1213 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForAudio(i)); | 1506 player_.OnDemuxerDataAvailable(CreateReadFromDemuxerAckForAudio(i)); |
1214 EXPECT_TRUE(GetMediaDecoderJob(true)->is_decoding()); | 1507 EXPECT_TRUE(GetMediaDecoderJob(true)->is_decoding()); |
1215 message_loop_.Run(); | 1508 message_loop_.Run(); |
1216 } | 1509 } |
1217 EXPECT_LT(0.0, player_.GetCurrentTime().InMillisecondsF()); | 1510 EXPECT_LT(0.0, player_.GetCurrentTime().InMillisecondsF()); |
1218 EXPECT_FALSE(IsPrerolling(true)); | 1511 EXPECT_FALSE(IsPrerolling(true)); |
1219 | 1512 |
1220 SeekPlayer(true, base::TimeDelta::FromMilliseconds(500)); | 1513 SeekPlayer(true, base::TimeDelta::FromMilliseconds(500), true, 1); |
1221 | 1514 |
1222 // Prerolling should have begun again. | 1515 // Prerolling should have begun again. |
1223 EXPECT_TRUE(IsPrerolling(true)); | 1516 EXPECT_TRUE(IsPrerolling(true)); |
1224 EXPECT_EQ(500.0, GetPrerollTimestamp().InMillisecondsF()); | 1517 EXPECT_EQ(500.0, GetPrerollTimestamp().InMillisecondsF()); |
1225 | 1518 |
1226 // Send data at and after the seek position. Prerolling should complete. | 1519 // Send data at and after the seek position. Prerolling should complete. |
1227 for (int i = 0; i < 4; ++i) { | 1520 for (int i = 0; i < 4; ++i) { |
1228 DemuxerData data = CreateReadFromDemuxerAckForAudio(i); | 1521 DemuxerData data = CreateReadFromDemuxerAckForAudio(i); |
1229 data.access_units[0].timestamp = base::TimeDelta::FromMilliseconds( | 1522 data.access_units[0].timestamp = base::TimeDelta::FromMilliseconds( |
1230 500 + 30 * (i - 1)); | 1523 500 + 30 * (i - 1)); |
(...skipping 12 matching lines...) Expand all Loading... | |
1243 | 1536 |
1244 TEST_F(MediaSourcePlayerTest, PrerollContinuesAcrossReleaseAndStart) { | 1537 TEST_F(MediaSourcePlayerTest, PrerollContinuesAcrossReleaseAndStart) { |
1245 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); | 1538 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); |
1246 | 1539 |
1247 // Test decoder job will resume media prerolling if interrupted by Release() | 1540 // Test decoder job will resume media prerolling if interrupted by Release() |
1248 // and Start(). | 1541 // and Start(). |
1249 StartAudioDecoderJob(); | 1542 StartAudioDecoderJob(); |
1250 EXPECT_TRUE(GetMediaDecoderJob(true)); | 1543 EXPECT_TRUE(GetMediaDecoderJob(true)); |
1251 EXPECT_EQ(1, demuxer_->num_data_requests()); | 1544 EXPECT_EQ(1, demuxer_->num_data_requests()); |
1252 | 1545 |
1253 SeekPlayer(true, base::TimeDelta::FromMilliseconds(100)); | 1546 SeekPlayer(true, base::TimeDelta::FromMilliseconds(100), true, 1); |
1254 EXPECT_TRUE(IsPrerolling(true)); | 1547 EXPECT_TRUE(IsPrerolling(true)); |
1255 EXPECT_EQ(100.0, GetPrerollTimestamp().InMillisecondsF()); | 1548 EXPECT_EQ(100.0, GetPrerollTimestamp().InMillisecondsF()); |
1256 | 1549 |
1257 // Send some data before the seek position. | 1550 // Send some data before the seek position. |
1258 // Test uses 'large' number of iterations because decoder job may not get | 1551 // Test uses 'large' number of iterations because decoder job may not get |
1259 // MEDIA_CODEC_OK output status until after a few dequeue output attempts. | 1552 // MEDIA_CODEC_OK output status until after a few dequeue output attempts. |
1260 // This allows decoder status to stabilize prior to AU timestamp reaching | 1553 // This allows decoder status to stabilize prior to AU timestamp reaching |
1261 // the preroll target. | 1554 // the preroll target. |
1262 DemuxerData data; | 1555 DemuxerData data; |
1263 for (int i = 0; i < 10; ++i) { | 1556 for (int i = 0; i < 10; ++i) { |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1300 | 1593 |
1301 TEST_F(MediaSourcePlayerTest, PrerollContinuesAcrossConfigChange) { | 1594 TEST_F(MediaSourcePlayerTest, PrerollContinuesAcrossConfigChange) { |
1302 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); | 1595 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); |
1303 | 1596 |
1304 // Test decoder job will resume media prerolling if interrupted by | 1597 // Test decoder job will resume media prerolling if interrupted by |
1305 // |kConfigChanged| and OnDemuxerConfigsAvailable(). | 1598 // |kConfigChanged| and OnDemuxerConfigsAvailable(). |
1306 StartAudioDecoderJob(); | 1599 StartAudioDecoderJob(); |
1307 EXPECT_TRUE(GetMediaDecoderJob(true)); | 1600 EXPECT_TRUE(GetMediaDecoderJob(true)); |
1308 EXPECT_EQ(1, demuxer_->num_data_requests()); | 1601 EXPECT_EQ(1, demuxer_->num_data_requests()); |
1309 | 1602 |
1310 SeekPlayer(true, base::TimeDelta::FromMilliseconds(100)); | 1603 SeekPlayer(true, base::TimeDelta::FromMilliseconds(100), true, 1); |
1311 EXPECT_TRUE(IsPrerolling(true)); | 1604 EXPECT_TRUE(IsPrerolling(true)); |
1312 EXPECT_EQ(100.0, GetPrerollTimestamp().InMillisecondsF()); | 1605 EXPECT_EQ(100.0, GetPrerollTimestamp().InMillisecondsF()); |
1313 | 1606 |
1314 // In response to data request, simulate that demuxer signals config change by | 1607 // In response to data request, simulate that demuxer signals config change by |
1315 // sending an AU with |kConfigChanged|. Player should prepare to reconfigure | 1608 // sending an AU with |kConfigChanged|. Player should prepare to reconfigure |
1316 // the audio decoder job, and should request new demuxer configs. | 1609 // the audio decoder job, and should request new demuxer configs. |
1317 DemuxerData data = CreateReadFromDemuxerAckWithConfigChanged(true, 0); | 1610 DemuxerData data = CreateReadFromDemuxerAckWithConfigChanged(true, 0); |
1318 EXPECT_EQ(0, demuxer_->num_config_requests()); | 1611 EXPECT_EQ(0, demuxer_->num_config_requests()); |
1319 player_.OnDemuxerDataAvailable(data); | 1612 player_.OnDemuxerDataAvailable(data); |
1320 EXPECT_EQ(1, demuxer_->num_config_requests()); | 1613 EXPECT_EQ(1, demuxer_->num_config_requests()); |
(...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1902 | 2195 |
1903 std::vector<std::string> codec_avc(1, "avc1"); | 2196 std::vector<std::string> codec_avc(1, "avc1"); |
1904 EXPECT_FALSE(IsTypeSupported(invalid_uuid, "L3", kVideoMp4, codec_avc)); | 2197 EXPECT_FALSE(IsTypeSupported(invalid_uuid, "L3", kVideoMp4, codec_avc)); |
1905 EXPECT_FALSE(IsTypeSupported(invalid_uuid, "L1", kVideoMp4, codec_avc)); | 2198 EXPECT_FALSE(IsTypeSupported(invalid_uuid, "L1", kVideoMp4, codec_avc)); |
1906 } | 2199 } |
1907 | 2200 |
1908 // TODO(xhwang): Are these IsTypeSupported tests device specific? | 2201 // TODO(xhwang): Are these IsTypeSupported tests device specific? |
1909 // TODO(xhwang): Add more IsTypeSupported tests. | 2202 // TODO(xhwang): Add more IsTypeSupported tests. |
1910 | 2203 |
1911 } // namespace media | 2204 } // namespace media |
OLD | NEW |