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

Side by Side Diff: media/test/pipeline_integration_test.cc

Issue 1805013003: Enable implicit signalling for HE AAC v1 & v2 in ADTS. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Feedback Created 4 years, 9 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 666 matching lines...) Expand 10 before | Expand all | Expand 10 after
677 private: 677 private:
678 interfaces::ServiceFactoryPtr media_service_factory_; 678 interfaces::ServiceFactoryPtr media_service_factory_;
679 }; 679 };
680 #else 680 #else
681 class PipelineIntegrationTestHost : public testing::Test, 681 class PipelineIntegrationTestHost : public testing::Test,
682 public PipelineIntegrationTestBase {}; 682 public PipelineIntegrationTestBase {};
683 #endif // defined(MOJO_RENDERER) 683 #endif // defined(MOJO_RENDERER)
684 684
685 class PipelineIntegrationTest : public PipelineIntegrationTestHost { 685 class PipelineIntegrationTest : public PipelineIntegrationTestHost {
686 public: 686 public:
687 void StartPipelineWithMediaSource(MockMediaSource* source) { 687 PipelineStatus StartPipelineWithMediaSource(MockMediaSource* source) {
688 return StartPipelineWithMediaSource(source, kNormal);
689 }
690
691 PipelineStatus StartPipelineWithMediaSource(MockMediaSource* source,
692 uint8_t test_type) {
693 hashing_enabled_ = test_type & kHashed;
694 clockless_playback_ = test_type & kClockless;
695
688 EXPECT_CALL(*source, InitSegmentReceived(_)).Times(AtLeast(1)); 696 EXPECT_CALL(*source, InitSegmentReceived(_)).Times(AtLeast(1));
689 EXPECT_CALL(*this, OnMetadata(_)) 697 EXPECT_CALL(*this, OnMetadata(_))
690 .Times(AtMost(1)) 698 .Times(AtMost(1))
691 .WillRepeatedly(SaveArg<0>(&metadata_)); 699 .WillRepeatedly(SaveArg<0>(&metadata_));
692 EXPECT_CALL(*this, OnBufferingStateChanged(BUFFERING_HAVE_ENOUGH)) 700 EXPECT_CALL(*this, OnBufferingStateChanged(BUFFERING_HAVE_ENOUGH))
693 .Times(AnyNumber()); 701 .Times(AnyNumber());
694 EXPECT_CALL(*this, OnBufferingStateChanged(BUFFERING_HAVE_NOTHING)) 702 EXPECT_CALL(*this, OnBufferingStateChanged(BUFFERING_HAVE_NOTHING))
695 .Times(AnyNumber()); 703 .Times(AnyNumber());
696 704
697 // Encrypted content not used, so this is never called. 705 // Encrypted content not used, so this is never called.
698 EXPECT_CALL(*this, OnWaitingForDecryptionKey()).Times(0); 706 EXPECT_CALL(*this, OnWaitingForDecryptionKey()).Times(0);
699 707
700 demuxer_ = source->GetDemuxer(); 708 demuxer_ = source->GetDemuxer();
701 pipeline_->Start( 709 pipeline_->Start(
702 demuxer_.get(), CreateRenderer(), 710 demuxer_.get(), CreateRenderer(),
703 base::Bind(&PipelineIntegrationTest::OnEnded, base::Unretained(this)), 711 base::Bind(&PipelineIntegrationTest::OnEnded, base::Unretained(this)),
704 base::Bind(&PipelineIntegrationTest::OnError, base::Unretained(this)), 712 base::Bind(&PipelineIntegrationTest::OnError, base::Unretained(this)),
705 base::Bind(&PipelineIntegrationTest::OnStatusCallback, 713 base::Bind(&PipelineIntegrationTest::OnStatusCallback,
706 base::Unretained(this)), 714 base::Unretained(this)),
707 base::Bind(&PipelineIntegrationTest::OnMetadata, 715 base::Bind(&PipelineIntegrationTest::OnMetadata,
708 base::Unretained(this)), 716 base::Unretained(this)),
709 base::Bind(&PipelineIntegrationTest::OnBufferingStateChanged, 717 base::Bind(&PipelineIntegrationTest::OnBufferingStateChanged,
710 base::Unretained(this)), 718 base::Unretained(this)),
711 base::Closure(), base::Bind(&PipelineIntegrationTest::OnAddTextTrack, 719 base::Closure(), base::Bind(&PipelineIntegrationTest::OnAddTextTrack,
712 base::Unretained(this)), 720 base::Unretained(this)),
713 base::Bind(&PipelineIntegrationTest::OnWaitingForDecryptionKey, 721 base::Bind(&PipelineIntegrationTest::OnWaitingForDecryptionKey,
714 base::Unretained(this))); 722 base::Unretained(this)));
715 message_loop_.Run(); 723 message_loop_.Run();
716 EXPECT_EQ(PIPELINE_OK, pipeline_status_); 724 EXPECT_EQ(PIPELINE_OK, pipeline_status_);
717 } 725 return pipeline_status_;
718
719 void StartHashedPipelineWithMediaSource(MockMediaSource* source) {
720 hashing_enabled_ = true;
721 StartPipelineWithMediaSource(source);
722 }
723
724 void StartHashedClocklessPipelineWithMediaSource(MockMediaSource* source) {
725 hashing_enabled_ = true;
726 clockless_playback_ = true;
727 StartPipelineWithMediaSource(source);
728 } 726 }
729 727
730 void StartPipelineWithEncryptedMedia(MockMediaSource* source, 728 void StartPipelineWithEncryptedMedia(MockMediaSource* source,
731 FakeEncryptedMedia* encrypted_media) { 729 FakeEncryptedMedia* encrypted_media) {
732 EXPECT_CALL(*source, InitSegmentReceived(_)).Times(AtLeast(1)); 730 EXPECT_CALL(*source, InitSegmentReceived(_)).Times(AtLeast(1));
733 EXPECT_CALL(*this, OnMetadata(_)) 731 EXPECT_CALL(*this, OnMetadata(_))
734 .Times(AtMost(1)) 732 .Times(AtMost(1))
735 .WillRepeatedly(SaveArg<0>(&metadata_)); 733 .WillRepeatedly(SaveArg<0>(&metadata_));
736 EXPECT_CALL(*this, OnBufferingStateChanged(BUFFERING_HAVE_ENOUGH)) 734 EXPECT_CALL(*this, OnBufferingStateChanged(BUFFERING_HAVE_ENOUGH))
737 .Times(AnyNumber()); 735 .Times(AnyNumber());
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
797 return false; 795 return false;
798 796
799 source.EndOfStream(); 797 source.EndOfStream();
800 798
801 source.Shutdown(); 799 source.Shutdown();
802 Stop(); 800 Stop();
803 return true; 801 return true;
804 } 802 }
805 }; 803 };
806 804
805 struct PlaybackTestData {
806 // PlaybackTestData(const char* filename,
DaleCurtis 2016/03/25 23:57:51 Delete?
chcunningham 2016/03/26 00:31:36 Done.
807 // const uint32_t start_time_ms,
808 // const uint32_t duration_ms)
809 // : filename(filename),
810 // start_time_ms(start_time_ms),
811 // duration_ms(duration_ms) {}
812
813 const std::string filename;
814 const uint32_t start_time_ms;
815 const uint32_t duration_ms;
816 };
817
818 struct MSEPlaybackTestData {
819 // MSEPlaybackTestData(const char* filename,
DaleCurtis 2016/03/25 23:57:51 Delete?
chcunningham 2016/03/26 00:31:36 Done.
820 // const char* mimetype,
821 // const size_t append_bytes,
822 // const uint32_t duration_ms)
823 // : filename(filename),
824 // mimetype(mimetype),
825 // append_bytes(append_bytes),
826 // duration_ms(duration_ms) {}
827
828 const std::string filename;
829 const std::string mimetype;
830 const size_t append_bytes;
831 const uint32_t duration_ms;
832 };
833
834 // Tells gtest how to print our PlaybackTestData structure.
835 std::ostream& operator<<(std::ostream& os, const PlaybackTestData& data) {
836 return os << data.filename;
837 }
838
839 std::ostream& operator<<(std::ostream& os, const MSEPlaybackTestData& data) {
840 return os << data.filename;
841 }
842
843 class BasicPlaybackTest : public PipelineIntegrationTest,
844 public testing::WithParamInterface<PlaybackTestData> {
845 };
846
847 class BasicMSEPlaybackTest
848 : public ::testing::WithParamInterface<MSEPlaybackTestData>,
849 public PipelineIntegrationTest {};
850
851 TEST_P(BasicPlaybackTest, PlayToEnd) {
852 PlaybackTestData data = GetParam();
853
854 ASSERT_EQ(PIPELINE_OK, Start(data.filename, kClockless));
855 EXPECT_EQ(data.start_time_ms, demuxer_->GetStartTime().InMilliseconds());
856 EXPECT_EQ(data.duration_ms, pipeline_->GetMediaDuration().InMilliseconds());
857
858 Play();
859 ASSERT_TRUE(WaitUntilOnEnded());
860 }
861
862 TEST_P(BasicMSEPlaybackTest, PlayToEnd) {
863 MSEPlaybackTestData data = GetParam();
864
865 MockMediaSource source(data.filename, data.mimetype, data.append_bytes);
866 // TODO -- ADD uint8_t test_type to StartWithMSE and pass clockless flags
867 ASSERT_EQ(PIPELINE_OK, StartPipelineWithMediaSource(&source, kClockless));
868 source.EndOfStream();
869
870 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size());
871 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds());
872 EXPECT_EQ(data.duration_ms,
873 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds());
874
875 Play();
876
877 ASSERT_TRUE(WaitUntilOnEnded());
878
879 EXPECT_TRUE(demuxer_->GetTimelineOffset().is_null());
880 source.Shutdown();
881 Stop();
882 }
883
884 #if defined(USE_PROPRIETARY_CODECS)
885
886 const PlaybackTestData kADTSTests[] = {
887 {"bear-audio-main-aac.aac", 0, 2724},
888 {"bear-audio-lc-aac.aac", 0, 2858},
889 {"bear-audio-implicit-he-aac-v1.aac", 0, 2812},
890 {"bear-audio-implicit-he-aac-v2.aac", 0, 3047},
891 };
892
893 // TODO(chcunningham): Migrate other basic playback tests to TEST_P.
894 INSTANTIATE_TEST_CASE_P(PropritaryCodecs,
895 BasicPlaybackTest,
896 testing::ValuesIn(kADTSTests));
897
898 const MSEPlaybackTestData kMediaSourceADTSTests[] = {
899 {"bear-audio-main-aac.aac", kADTS, kAppendWholeFile, 2773},
900 {"bear-audio-lc-aac.aac", kADTS, kAppendWholeFile, 2794},
901 {"bear-audio-implicit-he-aac-v1.aac", kADTS, kAppendWholeFile, 2858},
902 {"bear-audio-implicit-he-aac-v2.aac", kADTS, kAppendWholeFile, 2901},
903 };
904
905 // TODO(chcunningham): Migrate other basic MSE playback tests to TEST_P.
906 INSTANTIATE_TEST_CASE_P(PropritaryCodecs,
907 BasicMSEPlaybackTest,
908 testing::ValuesIn(kMediaSourceADTSTests));
909
910 #endif // defined(USE_PROPRIETARY_CODECS)
911
807 TEST_F(PipelineIntegrationTest, BasicPlayback) { 912 TEST_F(PipelineIntegrationTest, BasicPlayback) {
808 ASSERT_EQ(PIPELINE_OK, Start("bear-320x240.webm")); 913 ASSERT_EQ(PIPELINE_OK, Start("bear-320x240.webm"));
809 914
810 Play(); 915 Play();
811 916
812 ASSERT_TRUE(WaitUntilOnEnded()); 917 ASSERT_TRUE(WaitUntilOnEnded());
813 } 918 }
814 919
815 TEST_F(PipelineIntegrationTest, BasicPlaybackOpusOgg) { 920 TEST_F(PipelineIntegrationTest, BasicPlaybackOpusOgg) {
816 ASSERT_EQ(PIPELINE_OK, Start("bear-opus.ogg")); 921 ASSERT_EQ(PIPELINE_OK, Start("bear-opus.ogg"));
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
877 ASSERT_TRUE(Seek(base::TimeDelta::FromMilliseconds(6360))); 982 ASSERT_TRUE(Seek(base::TimeDelta::FromMilliseconds(6360)));
878 Play(); 983 Play();
879 ASSERT_TRUE(WaitUntilOnEnded()); 984 ASSERT_TRUE(WaitUntilOnEnded());
880 EXPECT_HASH_EQ(kOpusEndTrimmingHash_3, GetAudioHash()); 985 EXPECT_HASH_EQ(kOpusEndTrimmingHash_3, GetAudioHash());
881 } 986 }
882 987
883 TEST_F(PipelineIntegrationTest, 988 TEST_F(PipelineIntegrationTest,
884 MAYBE_CLOCKLESS(BasicPlaybackOpusWebmTrimmingHashed_MediaSource)) { 989 MAYBE_CLOCKLESS(BasicPlaybackOpusWebmTrimmingHashed_MediaSource)) {
885 MockMediaSource source("opus-trimming-test.webm", kOpusAudioOnlyWebM, 990 MockMediaSource source("opus-trimming-test.webm", kOpusAudioOnlyWebM,
886 kAppendWholeFile); 991 kAppendWholeFile);
887 StartHashedClocklessPipelineWithMediaSource(&source); 992 StartPipelineWithMediaSource(&source, kClockless | kHashed);
888 source.EndOfStream(); 993 source.EndOfStream();
889 994
890 Play(); 995 Play();
891 996
892 ASSERT_TRUE(WaitUntilOnEnded()); 997 ASSERT_TRUE(WaitUntilOnEnded());
893 EXPECT_HASH_EQ(kOpusEndTrimmingHash_1, GetAudioHash()); 998 EXPECT_HASH_EQ(kOpusEndTrimmingHash_1, GetAudioHash());
894 999
895 // Seek within the pre-skip section, this should not cause a beep. 1000 // Seek within the pre-skip section, this should not cause a beep.
896 base::TimeDelta seek_time = base::TimeDelta::FromSeconds(1); 1001 base::TimeDelta seek_time = base::TimeDelta::FromSeconds(1);
897 source.Seek(seek_time); 1002 source.Seek(seek_time);
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
1047 1152
1048 ASSERT_TRUE(WaitUntilOnEnded()); 1153 ASSERT_TRUE(WaitUntilOnEnded());
1049 source.Shutdown(); 1154 source.Shutdown();
1050 Stop(); 1155 Stop();
1051 } 1156 }
1052 1157
1053 // Flaky. http://crbug.com/304776 1158 // Flaky. http://crbug.com/304776
1054 TEST_F(PipelineIntegrationTest, DISABLED_MediaSource_Opus_Seeking_WebM) { 1159 TEST_F(PipelineIntegrationTest, DISABLED_MediaSource_Opus_Seeking_WebM) {
1055 MockMediaSource source("bear-opus-end-trimming.webm", kOpusAudioOnlyWebM, 1160 MockMediaSource source("bear-opus-end-trimming.webm", kOpusAudioOnlyWebM,
1056 kAppendWholeFile); 1161 kAppendWholeFile);
1057 StartHashedPipelineWithMediaSource(&source); 1162 StartPipelineWithMediaSource(&source, kHashed);
1058 1163
1059 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); 1164 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size());
1060 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); 1165 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds());
1061 EXPECT_EQ(kOpusEndTrimmingWebMFileDurationMs, 1166 EXPECT_EQ(kOpusEndTrimmingWebMFileDurationMs,
1062 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); 1167 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds());
1063 1168
1064 base::TimeDelta start_seek_time = base::TimeDelta::FromMilliseconds(1000); 1169 base::TimeDelta start_seek_time = base::TimeDelta::FromMilliseconds(1000);
1065 base::TimeDelta seek_time = base::TimeDelta::FromMilliseconds(2000); 1170 base::TimeDelta seek_time = base::TimeDelta::FromMilliseconds(2000);
1066 1171
1067 Play(); 1172 Play();
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
1262 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); 1367 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds());
1263 EXPECT_EQ(325, pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); 1368 EXPECT_EQ(325, pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds());
1264 1369
1265 Play(); 1370 Play();
1266 1371
1267 EXPECT_TRUE(WaitUntilOnEnded()); 1372 EXPECT_TRUE(WaitUntilOnEnded());
1268 } 1373 }
1269 1374
1270 TEST_F(PipelineIntegrationTest, MediaSource_ADTS_TimestampOffset) { 1375 TEST_F(PipelineIntegrationTest, MediaSource_ADTS_TimestampOffset) {
1271 MockMediaSource source("sfx.adts", kADTS, kAppendWholeFile); 1376 MockMediaSource source("sfx.adts", kADTS, kAppendWholeFile);
1272 StartHashedPipelineWithMediaSource(&source); 1377 StartPipelineWithMediaSource(&source, kHashed);
1273 EXPECT_EQ(325, source.last_timestamp_offset().InMilliseconds()); 1378 EXPECT_EQ(325, source.last_timestamp_offset().InMilliseconds());
1274 1379
1275 // Trim off multiple frames off the beginning of the segment which will cause 1380 // Trim off multiple frames off the beginning of the segment which will cause
1276 // the first decoded frame to be incorrect if preroll isn't implemented. 1381 // the first decoded frame to be incorrect if preroll isn't implemented.
1277 const base::TimeDelta adts_preroll_duration = 1382 const base::TimeDelta adts_preroll_duration =
1278 base::TimeDelta::FromSecondsD(2.5 * 1024 / 44100); 1383 base::TimeDelta::FromSecondsD(2.5 * 1024 / 44100);
1279 const base::TimeDelta append_time = 1384 const base::TimeDelta append_time =
1280 source.last_timestamp_offset() - adts_preroll_duration; 1385 source.last_timestamp_offset() - adts_preroll_duration;
1281 1386
1282 scoped_refptr<DecoderBuffer> second_file = ReadTestDataFile("sfx.adts"); 1387 scoped_refptr<DecoderBuffer> second_file = ReadTestDataFile("sfx.adts");
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
1377 1482
1378 INSTANTIATE_TEST_CASE_P( 1483 INSTANTIATE_TEST_CASE_P(
1379 VBRSeeks_NoTOC, 1484 VBRSeeks_NoTOC,
1380 Mp3FastSeekIntegrationTest, 1485 Mp3FastSeekIntegrationTest,
1381 ::testing::Values(Mp3FastSeekParams("bear-audio-10s-VBR-no-TOC.mp3", 1486 ::testing::Values(Mp3FastSeekParams("bear-audio-10s-VBR-no-TOC.mp3",
1382 "-0.22,0.80,1.19,0.73,-0.31,-1.12,"))); 1487 "-0.22,0.80,1.19,0.73,-0.31,-1.12,")));
1383 #endif // !defined(DISABLE_CLOCKLESS_TESTS) 1488 #endif // !defined(DISABLE_CLOCKLESS_TESTS)
1384 1489
1385 TEST_F(PipelineIntegrationTest, MediaSource_MP3) { 1490 TEST_F(PipelineIntegrationTest, MediaSource_MP3) {
1386 MockMediaSource source("sfx.mp3", kMP3, kAppendWholeFile); 1491 MockMediaSource source("sfx.mp3", kMP3, kAppendWholeFile);
1387 StartHashedPipelineWithMediaSource(&source); 1492 StartPipelineWithMediaSource(&source, kHashed);
1388 source.EndOfStream(); 1493 source.EndOfStream();
1389 1494
1390 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); 1495 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size());
1391 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); 1496 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds());
1392 EXPECT_EQ(313, pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); 1497 EXPECT_EQ(313, pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds());
1393 1498
1394 Play(); 1499 Play();
1395 1500
1396 EXPECT_TRUE(WaitUntilOnEnded()); 1501 EXPECT_TRUE(WaitUntilOnEnded());
1397 1502
(...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after
2040 2145
2041 TEST_F(PipelineIntegrationTest, BasicPlaybackPositiveStartTime) { 2146 TEST_F(PipelineIntegrationTest, BasicPlaybackPositiveStartTime) {
2042 ASSERT_EQ(PIPELINE_OK, Start("nonzero-start-time.webm")); 2147 ASSERT_EQ(PIPELINE_OK, Start("nonzero-start-time.webm"));
2043 Play(); 2148 Play();
2044 ASSERT_TRUE(WaitUntilOnEnded()); 2149 ASSERT_TRUE(WaitUntilOnEnded());
2045 ASSERT_EQ(base::TimeDelta::FromMicroseconds(396000), 2150 ASSERT_EQ(base::TimeDelta::FromMicroseconds(396000),
2046 demuxer_->GetStartTime()); 2151 demuxer_->GetStartTime());
2047 } 2152 }
2048 2153
2049 } // namespace media 2154 } // namespace media
OLDNEW
« media/renderers/audio_renderer_impl.cc ('K') | « media/test/data/bear-audio-main-aac.aac ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698