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