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

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

Issue 1838203003: [TO M50] Enable implicit signalling for HE AAC v1 & v2 in ADTS. (Closed) Base URL: https://chromium.googlesource.com/a/chromium/src.git@2661
Patch Set: Created 4 years, 8 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
« no previous file with comments | « media/test/data/bear-audio-main-aac.aac ('k') | media/test/pipeline_integration_test_base.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 663 matching lines...) Expand 10 before | Expand all | Expand 10 after
674 private: 674 private:
675 interfaces::ServiceFactoryPtr media_service_factory_; 675 interfaces::ServiceFactoryPtr media_service_factory_;
676 }; 676 };
677 #else 677 #else
678 class PipelineIntegrationTestHost : public testing::Test, 678 class PipelineIntegrationTestHost : public testing::Test,
679 public PipelineIntegrationTestBase {}; 679 public PipelineIntegrationTestBase {};
680 #endif // defined(MOJO_RENDERER) 680 #endif // defined(MOJO_RENDERER)
681 681
682 class PipelineIntegrationTest : public PipelineIntegrationTestHost { 682 class PipelineIntegrationTest : public PipelineIntegrationTestHost {
683 public: 683 public:
684 void StartPipelineWithMediaSource(MockMediaSource* source) { 684 PipelineStatus StartPipelineWithMediaSource(MockMediaSource* source) {
685 return StartPipelineWithMediaSource(source, kNormal);
686 }
687
688 PipelineStatus StartPipelineWithMediaSource(MockMediaSource* source,
689 uint8_t test_type) {
690 hashing_enabled_ = test_type & kHashed;
691 clockless_playback_ = test_type & kClockless;
692
685 EXPECT_CALL(*source, InitSegmentReceived()).Times(AtLeast(1)); 693 EXPECT_CALL(*source, InitSegmentReceived()).Times(AtLeast(1));
686 EXPECT_CALL(*this, OnMetadata(_)) 694 EXPECT_CALL(*this, OnMetadata(_))
687 .Times(AtMost(1)) 695 .Times(AtMost(1))
688 .WillRepeatedly(SaveArg<0>(&metadata_)); 696 .WillRepeatedly(SaveArg<0>(&metadata_));
689 EXPECT_CALL(*this, OnBufferingStateChanged(BUFFERING_HAVE_ENOUGH)) 697 EXPECT_CALL(*this, OnBufferingStateChanged(BUFFERING_HAVE_ENOUGH))
690 .Times(AnyNumber()); 698 .Times(AnyNumber());
691 EXPECT_CALL(*this, OnBufferingStateChanged(BUFFERING_HAVE_NOTHING)) 699 EXPECT_CALL(*this, OnBufferingStateChanged(BUFFERING_HAVE_NOTHING))
692 .Times(AnyNumber()); 700 .Times(AnyNumber());
693 701
694 // Encrypted content not used, so this is never called. 702 // Encrypted content not used, so this is never called.
695 EXPECT_CALL(*this, OnWaitingForDecryptionKey()).Times(0); 703 EXPECT_CALL(*this, OnWaitingForDecryptionKey()).Times(0);
696 704
697 demuxer_ = source->GetDemuxer(); 705 demuxer_ = source->GetDemuxer();
698 pipeline_->Start( 706 pipeline_->Start(
699 demuxer_.get(), CreateRenderer(), 707 demuxer_.get(), CreateRenderer(),
700 base::Bind(&PipelineIntegrationTest::OnEnded, base::Unretained(this)), 708 base::Bind(&PipelineIntegrationTest::OnEnded, base::Unretained(this)),
701 base::Bind(&PipelineIntegrationTest::OnError, base::Unretained(this)), 709 base::Bind(&PipelineIntegrationTest::OnError, base::Unretained(this)),
702 base::Bind(&PipelineIntegrationTest::OnStatusCallback, 710 base::Bind(&PipelineIntegrationTest::OnStatusCallback,
703 base::Unretained(this)), 711 base::Unretained(this)),
704 base::Bind(&PipelineIntegrationTest::OnMetadata, 712 base::Bind(&PipelineIntegrationTest::OnMetadata,
705 base::Unretained(this)), 713 base::Unretained(this)),
706 base::Bind(&PipelineIntegrationTest::OnBufferingStateChanged, 714 base::Bind(&PipelineIntegrationTest::OnBufferingStateChanged,
707 base::Unretained(this)), 715 base::Unretained(this)),
708 base::Closure(), base::Bind(&PipelineIntegrationTest::OnAddTextTrack, 716 base::Closure(), base::Bind(&PipelineIntegrationTest::OnAddTextTrack,
709 base::Unretained(this)), 717 base::Unretained(this)),
710 base::Bind(&PipelineIntegrationTest::OnWaitingForDecryptionKey, 718 base::Bind(&PipelineIntegrationTest::OnWaitingForDecryptionKey,
711 base::Unretained(this))); 719 base::Unretained(this)));
712 message_loop_.Run(); 720 message_loop_.Run();
713 EXPECT_EQ(PIPELINE_OK, pipeline_status_); 721 EXPECT_EQ(PIPELINE_OK, pipeline_status_);
714 } 722 return pipeline_status_;
715
716 void StartHashedPipelineWithMediaSource(MockMediaSource* source) {
717 hashing_enabled_ = true;
718 StartPipelineWithMediaSource(source);
719 }
720
721 void StartHashedClocklessPipelineWithMediaSource(MockMediaSource* source) {
722 hashing_enabled_ = true;
723 clockless_playback_ = true;
724 StartPipelineWithMediaSource(source);
725 } 723 }
726 724
727 void StartPipelineWithEncryptedMedia(MockMediaSource* source, 725 void StartPipelineWithEncryptedMedia(MockMediaSource* source,
728 FakeEncryptedMedia* encrypted_media) { 726 FakeEncryptedMedia* encrypted_media) {
729 EXPECT_CALL(*source, InitSegmentReceived()).Times(AtLeast(1)); 727 EXPECT_CALL(*source, InitSegmentReceived()).Times(AtLeast(1));
730 EXPECT_CALL(*this, OnMetadata(_)) 728 EXPECT_CALL(*this, OnMetadata(_))
731 .Times(AtMost(1)) 729 .Times(AtMost(1))
732 .WillRepeatedly(SaveArg<0>(&metadata_)); 730 .WillRepeatedly(SaveArg<0>(&metadata_));
733 EXPECT_CALL(*this, OnBufferingStateChanged(BUFFERING_HAVE_ENOUGH)) 731 EXPECT_CALL(*this, OnBufferingStateChanged(BUFFERING_HAVE_ENOUGH))
734 .Times(AnyNumber()); 732 .Times(AnyNumber());
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
794 return false; 792 return false;
795 793
796 source.EndOfStream(); 794 source.EndOfStream();
797 795
798 source.Shutdown(); 796 source.Shutdown();
799 Stop(); 797 Stop();
800 return true; 798 return true;
801 } 799 }
802 }; 800 };
803 801
802 struct PlaybackTestData {
803 const std::string filename;
804 const uint32_t start_time_ms;
805 const uint32_t duration_ms;
806 };
807
808 struct MSEPlaybackTestData {
809 const std::string filename;
810 const std::string mimetype;
811 const size_t append_bytes;
812 const uint32_t duration_ms;
813 };
814
815 // Tells gtest how to print our PlaybackTestData structure.
816 std::ostream& operator<<(std::ostream& os, const PlaybackTestData& data) {
817 return os << data.filename;
818 }
819
820 std::ostream& operator<<(std::ostream& os, const MSEPlaybackTestData& data) {
821 return os << data.filename;
822 }
823
824 class BasicPlaybackTest : public PipelineIntegrationTest,
825 public testing::WithParamInterface<PlaybackTestData> {
826 };
827
828 class BasicMSEPlaybackTest
829 : public ::testing::WithParamInterface<MSEPlaybackTestData>,
830 public PipelineIntegrationTest {};
831
832 TEST_P(BasicPlaybackTest, PlayToEnd) {
833 PlaybackTestData data = GetParam();
834
835 ASSERT_EQ(PIPELINE_OK, Start(data.filename, kClockless));
836 EXPECT_EQ(data.start_time_ms, demuxer_->GetStartTime().InMilliseconds());
837 EXPECT_EQ(data.duration_ms, pipeline_->GetMediaDuration().InMilliseconds());
838
839 Play();
840 ASSERT_TRUE(WaitUntilOnEnded());
841 }
842
843 TEST_P(BasicMSEPlaybackTest, PlayToEnd) {
844 MSEPlaybackTestData data = GetParam();
845
846 MockMediaSource source(data.filename, data.mimetype, data.append_bytes);
847 // TODO -- ADD uint8_t test_type to StartWithMSE and pass clockless flags
848 ASSERT_EQ(PIPELINE_OK, StartPipelineWithMediaSource(&source, kClockless));
849 source.EndOfStream();
850
851 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size());
852 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds());
853 EXPECT_EQ(data.duration_ms,
854 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds());
855
856 Play();
857
858 ASSERT_TRUE(WaitUntilOnEnded());
859
860 EXPECT_TRUE(demuxer_->GetTimelineOffset().is_null());
861 source.Shutdown();
862 Stop();
863 }
864
865 #if defined(USE_PROPRIETARY_CODECS)
866
867 const PlaybackTestData kADTSTests[] = {
868 {"bear-audio-main-aac.aac", 0, 2724},
869 {"bear-audio-lc-aac.aac", 0, 2858},
870 {"bear-audio-implicit-he-aac-v1.aac", 0, 2812},
871 {"bear-audio-implicit-he-aac-v2.aac", 0, 3047},
872 };
873
874 // TODO(chcunningham): Migrate other basic playback tests to TEST_P.
875 INSTANTIATE_TEST_CASE_P(PropritaryCodecs,
876 BasicPlaybackTest,
877 testing::ValuesIn(kADTSTests));
878
879 const MSEPlaybackTestData kMediaSourceADTSTests[] = {
880 {"bear-audio-main-aac.aac", kADTS, kAppendWholeFile, 2773},
881 {"bear-audio-lc-aac.aac", kADTS, kAppendWholeFile, 2794},
882 {"bear-audio-implicit-he-aac-v1.aac", kADTS, kAppendWholeFile, 2858},
883 {"bear-audio-implicit-he-aac-v2.aac", kADTS, kAppendWholeFile, 2901},
884 };
885
886 // TODO(chcunningham): Migrate other basic MSE playback tests to TEST_P.
887 INSTANTIATE_TEST_CASE_P(PropritaryCodecs,
888 BasicMSEPlaybackTest,
889 testing::ValuesIn(kMediaSourceADTSTests));
890
891 #endif // defined(USE_PROPRIETARY_CODECS)
892
804 TEST_F(PipelineIntegrationTest, BasicPlayback) { 893 TEST_F(PipelineIntegrationTest, BasicPlayback) {
805 ASSERT_EQ(PIPELINE_OK, Start("bear-320x240.webm")); 894 ASSERT_EQ(PIPELINE_OK, Start("bear-320x240.webm"));
806 895
807 Play(); 896 Play();
808 897
809 ASSERT_TRUE(WaitUntilOnEnded()); 898 ASSERT_TRUE(WaitUntilOnEnded());
810 } 899 }
811 900
812 TEST_F(PipelineIntegrationTest, BasicPlaybackOpusOgg) { 901 TEST_F(PipelineIntegrationTest, BasicPlaybackOpusOgg) {
813 ASSERT_EQ(PIPELINE_OK, Start("bear-opus.ogg")); 902 ASSERT_EQ(PIPELINE_OK, Start("bear-opus.ogg"));
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
874 ASSERT_TRUE(Seek(base::TimeDelta::FromMilliseconds(6360))); 963 ASSERT_TRUE(Seek(base::TimeDelta::FromMilliseconds(6360)));
875 Play(); 964 Play();
876 ASSERT_TRUE(WaitUntilOnEnded()); 965 ASSERT_TRUE(WaitUntilOnEnded());
877 EXPECT_HASH_EQ(kOpusEndTrimmingHash_3, GetAudioHash()); 966 EXPECT_HASH_EQ(kOpusEndTrimmingHash_3, GetAudioHash());
878 } 967 }
879 968
880 TEST_F(PipelineIntegrationTest, 969 TEST_F(PipelineIntegrationTest,
881 MAYBE_CLOCKLESS(BasicPlaybackOpusWebmTrimmingHashed_MediaSource)) { 970 MAYBE_CLOCKLESS(BasicPlaybackOpusWebmTrimmingHashed_MediaSource)) {
882 MockMediaSource source("opus-trimming-test.webm", kOpusAudioOnlyWebM, 971 MockMediaSource source("opus-trimming-test.webm", kOpusAudioOnlyWebM,
883 kAppendWholeFile); 972 kAppendWholeFile);
884 StartHashedClocklessPipelineWithMediaSource(&source); 973 StartPipelineWithMediaSource(&source, kClockless | kHashed);
885 source.EndOfStream(); 974 source.EndOfStream();
886 975
887 Play(); 976 Play();
888 977
889 ASSERT_TRUE(WaitUntilOnEnded()); 978 ASSERT_TRUE(WaitUntilOnEnded());
890 EXPECT_HASH_EQ(kOpusEndTrimmingHash_1, GetAudioHash()); 979 EXPECT_HASH_EQ(kOpusEndTrimmingHash_1, GetAudioHash());
891 980
892 // Seek within the pre-skip section, this should not cause a beep. 981 // Seek within the pre-skip section, this should not cause a beep.
893 base::TimeDelta seek_time = base::TimeDelta::FromSeconds(1); 982 base::TimeDelta seek_time = base::TimeDelta::FromSeconds(1);
894 source.Seek(seek_time); 983 source.Seek(seek_time);
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
1044 1133
1045 ASSERT_TRUE(WaitUntilOnEnded()); 1134 ASSERT_TRUE(WaitUntilOnEnded());
1046 source.Shutdown(); 1135 source.Shutdown();
1047 Stop(); 1136 Stop();
1048 } 1137 }
1049 1138
1050 // Flaky. http://crbug.com/304776 1139 // Flaky. http://crbug.com/304776
1051 TEST_F(PipelineIntegrationTest, DISABLED_MediaSource_Opus_Seeking_WebM) { 1140 TEST_F(PipelineIntegrationTest, DISABLED_MediaSource_Opus_Seeking_WebM) {
1052 MockMediaSource source("bear-opus-end-trimming.webm", kOpusAudioOnlyWebM, 1141 MockMediaSource source("bear-opus-end-trimming.webm", kOpusAudioOnlyWebM,
1053 kAppendWholeFile); 1142 kAppendWholeFile);
1054 StartHashedPipelineWithMediaSource(&source); 1143 StartPipelineWithMediaSource(&source, kHashed);
1055 1144
1056 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); 1145 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size());
1057 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); 1146 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds());
1058 EXPECT_EQ(kOpusEndTrimmingWebMFileDurationMs, 1147 EXPECT_EQ(kOpusEndTrimmingWebMFileDurationMs,
1059 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); 1148 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds());
1060 1149
1061 base::TimeDelta start_seek_time = base::TimeDelta::FromMilliseconds(1000); 1150 base::TimeDelta start_seek_time = base::TimeDelta::FromMilliseconds(1000);
1062 base::TimeDelta seek_time = base::TimeDelta::FromMilliseconds(2000); 1151 base::TimeDelta seek_time = base::TimeDelta::FromMilliseconds(2000);
1063 1152
1064 Play(); 1153 Play();
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
1259 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); 1348 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds());
1260 EXPECT_EQ(325, pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); 1349 EXPECT_EQ(325, pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds());
1261 1350
1262 Play(); 1351 Play();
1263 1352
1264 EXPECT_TRUE(WaitUntilOnEnded()); 1353 EXPECT_TRUE(WaitUntilOnEnded());
1265 } 1354 }
1266 1355
1267 TEST_F(PipelineIntegrationTest, MediaSource_ADTS_TimestampOffset) { 1356 TEST_F(PipelineIntegrationTest, MediaSource_ADTS_TimestampOffset) {
1268 MockMediaSource source("sfx.adts", kADTS, kAppendWholeFile); 1357 MockMediaSource source("sfx.adts", kADTS, kAppendWholeFile);
1269 StartHashedPipelineWithMediaSource(&source); 1358 StartPipelineWithMediaSource(&source, kHashed);
1270 EXPECT_EQ(325, source.last_timestamp_offset().InMilliseconds()); 1359 EXPECT_EQ(325, source.last_timestamp_offset().InMilliseconds());
1271 1360
1272 // Trim off multiple frames off the beginning of the segment which will cause 1361 // Trim off multiple frames off the beginning of the segment which will cause
1273 // the first decoded frame to be incorrect if preroll isn't implemented. 1362 // the first decoded frame to be incorrect if preroll isn't implemented.
1274 const base::TimeDelta adts_preroll_duration = 1363 const base::TimeDelta adts_preroll_duration =
1275 base::TimeDelta::FromSecondsD(2.5 * 1024 / 44100); 1364 base::TimeDelta::FromSecondsD(2.5 * 1024 / 44100);
1276 const base::TimeDelta append_time = 1365 const base::TimeDelta append_time =
1277 source.last_timestamp_offset() - adts_preroll_duration; 1366 source.last_timestamp_offset() - adts_preroll_duration;
1278 1367
1279 scoped_refptr<DecoderBuffer> second_file = ReadTestDataFile("sfx.adts"); 1368 scoped_refptr<DecoderBuffer> second_file = ReadTestDataFile("sfx.adts");
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
1374 1463
1375 INSTANTIATE_TEST_CASE_P( 1464 INSTANTIATE_TEST_CASE_P(
1376 VBRSeeks_NoTOC, 1465 VBRSeeks_NoTOC,
1377 Mp3FastSeekIntegrationTest, 1466 Mp3FastSeekIntegrationTest,
1378 ::testing::Values(Mp3FastSeekParams("bear-audio-10s-VBR-no-TOC.mp3", 1467 ::testing::Values(Mp3FastSeekParams("bear-audio-10s-VBR-no-TOC.mp3",
1379 "-0.22,0.80,1.19,0.73,-0.31,-1.12,"))); 1468 "-0.22,0.80,1.19,0.73,-0.31,-1.12,")));
1380 #endif // !defined(DISABLE_CLOCKLESS_TESTS) 1469 #endif // !defined(DISABLE_CLOCKLESS_TESTS)
1381 1470
1382 TEST_F(PipelineIntegrationTest, MediaSource_MP3) { 1471 TEST_F(PipelineIntegrationTest, MediaSource_MP3) {
1383 MockMediaSource source("sfx.mp3", kMP3, kAppendWholeFile); 1472 MockMediaSource source("sfx.mp3", kMP3, kAppendWholeFile);
1384 StartHashedPipelineWithMediaSource(&source); 1473 StartPipelineWithMediaSource(&source, kHashed);
1385 source.EndOfStream(); 1474 source.EndOfStream();
1386 1475
1387 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); 1476 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size());
1388 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); 1477 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds());
1389 EXPECT_EQ(313, pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); 1478 EXPECT_EQ(313, pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds());
1390 1479
1391 Play(); 1480 Play();
1392 1481
1393 EXPECT_TRUE(WaitUntilOnEnded()); 1482 EXPECT_TRUE(WaitUntilOnEnded());
1394 1483
(...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after
2020 2109
2021 TEST_F(PipelineIntegrationTest, BasicPlaybackPositiveStartTime) { 2110 TEST_F(PipelineIntegrationTest, BasicPlaybackPositiveStartTime) {
2022 ASSERT_EQ(PIPELINE_OK, Start("nonzero-start-time.webm")); 2111 ASSERT_EQ(PIPELINE_OK, Start("nonzero-start-time.webm"));
2023 Play(); 2112 Play();
2024 ASSERT_TRUE(WaitUntilOnEnded()); 2113 ASSERT_TRUE(WaitUntilOnEnded());
2025 ASSERT_EQ(base::TimeDelta::FromMicroseconds(396000), 2114 ASSERT_EQ(base::TimeDelta::FromMicroseconds(396000),
2026 demuxer_->GetStartTime()); 2115 demuxer_->GetStartTime());
2027 } 2116 }
2028 2117
2029 } // namespace media 2118 } // namespace media
OLDNEW
« no previous file with comments | « media/test/data/bear-audio-main-aac.aac ('k') | media/test/pipeline_integration_test_base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698