| 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 TEST_P(CommonPipelineIntegrationTest, BasicPlaybackOpusOggTrimmingHashed) { |
| 1138 MAYBE_CLOCKLESS(BasicPlaybackOpusOggTrimmingHashed)) { | 1154 #if defined(DISABLE_CLOCKLESS_TESTS) |
| 1155 return; |
| 1156 #endif // defined(DISABLE_CLOCKLESS_TESTS) |
| 1157 |
| 1139 ASSERT_EQ(PIPELINE_OK, | 1158 ASSERT_EQ(PIPELINE_OK, |
| 1140 Start("opus-trimming-test.webm", kHashed | kClockless)); | 1159 Start("opus-trimming-test.webm", kHashed | kClockless)); |
| 1141 | 1160 |
| 1142 Play(); | 1161 Play(); |
| 1143 | 1162 |
| 1144 ASSERT_TRUE(WaitUntilOnEnded()); | 1163 ASSERT_TRUE(WaitUntilOnEnded()); |
| 1145 EXPECT_HASH_EQ(kOpusEndTrimmingHash_1, GetAudioHash()); | 1164 EXPECT_HASH_EQ(kOpusEndTrimmingHash_1, GetAudioHash()); |
| 1146 | 1165 |
| 1147 // Seek within the pre-skip section, this should not cause a beep. | 1166 // Seek within the pre-skip section, this should not cause a beep. |
| 1148 ASSERT_TRUE(Seek(base::TimeDelta::FromSeconds(1))); | 1167 ASSERT_TRUE(Seek(base::TimeDelta::FromSeconds(1))); |
| 1149 Play(); | 1168 Play(); |
| 1150 ASSERT_TRUE(WaitUntilOnEnded()); | 1169 ASSERT_TRUE(WaitUntilOnEnded()); |
| 1151 EXPECT_HASH_EQ(kOpusEndTrimmingHash_2, GetAudioHash()); | 1170 EXPECT_HASH_EQ(kOpusEndTrimmingHash_2, GetAudioHash()); |
| 1152 | 1171 |
| 1153 // Seek somewhere outside of the pre-skip / end-trim section, demxuer should | 1172 // Seek somewhere outside of the pre-skip / end-trim section, demxuer should |
| 1154 // correctly preroll enough to accurately decode this segment. | 1173 // correctly preroll enough to accurately decode this segment. |
| 1155 ASSERT_TRUE(Seek(base::TimeDelta::FromMilliseconds(6360))); | 1174 ASSERT_TRUE(Seek(base::TimeDelta::FromMilliseconds(6360))); |
| 1156 Play(); | 1175 Play(); |
| 1157 ASSERT_TRUE(WaitUntilOnEnded()); | 1176 ASSERT_TRUE(WaitUntilOnEnded()); |
| 1158 EXPECT_HASH_EQ(kOpusEndTrimmingHash_3, GetAudioHash()); | 1177 EXPECT_HASH_EQ(kOpusEndTrimmingHash_3, GetAudioHash()); |
| 1159 } | 1178 } |
| 1160 | 1179 |
| 1161 TEST_F(PipelineIntegrationTest, | 1180 TEST_P(CommonPipelineIntegrationTest, BasicPlaybackOpusWebmTrimmingHashed) { |
| 1162 MAYBE_CLOCKLESS(BasicPlaybackOpusWebmTrimmingHashed)) { | 1181 #if defined(DISABLE_CLOCKLESS_TESTS) |
| 1182 return; |
| 1183 #endif // defined(DISABLE_CLOCKLESS_TESTS) |
| 1184 |
| 1163 ASSERT_EQ(PIPELINE_OK, | 1185 ASSERT_EQ(PIPELINE_OK, |
| 1164 Start("opus-trimming-test.webm", kHashed | kClockless)); | 1186 Start("opus-trimming-test.webm", kHashed | kClockless)); |
| 1165 | 1187 |
| 1166 Play(); | 1188 Play(); |
| 1167 | 1189 |
| 1168 ASSERT_TRUE(WaitUntilOnEnded()); | 1190 ASSERT_TRUE(WaitUntilOnEnded()); |
| 1169 EXPECT_HASH_EQ(kOpusEndTrimmingHash_1, GetAudioHash()); | 1191 EXPECT_HASH_EQ(kOpusEndTrimmingHash_1, GetAudioHash()); |
| 1170 | 1192 |
| 1171 // Seek within the pre-skip section, this should not cause a beep. | 1193 // Seek within the pre-skip section, this should not cause a beep. |
| 1172 ASSERT_TRUE(Seek(base::TimeDelta::FromSeconds(1))); | 1194 ASSERT_TRUE(Seek(base::TimeDelta::FromSeconds(1))); |
| 1173 Play(); | 1195 Play(); |
| 1174 ASSERT_TRUE(WaitUntilOnEnded()); | 1196 ASSERT_TRUE(WaitUntilOnEnded()); |
| 1175 EXPECT_HASH_EQ(kOpusEndTrimmingHash_2, GetAudioHash()); | 1197 EXPECT_HASH_EQ(kOpusEndTrimmingHash_2, GetAudioHash()); |
| 1176 | 1198 |
| 1177 // Seek somewhere outside of the pre-skip / end-trim section, demxuer should | 1199 // Seek somewhere outside of the pre-skip / end-trim section, demxuer should |
| 1178 // correctly preroll enough to accurately decode this segment. | 1200 // correctly preroll enough to accurately decode this segment. |
| 1179 ASSERT_TRUE(Seek(base::TimeDelta::FromMilliseconds(6360))); | 1201 ASSERT_TRUE(Seek(base::TimeDelta::FromMilliseconds(6360))); |
| 1180 Play(); | 1202 Play(); |
| 1181 ASSERT_TRUE(WaitUntilOnEnded()); | 1203 ASSERT_TRUE(WaitUntilOnEnded()); |
| 1182 EXPECT_HASH_EQ(kOpusEndTrimmingHash_3, GetAudioHash()); | 1204 EXPECT_HASH_EQ(kOpusEndTrimmingHash_3, GetAudioHash()); |
| 1183 } | 1205 } |
| 1184 | 1206 |
| 1185 TEST_F(PipelineIntegrationTest, | 1207 TEST_P(CommonPipelineIntegrationTest, |
| 1186 MAYBE_CLOCKLESS(BasicPlaybackOpusWebmTrimmingHashed_MediaSource)) { | 1208 BasicPlaybackOpusWebmTrimmingHashed_MediaSource) { |
| 1209 #if defined(DISABLE_CLOCKLESS_TESTS) |
| 1210 return; |
| 1211 #endif // defined(DISABLE_CLOCKLESS_TESTS) |
| 1212 |
| 1187 MockMediaSource source("opus-trimming-test.webm", kOpusAudioOnlyWebM, | 1213 MockMediaSource source("opus-trimming-test.webm", kOpusAudioOnlyWebM, |
| 1188 kAppendWholeFile); | 1214 kAppendWholeFile); |
| 1189 EXPECT_EQ(PIPELINE_OK, StartPipelineWithMediaSource( | 1215 EXPECT_EQ(PIPELINE_OK, StartPipelineWithMediaSource( |
| 1190 &source, kClockless | kHashed, nullptr)); | 1216 &source, kClockless | kHashed, nullptr)); |
| 1191 source.EndOfStream(); | 1217 source.EndOfStream(); |
| 1192 | 1218 |
| 1193 Play(); | 1219 Play(); |
| 1194 | 1220 |
| 1195 ASSERT_TRUE(WaitUntilOnEnded()); | 1221 ASSERT_TRUE(WaitUntilOnEnded()); |
| 1196 EXPECT_HASH_EQ(kOpusEndTrimmingHash_1, GetAudioHash()); | 1222 EXPECT_HASH_EQ(kOpusEndTrimmingHash_1, GetAudioHash()); |
| 1197 | 1223 |
| 1198 // Seek within the pre-skip section, this should not cause a beep. | 1224 // Seek within the pre-skip section, this should not cause a beep. |
| 1199 base::TimeDelta seek_time = base::TimeDelta::FromSeconds(1); | 1225 base::TimeDelta seek_time = base::TimeDelta::FromSeconds(1); |
| 1200 source.Seek(seek_time); | 1226 source.Seek(seek_time); |
| 1201 ASSERT_TRUE(Seek(seek_time)); | 1227 ASSERT_TRUE(Seek(seek_time)); |
| 1202 Play(); | 1228 Play(); |
| 1203 ASSERT_TRUE(WaitUntilOnEnded()); | 1229 ASSERT_TRUE(WaitUntilOnEnded()); |
| 1204 EXPECT_HASH_EQ(kOpusEndTrimmingHash_2, GetAudioHash()); | 1230 EXPECT_HASH_EQ(kOpusEndTrimmingHash_2, GetAudioHash()); |
| 1205 | 1231 |
| 1206 // Seek somewhere outside of the pre-skip / end-trim section, demuxer should | 1232 // Seek somewhere outside of the pre-skip / end-trim section, demuxer should |
| 1207 // correctly preroll enough to accurately decode this segment. | 1233 // correctly preroll enough to accurately decode this segment. |
| 1208 seek_time = base::TimeDelta::FromMilliseconds(6360); | 1234 seek_time = base::TimeDelta::FromMilliseconds(6360); |
| 1209 source.Seek(seek_time); | 1235 source.Seek(seek_time); |
| 1210 ASSERT_TRUE(Seek(seek_time)); | 1236 ASSERT_TRUE(Seek(seek_time)); |
| 1211 Play(); | 1237 Play(); |
| 1212 ASSERT_TRUE(WaitUntilOnEnded()); | 1238 ASSERT_TRUE(WaitUntilOnEnded()); |
| 1213 EXPECT_HASH_EQ(kOpusEndTrimmingHash_3, GetAudioHash()); | 1239 EXPECT_HASH_EQ(kOpusEndTrimmingHash_3, GetAudioHash()); |
| 1214 } | 1240 } |
| 1215 | 1241 |
| 1216 TEST_F(PipelineIntegrationTest, | 1242 TEST_P(CommonPipelineIntegrationTest, |
| 1217 MAYBE_CLOCKLESS(BasicPlaybackOpusPrerollExceedsCodecDelay)) { | 1243 BasicPlaybackOpusPrerollExceedsCodecDelay) { |
| 1244 #if defined(DISABLE_CLOCKLESS_TESTS) |
| 1245 return; |
| 1246 #endif // defined(DISABLE_CLOCKLESS_TESTS) |
| 1247 |
| 1218 ASSERT_EQ(PIPELINE_OK, Start("bear-opus.webm", kHashed | kClockless)); | 1248 ASSERT_EQ(PIPELINE_OK, Start("bear-opus.webm", kHashed | kClockless)); |
| 1219 | 1249 |
| 1220 AudioDecoderConfig config = | 1250 AudioDecoderConfig config = |
| 1221 demuxer_->GetFirstStream(DemuxerStream::AUDIO)->audio_decoder_config(); | 1251 demuxer_->GetFirstStream(DemuxerStream::AUDIO)->audio_decoder_config(); |
| 1222 | 1252 |
| 1223 // Verify that this file's preroll is not eclipsed by the codec delay so we | 1253 // Verify that this file's preroll is not eclipsed by the codec delay so we |
| 1224 // can detect when preroll is not properly performed. | 1254 // can detect when preroll is not properly performed. |
| 1225 base::TimeDelta codec_delay = base::TimeDelta::FromSecondsD( | 1255 base::TimeDelta codec_delay = base::TimeDelta::FromSecondsD( |
| 1226 static_cast<double>(config.codec_delay()) / config.samples_per_second()); | 1256 static_cast<double>(config.codec_delay()) / config.samples_per_second()); |
| 1227 ASSERT_GT(config.seek_preroll(), codec_delay); | 1257 ASSERT_GT(config.seek_preroll(), codec_delay); |
| 1228 | 1258 |
| 1229 Play(); | 1259 Play(); |
| 1230 ASSERT_TRUE(WaitUntilOnEnded()); | 1260 ASSERT_TRUE(WaitUntilOnEnded()); |
| 1231 EXPECT_HASH_EQ(kOpusSmallCodecDelayHash_1, GetAudioHash()); | 1261 EXPECT_HASH_EQ(kOpusSmallCodecDelayHash_1, GetAudioHash()); |
| 1232 | 1262 |
| 1233 // Seek halfway through the file to invoke seek preroll. | 1263 // Seek halfway through the file to invoke seek preroll. |
| 1234 ASSERT_TRUE(Seek(base::TimeDelta::FromSecondsD(1.414))); | 1264 ASSERT_TRUE(Seek(base::TimeDelta::FromSecondsD(1.414))); |
| 1235 Play(); | 1265 Play(); |
| 1236 ASSERT_TRUE(WaitUntilOnEnded()); | 1266 ASSERT_TRUE(WaitUntilOnEnded()); |
| 1237 EXPECT_HASH_EQ(kOpusSmallCodecDelayHash_2, GetAudioHash()); | 1267 EXPECT_HASH_EQ(kOpusSmallCodecDelayHash_2, GetAudioHash()); |
| 1238 } | 1268 } |
| 1239 | 1269 |
| 1240 TEST_F(PipelineIntegrationTest, | 1270 TEST_P(CommonPipelineIntegrationTest, |
| 1241 MAYBE_CLOCKLESS(BasicPlaybackOpusPrerollExceedsCodecDelay_MediaSource)) { | 1271 BasicPlaybackOpusPrerollExceedsCodecDelay_MediaSource) { |
| 1272 #if defined(DISABLE_CLOCKLESS_TESTS) |
| 1273 return; |
| 1274 #endif // defined(DISABLE_CLOCKLESS_TESTS) |
| 1275 |
| 1242 MockMediaSource source("bear-opus.webm", kOpusAudioOnlyWebM, | 1276 MockMediaSource source("bear-opus.webm", kOpusAudioOnlyWebM, |
| 1243 kAppendWholeFile); | 1277 kAppendWholeFile); |
| 1244 EXPECT_EQ(PIPELINE_OK, StartPipelineWithMediaSource( | 1278 EXPECT_EQ(PIPELINE_OK, StartPipelineWithMediaSource( |
| 1245 &source, kClockless | kHashed, nullptr)); | 1279 &source, kClockless | kHashed, nullptr)); |
| 1246 source.EndOfStream(); | 1280 source.EndOfStream(); |
| 1247 | 1281 |
| 1248 AudioDecoderConfig config = | 1282 AudioDecoderConfig config = |
| 1249 demuxer_->GetFirstStream(DemuxerStream::AUDIO)->audio_decoder_config(); | 1283 demuxer_->GetFirstStream(DemuxerStream::AUDIO)->audio_decoder_config(); |
| 1250 | 1284 |
| 1251 // Verify that this file's preroll is not eclipsed by the codec delay so we | 1285 // Verify that this file's preroll is not eclipsed by the codec delay so we |
| 1252 // can detect when preroll is not properly performed. | 1286 // can detect when preroll is not properly performed. |
| 1253 base::TimeDelta codec_delay = base::TimeDelta::FromSecondsD( | 1287 base::TimeDelta codec_delay = base::TimeDelta::FromSecondsD( |
| 1254 static_cast<double>(config.codec_delay()) / config.samples_per_second()); | 1288 static_cast<double>(config.codec_delay()) / config.samples_per_second()); |
| 1255 ASSERT_GT(config.seek_preroll(), codec_delay); | 1289 ASSERT_GT(config.seek_preroll(), codec_delay); |
| 1256 | 1290 |
| 1257 Play(); | 1291 Play(); |
| 1258 ASSERT_TRUE(WaitUntilOnEnded()); | 1292 ASSERT_TRUE(WaitUntilOnEnded()); |
| 1259 EXPECT_HASH_EQ(kOpusSmallCodecDelayHash_1, GetAudioHash()); | 1293 EXPECT_HASH_EQ(kOpusSmallCodecDelayHash_1, GetAudioHash()); |
| 1260 | 1294 |
| 1261 // Seek halfway through the file to invoke seek preroll. | 1295 // Seek halfway through the file to invoke seek preroll. |
| 1262 base::TimeDelta seek_time = base::TimeDelta::FromSecondsD(1.414); | 1296 base::TimeDelta seek_time = base::TimeDelta::FromSecondsD(1.414); |
| 1263 source.Seek(seek_time); | 1297 source.Seek(seek_time); |
| 1264 ASSERT_TRUE(Seek(seek_time)); | 1298 ASSERT_TRUE(Seek(seek_time)); |
| 1265 Play(); | 1299 Play(); |
| 1266 ASSERT_TRUE(WaitUntilOnEnded()); | 1300 ASSERT_TRUE(WaitUntilOnEnded()); |
| 1267 EXPECT_HASH_EQ(kOpusSmallCodecDelayHash_2, GetAudioHash()); | 1301 EXPECT_HASH_EQ(kOpusSmallCodecDelayHash_2, GetAudioHash()); |
| 1268 } | 1302 } |
| 1269 | 1303 |
| 1270 TEST_F(PipelineIntegrationTest, BasicPlaybackLive) { | 1304 TEST_P(CommonPipelineIntegrationTest, BasicPlaybackLive) { |
| 1271 ASSERT_EQ(PIPELINE_OK, Start("bear-320x240-live.webm", kHashed)); | 1305 ASSERT_EQ(PIPELINE_OK, Start("bear-320x240-live.webm", kHashed)); |
| 1272 | 1306 |
| 1273 // Live stream does not have duration in the initialization segment. | 1307 // Live stream does not have duration in the initialization segment. |
| 1274 // It will be set after the entire file is available. | 1308 // It will be set after the entire file is available. |
| 1275 EXPECT_CALL(*this, OnDurationChange()).Times(1); | 1309 EXPECT_CALL(*this, OnDurationChange()).Times(1); |
| 1276 | 1310 |
| 1277 Play(); | 1311 Play(); |
| 1278 | 1312 |
| 1279 ASSERT_TRUE(WaitUntilOnEnded()); | 1313 ASSERT_TRUE(WaitUntilOnEnded()); |
| 1280 | 1314 |
| 1281 EXPECT_HASH_EQ("f0be120a90a811506777c99a2cdf7cc1", GetVideoHash()); | 1315 EXPECT_HASH_EQ("f0be120a90a811506777c99a2cdf7cc1", GetVideoHash()); |
| 1282 EXPECT_HASH_EQ("-3.59,-2.06,-0.43,2.15,0.77,-0.95,", GetAudioHash()); | 1316 EXPECT_HASH_EQ("-3.59,-2.06,-0.43,2.15,0.77,-0.95,", GetAudioHash()); |
| 1283 EXPECT_EQ(kLiveTimelineOffset(), demuxer_->GetTimelineOffset()); | 1317 EXPECT_EQ(kLiveTimelineOffset(), demuxer_->GetTimelineOffset()); |
| 1284 } | 1318 } |
| 1285 | 1319 |
| 1286 TEST_F(PipelineIntegrationTest, S32PlaybackHashed) { | 1320 TEST_P(CommonPipelineIntegrationTest, S32PlaybackHashed) { |
| 1287 ASSERT_EQ(PIPELINE_OK, Start("sfx_s32le.wav", kHashed)); | 1321 ASSERT_EQ(PIPELINE_OK, Start("sfx_s32le.wav", kHashed)); |
| 1288 Play(); | 1322 Play(); |
| 1289 ASSERT_TRUE(WaitUntilOnEnded()); | 1323 ASSERT_TRUE(WaitUntilOnEnded()); |
| 1290 EXPECT_HASH_EQ(std::string(kNullVideoHash), GetVideoHash()); | 1324 EXPECT_HASH_EQ(std::string(kNullVideoHash), GetVideoHash()); |
| 1291 EXPECT_HASH_EQ("3.03,2.86,2.99,3.31,3.57,4.06,", GetAudioHash()); | 1325 EXPECT_HASH_EQ("3.03,2.86,2.99,3.31,3.57,4.06,", GetAudioHash()); |
| 1292 } | 1326 } |
| 1293 | 1327 |
| 1294 TEST_F(PipelineIntegrationTest, F32PlaybackHashed) { | 1328 TEST_P(CommonPipelineIntegrationTest, F32PlaybackHashed) { |
| 1295 ASSERT_EQ(PIPELINE_OK, Start("sfx_f32le.wav", kHashed)); | 1329 ASSERT_EQ(PIPELINE_OK, Start("sfx_f32le.wav", kHashed)); |
| 1296 Play(); | 1330 Play(); |
| 1297 ASSERT_TRUE(WaitUntilOnEnded()); | 1331 ASSERT_TRUE(WaitUntilOnEnded()); |
| 1298 EXPECT_HASH_EQ(std::string(kNullVideoHash), GetVideoHash()); | 1332 EXPECT_HASH_EQ(std::string(kNullVideoHash), GetVideoHash()); |
| 1299 EXPECT_HASH_EQ("3.03,2.86,2.99,3.31,3.57,4.06,", GetAudioHash()); | 1333 EXPECT_HASH_EQ("3.03,2.86,2.99,3.31,3.57,4.06,", GetAudioHash()); |
| 1300 } | 1334 } |
| 1301 | 1335 |
| 1302 TEST_F(PipelineIntegrationTest, MAYBE_EME(BasicPlaybackEncrypted)) { | 1336 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)); | 1337 ASSERT_EQ(PIPELINE_OK, Start("sfx.flac", kHashed)); |
| 1319 Play(); | 1338 Play(); |
| 1320 ASSERT_TRUE(WaitUntilOnEnded()); | 1339 ASSERT_TRUE(WaitUntilOnEnded()); |
| 1321 EXPECT_HASH_EQ(std::string(kNullVideoHash), GetVideoHash()); | 1340 EXPECT_HASH_EQ(std::string(kNullVideoHash), GetVideoHash()); |
| 1322 EXPECT_HASH_EQ("3.03,2.86,2.99,3.31,3.57,4.06,", GetAudioHash()); | 1341 EXPECT_HASH_EQ("3.03,2.86,2.99,3.31,3.57,4.06,", GetAudioHash()); |
| 1323 } | 1342 } |
| 1324 | 1343 |
| 1325 TEST_F(PipelineIntegrationTest, BasicPlayback_MediaSource) { | 1344 TEST_P(CommonPipelineIntegrationTest, BasicPlayback_MediaSource) { |
| 1326 MockMediaSource source("bear-320x240.webm", kWebM, 219229); | 1345 MockMediaSource source("bear-320x240.webm", kWebM, 219229); |
| 1327 EXPECT_EQ(PIPELINE_OK, StartPipelineWithMediaSource(&source)); | 1346 EXPECT_EQ(PIPELINE_OK, StartPipelineWithMediaSource(&source)); |
| 1328 source.EndOfStream(); | 1347 source.EndOfStream(); |
| 1329 | 1348 |
| 1330 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); | 1349 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); |
| 1331 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); | 1350 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); |
| 1332 EXPECT_EQ(k320WebMFileDurationMs, | 1351 EXPECT_EQ(k320WebMFileDurationMs, |
| 1333 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); | 1352 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); |
| 1334 | 1353 |
| 1335 Play(); | 1354 Play(); |
| 1336 | 1355 |
| 1337 ASSERT_TRUE(WaitUntilOnEnded()); | 1356 ASSERT_TRUE(WaitUntilOnEnded()); |
| 1338 | 1357 |
| 1339 EXPECT_TRUE(demuxer_->GetTimelineOffset().is_null()); | 1358 EXPECT_TRUE(demuxer_->GetTimelineOffset().is_null()); |
| 1340 source.Shutdown(); | 1359 source.Shutdown(); |
| 1341 Stop(); | 1360 Stop(); |
| 1342 } | 1361 } |
| 1343 | 1362 |
| 1344 TEST_F(PipelineIntegrationTest, BasicPlayback_MediaSource_Live) { | 1363 TEST_P(CommonPipelineIntegrationTest, BasicPlayback_MediaSource_Live) { |
| 1345 MockMediaSource source("bear-320x240-live.webm", kWebM, 219221); | 1364 MockMediaSource source("bear-320x240-live.webm", kWebM, 219221); |
| 1346 EXPECT_EQ(PIPELINE_OK, StartPipelineWithMediaSource(&source)); | 1365 EXPECT_EQ(PIPELINE_OK, StartPipelineWithMediaSource(&source)); |
| 1347 source.EndOfStream(); | 1366 source.EndOfStream(); |
| 1348 | 1367 |
| 1349 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); | 1368 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); |
| 1350 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); | 1369 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); |
| 1351 EXPECT_EQ(k320WebMFileDurationMs, | 1370 EXPECT_EQ(k320WebMFileDurationMs, |
| 1352 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); | 1371 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); |
| 1353 | 1372 |
| 1354 Play(); | 1373 Play(); |
| 1355 | 1374 |
| 1356 ASSERT_TRUE(WaitUntilOnEnded()); | 1375 ASSERT_TRUE(WaitUntilOnEnded()); |
| 1357 | 1376 |
| 1358 EXPECT_EQ(kLiveTimelineOffset(), demuxer_->GetTimelineOffset()); | 1377 EXPECT_EQ(kLiveTimelineOffset(), demuxer_->GetTimelineOffset()); |
| 1359 source.Shutdown(); | 1378 source.Shutdown(); |
| 1360 Stop(); | 1379 Stop(); |
| 1361 } | 1380 } |
| 1362 | 1381 |
| 1363 TEST_F(PipelineIntegrationTest, BasicPlayback_MediaSource_VP9_WebM) { | 1382 TEST_P(CommonPipelineIntegrationTest, BasicPlayback_MediaSource_VP9_WebM) { |
| 1364 MockMediaSource source("bear-vp9.webm", kWebMVP9, 67504); | 1383 MockMediaSource source("bear-vp9.webm", kWebMVP9, 67504); |
| 1365 EXPECT_EQ(PIPELINE_OK, StartPipelineWithMediaSource(&source)); | 1384 EXPECT_EQ(PIPELINE_OK, StartPipelineWithMediaSource(&source)); |
| 1366 source.EndOfStream(); | 1385 source.EndOfStream(); |
| 1367 | 1386 |
| 1368 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); | 1387 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); |
| 1369 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); | 1388 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); |
| 1370 EXPECT_EQ(kVP9WebMFileDurationMs, | 1389 EXPECT_EQ(kVP9WebMFileDurationMs, |
| 1371 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); | 1390 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); |
| 1372 | 1391 |
| 1373 Play(); | 1392 Play(); |
| 1374 | 1393 |
| 1375 ASSERT_TRUE(WaitUntilOnEnded()); | 1394 ASSERT_TRUE(WaitUntilOnEnded()); |
| 1376 source.Shutdown(); | 1395 source.Shutdown(); |
| 1377 Stop(); | 1396 Stop(); |
| 1378 } | 1397 } |
| 1379 | 1398 |
| 1380 TEST_F(PipelineIntegrationTest, BasicPlayback_MediaSource_VP9_BlockGroup_WebM) { | 1399 TEST_P(CommonPipelineIntegrationTest, |
| 1400 BasicPlayback_MediaSource_VP9_BlockGroup_WebM) { |
| 1381 MockMediaSource source("bear-vp9-blockgroup.webm", kWebMVP9, 67871); | 1401 MockMediaSource source("bear-vp9-blockgroup.webm", kWebMVP9, 67871); |
| 1382 EXPECT_EQ(PIPELINE_OK, StartPipelineWithMediaSource(&source)); | 1402 EXPECT_EQ(PIPELINE_OK, StartPipelineWithMediaSource(&source)); |
| 1383 source.EndOfStream(); | 1403 source.EndOfStream(); |
| 1384 | 1404 |
| 1385 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); | 1405 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); |
| 1386 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); | 1406 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); |
| 1387 EXPECT_EQ(kVP9WebMFileDurationMs, | 1407 EXPECT_EQ(kVP9WebMFileDurationMs, |
| 1388 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); | 1408 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); |
| 1389 | 1409 |
| 1390 Play(); | 1410 Play(); |
| 1391 | 1411 |
| 1392 ASSERT_TRUE(WaitUntilOnEnded()); | 1412 ASSERT_TRUE(WaitUntilOnEnded()); |
| 1393 source.Shutdown(); | 1413 source.Shutdown(); |
| 1394 Stop(); | 1414 Stop(); |
| 1395 } | 1415 } |
| 1396 | 1416 |
| 1397 TEST_F(PipelineIntegrationTest, BasicPlayback_MediaSource_VP8A_WebM) { | 1417 TEST_P(CommonPipelineIntegrationTest, BasicPlayback_MediaSource_VP8A_WebM) { |
| 1398 MockMediaSource source("bear-vp8a.webm", kVideoOnlyWebM, kAppendWholeFile); | 1418 MockMediaSource source("bear-vp8a.webm", kVideoOnlyWebM, kAppendWholeFile); |
| 1399 EXPECT_EQ(PIPELINE_OK, StartPipelineWithMediaSource(&source)); | 1419 EXPECT_EQ(PIPELINE_OK, StartPipelineWithMediaSource(&source)); |
| 1400 source.EndOfStream(); | 1420 source.EndOfStream(); |
| 1401 | 1421 |
| 1402 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); | 1422 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); |
| 1403 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); | 1423 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); |
| 1404 EXPECT_EQ(kVP8AWebMFileDurationMs, | 1424 EXPECT_EQ(kVP8AWebMFileDurationMs, |
| 1405 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); | 1425 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); |
| 1406 | 1426 |
| 1407 Play(); | 1427 Play(); |
| 1408 | 1428 |
| 1409 ASSERT_TRUE(WaitUntilOnEnded()); | 1429 ASSERT_TRUE(WaitUntilOnEnded()); |
| 1410 source.Shutdown(); | 1430 source.Shutdown(); |
| 1411 Stop(); | 1431 Stop(); |
| 1412 } | 1432 } |
| 1413 | 1433 |
| 1414 TEST_F(PipelineIntegrationTest, BasicPlayback_MediaSource_Opus_WebM) { | 1434 TEST_P(CommonPipelineIntegrationTest, BasicPlayback_MediaSource_Opus_WebM) { |
| 1415 MockMediaSource source("bear-opus-end-trimming.webm", kOpusAudioOnlyWebM, | 1435 MockMediaSource source("bear-opus-end-trimming.webm", kOpusAudioOnlyWebM, |
| 1416 kAppendWholeFile); | 1436 kAppendWholeFile); |
| 1417 EXPECT_EQ(PIPELINE_OK, StartPipelineWithMediaSource(&source)); | 1437 EXPECT_EQ(PIPELINE_OK, StartPipelineWithMediaSource(&source)); |
| 1418 source.EndOfStream(); | 1438 source.EndOfStream(); |
| 1419 | 1439 |
| 1420 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); | 1440 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); |
| 1421 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); | 1441 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); |
| 1422 EXPECT_EQ(kOpusEndTrimmingWebMFileDurationMs, | 1442 EXPECT_EQ(kOpusEndTrimmingWebMFileDurationMs, |
| 1423 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); | 1443 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); |
| 1424 Play(); | 1444 Play(); |
| 1425 | 1445 |
| 1426 ASSERT_TRUE(WaitUntilOnEnded()); | 1446 ASSERT_TRUE(WaitUntilOnEnded()); |
| 1427 source.Shutdown(); | 1447 source.Shutdown(); |
| 1428 Stop(); | 1448 Stop(); |
| 1429 } | 1449 } |
| 1430 | 1450 |
| 1431 // Flaky. http://crbug.com/304776 | 1451 // Flaky. http://crbug.com/304776 |
| 1432 TEST_F(PipelineIntegrationTest, DISABLED_MediaSource_Opus_Seeking_WebM) { | 1452 TEST_P(CommonPipelineIntegrationTest, DISABLED_MediaSource_Opus_Seeking_WebM) { |
| 1433 MockMediaSource source("bear-opus-end-trimming.webm", kOpusAudioOnlyWebM, | 1453 MockMediaSource source("bear-opus-end-trimming.webm", kOpusAudioOnlyWebM, |
| 1434 kAppendWholeFile); | 1454 kAppendWholeFile); |
| 1435 EXPECT_EQ(PIPELINE_OK, | 1455 EXPECT_EQ(PIPELINE_OK, |
| 1436 StartPipelineWithMediaSource(&source, kHashed, nullptr)); | 1456 StartPipelineWithMediaSource(&source, kHashed, nullptr)); |
| 1437 | 1457 |
| 1438 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); | 1458 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); |
| 1439 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); | 1459 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); |
| 1440 EXPECT_EQ(kOpusEndTrimmingWebMFileDurationMs, | 1460 EXPECT_EQ(kOpusEndTrimmingWebMFileDurationMs, |
| 1441 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); | 1461 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); |
| 1442 | 1462 |
| 1443 base::TimeDelta start_seek_time = base::TimeDelta::FromMilliseconds(1000); | 1463 base::TimeDelta start_seek_time = base::TimeDelta::FromMilliseconds(1000); |
| 1444 base::TimeDelta seek_time = base::TimeDelta::FromMilliseconds(2000); | 1464 base::TimeDelta seek_time = base::TimeDelta::FromMilliseconds(2000); |
| 1445 | 1465 |
| 1446 Play(); | 1466 Play(); |
| 1447 ASSERT_TRUE(WaitUntilCurrentTimeIsAfter(start_seek_time)); | 1467 ASSERT_TRUE(WaitUntilCurrentTimeIsAfter(start_seek_time)); |
| 1448 source.Seek(seek_time, 0x1D5, 34017); | 1468 source.Seek(seek_time, 0x1D5, 34017); |
| 1449 source.EndOfStream(); | 1469 source.EndOfStream(); |
| 1450 ASSERT_TRUE(Seek(seek_time)); | 1470 ASSERT_TRUE(Seek(seek_time)); |
| 1451 | 1471 |
| 1452 ASSERT_TRUE(WaitUntilOnEnded()); | 1472 ASSERT_TRUE(WaitUntilOnEnded()); |
| 1453 | 1473 |
| 1454 EXPECT_HASH_EQ("0.76,0.20,-0.82,-0.58,-1.29,-0.29,", GetAudioHash()); | 1474 EXPECT_HASH_EQ("0.76,0.20,-0.82,-0.58,-1.29,-0.29,", GetAudioHash()); |
| 1455 | 1475 |
| 1456 source.Shutdown(); | 1476 source.Shutdown(); |
| 1457 Stop(); | 1477 Stop(); |
| 1458 } | 1478 } |
| 1459 | 1479 |
| 1460 TEST_F(PipelineIntegrationTest, MediaSource_ConfigChange_WebM) { | 1480 TEST_P(CommonPipelineIntegrationTest, MediaSource_ConfigChange_WebM) { |
| 1461 MockMediaSource source("bear-320x240-16x9-aspect.webm", kWebM, | 1481 MockMediaSource source("bear-320x240-16x9-aspect.webm", kWebM, |
| 1462 kAppendWholeFile); | 1482 kAppendWholeFile); |
| 1463 EXPECT_EQ(PIPELINE_OK, StartPipelineWithMediaSource(&source)); | 1483 EXPECT_EQ(PIPELINE_OK, StartPipelineWithMediaSource(&source)); |
| 1464 | 1484 |
| 1465 EXPECT_CALL(*this, OnVideoNaturalSizeChange(gfx::Size(640, 360))).Times(1); | 1485 EXPECT_CALL(*this, OnVideoNaturalSizeChange(gfx::Size(640, 360))).Times(1); |
| 1466 scoped_refptr<DecoderBuffer> second_file = | 1486 scoped_refptr<DecoderBuffer> second_file = |
| 1467 ReadTestDataFile("bear-640x360.webm"); | 1487 ReadTestDataFile("bear-640x360.webm"); |
| 1468 ASSERT_TRUE(source.AppendAtTime(base::TimeDelta::FromSeconds(kAppendTimeSec), | 1488 ASSERT_TRUE(source.AppendAtTime(base::TimeDelta::FromSeconds(kAppendTimeSec), |
| 1469 second_file->data(), | 1489 second_file->data(), |
| 1470 second_file->data_size())); | 1490 second_file->data_size())); |
| 1471 source.EndOfStream(); | 1491 source.EndOfStream(); |
| 1472 | 1492 |
| 1473 Play(); | 1493 Play(); |
| 1474 EXPECT_TRUE(WaitUntilOnEnded()); | 1494 EXPECT_TRUE(WaitUntilOnEnded()); |
| 1475 | 1495 |
| 1476 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); | 1496 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); |
| 1477 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); | 1497 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); |
| 1478 EXPECT_EQ(kAppendTimeMs + k640WebMFileDurationMs, | 1498 EXPECT_EQ(kAppendTimeMs + k640WebMFileDurationMs, |
| 1479 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); | 1499 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); |
| 1480 | 1500 |
| 1481 source.Shutdown(); | 1501 source.Shutdown(); |
| 1482 Stop(); | 1502 Stop(); |
| 1483 } | 1503 } |
| 1484 | 1504 |
| 1485 TEST_F(PipelineIntegrationTest, MediaSource_Remove_Updates_BufferedRanges) { | 1505 TEST_P(CommonPipelineIntegrationTest, |
| 1506 MediaSource_Remove_Updates_BufferedRanges) { |
| 1486 const char* input_filename = "bear-320x240.webm"; | 1507 const char* input_filename = "bear-320x240.webm"; |
| 1487 MockMediaSource source(input_filename, kWebM, kAppendWholeFile); | 1508 MockMediaSource source(input_filename, kWebM, kAppendWholeFile); |
| 1488 EXPECT_EQ(PIPELINE_OK, StartPipelineWithMediaSource(&source)); | 1509 EXPECT_EQ(PIPELINE_OK, StartPipelineWithMediaSource(&source)); |
| 1489 | 1510 |
| 1490 auto buffered_ranges = pipeline_->GetBufferedTimeRanges(); | 1511 auto buffered_ranges = pipeline_->GetBufferedTimeRanges(); |
| 1491 EXPECT_EQ(1u, buffered_ranges.size()); | 1512 EXPECT_EQ(1u, buffered_ranges.size()); |
| 1492 EXPECT_EQ(0, buffered_ranges.start(0).InMilliseconds()); | 1513 EXPECT_EQ(0, buffered_ranges.start(0).InMilliseconds()); |
| 1493 EXPECT_EQ(k320WebMFileDurationMs, buffered_ranges.end(0).InMilliseconds()); | 1514 EXPECT_EQ(k320WebMFileDurationMs, buffered_ranges.end(0).InMilliseconds()); |
| 1494 | 1515 |
| 1495 source.RemoveRange(base::TimeDelta::FromMilliseconds(1000), | 1516 source.RemoveRange(base::TimeDelta::FromMilliseconds(1000), |
| 1496 base::TimeDelta::FromMilliseconds(k320WebMFileDurationMs)); | 1517 base::TimeDelta::FromMilliseconds(k320WebMFileDurationMs)); |
| 1497 base::RunLoop().RunUntilIdle(); | 1518 base::RunLoop().RunUntilIdle(); |
| 1498 | 1519 |
| 1499 buffered_ranges = pipeline_->GetBufferedTimeRanges(); | 1520 buffered_ranges = pipeline_->GetBufferedTimeRanges(); |
| 1500 EXPECT_EQ(1u, buffered_ranges.size()); | 1521 EXPECT_EQ(1u, buffered_ranges.size()); |
| 1501 EXPECT_EQ(0, buffered_ranges.start(0).InMilliseconds()); | 1522 EXPECT_EQ(0, buffered_ranges.start(0).InMilliseconds()); |
| 1502 EXPECT_EQ(1001, buffered_ranges.end(0).InMilliseconds()); | 1523 EXPECT_EQ(1001, buffered_ranges.end(0).InMilliseconds()); |
| 1503 | 1524 |
| 1504 source.Shutdown(); | 1525 source.Shutdown(); |
| 1505 Stop(); | 1526 Stop(); |
| 1506 } | 1527 } |
| 1507 | 1528 |
| 1508 // This test case imitates media playback with advancing media_time and | 1529 // This test case imitates media playback with advancing media_time and |
| 1509 // continuously adding new data. At some point we should reach the buffering | 1530 // continuously adding new data. At some point we should reach the buffering |
| 1510 // limit, after that MediaSource should evict some buffered data and that | 1531 // limit, after that MediaSource should evict some buffered data and that |
| 1511 // evicted data shold be reflected in the change of media::Pipeline buffered | 1532 // evicted data shold be reflected in the change of media::Pipeline buffered |
| 1512 // ranges (returned by GetBufferedTimeRanges). At that point the buffered ranges | 1533 // ranges (returned by GetBufferedTimeRanges). At that point the buffered ranges |
| 1513 // will no longer start at 0. | 1534 // will no longer start at 0. |
| 1514 TEST_F(PipelineIntegrationTest, MediaSource_FillUp_Buffer) { | 1535 TEST_P(CommonPipelineIntegrationTest, MediaSource_FillUp_Buffer) { |
| 1515 const char* input_filename = "bear-320x240.webm"; | 1536 const char* input_filename = "bear-320x240.webm"; |
| 1516 MockMediaSource source(input_filename, kWebM, kAppendWholeFile); | 1537 MockMediaSource source(input_filename, kWebM, kAppendWholeFile); |
| 1517 EXPECT_EQ(PIPELINE_OK, StartPipelineWithMediaSource(&source)); | 1538 EXPECT_EQ(PIPELINE_OK, StartPipelineWithMediaSource(&source)); |
| 1518 source.SetMemoryLimits(1048576); | 1539 source.SetMemoryLimits(1048576); |
| 1519 | 1540 |
| 1520 scoped_refptr<DecoderBuffer> file = ReadTestDataFile(input_filename); | 1541 scoped_refptr<DecoderBuffer> file = ReadTestDataFile(input_filename); |
| 1521 | 1542 |
| 1522 auto buffered_ranges = pipeline_->GetBufferedTimeRanges(); | 1543 auto buffered_ranges = pipeline_->GetBufferedTimeRanges(); |
| 1523 EXPECT_EQ(1u, buffered_ranges.size()); | 1544 EXPECT_EQ(1u, buffered_ranges.size()); |
| 1524 do { | 1545 do { |
| 1525 // Advance media_time to the end of the currently buffered data | 1546 // Advance media_time to the end of the currently buffered data |
| 1526 base::TimeDelta media_time = buffered_ranges.end(0); | 1547 base::TimeDelta media_time = buffered_ranges.end(0); |
| 1527 source.Seek(media_time); | 1548 source.Seek(media_time); |
| 1528 // Ask MediaSource to evict buffered data if buffering limit has been | 1549 // 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). | 1550 // reached (the data will be evicted from the front of the buffered range). |
| 1530 source.EvictCodedFrames(media_time, file->data_size()); | 1551 source.EvictCodedFrames(media_time, file->data_size()); |
| 1531 ASSERT_TRUE( | 1552 ASSERT_TRUE( |
| 1532 source.AppendAtTime(media_time, file->data(), file->data_size())); | 1553 source.AppendAtTime(media_time, file->data(), file->data_size())); |
| 1533 base::RunLoop().RunUntilIdle(); | 1554 base::RunLoop().RunUntilIdle(); |
| 1534 | 1555 |
| 1535 buffered_ranges = pipeline_->GetBufferedTimeRanges(); | 1556 buffered_ranges = pipeline_->GetBufferedTimeRanges(); |
| 1536 } while (buffered_ranges.size() == 1 && | 1557 } while (buffered_ranges.size() == 1 && |
| 1537 buffered_ranges.start(0) == base::TimeDelta::FromSeconds(0)); | 1558 buffered_ranges.start(0) == base::TimeDelta::FromSeconds(0)); |
| 1538 | 1559 |
| 1539 EXPECT_EQ(1u, buffered_ranges.size()); | 1560 EXPECT_EQ(1u, buffered_ranges.size()); |
| 1540 source.Shutdown(); | 1561 source.Shutdown(); |
| 1541 Stop(); | 1562 Stop(); |
| 1542 } | 1563 } |
| 1543 | 1564 |
| 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) | 1565 #if defined(ARCH_CPU_X86_FAMILY) && !defined(OS_ANDROID) |
| 1634 TEST_F(PipelineIntegrationTest, BasicPlaybackHi10PVP9) { | 1566 TEST_P(CommonPipelineIntegrationTest, BasicPlaybackHi10PVP9) { |
| 1635 ASSERT_EQ(PIPELINE_OK, Start("bear-320x180-hi10p-vp9.webm", kClockless)); | 1567 ASSERT_EQ(PIPELINE_OK, Start("bear-320x180-hi10p-vp9.webm", kClockless)); |
| 1636 | 1568 |
| 1637 Play(); | 1569 Play(); |
| 1638 | 1570 |
| 1639 ASSERT_TRUE(WaitUntilOnEnded()); | 1571 ASSERT_TRUE(WaitUntilOnEnded()); |
| 1640 } | 1572 } |
| 1641 | 1573 |
| 1642 TEST_F(PipelineIntegrationTest, BasicPlaybackHi12PVP9) { | 1574 TEST_P(CommonPipelineIntegrationTest, BasicPlaybackHi12PVP9) { |
| 1643 ASSERT_EQ(PIPELINE_OK, Start("bear-320x180-hi12p-vp9.webm", kClockless)); | 1575 ASSERT_EQ(PIPELINE_OK, Start("bear-320x180-hi12p-vp9.webm", kClockless)); |
| 1644 | 1576 |
| 1645 Play(); | 1577 Play(); |
| 1646 | 1578 |
| 1647 ASSERT_TRUE(WaitUntilOnEnded()); | 1579 ASSERT_TRUE(WaitUntilOnEnded()); |
| 1648 } | 1580 } |
| 1649 #endif | 1581 #endif |
| 1650 | 1582 |
| 1651 #if BUILDFLAG(USE_PROPRIETARY_CODECS) | 1583 #if BUILDFLAG(USE_PROPRIETARY_CODECS) |
| 1652 | 1584 |
| 1653 TEST_F(PipelineIntegrationTest, BasicPlaybackHi10P) { | 1585 TEST_P(CommonPipelineIntegrationTest, BasicPlaybackHi10P) { |
| 1654 ASSERT_EQ(PIPELINE_OK, Start("bear-320x180-hi10p.mp4", kClockless)); | 1586 ASSERT_EQ(PIPELINE_OK, Start("bear-320x180-hi10p.mp4", kClockless)); |
| 1655 | 1587 |
| 1656 Play(); | 1588 Play(); |
| 1657 | 1589 |
| 1658 ASSERT_TRUE(WaitUntilOnEnded()); | 1590 ASSERT_TRUE(WaitUntilOnEnded()); |
| 1659 } | 1591 } |
| 1660 | 1592 |
| 1661 TEST_F(PipelineIntegrationTest, BasicFallback) { | 1593 TEST_P(CommonPipelineIntegrationTest, BasicFallback) { |
| 1662 ScopedVector<VideoDecoder> failing_video_decoder; | 1594 ScopedVector<VideoDecoder> failing_video_decoder; |
| 1663 failing_video_decoder.push_back(new FailingVideoDecoder()); | 1595 failing_video_decoder.push_back(new FailingVideoDecoder()); |
| 1664 | 1596 |
| 1665 ASSERT_EQ(PIPELINE_OK, | 1597 ASSERT_EQ(PIPELINE_OK, |
| 1666 Start("bear.mp4", kClockless, std::move(failing_video_decoder))); | 1598 Start("bear.mp4", kClockless, std::move(failing_video_decoder))); |
| 1667 | 1599 |
| 1668 Play(); | 1600 Play(); |
| 1669 | 1601 |
| 1670 ASSERT_TRUE(WaitUntilOnEnded()); | 1602 ASSERT_TRUE(WaitUntilOnEnded()); |
| 1671 }; | 1603 }; |
| 1672 | 1604 |
| 1673 TEST_F(PipelineIntegrationTest, MediaSource_ADTS) { | 1605 TEST_P(CommonPipelineIntegrationTest, MediaSource_ADTS) { |
| 1674 MockMediaSource source("sfx.adts", kADTS, kAppendWholeFile); | 1606 MockMediaSource source("sfx.adts", kADTS, kAppendWholeFile); |
| 1675 EXPECT_EQ(PIPELINE_OK, StartPipelineWithMediaSource(&source)); | 1607 EXPECT_EQ(PIPELINE_OK, StartPipelineWithMediaSource(&source)); |
| 1676 source.EndOfStream(); | 1608 source.EndOfStream(); |
| 1677 | 1609 |
| 1678 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); | 1610 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); |
| 1679 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); | 1611 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); |
| 1680 EXPECT_EQ(325, pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); | 1612 EXPECT_EQ(325, pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); |
| 1681 | 1613 |
| 1682 Play(); | 1614 Play(); |
| 1683 | 1615 |
| 1684 EXPECT_TRUE(WaitUntilOnEnded()); | 1616 EXPECT_TRUE(WaitUntilOnEnded()); |
| 1685 } | 1617 } |
| 1686 | 1618 |
| 1687 TEST_F(PipelineIntegrationTest, MediaSource_ADTS_TimestampOffset) { | 1619 TEST_P(CommonPipelineIntegrationTest, MediaSource_ADTS_TimestampOffset) { |
| 1688 MockMediaSource source("sfx.adts", kADTS, kAppendWholeFile); | 1620 MockMediaSource source("sfx.adts", kADTS, kAppendWholeFile); |
| 1689 EXPECT_EQ(PIPELINE_OK, | 1621 EXPECT_EQ(PIPELINE_OK, |
| 1690 StartPipelineWithMediaSource(&source, kHashed, nullptr)); | 1622 StartPipelineWithMediaSource(&source, kHashed, nullptr)); |
| 1691 EXPECT_EQ(325, source.last_timestamp_offset().InMilliseconds()); | 1623 EXPECT_EQ(325, source.last_timestamp_offset().InMilliseconds()); |
| 1692 | 1624 |
| 1693 // Trim off multiple frames off the beginning of the segment which will cause | 1625 // 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. | 1626 // the first decoded frame to be incorrect if preroll isn't implemented. |
| 1695 const base::TimeDelta adts_preroll_duration = | 1627 const base::TimeDelta adts_preroll_duration = |
| 1696 base::TimeDelta::FromSecondsD(2.5 * 1024 / 44100); | 1628 base::TimeDelta::FromSecondsD(2.5 * 1024 / 44100); |
| 1697 const base::TimeDelta append_time = | 1629 const base::TimeDelta append_time = |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1708 | 1640 |
| 1709 EXPECT_EQ(592, source.last_timestamp_offset().InMilliseconds()); | 1641 EXPECT_EQ(592, source.last_timestamp_offset().InMilliseconds()); |
| 1710 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); | 1642 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); |
| 1711 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); | 1643 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); |
| 1712 EXPECT_EQ(592, pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); | 1644 EXPECT_EQ(592, pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); |
| 1713 | 1645 |
| 1714 // Verify preroll is stripped. | 1646 // Verify preroll is stripped. |
| 1715 EXPECT_HASH_EQ("-0.25,0.67,0.04,0.14,-0.49,-0.41,", GetAudioHash()); | 1647 EXPECT_HASH_EQ("-0.25,0.67,0.04,0.14,-0.49,-0.41,", GetAudioHash()); |
| 1716 } | 1648 } |
| 1717 | 1649 |
| 1718 TEST_F(PipelineIntegrationTest, BasicPlaybackHashed_MP3) { | 1650 TEST_P(CommonPipelineIntegrationTest, BasicPlaybackHashed_MP3) { |
| 1719 ASSERT_EQ(PIPELINE_OK, Start("sfx.mp3", kHashed)); | 1651 ASSERT_EQ(PIPELINE_OK, Start("sfx.mp3", kHashed)); |
| 1720 | 1652 |
| 1721 Play(); | 1653 Play(); |
| 1722 | 1654 |
| 1723 ASSERT_TRUE(WaitUntilOnEnded()); | 1655 ASSERT_TRUE(WaitUntilOnEnded()); |
| 1724 | 1656 |
| 1725 // Verify codec delay and preroll are stripped. | 1657 // Verify codec delay and preroll are stripped. |
| 1726 EXPECT_HASH_EQ("1.30,2.72,4.56,5.08,3.74,2.03,", GetAudioHash()); | 1658 EXPECT_HASH_EQ("1.30,2.72,4.56,5.08,3.74,2.03,", GetAudioHash()); |
| 1727 } | 1659 } |
| 1728 | 1660 |
| 1729 #if !defined(DISABLE_CLOCKLESS_TESTS) | 1661 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); | 1662 MockMediaSource source("sfx.mp3", kMP3, kAppendWholeFile); |
| 1800 EXPECT_EQ(PIPELINE_OK, | 1663 EXPECT_EQ(PIPELINE_OK, |
| 1801 StartPipelineWithMediaSource(&source, kHashed, nullptr)); | 1664 StartPipelineWithMediaSource(&source, kHashed, nullptr)); |
| 1802 source.EndOfStream(); | 1665 source.EndOfStream(); |
| 1803 | 1666 |
| 1804 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); | 1667 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); |
| 1805 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); | 1668 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); |
| 1806 EXPECT_EQ(313, pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); | 1669 EXPECT_EQ(313, pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); |
| 1807 | 1670 |
| 1808 Play(); | 1671 Play(); |
| 1809 | 1672 |
| 1810 EXPECT_TRUE(WaitUntilOnEnded()); | 1673 EXPECT_TRUE(WaitUntilOnEnded()); |
| 1811 | 1674 |
| 1812 // Verify that codec delay was stripped. | 1675 // Verify that codec delay was stripped. |
| 1813 EXPECT_HASH_EQ("1.01,2.71,4.18,4.32,3.04,1.12,", GetAudioHash()); | 1676 EXPECT_HASH_EQ("1.01,2.71,4.18,4.32,3.04,1.12,", GetAudioHash()); |
| 1814 } | 1677 } |
| 1815 | 1678 |
| 1816 TEST_F(PipelineIntegrationTest, MediaSource_MP3_TimestampOffset) { | 1679 TEST_P(CommonPipelineIntegrationTest, MediaSource_MP3_TimestampOffset) { |
| 1817 MockMediaSource source("sfx.mp3", kMP3, kAppendWholeFile); | 1680 MockMediaSource source("sfx.mp3", kMP3, kAppendWholeFile); |
| 1818 EXPECT_EQ(PIPELINE_OK, StartPipelineWithMediaSource(&source)); | 1681 EXPECT_EQ(PIPELINE_OK, StartPipelineWithMediaSource(&source)); |
| 1819 EXPECT_EQ(313, source.last_timestamp_offset().InMilliseconds()); | 1682 EXPECT_EQ(313, source.last_timestamp_offset().InMilliseconds()); |
| 1820 | 1683 |
| 1821 // There are 576 silent frames at the start of this mp3. The second append | 1684 // There are 576 silent frames at the start of this mp3. The second append |
| 1822 // should trim them off. | 1685 // should trim them off. |
| 1823 const base::TimeDelta mp3_preroll_duration = | 1686 const base::TimeDelta mp3_preroll_duration = |
| 1824 base::TimeDelta::FromSecondsD(576.0 / 44100); | 1687 base::TimeDelta::FromSecondsD(576.0 / 44100); |
| 1825 const base::TimeDelta append_time = | 1688 const base::TimeDelta append_time = |
| 1826 source.last_timestamp_offset() - mp3_preroll_duration; | 1689 source.last_timestamp_offset() - mp3_preroll_duration; |
| 1827 | 1690 |
| 1828 scoped_refptr<DecoderBuffer> second_file = ReadTestDataFile("sfx.mp3"); | 1691 scoped_refptr<DecoderBuffer> second_file = ReadTestDataFile("sfx.mp3"); |
| 1829 source.AppendAtTimeWithWindow(append_time, append_time + mp3_preroll_duration, | 1692 source.AppendAtTimeWithWindow(append_time, append_time + mp3_preroll_duration, |
| 1830 kInfiniteDuration, second_file->data(), | 1693 kInfiniteDuration, second_file->data(), |
| 1831 second_file->data_size()); | 1694 second_file->data_size()); |
| 1832 source.EndOfStream(); | 1695 source.EndOfStream(); |
| 1833 | 1696 |
| 1834 Play(); | 1697 Play(); |
| 1835 EXPECT_TRUE(WaitUntilOnEnded()); | 1698 EXPECT_TRUE(WaitUntilOnEnded()); |
| 1836 | 1699 |
| 1837 EXPECT_EQ(613, source.last_timestamp_offset().InMilliseconds()); | 1700 EXPECT_EQ(613, source.last_timestamp_offset().InMilliseconds()); |
| 1838 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); | 1701 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); |
| 1839 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); | 1702 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); |
| 1840 EXPECT_EQ(613, pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); | 1703 EXPECT_EQ(613, pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); |
| 1841 } | 1704 } |
| 1842 | 1705 |
| 1843 TEST_F(PipelineIntegrationTest, MediaSource_MP3_Icecast) { | 1706 TEST_P(CommonPipelineIntegrationTest, MediaSource_MP3_Icecast) { |
| 1844 MockMediaSource source("icy_sfx.mp3", kMP3, kAppendWholeFile); | 1707 MockMediaSource source("icy_sfx.mp3", kMP3, kAppendWholeFile); |
| 1845 EXPECT_EQ(PIPELINE_OK, StartPipelineWithMediaSource(&source)); | 1708 EXPECT_EQ(PIPELINE_OK, StartPipelineWithMediaSource(&source)); |
| 1846 source.EndOfStream(); | 1709 source.EndOfStream(); |
| 1847 | 1710 |
| 1848 Play(); | 1711 Play(); |
| 1849 | 1712 |
| 1850 EXPECT_TRUE(WaitUntilOnEnded()); | 1713 EXPECT_TRUE(WaitUntilOnEnded()); |
| 1851 } | 1714 } |
| 1852 | 1715 |
| 1853 TEST_F(PipelineIntegrationTest, MediaSource_ConfigChange_MP4) { | 1716 TEST_P(CommonPipelineIntegrationTest, MediaSource_ConfigChange_MP4) { |
| 1854 MockMediaSource source("bear-640x360-av_frag.mp4", kMP4, kAppendWholeFile); | 1717 MockMediaSource source("bear-640x360-av_frag.mp4", kMP4, kAppendWholeFile); |
| 1855 EXPECT_EQ(PIPELINE_OK, StartPipelineWithMediaSource(&source)); | 1718 EXPECT_EQ(PIPELINE_OK, StartPipelineWithMediaSource(&source)); |
| 1856 | 1719 |
| 1857 EXPECT_CALL(*this, OnVideoNaturalSizeChange(gfx::Size(1280, 720))).Times(1); | 1720 EXPECT_CALL(*this, OnVideoNaturalSizeChange(gfx::Size(1280, 720))).Times(1); |
| 1858 scoped_refptr<DecoderBuffer> second_file = | 1721 scoped_refptr<DecoderBuffer> second_file = |
| 1859 ReadTestDataFile("bear-1280x720-av_frag.mp4"); | 1722 ReadTestDataFile("bear-1280x720-av_frag.mp4"); |
| 1860 ASSERT_TRUE(source.AppendAtTime(base::TimeDelta::FromSeconds(kAppendTimeSec), | 1723 ASSERT_TRUE(source.AppendAtTime(base::TimeDelta::FromSeconds(kAppendTimeSec), |
| 1861 second_file->data(), | 1724 second_file->data(), |
| 1862 second_file->data_size())); | 1725 second_file->data_size())); |
| 1863 source.EndOfStream(); | 1726 source.EndOfStream(); |
| 1864 | 1727 |
| 1865 Play(); | 1728 Play(); |
| 1866 EXPECT_TRUE(WaitUntilOnEnded()); | 1729 EXPECT_TRUE(WaitUntilOnEnded()); |
| 1867 | 1730 |
| 1868 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); | 1731 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); |
| 1869 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); | 1732 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); |
| 1870 EXPECT_EQ(kAppendTimeMs + k1280IsoFileDurationMs, | 1733 EXPECT_EQ(kAppendTimeMs + k1280IsoFileDurationMs, |
| 1871 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); | 1734 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); |
| 1872 | 1735 |
| 1873 source.Shutdown(); | 1736 source.Shutdown(); |
| 1874 Stop(); | 1737 Stop(); |
| 1875 } | 1738 } |
| 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) | 1739 #endif // BUILDFLAG(USE_PROPRIETARY_CODECS) |
| 2005 | 1740 |
| 2006 TEST_F(PipelineIntegrationTest, BasicPlayback_16x9AspectRatio) { | 1741 TEST_P(CommonPipelineIntegrationTest, BasicPlayback_16x9AspectRatio) { |
| 2007 ASSERT_EQ(PIPELINE_OK, Start("bear-320x240-16x9-aspect.webm")); | 1742 ASSERT_EQ(PIPELINE_OK, Start("bear-320x240-16x9-aspect.webm")); |
| 2008 Play(); | 1743 Play(); |
| 2009 ASSERT_TRUE(WaitUntilOnEnded()); | 1744 ASSERT_TRUE(WaitUntilOnEnded()); |
| 2010 } | 1745 } |
| 2011 | 1746 |
| 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) | 1747 #if BUILDFLAG(USE_PROPRIETARY_CODECS) |
| 2064 TEST_F(PipelineIntegrationTest, | 1748 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, | 1749 MockMediaSource source("bear-1280x720-aac_he.ts", kMP2AudioSBR, |
| 2119 kAppendWholeFile); | 1750 kAppendWholeFile); |
| 2120 #if BUILDFLAG(ENABLE_MSE_MPEG2TS_STREAM_PARSER) | 1751 #if BUILDFLAG(ENABLE_MSE_MPEG2TS_STREAM_PARSER) |
| 2121 EXPECT_EQ(PIPELINE_OK, StartPipelineWithMediaSource(&source)); | 1752 EXPECT_EQ(PIPELINE_OK, StartPipelineWithMediaSource(&source)); |
| 2122 source.EndOfStream(); | 1753 source.EndOfStream(); |
| 2123 ASSERT_EQ(PIPELINE_OK, pipeline_status_); | 1754 ASSERT_EQ(PIPELINE_OK, pipeline_status_); |
| 2124 | 1755 |
| 2125 // Check that SBR is taken into account correctly by mpeg2ts parser. When an | 1756 // 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 | 1757 // 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 | 1758 // calculated incorrectly and that leads to gaps in buffered ranges (so this |
| 2128 // check will fail) and eventually leads to stalled playback. | 1759 // check will fail) and eventually leads to stalled playback. |
| 2129 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); | 1760 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); |
| 2130 #else | 1761 #else |
| 2131 EXPECT_EQ( | 1762 EXPECT_EQ( |
| 2132 DEMUXER_ERROR_COULD_NOT_OPEN, | 1763 DEMUXER_ERROR_COULD_NOT_OPEN, |
| 2133 StartPipelineWithMediaSource(&source, kExpectDemuxerFailure, nullptr)); | 1764 StartPipelineWithMediaSource(&source, kExpectDemuxerFailure, nullptr)); |
| 2134 #endif | 1765 #endif |
| 2135 } | 1766 } |
| 2136 | 1767 |
| 2137 TEST_F(PipelineIntegrationTest, Mpeg2ts_MP3Audio_Mp4a_6B) { | 1768 TEST_P(CommonPipelineIntegrationTest, Mpeg2ts_MP3Audio_Mp4a_6B) { |
| 2138 MockMediaSource source("bear-audio-mp4a.6B.ts", | 1769 MockMediaSource source("bear-audio-mp4a.6B.ts", |
| 2139 "video/mp2t; codecs=\"mp4a.6B\"", kAppendWholeFile); | 1770 "video/mp2t; codecs=\"mp4a.6B\"", kAppendWholeFile); |
| 2140 #if BUILDFLAG(ENABLE_MSE_MPEG2TS_STREAM_PARSER) | 1771 #if BUILDFLAG(ENABLE_MSE_MPEG2TS_STREAM_PARSER) |
| 2141 EXPECT_EQ(PIPELINE_OK, StartPipelineWithMediaSource(&source)); | 1772 EXPECT_EQ(PIPELINE_OK, StartPipelineWithMediaSource(&source)); |
| 2142 source.EndOfStream(); | 1773 source.EndOfStream(); |
| 2143 ASSERT_EQ(PIPELINE_OK, pipeline_status_); | 1774 ASSERT_EQ(PIPELINE_OK, pipeline_status_); |
| 2144 #else | 1775 #else |
| 2145 EXPECT_EQ( | 1776 EXPECT_EQ( |
| 2146 DEMUXER_ERROR_COULD_NOT_OPEN, | 1777 DEMUXER_ERROR_COULD_NOT_OPEN, |
| 2147 StartPipelineWithMediaSource(&source, kExpectDemuxerFailure, nullptr)); | 1778 StartPipelineWithMediaSource(&source, kExpectDemuxerFailure, nullptr)); |
| 2148 #endif | 1779 #endif |
| 2149 } | 1780 } |
| 2150 | 1781 |
| 2151 TEST_F(PipelineIntegrationTest, Mpeg2ts_MP3Audio_Mp4a_69) { | 1782 TEST_P(CommonPipelineIntegrationTest, Mpeg2ts_MP3Audio_Mp4a_69) { |
| 2152 MockMediaSource source("bear-audio-mp4a.69.ts", | 1783 MockMediaSource source("bear-audio-mp4a.69.ts", |
| 2153 "video/mp2t; codecs=\"mp4a.69\"", kAppendWholeFile); | 1784 "video/mp2t; codecs=\"mp4a.69\"", kAppendWholeFile); |
| 2154 #if BUILDFLAG(ENABLE_MSE_MPEG2TS_STREAM_PARSER) | 1785 #if BUILDFLAG(ENABLE_MSE_MPEG2TS_STREAM_PARSER) |
| 2155 EXPECT_EQ(PIPELINE_OK, StartPipelineWithMediaSource(&source)); | 1786 EXPECT_EQ(PIPELINE_OK, StartPipelineWithMediaSource(&source)); |
| 2156 source.EndOfStream(); | 1787 source.EndOfStream(); |
| 2157 ASSERT_EQ(PIPELINE_OK, pipeline_status_); | 1788 ASSERT_EQ(PIPELINE_OK, pipeline_status_); |
| 2158 #else | 1789 #else |
| 2159 EXPECT_EQ( | 1790 EXPECT_EQ( |
| 2160 DEMUXER_ERROR_COULD_NOT_OPEN, | 1791 DEMUXER_ERROR_COULD_NOT_OPEN, |
| 2161 StartPipelineWithMediaSource(&source, kExpectDemuxerFailure, nullptr)); | 1792 StartPipelineWithMediaSource(&source, kExpectDemuxerFailure, nullptr)); |
| 2162 #endif | 1793 #endif |
| 2163 } | 1794 } |
| 2164 | 1795 |
| 2165 TEST_F(PipelineIntegrationTest, | 1796 TEST_P(CommonPipelineIntegrationTest, |
| 2166 MAYBE_EME(EncryptedPlayback_NoEncryptedFrames_MP4_CENC_AudioOnly)) { | 1797 BasicPlayback_MediaSource_VideoOnly_MP4_AVC3) { |
| 2167 MockMediaSource source("bear-1280x720-a_frag-cenc_clear-all.mp4", kMP4Audio, | 1798 MockMediaSource source("bear-1280x720-v_frag-avc3.mp4", kMP4VideoAVC3, |
| 2168 kAppendWholeFile); | 1799 kAppendWholeFile); |
| 2169 FakeEncryptedMedia encrypted_media(new NoResponseApp()); | 1800 EXPECT_EQ(PIPELINE_OK, StartPipelineWithMediaSource(&source)); |
| 2170 EXPECT_EQ(PIPELINE_OK, | 1801 source.EndOfStream(); |
| 2171 StartPipelineWithEncryptedMedia(&source, &encrypted_media)); | 1802 |
| 2172 | 1803 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); |
| 2173 source.EndOfStream(); | 1804 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); |
| 2174 | 1805 EXPECT_EQ(k1280IsoAVC3FileDurationMs, |
| 2175 Play(); | 1806 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); |
| 2176 | 1807 |
| 2177 ASSERT_TRUE(WaitUntilOnEnded()); | 1808 Play(); |
| 2178 source.Shutdown(); | 1809 |
| 2179 Stop(); | 1810 ASSERT_TRUE(WaitUntilOnEnded()); |
| 2180 } | 1811 source.Shutdown(); |
| 2181 | 1812 Stop(); |
| 2182 TEST_F(PipelineIntegrationTest, | 1813 } |
| 2183 MAYBE_EME(EncryptedPlayback_MP4_CENC_SENC_Video)) { | 1814 |
| 2184 MockMediaSource source("bear-640x360-v_frag-cenc-senc.mp4", kMP4Video, | 1815 TEST_P(CommonPipelineIntegrationTest, |
| 2185 kAppendWholeFile); | 1816 BasicPlayback_MediaSource_VideoOnly_MP4_VP9) { |
| 2186 FakeEncryptedMedia encrypted_media(new KeyProvidingApp()); | 1817 MockMediaSource source("bear-320x240-v_frag-vp9.mp4", kMP4VideoVP9, |
| 2187 EXPECT_EQ(PIPELINE_OK, | |
| 2188 StartPipelineWithEncryptedMedia(&source, &encrypted_media)); | |
| 2189 | |
| 2190 source.EndOfStream(); | |
| 2191 | |
| 2192 Play(); | |
| 2193 | |
| 2194 ASSERT_TRUE(WaitUntilOnEnded()); | |
| 2195 source.Shutdown(); | |
| 2196 Stop(); | |
| 2197 } | |
| 2198 | |
| 2199 // 'SAIZ' and 'SAIO' boxes contain redundant information which is already | |
| 2200 // available in 'SENC' box. Although 'SAIZ' and 'SAIO' boxes are required per | |
| 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); | 1818 kAppendWholeFile); |
| 2259 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( | 1819 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 2260 switches::kEnableVp9InMp4)) { | 1820 switches::kEnableVp9InMp4)) { |
| 2261 ASSERT_EQ(ChunkDemuxer::kNotSupported, source.AddId()); | 1821 ASSERT_EQ(ChunkDemuxer::kNotSupported, source.AddId()); |
| 2262 return; | 1822 return; |
| 2263 } | 1823 } |
| 2264 | 1824 |
| 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)); | 1825 EXPECT_EQ(PIPELINE_OK, StartPipelineWithMediaSource(&source)); |
| 2282 source.EndOfStream(); | 1826 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_); | 1827 ASSERT_EQ(PIPELINE_OK, pipeline_status_); |
| 2308 | 1828 |
| 2309 Play(); | 1829 Play(); |
| 2310 | 1830 |
| 2311 ASSERT_TRUE(WaitUntilOnEnded()); | 1831 ASSERT_TRUE(WaitUntilOnEnded()); |
| 2312 source.Shutdown(); | 1832 source.Shutdown(); |
| 2313 Stop(); | 1833 Stop(); |
| 2314 } | 1834 } |
| 2315 | 1835 |
| 2316 TEST_F(PipelineIntegrationTest, BasicPlayback_MediaSource_VideoOnly_MP4_HEVC1) { | 1836 TEST_P(CommonPipelineIntegrationTest, |
| 1837 BasicPlayback_MediaSource_VideoOnly_MP4_HEVC1) { |
| 2317 // HEVC demuxing might be enabled even on platforms that don't support HEVC | 1838 // 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 | 1839 // 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 | 1840 // 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 | 1841 // to actually demux and decode the stream. On platforms that support both |
| 2321 // demuxing and decoding we'll get PIPELINE_OK. | 1842 // demuxing and decoding we'll get PIPELINE_OK. |
| 2322 MockMediaSource source("bear-320x240-v_frag-hevc.mp4", kMP4VideoHEVC1, | 1843 MockMediaSource source("bear-320x240-v_frag-hevc.mp4", kMP4VideoHEVC1, |
| 2323 kAppendWholeFile); | 1844 kAppendWholeFile); |
| 2324 #if BUILDFLAG(ENABLE_HEVC_DEMUXING) | 1845 #if BUILDFLAG(ENABLE_HEVC_DEMUXING) |
| 2325 PipelineStatus status = StartPipelineWithMediaSource(&source); | 1846 PipelineStatus status = StartPipelineWithMediaSource(&source); |
| 2326 EXPECT_TRUE(status == PIPELINE_OK || status == DECODER_ERROR_NOT_SUPPORTED); | 1847 EXPECT_TRUE(status == PIPELINE_OK || status == DECODER_ERROR_NOT_SUPPORTED); |
| 2327 #else | 1848 #else |
| 2328 EXPECT_EQ( | 1849 EXPECT_EQ( |
| 2329 DEMUXER_ERROR_COULD_NOT_OPEN, | 1850 DEMUXER_ERROR_COULD_NOT_OPEN, |
| 2330 StartPipelineWithMediaSource(&source, kExpectDemuxerFailure, nullptr)); | 1851 StartPipelineWithMediaSource(&source, kExpectDemuxerFailure, nullptr)); |
| 2331 #endif | 1852 #endif |
| 2332 } | 1853 } |
| 2333 | 1854 |
| 2334 TEST_F(PipelineIntegrationTest, BasicPlayback_MediaSource_VideoOnly_MP4_HEVC2) { | 1855 TEST_P(CommonPipelineIntegrationTest, |
| 1856 BasicPlayback_MediaSource_VideoOnly_MP4_HEVC2) { |
| 2335 // HEVC demuxing might be enabled even on platforms that don't support HEVC | 1857 // 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 | 1858 // 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 | 1859 // 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 | 1860 // to actually demux and decode the stream. On platforms that support both |
| 2339 // demuxing and decoding we'll get PIPELINE_OK. | 1861 // demuxing and decoding we'll get PIPELINE_OK. |
| 2340 MockMediaSource source("bear-320x240-v_frag-hevc.mp4", kMP4VideoHEVC2, | 1862 MockMediaSource source("bear-320x240-v_frag-hevc.mp4", kMP4VideoHEVC2, |
| 2341 kAppendWholeFile); | 1863 kAppendWholeFile); |
| 2342 #if BUILDFLAG(ENABLE_HEVC_DEMUXING) | 1864 #if BUILDFLAG(ENABLE_HEVC_DEMUXING) |
| 2343 PipelineStatus status = StartPipelineWithMediaSource(&source); | 1865 PipelineStatus status = StartPipelineWithMediaSource(&source); |
| 2344 EXPECT_TRUE(status == PIPELINE_OK || status == DECODER_ERROR_NOT_SUPPORTED); | 1866 EXPECT_TRUE(status == PIPELINE_OK || status == DECODER_ERROR_NOT_SUPPORTED); |
| 2345 #else | 1867 #else |
| 2346 EXPECT_EQ( | 1868 EXPECT_EQ( |
| 2347 DEMUXER_ERROR_COULD_NOT_OPEN, | 1869 DEMUXER_ERROR_COULD_NOT_OPEN, |
| 2348 StartPipelineWithMediaSource(&source, kExpectDemuxerFailure, nullptr)); | 1870 StartPipelineWithMediaSource(&source, kExpectDemuxerFailure, nullptr)); |
| 2349 #endif | 1871 #endif |
| 2350 } | 1872 } |
| 2351 | 1873 |
| 2352 #endif // BUILDFLAG(USE_PROPRIETARY_CODECS) | 1874 #endif // BUILDFLAG(USE_PROPRIETARY_CODECS) |
| 2353 | 1875 |
| 2354 TEST_F(PipelineIntegrationTest, SeekWhilePaused) { | 1876 TEST_P(CommonPipelineIntegrationTest, SeekWhilePaused) { |
| 2355 ASSERT_EQ(PIPELINE_OK, Start("bear-320x240.webm")); | 1877 ASSERT_EQ(PIPELINE_OK, Start("bear-320x240.webm")); |
| 2356 | 1878 |
| 2357 base::TimeDelta duration(pipeline_->GetMediaDuration()); | 1879 base::TimeDelta duration(pipeline_->GetMediaDuration()); |
| 2358 base::TimeDelta start_seek_time(duration / 4); | 1880 base::TimeDelta start_seek_time(duration / 4); |
| 2359 base::TimeDelta seek_time(duration * 3 / 4); | 1881 base::TimeDelta seek_time(duration * 3 / 4); |
| 2360 | 1882 |
| 2361 Play(); | 1883 Play(); |
| 2362 ASSERT_TRUE(WaitUntilCurrentTimeIsAfter(start_seek_time)); | 1884 ASSERT_TRUE(WaitUntilCurrentTimeIsAfter(start_seek_time)); |
| 2363 Pause(); | 1885 Pause(); |
| 2364 ASSERT_TRUE(Seek(seek_time)); | 1886 ASSERT_TRUE(Seek(seek_time)); |
| 2365 EXPECT_EQ(seek_time, pipeline_->GetMediaTime()); | 1887 EXPECT_EQ(seek_time, pipeline_->GetMediaTime()); |
| 2366 Play(); | 1888 Play(); |
| 2367 ASSERT_TRUE(WaitUntilOnEnded()); | 1889 ASSERT_TRUE(WaitUntilOnEnded()); |
| 2368 | 1890 |
| 2369 // Make sure seeking after reaching the end works as expected. | 1891 // Make sure seeking after reaching the end works as expected. |
| 2370 Pause(); | 1892 Pause(); |
| 2371 ASSERT_TRUE(Seek(seek_time)); | 1893 ASSERT_TRUE(Seek(seek_time)); |
| 2372 EXPECT_EQ(seek_time, pipeline_->GetMediaTime()); | 1894 EXPECT_EQ(seek_time, pipeline_->GetMediaTime()); |
| 2373 Play(); | 1895 Play(); |
| 2374 ASSERT_TRUE(WaitUntilOnEnded()); | 1896 ASSERT_TRUE(WaitUntilOnEnded()); |
| 2375 } | 1897 } |
| 2376 | 1898 |
| 2377 TEST_F(PipelineIntegrationTest, SeekWhilePlaying) { | 1899 TEST_P(CommonPipelineIntegrationTest, SeekWhilePlaying) { |
| 2378 ASSERT_EQ(PIPELINE_OK, Start("bear-320x240.webm")); | 1900 ASSERT_EQ(PIPELINE_OK, Start("bear-320x240.webm")); |
| 2379 | 1901 |
| 2380 base::TimeDelta duration(pipeline_->GetMediaDuration()); | 1902 base::TimeDelta duration(pipeline_->GetMediaDuration()); |
| 2381 base::TimeDelta start_seek_time(duration / 4); | 1903 base::TimeDelta start_seek_time(duration / 4); |
| 2382 base::TimeDelta seek_time(duration * 3 / 4); | 1904 base::TimeDelta seek_time(duration * 3 / 4); |
| 2383 | 1905 |
| 2384 Play(); | 1906 Play(); |
| 2385 ASSERT_TRUE(WaitUntilCurrentTimeIsAfter(start_seek_time)); | 1907 ASSERT_TRUE(WaitUntilCurrentTimeIsAfter(start_seek_time)); |
| 2386 ASSERT_TRUE(Seek(seek_time)); | 1908 ASSERT_TRUE(Seek(seek_time)); |
| 2387 EXPECT_GE(pipeline_->GetMediaTime(), seek_time); | 1909 EXPECT_GE(pipeline_->GetMediaTime(), seek_time); |
| 2388 ASSERT_TRUE(WaitUntilOnEnded()); | 1910 ASSERT_TRUE(WaitUntilOnEnded()); |
| 2389 | 1911 |
| 2390 // Make sure seeking after reaching the end works as expected. | 1912 // Make sure seeking after reaching the end works as expected. |
| 2391 ASSERT_TRUE(Seek(seek_time)); | 1913 ASSERT_TRUE(Seek(seek_time)); |
| 2392 EXPECT_GE(pipeline_->GetMediaTime(), seek_time); | 1914 EXPECT_GE(pipeline_->GetMediaTime(), seek_time); |
| 2393 ASSERT_TRUE(WaitUntilOnEnded()); | 1915 ASSERT_TRUE(WaitUntilOnEnded()); |
| 2394 } | 1916 } |
| 2395 | 1917 |
| 2396 TEST_F(PipelineIntegrationTest, SuspendWhilePaused) { | 1918 TEST_P(CommonPipelineIntegrationTest, SuspendWhilePaused) { |
| 2397 ASSERT_EQ(PIPELINE_OK, Start("bear-320x240.webm")); | 1919 ASSERT_EQ(PIPELINE_OK, Start("bear-320x240.webm")); |
| 2398 | 1920 |
| 2399 base::TimeDelta duration(pipeline_->GetMediaDuration()); | 1921 base::TimeDelta duration(pipeline_->GetMediaDuration()); |
| 2400 base::TimeDelta start_seek_time(duration / 4); | 1922 base::TimeDelta start_seek_time(duration / 4); |
| 2401 base::TimeDelta seek_time(duration * 3 / 4); | 1923 base::TimeDelta seek_time(duration * 3 / 4); |
| 2402 | 1924 |
| 2403 Play(); | 1925 Play(); |
| 2404 ASSERT_TRUE(WaitUntilCurrentTimeIsAfter(start_seek_time)); | 1926 ASSERT_TRUE(WaitUntilCurrentTimeIsAfter(start_seek_time)); |
| 2405 Pause(); | 1927 Pause(); |
| 2406 | 1928 |
| 2407 // Suspend while paused. | 1929 // Suspend while paused. |
| 2408 ASSERT_TRUE(Suspend()); | 1930 ASSERT_TRUE(Suspend()); |
| 2409 | 1931 |
| 2410 // Resuming the pipeline will create a new Renderer, | 1932 // Resuming the pipeline will create a new Renderer, |
| 2411 // which in turn will trigger video size and opacity notifications. | 1933 // which in turn will trigger video size and opacity notifications. |
| 2412 EXPECT_CALL(*this, OnVideoNaturalSizeChange(gfx::Size(320, 240))).Times(1); | 1934 EXPECT_CALL(*this, OnVideoNaturalSizeChange(gfx::Size(320, 240))).Times(1); |
| 2413 EXPECT_CALL(*this, OnVideoOpacityChange(true)).Times(1); | 1935 EXPECT_CALL(*this, OnVideoOpacityChange(true)).Times(1); |
| 2414 | 1936 |
| 2415 ASSERT_TRUE(Resume(seek_time)); | 1937 ASSERT_TRUE(Resume(seek_time)); |
| 2416 EXPECT_GE(pipeline_->GetMediaTime(), seek_time); | 1938 EXPECT_GE(pipeline_->GetMediaTime(), seek_time); |
| 2417 Play(); | 1939 Play(); |
| 2418 ASSERT_TRUE(WaitUntilOnEnded()); | 1940 ASSERT_TRUE(WaitUntilOnEnded()); |
| 2419 } | 1941 } |
| 2420 | 1942 |
| 2421 TEST_F(PipelineIntegrationTest, SuspendWhilePlaying) { | 1943 TEST_P(CommonPipelineIntegrationTest, SuspendWhilePlaying) { |
| 2422 ASSERT_EQ(PIPELINE_OK, Start("bear-320x240.webm")); | 1944 ASSERT_EQ(PIPELINE_OK, Start("bear-320x240.webm")); |
| 2423 | 1945 |
| 2424 base::TimeDelta duration(pipeline_->GetMediaDuration()); | 1946 base::TimeDelta duration(pipeline_->GetMediaDuration()); |
| 2425 base::TimeDelta start_seek_time(duration / 4); | 1947 base::TimeDelta start_seek_time(duration / 4); |
| 2426 base::TimeDelta seek_time(duration * 3 / 4); | 1948 base::TimeDelta seek_time(duration * 3 / 4); |
| 2427 | 1949 |
| 2428 Play(); | 1950 Play(); |
| 2429 ASSERT_TRUE(WaitUntilCurrentTimeIsAfter(start_seek_time)); | 1951 ASSERT_TRUE(WaitUntilCurrentTimeIsAfter(start_seek_time)); |
| 2430 ASSERT_TRUE(Suspend()); | 1952 ASSERT_TRUE(Suspend()); |
| 2431 | 1953 |
| 2432 // Resuming the pipeline will create a new Renderer, | 1954 // Resuming the pipeline will create a new Renderer, |
| 2433 // which in turn will trigger video size and opacity notifications. | 1955 // which in turn will trigger video size and opacity notifications. |
| 2434 EXPECT_CALL(*this, OnVideoNaturalSizeChange(gfx::Size(320, 240))).Times(1); | 1956 EXPECT_CALL(*this, OnVideoNaturalSizeChange(gfx::Size(320, 240))).Times(1); |
| 2435 EXPECT_CALL(*this, OnVideoOpacityChange(true)).Times(1); | 1957 EXPECT_CALL(*this, OnVideoOpacityChange(true)).Times(1); |
| 2436 | 1958 |
| 2437 ASSERT_TRUE(Resume(seek_time)); | 1959 ASSERT_TRUE(Resume(seek_time)); |
| 2438 EXPECT_GE(pipeline_->GetMediaTime(), seek_time); | 1960 EXPECT_GE(pipeline_->GetMediaTime(), seek_time); |
| 2439 ASSERT_TRUE(WaitUntilOnEnded()); | 1961 ASSERT_TRUE(WaitUntilOnEnded()); |
| 2440 } | 1962 } |
| 2441 | 1963 |
| 2442 #if BUILDFLAG(USE_PROPRIETARY_CODECS) | 1964 #if BUILDFLAG(USE_PROPRIETARY_CODECS) |
| 2443 TEST_F(PipelineIntegrationTest, Rotated_Metadata_0) { | 1965 TEST_P(CommonPipelineIntegrationTest, Rotated_Metadata_0) { |
| 2444 ASSERT_EQ(PIPELINE_OK, Start("bear_rotate_0.mp4")); | 1966 ASSERT_EQ(PIPELINE_OK, Start("bear_rotate_0.mp4")); |
| 2445 ASSERT_EQ(VIDEO_ROTATION_0, metadata_.video_rotation); | 1967 ASSERT_EQ(VIDEO_ROTATION_0, metadata_.video_rotation); |
| 2446 } | 1968 } |
| 2447 | 1969 |
| 2448 TEST_F(PipelineIntegrationTest, Rotated_Metadata_90) { | 1970 TEST_P(CommonPipelineIntegrationTest, Rotated_Metadata_90) { |
| 2449 ASSERT_EQ(PIPELINE_OK, Start("bear_rotate_90.mp4")); | 1971 ASSERT_EQ(PIPELINE_OK, Start("bear_rotate_90.mp4")); |
| 2450 ASSERT_EQ(VIDEO_ROTATION_90, metadata_.video_rotation); | 1972 ASSERT_EQ(VIDEO_ROTATION_90, metadata_.video_rotation); |
| 2451 } | 1973 } |
| 2452 | 1974 |
| 2453 TEST_F(PipelineIntegrationTest, Rotated_Metadata_180) { | 1975 TEST_P(CommonPipelineIntegrationTest, Rotated_Metadata_180) { |
| 2454 ASSERT_EQ(PIPELINE_OK, Start("bear_rotate_180.mp4")); | 1976 ASSERT_EQ(PIPELINE_OK, Start("bear_rotate_180.mp4")); |
| 2455 ASSERT_EQ(VIDEO_ROTATION_180, metadata_.video_rotation); | 1977 ASSERT_EQ(VIDEO_ROTATION_180, metadata_.video_rotation); |
| 2456 } | 1978 } |
| 2457 | 1979 |
| 2458 TEST_F(PipelineIntegrationTest, Rotated_Metadata_270) { | 1980 TEST_P(CommonPipelineIntegrationTest, Rotated_Metadata_270) { |
| 2459 ASSERT_EQ(PIPELINE_OK, Start("bear_rotate_270.mp4")); | 1981 ASSERT_EQ(PIPELINE_OK, Start("bear_rotate_270.mp4")); |
| 2460 ASSERT_EQ(VIDEO_ROTATION_270, metadata_.video_rotation); | 1982 ASSERT_EQ(VIDEO_ROTATION_270, metadata_.video_rotation); |
| 2461 } | 1983 } |
| 2462 #endif // BUILDFLAG(USE_PROPRIETARY_CODECS) | 1984 #endif // BUILDFLAG(USE_PROPRIETARY_CODECS) |
| 2463 | 1985 |
| 2464 // Verify audio decoder & renderer can handle aborted demuxer reads. | 1986 // Verify audio decoder & renderer can handle aborted demuxer reads. |
| 2465 TEST_F(PipelineIntegrationTest, ChunkDemuxerAbortRead_AudioOnly) { | 1987 TEST_P(CommonPipelineIntegrationTest, ChunkDemuxerAbortRead_AudioOnly) { |
| 2466 ASSERT_TRUE(TestSeekDuringRead("bear-320x240-audio-only.webm", kAudioOnlyWebM, | 1988 ASSERT_TRUE(TestSeekDuringRead("bear-320x240-audio-only.webm", kAudioOnlyWebM, |
| 2467 16384, base::TimeDelta::FromMilliseconds(464), | 1989 16384, base::TimeDelta::FromMilliseconds(464), |
| 2468 base::TimeDelta::FromMilliseconds(617), 0x10CA, | 1990 base::TimeDelta::FromMilliseconds(617), 0x10CA, |
| 2469 19730)); | 1991 19730)); |
| 2470 } | 1992 } |
| 2471 | 1993 |
| 2472 // Verify video decoder & renderer can handle aborted demuxer reads. | 1994 // Verify video decoder & renderer can handle aborted demuxer reads. |
| 2473 TEST_F(PipelineIntegrationTest, ChunkDemuxerAbortRead_VideoOnly) { | 1995 TEST_P(CommonPipelineIntegrationTest, ChunkDemuxerAbortRead_VideoOnly) { |
| 2474 ASSERT_TRUE(TestSeekDuringRead("bear-320x240-video-only.webm", kVideoOnlyWebM, | 1996 ASSERT_TRUE(TestSeekDuringRead("bear-320x240-video-only.webm", kVideoOnlyWebM, |
| 2475 32768, base::TimeDelta::FromMilliseconds(167), | 1997 32768, base::TimeDelta::FromMilliseconds(167), |
| 2476 base::TimeDelta::FromMilliseconds(1668), | 1998 base::TimeDelta::FromMilliseconds(1668), |
| 2477 0x1C896, 65536)); | 1999 0x1C896, 65536)); |
| 2478 } | 2000 } |
| 2479 | 2001 |
| 2480 // Verify that Opus audio in WebM containers can be played back. | 2002 // Verify that Opus audio in WebM containers can be played back. |
| 2481 TEST_F(PipelineIntegrationTest, BasicPlayback_AudioOnly_Opus_WebM) { | 2003 TEST_P(CommonPipelineIntegrationTest, BasicPlayback_AudioOnly_Opus_WebM) { |
| 2482 ASSERT_EQ(PIPELINE_OK, Start("bear-opus-end-trimming.webm")); | 2004 ASSERT_EQ(PIPELINE_OK, Start("bear-opus-end-trimming.webm")); |
| 2483 Play(); | 2005 Play(); |
| 2484 ASSERT_TRUE(WaitUntilOnEnded()); | 2006 ASSERT_TRUE(WaitUntilOnEnded()); |
| 2485 } | 2007 } |
| 2486 | 2008 |
| 2487 // Verify that VP9 video in WebM containers can be played back. | 2009 // Verify that VP9 video in WebM containers can be played back. |
| 2488 TEST_F(PipelineIntegrationTest, BasicPlayback_VideoOnly_VP9_WebM) { | 2010 TEST_P(CommonPipelineIntegrationTest, BasicPlayback_VideoOnly_VP9_WebM) { |
| 2489 ASSERT_EQ(PIPELINE_OK, Start("bear-vp9.webm")); | 2011 ASSERT_EQ(PIPELINE_OK, Start("bear-vp9.webm")); |
| 2490 Play(); | 2012 Play(); |
| 2491 ASSERT_TRUE(WaitUntilOnEnded()); | 2013 ASSERT_TRUE(WaitUntilOnEnded()); |
| 2492 } | 2014 } |
| 2493 | 2015 |
| 2494 // Verify that VP9 video and Opus audio in the same WebM container can be played | 2016 // Verify that VP9 video and Opus audio in the same WebM container can be played |
| 2495 // back. | 2017 // back. |
| 2496 TEST_F(PipelineIntegrationTest, BasicPlayback_VP9_Opus_WebM) { | 2018 TEST_P(CommonPipelineIntegrationTest, BasicPlayback_VP9_Opus_WebM) { |
| 2497 ASSERT_EQ(PIPELINE_OK, Start("bear-vp9-opus.webm")); | 2019 ASSERT_EQ(PIPELINE_OK, Start("bear-vp9-opus.webm")); |
| 2498 Play(); | 2020 Play(); |
| 2499 ASSERT_TRUE(WaitUntilOnEnded()); | 2021 ASSERT_TRUE(WaitUntilOnEnded()); |
| 2500 } | 2022 } |
| 2501 | 2023 |
| 2502 // Verify that VP8 video with alpha channel can be played back. | 2024 // Verify that VP8 video with alpha channel can be played back. |
| 2503 TEST_F(PipelineIntegrationTest, BasicPlayback_VP8A_WebM) { | 2025 TEST_P(CommonPipelineIntegrationTest, BasicPlayback_VP8A_WebM) { |
| 2504 ASSERT_EQ(PIPELINE_OK, Start("bear-vp8a.webm")); | 2026 ASSERT_EQ(PIPELINE_OK, Start("bear-vp8a.webm")); |
| 2505 Play(); | 2027 Play(); |
| 2506 ASSERT_TRUE(WaitUntilOnEnded()); | 2028 ASSERT_TRUE(WaitUntilOnEnded()); |
| 2507 EXPECT_VIDEO_FORMAT_EQ(last_video_frame_format_, PIXEL_FORMAT_YV12A); | 2029 EXPECT_VIDEO_FORMAT_EQ(last_video_frame_format_, PIXEL_FORMAT_YV12A); |
| 2508 } | 2030 } |
| 2509 | 2031 |
| 2510 // Verify that VP8A video with odd width/height can be played back. | 2032 // Verify that VP8A video with odd width/height can be played back. |
| 2511 TEST_F(PipelineIntegrationTest, BasicPlayback_VP8A_Odd_WebM) { | 2033 TEST_P(CommonPipelineIntegrationTest, BasicPlayback_VP8A_Odd_WebM) { |
| 2512 ASSERT_EQ(PIPELINE_OK, Start("bear-vp8a-odd-dimensions.webm")); | 2034 ASSERT_EQ(PIPELINE_OK, Start("bear-vp8a-odd-dimensions.webm")); |
| 2513 Play(); | 2035 Play(); |
| 2514 ASSERT_TRUE(WaitUntilOnEnded()); | 2036 ASSERT_TRUE(WaitUntilOnEnded()); |
| 2515 EXPECT_VIDEO_FORMAT_EQ(last_video_frame_format_, PIXEL_FORMAT_YV12A); | 2037 EXPECT_VIDEO_FORMAT_EQ(last_video_frame_format_, PIXEL_FORMAT_YV12A); |
| 2516 } | 2038 } |
| 2517 | 2039 |
| 2518 // Verify that VP9 video with odd width/height can be played back. | 2040 // Verify that VP9 video with odd width/height can be played back. |
| 2519 TEST_F(PipelineIntegrationTest, BasicPlayback_VP9_Odd_WebM) { | 2041 TEST_P(CommonPipelineIntegrationTest, BasicPlayback_VP9_Odd_WebM) { |
| 2520 ASSERT_EQ(PIPELINE_OK, Start("bear-vp9-odd-dimensions.webm")); | 2042 ASSERT_EQ(PIPELINE_OK, Start("bear-vp9-odd-dimensions.webm")); |
| 2521 Play(); | 2043 Play(); |
| 2522 ASSERT_TRUE(WaitUntilOnEnded()); | 2044 ASSERT_TRUE(WaitUntilOnEnded()); |
| 2523 } | 2045 } |
| 2524 | 2046 |
| 2525 // Verify that VP9 video with alpha channel can be played back. | 2047 // Verify that VP9 video with alpha channel can be played back. |
| 2526 TEST_F(PipelineIntegrationTest, BasicPlayback_VP9A_WebM) { | 2048 TEST_P(CommonPipelineIntegrationTest, BasicPlayback_VP9A_WebM) { |
| 2527 ASSERT_EQ(PIPELINE_OK, Start("bear-vp9a.webm")); | 2049 ASSERT_EQ(PIPELINE_OK, Start("bear-vp9a.webm")); |
| 2528 Play(); | 2050 Play(); |
| 2529 ASSERT_TRUE(WaitUntilOnEnded()); | 2051 ASSERT_TRUE(WaitUntilOnEnded()); |
| 2530 EXPECT_VIDEO_FORMAT_EQ(last_video_frame_format_, PIXEL_FORMAT_YV12A); | 2052 EXPECT_VIDEO_FORMAT_EQ(last_video_frame_format_, PIXEL_FORMAT_YV12A); |
| 2531 } | 2053 } |
| 2532 | 2054 |
| 2533 // Verify that VP9A video with odd width/height can be played back. | 2055 // Verify that VP9A video with odd width/height can be played back. |
| 2534 TEST_F(PipelineIntegrationTest, BasicPlayback_VP9A_Odd_WebM) { | 2056 TEST_P(CommonPipelineIntegrationTest, BasicPlayback_VP9A_Odd_WebM) { |
| 2535 ASSERT_EQ(PIPELINE_OK, Start("bear-vp9a-odd-dimensions.webm")); | 2057 ASSERT_EQ(PIPELINE_OK, Start("bear-vp9a-odd-dimensions.webm")); |
| 2536 Play(); | 2058 Play(); |
| 2537 ASSERT_TRUE(WaitUntilOnEnded()); | 2059 ASSERT_TRUE(WaitUntilOnEnded()); |
| 2538 EXPECT_VIDEO_FORMAT_EQ(last_video_frame_format_, PIXEL_FORMAT_YV12A); | 2060 EXPECT_VIDEO_FORMAT_EQ(last_video_frame_format_, PIXEL_FORMAT_YV12A); |
| 2539 } | 2061 } |
| 2540 | 2062 |
| 2063 // Verify that VP9 video with 4:4:4 subsampling can be played back. |
| 2064 TEST_P(CommonPipelineIntegrationTest, P444_VP9_WebM) { |
| 2065 ASSERT_EQ(PIPELINE_OK, Start("bear-320x240-P444.webm")); |
| 2066 Play(); |
| 2067 ASSERT_TRUE(WaitUntilOnEnded()); |
| 2068 EXPECT_VIDEO_FORMAT_EQ(last_video_frame_format_, PIXEL_FORMAT_YV24); |
| 2069 } |
| 2070 |
| 2071 // Verify that frames of VP9 video in the BT.709 color space have the YV12HD |
| 2072 // format. |
| 2073 TEST_P(CommonPipelineIntegrationTest, BT709_VP9_WebM) { |
| 2074 ASSERT_EQ(PIPELINE_OK, Start("bear-vp9-bt709.webm")); |
| 2075 Play(); |
| 2076 ASSERT_TRUE(WaitUntilOnEnded()); |
| 2077 EXPECT_VIDEO_FORMAT_EQ(last_video_frame_format_, PIXEL_FORMAT_YV12); |
| 2078 EXPECT_COLOR_SPACE_EQ(last_video_frame_color_space_, COLOR_SPACE_HD_REC709); |
| 2079 } |
| 2080 |
| 2081 TEST_P(CommonPipelineIntegrationTest, HD_VP9_WebM) { |
| 2082 ASSERT_EQ(PIPELINE_OK, Start("bear-1280x720.webm", kClockless)); |
| 2083 Play(); |
| 2084 ASSERT_TRUE(WaitUntilOnEnded()); |
| 2085 } |
| 2086 |
| 2087 // Verify that videos with an odd frame size playback successfully. |
| 2088 TEST_P(CommonPipelineIntegrationTest, BasicPlayback_OddVideoSize) { |
| 2089 ASSERT_EQ(PIPELINE_OK, Start("butterfly-853x480.webm")); |
| 2090 Play(); |
| 2091 ASSERT_TRUE(WaitUntilOnEnded()); |
| 2092 } |
| 2093 |
| 2094 // Verify that OPUS audio in a webm which reports a 44.1kHz sample rate plays |
| 2095 // correctly at 48kHz |
| 2096 TEST_P(CommonPipelineIntegrationTest, BasicPlayback_Opus441kHz) { |
| 2097 ASSERT_EQ(PIPELINE_OK, Start("sfx-opus-441.webm")); |
| 2098 Play(); |
| 2099 ASSERT_TRUE(WaitUntilOnEnded()); |
| 2100 EXPECT_EQ(48000, demuxer_->GetFirstStream(DemuxerStream::AUDIO) |
| 2101 ->audio_decoder_config() |
| 2102 .samples_per_second()); |
| 2103 } |
| 2104 |
| 2105 // Same as above but using MediaSource. |
| 2106 TEST_P(CommonPipelineIntegrationTest, BasicPlayback_MediaSource_Opus441kHz) { |
| 2107 MockMediaSource source("sfx-opus-441.webm", kOpusAudioOnlyWebM, |
| 2108 kAppendWholeFile); |
| 2109 EXPECT_EQ(PIPELINE_OK, StartPipelineWithMediaSource(&source)); |
| 2110 source.EndOfStream(); |
| 2111 Play(); |
| 2112 ASSERT_TRUE(WaitUntilOnEnded()); |
| 2113 source.Shutdown(); |
| 2114 Stop(); |
| 2115 EXPECT_EQ(48000, demuxer_->GetFirstStream(DemuxerStream::AUDIO) |
| 2116 ->audio_decoder_config() |
| 2117 .samples_per_second()); |
| 2118 } |
| 2119 |
| 2120 // Ensures audio-only playback with missing or negative timestamps works. Tests |
| 2121 // the common live-streaming case for chained ogg. See http://crbug.com/396864. |
| 2122 TEST_P(CommonPipelineIntegrationTest, BasicPlaybackChainedOgg) { |
| 2123 ASSERT_EQ(PIPELINE_OK, Start("double-sfx.ogg", kUnreliableDuration)); |
| 2124 Play(); |
| 2125 ASSERT_TRUE(WaitUntilOnEnded()); |
| 2126 ASSERT_EQ(base::TimeDelta(), demuxer_->GetStartTime()); |
| 2127 } |
| 2128 |
| 2129 // Tests that we signal ended even when audio runs longer than video track. |
| 2130 TEST_P(CommonPipelineIntegrationTest, BasicPlaybackAudioLongerThanVideo) { |
| 2131 ASSERT_EQ(PIPELINE_OK, Start("bear_audio_longer_than_video.ogv")); |
| 2132 // Audio track is 2000ms. Video track is 1001ms. Duration should be higher |
| 2133 // of the two. |
| 2134 EXPECT_EQ(2000, pipeline_->GetMediaDuration().InMilliseconds()); |
| 2135 Play(); |
| 2136 ASSERT_TRUE(WaitUntilOnEnded()); |
| 2137 } |
| 2138 |
| 2139 // Tests that we signal ended even when audio runs shorter than video track. |
| 2140 TEST_P(CommonPipelineIntegrationTest, BasicPlaybackAudioShorterThanVideo) { |
| 2141 ASSERT_EQ(PIPELINE_OK, Start("bear_audio_shorter_than_video.ogv")); |
| 2142 // Audio track is 500ms. Video track is 1001ms. Duration should be higher of |
| 2143 // the two. |
| 2144 EXPECT_EQ(1001, pipeline_->GetMediaDuration().InMilliseconds()); |
| 2145 Play(); |
| 2146 ASSERT_TRUE(WaitUntilOnEnded()); |
| 2147 } |
| 2148 |
| 2149 TEST_P(CommonPipelineIntegrationTest, BasicPlaybackPositiveStartTime) { |
| 2150 ASSERT_EQ(PIPELINE_OK, Start("nonzero-start-time.webm")); |
| 2151 Play(); |
| 2152 ASSERT_TRUE(WaitUntilOnEnded()); |
| 2153 ASSERT_EQ(base::TimeDelta::FromMicroseconds(396000), |
| 2154 demuxer_->GetStartTime()); |
| 2155 } |
| 2156 |
| 2157 const IntegrationTestData kIntegrationTests[] = { |
| 2158 {PipelineType::Media}, |
| 2159 #if BUILDFLAG(ENABLE_MEDIA_REMOTING) |
| 2160 {PipelineType::MediaRemoting}, |
| 2161 #endif // BUILDFLAG(ENABLE_MEDIA_REMOTING) |
| 2162 }; |
| 2163 |
| 2164 INSTANTIATE_TEST_CASE_P(, |
| 2165 CommonPipelineIntegrationTest, |
| 2166 testing::ValuesIn(kIntegrationTests)); |
| 2167 |
| 2168 // Media Remoting currently doesn't support stream status change without |
| 2169 // restarting pipeline. |
| 2170 TEST_F(PipelineIntegrationTest, ReinitRenderersWhileAudioTrackIsDisabled) { |
| 2171 ASSERT_EQ(PIPELINE_OK, Start("bear-320x240.webm")); |
| 2172 Play(); |
| 2173 |
| 2174 // These get triggered every time playback is resumed. |
| 2175 EXPECT_CALL(*this, OnVideoNaturalSizeChange(gfx::Size(320, 240))) |
| 2176 .Times(AnyNumber()); |
| 2177 EXPECT_CALL(*this, OnVideoOpacityChange(true)).Times(AnyNumber()); |
| 2178 |
| 2179 // Disable the audio track. |
| 2180 std::vector<MediaTrack::Id> track_ids; |
| 2181 pipeline_->OnEnabledAudioTracksChanged(track_ids); |
| 2182 // pipeline.Suspend() releases renderers and pipeline.Resume() recreates and |
| 2183 // reinitializes renderers while the audio track is disabled. |
| 2184 ASSERT_TRUE(Suspend()); |
| 2185 ASSERT_TRUE(Resume(TimestampMs(100))); |
| 2186 // Now re-enable the audio track, playback should continue successfully. |
| 2187 EXPECT_CALL(*this, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)).Times(1); |
| 2188 track_ids.push_back("2"); |
| 2189 pipeline_->OnEnabledAudioTracksChanged(track_ids); |
| 2190 ASSERT_TRUE(WaitUntilCurrentTimeIsAfter(TimestampMs(200))); |
| 2191 |
| 2192 Stop(); |
| 2193 } |
| 2194 |
| 2195 TEST_F(PipelineIntegrationTest, ReinitRenderersWhileVideoTrackIsDisabled) { |
| 2196 ASSERT_EQ(PIPELINE_OK, Start("bear-320x240.webm", kHashed)); |
| 2197 Play(); |
| 2198 |
| 2199 // These get triggered every time playback is resumed. |
| 2200 EXPECT_CALL(*this, OnVideoNaturalSizeChange(gfx::Size(320, 240))) |
| 2201 .Times(AnyNumber()); |
| 2202 EXPECT_CALL(*this, OnVideoOpacityChange(true)).Times(AnyNumber()); |
| 2203 |
| 2204 // Disable the video track. |
| 2205 pipeline_->OnSelectedVideoTrackChanged(base::nullopt); |
| 2206 // pipeline.Suspend() releases renderers and pipeline.Resume() recreates and |
| 2207 // reinitializes renderers while the video track is disabled. |
| 2208 ASSERT_TRUE(Suspend()); |
| 2209 ASSERT_TRUE(Resume(TimestampMs(100))); |
| 2210 // Now re-enable the video track, playback should continue successfully. |
| 2211 pipeline_->OnSelectedVideoTrackChanged(MediaTrack::Id("1")); |
| 2212 ASSERT_TRUE(WaitUntilCurrentTimeIsAfter(TimestampMs(200))); |
| 2213 |
| 2214 Stop(); |
| 2215 } |
| 2216 |
| 2217 TEST_F(PipelineIntegrationTest, MAYBE_EME(BasicPlaybackEncrypted)) { |
| 2218 FakeEncryptedMedia encrypted_media(new KeyProvidingApp()); |
| 2219 set_encrypted_media_init_data_cb( |
| 2220 base::Bind(&FakeEncryptedMedia::OnEncryptedMediaInitData, |
| 2221 base::Unretained(&encrypted_media))); |
| 2222 |
| 2223 ASSERT_EQ(PIPELINE_OK, Start("bear-320x240-av_enc-av.webm", |
| 2224 encrypted_media.GetCdmContext())); |
| 2225 |
| 2226 Play(); |
| 2227 |
| 2228 ASSERT_TRUE(WaitUntilOnEnded()); |
| 2229 Stop(); |
| 2230 } |
| 2231 |
| 2232 TEST_F(PipelineIntegrationTest, |
| 2233 MAYBE_EME(MediaSource_ConfigChange_Encrypted_WebM)) { |
| 2234 MockMediaSource source("bear-320x240-16x9-aspect-av_enc-av.webm", kWebM, |
| 2235 kAppendWholeFile); |
| 2236 FakeEncryptedMedia encrypted_media(new KeyProvidingApp()); |
| 2237 EXPECT_EQ(PIPELINE_OK, |
| 2238 StartPipelineWithEncryptedMedia(&source, &encrypted_media)); |
| 2239 |
| 2240 EXPECT_CALL(*this, OnVideoNaturalSizeChange(gfx::Size(640, 360))).Times(1); |
| 2241 scoped_refptr<DecoderBuffer> second_file = |
| 2242 ReadTestDataFile("bear-640x360-av_enc-av.webm"); |
| 2243 ASSERT_TRUE(source.AppendAtTime(base::TimeDelta::FromSeconds(kAppendTimeSec), |
| 2244 second_file->data(), |
| 2245 second_file->data_size())); |
| 2246 source.EndOfStream(); |
| 2247 |
| 2248 Play(); |
| 2249 EXPECT_TRUE(WaitUntilOnEnded()); |
| 2250 |
| 2251 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); |
| 2252 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); |
| 2253 EXPECT_EQ(kAppendTimeMs + k640WebMFileDurationMs, |
| 2254 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); |
| 2255 |
| 2256 source.Shutdown(); |
| 2257 Stop(); |
| 2258 } |
| 2259 |
| 2260 TEST_F(PipelineIntegrationTest, |
| 2261 MAYBE_EME(MediaSource_ConfigChange_ClearThenEncrypted_WebM)) { |
| 2262 MockMediaSource source("bear-320x240-16x9-aspect.webm", kWebM, |
| 2263 kAppendWholeFile); |
| 2264 FakeEncryptedMedia encrypted_media(new KeyProvidingApp()); |
| 2265 EXPECT_EQ(PIPELINE_OK, |
| 2266 StartPipelineWithEncryptedMedia(&source, &encrypted_media)); |
| 2267 |
| 2268 EXPECT_CALL(*this, OnVideoNaturalSizeChange(gfx::Size(640, 360))).Times(1); |
| 2269 scoped_refptr<DecoderBuffer> second_file = |
| 2270 ReadTestDataFile("bear-640x360-av_enc-av.webm"); |
| 2271 |
| 2272 EXPECT_TRUE(source.AppendAtTime(base::TimeDelta::FromSeconds(kAppendTimeSec), |
| 2273 second_file->data(), |
| 2274 second_file->data_size())); |
| 2275 source.EndOfStream(); |
| 2276 |
| 2277 Play(); |
| 2278 EXPECT_TRUE(WaitUntilOnEnded()); |
| 2279 |
| 2280 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); |
| 2281 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); |
| 2282 EXPECT_EQ(kAppendTimeMs + k640WebMFileDurationMs, |
| 2283 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); |
| 2284 |
| 2285 source.Shutdown(); |
| 2286 Stop(); |
| 2287 } |
| 2288 |
| 2289 // Config change from encrypted to clear is allowed by the demuxer, and is |
| 2290 // supported by the Renderer. |
| 2291 TEST_F(PipelineIntegrationTest, |
| 2292 MAYBE_EME(MediaSource_ConfigChange_EncryptedThenClear_WebM)) { |
| 2293 MockMediaSource source("bear-320x240-16x9-aspect-av_enc-av.webm", kWebM, |
| 2294 kAppendWholeFile); |
| 2295 FakeEncryptedMedia encrypted_media(new KeyProvidingApp()); |
| 2296 EXPECT_EQ(PIPELINE_OK, |
| 2297 StartPipelineWithEncryptedMedia(&source, &encrypted_media)); |
| 2298 |
| 2299 EXPECT_CALL(*this, OnVideoNaturalSizeChange(gfx::Size(640, 360))).Times(1); |
| 2300 scoped_refptr<DecoderBuffer> second_file = |
| 2301 ReadTestDataFile("bear-640x360.webm"); |
| 2302 |
| 2303 ASSERT_TRUE(source.AppendAtTime(base::TimeDelta::FromSeconds(kAppendTimeSec), |
| 2304 second_file->data(), |
| 2305 second_file->data_size())); |
| 2306 source.EndOfStream(); |
| 2307 |
| 2308 Play(); |
| 2309 ASSERT_TRUE(WaitUntilOnEnded()); |
| 2310 |
| 2311 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); |
| 2312 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); |
| 2313 EXPECT_EQ(kAppendTimeMs + k640WebMFileDurationMs, |
| 2314 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); |
| 2315 |
| 2316 source.Shutdown(); |
| 2317 Stop(); |
| 2318 } |
| 2319 |
| 2320 #if BUILDFLAG(USE_PROPRIETARY_CODECS) |
| 2321 #if !defined(DISABLE_CLOCKLESS_TESTS) |
| 2322 class Mp3FastSeekParams { |
| 2323 public: |
| 2324 Mp3FastSeekParams(const char* filename, const char* hash) |
| 2325 : filename(filename), hash(hash) {} |
| 2326 const char* filename; |
| 2327 const char* hash; |
| 2328 }; |
| 2329 |
| 2330 class Mp3FastSeekIntegrationTest |
| 2331 : public PipelineIntegrationTest, |
| 2332 public testing::WithParamInterface<Mp3FastSeekParams> {}; |
| 2333 |
| 2334 TEST_P(Mp3FastSeekIntegrationTest, FastSeekAccuracy_MP3) { |
| 2335 Mp3FastSeekParams config = GetParam(); |
| 2336 ASSERT_EQ(PIPELINE_OK, Start(config.filename, kHashed)); |
| 2337 |
| 2338 // The XING TOC is inaccurate. We don't use it for CBR, we tolerate it for VBR |
| 2339 // (best option for fast seeking; see Mp3SeekFFmpegDemuxerTest). The chosen |
| 2340 // seek time exposes inaccuracy in TOC such that the hash will change if seek |
| 2341 // logic is regressed. See https://crbug.com/545914. |
| 2342 // |
| 2343 // Quick TOC design (not pretty!): |
| 2344 // - All MP3 TOCs are 100 bytes |
| 2345 // - Each byte is read as a uint8_t; value between 0 - 255. |
| 2346 // - The index into this array is the numerator in the ratio: index / 100. |
| 2347 // This fraction represents a playback time as a percentage of duration. |
| 2348 // - The value at the given index is the numerator in the ratio: value / 256. |
| 2349 // This fraction represents a byte offset as a percentage of the file size. |
| 2350 // |
| 2351 // For CBR files, each frame is the same size, so the offset for time of |
| 2352 // (0.98 * duration) should be around (0.98 * file size). This is 250.88 / 256 |
| 2353 // but the numerator will be truncated in the TOC as 250, losing precision. |
| 2354 base::TimeDelta seek_time(0.98 * pipeline_->GetMediaDuration()); |
| 2355 |
| 2356 ASSERT_TRUE(Seek(seek_time)); |
| 2357 Play(); |
| 2358 ASSERT_TRUE(WaitUntilOnEnded()); |
| 2359 |
| 2360 EXPECT_HASH_EQ(config.hash, GetAudioHash()); |
| 2361 } |
| 2362 |
| 2363 INSTANTIATE_TEST_CASE_P( |
| 2364 CBRSeek_HasTOC, |
| 2365 Mp3FastSeekIntegrationTest, |
| 2366 ::testing::Values(Mp3FastSeekParams("bear-audio-10s-CBR-has-TOC.mp3", |
| 2367 "-0.71,0.36,2.96,2.68,2.11,-1.08,"))); |
| 2368 INSTANTIATE_TEST_CASE_P( |
| 2369 CBRSeeks_NoTOC, |
| 2370 Mp3FastSeekIntegrationTest, |
| 2371 ::testing::Values(Mp3FastSeekParams("bear-audio-10s-CBR-no-TOC.mp3", |
| 2372 "0.95,0.56,1.34,0.47,1.77,0.84,"))); |
| 2373 // VBR seeks can be fast *OR* accurate, but not both. We chose fast. |
| 2374 INSTANTIATE_TEST_CASE_P( |
| 2375 VBRSeeks_HasTOC, |
| 2376 Mp3FastSeekIntegrationTest, |
| 2377 ::testing::Values(Mp3FastSeekParams("bear-audio-10s-VBR-has-TOC.mp3", |
| 2378 "-0.15,-0.83,0.54,1.00,1.94,0.93,"))); |
| 2379 INSTANTIATE_TEST_CASE_P( |
| 2380 VBRSeeks_NoTOC, |
| 2381 Mp3FastSeekIntegrationTest, |
| 2382 ::testing::Values(Mp3FastSeekParams("bear-audio-10s-VBR-no-TOC.mp3", |
| 2383 "-0.22,0.80,1.19,0.73,-0.31,-1.12,"))); |
| 2384 #endif // !defined(DISABLE_CLOCKLESS_TESTS) |
| 2385 |
| 2386 TEST_F(PipelineIntegrationTest, |
| 2387 MAYBE_EME(MediaSource_ConfigChange_Encrypted_MP4_CENC_VideoOnly)) { |
| 2388 MockMediaSource source("bear-640x360-v_frag-cenc.mp4", kMP4Video, |
| 2389 kAppendWholeFile); |
| 2390 FakeEncryptedMedia encrypted_media(new KeyProvidingApp()); |
| 2391 EXPECT_EQ(PIPELINE_OK, |
| 2392 StartPipelineWithEncryptedMedia(&source, &encrypted_media)); |
| 2393 |
| 2394 EXPECT_CALL(*this, OnVideoNaturalSizeChange(gfx::Size(1280, 720))).Times(1); |
| 2395 scoped_refptr<DecoderBuffer> second_file = |
| 2396 ReadTestDataFile("bear-1280x720-v_frag-cenc.mp4"); |
| 2397 ASSERT_TRUE(source.AppendAtTime(base::TimeDelta::FromSeconds(kAppendTimeSec), |
| 2398 second_file->data(), |
| 2399 second_file->data_size())); |
| 2400 source.EndOfStream(); |
| 2401 |
| 2402 Play(); |
| 2403 EXPECT_TRUE(WaitUntilOnEnded()); |
| 2404 |
| 2405 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); |
| 2406 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); |
| 2407 EXPECT_EQ(kAppendTimeMs + k1280IsoFileDurationMs, |
| 2408 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); |
| 2409 |
| 2410 source.Shutdown(); |
| 2411 Stop(); |
| 2412 } |
| 2413 |
| 2414 TEST_F(PipelineIntegrationTest, |
| 2415 MAYBE_EME( |
| 2416 MediaSource_ConfigChange_Encrypted_MP4_CENC_KeyRotation_VideoOnly)) { |
| 2417 MockMediaSource source("bear-640x360-v_frag-cenc-key_rotation.mp4", kMP4Video, |
| 2418 kAppendWholeFile); |
| 2419 FakeEncryptedMedia encrypted_media(new RotatingKeyProvidingApp()); |
| 2420 EXPECT_EQ(PIPELINE_OK, |
| 2421 StartPipelineWithEncryptedMedia(&source, &encrypted_media)); |
| 2422 |
| 2423 EXPECT_CALL(*this, OnVideoNaturalSizeChange(gfx::Size(1280, 720))).Times(1); |
| 2424 scoped_refptr<DecoderBuffer> second_file = |
| 2425 ReadTestDataFile("bear-1280x720-v_frag-cenc-key_rotation.mp4"); |
| 2426 ASSERT_TRUE(source.AppendAtTime(base::TimeDelta::FromSeconds(kAppendTimeSec), |
| 2427 second_file->data(), |
| 2428 second_file->data_size())); |
| 2429 source.EndOfStream(); |
| 2430 |
| 2431 Play(); |
| 2432 EXPECT_TRUE(WaitUntilOnEnded()); |
| 2433 |
| 2434 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); |
| 2435 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); |
| 2436 EXPECT_EQ(kAppendTimeMs + k1280IsoFileDurationMs, |
| 2437 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); |
| 2438 |
| 2439 source.Shutdown(); |
| 2440 Stop(); |
| 2441 } |
| 2442 |
| 2443 // Config changes from clear to encrypted are not currently supported. |
| 2444 // TODO(ddorwin): Figure out why this CHECKs in AppendAtTime(). |
| 2445 TEST_F(PipelineIntegrationTest, |
| 2446 DISABLED_MediaSource_ConfigChange_ClearThenEncrypted_MP4_CENC) { |
| 2447 MockMediaSource source("bear-640x360-av_frag.mp4", kMP4Video, |
| 2448 kAppendWholeFile); |
| 2449 FakeEncryptedMedia encrypted_media(new KeyProvidingApp()); |
| 2450 EXPECT_EQ(PIPELINE_OK, |
| 2451 StartPipelineWithEncryptedMedia(&source, &encrypted_media)); |
| 2452 |
| 2453 EXPECT_CALL(*this, OnVideoNaturalSizeChange(gfx::Size(1280, 720))).Times(1); |
| 2454 scoped_refptr<DecoderBuffer> second_file = |
| 2455 ReadTestDataFile("bear-1280x720-v_frag-cenc.mp4"); |
| 2456 ASSERT_FALSE(source.AppendAtTime(base::TimeDelta::FromSeconds(kAppendTimeSec), |
| 2457 second_file->data(), |
| 2458 second_file->data_size())); |
| 2459 |
| 2460 source.EndOfStream(); |
| 2461 |
| 2462 base::RunLoop().Run(); |
| 2463 EXPECT_EQ(CHUNK_DEMUXER_ERROR_APPEND_FAILED, pipeline_status_); |
| 2464 |
| 2465 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); |
| 2466 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); |
| 2467 // The second video was not added, so its time has not been added. |
| 2468 EXPECT_EQ(k640IsoFileDurationMs, |
| 2469 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); |
| 2470 |
| 2471 Play(); |
| 2472 |
| 2473 EXPECT_EQ(CHUNK_DEMUXER_ERROR_APPEND_FAILED, WaitUntilEndedOrError()); |
| 2474 source.Shutdown(); |
| 2475 } |
| 2476 |
| 2477 // Config changes from encrypted to clear are not currently supported. |
| 2478 TEST_F(PipelineIntegrationTest, |
| 2479 MAYBE_EME(MediaSource_ConfigChange_EncryptedThenClear_MP4_CENC)) { |
| 2480 MockMediaSource source("bear-640x360-v_frag-cenc.mp4", kMP4Video, |
| 2481 kAppendWholeFile); |
| 2482 FakeEncryptedMedia encrypted_media(new KeyProvidingApp()); |
| 2483 EXPECT_EQ(PIPELINE_OK, |
| 2484 StartPipelineWithEncryptedMedia(&source, &encrypted_media)); |
| 2485 |
| 2486 scoped_refptr<DecoderBuffer> second_file = |
| 2487 ReadTestDataFile("bear-1280x720-av_frag.mp4"); |
| 2488 |
| 2489 ASSERT_FALSE(source.AppendAtTime(base::TimeDelta::FromSeconds(kAppendTimeSec), |
| 2490 second_file->data(), |
| 2491 second_file->data_size())); |
| 2492 |
| 2493 source.EndOfStream(); |
| 2494 |
| 2495 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); |
| 2496 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); |
| 2497 // The second video was not added, so its time has not been added. |
| 2498 EXPECT_EQ(k640IsoCencFileDurationMs, |
| 2499 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); |
| 2500 |
| 2501 Play(); |
| 2502 |
| 2503 EXPECT_EQ(CHUNK_DEMUXER_ERROR_APPEND_FAILED, WaitUntilEndedOrError()); |
| 2504 source.Shutdown(); |
| 2505 } |
| 2506 |
| 2507 // Verify files which change configuration midstream fail gracefully. |
| 2508 TEST_F(PipelineIntegrationTest, MidStreamConfigChangesFail) { |
| 2509 ASSERT_EQ(PIPELINE_OK, Start("midstream_config_change.mp3")); |
| 2510 Play(); |
| 2511 ASSERT_EQ(WaitUntilEndedOrError(), PIPELINE_ERROR_DECODE); |
| 2512 } |
| 2513 #endif // BUILDFLAG(USE_PROPRIETARY_CODECS) |
| 2514 |
| 2515 TEST_F(PipelineIntegrationTest, MAYBE_EME(EncryptedPlayback_WebM)) { |
| 2516 MockMediaSource source("bear-320x240-av_enc-av.webm", kWebM, 219816); |
| 2517 FakeEncryptedMedia encrypted_media(new KeyProvidingApp()); |
| 2518 EXPECT_EQ(PIPELINE_OK, |
| 2519 StartPipelineWithEncryptedMedia(&source, &encrypted_media)); |
| 2520 |
| 2521 source.EndOfStream(); |
| 2522 ASSERT_EQ(PIPELINE_OK, pipeline_status_); |
| 2523 |
| 2524 Play(); |
| 2525 |
| 2526 ASSERT_TRUE(WaitUntilOnEnded()); |
| 2527 source.Shutdown(); |
| 2528 Stop(); |
| 2529 } |
| 2530 |
| 2531 TEST_F(PipelineIntegrationTest, MAYBE_EME(EncryptedPlayback_ClearStart_WebM)) { |
| 2532 MockMediaSource source("bear-320x240-av_enc-av_clear-1s.webm", kWebM, |
| 2533 kAppendWholeFile); |
| 2534 FakeEncryptedMedia encrypted_media(new KeyProvidingApp()); |
| 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 TEST_F(PipelineIntegrationTest, |
| 2549 MAYBE_EME(EncryptedPlayback_NoEncryptedFrames_WebM)) { |
| 2550 MockMediaSource source("bear-320x240-av_enc-av_clear-all.webm", kWebM, |
| 2551 kAppendWholeFile); |
| 2552 FakeEncryptedMedia encrypted_media(new NoResponseApp()); |
| 2553 EXPECT_EQ(PIPELINE_OK, |
| 2554 StartPipelineWithEncryptedMedia(&source, &encrypted_media)); |
| 2555 |
| 2556 source.EndOfStream(); |
| 2557 ASSERT_EQ(PIPELINE_OK, pipeline_status_); |
| 2558 |
| 2559 Play(); |
| 2560 |
| 2561 ASSERT_TRUE(WaitUntilOnEnded()); |
| 2562 source.Shutdown(); |
| 2563 Stop(); |
| 2564 } |
| 2565 |
| 2566 #if BUILDFLAG(USE_PROPRIETARY_CODECS) |
| 2567 TEST_F(PipelineIntegrationTest, |
| 2568 MAYBE_EME(EncryptedPlayback_MP4_CENC_VideoOnly)) { |
| 2569 MockMediaSource source("bear-1280x720-v_frag-cenc.mp4", kMP4Video, |
| 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_MP4_CENC_AudioOnly)) { |
| 2587 MockMediaSource source("bear-1280x720-a_frag-cenc.mp4", kMP4Audio, |
| 2588 kAppendWholeFile); |
| 2589 FakeEncryptedMedia encrypted_media(new KeyProvidingApp()); |
| 2590 EXPECT_EQ(PIPELINE_OK, |
| 2591 StartPipelineWithEncryptedMedia(&source, &encrypted_media)); |
| 2592 |
| 2593 source.EndOfStream(); |
| 2594 ASSERT_EQ(PIPELINE_OK, pipeline_status_); |
| 2595 |
| 2596 Play(); |
| 2597 |
| 2598 ASSERT_TRUE(WaitUntilOnEnded()); |
| 2599 source.Shutdown(); |
| 2600 Stop(); |
| 2601 } |
| 2602 |
| 2603 TEST_F(PipelineIntegrationTest, |
| 2604 MAYBE_EME(EncryptedPlayback_NoEncryptedFrames_MP4_CENC_VideoOnly)) { |
| 2605 MockMediaSource source("bear-1280x720-v_frag-cenc_clear-all.mp4", kMP4Video, |
| 2606 kAppendWholeFile); |
| 2607 FakeEncryptedMedia encrypted_media(new NoResponseApp()); |
| 2608 EXPECT_EQ(PIPELINE_OK, |
| 2609 StartPipelineWithEncryptedMedia(&source, &encrypted_media)); |
| 2610 |
| 2611 source.EndOfStream(); |
| 2612 |
| 2613 Play(); |
| 2614 |
| 2615 ASSERT_TRUE(WaitUntilOnEnded()); |
| 2616 source.Shutdown(); |
| 2617 Stop(); |
| 2618 } |
| 2619 |
| 2620 TEST_F(PipelineIntegrationTest, |
| 2621 MAYBE_EME(EncryptedPlayback_NoEncryptedFrames_MP4_CENC_AudioOnly)) { |
| 2622 MockMediaSource source("bear-1280x720-a_frag-cenc_clear-all.mp4", kMP4Audio, |
| 2623 kAppendWholeFile); |
| 2624 FakeEncryptedMedia encrypted_media(new NoResponseApp()); |
| 2625 EXPECT_EQ(PIPELINE_OK, |
| 2626 StartPipelineWithEncryptedMedia(&source, &encrypted_media)); |
| 2627 |
| 2628 source.EndOfStream(); |
| 2629 |
| 2630 Play(); |
| 2631 |
| 2632 ASSERT_TRUE(WaitUntilOnEnded()); |
| 2633 source.Shutdown(); |
| 2634 Stop(); |
| 2635 } |
| 2636 |
| 2637 TEST_F(PipelineIntegrationTest, |
| 2638 MAYBE_EME(EncryptedPlayback_MP4_CENC_SENC_Video)) { |
| 2639 MockMediaSource source("bear-640x360-v_frag-cenc-senc.mp4", kMP4Video, |
| 2640 kAppendWholeFile); |
| 2641 FakeEncryptedMedia encrypted_media(new KeyProvidingApp()); |
| 2642 EXPECT_EQ(PIPELINE_OK, |
| 2643 StartPipelineWithEncryptedMedia(&source, &encrypted_media)); |
| 2644 |
| 2645 source.EndOfStream(); |
| 2646 |
| 2647 Play(); |
| 2648 |
| 2649 ASSERT_TRUE(WaitUntilOnEnded()); |
| 2650 source.Shutdown(); |
| 2651 Stop(); |
| 2652 } |
| 2653 |
| 2654 // 'SAIZ' and 'SAIO' boxes contain redundant information which is already |
| 2655 // available in 'SENC' box. Although 'SAIZ' and 'SAIO' boxes are required per |
| 2656 // CENC spec for backward compatibility reasons, but we do not use the two |
| 2657 // boxes if 'SENC' box is present, so the code should work even if the two |
| 2658 // boxes are not present. |
| 2659 TEST_F(PipelineIntegrationTest, |
| 2660 MAYBE_EME(EncryptedPlayback_MP4_CENC_SENC_NO_SAIZ_SAIO_Video)) { |
| 2661 MockMediaSource source("bear-640x360-v_frag-cenc-senc-no-saiz-saio.mp4", |
| 2662 kMP4Video, kAppendWholeFile); |
| 2663 FakeEncryptedMedia encrypted_media(new KeyProvidingApp()); |
| 2664 EXPECT_EQ(PIPELINE_OK, |
| 2665 StartPipelineWithEncryptedMedia(&source, &encrypted_media)); |
| 2666 |
| 2667 source.EndOfStream(); |
| 2668 |
| 2669 Play(); |
| 2670 |
| 2671 ASSERT_TRUE(WaitUntilOnEnded()); |
| 2672 source.Shutdown(); |
| 2673 Stop(); |
| 2674 } |
| 2675 |
| 2676 TEST_F(PipelineIntegrationTest, |
| 2677 MAYBE_EME(EncryptedPlayback_MP4_CENC_KeyRotation_Video)) { |
| 2678 MockMediaSource source("bear-1280x720-v_frag-cenc-key_rotation.mp4", |
| 2679 kMP4Video, kAppendWholeFile); |
| 2680 FakeEncryptedMedia encrypted_media(new RotatingKeyProvidingApp()); |
| 2681 EXPECT_EQ(PIPELINE_OK, |
| 2682 StartPipelineWithEncryptedMedia(&source, &encrypted_media)); |
| 2683 |
| 2684 source.EndOfStream(); |
| 2685 |
| 2686 Play(); |
| 2687 |
| 2688 ASSERT_TRUE(WaitUntilOnEnded()); |
| 2689 source.Shutdown(); |
| 2690 Stop(); |
| 2691 } |
| 2692 |
| 2693 TEST_F(PipelineIntegrationTest, |
| 2694 MAYBE_EME(EncryptedPlayback_MP4_CENC_KeyRotation_Audio)) { |
| 2695 MockMediaSource source("bear-1280x720-a_frag-cenc-key_rotation.mp4", |
| 2696 kMP4Audio, kAppendWholeFile); |
| 2697 FakeEncryptedMedia encrypted_media(new RotatingKeyProvidingApp()); |
| 2698 EXPECT_EQ(PIPELINE_OK, |
| 2699 StartPipelineWithEncryptedMedia(&source, &encrypted_media)); |
| 2700 |
| 2701 source.EndOfStream(); |
| 2702 |
| 2703 Play(); |
| 2704 |
| 2705 ASSERT_TRUE(WaitUntilOnEnded()); |
| 2706 source.Shutdown(); |
| 2707 Stop(); |
| 2708 } |
| 2709 |
| 2710 TEST_F(PipelineIntegrationTest, |
| 2711 MAYBE_EME(EncryptedPlayback_MP4_VP9_CENC_VideoOnly)) { |
| 2712 MockMediaSource source("bear-320x240-v_frag-vp9-cenc.mp4", kMP4VideoVP9, |
| 2713 kAppendWholeFile); |
| 2714 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 2715 switches::kEnableVp9InMp4)) { |
| 2716 ASSERT_EQ(ChunkDemuxer::kNotSupported, source.AddId()); |
| 2717 return; |
| 2718 } |
| 2719 |
| 2720 FakeEncryptedMedia encrypted_media(new KeyProvidingApp()); |
| 2721 EXPECT_EQ(PIPELINE_OK, |
| 2722 StartPipelineWithEncryptedMedia(&source, &encrypted_media)); |
| 2723 |
| 2724 source.EndOfStream(); |
| 2725 |
| 2726 Play(); |
| 2727 |
| 2728 ASSERT_TRUE(WaitUntilOnEnded()); |
| 2729 source.Shutdown(); |
| 2730 Stop(); |
| 2731 } |
| 2732 |
| 2733 #endif // BUILDFLAG(USE_PROPRIETARY_CODECS) |
| 2734 |
| 2541 // Verify that VP8 video with inband text track can be played back. | 2735 // Verify that VP8 video with inband text track can be played back. |
| 2542 TEST_F(PipelineIntegrationTest, MAYBE_TEXT(BasicPlayback_VP8_WebVTT_WebM)) { | 2736 TEST_F(PipelineIntegrationTest, MAYBE_TEXT(BasicPlayback_VP8_WebVTT_WebM)) { |
| 2543 EXPECT_CALL(*this, OnAddTextTrack(_, _)); | 2737 EXPECT_CALL(*this, OnAddTextTrack(_, _)); |
| 2544 ASSERT_EQ(PIPELINE_OK, Start("bear-vp8-webvtt.webm")); | 2738 ASSERT_EQ(PIPELINE_OK, Start("bear-vp8-webvtt.webm")); |
| 2545 Play(); | 2739 Play(); |
| 2546 ASSERT_TRUE(WaitUntilOnEnded()); | 2740 ASSERT_TRUE(WaitUntilOnEnded()); |
| 2547 } | 2741 } |
| 2548 | 2742 |
| 2549 // Verify that VP9 video with 4:4:4 subsampling can be played back. | |
| 2550 TEST_F(PipelineIntegrationTest, P444_VP9_WebM) { | |
| 2551 ASSERT_EQ(PIPELINE_OK, Start("bear-320x240-P444.webm")); | |
| 2552 Play(); | |
| 2553 ASSERT_TRUE(WaitUntilOnEnded()); | |
| 2554 EXPECT_VIDEO_FORMAT_EQ(last_video_frame_format_, PIXEL_FORMAT_YV24); | |
| 2555 } | |
| 2556 | |
| 2557 // Verify that frames of VP9 video in the BT.709 color space have the YV12HD | |
| 2558 // format. | |
| 2559 TEST_F(PipelineIntegrationTest, BT709_VP9_WebM) { | |
| 2560 ASSERT_EQ(PIPELINE_OK, Start("bear-vp9-bt709.webm")); | |
| 2561 Play(); | |
| 2562 ASSERT_TRUE(WaitUntilOnEnded()); | |
| 2563 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); | |
| 2565 } | |
| 2566 | |
| 2567 TEST_F(PipelineIntegrationTest, HD_VP9_WebM) { | |
| 2568 ASSERT_EQ(PIPELINE_OK, Start("bear-1280x720.webm", kClockless)); | |
| 2569 Play(); | |
| 2570 ASSERT_TRUE(WaitUntilOnEnded()); | |
| 2571 } | |
| 2572 | |
| 2573 // Verify that videos with an odd frame size playback successfully. | |
| 2574 TEST_F(PipelineIntegrationTest, BasicPlayback_OddVideoSize) { | |
| 2575 ASSERT_EQ(PIPELINE_OK, Start("butterfly-853x480.webm")); | |
| 2576 Play(); | |
| 2577 ASSERT_TRUE(WaitUntilOnEnded()); | |
| 2578 } | |
| 2579 | |
| 2580 // Verify that OPUS audio in a webm which reports a 44.1kHz sample rate plays | |
| 2581 // correctly at 48kHz | |
| 2582 TEST_F(PipelineIntegrationTest, BasicPlayback_Opus441kHz) { | |
| 2583 ASSERT_EQ(PIPELINE_OK, Start("sfx-opus-441.webm")); | |
| 2584 Play(); | |
| 2585 ASSERT_TRUE(WaitUntilOnEnded()); | |
| 2586 | |
| 2587 EXPECT_EQ(48000, demuxer_->GetFirstStream(DemuxerStream::AUDIO) | |
| 2588 ->audio_decoder_config() | |
| 2589 .samples_per_second()); | |
| 2590 } | |
| 2591 | |
| 2592 // Same as above but using MediaSource. | |
| 2593 TEST_F(PipelineIntegrationTest, BasicPlayback_MediaSource_Opus441kHz) { | |
| 2594 MockMediaSource source("sfx-opus-441.webm", kOpusAudioOnlyWebM, | |
| 2595 kAppendWholeFile); | |
| 2596 EXPECT_EQ(PIPELINE_OK, StartPipelineWithMediaSource(&source)); | |
| 2597 source.EndOfStream(); | |
| 2598 Play(); | |
| 2599 ASSERT_TRUE(WaitUntilOnEnded()); | |
| 2600 source.Shutdown(); | |
| 2601 Stop(); | |
| 2602 EXPECT_EQ(48000, demuxer_->GetFirstStream(DemuxerStream::AUDIO) | |
| 2603 ->audio_decoder_config() | |
| 2604 .samples_per_second()); | |
| 2605 } | |
| 2606 | |
| 2607 // 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. | |
| 2609 TEST_F(PipelineIntegrationTest, BasicPlaybackChainedOgg) { | |
| 2610 ASSERT_EQ(PIPELINE_OK, Start("double-sfx.ogg", kUnreliableDuration)); | |
| 2611 Play(); | |
| 2612 ASSERT_TRUE(WaitUntilOnEnded()); | |
| 2613 ASSERT_EQ(base::TimeDelta(), demuxer_->GetStartTime()); | |
| 2614 } | |
| 2615 | |
| 2616 // Ensures audio-video playback with missing or negative timestamps fails softly | 2743 // Ensures audio-video playback with missing or negative timestamps fails softly |
| 2617 // instead of crashing. See http://crbug.com/396864. | 2744 // instead of crashing. See http://crbug.com/396864. |
| 2618 TEST_F(PipelineIntegrationTest, BasicPlaybackChainedOggVideo) { | 2745 TEST_F(PipelineIntegrationTest, BasicPlaybackChainedOggVideo) { |
| 2619 ASSERT_EQ(PIPELINE_OK, Start("double-bear.ogv", kUnreliableDuration)); | 2746 ASSERT_EQ(PIPELINE_OK, Start("double-bear.ogv", kUnreliableDuration)); |
| 2620 Play(); | 2747 Play(); |
| 2621 EXPECT_EQ(PIPELINE_ERROR_DECODE, WaitUntilEndedOrError()); | 2748 EXPECT_EQ(PIPELINE_ERROR_DECODE, WaitUntilEndedOrError()); |
| 2622 ASSERT_EQ(base::TimeDelta(), demuxer_->GetStartTime()); | 2749 ASSERT_EQ(base::TimeDelta(), demuxer_->GetStartTime()); |
| 2623 } | 2750 } |
| 2624 | 2751 |
| 2625 // Tests that we signal ended even when audio runs longer than video track. | |
| 2626 TEST_F(PipelineIntegrationTest, BasicPlaybackAudioLongerThanVideo) { | |
| 2627 ASSERT_EQ(PIPELINE_OK, Start("bear_audio_longer_than_video.ogv")); | |
| 2628 // Audio track is 2000ms. Video track is 1001ms. Duration should be higher | |
| 2629 // of the two. | |
| 2630 EXPECT_EQ(2000, pipeline_->GetMediaDuration().InMilliseconds()); | |
| 2631 Play(); | |
| 2632 ASSERT_TRUE(WaitUntilOnEnded()); | |
| 2633 } | |
| 2634 | |
| 2635 // Tests that we signal ended even when audio runs shorter than video track. | |
| 2636 TEST_F(PipelineIntegrationTest, BasicPlaybackAudioShorterThanVideo) { | |
| 2637 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 | |
| 2639 // the two. | |
| 2640 EXPECT_EQ(1001, pipeline_->GetMediaDuration().InMilliseconds()); | |
| 2641 Play(); | |
| 2642 ASSERT_TRUE(WaitUntilOnEnded()); | |
| 2643 } | |
| 2644 | |
| 2645 TEST_F(PipelineIntegrationTest, BasicPlaybackPositiveStartTime) { | |
| 2646 ASSERT_EQ(PIPELINE_OK, Start("nonzero-start-time.webm")); | |
| 2647 Play(); | |
| 2648 ASSERT_TRUE(WaitUntilOnEnded()); | |
| 2649 ASSERT_EQ(base::TimeDelta::FromMicroseconds(396000), | |
| 2650 demuxer_->GetStartTime()); | |
| 2651 } | |
| 2652 | |
| 2653 } // namespace media | 2752 } // namespace media |
| OLD | NEW |