OLD | NEW |
---|---|
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 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
73 #else | 73 #else |
74 #define MAYBE_EME(test) test | 74 #define MAYBE_EME(test) test |
75 #endif | 75 #endif |
76 | 76 |
77 #if defined(DISABLE_TEXT_TRACK_TESTS) | 77 #if defined(DISABLE_TEXT_TRACK_TESTS) |
78 #define MAYBE_TEXT(test) DISABLED_##test | 78 #define MAYBE_TEXT(test) DISABLED_##test |
79 #else | 79 #else |
80 #define MAYBE_TEXT(test) test | 80 #define MAYBE_TEXT(test) test |
81 #endif | 81 #endif |
82 | 82 |
83 #if defined(DISABLE_CLOCKLESS_TESTS) | |
84 #define MAYBE_CLOCKLESS(test) DISABLED_##test | |
85 #else | |
86 #define MAYBE_CLOCKLESS(test) test | |
87 #endif | |
88 | |
89 using testing::_; | 83 using testing::_; |
90 using testing::AnyNumber; | 84 using testing::AnyNumber; |
91 using testing::AtLeast; | 85 using testing::AtLeast; |
92 using testing::AtMost; | 86 using testing::AtMost; |
93 using testing::SaveArg; | 87 using testing::SaveArg; |
94 | 88 |
95 namespace media { | 89 namespace media { |
96 | 90 |
91 namespace { | |
92 | |
97 const char kSourceId[] = "SourceId"; | 93 const char kSourceId[] = "SourceId"; |
98 | 94 |
99 const char kWebM[] = "video/webm; codecs=\"vp8,vorbis\""; | 95 const char kWebM[] = "video/webm; codecs=\"vp8,vorbis\""; |
100 const char kWebMVP9[] = "video/webm; codecs=\"vp9\""; | 96 const char kWebMVP9[] = "video/webm; codecs=\"vp9\""; |
101 const char kAudioOnlyWebM[] = "video/webm; codecs=\"vorbis\""; | 97 const char kAudioOnlyWebM[] = "video/webm; codecs=\"vorbis\""; |
102 const char kOpusAudioOnlyWebM[] = "video/webm; codecs=\"opus\""; | 98 const char kOpusAudioOnlyWebM[] = "video/webm; codecs=\"opus\""; |
103 const char kVideoOnlyWebM[] = "video/webm; codecs=\"vp8\""; | 99 const char kVideoOnlyWebM[] = "video/webm; codecs=\"vp8\""; |
104 #if BUILDFLAG(USE_PROPRIETARY_CODECS) | 100 #if BUILDFLAG(USE_PROPRIETARY_CODECS) |
105 const char kADTS[] = "audio/aac"; | 101 const char kADTS[] = "audio/aac"; |
106 const char kMP4[] = "video/mp4; codecs=\"avc1.4D4041,mp4a.40.2\""; | 102 const char kMP4[] = "video/mp4; codecs=\"avc1.4D4041,mp4a.40.2\""; |
(...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
658 } | 654 } |
659 void Decode(const scoped_refptr<DecoderBuffer>& buffer, | 655 void Decode(const scoped_refptr<DecoderBuffer>& buffer, |
660 const DecodeCB& decode_cb) override { | 656 const DecodeCB& decode_cb) override { |
661 base::ThreadTaskRunnerHandle::Get()->PostTask( | 657 base::ThreadTaskRunnerHandle::Get()->PostTask( |
662 FROM_HERE, base::Bind(decode_cb, DecodeStatus::DECODE_ERROR)); | 658 FROM_HERE, base::Bind(decode_cb, DecodeStatus::DECODE_ERROR)); |
663 } | 659 } |
664 void Reset(const base::Closure& closure) override { closure.Run(); } | 660 void Reset(const base::Closure& closure) override { closure.Run(); } |
665 bool NeedsBitstreamConversion() const override { return true; } | 661 bool NeedsBitstreamConversion() const override { return true; } |
666 }; | 662 }; |
667 | 663 |
664 } // namespace | |
665 | |
668 // TODO(xhwang): These tests have been disabled for some time as apptests and no | 666 // TODO(xhwang): These tests have been disabled for some time as apptests and no |
669 // longer pass. They need to be reconstituted as shell tests. | 667 // longer pass. They need to be reconstituted as shell tests. |
670 // Currently there are compile issues which must be resolved, | 668 // Currently there are compile issues which must be resolved, |
671 // preferably by eliminating multiple inheritance here which is | 669 // preferably by eliminating multiple inheritance here which is |
672 // banned by Google C++ style. | 670 // banned by Google C++ style. |
673 #if defined(MOJO_RENDERER) && defined(ENABLE_MOJO_PIPELINE_INTEGRATION_TEST) | 671 #if defined(MOJO_RENDERER) && defined(ENABLE_MOJO_PIPELINE_INTEGRATION_TEST) |
674 class PipelineIntegrationTestHost : public service_manager::test::ServiceTest, | 672 class PipelineIntegrationTestHost : public service_manager::test::ServiceTest, |
675 public PipelineIntegrationTestBase { | 673 public PipelineIntegrationTestBase { |
676 public: | 674 public: |
677 PipelineIntegrationTestHost() | 675 PipelineIntegrationTestHost() |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
749 // never called. | 747 // never called. |
750 EXPECT_CALL(*this, OnWaitingForDecryptionKey()).Times(0); | 748 EXPECT_CALL(*this, OnWaitingForDecryptionKey()).Times(0); |
751 pipeline_->SetCdm(encrypted_media->GetCdmContext(), | 749 pipeline_->SetCdm(encrypted_media->GetCdmContext(), |
752 base::Bind(&PipelineIntegrationTest::DecryptorAttached, | 750 base::Bind(&PipelineIntegrationTest::DecryptorAttached, |
753 base::Unretained(this))); | 751 base::Unretained(this))); |
754 } else { | 752 } else { |
755 // Encrypted content not used, so this is never called. | 753 // Encrypted content not used, so this is never called. |
756 EXPECT_CALL(*this, OnWaitingForDecryptionKey()).Times(0); | 754 EXPECT_CALL(*this, OnWaitingForDecryptionKey()).Times(0); |
757 } | 755 } |
758 | 756 |
759 pipeline_->Start(demuxer_.get(), CreateRenderer(), this, | 757 pipeline_->Start(demuxer_.get(), renderer_factory_->CreateRenderer(), this, |
760 base::Bind(&PipelineIntegrationTest::OnStatusCallback, | 758 base::Bind(&PipelineIntegrationTest::OnStatusCallback, |
761 base::Unretained(this))); | 759 base::Unretained(this))); |
762 | 760 |
763 if (encrypted_media) { | 761 if (encrypted_media) { |
764 source->set_encrypted_media_init_data_cb( | 762 source->set_encrypted_media_init_data_cb( |
765 base::Bind(&FakeEncryptedMedia::OnEncryptedMediaInitData, | 763 base::Bind(&FakeEncryptedMedia::OnEncryptedMediaInitData, |
766 base::Unretained(encrypted_media))); | 764 base::Unretained(encrypted_media))); |
767 } | 765 } |
768 base::RunLoop().Run(); | 766 base::RunLoop().Run(); |
769 return pipeline_status_; | 767 return pipeline_status_; |
(...skipping 24 matching lines...) Expand all Loading... | |
794 | 792 |
795 source.EndOfStream(); | 793 source.EndOfStream(); |
796 | 794 |
797 source.Shutdown(); | 795 source.Shutdown(); |
798 Stop(); | 796 Stop(); |
799 return true; | 797 return true; |
800 } | 798 } |
801 }; | 799 }; |
802 | 800 |
803 struct PlaybackTestData { | 801 struct PlaybackTestData { |
802 const PipelineType type; | |
804 const std::string filename; | 803 const std::string filename; |
805 const uint32_t start_time_ms; | 804 const uint32_t start_time_ms; |
806 const uint32_t duration_ms; | 805 const uint32_t duration_ms; |
807 }; | 806 }; |
808 | 807 |
809 struct MSEPlaybackTestData { | 808 struct MSEPlaybackTestData { |
809 const PipelineType type; | |
810 const std::string filename; | 810 const std::string filename; |
811 const std::string mimetype; | 811 const std::string mimetype; |
812 const size_t append_bytes; | 812 const size_t append_bytes; |
813 const uint32_t duration_ms; | 813 const uint32_t duration_ms; |
814 }; | 814 }; |
815 | 815 |
816 // Tells gtest how to print our PlaybackTestData structure. | 816 // Tells gtest how to print our PlaybackTestData structure. |
817 std::ostream& operator<<(std::ostream& os, const PlaybackTestData& data) { | 817 std::ostream& operator<<(std::ostream& os, const PlaybackTestData& data) { |
818 return os << data.filename; | 818 return os << data.filename; |
819 } | 819 } |
820 | 820 |
821 std::ostream& operator<<(std::ostream& os, const MSEPlaybackTestData& data) { | 821 std::ostream& operator<<(std::ostream& os, const MSEPlaybackTestData& data) { |
822 return os << data.filename; | 822 return os << data.filename; |
823 } | 823 } |
824 | 824 |
825 class BasicPlaybackTest : public PipelineIntegrationTest, | 825 class BasicPlaybackTest : public PipelineIntegrationTest, |
826 public testing::WithParamInterface<PlaybackTestData> { | 826 public testing::WithParamInterface<PlaybackTestData> { |
827 public: | |
828 BasicPlaybackTest() { | |
829 #if BUILDFLAG(ENABLE_MEDIA_REMOTING) | |
830 if (GetParam().type == PipelineType::MediaRemoting) | |
831 SetUpRemotingPipeline(); | |
832 #endif // BUILDFLAG(ENABLE_MEDIA_REMOTING) | |
833 } | |
827 }; | 834 }; |
828 | 835 |
829 class BasicMSEPlaybackTest | 836 class BasicMSEPlaybackTest |
830 : public ::testing::WithParamInterface<MSEPlaybackTestData>, | 837 : public ::testing::WithParamInterface<MSEPlaybackTestData>, |
831 public PipelineIntegrationTest {}; | 838 public PipelineIntegrationTest { |
839 public: | |
840 BasicMSEPlaybackTest() { | |
841 #if BUILDFLAG(ENABLE_MEDIA_REMOTING) | |
842 if (GetParam().type == PipelineType::MediaRemoting) | |
843 SetUpRemotingPipeline(); | |
844 #endif // BUILDFLAG(ENABLE_MEDIA_REMOTING) | |
845 } | |
846 }; | |
832 | 847 |
833 TEST_P(BasicPlaybackTest, PlayToEnd) { | 848 TEST_P(BasicPlaybackTest, PlayToEnd) { |
834 PlaybackTestData data = GetParam(); | 849 PlaybackTestData data = GetParam(); |
835 | |
836 ASSERT_EQ(PIPELINE_OK, | 850 ASSERT_EQ(PIPELINE_OK, |
837 Start(data.filename, kClockless | kUnreliableDuration)); | 851 Start(data.filename, kClockless | kUnreliableDuration)); |
838 EXPECT_EQ(data.start_time_ms, demuxer_->GetStartTime().InMilliseconds()); | 852 EXPECT_EQ(data.start_time_ms, demuxer_->GetStartTime().InMilliseconds()); |
839 EXPECT_EQ(data.duration_ms, pipeline_->GetMediaDuration().InMilliseconds()); | 853 EXPECT_EQ(data.duration_ms, pipeline_->GetMediaDuration().InMilliseconds()); |
840 | 854 |
841 Play(); | 855 Play(); |
842 ASSERT_TRUE(WaitUntilOnEnded()); | 856 ASSERT_TRUE(WaitUntilOnEnded()); |
843 } | 857 } |
844 | 858 |
845 TEST_P(BasicMSEPlaybackTest, PlayToEnd) { | 859 TEST_P(BasicMSEPlaybackTest, PlayToEnd) { |
846 MSEPlaybackTestData data = GetParam(); | 860 MSEPlaybackTestData data = GetParam(); |
847 | |
848 MockMediaSource source(data.filename, data.mimetype, data.append_bytes); | 861 MockMediaSource source(data.filename, data.mimetype, data.append_bytes); |
849 // TODO -- ADD uint8_t test_type to StartWithMSE and pass clockless flags | 862 // TODO -- ADD uint8_t test_type to StartWithMSE and pass clockless flags |
850 ASSERT_EQ(PIPELINE_OK, | 863 ASSERT_EQ(PIPELINE_OK, |
851 StartPipelineWithMediaSource(&source, kClockless, nullptr)); | 864 StartPipelineWithMediaSource(&source, kClockless, nullptr)); |
852 source.EndOfStream(); | 865 source.EndOfStream(); |
853 | 866 |
854 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); | 867 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); |
855 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); | 868 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); |
856 EXPECT_EQ(data.duration_ms, | 869 EXPECT_EQ(data.duration_ms, |
857 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); | 870 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); |
858 | 871 |
859 Play(); | 872 Play(); |
860 | 873 |
861 ASSERT_TRUE(WaitUntilOnEnded()); | 874 ASSERT_TRUE(WaitUntilOnEnded()); |
862 | 875 |
863 EXPECT_TRUE(demuxer_->GetTimelineOffset().is_null()); | 876 EXPECT_TRUE(demuxer_->GetTimelineOffset().is_null()); |
864 source.Shutdown(); | 877 source.Shutdown(); |
865 Stop(); | 878 Stop(); |
866 } | 879 } |
867 | 880 |
868 #if BUILDFLAG(USE_PROPRIETARY_CODECS) | 881 #if BUILDFLAG(USE_PROPRIETARY_CODECS) |
869 | 882 |
883 // Any new/changed entries should be made for both the ::Media and | |
884 // ::MediaRemoting types. If you don't think something applies, please contact | |
885 // one of the media/remoting/OWNERS. | |
870 const PlaybackTestData kADTSTests[] = { | 886 const PlaybackTestData kADTSTests[] = { |
871 {"bear-audio-main-aac.aac", 0, 2724}, | 887 {PipelineType::Media, "bear-audio-main-aac.aac", 0, 2724}, |
872 {"bear-audio-lc-aac.aac", 0, 2858}, | 888 {PipelineType::Media, "bear-audio-lc-aac.aac", 0, 2858}, |
873 {"bear-audio-implicit-he-aac-v1.aac", 0, 2812}, | 889 {PipelineType::Media, "bear-audio-implicit-he-aac-v1.aac", 0, 2812}, |
874 {"bear-audio-implicit-he-aac-v2.aac", 0, 3047}, | 890 {PipelineType::Media, "bear-audio-implicit-he-aac-v2.aac", 0, 3047}, |
891 #if BUILDFLAG(ENABLE_MEDIA_REMOTING) | |
892 {PipelineType::MediaRemoting, "bear-audio-main-aac.aac", 0, 2724}, | |
893 {PipelineType::MediaRemoting, "bear-audio-lc-aac.aac", 0, 2858}, | |
894 {PipelineType::MediaRemoting, "bear-audio-implicit-he-aac-v1.aac", 0, 2812}, | |
895 {PipelineType::MediaRemoting, "bear-audio-implicit-he-aac-v2.aac", 0, 3047}, | |
896 #endif // BUILDFLAG(ENABLE_MEDIA_REMOTING) | |
875 }; | 897 }; |
876 | 898 |
877 // TODO(chcunningham): Migrate other basic playback tests to TEST_P. | 899 // TODO(chcunningham): Migrate other basic playback tests to TEST_P. |
878 INSTANTIATE_TEST_CASE_P(ProprietaryCodecs, | 900 INSTANTIATE_TEST_CASE_P(ProprietaryCodecs, |
879 BasicPlaybackTest, | 901 BasicPlaybackTest, |
880 testing::ValuesIn(kADTSTests)); | 902 testing::ValuesIn(kADTSTests)); |
881 | 903 |
904 // Any new/changed entries should be made for both the ::Media and | |
905 // ::MediaRemoting types. If you don't think something applies, please contact | |
906 // one of the media/remoting/OWNERS. | |
882 const MSEPlaybackTestData kMediaSourceADTSTests[] = { | 907 const MSEPlaybackTestData kMediaSourceADTSTests[] = { |
883 {"bear-audio-main-aac.aac", kADTS, kAppendWholeFile, 2773}, | 908 {PipelineType::Media, "bear-audio-main-aac.aac", kADTS, kAppendWholeFile, |
884 {"bear-audio-lc-aac.aac", kADTS, kAppendWholeFile, 2794}, | 909 2773}, |
885 {"bear-audio-implicit-he-aac-v1.aac", kADTS, kAppendWholeFile, 2858}, | 910 {PipelineType::Media, "bear-audio-lc-aac.aac", kADTS, kAppendWholeFile, |
886 {"bear-audio-implicit-he-aac-v2.aac", kADTS, kAppendWholeFile, 2901}, | 911 2794}, |
912 {PipelineType::Media, "bear-audio-implicit-he-aac-v1.aac", kADTS, | |
913 kAppendWholeFile, 2858}, | |
914 {PipelineType::Media, "bear-audio-implicit-he-aac-v2.aac", kADTS, | |
915 kAppendWholeFile, 2901}, | |
916 #if BUILDFLAG(ENABLE_MEDIA_REMOTING) | |
917 {PipelineType::MediaRemoting, "bear-audio-main-aac.aac", kADTS, | |
918 kAppendWholeFile, 2773}, | |
919 {PipelineType::MediaRemoting, "bear-audio-lc-aac.aac", kADTS, | |
920 kAppendWholeFile, 2794}, | |
921 {PipelineType::MediaRemoting, "bear-audio-implicit-he-aac-v1.aac", kADTS, | |
922 kAppendWholeFile, 2858}, | |
923 {PipelineType::MediaRemoting, "bear-audio-implicit-he-aac-v2.aac", kADTS, | |
924 kAppendWholeFile, 2901}, | |
925 #endif // BUILDFLAG(ENABLE_MEDIA_REMOTING) | |
887 }; | 926 }; |
888 | 927 |
889 // TODO(chcunningham): Migrate other basic MSE playback tests to TEST_P. | 928 // TODO(chcunningham): Migrate other basic MSE playback tests to TEST_P. |
890 INSTANTIATE_TEST_CASE_P(ProprietaryCodecs, | 929 INSTANTIATE_TEST_CASE_P(ProprietaryCodecs, |
891 BasicMSEPlaybackTest, | 930 BasicMSEPlaybackTest, |
892 testing::ValuesIn(kMediaSourceADTSTests)); | 931 testing::ValuesIn(kMediaSourceADTSTests)); |
893 | 932 |
894 #endif // BUILDFLAG(USE_PROPRIETARY_CODECS) | 933 #endif // BUILDFLAG(USE_PROPRIETARY_CODECS) |
895 | 934 |
896 TEST_F(PipelineIntegrationTest, BasicPlayback) { | 935 struct IntegrationTestData { |
936 const PipelineType type; | |
937 }; | |
938 | |
939 // Tells gtest how to print our PlaybackTestData structure. | |
940 std::ostream& operator<<(std::ostream& os, const IntegrationTestData& data) { | |
941 return os << (data.type == PipelineType::Media ? "Media" : "MediaRemoting"); | |
942 } | |
943 | |
944 // These tests are used to test both media pipeline and media remoting pipeline. | |
945 class CommonPipelineIntegrationTest | |
946 : public PipelineIntegrationTest, | |
947 public testing::WithParamInterface<IntegrationTestData> { | |
948 public: | |
949 CommonPipelineIntegrationTest() { | |
950 #if BUILDFLAG(ENABLE_MEDIA_REMOTING) | |
951 if (GetParam().type == PipelineType::MediaRemoting) | |
952 SetUpRemotingPipeline(); | |
953 #endif // BUILDFLAG(ENABLE_MEDIA_REMOTING) | |
954 } | |
955 }; | |
956 | |
957 TEST_P(CommonPipelineIntegrationTest, BasicPlayback) { | |
897 ASSERT_EQ(PIPELINE_OK, Start("bear-320x240.webm")); | 958 ASSERT_EQ(PIPELINE_OK, Start("bear-320x240.webm")); |
898 | 959 |
899 Play(); | 960 Play(); |
900 | 961 |
901 ASSERT_TRUE(WaitUntilOnEnded()); | 962 ASSERT_TRUE(WaitUntilOnEnded()); |
902 } | 963 } |
903 | 964 |
904 TEST_F(PipelineIntegrationTest, BasicPlaybackOpusOgg) { | 965 TEST_P(CommonPipelineIntegrationTest, BasicPlaybackOpusOgg) { |
905 ASSERT_EQ(PIPELINE_OK, Start("bear-opus.ogg")); | 966 ASSERT_EQ(PIPELINE_OK, Start("bear-opus.ogg")); |
906 | 967 |
907 Play(); | 968 Play(); |
908 | 969 |
909 ASSERT_TRUE(WaitUntilOnEnded()); | 970 ASSERT_TRUE(WaitUntilOnEnded()); |
910 } | 971 } |
911 | 972 |
912 TEST_F(PipelineIntegrationTest, BasicPlaybackHashed) { | 973 TEST_P(CommonPipelineIntegrationTest, BasicPlaybackHashed) { |
913 ASSERT_EQ(PIPELINE_OK, Start("bear-320x240.webm", kHashed)); | 974 ASSERT_EQ(PIPELINE_OK, Start("bear-320x240.webm", kHashed)); |
914 | 975 |
915 Play(); | 976 Play(); |
916 | 977 |
917 ASSERT_TRUE(WaitUntilOnEnded()); | 978 ASSERT_TRUE(WaitUntilOnEnded()); |
918 | 979 |
919 EXPECT_HASH_EQ("f0be120a90a811506777c99a2cdf7cc1", GetVideoHash()); | 980 EXPECT_HASH_EQ("f0be120a90a811506777c99a2cdf7cc1", GetVideoHash()); |
920 EXPECT_HASH_EQ("-3.59,-2.06,-0.43,2.15,0.77,-0.95,", GetAudioHash()); | 981 EXPECT_HASH_EQ("-3.59,-2.06,-0.43,2.15,0.77,-0.95,", GetAudioHash()); |
921 EXPECT_TRUE(demuxer_->GetTimelineOffset().is_null()); | 982 EXPECT_TRUE(demuxer_->GetTimelineOffset().is_null()); |
922 } | 983 } |
923 | 984 |
924 base::TimeDelta TimestampMs(int milliseconds) { | 985 base::TimeDelta TimestampMs(int milliseconds) { |
925 return base::TimeDelta::FromMilliseconds(milliseconds); | 986 return base::TimeDelta::FromMilliseconds(milliseconds); |
926 } | 987 } |
927 | 988 |
928 TEST_F(PipelineIntegrationTest, PlaybackWithAudioTrackDisabledThenEnabled) { | 989 TEST_P(CommonPipelineIntegrationTest, |
990 PlaybackWithAudioTrackDisabledThenEnabled) { | |
929 ASSERT_EQ(PIPELINE_OK, Start("bear-320x240.webm", kHashed)); | 991 ASSERT_EQ(PIPELINE_OK, Start("bear-320x240.webm", kHashed)); |
930 | 992 |
931 // Disable audio. | 993 // Disable audio. |
932 std::vector<MediaTrack::Id> empty; | 994 std::vector<MediaTrack::Id> empty; |
933 pipeline_->OnEnabledAudioTracksChanged(empty); | 995 pipeline_->OnEnabledAudioTracksChanged(empty); |
934 base::RunLoop().RunUntilIdle(); | 996 base::RunLoop().RunUntilIdle(); |
935 | 997 |
936 // Seek to flush the pipeline and ensure there's no prerolled audio data. | 998 // Seek to flush the pipeline and ensure there's no prerolled audio data. |
937 ASSERT_TRUE(Seek(base::TimeDelta())); | 999 ASSERT_TRUE(Seek(base::TimeDelta())); |
938 | 1000 |
(...skipping 13 matching lines...) Expand all Loading... | |
952 | 1014 |
953 // Restart playback from 500ms position. | 1015 // Restart playback from 500ms position. |
954 ASSERT_TRUE(Seek(k500ms)); | 1016 ASSERT_TRUE(Seek(k500ms)); |
955 Play(); | 1017 Play(); |
956 ASSERT_TRUE(WaitUntilOnEnded()); | 1018 ASSERT_TRUE(WaitUntilOnEnded()); |
957 | 1019 |
958 // Verify that audio has been playing after being enabled. | 1020 // Verify that audio has been playing after being enabled. |
959 EXPECT_HASH_EQ("-1.53,0.21,1.23,1.56,-0.34,-0.94,", GetAudioHash()); | 1021 EXPECT_HASH_EQ("-1.53,0.21,1.23,1.56,-0.34,-0.94,", GetAudioHash()); |
960 } | 1022 } |
961 | 1023 |
962 TEST_F(PipelineIntegrationTest, PlaybackWithVideoTrackDisabledThenEnabled) { | 1024 TEST_P(CommonPipelineIntegrationTest, |
1025 PlaybackWithVideoTrackDisabledThenEnabled) { | |
963 ASSERT_EQ(PIPELINE_OK, Start("bear-320x240.webm", kHashed)); | 1026 ASSERT_EQ(PIPELINE_OK, Start("bear-320x240.webm", kHashed)); |
964 | 1027 |
965 // Disable video. | 1028 // Disable video. |
966 pipeline_->OnSelectedVideoTrackChanged(base::nullopt); | 1029 pipeline_->OnSelectedVideoTrackChanged(base::nullopt); |
967 base::RunLoop().RunUntilIdle(); | 1030 base::RunLoop().RunUntilIdle(); |
968 | 1031 |
969 // Seek to flush the pipeline and ensure there's no prerolled video data. | 1032 // Seek to flush the pipeline and ensure there's no prerolled video data. |
970 ASSERT_TRUE(Seek(base::TimeDelta())); | 1033 ASSERT_TRUE(Seek(base::TimeDelta())); |
971 | 1034 |
972 // Reset the video hash in case some of the prerolled video frames have been | 1035 // Reset the video hash in case some of the prerolled video frames have been |
(...skipping 19 matching lines...) Expand all Loading... | |
992 | 1055 |
993 // Restart playback from 500ms position. | 1056 // Restart playback from 500ms position. |
994 ASSERT_TRUE(Seek(k500ms)); | 1057 ASSERT_TRUE(Seek(k500ms)); |
995 Play(); | 1058 Play(); |
996 ASSERT_TRUE(WaitUntilOnEnded()); | 1059 ASSERT_TRUE(WaitUntilOnEnded()); |
997 | 1060 |
998 // Verify that video has been rendered after being enabled. | 1061 // Verify that video has been rendered after being enabled. |
999 EXPECT_HASH_EQ("fd59357dfd9c144ab4fb8181b2de32c3", GetVideoHash()); | 1062 EXPECT_HASH_EQ("fd59357dfd9c144ab4fb8181b2de32c3", GetVideoHash()); |
1000 } | 1063 } |
1001 | 1064 |
1002 TEST_F(PipelineIntegrationTest, TrackStatusChangesBeforePipelineStarted) { | 1065 TEST_P(CommonPipelineIntegrationTest, TrackStatusChangesBeforePipelineStarted) { |
1003 std::vector<MediaTrack::Id> empty_track_ids; | 1066 std::vector<MediaTrack::Id> empty_track_ids; |
1004 pipeline_->OnEnabledAudioTracksChanged(empty_track_ids); | 1067 pipeline_->OnEnabledAudioTracksChanged(empty_track_ids); |
1005 pipeline_->OnSelectedVideoTrackChanged(base::nullopt); | 1068 pipeline_->OnSelectedVideoTrackChanged(base::nullopt); |
1006 } | 1069 } |
1007 | 1070 |
1008 TEST_F(PipelineIntegrationTest, TrackStatusChangesAfterPipelineEnded) { | 1071 TEST_P(CommonPipelineIntegrationTest, TrackStatusChangesAfterPipelineEnded) { |
1009 ASSERT_EQ(PIPELINE_OK, Start("bear-320x240.webm", kHashed)); | 1072 ASSERT_EQ(PIPELINE_OK, Start("bear-320x240.webm", kHashed)); |
1010 Play(); | 1073 Play(); |
1011 ASSERT_TRUE(WaitUntilOnEnded()); | 1074 ASSERT_TRUE(WaitUntilOnEnded()); |
1012 std::vector<MediaTrack::Id> track_ids; | 1075 std::vector<MediaTrack::Id> track_ids; |
1013 // Disable audio track. | 1076 // Disable audio track. |
1014 pipeline_->OnEnabledAudioTracksChanged(track_ids); | 1077 pipeline_->OnEnabledAudioTracksChanged(track_ids); |
1015 // Re-enable audio track. | 1078 // Re-enable audio track. |
1016 track_ids.push_back("2"); | 1079 track_ids.push_back("2"); |
1017 pipeline_->OnEnabledAudioTracksChanged(track_ids); | 1080 pipeline_->OnEnabledAudioTracksChanged(track_ids); |
1018 // Disable video track. | 1081 // Disable video track. |
1019 pipeline_->OnSelectedVideoTrackChanged(base::nullopt); | 1082 pipeline_->OnSelectedVideoTrackChanged(base::nullopt); |
1020 // Re-enable video track. | 1083 // Re-enable video track. |
1021 pipeline_->OnSelectedVideoTrackChanged(MediaTrack::Id("1")); | 1084 pipeline_->OnSelectedVideoTrackChanged(MediaTrack::Id("1")); |
1022 } | 1085 } |
1023 | 1086 |
1024 TEST_F(PipelineIntegrationTest, TrackStatusChangesWhileSuspended) { | 1087 TEST_P(CommonPipelineIntegrationTest, TrackStatusChangesWhileSuspended) { |
1025 ASSERT_EQ(PIPELINE_OK, Start("bear-320x240.webm", kHashed)); | 1088 ASSERT_EQ(PIPELINE_OK, Start("bear-320x240.webm", kHashed)); |
1026 Play(); | 1089 Play(); |
1027 | 1090 |
1028 ASSERT_TRUE(Suspend()); | 1091 ASSERT_TRUE(Suspend()); |
1029 | 1092 |
1030 // These get triggered every time playback is resumed. | 1093 // These get triggered every time playback is resumed. |
1031 EXPECT_CALL(*this, OnVideoNaturalSizeChange(gfx::Size(320, 240))) | 1094 EXPECT_CALL(*this, OnVideoNaturalSizeChange(gfx::Size(320, 240))) |
1032 .Times(AnyNumber()); | 1095 .Times(AnyNumber()); |
1033 EXPECT_CALL(*this, OnVideoOpacityChange(true)).Times(AnyNumber()); | 1096 EXPECT_CALL(*this, OnVideoOpacityChange(true)).Times(AnyNumber()); |
1034 | 1097 |
(...skipping 17 matching lines...) Expand all Loading... | |
1052 ASSERT_TRUE(Resume(TimestampMs(300))); | 1115 ASSERT_TRUE(Resume(TimestampMs(300))); |
1053 ASSERT_TRUE(WaitUntilCurrentTimeIsAfter(TimestampMs(400))); | 1116 ASSERT_TRUE(WaitUntilCurrentTimeIsAfter(TimestampMs(400))); |
1054 ASSERT_TRUE(Suspend()); | 1117 ASSERT_TRUE(Suspend()); |
1055 | 1118 |
1056 // Re-enable video track. | 1119 // Re-enable video track. |
1057 pipeline_->OnSelectedVideoTrackChanged(MediaTrack::Id("1")); | 1120 pipeline_->OnSelectedVideoTrackChanged(MediaTrack::Id("1")); |
1058 ASSERT_TRUE(Resume(TimestampMs(400))); | 1121 ASSERT_TRUE(Resume(TimestampMs(400))); |
1059 ASSERT_TRUE(WaitUntilOnEnded()); | 1122 ASSERT_TRUE(WaitUntilOnEnded()); |
1060 } | 1123 } |
1061 | 1124 |
1062 TEST_F(PipelineIntegrationTest, ReinitRenderersWhileAudioTrackIsDisabled) { | 1125 TEST_P(CommonPipelineIntegrationTest, PipelineStoppedWhileAudioRestartPending) { |
1063 ASSERT_EQ(PIPELINE_OK, Start("bear-320x240.webm")); | 1126 ASSERT_EQ(PIPELINE_OK, Start("bear-320x240.webm")); |
1064 Play(); | 1127 Play(); |
1065 | 1128 |
1066 // These get triggered every time playback is resumed. | |
1067 EXPECT_CALL(*this, OnVideoNaturalSizeChange(gfx::Size(320, 240))) | |
1068 .Times(AnyNumber()); | |
1069 EXPECT_CALL(*this, OnVideoOpacityChange(true)).Times(AnyNumber()); | |
1070 | |
1071 // Disable the audio track. | |
1072 std::vector<MediaTrack::Id> track_ids; | |
1073 pipeline_->OnEnabledAudioTracksChanged(track_ids); | |
1074 // pipeline.Suspend() releases renderers and pipeline.Resume() recreates and | |
1075 // reinitializes renderers while the audio track is disabled. | |
1076 ASSERT_TRUE(Suspend()); | |
1077 ASSERT_TRUE(Resume(TimestampMs(100))); | |
1078 // Now re-enable the audio track, playback should continue successfully. | |
1079 EXPECT_CALL(*this, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)).Times(1); | |
1080 track_ids.push_back("2"); | |
1081 pipeline_->OnEnabledAudioTracksChanged(track_ids); | |
1082 ASSERT_TRUE(WaitUntilCurrentTimeIsAfter(TimestampMs(200))); | |
1083 | |
1084 Stop(); | |
1085 } | |
1086 | |
1087 TEST_F(PipelineIntegrationTest, ReinitRenderersWhileVideoTrackIsDisabled) { | |
1088 ASSERT_EQ(PIPELINE_OK, Start("bear-320x240.webm", kHashed)); | |
1089 Play(); | |
1090 | |
1091 // These get triggered every time playback is resumed. | |
1092 EXPECT_CALL(*this, OnVideoNaturalSizeChange(gfx::Size(320, 240))) | |
1093 .Times(AnyNumber()); | |
1094 EXPECT_CALL(*this, OnVideoOpacityChange(true)).Times(AnyNumber()); | |
1095 | |
1096 // Disable the video track. | |
1097 pipeline_->OnSelectedVideoTrackChanged(base::nullopt); | |
1098 // pipeline.Suspend() releases renderers and pipeline.Resume() recreates and | |
1099 // reinitializes renderers while the video track is disabled. | |
1100 ASSERT_TRUE(Suspend()); | |
1101 ASSERT_TRUE(Resume(TimestampMs(100))); | |
1102 // Now re-enable the video track, playback should continue successfully. | |
1103 pipeline_->OnSelectedVideoTrackChanged(MediaTrack::Id("1")); | |
1104 ASSERT_TRUE(WaitUntilCurrentTimeIsAfter(TimestampMs(200))); | |
1105 | |
1106 Stop(); | |
1107 } | |
1108 | |
1109 TEST_F(PipelineIntegrationTest, PipelineStoppedWhileAudioRestartPending) { | |
1110 ASSERT_EQ(PIPELINE_OK, Start("bear-320x240.webm")); | |
1111 Play(); | |
1112 | |
1113 // Disable audio track first, to re-enable it later and stop the pipeline | 1129 // Disable audio track first, to re-enable it later and stop the pipeline |
1114 // (which destroys the media renderer) while audio restart is pending. | 1130 // (which destroys the media renderer) while audio restart is pending. |
1115 std::vector<MediaTrack::Id> track_ids; | 1131 std::vector<MediaTrack::Id> track_ids; |
1116 pipeline_->OnEnabledAudioTracksChanged(track_ids); | 1132 pipeline_->OnEnabledAudioTracksChanged(track_ids); |
1117 ASSERT_TRUE(WaitUntilCurrentTimeIsAfter(TimestampMs(200))); | 1133 ASSERT_TRUE(WaitUntilCurrentTimeIsAfter(TimestampMs(200))); |
1118 | 1134 |
1119 track_ids.push_back("2"); | 1135 track_ids.push_back("2"); |
1120 pipeline_->OnEnabledAudioTracksChanged(track_ids); | 1136 pipeline_->OnEnabledAudioTracksChanged(track_ids); |
1121 Stop(); | 1137 Stop(); |
1122 } | 1138 } |
1123 | 1139 |
1124 TEST_F(PipelineIntegrationTest, PipelineStoppedWhileVideoRestartPending) { | 1140 TEST_P(CommonPipelineIntegrationTest, PipelineStoppedWhileVideoRestartPending) { |
1125 ASSERT_EQ(PIPELINE_OK, Start("bear-320x240.webm")); | 1141 ASSERT_EQ(PIPELINE_OK, Start("bear-320x240.webm")); |
1126 Play(); | 1142 Play(); |
1127 | 1143 |
1128 // Disable video track first, to re-enable it later and stop the pipeline | 1144 // Disable video track first, to re-enable it later and stop the pipeline |
1129 // (which destroys the media renderer) while video restart is pending. | 1145 // (which destroys the media renderer) while video restart is pending. |
1130 pipeline_->OnSelectedVideoTrackChanged(base::nullopt); | 1146 pipeline_->OnSelectedVideoTrackChanged(base::nullopt); |
1131 ASSERT_TRUE(WaitUntilCurrentTimeIsAfter(TimestampMs(200))); | 1147 ASSERT_TRUE(WaitUntilCurrentTimeIsAfter(TimestampMs(200))); |
1132 | 1148 |
1133 pipeline_->OnSelectedVideoTrackChanged(MediaTrack::Id("1")); | 1149 pipeline_->OnSelectedVideoTrackChanged(MediaTrack::Id("1")); |
1134 Stop(); | 1150 Stop(); |
1135 } | 1151 } |
1136 | 1152 |
1137 TEST_F(PipelineIntegrationTest, | 1153 #if !defined(DISABLE_CLOCKLESS_TESTS) |
miu
2017/04/09 03:25:53
This is prone to errors, since it's easy for futur
xjz
2017/04/10 17:14:52
Is there a way to make the MAYBE_CLOCKLESS() macro
sandersd (OOO until July 31)
2017/04/10 22:26:24
Dale has requested that the remoting tests be limi
xjz
2017/04/14 23:51:31
Done. Now don't test these for media remoting pipe
| |
1138 MAYBE_CLOCKLESS(BasicPlaybackOpusOggTrimmingHashed)) { | 1154 TEST_P(CommonPipelineIntegrationTest, BasicPlaybackOpusOggTrimmingHashed) { |
1139 ASSERT_EQ(PIPELINE_OK, | 1155 ASSERT_EQ(PIPELINE_OK, |
1140 Start("opus-trimming-test.webm", kHashed | kClockless)); | 1156 Start("opus-trimming-test.webm", kHashed | kClockless)); |
1141 | 1157 |
1142 Play(); | 1158 Play(); |
1143 | 1159 |
1144 ASSERT_TRUE(WaitUntilOnEnded()); | 1160 ASSERT_TRUE(WaitUntilOnEnded()); |
1145 EXPECT_HASH_EQ(kOpusEndTrimmingHash_1, GetAudioHash()); | 1161 EXPECT_HASH_EQ(kOpusEndTrimmingHash_1, GetAudioHash()); |
1146 | 1162 |
1147 // Seek within the pre-skip section, this should not cause a beep. | 1163 // Seek within the pre-skip section, this should not cause a beep. |
1148 ASSERT_TRUE(Seek(base::TimeDelta::FromSeconds(1))); | 1164 ASSERT_TRUE(Seek(base::TimeDelta::FromSeconds(1))); |
1149 Play(); | 1165 Play(); |
1150 ASSERT_TRUE(WaitUntilOnEnded()); | 1166 ASSERT_TRUE(WaitUntilOnEnded()); |
1151 EXPECT_HASH_EQ(kOpusEndTrimmingHash_2, GetAudioHash()); | 1167 EXPECT_HASH_EQ(kOpusEndTrimmingHash_2, GetAudioHash()); |
1152 | 1168 |
1153 // Seek somewhere outside of the pre-skip / end-trim section, demxuer should | 1169 // Seek somewhere outside of the pre-skip / end-trim section, demxuer should |
1154 // correctly preroll enough to accurately decode this segment. | 1170 // correctly preroll enough to accurately decode this segment. |
1155 ASSERT_TRUE(Seek(base::TimeDelta::FromMilliseconds(6360))); | 1171 ASSERT_TRUE(Seek(base::TimeDelta::FromMilliseconds(6360))); |
1156 Play(); | 1172 Play(); |
1157 ASSERT_TRUE(WaitUntilOnEnded()); | 1173 ASSERT_TRUE(WaitUntilOnEnded()); |
1158 EXPECT_HASH_EQ(kOpusEndTrimmingHash_3, GetAudioHash()); | 1174 EXPECT_HASH_EQ(kOpusEndTrimmingHash_3, GetAudioHash()); |
1159 } | 1175 } |
1160 | 1176 |
1161 TEST_F(PipelineIntegrationTest, | 1177 TEST_P(CommonPipelineIntegrationTest, BasicPlaybackOpusWebmTrimmingHashed) { |
1162 MAYBE_CLOCKLESS(BasicPlaybackOpusWebmTrimmingHashed)) { | |
1163 ASSERT_EQ(PIPELINE_OK, | 1178 ASSERT_EQ(PIPELINE_OK, |
1164 Start("opus-trimming-test.webm", kHashed | kClockless)); | 1179 Start("opus-trimming-test.webm", kHashed | kClockless)); |
1165 | 1180 |
1166 Play(); | 1181 Play(); |
1167 | 1182 |
1168 ASSERT_TRUE(WaitUntilOnEnded()); | 1183 ASSERT_TRUE(WaitUntilOnEnded()); |
1169 EXPECT_HASH_EQ(kOpusEndTrimmingHash_1, GetAudioHash()); | 1184 EXPECT_HASH_EQ(kOpusEndTrimmingHash_1, GetAudioHash()); |
1170 | 1185 |
1171 // Seek within the pre-skip section, this should not cause a beep. | 1186 // Seek within the pre-skip section, this should not cause a beep. |
1172 ASSERT_TRUE(Seek(base::TimeDelta::FromSeconds(1))); | 1187 ASSERT_TRUE(Seek(base::TimeDelta::FromSeconds(1))); |
1173 Play(); | 1188 Play(); |
1174 ASSERT_TRUE(WaitUntilOnEnded()); | 1189 ASSERT_TRUE(WaitUntilOnEnded()); |
1175 EXPECT_HASH_EQ(kOpusEndTrimmingHash_2, GetAudioHash()); | 1190 EXPECT_HASH_EQ(kOpusEndTrimmingHash_2, GetAudioHash()); |
1176 | 1191 |
1177 // Seek somewhere outside of the pre-skip / end-trim section, demxuer should | 1192 // Seek somewhere outside of the pre-skip / end-trim section, demxuer should |
1178 // correctly preroll enough to accurately decode this segment. | 1193 // correctly preroll enough to accurately decode this segment. |
1179 ASSERT_TRUE(Seek(base::TimeDelta::FromMilliseconds(6360))); | 1194 ASSERT_TRUE(Seek(base::TimeDelta::FromMilliseconds(6360))); |
1180 Play(); | 1195 Play(); |
1181 ASSERT_TRUE(WaitUntilOnEnded()); | 1196 ASSERT_TRUE(WaitUntilOnEnded()); |
1182 EXPECT_HASH_EQ(kOpusEndTrimmingHash_3, GetAudioHash()); | 1197 EXPECT_HASH_EQ(kOpusEndTrimmingHash_3, GetAudioHash()); |
1183 } | 1198 } |
1184 | 1199 |
1185 TEST_F(PipelineIntegrationTest, | 1200 TEST_P(CommonPipelineIntegrationTest, |
1186 MAYBE_CLOCKLESS(BasicPlaybackOpusWebmTrimmingHashed_MediaSource)) { | 1201 BasicPlaybackOpusWebmTrimmingHashed_MediaSource) { |
1187 MockMediaSource source("opus-trimming-test.webm", kOpusAudioOnlyWebM, | 1202 MockMediaSource source("opus-trimming-test.webm", kOpusAudioOnlyWebM, |
1188 kAppendWholeFile); | 1203 kAppendWholeFile); |
1189 EXPECT_EQ(PIPELINE_OK, StartPipelineWithMediaSource( | 1204 EXPECT_EQ(PIPELINE_OK, StartPipelineWithMediaSource( |
1190 &source, kClockless | kHashed, nullptr)); | 1205 &source, kClockless | kHashed, nullptr)); |
1191 source.EndOfStream(); | 1206 source.EndOfStream(); |
1192 | 1207 |
1193 Play(); | 1208 Play(); |
1194 | 1209 |
1195 ASSERT_TRUE(WaitUntilOnEnded()); | 1210 ASSERT_TRUE(WaitUntilOnEnded()); |
1196 EXPECT_HASH_EQ(kOpusEndTrimmingHash_1, GetAudioHash()); | 1211 EXPECT_HASH_EQ(kOpusEndTrimmingHash_1, GetAudioHash()); |
1197 | 1212 |
1198 // Seek within the pre-skip section, this should not cause a beep. | 1213 // Seek within the pre-skip section, this should not cause a beep. |
1199 base::TimeDelta seek_time = base::TimeDelta::FromSeconds(1); | 1214 base::TimeDelta seek_time = base::TimeDelta::FromSeconds(1); |
1200 source.Seek(seek_time); | 1215 source.Seek(seek_time); |
1201 ASSERT_TRUE(Seek(seek_time)); | 1216 ASSERT_TRUE(Seek(seek_time)); |
1202 Play(); | 1217 Play(); |
1203 ASSERT_TRUE(WaitUntilOnEnded()); | 1218 ASSERT_TRUE(WaitUntilOnEnded()); |
1204 EXPECT_HASH_EQ(kOpusEndTrimmingHash_2, GetAudioHash()); | 1219 EXPECT_HASH_EQ(kOpusEndTrimmingHash_2, GetAudioHash()); |
1205 | 1220 |
1206 // Seek somewhere outside of the pre-skip / end-trim section, demuxer should | 1221 // Seek somewhere outside of the pre-skip / end-trim section, demuxer should |
1207 // correctly preroll enough to accurately decode this segment. | 1222 // correctly preroll enough to accurately decode this segment. |
1208 seek_time = base::TimeDelta::FromMilliseconds(6360); | 1223 seek_time = base::TimeDelta::FromMilliseconds(6360); |
1209 source.Seek(seek_time); | 1224 source.Seek(seek_time); |
1210 ASSERT_TRUE(Seek(seek_time)); | 1225 ASSERT_TRUE(Seek(seek_time)); |
1211 Play(); | 1226 Play(); |
1212 ASSERT_TRUE(WaitUntilOnEnded()); | 1227 ASSERT_TRUE(WaitUntilOnEnded()); |
1213 EXPECT_HASH_EQ(kOpusEndTrimmingHash_3, GetAudioHash()); | 1228 EXPECT_HASH_EQ(kOpusEndTrimmingHash_3, GetAudioHash()); |
1214 } | 1229 } |
1215 | 1230 |
1216 TEST_F(PipelineIntegrationTest, | 1231 TEST_P(CommonPipelineIntegrationTest, |
1217 MAYBE_CLOCKLESS(BasicPlaybackOpusPrerollExceedsCodecDelay)) { | 1232 BasicPlaybackOpusPrerollExceedsCodecDelay) { |
1218 ASSERT_EQ(PIPELINE_OK, Start("bear-opus.webm", kHashed | kClockless)); | 1233 ASSERT_EQ(PIPELINE_OK, Start("bear-opus.webm", kHashed | kClockless)); |
1219 | 1234 |
1220 AudioDecoderConfig config = | 1235 AudioDecoderConfig config = |
1221 demuxer_->GetFirstStream(DemuxerStream::AUDIO)->audio_decoder_config(); | 1236 demuxer_->GetFirstStream(DemuxerStream::AUDIO)->audio_decoder_config(); |
1222 | 1237 |
1223 // Verify that this file's preroll is not eclipsed by the codec delay so we | 1238 // Verify that this file's preroll is not eclipsed by the codec delay so we |
1224 // can detect when preroll is not properly performed. | 1239 // can detect when preroll is not properly performed. |
1225 base::TimeDelta codec_delay = base::TimeDelta::FromSecondsD( | 1240 base::TimeDelta codec_delay = base::TimeDelta::FromSecondsD( |
1226 static_cast<double>(config.codec_delay()) / config.samples_per_second()); | 1241 static_cast<double>(config.codec_delay()) / config.samples_per_second()); |
1227 ASSERT_GT(config.seek_preroll(), codec_delay); | 1242 ASSERT_GT(config.seek_preroll(), codec_delay); |
1228 | 1243 |
1229 Play(); | 1244 Play(); |
1230 ASSERT_TRUE(WaitUntilOnEnded()); | 1245 ASSERT_TRUE(WaitUntilOnEnded()); |
1231 EXPECT_HASH_EQ(kOpusSmallCodecDelayHash_1, GetAudioHash()); | 1246 EXPECT_HASH_EQ(kOpusSmallCodecDelayHash_1, GetAudioHash()); |
1232 | 1247 |
1233 // Seek halfway through the file to invoke seek preroll. | 1248 // Seek halfway through the file to invoke seek preroll. |
1234 ASSERT_TRUE(Seek(base::TimeDelta::FromSecondsD(1.414))); | 1249 ASSERT_TRUE(Seek(base::TimeDelta::FromSecondsD(1.414))); |
1235 Play(); | 1250 Play(); |
1236 ASSERT_TRUE(WaitUntilOnEnded()); | 1251 ASSERT_TRUE(WaitUntilOnEnded()); |
1237 EXPECT_HASH_EQ(kOpusSmallCodecDelayHash_2, GetAudioHash()); | 1252 EXPECT_HASH_EQ(kOpusSmallCodecDelayHash_2, GetAudioHash()); |
1238 } | 1253 } |
1239 | 1254 |
1240 TEST_F(PipelineIntegrationTest, | 1255 TEST_P(CommonPipelineIntegrationTest, |
1241 MAYBE_CLOCKLESS(BasicPlaybackOpusPrerollExceedsCodecDelay_MediaSource)) { | 1256 BasicPlaybackOpusPrerollExceedsCodecDelay_MediaSource) { |
1242 MockMediaSource source("bear-opus.webm", kOpusAudioOnlyWebM, | 1257 MockMediaSource source("bear-opus.webm", kOpusAudioOnlyWebM, |
1243 kAppendWholeFile); | 1258 kAppendWholeFile); |
1244 EXPECT_EQ(PIPELINE_OK, StartPipelineWithMediaSource( | 1259 EXPECT_EQ(PIPELINE_OK, StartPipelineWithMediaSource( |
1245 &source, kClockless | kHashed, nullptr)); | 1260 &source, kClockless | kHashed, nullptr)); |
1246 source.EndOfStream(); | 1261 source.EndOfStream(); |
1247 | 1262 |
1248 AudioDecoderConfig config = | 1263 AudioDecoderConfig config = |
1249 demuxer_->GetFirstStream(DemuxerStream::AUDIO)->audio_decoder_config(); | 1264 demuxer_->GetFirstStream(DemuxerStream::AUDIO)->audio_decoder_config(); |
1250 | 1265 |
1251 // Verify that this file's preroll is not eclipsed by the codec delay so we | 1266 // Verify that this file's preroll is not eclipsed by the codec delay so we |
1252 // can detect when preroll is not properly performed. | 1267 // can detect when preroll is not properly performed. |
1253 base::TimeDelta codec_delay = base::TimeDelta::FromSecondsD( | 1268 base::TimeDelta codec_delay = base::TimeDelta::FromSecondsD( |
1254 static_cast<double>(config.codec_delay()) / config.samples_per_second()); | 1269 static_cast<double>(config.codec_delay()) / config.samples_per_second()); |
1255 ASSERT_GT(config.seek_preroll(), codec_delay); | 1270 ASSERT_GT(config.seek_preroll(), codec_delay); |
1256 | 1271 |
1257 Play(); | 1272 Play(); |
1258 ASSERT_TRUE(WaitUntilOnEnded()); | 1273 ASSERT_TRUE(WaitUntilOnEnded()); |
1259 EXPECT_HASH_EQ(kOpusSmallCodecDelayHash_1, GetAudioHash()); | 1274 EXPECT_HASH_EQ(kOpusSmallCodecDelayHash_1, GetAudioHash()); |
1260 | 1275 |
1261 // Seek halfway through the file to invoke seek preroll. | 1276 // Seek halfway through the file to invoke seek preroll. |
1262 base::TimeDelta seek_time = base::TimeDelta::FromSecondsD(1.414); | 1277 base::TimeDelta seek_time = base::TimeDelta::FromSecondsD(1.414); |
1263 source.Seek(seek_time); | 1278 source.Seek(seek_time); |
1264 ASSERT_TRUE(Seek(seek_time)); | 1279 ASSERT_TRUE(Seek(seek_time)); |
1265 Play(); | 1280 Play(); |
1266 ASSERT_TRUE(WaitUntilOnEnded()); | 1281 ASSERT_TRUE(WaitUntilOnEnded()); |
1267 EXPECT_HASH_EQ(kOpusSmallCodecDelayHash_2, GetAudioHash()); | 1282 EXPECT_HASH_EQ(kOpusSmallCodecDelayHash_2, GetAudioHash()); |
1268 } | 1283 } |
1284 #endif // !defined(DISABLE_CLOCKLESS_TESTS) | |
1269 | 1285 |
1270 TEST_F(PipelineIntegrationTest, BasicPlaybackLive) { | 1286 TEST_P(CommonPipelineIntegrationTest, BasicPlaybackLive) { |
1271 ASSERT_EQ(PIPELINE_OK, Start("bear-320x240-live.webm", kHashed)); | 1287 ASSERT_EQ(PIPELINE_OK, Start("bear-320x240-live.webm", kHashed)); |
1272 | 1288 |
1273 // Live stream does not have duration in the initialization segment. | 1289 // Live stream does not have duration in the initialization segment. |
1274 // It will be set after the entire file is available. | 1290 // It will be set after the entire file is available. |
1275 EXPECT_CALL(*this, OnDurationChange()).Times(1); | 1291 EXPECT_CALL(*this, OnDurationChange()).Times(1); |
1276 | 1292 |
1277 Play(); | 1293 Play(); |
1278 | 1294 |
1279 ASSERT_TRUE(WaitUntilOnEnded()); | 1295 ASSERT_TRUE(WaitUntilOnEnded()); |
1280 | 1296 |
1281 EXPECT_HASH_EQ("f0be120a90a811506777c99a2cdf7cc1", GetVideoHash()); | 1297 EXPECT_HASH_EQ("f0be120a90a811506777c99a2cdf7cc1", GetVideoHash()); |
1282 EXPECT_HASH_EQ("-3.59,-2.06,-0.43,2.15,0.77,-0.95,", GetAudioHash()); | 1298 EXPECT_HASH_EQ("-3.59,-2.06,-0.43,2.15,0.77,-0.95,", GetAudioHash()); |
1283 EXPECT_EQ(kLiveTimelineOffset(), demuxer_->GetTimelineOffset()); | 1299 EXPECT_EQ(kLiveTimelineOffset(), demuxer_->GetTimelineOffset()); |
1284 } | 1300 } |
1285 | 1301 |
1286 TEST_F(PipelineIntegrationTest, S32PlaybackHashed) { | 1302 TEST_P(CommonPipelineIntegrationTest, S32PlaybackHashed) { |
1287 ASSERT_EQ(PIPELINE_OK, Start("sfx_s32le.wav", kHashed)); | 1303 ASSERT_EQ(PIPELINE_OK, Start("sfx_s32le.wav", kHashed)); |
1288 Play(); | 1304 Play(); |
1289 ASSERT_TRUE(WaitUntilOnEnded()); | 1305 ASSERT_TRUE(WaitUntilOnEnded()); |
1290 EXPECT_HASH_EQ(std::string(kNullVideoHash), GetVideoHash()); | 1306 EXPECT_HASH_EQ(std::string(kNullVideoHash), GetVideoHash()); |
1291 EXPECT_HASH_EQ("3.03,2.86,2.99,3.31,3.57,4.06,", GetAudioHash()); | 1307 EXPECT_HASH_EQ("3.03,2.86,2.99,3.31,3.57,4.06,", GetAudioHash()); |
1292 } | 1308 } |
1293 | 1309 |
1294 TEST_F(PipelineIntegrationTest, F32PlaybackHashed) { | 1310 TEST_P(CommonPipelineIntegrationTest, F32PlaybackHashed) { |
1295 ASSERT_EQ(PIPELINE_OK, Start("sfx_f32le.wav", kHashed)); | 1311 ASSERT_EQ(PIPELINE_OK, Start("sfx_f32le.wav", kHashed)); |
1296 Play(); | 1312 Play(); |
1297 ASSERT_TRUE(WaitUntilOnEnded()); | 1313 ASSERT_TRUE(WaitUntilOnEnded()); |
1298 EXPECT_HASH_EQ(std::string(kNullVideoHash), GetVideoHash()); | 1314 EXPECT_HASH_EQ(std::string(kNullVideoHash), GetVideoHash()); |
1299 EXPECT_HASH_EQ("3.03,2.86,2.99,3.31,3.57,4.06,", GetAudioHash()); | 1315 EXPECT_HASH_EQ("3.03,2.86,2.99,3.31,3.57,4.06,", GetAudioHash()); |
1300 } | 1316 } |
1301 | 1317 |
1302 TEST_F(PipelineIntegrationTest, MAYBE_EME(BasicPlaybackEncrypted)) { | 1318 TEST_P(CommonPipelineIntegrationTest, FlacPlaybackHashed) { |
1303 FakeEncryptedMedia encrypted_media(new KeyProvidingApp()); | |
1304 set_encrypted_media_init_data_cb( | |
1305 base::Bind(&FakeEncryptedMedia::OnEncryptedMediaInitData, | |
1306 base::Unretained(&encrypted_media))); | |
1307 | |
1308 ASSERT_EQ(PIPELINE_OK, Start("bear-320x240-av_enc-av.webm", | |
1309 encrypted_media.GetCdmContext())); | |
1310 | |
1311 Play(); | |
1312 | |
1313 ASSERT_TRUE(WaitUntilOnEnded()); | |
1314 Stop(); | |
1315 } | |
1316 | |
1317 TEST_F(PipelineIntegrationTest, FlacPlaybackHashed) { | |
1318 ASSERT_EQ(PIPELINE_OK, Start("sfx.flac", kHashed)); | 1319 ASSERT_EQ(PIPELINE_OK, Start("sfx.flac", kHashed)); |
1319 Play(); | 1320 Play(); |
1320 ASSERT_TRUE(WaitUntilOnEnded()); | 1321 ASSERT_TRUE(WaitUntilOnEnded()); |
1321 EXPECT_HASH_EQ(std::string(kNullVideoHash), GetVideoHash()); | 1322 EXPECT_HASH_EQ(std::string(kNullVideoHash), GetVideoHash()); |
1322 EXPECT_HASH_EQ("3.03,2.86,2.99,3.31,3.57,4.06,", GetAudioHash()); | 1323 EXPECT_HASH_EQ("3.03,2.86,2.99,3.31,3.57,4.06,", GetAudioHash()); |
1323 } | 1324 } |
1324 | 1325 |
1325 TEST_F(PipelineIntegrationTest, BasicPlayback_MediaSource) { | 1326 TEST_P(CommonPipelineIntegrationTest, BasicPlayback_MediaSource) { |
1326 MockMediaSource source("bear-320x240.webm", kWebM, 219229); | 1327 MockMediaSource source("bear-320x240.webm", kWebM, 219229); |
1327 EXPECT_EQ(PIPELINE_OK, StartPipelineWithMediaSource(&source)); | 1328 EXPECT_EQ(PIPELINE_OK, StartPipelineWithMediaSource(&source)); |
1328 source.EndOfStream(); | 1329 source.EndOfStream(); |
1329 | 1330 |
1330 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); | 1331 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); |
1331 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); | 1332 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); |
1332 EXPECT_EQ(k320WebMFileDurationMs, | 1333 EXPECT_EQ(k320WebMFileDurationMs, |
1333 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); | 1334 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); |
1334 | 1335 |
1335 Play(); | 1336 Play(); |
1336 | 1337 |
1337 ASSERT_TRUE(WaitUntilOnEnded()); | 1338 ASSERT_TRUE(WaitUntilOnEnded()); |
1338 | 1339 |
1339 EXPECT_TRUE(demuxer_->GetTimelineOffset().is_null()); | 1340 EXPECT_TRUE(demuxer_->GetTimelineOffset().is_null()); |
1340 source.Shutdown(); | 1341 source.Shutdown(); |
1341 Stop(); | 1342 Stop(); |
1342 } | 1343 } |
1343 | 1344 |
1344 TEST_F(PipelineIntegrationTest, BasicPlayback_MediaSource_Live) { | 1345 TEST_P(CommonPipelineIntegrationTest, BasicPlayback_MediaSource_Live) { |
1345 MockMediaSource source("bear-320x240-live.webm", kWebM, 219221); | 1346 MockMediaSource source("bear-320x240-live.webm", kWebM, 219221); |
1346 EXPECT_EQ(PIPELINE_OK, StartPipelineWithMediaSource(&source)); | 1347 EXPECT_EQ(PIPELINE_OK, StartPipelineWithMediaSource(&source)); |
1347 source.EndOfStream(); | 1348 source.EndOfStream(); |
1348 | 1349 |
1349 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); | 1350 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); |
1350 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); | 1351 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); |
1351 EXPECT_EQ(k320WebMFileDurationMs, | 1352 EXPECT_EQ(k320WebMFileDurationMs, |
1352 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); | 1353 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); |
1353 | 1354 |
1354 Play(); | 1355 Play(); |
1355 | 1356 |
1356 ASSERT_TRUE(WaitUntilOnEnded()); | 1357 ASSERT_TRUE(WaitUntilOnEnded()); |
1357 | 1358 |
1358 EXPECT_EQ(kLiveTimelineOffset(), demuxer_->GetTimelineOffset()); | 1359 EXPECT_EQ(kLiveTimelineOffset(), demuxer_->GetTimelineOffset()); |
1359 source.Shutdown(); | 1360 source.Shutdown(); |
1360 Stop(); | 1361 Stop(); |
1361 } | 1362 } |
1362 | 1363 |
1363 TEST_F(PipelineIntegrationTest, BasicPlayback_MediaSource_VP9_WebM) { | 1364 TEST_P(CommonPipelineIntegrationTest, BasicPlayback_MediaSource_VP9_WebM) { |
1364 MockMediaSource source("bear-vp9.webm", kWebMVP9, 67504); | 1365 MockMediaSource source("bear-vp9.webm", kWebMVP9, 67504); |
1365 EXPECT_EQ(PIPELINE_OK, StartPipelineWithMediaSource(&source)); | 1366 EXPECT_EQ(PIPELINE_OK, StartPipelineWithMediaSource(&source)); |
1366 source.EndOfStream(); | 1367 source.EndOfStream(); |
1367 | 1368 |
1368 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); | 1369 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); |
1369 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); | 1370 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); |
1370 EXPECT_EQ(kVP9WebMFileDurationMs, | 1371 EXPECT_EQ(kVP9WebMFileDurationMs, |
1371 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); | 1372 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); |
1372 | 1373 |
1373 Play(); | 1374 Play(); |
1374 | 1375 |
1375 ASSERT_TRUE(WaitUntilOnEnded()); | 1376 ASSERT_TRUE(WaitUntilOnEnded()); |
1376 source.Shutdown(); | 1377 source.Shutdown(); |
1377 Stop(); | 1378 Stop(); |
1378 } | 1379 } |
1379 | 1380 |
1380 TEST_F(PipelineIntegrationTest, BasicPlayback_MediaSource_VP9_BlockGroup_WebM) { | 1381 TEST_P(CommonPipelineIntegrationTest, |
1382 BasicPlayback_MediaSource_VP9_BlockGroup_WebM) { | |
1381 MockMediaSource source("bear-vp9-blockgroup.webm", kWebMVP9, 67871); | 1383 MockMediaSource source("bear-vp9-blockgroup.webm", kWebMVP9, 67871); |
1382 EXPECT_EQ(PIPELINE_OK, StartPipelineWithMediaSource(&source)); | 1384 EXPECT_EQ(PIPELINE_OK, StartPipelineWithMediaSource(&source)); |
1383 source.EndOfStream(); | 1385 source.EndOfStream(); |
1384 | 1386 |
1385 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); | 1387 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); |
1386 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); | 1388 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); |
1387 EXPECT_EQ(kVP9WebMFileDurationMs, | 1389 EXPECT_EQ(kVP9WebMFileDurationMs, |
1388 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); | 1390 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); |
1389 | 1391 |
1390 Play(); | 1392 Play(); |
1391 | 1393 |
1392 ASSERT_TRUE(WaitUntilOnEnded()); | 1394 ASSERT_TRUE(WaitUntilOnEnded()); |
1393 source.Shutdown(); | 1395 source.Shutdown(); |
1394 Stop(); | 1396 Stop(); |
1395 } | 1397 } |
1396 | 1398 |
1397 TEST_F(PipelineIntegrationTest, BasicPlayback_MediaSource_VP8A_WebM) { | 1399 TEST_P(CommonPipelineIntegrationTest, BasicPlayback_MediaSource_VP8A_WebM) { |
1398 MockMediaSource source("bear-vp8a.webm", kVideoOnlyWebM, kAppendWholeFile); | 1400 MockMediaSource source("bear-vp8a.webm", kVideoOnlyWebM, kAppendWholeFile); |
1399 EXPECT_EQ(PIPELINE_OK, StartPipelineWithMediaSource(&source)); | 1401 EXPECT_EQ(PIPELINE_OK, StartPipelineWithMediaSource(&source)); |
1400 source.EndOfStream(); | 1402 source.EndOfStream(); |
1401 | 1403 |
1402 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); | 1404 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); |
1403 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); | 1405 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); |
1404 EXPECT_EQ(kVP8AWebMFileDurationMs, | 1406 EXPECT_EQ(kVP8AWebMFileDurationMs, |
1405 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); | 1407 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); |
1406 | 1408 |
1407 Play(); | 1409 Play(); |
1408 | 1410 |
1409 ASSERT_TRUE(WaitUntilOnEnded()); | 1411 ASSERT_TRUE(WaitUntilOnEnded()); |
1410 source.Shutdown(); | 1412 source.Shutdown(); |
1411 Stop(); | 1413 Stop(); |
1412 } | 1414 } |
1413 | 1415 |
1414 TEST_F(PipelineIntegrationTest, BasicPlayback_MediaSource_Opus_WebM) { | 1416 TEST_P(CommonPipelineIntegrationTest, BasicPlayback_MediaSource_Opus_WebM) { |
1415 MockMediaSource source("bear-opus-end-trimming.webm", kOpusAudioOnlyWebM, | 1417 MockMediaSource source("bear-opus-end-trimming.webm", kOpusAudioOnlyWebM, |
1416 kAppendWholeFile); | 1418 kAppendWholeFile); |
1417 EXPECT_EQ(PIPELINE_OK, StartPipelineWithMediaSource(&source)); | 1419 EXPECT_EQ(PIPELINE_OK, StartPipelineWithMediaSource(&source)); |
1418 source.EndOfStream(); | 1420 source.EndOfStream(); |
1419 | 1421 |
1420 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); | 1422 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); |
1421 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); | 1423 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); |
1422 EXPECT_EQ(kOpusEndTrimmingWebMFileDurationMs, | 1424 EXPECT_EQ(kOpusEndTrimmingWebMFileDurationMs, |
1423 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); | 1425 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); |
1424 Play(); | 1426 Play(); |
1425 | 1427 |
1426 ASSERT_TRUE(WaitUntilOnEnded()); | 1428 ASSERT_TRUE(WaitUntilOnEnded()); |
1427 source.Shutdown(); | 1429 source.Shutdown(); |
1428 Stop(); | 1430 Stop(); |
1429 } | 1431 } |
1430 | 1432 |
1431 // Flaky. http://crbug.com/304776 | 1433 // Flaky. http://crbug.com/304776 |
1432 TEST_F(PipelineIntegrationTest, DISABLED_MediaSource_Opus_Seeking_WebM) { | 1434 TEST_P(CommonPipelineIntegrationTest, DISABLED_MediaSource_Opus_Seeking_WebM) { |
1433 MockMediaSource source("bear-opus-end-trimming.webm", kOpusAudioOnlyWebM, | 1435 MockMediaSource source("bear-opus-end-trimming.webm", kOpusAudioOnlyWebM, |
1434 kAppendWholeFile); | 1436 kAppendWholeFile); |
1435 EXPECT_EQ(PIPELINE_OK, | 1437 EXPECT_EQ(PIPELINE_OK, |
1436 StartPipelineWithMediaSource(&source, kHashed, nullptr)); | 1438 StartPipelineWithMediaSource(&source, kHashed, nullptr)); |
1437 | 1439 |
1438 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); | 1440 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); |
1439 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); | 1441 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); |
1440 EXPECT_EQ(kOpusEndTrimmingWebMFileDurationMs, | 1442 EXPECT_EQ(kOpusEndTrimmingWebMFileDurationMs, |
1441 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); | 1443 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); |
1442 | 1444 |
1443 base::TimeDelta start_seek_time = base::TimeDelta::FromMilliseconds(1000); | 1445 base::TimeDelta start_seek_time = base::TimeDelta::FromMilliseconds(1000); |
1444 base::TimeDelta seek_time = base::TimeDelta::FromMilliseconds(2000); | 1446 base::TimeDelta seek_time = base::TimeDelta::FromMilliseconds(2000); |
1445 | 1447 |
1446 Play(); | 1448 Play(); |
1447 ASSERT_TRUE(WaitUntilCurrentTimeIsAfter(start_seek_time)); | 1449 ASSERT_TRUE(WaitUntilCurrentTimeIsAfter(start_seek_time)); |
1448 source.Seek(seek_time, 0x1D5, 34017); | 1450 source.Seek(seek_time, 0x1D5, 34017); |
1449 source.EndOfStream(); | 1451 source.EndOfStream(); |
1450 ASSERT_TRUE(Seek(seek_time)); | 1452 ASSERT_TRUE(Seek(seek_time)); |
1451 | 1453 |
1452 ASSERT_TRUE(WaitUntilOnEnded()); | 1454 ASSERT_TRUE(WaitUntilOnEnded()); |
1453 | 1455 |
1454 EXPECT_HASH_EQ("0.76,0.20,-0.82,-0.58,-1.29,-0.29,", GetAudioHash()); | 1456 EXPECT_HASH_EQ("0.76,0.20,-0.82,-0.58,-1.29,-0.29,", GetAudioHash()); |
1455 | 1457 |
1456 source.Shutdown(); | 1458 source.Shutdown(); |
1457 Stop(); | 1459 Stop(); |
1458 } | 1460 } |
1459 | 1461 |
1460 TEST_F(PipelineIntegrationTest, MediaSource_ConfigChange_WebM) { | 1462 TEST_P(CommonPipelineIntegrationTest, MediaSource_ConfigChange_WebM) { |
1461 MockMediaSource source("bear-320x240-16x9-aspect.webm", kWebM, | 1463 MockMediaSource source("bear-320x240-16x9-aspect.webm", kWebM, |
1462 kAppendWholeFile); | 1464 kAppendWholeFile); |
1463 EXPECT_EQ(PIPELINE_OK, StartPipelineWithMediaSource(&source)); | 1465 EXPECT_EQ(PIPELINE_OK, StartPipelineWithMediaSource(&source)); |
1464 | 1466 |
1465 EXPECT_CALL(*this, OnVideoNaturalSizeChange(gfx::Size(640, 360))).Times(1); | 1467 EXPECT_CALL(*this, OnVideoNaturalSizeChange(gfx::Size(640, 360))).Times(1); |
1466 scoped_refptr<DecoderBuffer> second_file = | 1468 scoped_refptr<DecoderBuffer> second_file = |
1467 ReadTestDataFile("bear-640x360.webm"); | 1469 ReadTestDataFile("bear-640x360.webm"); |
1468 ASSERT_TRUE(source.AppendAtTime(base::TimeDelta::FromSeconds(kAppendTimeSec), | 1470 ASSERT_TRUE(source.AppendAtTime(base::TimeDelta::FromSeconds(kAppendTimeSec), |
1469 second_file->data(), | 1471 second_file->data(), |
1470 second_file->data_size())); | 1472 second_file->data_size())); |
1471 source.EndOfStream(); | 1473 source.EndOfStream(); |
1472 | 1474 |
1473 Play(); | 1475 Play(); |
1474 EXPECT_TRUE(WaitUntilOnEnded()); | 1476 EXPECT_TRUE(WaitUntilOnEnded()); |
1475 | 1477 |
1476 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); | 1478 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); |
1477 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); | 1479 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); |
1478 EXPECT_EQ(kAppendTimeMs + k640WebMFileDurationMs, | 1480 EXPECT_EQ(kAppendTimeMs + k640WebMFileDurationMs, |
1479 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); | 1481 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); |
1480 | 1482 |
1481 source.Shutdown(); | 1483 source.Shutdown(); |
1482 Stop(); | 1484 Stop(); |
1483 } | 1485 } |
1484 | 1486 |
1485 TEST_F(PipelineIntegrationTest, MediaSource_Remove_Updates_BufferedRanges) { | 1487 TEST_P(CommonPipelineIntegrationTest, |
1488 MediaSource_Remove_Updates_BufferedRanges) { | |
1486 const char* input_filename = "bear-320x240.webm"; | 1489 const char* input_filename = "bear-320x240.webm"; |
1487 MockMediaSource source(input_filename, kWebM, kAppendWholeFile); | 1490 MockMediaSource source(input_filename, kWebM, kAppendWholeFile); |
1488 EXPECT_EQ(PIPELINE_OK, StartPipelineWithMediaSource(&source)); | 1491 EXPECT_EQ(PIPELINE_OK, StartPipelineWithMediaSource(&source)); |
1489 | 1492 |
1490 auto buffered_ranges = pipeline_->GetBufferedTimeRanges(); | 1493 auto buffered_ranges = pipeline_->GetBufferedTimeRanges(); |
1491 EXPECT_EQ(1u, buffered_ranges.size()); | 1494 EXPECT_EQ(1u, buffered_ranges.size()); |
1492 EXPECT_EQ(0, buffered_ranges.start(0).InMilliseconds()); | 1495 EXPECT_EQ(0, buffered_ranges.start(0).InMilliseconds()); |
1493 EXPECT_EQ(k320WebMFileDurationMs, buffered_ranges.end(0).InMilliseconds()); | 1496 EXPECT_EQ(k320WebMFileDurationMs, buffered_ranges.end(0).InMilliseconds()); |
1494 | 1497 |
1495 source.RemoveRange(base::TimeDelta::FromMilliseconds(1000), | 1498 source.RemoveRange(base::TimeDelta::FromMilliseconds(1000), |
1496 base::TimeDelta::FromMilliseconds(k320WebMFileDurationMs)); | 1499 base::TimeDelta::FromMilliseconds(k320WebMFileDurationMs)); |
1497 base::RunLoop().RunUntilIdle(); | 1500 base::RunLoop().RunUntilIdle(); |
1498 | 1501 |
1499 buffered_ranges = pipeline_->GetBufferedTimeRanges(); | 1502 buffered_ranges = pipeline_->GetBufferedTimeRanges(); |
1500 EXPECT_EQ(1u, buffered_ranges.size()); | 1503 EXPECT_EQ(1u, buffered_ranges.size()); |
1501 EXPECT_EQ(0, buffered_ranges.start(0).InMilliseconds()); | 1504 EXPECT_EQ(0, buffered_ranges.start(0).InMilliseconds()); |
1502 EXPECT_EQ(1001, buffered_ranges.end(0).InMilliseconds()); | 1505 EXPECT_EQ(1001, buffered_ranges.end(0).InMilliseconds()); |
1503 | 1506 |
1504 source.Shutdown(); | 1507 source.Shutdown(); |
1505 Stop(); | 1508 Stop(); |
1506 } | 1509 } |
1507 | 1510 |
1508 // This test case imitates media playback with advancing media_time and | 1511 // This test case imitates media playback with advancing media_time and |
1509 // continuously adding new data. At some point we should reach the buffering | 1512 // continuously adding new data. At some point we should reach the buffering |
1510 // limit, after that MediaSource should evict some buffered data and that | 1513 // limit, after that MediaSource should evict some buffered data and that |
1511 // evicted data shold be reflected in the change of media::Pipeline buffered | 1514 // evicted data shold be reflected in the change of media::Pipeline buffered |
1512 // ranges (returned by GetBufferedTimeRanges). At that point the buffered ranges | 1515 // ranges (returned by GetBufferedTimeRanges). At that point the buffered ranges |
1513 // will no longer start at 0. | 1516 // will no longer start at 0. |
1514 TEST_F(PipelineIntegrationTest, MediaSource_FillUp_Buffer) { | 1517 TEST_P(CommonPipelineIntegrationTest, MediaSource_FillUp_Buffer) { |
1515 const char* input_filename = "bear-320x240.webm"; | 1518 const char* input_filename = "bear-320x240.webm"; |
1516 MockMediaSource source(input_filename, kWebM, kAppendWholeFile); | 1519 MockMediaSource source(input_filename, kWebM, kAppendWholeFile); |
1517 EXPECT_EQ(PIPELINE_OK, StartPipelineWithMediaSource(&source)); | 1520 EXPECT_EQ(PIPELINE_OK, StartPipelineWithMediaSource(&source)); |
1518 source.SetMemoryLimits(1048576); | 1521 source.SetMemoryLimits(1048576); |
1519 | 1522 |
1520 scoped_refptr<DecoderBuffer> file = ReadTestDataFile(input_filename); | 1523 scoped_refptr<DecoderBuffer> file = ReadTestDataFile(input_filename); |
1521 | 1524 |
1522 auto buffered_ranges = pipeline_->GetBufferedTimeRanges(); | 1525 auto buffered_ranges = pipeline_->GetBufferedTimeRanges(); |
1523 EXPECT_EQ(1u, buffered_ranges.size()); | 1526 EXPECT_EQ(1u, buffered_ranges.size()); |
1524 do { | 1527 do { |
1525 // Advance media_time to the end of the currently buffered data | 1528 // Advance media_time to the end of the currently buffered data |
1526 base::TimeDelta media_time = buffered_ranges.end(0); | 1529 base::TimeDelta media_time = buffered_ranges.end(0); |
1527 source.Seek(media_time); | 1530 source.Seek(media_time); |
1528 // Ask MediaSource to evict buffered data if buffering limit has been | 1531 // Ask MediaSource to evict buffered data if buffering limit has been |
1529 // reached (the data will be evicted from the front of the buffered range). | 1532 // reached (the data will be evicted from the front of the buffered range). |
1530 source.EvictCodedFrames(media_time, file->data_size()); | 1533 source.EvictCodedFrames(media_time, file->data_size()); |
1531 ASSERT_TRUE( | 1534 ASSERT_TRUE( |
1532 source.AppendAtTime(media_time, file->data(), file->data_size())); | 1535 source.AppendAtTime(media_time, file->data(), file->data_size())); |
1533 base::RunLoop().RunUntilIdle(); | 1536 base::RunLoop().RunUntilIdle(); |
1534 | 1537 |
1535 buffered_ranges = pipeline_->GetBufferedTimeRanges(); | 1538 buffered_ranges = pipeline_->GetBufferedTimeRanges(); |
1536 } while (buffered_ranges.size() == 1 && | 1539 } while (buffered_ranges.size() == 1 && |
1537 buffered_ranges.start(0) == base::TimeDelta::FromSeconds(0)); | 1540 buffered_ranges.start(0) == base::TimeDelta::FromSeconds(0)); |
1538 | 1541 |
1539 EXPECT_EQ(1u, buffered_ranges.size()); | 1542 EXPECT_EQ(1u, buffered_ranges.size()); |
1540 source.Shutdown(); | 1543 source.Shutdown(); |
1541 Stop(); | 1544 Stop(); |
1542 } | 1545 } |
1543 | 1546 |
1544 TEST_F(PipelineIntegrationTest, | |
1545 MAYBE_EME(MediaSource_ConfigChange_Encrypted_WebM)) { | |
1546 MockMediaSource source("bear-320x240-16x9-aspect-av_enc-av.webm", kWebM, | |
1547 kAppendWholeFile); | |
1548 FakeEncryptedMedia encrypted_media(new KeyProvidingApp()); | |
1549 EXPECT_EQ(PIPELINE_OK, | |
1550 StartPipelineWithEncryptedMedia(&source, &encrypted_media)); | |
1551 | |
1552 EXPECT_CALL(*this, OnVideoNaturalSizeChange(gfx::Size(640, 360))).Times(1); | |
1553 scoped_refptr<DecoderBuffer> second_file = | |
1554 ReadTestDataFile("bear-640x360-av_enc-av.webm"); | |
1555 | |
1556 ASSERT_TRUE(source.AppendAtTime(base::TimeDelta::FromSeconds(kAppendTimeSec), | |
1557 second_file->data(), | |
1558 second_file->data_size())); | |
1559 source.EndOfStream(); | |
1560 | |
1561 Play(); | |
1562 EXPECT_TRUE(WaitUntilOnEnded()); | |
1563 | |
1564 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); | |
1565 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); | |
1566 EXPECT_EQ(kAppendTimeMs + k640WebMFileDurationMs, | |
1567 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); | |
1568 | |
1569 source.Shutdown(); | |
1570 Stop(); | |
1571 } | |
1572 | |
1573 TEST_F(PipelineIntegrationTest, | |
1574 MAYBE_EME(MediaSource_ConfigChange_ClearThenEncrypted_WebM)) { | |
1575 MockMediaSource source("bear-320x240-16x9-aspect.webm", kWebM, | |
1576 kAppendWholeFile); | |
1577 FakeEncryptedMedia encrypted_media(new KeyProvidingApp()); | |
1578 EXPECT_EQ(PIPELINE_OK, | |
1579 StartPipelineWithEncryptedMedia(&source, &encrypted_media)); | |
1580 | |
1581 EXPECT_CALL(*this, OnVideoNaturalSizeChange(gfx::Size(640, 360))).Times(1); | |
1582 scoped_refptr<DecoderBuffer> second_file = | |
1583 ReadTestDataFile("bear-640x360-av_enc-av.webm"); | |
1584 | |
1585 EXPECT_TRUE(source.AppendAtTime(base::TimeDelta::FromSeconds(kAppendTimeSec), | |
1586 second_file->data(), | |
1587 second_file->data_size())); | |
1588 source.EndOfStream(); | |
1589 | |
1590 Play(); | |
1591 EXPECT_TRUE(WaitUntilOnEnded()); | |
1592 | |
1593 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); | |
1594 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); | |
1595 EXPECT_EQ(kAppendTimeMs + k640WebMFileDurationMs, | |
1596 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); | |
1597 | |
1598 source.Shutdown(); | |
1599 Stop(); | |
1600 } | |
1601 | |
1602 // Config change from encrypted to clear is allowed by the demuxer, and is | |
1603 // supported by the Renderer. | |
1604 TEST_F(PipelineIntegrationTest, | |
1605 MAYBE_EME(MediaSource_ConfigChange_EncryptedThenClear_WebM)) { | |
1606 MockMediaSource source("bear-320x240-16x9-aspect-av_enc-av.webm", kWebM, | |
1607 kAppendWholeFile); | |
1608 FakeEncryptedMedia encrypted_media(new KeyProvidingApp()); | |
1609 EXPECT_EQ(PIPELINE_OK, | |
1610 StartPipelineWithEncryptedMedia(&source, &encrypted_media)); | |
1611 | |
1612 EXPECT_CALL(*this, OnVideoNaturalSizeChange(gfx::Size(640, 360))).Times(1); | |
1613 scoped_refptr<DecoderBuffer> second_file = | |
1614 ReadTestDataFile("bear-640x360.webm"); | |
1615 | |
1616 ASSERT_TRUE(source.AppendAtTime(base::TimeDelta::FromSeconds(kAppendTimeSec), | |
1617 second_file->data(), | |
1618 second_file->data_size())); | |
1619 source.EndOfStream(); | |
1620 | |
1621 Play(); | |
1622 ASSERT_TRUE(WaitUntilOnEnded()); | |
1623 | |
1624 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); | |
1625 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); | |
1626 EXPECT_EQ(kAppendTimeMs + k640WebMFileDurationMs, | |
1627 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); | |
1628 | |
1629 source.Shutdown(); | |
1630 Stop(); | |
1631 } | |
1632 | |
1633 #if defined(ARCH_CPU_X86_FAMILY) && !defined(OS_ANDROID) | 1547 #if defined(ARCH_CPU_X86_FAMILY) && !defined(OS_ANDROID) |
1634 TEST_F(PipelineIntegrationTest, BasicPlaybackHi10PVP9) { | 1548 TEST_P(CommonPipelineIntegrationTest, BasicPlaybackHi10PVP9) { |
1635 ASSERT_EQ(PIPELINE_OK, Start("bear-320x180-hi10p-vp9.webm", kClockless)); | 1549 ASSERT_EQ(PIPELINE_OK, Start("bear-320x180-hi10p-vp9.webm", kClockless)); |
1636 | 1550 |
1637 Play(); | 1551 Play(); |
1638 | 1552 |
1639 ASSERT_TRUE(WaitUntilOnEnded()); | 1553 ASSERT_TRUE(WaitUntilOnEnded()); |
1640 } | 1554 } |
1641 | 1555 |
1642 TEST_F(PipelineIntegrationTest, BasicPlaybackHi12PVP9) { | 1556 TEST_P(CommonPipelineIntegrationTest, BasicPlaybackHi12PVP9) { |
1643 ASSERT_EQ(PIPELINE_OK, Start("bear-320x180-hi12p-vp9.webm", kClockless)); | 1557 ASSERT_EQ(PIPELINE_OK, Start("bear-320x180-hi12p-vp9.webm", kClockless)); |
1644 | 1558 |
1645 Play(); | 1559 Play(); |
1646 | 1560 |
1647 ASSERT_TRUE(WaitUntilOnEnded()); | 1561 ASSERT_TRUE(WaitUntilOnEnded()); |
1648 } | 1562 } |
1649 #endif | 1563 #endif |
1650 | 1564 |
1651 #if BUILDFLAG(USE_PROPRIETARY_CODECS) | 1565 #if BUILDFLAG(USE_PROPRIETARY_CODECS) |
1652 | 1566 |
1653 TEST_F(PipelineIntegrationTest, BasicPlaybackHi10P) { | 1567 TEST_P(CommonPipelineIntegrationTest, BasicPlaybackHi10P) { |
1654 ASSERT_EQ(PIPELINE_OK, Start("bear-320x180-hi10p.mp4", kClockless)); | 1568 ASSERT_EQ(PIPELINE_OK, Start("bear-320x180-hi10p.mp4", kClockless)); |
1655 | 1569 |
1656 Play(); | 1570 Play(); |
1657 | 1571 |
1658 ASSERT_TRUE(WaitUntilOnEnded()); | 1572 ASSERT_TRUE(WaitUntilOnEnded()); |
1659 } | 1573 } |
1660 | 1574 |
1661 TEST_F(PipelineIntegrationTest, BasicFallback) { | 1575 TEST_P(CommonPipelineIntegrationTest, BasicFallback) { |
1662 ScopedVector<VideoDecoder> failing_video_decoder; | 1576 ScopedVector<VideoDecoder> failing_video_decoder; |
1663 failing_video_decoder.push_back(new FailingVideoDecoder()); | 1577 failing_video_decoder.push_back(new FailingVideoDecoder()); |
1664 | 1578 |
1665 ASSERT_EQ(PIPELINE_OK, | 1579 ASSERT_EQ(PIPELINE_OK, |
1666 Start("bear.mp4", kClockless, std::move(failing_video_decoder))); | 1580 Start("bear.mp4", kClockless, std::move(failing_video_decoder))); |
1667 | 1581 |
1668 Play(); | 1582 Play(); |
1669 | 1583 |
1670 ASSERT_TRUE(WaitUntilOnEnded()); | 1584 ASSERT_TRUE(WaitUntilOnEnded()); |
1671 }; | 1585 }; |
1672 | 1586 |
1673 TEST_F(PipelineIntegrationTest, MediaSource_ADTS) { | 1587 TEST_P(CommonPipelineIntegrationTest, MediaSource_ADTS) { |
1674 MockMediaSource source("sfx.adts", kADTS, kAppendWholeFile); | 1588 MockMediaSource source("sfx.adts", kADTS, kAppendWholeFile); |
1675 EXPECT_EQ(PIPELINE_OK, StartPipelineWithMediaSource(&source)); | 1589 EXPECT_EQ(PIPELINE_OK, StartPipelineWithMediaSource(&source)); |
1676 source.EndOfStream(); | 1590 source.EndOfStream(); |
1677 | 1591 |
1678 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); | 1592 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); |
1679 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); | 1593 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); |
1680 EXPECT_EQ(325, pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); | 1594 EXPECT_EQ(325, pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); |
1681 | 1595 |
1682 Play(); | 1596 Play(); |
1683 | 1597 |
1684 EXPECT_TRUE(WaitUntilOnEnded()); | 1598 EXPECT_TRUE(WaitUntilOnEnded()); |
1685 } | 1599 } |
1686 | 1600 |
1687 TEST_F(PipelineIntegrationTest, MediaSource_ADTS_TimestampOffset) { | 1601 TEST_P(CommonPipelineIntegrationTest, MediaSource_ADTS_TimestampOffset) { |
1688 MockMediaSource source("sfx.adts", kADTS, kAppendWholeFile); | 1602 MockMediaSource source("sfx.adts", kADTS, kAppendWholeFile); |
1689 EXPECT_EQ(PIPELINE_OK, | 1603 EXPECT_EQ(PIPELINE_OK, |
1690 StartPipelineWithMediaSource(&source, kHashed, nullptr)); | 1604 StartPipelineWithMediaSource(&source, kHashed, nullptr)); |
1691 EXPECT_EQ(325, source.last_timestamp_offset().InMilliseconds()); | 1605 EXPECT_EQ(325, source.last_timestamp_offset().InMilliseconds()); |
1692 | 1606 |
1693 // Trim off multiple frames off the beginning of the segment which will cause | 1607 // Trim off multiple frames off the beginning of the segment which will cause |
1694 // the first decoded frame to be incorrect if preroll isn't implemented. | 1608 // the first decoded frame to be incorrect if preroll isn't implemented. |
1695 const base::TimeDelta adts_preroll_duration = | 1609 const base::TimeDelta adts_preroll_duration = |
1696 base::TimeDelta::FromSecondsD(2.5 * 1024 / 44100); | 1610 base::TimeDelta::FromSecondsD(2.5 * 1024 / 44100); |
1697 const base::TimeDelta append_time = | 1611 const base::TimeDelta append_time = |
(...skipping 10 matching lines...) Expand all Loading... | |
1708 | 1622 |
1709 EXPECT_EQ(592, source.last_timestamp_offset().InMilliseconds()); | 1623 EXPECT_EQ(592, source.last_timestamp_offset().InMilliseconds()); |
1710 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); | 1624 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); |
1711 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); | 1625 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); |
1712 EXPECT_EQ(592, pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); | 1626 EXPECT_EQ(592, pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); |
1713 | 1627 |
1714 // Verify preroll is stripped. | 1628 // Verify preroll is stripped. |
1715 EXPECT_HASH_EQ("-0.25,0.67,0.04,0.14,-0.49,-0.41,", GetAudioHash()); | 1629 EXPECT_HASH_EQ("-0.25,0.67,0.04,0.14,-0.49,-0.41,", GetAudioHash()); |
1716 } | 1630 } |
1717 | 1631 |
1718 TEST_F(PipelineIntegrationTest, BasicPlaybackHashed_MP3) { | 1632 TEST_P(CommonPipelineIntegrationTest, BasicPlaybackHashed_MP3) { |
1719 ASSERT_EQ(PIPELINE_OK, Start("sfx.mp3", kHashed)); | 1633 ASSERT_EQ(PIPELINE_OK, Start("sfx.mp3", kHashed)); |
1720 | 1634 |
1721 Play(); | 1635 Play(); |
1722 | 1636 |
1723 ASSERT_TRUE(WaitUntilOnEnded()); | 1637 ASSERT_TRUE(WaitUntilOnEnded()); |
1724 | 1638 |
1725 // Verify codec delay and preroll are stripped. | 1639 // Verify codec delay and preroll are stripped. |
1726 EXPECT_HASH_EQ("1.30,2.72,4.56,5.08,3.74,2.03,", GetAudioHash()); | 1640 EXPECT_HASH_EQ("1.30,2.72,4.56,5.08,3.74,2.03,", GetAudioHash()); |
1727 } | 1641 } |
1728 | 1642 |
1729 #if !defined(DISABLE_CLOCKLESS_TESTS) | 1643 TEST_P(CommonPipelineIntegrationTest, MediaSource_MP3) { |
1730 class Mp3FastSeekParams { | |
1731 public: | |
1732 Mp3FastSeekParams(const char* filename, const char* hash) | |
1733 : filename(filename), hash(hash) {} | |
1734 const char* filename; | |
1735 const char* hash; | |
1736 }; | |
1737 | |
1738 class Mp3FastSeekIntegrationTest | |
1739 : public PipelineIntegrationTest, | |
1740 public testing::WithParamInterface<Mp3FastSeekParams> {}; | |
1741 | |
1742 TEST_P(Mp3FastSeekIntegrationTest, FastSeekAccuracy_MP3) { | |
1743 Mp3FastSeekParams config = GetParam(); | |
1744 ASSERT_EQ(PIPELINE_OK, Start(config.filename, kHashed)); | |
1745 | |
1746 // The XING TOC is inaccurate. We don't use it for CBR, we tolerate it for VBR | |
1747 // (best option for fast seeking; see Mp3SeekFFmpegDemuxerTest). The chosen | |
1748 // seek time exposes inaccuracy in TOC such that the hash will change if seek | |
1749 // logic is regressed. See https://crbug.com/545914. | |
1750 // | |
1751 // Quick TOC design (not pretty!): | |
1752 // - All MP3 TOCs are 100 bytes | |
1753 // - Each byte is read as a uint8_t; value between 0 - 255. | |
1754 // - The index into this array is the numerator in the ratio: index / 100. | |
1755 // This fraction represents a playback time as a percentage of duration. | |
1756 // - The value at the given index is the numerator in the ratio: value / 256. | |
1757 // This fraction represents a byte offset as a percentage of the file size. | |
1758 // | |
1759 // For CBR files, each frame is the same size, so the offset for time of | |
1760 // (0.98 * duration) should be around (0.98 * file size). This is 250.88 / 256 | |
1761 // but the numerator will be truncated in the TOC as 250, losing precision. | |
1762 base::TimeDelta seek_time(0.98 * pipeline_->GetMediaDuration()); | |
1763 | |
1764 ASSERT_TRUE(Seek(seek_time)); | |
1765 Play(); | |
1766 ASSERT_TRUE(WaitUntilOnEnded()); | |
1767 | |
1768 EXPECT_HASH_EQ(config.hash, GetAudioHash()); | |
1769 } | |
1770 | |
1771 // CBR seeks should always be fast and accurate. | |
1772 INSTANTIATE_TEST_CASE_P( | |
1773 CBRSeek_HasTOC, | |
1774 Mp3FastSeekIntegrationTest, | |
1775 ::testing::Values(Mp3FastSeekParams("bear-audio-10s-CBR-has-TOC.mp3", | |
1776 "-0.71,0.36,2.96,2.68,2.11,-1.08,"))); | |
1777 | |
1778 INSTANTIATE_TEST_CASE_P( | |
1779 CBRSeeks_NoTOC, | |
1780 Mp3FastSeekIntegrationTest, | |
1781 ::testing::Values(Mp3FastSeekParams("bear-audio-10s-CBR-no-TOC.mp3", | |
1782 "0.95,0.56,1.34,0.47,1.77,0.84,"))); | |
1783 | |
1784 // VBR seeks can be fast *OR* accurate, but not both. We chose fast. | |
1785 INSTANTIATE_TEST_CASE_P( | |
1786 VBRSeeks_HasTOC, | |
1787 Mp3FastSeekIntegrationTest, | |
1788 ::testing::Values(Mp3FastSeekParams("bear-audio-10s-VBR-has-TOC.mp3", | |
1789 "-0.15,-0.83,0.54,1.00,1.94,0.93,"))); | |
1790 | |
1791 INSTANTIATE_TEST_CASE_P( | |
1792 VBRSeeks_NoTOC, | |
1793 Mp3FastSeekIntegrationTest, | |
1794 ::testing::Values(Mp3FastSeekParams("bear-audio-10s-VBR-no-TOC.mp3", | |
1795 "-0.22,0.80,1.19,0.73,-0.31,-1.12,"))); | |
1796 #endif // !defined(DISABLE_CLOCKLESS_TESTS) | |
1797 | |
1798 TEST_F(PipelineIntegrationTest, MediaSource_MP3) { | |
1799 MockMediaSource source("sfx.mp3", kMP3, kAppendWholeFile); | 1644 MockMediaSource source("sfx.mp3", kMP3, kAppendWholeFile); |
1800 EXPECT_EQ(PIPELINE_OK, | 1645 EXPECT_EQ(PIPELINE_OK, |
1801 StartPipelineWithMediaSource(&source, kHashed, nullptr)); | 1646 StartPipelineWithMediaSource(&source, kHashed, nullptr)); |
1802 source.EndOfStream(); | 1647 source.EndOfStream(); |
1803 | 1648 |
1804 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); | 1649 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); |
1805 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); | 1650 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); |
1806 EXPECT_EQ(313, pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); | 1651 EXPECT_EQ(313, pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); |
1807 | 1652 |
1808 Play(); | 1653 Play(); |
1809 | 1654 |
1810 EXPECT_TRUE(WaitUntilOnEnded()); | 1655 EXPECT_TRUE(WaitUntilOnEnded()); |
1811 | 1656 |
1812 // Verify that codec delay was stripped. | 1657 // Verify that codec delay was stripped. |
1813 EXPECT_HASH_EQ("1.01,2.71,4.18,4.32,3.04,1.12,", GetAudioHash()); | 1658 EXPECT_HASH_EQ("1.01,2.71,4.18,4.32,3.04,1.12,", GetAudioHash()); |
1814 } | 1659 } |
1815 | 1660 |
1816 TEST_F(PipelineIntegrationTest, MediaSource_MP3_TimestampOffset) { | 1661 TEST_P(CommonPipelineIntegrationTest, MediaSource_MP3_TimestampOffset) { |
1817 MockMediaSource source("sfx.mp3", kMP3, kAppendWholeFile); | 1662 MockMediaSource source("sfx.mp3", kMP3, kAppendWholeFile); |
1818 EXPECT_EQ(PIPELINE_OK, StartPipelineWithMediaSource(&source)); | 1663 EXPECT_EQ(PIPELINE_OK, StartPipelineWithMediaSource(&source)); |
1819 EXPECT_EQ(313, source.last_timestamp_offset().InMilliseconds()); | 1664 EXPECT_EQ(313, source.last_timestamp_offset().InMilliseconds()); |
1820 | 1665 |
1821 // There are 576 silent frames at the start of this mp3. The second append | 1666 // There are 576 silent frames at the start of this mp3. The second append |
1822 // should trim them off. | 1667 // should trim them off. |
1823 const base::TimeDelta mp3_preroll_duration = | 1668 const base::TimeDelta mp3_preroll_duration = |
1824 base::TimeDelta::FromSecondsD(576.0 / 44100); | 1669 base::TimeDelta::FromSecondsD(576.0 / 44100); |
1825 const base::TimeDelta append_time = | 1670 const base::TimeDelta append_time = |
1826 source.last_timestamp_offset() - mp3_preroll_duration; | 1671 source.last_timestamp_offset() - mp3_preroll_duration; |
1827 | 1672 |
1828 scoped_refptr<DecoderBuffer> second_file = ReadTestDataFile("sfx.mp3"); | 1673 scoped_refptr<DecoderBuffer> second_file = ReadTestDataFile("sfx.mp3"); |
1829 source.AppendAtTimeWithWindow(append_time, append_time + mp3_preroll_duration, | 1674 source.AppendAtTimeWithWindow(append_time, append_time + mp3_preroll_duration, |
1830 kInfiniteDuration, second_file->data(), | 1675 kInfiniteDuration, second_file->data(), |
1831 second_file->data_size()); | 1676 second_file->data_size()); |
1832 source.EndOfStream(); | 1677 source.EndOfStream(); |
1833 | 1678 |
1834 Play(); | 1679 Play(); |
1835 EXPECT_TRUE(WaitUntilOnEnded()); | 1680 EXPECT_TRUE(WaitUntilOnEnded()); |
1836 | 1681 |
1837 EXPECT_EQ(613, source.last_timestamp_offset().InMilliseconds()); | 1682 EXPECT_EQ(613, source.last_timestamp_offset().InMilliseconds()); |
1838 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); | 1683 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); |
1839 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); | 1684 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); |
1840 EXPECT_EQ(613, pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); | 1685 EXPECT_EQ(613, pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); |
1841 } | 1686 } |
1842 | 1687 |
1843 TEST_F(PipelineIntegrationTest, MediaSource_MP3_Icecast) { | 1688 TEST_P(CommonPipelineIntegrationTest, MediaSource_MP3_Icecast) { |
1844 MockMediaSource source("icy_sfx.mp3", kMP3, kAppendWholeFile); | 1689 MockMediaSource source("icy_sfx.mp3", kMP3, kAppendWholeFile); |
1845 EXPECT_EQ(PIPELINE_OK, StartPipelineWithMediaSource(&source)); | 1690 EXPECT_EQ(PIPELINE_OK, StartPipelineWithMediaSource(&source)); |
1846 source.EndOfStream(); | 1691 source.EndOfStream(); |
1847 | 1692 |
1848 Play(); | 1693 Play(); |
1849 | 1694 |
1850 EXPECT_TRUE(WaitUntilOnEnded()); | 1695 EXPECT_TRUE(WaitUntilOnEnded()); |
1851 } | 1696 } |
1852 | 1697 |
1853 TEST_F(PipelineIntegrationTest, MediaSource_ConfigChange_MP4) { | 1698 TEST_P(CommonPipelineIntegrationTest, MediaSource_ConfigChange_MP4) { |
1854 MockMediaSource source("bear-640x360-av_frag.mp4", kMP4, kAppendWholeFile); | 1699 MockMediaSource source("bear-640x360-av_frag.mp4", kMP4, kAppendWholeFile); |
1855 EXPECT_EQ(PIPELINE_OK, StartPipelineWithMediaSource(&source)); | 1700 EXPECT_EQ(PIPELINE_OK, StartPipelineWithMediaSource(&source)); |
1856 | 1701 |
1857 EXPECT_CALL(*this, OnVideoNaturalSizeChange(gfx::Size(1280, 720))).Times(1); | 1702 EXPECT_CALL(*this, OnVideoNaturalSizeChange(gfx::Size(1280, 720))).Times(1); |
1858 scoped_refptr<DecoderBuffer> second_file = | 1703 scoped_refptr<DecoderBuffer> second_file = |
1859 ReadTestDataFile("bear-1280x720-av_frag.mp4"); | 1704 ReadTestDataFile("bear-1280x720-av_frag.mp4"); |
1860 ASSERT_TRUE(source.AppendAtTime(base::TimeDelta::FromSeconds(kAppendTimeSec), | 1705 ASSERT_TRUE(source.AppendAtTime(base::TimeDelta::FromSeconds(kAppendTimeSec), |
1861 second_file->data(), | 1706 second_file->data(), |
1862 second_file->data_size())); | 1707 second_file->data_size())); |
1863 source.EndOfStream(); | 1708 source.EndOfStream(); |
1864 | 1709 |
1865 Play(); | 1710 Play(); |
1866 EXPECT_TRUE(WaitUntilOnEnded()); | 1711 EXPECT_TRUE(WaitUntilOnEnded()); |
1867 | 1712 |
1868 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); | 1713 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); |
1869 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); | 1714 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); |
1870 EXPECT_EQ(kAppendTimeMs + k1280IsoFileDurationMs, | 1715 EXPECT_EQ(kAppendTimeMs + k1280IsoFileDurationMs, |
1871 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); | 1716 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); |
1872 | 1717 |
1873 source.Shutdown(); | 1718 source.Shutdown(); |
1874 Stop(); | 1719 Stop(); |
1875 } | 1720 } |
1876 | |
1877 TEST_F(PipelineIntegrationTest, | |
1878 MAYBE_EME(MediaSource_ConfigChange_Encrypted_MP4_CENC_VideoOnly)) { | |
1879 MockMediaSource source("bear-640x360-v_frag-cenc.mp4", kMP4Video, | |
1880 kAppendWholeFile); | |
1881 FakeEncryptedMedia encrypted_media(new KeyProvidingApp()); | |
1882 EXPECT_EQ(PIPELINE_OK, | |
1883 StartPipelineWithEncryptedMedia(&source, &encrypted_media)); | |
1884 | |
1885 EXPECT_CALL(*this, OnVideoNaturalSizeChange(gfx::Size(1280, 720))).Times(1); | |
1886 scoped_refptr<DecoderBuffer> second_file = | |
1887 ReadTestDataFile("bear-1280x720-v_frag-cenc.mp4"); | |
1888 ASSERT_TRUE(source.AppendAtTime(base::TimeDelta::FromSeconds(kAppendTimeSec), | |
1889 second_file->data(), | |
1890 second_file->data_size())); | |
1891 source.EndOfStream(); | |
1892 | |
1893 Play(); | |
1894 EXPECT_TRUE(WaitUntilOnEnded()); | |
1895 | |
1896 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); | |
1897 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); | |
1898 EXPECT_EQ(kAppendTimeMs + k1280IsoFileDurationMs, | |
1899 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); | |
1900 | |
1901 source.Shutdown(); | |
1902 Stop(); | |
1903 } | |
1904 | |
1905 TEST_F(PipelineIntegrationTest, | |
1906 MAYBE_EME( | |
1907 MediaSource_ConfigChange_Encrypted_MP4_CENC_KeyRotation_VideoOnly)) { | |
1908 MockMediaSource source("bear-640x360-v_frag-cenc-key_rotation.mp4", kMP4Video, | |
1909 kAppendWholeFile); | |
1910 FakeEncryptedMedia encrypted_media(new RotatingKeyProvidingApp()); | |
1911 EXPECT_EQ(PIPELINE_OK, | |
1912 StartPipelineWithEncryptedMedia(&source, &encrypted_media)); | |
1913 | |
1914 EXPECT_CALL(*this, OnVideoNaturalSizeChange(gfx::Size(1280, 720))).Times(1); | |
1915 scoped_refptr<DecoderBuffer> second_file = | |
1916 ReadTestDataFile("bear-1280x720-v_frag-cenc-key_rotation.mp4"); | |
1917 ASSERT_TRUE(source.AppendAtTime(base::TimeDelta::FromSeconds(kAppendTimeSec), | |
1918 second_file->data(), | |
1919 second_file->data_size())); | |
1920 source.EndOfStream(); | |
1921 | |
1922 Play(); | |
1923 EXPECT_TRUE(WaitUntilOnEnded()); | |
1924 | |
1925 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); | |
1926 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); | |
1927 EXPECT_EQ(kAppendTimeMs + k1280IsoFileDurationMs, | |
1928 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); | |
1929 | |
1930 source.Shutdown(); | |
1931 Stop(); | |
1932 } | |
1933 | |
1934 // Config changes from clear to encrypted are not currently supported. | |
1935 // TODO(ddorwin): Figure out why this CHECKs in AppendAtTime(). | |
1936 TEST_F(PipelineIntegrationTest, | |
1937 DISABLED_MediaSource_ConfigChange_ClearThenEncrypted_MP4_CENC) { | |
1938 MockMediaSource source("bear-640x360-av_frag.mp4", kMP4Video, | |
1939 kAppendWholeFile); | |
1940 FakeEncryptedMedia encrypted_media(new KeyProvidingApp()); | |
1941 EXPECT_EQ(PIPELINE_OK, | |
1942 StartPipelineWithEncryptedMedia(&source, &encrypted_media)); | |
1943 | |
1944 EXPECT_CALL(*this, OnVideoNaturalSizeChange(gfx::Size(1280, 720))).Times(1); | |
1945 scoped_refptr<DecoderBuffer> second_file = | |
1946 ReadTestDataFile("bear-1280x720-v_frag-cenc.mp4"); | |
1947 ASSERT_FALSE(source.AppendAtTime(base::TimeDelta::FromSeconds(kAppendTimeSec), | |
1948 second_file->data(), | |
1949 second_file->data_size())); | |
1950 | |
1951 source.EndOfStream(); | |
1952 | |
1953 base::RunLoop().Run(); | |
1954 EXPECT_EQ(CHUNK_DEMUXER_ERROR_APPEND_FAILED, pipeline_status_); | |
1955 | |
1956 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); | |
1957 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); | |
1958 // The second video was not added, so its time has not been added. | |
1959 EXPECT_EQ(k640IsoFileDurationMs, | |
1960 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); | |
1961 | |
1962 Play(); | |
1963 | |
1964 EXPECT_EQ(CHUNK_DEMUXER_ERROR_APPEND_FAILED, WaitUntilEndedOrError()); | |
1965 source.Shutdown(); | |
1966 } | |
1967 | |
1968 // Config changes from encrypted to clear are not currently supported. | |
1969 TEST_F(PipelineIntegrationTest, | |
1970 MAYBE_EME(MediaSource_ConfigChange_EncryptedThenClear_MP4_CENC)) { | |
1971 MockMediaSource source("bear-640x360-v_frag-cenc.mp4", kMP4Video, | |
1972 kAppendWholeFile); | |
1973 FakeEncryptedMedia encrypted_media(new KeyProvidingApp()); | |
1974 EXPECT_EQ(PIPELINE_OK, | |
1975 StartPipelineWithEncryptedMedia(&source, &encrypted_media)); | |
1976 | |
1977 scoped_refptr<DecoderBuffer> second_file = | |
1978 ReadTestDataFile("bear-1280x720-av_frag.mp4"); | |
1979 | |
1980 ASSERT_FALSE(source.AppendAtTime(base::TimeDelta::FromSeconds(kAppendTimeSec), | |
1981 second_file->data(), | |
1982 second_file->data_size())); | |
1983 | |
1984 source.EndOfStream(); | |
1985 | |
1986 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); | |
1987 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); | |
1988 // The second video was not added, so its time has not been added. | |
1989 EXPECT_EQ(k640IsoCencFileDurationMs, | |
1990 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); | |
1991 | |
1992 Play(); | |
1993 | |
1994 EXPECT_EQ(CHUNK_DEMUXER_ERROR_APPEND_FAILED, WaitUntilEndedOrError()); | |
1995 source.Shutdown(); | |
1996 } | |
1997 | |
1998 // Verify files which change configuration midstream fail gracefully. | |
1999 TEST_F(PipelineIntegrationTest, MidStreamConfigChangesFail) { | |
2000 ASSERT_EQ(PIPELINE_OK, Start("midstream_config_change.mp3")); | |
2001 Play(); | |
2002 ASSERT_EQ(WaitUntilEndedOrError(), PIPELINE_ERROR_DECODE); | |
2003 } | |
2004 #endif // BUILDFLAG(USE_PROPRIETARY_CODECS) | 1721 #endif // BUILDFLAG(USE_PROPRIETARY_CODECS) |
2005 | 1722 |
2006 TEST_F(PipelineIntegrationTest, BasicPlayback_16x9AspectRatio) { | 1723 TEST_P(CommonPipelineIntegrationTest, BasicPlayback_16x9AspectRatio) { |
2007 ASSERT_EQ(PIPELINE_OK, Start("bear-320x240-16x9-aspect.webm")); | 1724 ASSERT_EQ(PIPELINE_OK, Start("bear-320x240-16x9-aspect.webm")); |
2008 Play(); | 1725 Play(); |
2009 ASSERT_TRUE(WaitUntilOnEnded()); | 1726 ASSERT_TRUE(WaitUntilOnEnded()); |
2010 } | 1727 } |
2011 | 1728 |
2012 TEST_F(PipelineIntegrationTest, MAYBE_EME(EncryptedPlayback_WebM)) { | |
2013 MockMediaSource source("bear-320x240-av_enc-av.webm", kWebM, 219816); | |
2014 FakeEncryptedMedia encrypted_media(new KeyProvidingApp()); | |
2015 EXPECT_EQ(PIPELINE_OK, | |
2016 StartPipelineWithEncryptedMedia(&source, &encrypted_media)); | |
2017 | |
2018 source.EndOfStream(); | |
2019 ASSERT_EQ(PIPELINE_OK, pipeline_status_); | |
2020 | |
2021 Play(); | |
2022 | |
2023 ASSERT_TRUE(WaitUntilOnEnded()); | |
2024 source.Shutdown(); | |
2025 Stop(); | |
2026 } | |
2027 | |
2028 TEST_F(PipelineIntegrationTest, MAYBE_EME(EncryptedPlayback_ClearStart_WebM)) { | |
2029 MockMediaSource source("bear-320x240-av_enc-av_clear-1s.webm", kWebM, | |
2030 kAppendWholeFile); | |
2031 FakeEncryptedMedia encrypted_media(new KeyProvidingApp()); | |
2032 EXPECT_EQ(PIPELINE_OK, | |
2033 StartPipelineWithEncryptedMedia(&source, &encrypted_media)); | |
2034 | |
2035 source.EndOfStream(); | |
2036 ASSERT_EQ(PIPELINE_OK, pipeline_status_); | |
2037 | |
2038 Play(); | |
2039 | |
2040 ASSERT_TRUE(WaitUntilOnEnded()); | |
2041 source.Shutdown(); | |
2042 Stop(); | |
2043 } | |
2044 | |
2045 TEST_F(PipelineIntegrationTest, | |
2046 MAYBE_EME(EncryptedPlayback_NoEncryptedFrames_WebM)) { | |
2047 MockMediaSource source("bear-320x240-av_enc-av_clear-all.webm", kWebM, | |
2048 kAppendWholeFile); | |
2049 FakeEncryptedMedia encrypted_media(new NoResponseApp()); | |
2050 EXPECT_EQ(PIPELINE_OK, | |
2051 StartPipelineWithEncryptedMedia(&source, &encrypted_media)); | |
2052 | |
2053 source.EndOfStream(); | |
2054 ASSERT_EQ(PIPELINE_OK, pipeline_status_); | |
2055 | |
2056 Play(); | |
2057 | |
2058 ASSERT_TRUE(WaitUntilOnEnded()); | |
2059 source.Shutdown(); | |
2060 Stop(); | |
2061 } | |
2062 | |
2063 #if BUILDFLAG(USE_PROPRIETARY_CODECS) | 1729 #if BUILDFLAG(USE_PROPRIETARY_CODECS) |
2064 TEST_F(PipelineIntegrationTest, | 1730 TEST_P(CommonPipelineIntegrationTest, Mp2ts_AAC_HE_SBR_Audio) { |
2065 MAYBE_EME(EncryptedPlayback_MP4_CENC_VideoOnly)) { | |
2066 MockMediaSource source("bear-1280x720-v_frag-cenc.mp4", kMP4Video, | |
2067 kAppendWholeFile); | |
2068 FakeEncryptedMedia encrypted_media(new KeyProvidingApp()); | |
2069 EXPECT_EQ(PIPELINE_OK, | |
2070 StartPipelineWithEncryptedMedia(&source, &encrypted_media)); | |
2071 | |
2072 source.EndOfStream(); | |
2073 ASSERT_EQ(PIPELINE_OK, pipeline_status_); | |
2074 | |
2075 Play(); | |
2076 | |
2077 ASSERT_TRUE(WaitUntilOnEnded()); | |
2078 source.Shutdown(); | |
2079 Stop(); | |
2080 } | |
2081 | |
2082 TEST_F(PipelineIntegrationTest, | |
2083 MAYBE_EME(EncryptedPlayback_MP4_CENC_AudioOnly)) { | |
2084 MockMediaSource source("bear-1280x720-a_frag-cenc.mp4", kMP4Audio, | |
2085 kAppendWholeFile); | |
2086 FakeEncryptedMedia encrypted_media(new KeyProvidingApp()); | |
2087 EXPECT_EQ(PIPELINE_OK, | |
2088 StartPipelineWithEncryptedMedia(&source, &encrypted_media)); | |
2089 | |
2090 source.EndOfStream(); | |
2091 ASSERT_EQ(PIPELINE_OK, pipeline_status_); | |
2092 | |
2093 Play(); | |
2094 | |
2095 ASSERT_TRUE(WaitUntilOnEnded()); | |
2096 source.Shutdown(); | |
2097 Stop(); | |
2098 } | |
2099 | |
2100 TEST_F(PipelineIntegrationTest, | |
2101 MAYBE_EME(EncryptedPlayback_NoEncryptedFrames_MP4_CENC_VideoOnly)) { | |
2102 MockMediaSource source("bear-1280x720-v_frag-cenc_clear-all.mp4", kMP4Video, | |
2103 kAppendWholeFile); | |
2104 FakeEncryptedMedia encrypted_media(new NoResponseApp()); | |
2105 EXPECT_EQ(PIPELINE_OK, | |
2106 StartPipelineWithEncryptedMedia(&source, &encrypted_media)); | |
2107 | |
2108 source.EndOfStream(); | |
2109 | |
2110 Play(); | |
2111 | |
2112 ASSERT_TRUE(WaitUntilOnEnded()); | |
2113 source.Shutdown(); | |
2114 Stop(); | |
2115 } | |
2116 | |
2117 TEST_F(PipelineIntegrationTest, Mp2ts_AAC_HE_SBR_Audio) { | |
2118 MockMediaSource source("bear-1280x720-aac_he.ts", kMP2AudioSBR, | 1731 MockMediaSource source("bear-1280x720-aac_he.ts", kMP2AudioSBR, |
2119 kAppendWholeFile); | 1732 kAppendWholeFile); |
2120 #if BUILDFLAG(ENABLE_MSE_MPEG2TS_STREAM_PARSER) | 1733 #if BUILDFLAG(ENABLE_MSE_MPEG2TS_STREAM_PARSER) |
2121 EXPECT_EQ(PIPELINE_OK, StartPipelineWithMediaSource(&source)); | 1734 EXPECT_EQ(PIPELINE_OK, StartPipelineWithMediaSource(&source)); |
2122 source.EndOfStream(); | 1735 source.EndOfStream(); |
2123 ASSERT_EQ(PIPELINE_OK, pipeline_status_); | 1736 ASSERT_EQ(PIPELINE_OK, pipeline_status_); |
2124 | 1737 |
2125 // Check that SBR is taken into account correctly by mpeg2ts parser. When an | 1738 // Check that SBR is taken into account correctly by mpeg2ts parser. When an |
2126 // SBR stream is parsed as non-SBR stream, then audio frame durations are | 1739 // SBR stream is parsed as non-SBR stream, then audio frame durations are |
2127 // calculated incorrectly and that leads to gaps in buffered ranges (so this | 1740 // calculated incorrectly and that leads to gaps in buffered ranges (so this |
2128 // check will fail) and eventually leads to stalled playback. | 1741 // check will fail) and eventually leads to stalled playback. |
2129 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); | 1742 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); |
2130 #else | 1743 #else |
2131 EXPECT_EQ( | 1744 EXPECT_EQ( |
2132 DEMUXER_ERROR_COULD_NOT_OPEN, | 1745 DEMUXER_ERROR_COULD_NOT_OPEN, |
2133 StartPipelineWithMediaSource(&source, kExpectDemuxerFailure, nullptr)); | 1746 StartPipelineWithMediaSource(&source, kExpectDemuxerFailure, nullptr)); |
2134 #endif | 1747 #endif |
2135 } | 1748 } |
2136 | 1749 |
2137 TEST_F(PipelineIntegrationTest, Mpeg2ts_MP3Audio_Mp4a_6B) { | 1750 TEST_P(CommonPipelineIntegrationTest, Mpeg2ts_MP3Audio_Mp4a_6B) { |
2138 MockMediaSource source("bear-audio-mp4a.6B.ts", | 1751 MockMediaSource source("bear-audio-mp4a.6B.ts", |
2139 "video/mp2t; codecs=\"mp4a.6B\"", kAppendWholeFile); | 1752 "video/mp2t; codecs=\"mp4a.6B\"", kAppendWholeFile); |
2140 #if BUILDFLAG(ENABLE_MSE_MPEG2TS_STREAM_PARSER) | 1753 #if BUILDFLAG(ENABLE_MSE_MPEG2TS_STREAM_PARSER) |
2141 EXPECT_EQ(PIPELINE_OK, StartPipelineWithMediaSource(&source)); | 1754 EXPECT_EQ(PIPELINE_OK, StartPipelineWithMediaSource(&source)); |
2142 source.EndOfStream(); | 1755 source.EndOfStream(); |
2143 ASSERT_EQ(PIPELINE_OK, pipeline_status_); | 1756 ASSERT_EQ(PIPELINE_OK, pipeline_status_); |
2144 #else | 1757 #else |
2145 EXPECT_EQ( | 1758 EXPECT_EQ( |
2146 DEMUXER_ERROR_COULD_NOT_OPEN, | 1759 DEMUXER_ERROR_COULD_NOT_OPEN, |
2147 StartPipelineWithMediaSource(&source, kExpectDemuxerFailure, nullptr)); | 1760 StartPipelineWithMediaSource(&source, kExpectDemuxerFailure, nullptr)); |
2148 #endif | 1761 #endif |
2149 } | 1762 } |
2150 | 1763 |
2151 TEST_F(PipelineIntegrationTest, Mpeg2ts_MP3Audio_Mp4a_69) { | 1764 TEST_P(CommonPipelineIntegrationTest, Mpeg2ts_MP3Audio_Mp4a_69) { |
2152 MockMediaSource source("bear-audio-mp4a.69.ts", | 1765 MockMediaSource source("bear-audio-mp4a.69.ts", |
2153 "video/mp2t; codecs=\"mp4a.69\"", kAppendWholeFile); | 1766 "video/mp2t; codecs=\"mp4a.69\"", kAppendWholeFile); |
2154 #if BUILDFLAG(ENABLE_MSE_MPEG2TS_STREAM_PARSER) | 1767 #if BUILDFLAG(ENABLE_MSE_MPEG2TS_STREAM_PARSER) |
2155 EXPECT_EQ(PIPELINE_OK, StartPipelineWithMediaSource(&source)); | 1768 EXPECT_EQ(PIPELINE_OK, StartPipelineWithMediaSource(&source)); |
2156 source.EndOfStream(); | 1769 source.EndOfStream(); |
2157 ASSERT_EQ(PIPELINE_OK, pipeline_status_); | 1770 ASSERT_EQ(PIPELINE_OK, pipeline_status_); |
2158 #else | 1771 #else |
2159 EXPECT_EQ( | 1772 EXPECT_EQ( |
2160 DEMUXER_ERROR_COULD_NOT_OPEN, | 1773 DEMUXER_ERROR_COULD_NOT_OPEN, |
2161 StartPipelineWithMediaSource(&source, kExpectDemuxerFailure, nullptr)); | 1774 StartPipelineWithMediaSource(&source, kExpectDemuxerFailure, nullptr)); |
2162 #endif | 1775 #endif |
2163 } | 1776 } |
2164 | 1777 |
2165 TEST_F(PipelineIntegrationTest, | 1778 TEST_P(CommonPipelineIntegrationTest, |
2166 MAYBE_EME(EncryptedPlayback_NoEncryptedFrames_MP4_CENC_AudioOnly)) { | 1779 BasicPlayback_MediaSource_VideoOnly_MP4_AVC3) { |
2167 MockMediaSource source("bear-1280x720-a_frag-cenc_clear-all.mp4", kMP4Audio, | 1780 MockMediaSource source("bear-1280x720-v_frag-avc3.mp4", kMP4VideoAVC3, |
2168 kAppendWholeFile); | 1781 kAppendWholeFile); |
2169 FakeEncryptedMedia encrypted_media(new NoResponseApp()); | 1782 EXPECT_EQ(PIPELINE_OK, StartPipelineWithMediaSource(&source)); |
2170 EXPECT_EQ(PIPELINE_OK, | 1783 source.EndOfStream(); |
2171 StartPipelineWithEncryptedMedia(&source, &encrypted_media)); | |
2172 | 1784 |
2173 source.EndOfStream(); | 1785 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); |
1786 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); | |
1787 EXPECT_EQ(k1280IsoAVC3FileDurationMs, | |
1788 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); | |
2174 | 1789 |
2175 Play(); | 1790 Play(); |
2176 | 1791 |
2177 ASSERT_TRUE(WaitUntilOnEnded()); | 1792 ASSERT_TRUE(WaitUntilOnEnded()); |
2178 source.Shutdown(); | 1793 source.Shutdown(); |
2179 Stop(); | 1794 Stop(); |
2180 } | 1795 } |
2181 | 1796 |
2182 TEST_F(PipelineIntegrationTest, | 1797 TEST_P(CommonPipelineIntegrationTest, |
2183 MAYBE_EME(EncryptedPlayback_MP4_CENC_SENC_Video)) { | 1798 BasicPlayback_MediaSource_VideoOnly_MP4_VP9) { |
2184 MockMediaSource source("bear-640x360-v_frag-cenc-senc.mp4", kMP4Video, | 1799 MockMediaSource source("bear-320x240-v_frag-vp9.mp4", kMP4VideoVP9, |
2185 kAppendWholeFile); | 1800 kAppendWholeFile); |
2186 FakeEncryptedMedia encrypted_media(new KeyProvidingApp()); | 1801 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
2187 EXPECT_EQ(PIPELINE_OK, | 1802 switches::kEnableVp9InMp4)) { |
2188 StartPipelineWithEncryptedMedia(&source, &encrypted_media)); | 1803 ASSERT_EQ(ChunkDemuxer::kNotSupported, source.AddId()); |
1804 return; | |
1805 } | |
2189 | 1806 |
1807 EXPECT_EQ(PIPELINE_OK, StartPipelineWithMediaSource(&source)); | |
2190 source.EndOfStream(); | 1808 source.EndOfStream(); |
1809 ASSERT_EQ(PIPELINE_OK, pipeline_status_); | |
2191 | 1810 |
2192 Play(); | 1811 Play(); |
2193 | 1812 |
2194 ASSERT_TRUE(WaitUntilOnEnded()); | 1813 ASSERT_TRUE(WaitUntilOnEnded()); |
2195 source.Shutdown(); | 1814 source.Shutdown(); |
2196 Stop(); | 1815 Stop(); |
2197 } | 1816 } |
2198 | 1817 |
2199 // 'SAIZ' and 'SAIO' boxes contain redundant information which is already | 1818 TEST_P(CommonPipelineIntegrationTest, |
2200 // available in 'SENC' box. Although 'SAIZ' and 'SAIO' boxes are required per | 1819 BasicPlayback_MediaSource_VideoOnly_MP4_HEVC1) { |
2201 // CENC spec for backward compatibility reasons, but we do not use the two | |
2202 // boxes if 'SENC' box is present, so the code should work even if the two | |
2203 // boxes are not present. | |
2204 TEST_F(PipelineIntegrationTest, | |
2205 MAYBE_EME(EncryptedPlayback_MP4_CENC_SENC_NO_SAIZ_SAIO_Video)) { | |
2206 MockMediaSource source("bear-640x360-v_frag-cenc-senc-no-saiz-saio.mp4", | |
2207 kMP4Video, kAppendWholeFile); | |
2208 FakeEncryptedMedia encrypted_media(new KeyProvidingApp()); | |
2209 EXPECT_EQ(PIPELINE_OK, | |
2210 StartPipelineWithEncryptedMedia(&source, &encrypted_media)); | |
2211 | |
2212 source.EndOfStream(); | |
2213 | |
2214 Play(); | |
2215 | |
2216 ASSERT_TRUE(WaitUntilOnEnded()); | |
2217 source.Shutdown(); | |
2218 Stop(); | |
2219 } | |
2220 | |
2221 TEST_F(PipelineIntegrationTest, | |
2222 MAYBE_EME(EncryptedPlayback_MP4_CENC_KeyRotation_Video)) { | |
2223 MockMediaSource source("bear-1280x720-v_frag-cenc-key_rotation.mp4", | |
2224 kMP4Video, kAppendWholeFile); | |
2225 FakeEncryptedMedia encrypted_media(new RotatingKeyProvidingApp()); | |
2226 EXPECT_EQ(PIPELINE_OK, | |
2227 StartPipelineWithEncryptedMedia(&source, &encrypted_media)); | |
2228 | |
2229 source.EndOfStream(); | |
2230 | |
2231 Play(); | |
2232 | |
2233 ASSERT_TRUE(WaitUntilOnEnded()); | |
2234 source.Shutdown(); | |
2235 Stop(); | |
2236 } | |
2237 | |
2238 TEST_F(PipelineIntegrationTest, | |
2239 MAYBE_EME(EncryptedPlayback_MP4_CENC_KeyRotation_Audio)) { | |
2240 MockMediaSource source("bear-1280x720-a_frag-cenc-key_rotation.mp4", | |
2241 kMP4Audio, kAppendWholeFile); | |
2242 FakeEncryptedMedia encrypted_media(new RotatingKeyProvidingApp()); | |
2243 EXPECT_EQ(PIPELINE_OK, | |
2244 StartPipelineWithEncryptedMedia(&source, &encrypted_media)); | |
2245 | |
2246 source.EndOfStream(); | |
2247 | |
2248 Play(); | |
2249 | |
2250 ASSERT_TRUE(WaitUntilOnEnded()); | |
2251 source.Shutdown(); | |
2252 Stop(); | |
2253 } | |
2254 | |
2255 TEST_F(PipelineIntegrationTest, | |
2256 MAYBE_EME(EncryptedPlayback_MP4_VP9_CENC_VideoOnly)) { | |
2257 MockMediaSource source("bear-320x240-v_frag-vp9-cenc.mp4", kMP4VideoVP9, | |
2258 kAppendWholeFile); | |
2259 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( | |
2260 switches::kEnableVp9InMp4)) { | |
2261 ASSERT_EQ(ChunkDemuxer::kNotSupported, source.AddId()); | |
2262 return; | |
2263 } | |
2264 | |
2265 FakeEncryptedMedia encrypted_media(new KeyProvidingApp()); | |
2266 EXPECT_EQ(PIPELINE_OK, | |
2267 StartPipelineWithEncryptedMedia(&source, &encrypted_media)); | |
2268 | |
2269 source.EndOfStream(); | |
2270 | |
2271 Play(); | |
2272 | |
2273 ASSERT_TRUE(WaitUntilOnEnded()); | |
2274 source.Shutdown(); | |
2275 Stop(); | |
2276 } | |
2277 | |
2278 TEST_F(PipelineIntegrationTest, BasicPlayback_MediaSource_VideoOnly_MP4_AVC3) { | |
2279 MockMediaSource source("bear-1280x720-v_frag-avc3.mp4", kMP4VideoAVC3, | |
2280 kAppendWholeFile); | |
2281 EXPECT_EQ(PIPELINE_OK, StartPipelineWithMediaSource(&source)); | |
2282 source.EndOfStream(); | |
2283 | |
2284 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); | |
2285 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); | |
2286 EXPECT_EQ(k1280IsoAVC3FileDurationMs, | |
2287 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); | |
2288 | |
2289 Play(); | |
2290 | |
2291 ASSERT_TRUE(WaitUntilOnEnded()); | |
2292 source.Shutdown(); | |
2293 Stop(); | |
2294 } | |
2295 | |
2296 TEST_F(PipelineIntegrationTest, BasicPlayback_MediaSource_VideoOnly_MP4_VP9) { | |
2297 MockMediaSource source("bear-320x240-v_frag-vp9.mp4", kMP4VideoVP9, | |
2298 kAppendWholeFile); | |
2299 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( | |
2300 switches::kEnableVp9InMp4)) { | |
2301 ASSERT_EQ(ChunkDemuxer::kNotSupported, source.AddId()); | |
2302 return; | |
2303 } | |
2304 | |
2305 EXPECT_EQ(PIPELINE_OK, StartPipelineWithMediaSource(&source)); | |
2306 source.EndOfStream(); | |
2307 ASSERT_EQ(PIPELINE_OK, pipeline_status_); | |
2308 | |
2309 Play(); | |
2310 | |
2311 ASSERT_TRUE(WaitUntilOnEnded()); | |
2312 source.Shutdown(); | |
2313 Stop(); | |
2314 } | |
2315 | |
2316 TEST_F(PipelineIntegrationTest, BasicPlayback_MediaSource_VideoOnly_MP4_HEVC1) { | |
2317 // HEVC demuxing might be enabled even on platforms that don't support HEVC | 1820 // HEVC demuxing might be enabled even on platforms that don't support HEVC |
2318 // decoding. For those cases we'll get DECODER_ERROR_NOT_SUPPORTED, which | 1821 // decoding. For those cases we'll get DECODER_ERROR_NOT_SUPPORTED, which |
2319 // indicates indicates that we did pass media mime type checks and attempted | 1822 // indicates indicates that we did pass media mime type checks and attempted |
2320 // to actually demux and decode the stream. On platforms that support both | 1823 // to actually demux and decode the stream. On platforms that support both |
2321 // demuxing and decoding we'll get PIPELINE_OK. | 1824 // demuxing and decoding we'll get PIPELINE_OK. |
2322 MockMediaSource source("bear-320x240-v_frag-hevc.mp4", kMP4VideoHEVC1, | 1825 MockMediaSource source("bear-320x240-v_frag-hevc.mp4", kMP4VideoHEVC1, |
2323 kAppendWholeFile); | 1826 kAppendWholeFile); |
2324 #if BUILDFLAG(ENABLE_HEVC_DEMUXING) | 1827 #if BUILDFLAG(ENABLE_HEVC_DEMUXING) |
2325 PipelineStatus status = StartPipelineWithMediaSource(&source); | 1828 PipelineStatus status = StartPipelineWithMediaSource(&source); |
2326 EXPECT_TRUE(status == PIPELINE_OK || status == DECODER_ERROR_NOT_SUPPORTED); | 1829 EXPECT_TRUE(status == PIPELINE_OK || status == DECODER_ERROR_NOT_SUPPORTED); |
2327 #else | 1830 #else |
2328 EXPECT_EQ( | 1831 EXPECT_EQ( |
2329 DEMUXER_ERROR_COULD_NOT_OPEN, | 1832 DEMUXER_ERROR_COULD_NOT_OPEN, |
2330 StartPipelineWithMediaSource(&source, kExpectDemuxerFailure, nullptr)); | 1833 StartPipelineWithMediaSource(&source, kExpectDemuxerFailure, nullptr)); |
2331 #endif | 1834 #endif |
2332 } | 1835 } |
2333 | 1836 |
2334 TEST_F(PipelineIntegrationTest, BasicPlayback_MediaSource_VideoOnly_MP4_HEVC2) { | 1837 TEST_P(CommonPipelineIntegrationTest, |
1838 BasicPlayback_MediaSource_VideoOnly_MP4_HEVC2) { | |
2335 // HEVC demuxing might be enabled even on platforms that don't support HEVC | 1839 // HEVC demuxing might be enabled even on platforms that don't support HEVC |
2336 // decoding. For those cases we'll get DECODER_ERROR_NOT_SUPPORTED, which | 1840 // decoding. For those cases we'll get DECODER_ERROR_NOT_SUPPORTED, which |
2337 // indicates indicates that we did pass media mime type checks and attempted | 1841 // indicates indicates that we did pass media mime type checks and attempted |
2338 // to actually demux and decode the stream. On platforms that support both | 1842 // to actually demux and decode the stream. On platforms that support both |
2339 // demuxing and decoding we'll get PIPELINE_OK. | 1843 // demuxing and decoding we'll get PIPELINE_OK. |
2340 MockMediaSource source("bear-320x240-v_frag-hevc.mp4", kMP4VideoHEVC2, | 1844 MockMediaSource source("bear-320x240-v_frag-hevc.mp4", kMP4VideoHEVC2, |
2341 kAppendWholeFile); | 1845 kAppendWholeFile); |
2342 #if BUILDFLAG(ENABLE_HEVC_DEMUXING) | 1846 #if BUILDFLAG(ENABLE_HEVC_DEMUXING) |
2343 PipelineStatus status = StartPipelineWithMediaSource(&source); | 1847 PipelineStatus status = StartPipelineWithMediaSource(&source); |
2344 EXPECT_TRUE(status == PIPELINE_OK || status == DECODER_ERROR_NOT_SUPPORTED); | 1848 EXPECT_TRUE(status == PIPELINE_OK || status == DECODER_ERROR_NOT_SUPPORTED); |
2345 #else | 1849 #else |
2346 EXPECT_EQ( | 1850 EXPECT_EQ( |
2347 DEMUXER_ERROR_COULD_NOT_OPEN, | 1851 DEMUXER_ERROR_COULD_NOT_OPEN, |
2348 StartPipelineWithMediaSource(&source, kExpectDemuxerFailure, nullptr)); | 1852 StartPipelineWithMediaSource(&source, kExpectDemuxerFailure, nullptr)); |
2349 #endif | 1853 #endif |
2350 } | 1854 } |
2351 | 1855 |
2352 #endif // BUILDFLAG(USE_PROPRIETARY_CODECS) | 1856 #endif // BUILDFLAG(USE_PROPRIETARY_CODECS) |
2353 | 1857 |
2354 TEST_F(PipelineIntegrationTest, SeekWhilePaused) { | 1858 TEST_P(CommonPipelineIntegrationTest, SeekWhilePaused) { |
2355 ASSERT_EQ(PIPELINE_OK, Start("bear-320x240.webm")); | 1859 ASSERT_EQ(PIPELINE_OK, Start("bear-320x240.webm")); |
2356 | 1860 |
2357 base::TimeDelta duration(pipeline_->GetMediaDuration()); | 1861 base::TimeDelta duration(pipeline_->GetMediaDuration()); |
2358 base::TimeDelta start_seek_time(duration / 4); | 1862 base::TimeDelta start_seek_time(duration / 4); |
2359 base::TimeDelta seek_time(duration * 3 / 4); | 1863 base::TimeDelta seek_time(duration * 3 / 4); |
2360 | 1864 |
2361 Play(); | 1865 Play(); |
2362 ASSERT_TRUE(WaitUntilCurrentTimeIsAfter(start_seek_time)); | 1866 ASSERT_TRUE(WaitUntilCurrentTimeIsAfter(start_seek_time)); |
2363 Pause(); | 1867 Pause(); |
2364 ASSERT_TRUE(Seek(seek_time)); | 1868 ASSERT_TRUE(Seek(seek_time)); |
2365 EXPECT_EQ(seek_time, pipeline_->GetMediaTime()); | 1869 EXPECT_EQ(seek_time, pipeline_->GetMediaTime()); |
2366 Play(); | 1870 Play(); |
2367 ASSERT_TRUE(WaitUntilOnEnded()); | 1871 ASSERT_TRUE(WaitUntilOnEnded()); |
2368 | 1872 |
2369 // Make sure seeking after reaching the end works as expected. | 1873 // Make sure seeking after reaching the end works as expected. |
2370 Pause(); | 1874 Pause(); |
2371 ASSERT_TRUE(Seek(seek_time)); | 1875 ASSERT_TRUE(Seek(seek_time)); |
2372 EXPECT_EQ(seek_time, pipeline_->GetMediaTime()); | 1876 EXPECT_EQ(seek_time, pipeline_->GetMediaTime()); |
2373 Play(); | 1877 Play(); |
2374 ASSERT_TRUE(WaitUntilOnEnded()); | 1878 ASSERT_TRUE(WaitUntilOnEnded()); |
2375 } | 1879 } |
2376 | 1880 |
2377 TEST_F(PipelineIntegrationTest, SeekWhilePlaying) { | 1881 TEST_P(CommonPipelineIntegrationTest, SeekWhilePlaying) { |
2378 ASSERT_EQ(PIPELINE_OK, Start("bear-320x240.webm")); | 1882 ASSERT_EQ(PIPELINE_OK, Start("bear-320x240.webm")); |
2379 | 1883 |
2380 base::TimeDelta duration(pipeline_->GetMediaDuration()); | 1884 base::TimeDelta duration(pipeline_->GetMediaDuration()); |
2381 base::TimeDelta start_seek_time(duration / 4); | 1885 base::TimeDelta start_seek_time(duration / 4); |
2382 base::TimeDelta seek_time(duration * 3 / 4); | 1886 base::TimeDelta seek_time(duration * 3 / 4); |
2383 | 1887 |
2384 Play(); | 1888 Play(); |
2385 ASSERT_TRUE(WaitUntilCurrentTimeIsAfter(start_seek_time)); | 1889 ASSERT_TRUE(WaitUntilCurrentTimeIsAfter(start_seek_time)); |
2386 ASSERT_TRUE(Seek(seek_time)); | 1890 ASSERT_TRUE(Seek(seek_time)); |
2387 EXPECT_GE(pipeline_->GetMediaTime(), seek_time); | 1891 EXPECT_GE(pipeline_->GetMediaTime(), seek_time); |
2388 ASSERT_TRUE(WaitUntilOnEnded()); | 1892 ASSERT_TRUE(WaitUntilOnEnded()); |
2389 | 1893 |
2390 // Make sure seeking after reaching the end works as expected. | 1894 // Make sure seeking after reaching the end works as expected. |
2391 ASSERT_TRUE(Seek(seek_time)); | 1895 ASSERT_TRUE(Seek(seek_time)); |
2392 EXPECT_GE(pipeline_->GetMediaTime(), seek_time); | 1896 EXPECT_GE(pipeline_->GetMediaTime(), seek_time); |
2393 ASSERT_TRUE(WaitUntilOnEnded()); | 1897 ASSERT_TRUE(WaitUntilOnEnded()); |
2394 } | 1898 } |
2395 | 1899 |
2396 TEST_F(PipelineIntegrationTest, SuspendWhilePaused) { | 1900 TEST_P(CommonPipelineIntegrationTest, SuspendWhilePaused) { |
2397 ASSERT_EQ(PIPELINE_OK, Start("bear-320x240.webm")); | 1901 ASSERT_EQ(PIPELINE_OK, Start("bear-320x240.webm")); |
2398 | 1902 |
2399 base::TimeDelta duration(pipeline_->GetMediaDuration()); | 1903 base::TimeDelta duration(pipeline_->GetMediaDuration()); |
2400 base::TimeDelta start_seek_time(duration / 4); | 1904 base::TimeDelta start_seek_time(duration / 4); |
2401 base::TimeDelta seek_time(duration * 3 / 4); | 1905 base::TimeDelta seek_time(duration * 3 / 4); |
2402 | 1906 |
2403 Play(); | 1907 Play(); |
2404 ASSERT_TRUE(WaitUntilCurrentTimeIsAfter(start_seek_time)); | 1908 ASSERT_TRUE(WaitUntilCurrentTimeIsAfter(start_seek_time)); |
2405 Pause(); | 1909 Pause(); |
2406 | 1910 |
2407 // Suspend while paused. | 1911 // Suspend while paused. |
2408 ASSERT_TRUE(Suspend()); | 1912 ASSERT_TRUE(Suspend()); |
2409 | 1913 |
2410 // Resuming the pipeline will create a new Renderer, | 1914 // Resuming the pipeline will create a new Renderer, |
2411 // which in turn will trigger video size and opacity notifications. | 1915 // which in turn will trigger video size and opacity notifications. |
2412 EXPECT_CALL(*this, OnVideoNaturalSizeChange(gfx::Size(320, 240))).Times(1); | 1916 EXPECT_CALL(*this, OnVideoNaturalSizeChange(gfx::Size(320, 240))).Times(1); |
2413 EXPECT_CALL(*this, OnVideoOpacityChange(true)).Times(1); | 1917 EXPECT_CALL(*this, OnVideoOpacityChange(true)).Times(1); |
2414 | 1918 |
2415 ASSERT_TRUE(Resume(seek_time)); | 1919 ASSERT_TRUE(Resume(seek_time)); |
2416 EXPECT_GE(pipeline_->GetMediaTime(), seek_time); | 1920 EXPECT_GE(pipeline_->GetMediaTime(), seek_time); |
2417 Play(); | 1921 Play(); |
2418 ASSERT_TRUE(WaitUntilOnEnded()); | 1922 ASSERT_TRUE(WaitUntilOnEnded()); |
2419 } | 1923 } |
2420 | 1924 |
2421 TEST_F(PipelineIntegrationTest, SuspendWhilePlaying) { | 1925 TEST_P(CommonPipelineIntegrationTest, SuspendWhilePlaying) { |
2422 ASSERT_EQ(PIPELINE_OK, Start("bear-320x240.webm")); | 1926 ASSERT_EQ(PIPELINE_OK, Start("bear-320x240.webm")); |
2423 | 1927 |
2424 base::TimeDelta duration(pipeline_->GetMediaDuration()); | 1928 base::TimeDelta duration(pipeline_->GetMediaDuration()); |
2425 base::TimeDelta start_seek_time(duration / 4); | 1929 base::TimeDelta start_seek_time(duration / 4); |
2426 base::TimeDelta seek_time(duration * 3 / 4); | 1930 base::TimeDelta seek_time(duration * 3 / 4); |
2427 | 1931 |
2428 Play(); | 1932 Play(); |
2429 ASSERT_TRUE(WaitUntilCurrentTimeIsAfter(start_seek_time)); | 1933 ASSERT_TRUE(WaitUntilCurrentTimeIsAfter(start_seek_time)); |
2430 ASSERT_TRUE(Suspend()); | 1934 ASSERT_TRUE(Suspend()); |
2431 | 1935 |
2432 // Resuming the pipeline will create a new Renderer, | 1936 // Resuming the pipeline will create a new Renderer, |
2433 // which in turn will trigger video size and opacity notifications. | 1937 // which in turn will trigger video size and opacity notifications. |
2434 EXPECT_CALL(*this, OnVideoNaturalSizeChange(gfx::Size(320, 240))).Times(1); | 1938 EXPECT_CALL(*this, OnVideoNaturalSizeChange(gfx::Size(320, 240))).Times(1); |
2435 EXPECT_CALL(*this, OnVideoOpacityChange(true)).Times(1); | 1939 EXPECT_CALL(*this, OnVideoOpacityChange(true)).Times(1); |
2436 | 1940 |
2437 ASSERT_TRUE(Resume(seek_time)); | 1941 ASSERT_TRUE(Resume(seek_time)); |
2438 EXPECT_GE(pipeline_->GetMediaTime(), seek_time); | 1942 EXPECT_GE(pipeline_->GetMediaTime(), seek_time); |
2439 ASSERT_TRUE(WaitUntilOnEnded()); | 1943 ASSERT_TRUE(WaitUntilOnEnded()); |
2440 } | 1944 } |
2441 | 1945 |
2442 #if BUILDFLAG(USE_PROPRIETARY_CODECS) | 1946 #if BUILDFLAG(USE_PROPRIETARY_CODECS) |
2443 TEST_F(PipelineIntegrationTest, Rotated_Metadata_0) { | 1947 TEST_P(CommonPipelineIntegrationTest, Rotated_Metadata_0) { |
2444 ASSERT_EQ(PIPELINE_OK, Start("bear_rotate_0.mp4")); | 1948 ASSERT_EQ(PIPELINE_OK, Start("bear_rotate_0.mp4")); |
2445 ASSERT_EQ(VIDEO_ROTATION_0, metadata_.video_rotation); | 1949 ASSERT_EQ(VIDEO_ROTATION_0, metadata_.video_rotation); |
2446 } | 1950 } |
2447 | 1951 |
2448 TEST_F(PipelineIntegrationTest, Rotated_Metadata_90) { | 1952 TEST_P(CommonPipelineIntegrationTest, Rotated_Metadata_90) { |
2449 ASSERT_EQ(PIPELINE_OK, Start("bear_rotate_90.mp4")); | 1953 ASSERT_EQ(PIPELINE_OK, Start("bear_rotate_90.mp4")); |
2450 ASSERT_EQ(VIDEO_ROTATION_90, metadata_.video_rotation); | 1954 ASSERT_EQ(VIDEO_ROTATION_90, metadata_.video_rotation); |
2451 } | 1955 } |
2452 | 1956 |
2453 TEST_F(PipelineIntegrationTest, Rotated_Metadata_180) { | 1957 TEST_P(CommonPipelineIntegrationTest, Rotated_Metadata_180) { |
2454 ASSERT_EQ(PIPELINE_OK, Start("bear_rotate_180.mp4")); | 1958 ASSERT_EQ(PIPELINE_OK, Start("bear_rotate_180.mp4")); |
2455 ASSERT_EQ(VIDEO_ROTATION_180, metadata_.video_rotation); | 1959 ASSERT_EQ(VIDEO_ROTATION_180, metadata_.video_rotation); |
2456 } | 1960 } |
2457 | 1961 |
2458 TEST_F(PipelineIntegrationTest, Rotated_Metadata_270) { | 1962 TEST_P(CommonPipelineIntegrationTest, Rotated_Metadata_270) { |
2459 ASSERT_EQ(PIPELINE_OK, Start("bear_rotate_270.mp4")); | 1963 ASSERT_EQ(PIPELINE_OK, Start("bear_rotate_270.mp4")); |
2460 ASSERT_EQ(VIDEO_ROTATION_270, metadata_.video_rotation); | 1964 ASSERT_EQ(VIDEO_ROTATION_270, metadata_.video_rotation); |
2461 } | 1965 } |
2462 #endif // BUILDFLAG(USE_PROPRIETARY_CODECS) | 1966 #endif // BUILDFLAG(USE_PROPRIETARY_CODECS) |
2463 | 1967 |
2464 // Verify audio decoder & renderer can handle aborted demuxer reads. | 1968 // Verify audio decoder & renderer can handle aborted demuxer reads. |
2465 TEST_F(PipelineIntegrationTest, ChunkDemuxerAbortRead_AudioOnly) { | 1969 TEST_P(CommonPipelineIntegrationTest, ChunkDemuxerAbortRead_AudioOnly) { |
2466 ASSERT_TRUE(TestSeekDuringRead("bear-320x240-audio-only.webm", kAudioOnlyWebM, | 1970 ASSERT_TRUE(TestSeekDuringRead("bear-320x240-audio-only.webm", kAudioOnlyWebM, |
2467 16384, base::TimeDelta::FromMilliseconds(464), | 1971 16384, base::TimeDelta::FromMilliseconds(464), |
2468 base::TimeDelta::FromMilliseconds(617), 0x10CA, | 1972 base::TimeDelta::FromMilliseconds(617), 0x10CA, |
2469 19730)); | 1973 19730)); |
2470 } | 1974 } |
2471 | 1975 |
2472 // Verify video decoder & renderer can handle aborted demuxer reads. | 1976 // Verify video decoder & renderer can handle aborted demuxer reads. |
2473 TEST_F(PipelineIntegrationTest, ChunkDemuxerAbortRead_VideoOnly) { | 1977 TEST_P(CommonPipelineIntegrationTest, ChunkDemuxerAbortRead_VideoOnly) { |
2474 ASSERT_TRUE(TestSeekDuringRead("bear-320x240-video-only.webm", kVideoOnlyWebM, | 1978 ASSERT_TRUE(TestSeekDuringRead("bear-320x240-video-only.webm", kVideoOnlyWebM, |
2475 32768, base::TimeDelta::FromMilliseconds(167), | 1979 32768, base::TimeDelta::FromMilliseconds(167), |
2476 base::TimeDelta::FromMilliseconds(1668), | 1980 base::TimeDelta::FromMilliseconds(1668), |
2477 0x1C896, 65536)); | 1981 0x1C896, 65536)); |
2478 } | 1982 } |
2479 | 1983 |
2480 // Verify that Opus audio in WebM containers can be played back. | 1984 // Verify that Opus audio in WebM containers can be played back. |
2481 TEST_F(PipelineIntegrationTest, BasicPlayback_AudioOnly_Opus_WebM) { | 1985 TEST_P(CommonPipelineIntegrationTest, BasicPlayback_AudioOnly_Opus_WebM) { |
2482 ASSERT_EQ(PIPELINE_OK, Start("bear-opus-end-trimming.webm")); | 1986 ASSERT_EQ(PIPELINE_OK, Start("bear-opus-end-trimming.webm")); |
2483 Play(); | 1987 Play(); |
2484 ASSERT_TRUE(WaitUntilOnEnded()); | 1988 ASSERT_TRUE(WaitUntilOnEnded()); |
2485 } | 1989 } |
2486 | 1990 |
2487 // Verify that VP9 video in WebM containers can be played back. | 1991 // Verify that VP9 video in WebM containers can be played back. |
2488 TEST_F(PipelineIntegrationTest, BasicPlayback_VideoOnly_VP9_WebM) { | 1992 TEST_P(CommonPipelineIntegrationTest, BasicPlayback_VideoOnly_VP9_WebM) { |
2489 ASSERT_EQ(PIPELINE_OK, Start("bear-vp9.webm")); | 1993 ASSERT_EQ(PIPELINE_OK, Start("bear-vp9.webm")); |
2490 Play(); | 1994 Play(); |
2491 ASSERT_TRUE(WaitUntilOnEnded()); | 1995 ASSERT_TRUE(WaitUntilOnEnded()); |
2492 } | 1996 } |
2493 | 1997 |
2494 // Verify that VP9 video and Opus audio in the same WebM container can be played | 1998 // Verify that VP9 video and Opus audio in the same WebM container can be played |
2495 // back. | 1999 // back. |
2496 TEST_F(PipelineIntegrationTest, BasicPlayback_VP9_Opus_WebM) { | 2000 TEST_P(CommonPipelineIntegrationTest, BasicPlayback_VP9_Opus_WebM) { |
2497 ASSERT_EQ(PIPELINE_OK, Start("bear-vp9-opus.webm")); | 2001 ASSERT_EQ(PIPELINE_OK, Start("bear-vp9-opus.webm")); |
2498 Play(); | 2002 Play(); |
2499 ASSERT_TRUE(WaitUntilOnEnded()); | 2003 ASSERT_TRUE(WaitUntilOnEnded()); |
2500 } | 2004 } |
2501 | 2005 |
2502 // Verify that VP8 video with alpha channel can be played back. | 2006 // Verify that VP8 video with alpha channel can be played back. |
2503 TEST_F(PipelineIntegrationTest, BasicPlayback_VP8A_WebM) { | 2007 TEST_P(CommonPipelineIntegrationTest, BasicPlayback_VP8A_WebM) { |
2504 ASSERT_EQ(PIPELINE_OK, Start("bear-vp8a.webm")); | 2008 ASSERT_EQ(PIPELINE_OK, Start("bear-vp8a.webm")); |
2505 Play(); | 2009 Play(); |
2506 ASSERT_TRUE(WaitUntilOnEnded()); | 2010 ASSERT_TRUE(WaitUntilOnEnded()); |
2507 EXPECT_VIDEO_FORMAT_EQ(last_video_frame_format_, PIXEL_FORMAT_YV12A); | 2011 EXPECT_VIDEO_FORMAT_EQ(last_video_frame_format_, PIXEL_FORMAT_YV12A); |
2508 } | 2012 } |
2509 | 2013 |
2510 // Verify that VP8A video with odd width/height can be played back. | 2014 // Verify that VP8A video with odd width/height can be played back. |
2511 TEST_F(PipelineIntegrationTest, BasicPlayback_VP8A_Odd_WebM) { | 2015 TEST_P(CommonPipelineIntegrationTest, BasicPlayback_VP8A_Odd_WebM) { |
2512 ASSERT_EQ(PIPELINE_OK, Start("bear-vp8a-odd-dimensions.webm")); | 2016 ASSERT_EQ(PIPELINE_OK, Start("bear-vp8a-odd-dimensions.webm")); |
2513 Play(); | 2017 Play(); |
2514 ASSERT_TRUE(WaitUntilOnEnded()); | 2018 ASSERT_TRUE(WaitUntilOnEnded()); |
2515 EXPECT_VIDEO_FORMAT_EQ(last_video_frame_format_, PIXEL_FORMAT_YV12A); | 2019 EXPECT_VIDEO_FORMAT_EQ(last_video_frame_format_, PIXEL_FORMAT_YV12A); |
2516 } | 2020 } |
2517 | 2021 |
2518 // Verify that VP9 video with odd width/height can be played back. | 2022 // Verify that VP9 video with odd width/height can be played back. |
2519 TEST_F(PipelineIntegrationTest, BasicPlayback_VP9_Odd_WebM) { | 2023 TEST_P(CommonPipelineIntegrationTest, BasicPlayback_VP9_Odd_WebM) { |
2520 ASSERT_EQ(PIPELINE_OK, Start("bear-vp9-odd-dimensions.webm")); | 2024 ASSERT_EQ(PIPELINE_OK, Start("bear-vp9-odd-dimensions.webm")); |
2521 Play(); | 2025 Play(); |
2522 ASSERT_TRUE(WaitUntilOnEnded()); | 2026 ASSERT_TRUE(WaitUntilOnEnded()); |
2523 } | 2027 } |
2524 | 2028 |
2525 // Verify that VP9 video with alpha channel can be played back. | 2029 // Verify that VP9 video with alpha channel can be played back. |
2526 TEST_F(PipelineIntegrationTest, BasicPlayback_VP9A_WebM) { | 2030 TEST_P(CommonPipelineIntegrationTest, BasicPlayback_VP9A_WebM) { |
2527 ASSERT_EQ(PIPELINE_OK, Start("bear-vp9a.webm")); | 2031 ASSERT_EQ(PIPELINE_OK, Start("bear-vp9a.webm")); |
2528 Play(); | 2032 Play(); |
2529 ASSERT_TRUE(WaitUntilOnEnded()); | 2033 ASSERT_TRUE(WaitUntilOnEnded()); |
2530 EXPECT_VIDEO_FORMAT_EQ(last_video_frame_format_, PIXEL_FORMAT_YV12A); | 2034 EXPECT_VIDEO_FORMAT_EQ(last_video_frame_format_, PIXEL_FORMAT_YV12A); |
2531 } | 2035 } |
2532 | 2036 |
2533 // Verify that VP9A video with odd width/height can be played back. | 2037 // Verify that VP9A video with odd width/height can be played back. |
2534 TEST_F(PipelineIntegrationTest, BasicPlayback_VP9A_Odd_WebM) { | 2038 TEST_P(CommonPipelineIntegrationTest, BasicPlayback_VP9A_Odd_WebM) { |
2535 ASSERT_EQ(PIPELINE_OK, Start("bear-vp9a-odd-dimensions.webm")); | 2039 ASSERT_EQ(PIPELINE_OK, Start("bear-vp9a-odd-dimensions.webm")); |
2536 Play(); | 2040 Play(); |
2537 ASSERT_TRUE(WaitUntilOnEnded()); | 2041 ASSERT_TRUE(WaitUntilOnEnded()); |
2538 EXPECT_VIDEO_FORMAT_EQ(last_video_frame_format_, PIXEL_FORMAT_YV12A); | 2042 EXPECT_VIDEO_FORMAT_EQ(last_video_frame_format_, PIXEL_FORMAT_YV12A); |
2539 } | 2043 } |
2540 | 2044 |
2541 // Verify that VP8 video with inband text track can be played back. | |
2542 TEST_F(PipelineIntegrationTest, MAYBE_TEXT(BasicPlayback_VP8_WebVTT_WebM)) { | |
2543 EXPECT_CALL(*this, OnAddTextTrack(_, _)); | |
2544 ASSERT_EQ(PIPELINE_OK, Start("bear-vp8-webvtt.webm")); | |
2545 Play(); | |
2546 ASSERT_TRUE(WaitUntilOnEnded()); | |
2547 } | |
2548 | |
2549 // Verify that VP9 video with 4:4:4 subsampling can be played back. | 2045 // Verify that VP9 video with 4:4:4 subsampling can be played back. |
2550 TEST_F(PipelineIntegrationTest, P444_VP9_WebM) { | 2046 TEST_P(CommonPipelineIntegrationTest, P444_VP9_WebM) { |
2551 ASSERT_EQ(PIPELINE_OK, Start("bear-320x240-P444.webm")); | 2047 ASSERT_EQ(PIPELINE_OK, Start("bear-320x240-P444.webm")); |
2552 Play(); | 2048 Play(); |
2553 ASSERT_TRUE(WaitUntilOnEnded()); | 2049 ASSERT_TRUE(WaitUntilOnEnded()); |
2554 EXPECT_VIDEO_FORMAT_EQ(last_video_frame_format_, PIXEL_FORMAT_YV24); | 2050 EXPECT_VIDEO_FORMAT_EQ(last_video_frame_format_, PIXEL_FORMAT_YV24); |
2555 } | 2051 } |
2556 | 2052 |
2557 // Verify that frames of VP9 video in the BT.709 color space have the YV12HD | 2053 // Verify that frames of VP9 video in the BT.709 color space have the YV12HD |
2558 // format. | 2054 // format. |
2559 TEST_F(PipelineIntegrationTest, BT709_VP9_WebM) { | 2055 TEST_P(CommonPipelineIntegrationTest, BT709_VP9_WebM) { |
2560 ASSERT_EQ(PIPELINE_OK, Start("bear-vp9-bt709.webm")); | 2056 ASSERT_EQ(PIPELINE_OK, Start("bear-vp9-bt709.webm")); |
2561 Play(); | 2057 Play(); |
2562 ASSERT_TRUE(WaitUntilOnEnded()); | 2058 ASSERT_TRUE(WaitUntilOnEnded()); |
2563 EXPECT_VIDEO_FORMAT_EQ(last_video_frame_format_, PIXEL_FORMAT_YV12); | 2059 EXPECT_VIDEO_FORMAT_EQ(last_video_frame_format_, PIXEL_FORMAT_YV12); |
2564 EXPECT_COLOR_SPACE_EQ(last_video_frame_color_space_, COLOR_SPACE_HD_REC709); | 2060 EXPECT_COLOR_SPACE_EQ(last_video_frame_color_space_, COLOR_SPACE_HD_REC709); |
2565 } | 2061 } |
2566 | 2062 |
2567 TEST_F(PipelineIntegrationTest, HD_VP9_WebM) { | 2063 TEST_P(CommonPipelineIntegrationTest, HD_VP9_WebM) { |
2568 ASSERT_EQ(PIPELINE_OK, Start("bear-1280x720.webm", kClockless)); | 2064 ASSERT_EQ(PIPELINE_OK, Start("bear-1280x720.webm", kClockless)); |
2569 Play(); | 2065 Play(); |
2570 ASSERT_TRUE(WaitUntilOnEnded()); | 2066 ASSERT_TRUE(WaitUntilOnEnded()); |
2571 } | 2067 } |
2572 | 2068 |
2573 // Verify that videos with an odd frame size playback successfully. | 2069 // Verify that videos with an odd frame size playback successfully. |
2574 TEST_F(PipelineIntegrationTest, BasicPlayback_OddVideoSize) { | 2070 TEST_P(CommonPipelineIntegrationTest, BasicPlayback_OddVideoSize) { |
2575 ASSERT_EQ(PIPELINE_OK, Start("butterfly-853x480.webm")); | 2071 ASSERT_EQ(PIPELINE_OK, Start("butterfly-853x480.webm")); |
2576 Play(); | 2072 Play(); |
2577 ASSERT_TRUE(WaitUntilOnEnded()); | 2073 ASSERT_TRUE(WaitUntilOnEnded()); |
2578 } | 2074 } |
2579 | 2075 |
2580 // Verify that OPUS audio in a webm which reports a 44.1kHz sample rate plays | 2076 // Verify that OPUS audio in a webm which reports a 44.1kHz sample rate plays |
2581 // correctly at 48kHz | 2077 // correctly at 48kHz |
2582 TEST_F(PipelineIntegrationTest, BasicPlayback_Opus441kHz) { | 2078 TEST_P(CommonPipelineIntegrationTest, BasicPlayback_Opus441kHz) { |
2583 ASSERT_EQ(PIPELINE_OK, Start("sfx-opus-441.webm")); | 2079 ASSERT_EQ(PIPELINE_OK, Start("sfx-opus-441.webm")); |
2584 Play(); | 2080 Play(); |
2585 ASSERT_TRUE(WaitUntilOnEnded()); | 2081 ASSERT_TRUE(WaitUntilOnEnded()); |
2586 | |
2587 EXPECT_EQ(48000, demuxer_->GetFirstStream(DemuxerStream::AUDIO) | 2082 EXPECT_EQ(48000, demuxer_->GetFirstStream(DemuxerStream::AUDIO) |
2588 ->audio_decoder_config() | 2083 ->audio_decoder_config() |
2589 .samples_per_second()); | 2084 .samples_per_second()); |
2590 } | 2085 } |
2591 | 2086 |
2592 // Same as above but using MediaSource. | 2087 // Same as above but using MediaSource. |
2593 TEST_F(PipelineIntegrationTest, BasicPlayback_MediaSource_Opus441kHz) { | 2088 TEST_P(CommonPipelineIntegrationTest, BasicPlayback_MediaSource_Opus441kHz) { |
2594 MockMediaSource source("sfx-opus-441.webm", kOpusAudioOnlyWebM, | 2089 MockMediaSource source("sfx-opus-441.webm", kOpusAudioOnlyWebM, |
2595 kAppendWholeFile); | 2090 kAppendWholeFile); |
2596 EXPECT_EQ(PIPELINE_OK, StartPipelineWithMediaSource(&source)); | 2091 EXPECT_EQ(PIPELINE_OK, StartPipelineWithMediaSource(&source)); |
2597 source.EndOfStream(); | 2092 source.EndOfStream(); |
2598 Play(); | 2093 Play(); |
2599 ASSERT_TRUE(WaitUntilOnEnded()); | 2094 ASSERT_TRUE(WaitUntilOnEnded()); |
2600 source.Shutdown(); | 2095 source.Shutdown(); |
2601 Stop(); | 2096 Stop(); |
2602 EXPECT_EQ(48000, demuxer_->GetFirstStream(DemuxerStream::AUDIO) | 2097 EXPECT_EQ(48000, demuxer_->GetFirstStream(DemuxerStream::AUDIO) |
2603 ->audio_decoder_config() | 2098 ->audio_decoder_config() |
2604 .samples_per_second()); | 2099 .samples_per_second()); |
2605 } | 2100 } |
2606 | 2101 |
2607 // Ensures audio-only playback with missing or negative timestamps works. Tests | 2102 // Ensures audio-only playback with missing or negative timestamps works. Tests |
2608 // the common live-streaming case for chained ogg. See http://crbug.com/396864. | 2103 // the common live-streaming case for chained ogg. See http://crbug.com/396864. |
2609 TEST_F(PipelineIntegrationTest, BasicPlaybackChainedOgg) { | 2104 TEST_P(CommonPipelineIntegrationTest, BasicPlaybackChainedOgg) { |
2610 ASSERT_EQ(PIPELINE_OK, Start("double-sfx.ogg", kUnreliableDuration)); | 2105 ASSERT_EQ(PIPELINE_OK, Start("double-sfx.ogg", kUnreliableDuration)); |
2611 Play(); | 2106 Play(); |
2612 ASSERT_TRUE(WaitUntilOnEnded()); | 2107 ASSERT_TRUE(WaitUntilOnEnded()); |
2613 ASSERT_EQ(base::TimeDelta(), demuxer_->GetStartTime()); | 2108 ASSERT_EQ(base::TimeDelta(), demuxer_->GetStartTime()); |
2614 } | 2109 } |
2615 | 2110 |
2616 // Ensures audio-video playback with missing or negative timestamps fails softly | |
2617 // instead of crashing. See http://crbug.com/396864. | |
2618 TEST_F(PipelineIntegrationTest, BasicPlaybackChainedOggVideo) { | |
2619 ASSERT_EQ(PIPELINE_OK, Start("double-bear.ogv", kUnreliableDuration)); | |
2620 Play(); | |
2621 EXPECT_EQ(PIPELINE_ERROR_DECODE, WaitUntilEndedOrError()); | |
2622 ASSERT_EQ(base::TimeDelta(), demuxer_->GetStartTime()); | |
2623 } | |
2624 | |
2625 // Tests that we signal ended even when audio runs longer than video track. | 2111 // Tests that we signal ended even when audio runs longer than video track. |
2626 TEST_F(PipelineIntegrationTest, BasicPlaybackAudioLongerThanVideo) { | 2112 TEST_P(CommonPipelineIntegrationTest, BasicPlaybackAudioLongerThanVideo) { |
2627 ASSERT_EQ(PIPELINE_OK, Start("bear_audio_longer_than_video.ogv")); | 2113 ASSERT_EQ(PIPELINE_OK, Start("bear_audio_longer_than_video.ogv")); |
2628 // Audio track is 2000ms. Video track is 1001ms. Duration should be higher | 2114 // Audio track is 2000ms. Video track is 1001ms. Duration should be higher |
2629 // of the two. | 2115 // of the two. |
2630 EXPECT_EQ(2000, pipeline_->GetMediaDuration().InMilliseconds()); | 2116 EXPECT_EQ(2000, pipeline_->GetMediaDuration().InMilliseconds()); |
2631 Play(); | 2117 Play(); |
2632 ASSERT_TRUE(WaitUntilOnEnded()); | 2118 ASSERT_TRUE(WaitUntilOnEnded()); |
2633 } | 2119 } |
2634 | 2120 |
2635 // Tests that we signal ended even when audio runs shorter than video track. | 2121 // Tests that we signal ended even when audio runs shorter than video track. |
2636 TEST_F(PipelineIntegrationTest, BasicPlaybackAudioShorterThanVideo) { | 2122 TEST_P(CommonPipelineIntegrationTest, BasicPlaybackAudioShorterThanVideo) { |
2637 ASSERT_EQ(PIPELINE_OK, Start("bear_audio_shorter_than_video.ogv")); | 2123 ASSERT_EQ(PIPELINE_OK, Start("bear_audio_shorter_than_video.ogv")); |
2638 // Audio track is 500ms. Video track is 1001ms. Duration should be higher of | 2124 // Audio track is 500ms. Video track is 1001ms. Duration should be higher of |
2639 // the two. | 2125 // the two. |
2640 EXPECT_EQ(1001, pipeline_->GetMediaDuration().InMilliseconds()); | 2126 EXPECT_EQ(1001, pipeline_->GetMediaDuration().InMilliseconds()); |
2641 Play(); | 2127 Play(); |
2642 ASSERT_TRUE(WaitUntilOnEnded()); | 2128 ASSERT_TRUE(WaitUntilOnEnded()); |
2643 } | 2129 } |
2644 | 2130 |
2645 TEST_F(PipelineIntegrationTest, BasicPlaybackPositiveStartTime) { | 2131 TEST_P(CommonPipelineIntegrationTest, BasicPlaybackPositiveStartTime) { |
2646 ASSERT_EQ(PIPELINE_OK, Start("nonzero-start-time.webm")); | 2132 ASSERT_EQ(PIPELINE_OK, Start("nonzero-start-time.webm")); |
2647 Play(); | 2133 Play(); |
2648 ASSERT_TRUE(WaitUntilOnEnded()); | 2134 ASSERT_TRUE(WaitUntilOnEnded()); |
2649 ASSERT_EQ(base::TimeDelta::FromMicroseconds(396000), | 2135 ASSERT_EQ(base::TimeDelta::FromMicroseconds(396000), |
2650 demuxer_->GetStartTime()); | 2136 demuxer_->GetStartTime()); |
2651 } | 2137 } |
2652 | 2138 |
2139 const IntegrationTestData kIntegrationTests[] = { | |
2140 {PipelineType::Media}, | |
2141 #if BUILDFLAG(ENABLE_MEDIA_REMOTING) | |
2142 {PipelineType::MediaRemoting}, | |
2143 #endif // BUILDFLAG(ENABLE_MEDIA_REMOTING) | |
2144 }; | |
2145 | |
2146 INSTANTIATE_TEST_CASE_P(, | |
2147 CommonPipelineIntegrationTest, | |
2148 testing::ValuesIn(kIntegrationTests)); | |
2149 | |
2150 // Media Remoting currently doesn't support stream status change without | |
2151 // restarting pipeline. | |
2152 TEST_F(PipelineIntegrationTest, ReinitRenderersWhileAudioTrackIsDisabled) { | |
2153 ASSERT_EQ(PIPELINE_OK, Start("bear-320x240.webm")); | |
2154 Play(); | |
2155 | |
2156 // These get triggered every time playback is resumed. | |
2157 EXPECT_CALL(*this, OnVideoNaturalSizeChange(gfx::Size(320, 240))) | |
2158 .Times(AnyNumber()); | |
2159 EXPECT_CALL(*this, OnVideoOpacityChange(true)).Times(AnyNumber()); | |
2160 | |
2161 // Disable the audio track. | |
2162 std::vector<MediaTrack::Id> track_ids; | |
2163 pipeline_->OnEnabledAudioTracksChanged(track_ids); | |
2164 // pipeline.Suspend() releases renderers and pipeline.Resume() recreates and | |
2165 // reinitializes renderers while the audio track is disabled. | |
2166 ASSERT_TRUE(Suspend()); | |
2167 ASSERT_TRUE(Resume(TimestampMs(100))); | |
2168 // Now re-enable the audio track, playback should continue successfully. | |
2169 EXPECT_CALL(*this, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)).Times(1); | |
2170 track_ids.push_back("2"); | |
2171 pipeline_->OnEnabledAudioTracksChanged(track_ids); | |
2172 ASSERT_TRUE(WaitUntilCurrentTimeIsAfter(TimestampMs(200))); | |
2173 | |
2174 Stop(); | |
2175 } | |
2176 | |
2177 TEST_F(PipelineIntegrationTest, ReinitRenderersWhileVideoTrackIsDisabled) { | |
2178 ASSERT_EQ(PIPELINE_OK, Start("bear-320x240.webm", kHashed)); | |
2179 Play(); | |
2180 | |
2181 // These get triggered every time playback is resumed. | |
2182 EXPECT_CALL(*this, OnVideoNaturalSizeChange(gfx::Size(320, 240))) | |
2183 .Times(AnyNumber()); | |
2184 EXPECT_CALL(*this, OnVideoOpacityChange(true)).Times(AnyNumber()); | |
2185 | |
2186 // Disable the video track. | |
2187 pipeline_->OnSelectedVideoTrackChanged(base::nullopt); | |
2188 // pipeline.Suspend() releases renderers and pipeline.Resume() recreates and | |
2189 // reinitializes renderers while the video track is disabled. | |
2190 ASSERT_TRUE(Suspend()); | |
2191 ASSERT_TRUE(Resume(TimestampMs(100))); | |
2192 // Now re-enable the video track, playback should continue successfully. | |
2193 pipeline_->OnSelectedVideoTrackChanged(MediaTrack::Id("1")); | |
2194 ASSERT_TRUE(WaitUntilCurrentTimeIsAfter(TimestampMs(200))); | |
2195 | |
2196 Stop(); | |
2197 } | |
2198 | |
2199 TEST_F(PipelineIntegrationTest, MAYBE_EME(BasicPlaybackEncrypted)) { | |
2200 FakeEncryptedMedia encrypted_media(new KeyProvidingApp()); | |
2201 set_encrypted_media_init_data_cb( | |
2202 base::Bind(&FakeEncryptedMedia::OnEncryptedMediaInitData, | |
2203 base::Unretained(&encrypted_media))); | |
2204 | |
2205 ASSERT_EQ(PIPELINE_OK, Start("bear-320x240-av_enc-av.webm", | |
2206 encrypted_media.GetCdmContext())); | |
2207 | |
2208 Play(); | |
2209 | |
2210 ASSERT_TRUE(WaitUntilOnEnded()); | |
2211 Stop(); | |
2212 } | |
2213 | |
2214 TEST_F(PipelineIntegrationTest, | |
2215 MAYBE_EME(MediaSource_ConfigChange_Encrypted_WebM)) { | |
2216 MockMediaSource source("bear-320x240-16x9-aspect-av_enc-av.webm", kWebM, | |
2217 kAppendWholeFile); | |
2218 FakeEncryptedMedia encrypted_media(new KeyProvidingApp()); | |
2219 EXPECT_EQ(PIPELINE_OK, | |
2220 StartPipelineWithEncryptedMedia(&source, &encrypted_media)); | |
2221 | |
2222 EXPECT_CALL(*this, OnVideoNaturalSizeChange(gfx::Size(640, 360))).Times(1); | |
2223 scoped_refptr<DecoderBuffer> second_file = | |
2224 ReadTestDataFile("bear-640x360-av_enc-av.webm"); | |
2225 ASSERT_TRUE(source.AppendAtTime(base::TimeDelta::FromSeconds(kAppendTimeSec), | |
2226 second_file->data(), | |
2227 second_file->data_size())); | |
2228 source.EndOfStream(); | |
2229 | |
2230 Play(); | |
2231 EXPECT_TRUE(WaitUntilOnEnded()); | |
2232 | |
2233 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); | |
2234 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); | |
2235 EXPECT_EQ(kAppendTimeMs + k640WebMFileDurationMs, | |
2236 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); | |
2237 | |
2238 source.Shutdown(); | |
2239 Stop(); | |
2240 } | |
2241 | |
2242 TEST_F(PipelineIntegrationTest, | |
2243 MAYBE_EME(MediaSource_ConfigChange_ClearThenEncrypted_WebM)) { | |
2244 MockMediaSource source("bear-320x240-16x9-aspect.webm", kWebM, | |
2245 kAppendWholeFile); | |
2246 FakeEncryptedMedia encrypted_media(new KeyProvidingApp()); | |
2247 EXPECT_EQ(PIPELINE_OK, | |
2248 StartPipelineWithEncryptedMedia(&source, &encrypted_media)); | |
2249 | |
2250 EXPECT_CALL(*this, OnVideoNaturalSizeChange(gfx::Size(640, 360))).Times(1); | |
2251 scoped_refptr<DecoderBuffer> second_file = | |
2252 ReadTestDataFile("bear-640x360-av_enc-av.webm"); | |
2253 | |
2254 EXPECT_TRUE(source.AppendAtTime(base::TimeDelta::FromSeconds(kAppendTimeSec), | |
2255 second_file->data(), | |
2256 second_file->data_size())); | |
2257 source.EndOfStream(); | |
2258 | |
2259 Play(); | |
2260 EXPECT_TRUE(WaitUntilOnEnded()); | |
2261 | |
2262 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); | |
2263 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); | |
2264 EXPECT_EQ(kAppendTimeMs + k640WebMFileDurationMs, | |
2265 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); | |
2266 | |
2267 source.Shutdown(); | |
2268 Stop(); | |
2269 } | |
2270 | |
2271 // Config change from encrypted to clear is allowed by the demuxer, and is | |
2272 // supported by the Renderer. | |
2273 TEST_F(PipelineIntegrationTest, | |
2274 MAYBE_EME(MediaSource_ConfigChange_EncryptedThenClear_WebM)) { | |
2275 MockMediaSource source("bear-320x240-16x9-aspect-av_enc-av.webm", kWebM, | |
2276 kAppendWholeFile); | |
2277 FakeEncryptedMedia encrypted_media(new KeyProvidingApp()); | |
2278 EXPECT_EQ(PIPELINE_OK, | |
2279 StartPipelineWithEncryptedMedia(&source, &encrypted_media)); | |
2280 | |
2281 EXPECT_CALL(*this, OnVideoNaturalSizeChange(gfx::Size(640, 360))).Times(1); | |
2282 scoped_refptr<DecoderBuffer> second_file = | |
2283 ReadTestDataFile("bear-640x360.webm"); | |
2284 | |
2285 ASSERT_TRUE(source.AppendAtTime(base::TimeDelta::FromSeconds(kAppendTimeSec), | |
2286 second_file->data(), | |
2287 second_file->data_size())); | |
2288 source.EndOfStream(); | |
2289 | |
2290 Play(); | |
2291 ASSERT_TRUE(WaitUntilOnEnded()); | |
2292 | |
2293 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); | |
2294 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); | |
2295 EXPECT_EQ(kAppendTimeMs + k640WebMFileDurationMs, | |
2296 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); | |
2297 | |
2298 source.Shutdown(); | |
2299 Stop(); | |
2300 } | |
2301 | |
2302 #if BUILDFLAG(USE_PROPRIETARY_CODECS) | |
2303 #if !defined(DISABLE_CLOCKLESS_TESTS) | |
2304 class Mp3FastSeekParams { | |
2305 public: | |
2306 Mp3FastSeekParams(const char* filename, const char* hash) | |
2307 : filename(filename), hash(hash) {} | |
2308 const char* filename; | |
2309 const char* hash; | |
2310 }; | |
2311 | |
2312 class Mp3FastSeekIntegrationTest | |
2313 : public PipelineIntegrationTest, | |
2314 public testing::WithParamInterface<Mp3FastSeekParams> {}; | |
2315 | |
2316 TEST_P(Mp3FastSeekIntegrationTest, FastSeekAccuracy_MP3) { | |
2317 Mp3FastSeekParams config = GetParam(); | |
2318 ASSERT_EQ(PIPELINE_OK, Start(config.filename, kHashed)); | |
2319 | |
2320 // The XING TOC is inaccurate. We don't use it for CBR, we tolerate it for VBR | |
2321 // (best option for fast seeking; see Mp3SeekFFmpegDemuxerTest). The chosen | |
2322 // seek time exposes inaccuracy in TOC such that the hash will change if seek | |
2323 // logic is regressed. See https://crbug.com/545914. | |
2324 // | |
2325 // Quick TOC design (not pretty!): | |
2326 // - All MP3 TOCs are 100 bytes | |
2327 // - Each byte is read as a uint8_t; value between 0 - 255. | |
2328 // - The index into this array is the numerator in the ratio: index / 100. | |
2329 // This fraction represents a playback time as a percentage of duration. | |
2330 // - The value at the given index is the numerator in the ratio: value / 256. | |
2331 // This fraction represents a byte offset as a percentage of the file size. | |
2332 // | |
2333 // For CBR files, each frame is the same size, so the offset for time of | |
2334 // (0.98 * duration) should be around (0.98 * file size). This is 250.88 / 256 | |
2335 // but the numerator will be truncated in the TOC as 250, losing precision. | |
2336 base::TimeDelta seek_time(0.98 * pipeline_->GetMediaDuration()); | |
2337 | |
2338 ASSERT_TRUE(Seek(seek_time)); | |
2339 Play(); | |
2340 ASSERT_TRUE(WaitUntilOnEnded()); | |
2341 | |
2342 EXPECT_HASH_EQ(config.hash, GetAudioHash()); | |
2343 } | |
2344 | |
2345 INSTANTIATE_TEST_CASE_P( | |
2346 CBRSeek_HasTOC, | |
2347 Mp3FastSeekIntegrationTest, | |
2348 ::testing::Values(Mp3FastSeekParams("bear-audio-10s-CBR-has-TOC.mp3", | |
2349 "-0.71,0.36,2.96,2.68,2.11,-1.08,"))); | |
2350 INSTANTIATE_TEST_CASE_P( | |
2351 CBRSeeks_NoTOC, | |
2352 Mp3FastSeekIntegrationTest, | |
2353 ::testing::Values(Mp3FastSeekParams("bear-audio-10s-CBR-no-TOC.mp3", | |
2354 "0.95,0.56,1.34,0.47,1.77,0.84,"))); | |
2355 // VBR seeks can be fast *OR* accurate, but not both. We chose fast. | |
2356 INSTANTIATE_TEST_CASE_P( | |
2357 VBRSeeks_HasTOC, | |
2358 Mp3FastSeekIntegrationTest, | |
2359 ::testing::Values(Mp3FastSeekParams("bear-audio-10s-VBR-has-TOC.mp3", | |
2360 "-0.15,-0.83,0.54,1.00,1.94,0.93,"))); | |
2361 INSTANTIATE_TEST_CASE_P( | |
2362 VBRSeeks_NoTOC, | |
2363 Mp3FastSeekIntegrationTest, | |
2364 ::testing::Values(Mp3FastSeekParams("bear-audio-10s-VBR-no-TOC.mp3", | |
2365 "-0.22,0.80,1.19,0.73,-0.31,-1.12,"))); | |
2366 #endif // !defined(DISABLE_CLOCKLESS_TESTS) | |
2367 | |
2368 TEST_F(PipelineIntegrationTest, | |
2369 MAYBE_EME(MediaSource_ConfigChange_Encrypted_MP4_CENC_VideoOnly)) { | |
2370 MockMediaSource source("bear-640x360-v_frag-cenc.mp4", kMP4Video, | |
2371 kAppendWholeFile); | |
2372 FakeEncryptedMedia encrypted_media(new KeyProvidingApp()); | |
2373 EXPECT_EQ(PIPELINE_OK, | |
2374 StartPipelineWithEncryptedMedia(&source, &encrypted_media)); | |
2375 | |
2376 EXPECT_CALL(*this, OnVideoNaturalSizeChange(gfx::Size(1280, 720))).Times(1); | |
2377 scoped_refptr<DecoderBuffer> second_file = | |
2378 ReadTestDataFile("bear-1280x720-v_frag-cenc.mp4"); | |
2379 ASSERT_TRUE(source.AppendAtTime(base::TimeDelta::FromSeconds(kAppendTimeSec), | |
2380 second_file->data(), | |
2381 second_file->data_size())); | |
2382 source.EndOfStream(); | |
2383 | |
2384 Play(); | |
2385 EXPECT_TRUE(WaitUntilOnEnded()); | |
2386 | |
2387 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); | |
2388 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); | |
2389 EXPECT_EQ(kAppendTimeMs + k1280IsoFileDurationMs, | |
2390 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); | |
2391 | |
2392 source.Shutdown(); | |
2393 Stop(); | |
2394 } | |
2395 | |
2396 TEST_F(PipelineIntegrationTest, | |
2397 MAYBE_EME( | |
2398 MediaSource_ConfigChange_Encrypted_MP4_CENC_KeyRotation_VideoOnly)) { | |
2399 MockMediaSource source("bear-640x360-v_frag-cenc-key_rotation.mp4", kMP4Video, | |
2400 kAppendWholeFile); | |
2401 FakeEncryptedMedia encrypted_media(new RotatingKeyProvidingApp()); | |
2402 EXPECT_EQ(PIPELINE_OK, | |
2403 StartPipelineWithEncryptedMedia(&source, &encrypted_media)); | |
2404 | |
2405 EXPECT_CALL(*this, OnVideoNaturalSizeChange(gfx::Size(1280, 720))).Times(1); | |
2406 scoped_refptr<DecoderBuffer> second_file = | |
2407 ReadTestDataFile("bear-1280x720-v_frag-cenc-key_rotation.mp4"); | |
2408 ASSERT_TRUE(source.AppendAtTime(base::TimeDelta::FromSeconds(kAppendTimeSec), | |
2409 second_file->data(), | |
2410 second_file->data_size())); | |
2411 source.EndOfStream(); | |
2412 | |
2413 Play(); | |
2414 EXPECT_TRUE(WaitUntilOnEnded()); | |
2415 | |
2416 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); | |
2417 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); | |
2418 EXPECT_EQ(kAppendTimeMs + k1280IsoFileDurationMs, | |
2419 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); | |
2420 | |
2421 source.Shutdown(); | |
2422 Stop(); | |
2423 } | |
2424 | |
2425 // Config changes from clear to encrypted are not currently supported. | |
2426 // TODO(ddorwin): Figure out why this CHECKs in AppendAtTime(). | |
2427 TEST_F(PipelineIntegrationTest, | |
2428 DISABLED_MediaSource_ConfigChange_ClearThenEncrypted_MP4_CENC) { | |
2429 MockMediaSource source("bear-640x360-av_frag.mp4", kMP4Video, | |
2430 kAppendWholeFile); | |
2431 FakeEncryptedMedia encrypted_media(new KeyProvidingApp()); | |
2432 EXPECT_EQ(PIPELINE_OK, | |
2433 StartPipelineWithEncryptedMedia(&source, &encrypted_media)); | |
2434 | |
2435 EXPECT_CALL(*this, OnVideoNaturalSizeChange(gfx::Size(1280, 720))).Times(1); | |
2436 scoped_refptr<DecoderBuffer> second_file = | |
2437 ReadTestDataFile("bear-1280x720-v_frag-cenc.mp4"); | |
2438 ASSERT_FALSE(source.AppendAtTime(base::TimeDelta::FromSeconds(kAppendTimeSec), | |
2439 second_file->data(), | |
2440 second_file->data_size())); | |
2441 | |
2442 source.EndOfStream(); | |
2443 | |
2444 base::RunLoop().Run(); | |
2445 EXPECT_EQ(CHUNK_DEMUXER_ERROR_APPEND_FAILED, pipeline_status_); | |
2446 | |
2447 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); | |
2448 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); | |
2449 // The second video was not added, so its time has not been added. | |
2450 EXPECT_EQ(k640IsoFileDurationMs, | |
2451 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); | |
2452 | |
2453 Play(); | |
2454 | |
2455 EXPECT_EQ(CHUNK_DEMUXER_ERROR_APPEND_FAILED, WaitUntilEndedOrError()); | |
2456 source.Shutdown(); | |
2457 } | |
2458 | |
2459 // Config changes from encrypted to clear are not currently supported. | |
2460 TEST_F(PipelineIntegrationTest, | |
2461 MAYBE_EME(MediaSource_ConfigChange_EncryptedThenClear_MP4_CENC)) { | |
2462 MockMediaSource source("bear-640x360-v_frag-cenc.mp4", kMP4Video, | |
2463 kAppendWholeFile); | |
2464 FakeEncryptedMedia encrypted_media(new KeyProvidingApp()); | |
2465 EXPECT_EQ(PIPELINE_OK, | |
2466 StartPipelineWithEncryptedMedia(&source, &encrypted_media)); | |
2467 | |
2468 scoped_refptr<DecoderBuffer> second_file = | |
2469 ReadTestDataFile("bear-1280x720-av_frag.mp4"); | |
2470 | |
2471 ASSERT_FALSE(source.AppendAtTime(base::TimeDelta::FromSeconds(kAppendTimeSec), | |
2472 second_file->data(), | |
2473 second_file->data_size())); | |
2474 | |
2475 source.EndOfStream(); | |
2476 | |
2477 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); | |
2478 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); | |
2479 // The second video was not added, so its time has not been added. | |
2480 EXPECT_EQ(k640IsoCencFileDurationMs, | |
2481 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); | |
2482 | |
2483 Play(); | |
2484 | |
2485 EXPECT_EQ(CHUNK_DEMUXER_ERROR_APPEND_FAILED, WaitUntilEndedOrError()); | |
2486 source.Shutdown(); | |
2487 } | |
2488 | |
2489 // Verify files which change configuration midstream fail gracefully. | |
2490 TEST_F(PipelineIntegrationTest, MidStreamConfigChangesFail) { | |
2491 ASSERT_EQ(PIPELINE_OK, Start("midstream_config_change.mp3")); | |
2492 Play(); | |
2493 ASSERT_EQ(WaitUntilEndedOrError(), PIPELINE_ERROR_DECODE); | |
2494 } | |
2495 #endif // BUILDFLAG(USE_PROPRIETARY_CODECS) | |
2496 | |
2497 TEST_F(PipelineIntegrationTest, MAYBE_EME(EncryptedPlayback_WebM)) { | |
2498 MockMediaSource source("bear-320x240-av_enc-av.webm", kWebM, 219816); | |
2499 FakeEncryptedMedia encrypted_media(new KeyProvidingApp()); | |
2500 EXPECT_EQ(PIPELINE_OK, | |
2501 StartPipelineWithEncryptedMedia(&source, &encrypted_media)); | |
2502 | |
2503 source.EndOfStream(); | |
2504 ASSERT_EQ(PIPELINE_OK, pipeline_status_); | |
2505 | |
2506 Play(); | |
2507 | |
2508 ASSERT_TRUE(WaitUntilOnEnded()); | |
2509 source.Shutdown(); | |
2510 Stop(); | |
2511 } | |
2512 | |
2513 TEST_F(PipelineIntegrationTest, MAYBE_EME(EncryptedPlayback_ClearStart_WebM)) { | |
2514 MockMediaSource source("bear-320x240-av_enc-av_clear-1s.webm", kWebM, | |
2515 kAppendWholeFile); | |
2516 FakeEncryptedMedia encrypted_media(new KeyProvidingApp()); | |
2517 EXPECT_EQ(PIPELINE_OK, | |
2518 StartPipelineWithEncryptedMedia(&source, &encrypted_media)); | |
2519 | |
2520 source.EndOfStream(); | |
2521 ASSERT_EQ(PIPELINE_OK, pipeline_status_); | |
2522 | |
2523 Play(); | |
2524 | |
2525 ASSERT_TRUE(WaitUntilOnEnded()); | |
2526 source.Shutdown(); | |
2527 Stop(); | |
2528 } | |
2529 | |
2530 TEST_F(PipelineIntegrationTest, | |
2531 MAYBE_EME(EncryptedPlayback_NoEncryptedFrames_WebM)) { | |
2532 MockMediaSource source("bear-320x240-av_enc-av_clear-all.webm", kWebM, | |
2533 kAppendWholeFile); | |
2534 FakeEncryptedMedia encrypted_media(new NoResponseApp()); | |
2535 EXPECT_EQ(PIPELINE_OK, | |
2536 StartPipelineWithEncryptedMedia(&source, &encrypted_media)); | |
2537 | |
2538 source.EndOfStream(); | |
2539 ASSERT_EQ(PIPELINE_OK, pipeline_status_); | |
2540 | |
2541 Play(); | |
2542 | |
2543 ASSERT_TRUE(WaitUntilOnEnded()); | |
2544 source.Shutdown(); | |
2545 Stop(); | |
2546 } | |
2547 | |
2548 #if BUILDFLAG(USE_PROPRIETARY_CODECS) | |
2549 TEST_F(PipelineIntegrationTest, | |
2550 MAYBE_EME(EncryptedPlayback_MP4_CENC_VideoOnly)) { | |
2551 MockMediaSource source("bear-1280x720-v_frag-cenc.mp4", kMP4Video, | |
2552 kAppendWholeFile); | |
2553 FakeEncryptedMedia encrypted_media(new KeyProvidingApp()); | |
2554 EXPECT_EQ(PIPELINE_OK, | |
2555 StartPipelineWithEncryptedMedia(&source, &encrypted_media)); | |
2556 | |
2557 source.EndOfStream(); | |
2558 ASSERT_EQ(PIPELINE_OK, pipeline_status_); | |
2559 | |
2560 Play(); | |
2561 | |
2562 ASSERT_TRUE(WaitUntilOnEnded()); | |
2563 source.Shutdown(); | |
2564 Stop(); | |
2565 } | |
2566 | |
2567 TEST_F(PipelineIntegrationTest, | |
2568 MAYBE_EME(EncryptedPlayback_MP4_CENC_AudioOnly)) { | |
2569 MockMediaSource source("bear-1280x720-a_frag-cenc.mp4", kMP4Audio, | |
2570 kAppendWholeFile); | |
2571 FakeEncryptedMedia encrypted_media(new KeyProvidingApp()); | |
2572 EXPECT_EQ(PIPELINE_OK, | |
2573 StartPipelineWithEncryptedMedia(&source, &encrypted_media)); | |
2574 | |
2575 source.EndOfStream(); | |
2576 ASSERT_EQ(PIPELINE_OK, pipeline_status_); | |
2577 | |
2578 Play(); | |
2579 | |
2580 ASSERT_TRUE(WaitUntilOnEnded()); | |
2581 source.Shutdown(); | |
2582 Stop(); | |
2583 } | |
2584 | |
2585 TEST_F(PipelineIntegrationTest, | |
2586 MAYBE_EME(EncryptedPlayback_NoEncryptedFrames_MP4_CENC_VideoOnly)) { | |
2587 MockMediaSource source("bear-1280x720-v_frag-cenc_clear-all.mp4", kMP4Video, | |
2588 kAppendWholeFile); | |
2589 FakeEncryptedMedia encrypted_media(new NoResponseApp()); | |
2590 EXPECT_EQ(PIPELINE_OK, | |
2591 StartPipelineWithEncryptedMedia(&source, &encrypted_media)); | |
2592 | |
2593 source.EndOfStream(); | |
2594 | |
2595 Play(); | |
2596 | |
2597 ASSERT_TRUE(WaitUntilOnEnded()); | |
2598 source.Shutdown(); | |
2599 Stop(); | |
2600 } | |
2601 | |
2602 TEST_F(PipelineIntegrationTest, | |
2603 MAYBE_EME(EncryptedPlayback_NoEncryptedFrames_MP4_CENC_AudioOnly)) { | |
2604 MockMediaSource source("bear-1280x720-a_frag-cenc_clear-all.mp4", kMP4Audio, | |
2605 kAppendWholeFile); | |
2606 FakeEncryptedMedia encrypted_media(new NoResponseApp()); | |
2607 EXPECT_EQ(PIPELINE_OK, | |
2608 StartPipelineWithEncryptedMedia(&source, &encrypted_media)); | |
2609 | |
2610 source.EndOfStream(); | |
2611 | |
2612 Play(); | |
2613 | |
2614 ASSERT_TRUE(WaitUntilOnEnded()); | |
2615 source.Shutdown(); | |
2616 Stop(); | |
2617 } | |
2618 | |
2619 TEST_F(PipelineIntegrationTest, | |
2620 MAYBE_EME(EncryptedPlayback_MP4_CENC_SENC_Video)) { | |
2621 MockMediaSource source("bear-640x360-v_frag-cenc-senc.mp4", kMP4Video, | |
2622 kAppendWholeFile); | |
2623 FakeEncryptedMedia encrypted_media(new KeyProvidingApp()); | |
2624 EXPECT_EQ(PIPELINE_OK, | |
2625 StartPipelineWithEncryptedMedia(&source, &encrypted_media)); | |
2626 | |
2627 source.EndOfStream(); | |
2628 | |
2629 Play(); | |
2630 | |
2631 ASSERT_TRUE(WaitUntilOnEnded()); | |
2632 source.Shutdown(); | |
2633 Stop(); | |
2634 } | |
2635 | |
2636 // 'SAIZ' and 'SAIO' boxes contain redundant information which is already | |
2637 // available in 'SENC' box. Although 'SAIZ' and 'SAIO' boxes are required per | |
2638 // CENC spec for backward compatibility reasons, but we do not use the two | |
2639 // boxes if 'SENC' box is present, so the code should work even if the two | |
2640 // boxes are not present. | |
2641 TEST_F(PipelineIntegrationTest, | |
2642 MAYBE_EME(EncryptedPlayback_MP4_CENC_SENC_NO_SAIZ_SAIO_Video)) { | |
2643 MockMediaSource source("bear-640x360-v_frag-cenc-senc-no-saiz-saio.mp4", | |
2644 kMP4Video, kAppendWholeFile); | |
2645 FakeEncryptedMedia encrypted_media(new KeyProvidingApp()); | |
2646 EXPECT_EQ(PIPELINE_OK, | |
2647 StartPipelineWithEncryptedMedia(&source, &encrypted_media)); | |
2648 | |
2649 source.EndOfStream(); | |
2650 | |
2651 Play(); | |
2652 | |
2653 ASSERT_TRUE(WaitUntilOnEnded()); | |
2654 source.Shutdown(); | |
2655 Stop(); | |
2656 } | |
2657 | |
2658 TEST_F(PipelineIntegrationTest, | |
2659 MAYBE_EME(EncryptedPlayback_MP4_CENC_KeyRotation_Video)) { | |
2660 MockMediaSource source("bear-1280x720-v_frag-cenc-key_rotation.mp4", | |
2661 kMP4Video, kAppendWholeFile); | |
2662 FakeEncryptedMedia encrypted_media(new RotatingKeyProvidingApp()); | |
2663 EXPECT_EQ(PIPELINE_OK, | |
2664 StartPipelineWithEncryptedMedia(&source, &encrypted_media)); | |
2665 | |
2666 source.EndOfStream(); | |
2667 | |
2668 Play(); | |
2669 | |
2670 ASSERT_TRUE(WaitUntilOnEnded()); | |
2671 source.Shutdown(); | |
2672 Stop(); | |
2673 } | |
2674 | |
2675 TEST_F(PipelineIntegrationTest, | |
2676 MAYBE_EME(EncryptedPlayback_MP4_CENC_KeyRotation_Audio)) { | |
2677 MockMediaSource source("bear-1280x720-a_frag-cenc-key_rotation.mp4", | |
2678 kMP4Audio, kAppendWholeFile); | |
2679 FakeEncryptedMedia encrypted_media(new RotatingKeyProvidingApp()); | |
2680 EXPECT_EQ(PIPELINE_OK, | |
2681 StartPipelineWithEncryptedMedia(&source, &encrypted_media)); | |
2682 | |
2683 source.EndOfStream(); | |
2684 | |
2685 Play(); | |
2686 | |
2687 ASSERT_TRUE(WaitUntilOnEnded()); | |
2688 source.Shutdown(); | |
2689 Stop(); | |
2690 } | |
2691 | |
2692 TEST_F(PipelineIntegrationTest, | |
2693 MAYBE_EME(EncryptedPlayback_MP4_VP9_CENC_VideoOnly)) { | |
2694 MockMediaSource source("bear-320x240-v_frag-vp9-cenc.mp4", kMP4VideoVP9, | |
2695 kAppendWholeFile); | |
2696 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( | |
2697 switches::kEnableVp9InMp4)) { | |
2698 ASSERT_EQ(ChunkDemuxer::kNotSupported, source.AddId()); | |
2699 return; | |
2700 } | |
2701 | |
2702 FakeEncryptedMedia encrypted_media(new KeyProvidingApp()); | |
2703 EXPECT_EQ(PIPELINE_OK, | |
2704 StartPipelineWithEncryptedMedia(&source, &encrypted_media)); | |
2705 | |
2706 source.EndOfStream(); | |
2707 | |
2708 Play(); | |
2709 | |
2710 ASSERT_TRUE(WaitUntilOnEnded()); | |
2711 source.Shutdown(); | |
2712 Stop(); | |
2713 } | |
2714 | |
2715 #endif // BUILDFLAG(USE_PROPRIETARY_CODECS) | |
2716 | |
2717 // Verify that VP8 video with inband text track can be played back. | |
2718 TEST_F(PipelineIntegrationTest, MAYBE_TEXT(BasicPlayback_VP8_WebVTT_WebM)) { | |
2719 EXPECT_CALL(*this, OnAddTextTrack(_, _)); | |
2720 ASSERT_EQ(PIPELINE_OK, Start("bear-vp8-webvtt.webm")); | |
2721 Play(); | |
2722 ASSERT_TRUE(WaitUntilOnEnded()); | |
2723 } | |
2724 | |
2725 // Ensures audio-video playback with missing or negative timestamps fails softly | |
2726 // instead of crashing. See http://crbug.com/396864. | |
2727 TEST_F(PipelineIntegrationTest, BasicPlaybackChainedOggVideo) { | |
2728 ASSERT_EQ(PIPELINE_OK, Start("double-bear.ogv", kUnreliableDuration)); | |
2729 Play(); | |
2730 EXPECT_EQ(PIPELINE_ERROR_DECODE, WaitUntilEndedOrError()); | |
2731 ASSERT_EQ(base::TimeDelta(), demuxer_->GetStartTime()); | |
2732 } | |
2733 | |
2653 } // namespace media | 2734 } // namespace media |
OLD | NEW |