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 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
694 | 694 |
695 PipelineStatus StartPipelineWithMediaSource(MockMediaSource* source, | 695 PipelineStatus StartPipelineWithMediaSource(MockMediaSource* source, |
696 uint8_t test_type) { | 696 uint8_t test_type) { |
697 hashing_enabled_ = test_type & kHashed; | 697 hashing_enabled_ = test_type & kHashed; |
698 clockless_playback_ = test_type & kClockless; | 698 clockless_playback_ = test_type & kClockless; |
699 | 699 |
700 EXPECT_CALL(*source, InitSegmentReceived(_)).Times(AtLeast(1)); | 700 EXPECT_CALL(*source, InitSegmentReceived(_)).Times(AtLeast(1)); |
701 EXPECT_CALL(*this, OnMetadata(_)) | 701 EXPECT_CALL(*this, OnMetadata(_)) |
702 .Times(AtMost(1)) | 702 .Times(AtMost(1)) |
703 .WillRepeatedly(SaveArg<0>(&metadata_)); | 703 .WillRepeatedly(SaveArg<0>(&metadata_)); |
704 EXPECT_CALL(*this, OnBufferingStateChanged(BUFFERING_HAVE_ENOUGH)) | 704 EXPECT_CALL(*this, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)) |
705 .Times(AnyNumber()); | 705 .Times(AnyNumber()); |
706 EXPECT_CALL(*this, OnBufferingStateChanged(BUFFERING_HAVE_NOTHING)) | 706 EXPECT_CALL(*this, OnBufferingStateChange(BUFFERING_HAVE_NOTHING)) |
707 .Times(AnyNumber()); | 707 .Times(AnyNumber()); |
708 | 708 |
709 // Encrypted content not used, so this is never called. | 709 // Encrypted content not used, so this is never called. |
710 EXPECT_CALL(*this, OnWaitingForDecryptionKey()).Times(0); | 710 EXPECT_CALL(*this, OnWaitingForDecryptionKey()).Times(0); |
711 | 711 |
712 demuxer_ = source->GetDemuxer(); | 712 demuxer_ = source->GetDemuxer(); |
713 pipeline_->Start( | 713 pipeline_->Start(demuxer_.get(), CreateRenderer(), this, |
714 demuxer_.get(), CreateRenderer(), | 714 base::Bind(&PipelineIntegrationTest::OnStatusCallback, |
715 base::Bind(&PipelineIntegrationTest::OnEnded, base::Unretained(this)), | 715 base::Unretained(this))); |
716 base::Bind(&PipelineIntegrationTest::OnError, base::Unretained(this)), | |
717 base::Bind(&PipelineIntegrationTest::OnStatusCallback, | |
718 base::Unretained(this)), | |
719 base::Bind(&PipelineIntegrationTest::OnMetadata, | |
720 base::Unretained(this)), | |
721 base::Bind(&PipelineIntegrationTest::OnBufferingStateChanged, | |
722 base::Unretained(this)), | |
723 base::Closure(), base::Bind(&PipelineIntegrationTest::OnAddTextTrack, | |
724 base::Unretained(this)), | |
725 base::Bind(&PipelineIntegrationTest::OnWaitingForDecryptionKey, | |
726 base::Unretained(this))); | |
727 message_loop_.Run(); | 716 message_loop_.Run(); |
728 EXPECT_EQ(PIPELINE_OK, pipeline_status_); | 717 EXPECT_EQ(PIPELINE_OK, pipeline_status_); |
729 return pipeline_status_; | 718 return pipeline_status_; |
730 } | 719 } |
731 | 720 |
732 void StartPipelineWithEncryptedMedia(MockMediaSource* source, | 721 void StartPipelineWithEncryptedMedia(MockMediaSource* source, |
733 FakeEncryptedMedia* encrypted_media) { | 722 FakeEncryptedMedia* encrypted_media) { |
734 EXPECT_CALL(*source, InitSegmentReceived(_)).Times(AtLeast(1)); | 723 EXPECT_CALL(*source, InitSegmentReceived(_)).Times(AtLeast(1)); |
735 EXPECT_CALL(*this, OnMetadata(_)) | 724 EXPECT_CALL(*this, OnMetadata(_)) |
736 .Times(AtMost(1)) | 725 .Times(AtMost(1)) |
737 .WillRepeatedly(SaveArg<0>(&metadata_)); | 726 .WillRepeatedly(SaveArg<0>(&metadata_)); |
738 EXPECT_CALL(*this, OnBufferingStateChanged(BUFFERING_HAVE_ENOUGH)) | 727 EXPECT_CALL(*this, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)) |
739 .Times(AnyNumber()); | 728 .Times(AnyNumber()); |
740 EXPECT_CALL(*this, OnBufferingStateChanged(BUFFERING_HAVE_NOTHING)) | 729 EXPECT_CALL(*this, OnBufferingStateChange(BUFFERING_HAVE_NOTHING)) |
741 .Times(AnyNumber()); | 730 .Times(AnyNumber()); |
742 EXPECT_CALL(*this, DecryptorAttached(true)); | 731 EXPECT_CALL(*this, DecryptorAttached(true)); |
743 | 732 |
744 // Encrypted content used but keys provided in advance, so this is | 733 // Encrypted content used but keys provided in advance, so this is |
745 // never called. | 734 // never called. |
746 EXPECT_CALL(*this, OnWaitingForDecryptionKey()).Times(0); | 735 EXPECT_CALL(*this, OnWaitingForDecryptionKey()).Times(0); |
747 | 736 |
748 demuxer_ = source->GetDemuxer(); | 737 demuxer_ = source->GetDemuxer(); |
749 | 738 |
750 pipeline_->SetCdm(encrypted_media->GetCdmContext(), | 739 pipeline_->SetCdm(encrypted_media->GetCdmContext(), |
751 base::Bind(&PipelineIntegrationTest::DecryptorAttached, | 740 base::Bind(&PipelineIntegrationTest::DecryptorAttached, |
752 base::Unretained(this))); | 741 base::Unretained(this))); |
753 | 742 |
754 pipeline_->Start( | 743 pipeline_->Start(demuxer_.get(), CreateRenderer(), this, |
755 demuxer_.get(), CreateRenderer(), | 744 base::Bind(&PipelineIntegrationTest::OnStatusCallback, |
756 base::Bind(&PipelineIntegrationTest::OnEnded, base::Unretained(this)), | 745 base::Unretained(this))); |
757 base::Bind(&PipelineIntegrationTest::OnError, base::Unretained(this)), | |
758 base::Bind(&PipelineIntegrationTest::OnStatusCallback, | |
759 base::Unretained(this)), | |
760 base::Bind(&PipelineIntegrationTest::OnMetadata, | |
761 base::Unretained(this)), | |
762 base::Bind(&PipelineIntegrationTest::OnBufferingStateChanged, | |
763 base::Unretained(this)), | |
764 base::Closure(), base::Bind(&PipelineIntegrationTest::OnAddTextTrack, | |
765 base::Unretained(this)), | |
766 base::Bind(&PipelineIntegrationTest::OnWaitingForDecryptionKey, | |
767 base::Unretained(this))); | |
768 | 746 |
769 source->set_encrypted_media_init_data_cb( | 747 source->set_encrypted_media_init_data_cb( |
770 base::Bind(&FakeEncryptedMedia::OnEncryptedMediaInitData, | 748 base::Bind(&FakeEncryptedMedia::OnEncryptedMediaInitData, |
771 base::Unretained(encrypted_media))); | 749 base::Unretained(encrypted_media))); |
772 | 750 |
773 message_loop_.Run(); | 751 message_loop_.Run(); |
774 EXPECT_EQ(PIPELINE_OK, pipeline_status_); | 752 EXPECT_EQ(PIPELINE_OK, pipeline_status_); |
775 } | 753 } |
776 | 754 |
777 // Verifies that seeking works properly for ChunkDemuxer when the | 755 // Verifies that seeking works properly for ChunkDemuxer when the |
(...skipping 1389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2167 | 2145 |
2168 TEST_F(PipelineIntegrationTest, BasicPlaybackPositiveStartTime) { | 2146 TEST_F(PipelineIntegrationTest, BasicPlaybackPositiveStartTime) { |
2169 ASSERT_EQ(PIPELINE_OK, Start("nonzero-start-time.webm")); | 2147 ASSERT_EQ(PIPELINE_OK, Start("nonzero-start-time.webm")); |
2170 Play(); | 2148 Play(); |
2171 ASSERT_TRUE(WaitUntilOnEnded()); | 2149 ASSERT_TRUE(WaitUntilOnEnded()); |
2172 ASSERT_EQ(base::TimeDelta::FromMicroseconds(396000), | 2150 ASSERT_EQ(base::TimeDelta::FromMicroseconds(396000), |
2173 demuxer_->GetStartTime()); | 2151 demuxer_->GetStartTime()); |
2174 } | 2152 } |
2175 | 2153 |
2176 } // namespace media | 2154 } // namespace media |
OLD | NEW |