| 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 694 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 705 | 705 |
| 706 PipelineStatus StartPipelineWithMediaSource(MockMediaSource* source, | 706 PipelineStatus StartPipelineWithMediaSource(MockMediaSource* source, |
| 707 uint8_t test_type) { | 707 uint8_t test_type) { |
| 708 hashing_enabled_ = test_type & kHashed; | 708 hashing_enabled_ = test_type & kHashed; |
| 709 clockless_playback_ = test_type & kClockless; | 709 clockless_playback_ = test_type & kClockless; |
| 710 | 710 |
| 711 EXPECT_CALL(*source, InitSegmentReceived(_)).Times(AtLeast(1)); | 711 EXPECT_CALL(*source, InitSegmentReceived(_)).Times(AtLeast(1)); |
| 712 EXPECT_CALL(*this, OnMetadata(_)) | 712 EXPECT_CALL(*this, OnMetadata(_)) |
| 713 .Times(AtMost(1)) | 713 .Times(AtMost(1)) |
| 714 .WillRepeatedly(SaveArg<0>(&metadata_)); | 714 .WillRepeatedly(SaveArg<0>(&metadata_)); |
| 715 EXPECT_CALL(*this, OnBufferingStateChanged(BUFFERING_HAVE_ENOUGH)) | 715 EXPECT_CALL(*this, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)) |
| 716 .Times(AnyNumber()); | 716 .Times(AnyNumber()); |
| 717 EXPECT_CALL(*this, OnBufferingStateChanged(BUFFERING_HAVE_NOTHING)) | 717 EXPECT_CALL(*this, OnBufferingStateChange(BUFFERING_HAVE_NOTHING)) |
| 718 .Times(AnyNumber()); | 718 .Times(AnyNumber()); |
| 719 | 719 |
| 720 // Encrypted content not used, so this is never called. | 720 // Encrypted content not used, so this is never called. |
| 721 EXPECT_CALL(*this, OnWaitingForDecryptionKey()).Times(0); | 721 EXPECT_CALL(*this, OnWaitingForDecryptionKey()).Times(0); |
| 722 | 722 |
| 723 demuxer_ = source->GetDemuxer(); | 723 demuxer_ = source->GetDemuxer(); |
| 724 pipeline_->Start( | 724 pipeline_->Start(demuxer_.get(), CreateRenderer(), this, |
| 725 demuxer_.get(), CreateRenderer(), | 725 base::Bind(&PipelineIntegrationTest::OnStatusCallback, |
| 726 base::Bind(&PipelineIntegrationTest::OnEnded, base::Unretained(this)), | 726 base::Unretained(this))); |
| 727 base::Bind(&PipelineIntegrationTest::OnError, base::Unretained(this)), | |
| 728 base::Bind(&PipelineIntegrationTest::OnStatusCallback, | |
| 729 base::Unretained(this)), | |
| 730 base::Bind(&PipelineIntegrationTest::OnMetadata, | |
| 731 base::Unretained(this)), | |
| 732 base::Bind(&PipelineIntegrationTest::OnBufferingStateChanged, | |
| 733 base::Unretained(this)), | |
| 734 base::Closure(), base::Bind(&PipelineIntegrationTest::OnAddTextTrack, | |
| 735 base::Unretained(this)), | |
| 736 base::Bind(&PipelineIntegrationTest::OnWaitingForDecryptionKey, | |
| 737 base::Unretained(this))); | |
| 738 message_loop_.Run(); | 727 message_loop_.Run(); |
| 739 EXPECT_EQ(PIPELINE_OK, pipeline_status_); | 728 EXPECT_EQ(PIPELINE_OK, pipeline_status_); |
| 740 return pipeline_status_; | 729 return pipeline_status_; |
| 741 } | 730 } |
| 742 | 731 |
| 743 void StartPipelineWithEncryptedMedia(MockMediaSource* source, | 732 void StartPipelineWithEncryptedMedia(MockMediaSource* source, |
| 744 FakeEncryptedMedia* encrypted_media) { | 733 FakeEncryptedMedia* encrypted_media) { |
| 745 EXPECT_CALL(*source, InitSegmentReceived(_)).Times(AtLeast(1)); | 734 EXPECT_CALL(*source, InitSegmentReceived(_)).Times(AtLeast(1)); |
| 746 EXPECT_CALL(*this, OnMetadata(_)) | 735 EXPECT_CALL(*this, OnMetadata(_)) |
| 747 .Times(AtMost(1)) | 736 .Times(AtMost(1)) |
| 748 .WillRepeatedly(SaveArg<0>(&metadata_)); | 737 .WillRepeatedly(SaveArg<0>(&metadata_)); |
| 749 EXPECT_CALL(*this, OnBufferingStateChanged(BUFFERING_HAVE_ENOUGH)) | 738 EXPECT_CALL(*this, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)) |
| 750 .Times(AnyNumber()); | 739 .Times(AnyNumber()); |
| 751 EXPECT_CALL(*this, OnBufferingStateChanged(BUFFERING_HAVE_NOTHING)) | 740 EXPECT_CALL(*this, OnBufferingStateChange(BUFFERING_HAVE_NOTHING)) |
| 752 .Times(AnyNumber()); | 741 .Times(AnyNumber()); |
| 753 EXPECT_CALL(*this, DecryptorAttached(true)); | 742 EXPECT_CALL(*this, DecryptorAttached(true)); |
| 754 | 743 |
| 755 // Encrypted content used but keys provided in advance, so this is | 744 // Encrypted content used but keys provided in advance, so this is |
| 756 // never called. | 745 // never called. |
| 757 EXPECT_CALL(*this, OnWaitingForDecryptionKey()).Times(0); | 746 EXPECT_CALL(*this, OnWaitingForDecryptionKey()).Times(0); |
| 758 | 747 |
| 759 demuxer_ = source->GetDemuxer(); | 748 demuxer_ = source->GetDemuxer(); |
| 760 | 749 |
| 761 pipeline_->SetCdm(encrypted_media->GetCdmContext(), | 750 pipeline_->SetCdm(encrypted_media->GetCdmContext(), |
| 762 base::Bind(&PipelineIntegrationTest::DecryptorAttached, | 751 base::Bind(&PipelineIntegrationTest::DecryptorAttached, |
| 763 base::Unretained(this))); | 752 base::Unretained(this))); |
| 764 | 753 |
| 765 pipeline_->Start( | 754 pipeline_->Start(demuxer_.get(), CreateRenderer(), this, |
| 766 demuxer_.get(), CreateRenderer(), | 755 base::Bind(&PipelineIntegrationTest::OnStatusCallback, |
| 767 base::Bind(&PipelineIntegrationTest::OnEnded, base::Unretained(this)), | 756 base::Unretained(this))); |
| 768 base::Bind(&PipelineIntegrationTest::OnError, base::Unretained(this)), | |
| 769 base::Bind(&PipelineIntegrationTest::OnStatusCallback, | |
| 770 base::Unretained(this)), | |
| 771 base::Bind(&PipelineIntegrationTest::OnMetadata, | |
| 772 base::Unretained(this)), | |
| 773 base::Bind(&PipelineIntegrationTest::OnBufferingStateChanged, | |
| 774 base::Unretained(this)), | |
| 775 base::Closure(), base::Bind(&PipelineIntegrationTest::OnAddTextTrack, | |
| 776 base::Unretained(this)), | |
| 777 base::Bind(&PipelineIntegrationTest::OnWaitingForDecryptionKey, | |
| 778 base::Unretained(this))); | |
| 779 | 757 |
| 780 source->set_encrypted_media_init_data_cb( | 758 source->set_encrypted_media_init_data_cb( |
| 781 base::Bind(&FakeEncryptedMedia::OnEncryptedMediaInitData, | 759 base::Bind(&FakeEncryptedMedia::OnEncryptedMediaInitData, |
| 782 base::Unretained(encrypted_media))); | 760 base::Unretained(encrypted_media))); |
| 783 | 761 |
| 784 message_loop_.Run(); | 762 message_loop_.Run(); |
| 785 EXPECT_EQ(PIPELINE_OK, pipeline_status_); | 763 EXPECT_EQ(PIPELINE_OK, pipeline_status_); |
| 786 } | 764 } |
| 787 | 765 |
| 788 // Verifies that seeking works properly for ChunkDemuxer when the | 766 // Verifies that seeking works properly for ChunkDemuxer when the |
| (...skipping 1389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2178 | 2156 |
| 2179 TEST_F(PipelineIntegrationTest, BasicPlaybackPositiveStartTime) { | 2157 TEST_F(PipelineIntegrationTest, BasicPlaybackPositiveStartTime) { |
| 2180 ASSERT_EQ(PIPELINE_OK, Start("nonzero-start-time.webm")); | 2158 ASSERT_EQ(PIPELINE_OK, Start("nonzero-start-time.webm")); |
| 2181 Play(); | 2159 Play(); |
| 2182 ASSERT_TRUE(WaitUntilOnEnded()); | 2160 ASSERT_TRUE(WaitUntilOnEnded()); |
| 2183 ASSERT_EQ(base::TimeDelta::FromMicroseconds(396000), | 2161 ASSERT_EQ(base::TimeDelta::FromMicroseconds(396000), |
| 2184 demuxer_->GetStartTime()); | 2162 demuxer_->GetStartTime()); |
| 2185 } | 2163 } |
| 2186 | 2164 |
| 2187 } // namespace media | 2165 } // namespace media |
| OLD | NEW |