| 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 "media/filters/pipeline_integration_test_base.h" | 5 #include "media/filters/pipeline_integration_test_base.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 const uint8 kInitData[] = { 0x69, 0x6e, 0x69, 0x74 }; | 26 const uint8 kInitData[] = { 0x69, 0x6e, 0x69, 0x74 }; |
| 27 | 27 |
| 28 const char kWebM[] = "video/webm; codecs=\"vp8,vorbis\""; | 28 const char kWebM[] = "video/webm; codecs=\"vp8,vorbis\""; |
| 29 const char kWebMVP9[] = "video/webm; codecs=\"vp9\""; | 29 const char kWebMVP9[] = "video/webm; codecs=\"vp9\""; |
| 30 const char kAudioOnlyWebM[] = "video/webm; codecs=\"vorbis\""; | 30 const char kAudioOnlyWebM[] = "video/webm; codecs=\"vorbis\""; |
| 31 const char kOpusAudioOnlyWebM[] = "video/webm; codecs=\"opus\""; | 31 const char kOpusAudioOnlyWebM[] = "video/webm; codecs=\"opus\""; |
| 32 const char kVideoOnlyWebM[] = "video/webm; codecs=\"vp8\""; | 32 const char kVideoOnlyWebM[] = "video/webm; codecs=\"vp8\""; |
| 33 const char kMP4VideoType[] = "video/mp4"; | 33 const char kMP4VideoType[] = "video/mp4"; |
| 34 const char kMP4AudioType[] = "audio/mp4"; | 34 const char kMP4AudioType[] = "audio/mp4"; |
| 35 #if defined(USE_PROPRIETARY_CODECS) | 35 #if defined(USE_PROPRIETARY_CODECS) |
| 36 const char kADTS[] = "audio/aac"; |
| 36 const char kMP4[] = "video/mp4; codecs=\"avc1.4D4041,mp4a.40.2\""; | 37 const char kMP4[] = "video/mp4; codecs=\"avc1.4D4041,mp4a.40.2\""; |
| 37 const char kMP4Video[] = "video/mp4; codecs=\"avc1.4D4041\""; | 38 const char kMP4Video[] = "video/mp4; codecs=\"avc1.4D4041\""; |
| 38 const char kMP4VideoAVC3[] = "video/mp4; codecs=\"avc3.64001f\""; | 39 const char kMP4VideoAVC3[] = "video/mp4; codecs=\"avc3.64001f\""; |
| 39 const char kMP4Audio[] = "audio/mp4; codecs=\"mp4a.40.2\""; | 40 const char kMP4Audio[] = "audio/mp4; codecs=\"mp4a.40.2\""; |
| 40 const char kMP3[] = "audio/mpeg"; | 41 const char kMP3[] = "audio/mpeg"; |
| 41 #endif // defined(USE_PROPRIETARY_CODECS) | 42 #endif // defined(USE_PROPRIETARY_CODECS) |
| 42 | 43 |
| 43 // Key used to encrypt test files. | 44 // Key used to encrypt test files. |
| 44 const uint8 kSecretKey[] = { | 45 const uint8 kSecretKey[] = { |
| 45 0xeb, 0xdd, 0x62, 0xf1, 0x68, 0x14, 0xd2, 0x7b, | 46 0xeb, 0xdd, 0x62, 0xf1, 0x68, 0x14, 0xd2, 0x7b, |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 DCHECK_LT(current_position_, file_data_->data_size()); | 299 DCHECK_LT(current_position_, file_data_->data_size()); |
| 299 DCHECK_LE(current_position_ + size, file_data_->data_size()); | 300 DCHECK_LE(current_position_ + size, file_data_->data_size()); |
| 300 | 301 |
| 301 // TODO(wolenetz): Test timestamp offset updating once "sequence" append | 302 // TODO(wolenetz): Test timestamp offset updating once "sequence" append |
| 302 // mode processing is implemented. See http://crbug.com/249422. | 303 // mode processing is implemented. See http://crbug.com/249422. |
| 303 base::TimeDelta timestamp_offset; | 304 base::TimeDelta timestamp_offset; |
| 304 chunk_demuxer_->AppendData( | 305 chunk_demuxer_->AppendData( |
| 305 kSourceId, file_data_->data() + current_position_, size, | 306 kSourceId, file_data_->data() + current_position_, size, |
| 306 base::TimeDelta(), kInfiniteDuration(), ×tamp_offset); | 307 base::TimeDelta(), kInfiniteDuration(), ×tamp_offset); |
| 307 current_position_ += size; | 308 current_position_ += size; |
| 309 last_timestamp_offset_ = timestamp_offset; |
| 308 } | 310 } |
| 309 | 311 |
| 310 void AppendAtTime(const base::TimeDelta& timestampOffset, | 312 void AppendAtTime(base::TimeDelta timestamp_offset, |
| 311 const uint8* pData, int size) { | 313 const uint8* pData, |
| 312 base::TimeDelta timestamp_offset = timestampOffset; | 314 int size) { |
| 313 CHECK(!chunk_demuxer_->IsParsingMediaSegment(kSourceId)); | 315 CHECK(!chunk_demuxer_->IsParsingMediaSegment(kSourceId)); |
| 314 chunk_demuxer_->AppendData(kSourceId, pData, size, | 316 chunk_demuxer_->AppendData(kSourceId, pData, size, |
| 315 base::TimeDelta(), kInfiniteDuration(), | 317 base::TimeDelta(), kInfiniteDuration(), |
| 316 ×tamp_offset); | 318 ×tamp_offset); |
| 319 last_timestamp_offset_ = timestamp_offset; |
| 317 } | 320 } |
| 318 | 321 |
| 319 void EndOfStream() { | 322 void EndOfStream() { |
| 320 chunk_demuxer_->MarkEndOfStream(PIPELINE_OK); | 323 chunk_demuxer_->MarkEndOfStream(PIPELINE_OK); |
| 321 } | 324 } |
| 322 | 325 |
| 323 void Abort() { | 326 void Abort() { |
| 324 if (!chunk_demuxer_) | 327 if (!chunk_demuxer_) |
| 325 return; | 328 return; |
| 326 chunk_demuxer_->Shutdown(); | 329 chunk_demuxer_->Shutdown(); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 AppendData(initial_append_size_); | 365 AppendData(initial_append_size_); |
| 363 } | 366 } |
| 364 | 367 |
| 365 void DemuxerNeedKey(const std::string& type, | 368 void DemuxerNeedKey(const std::string& type, |
| 366 const std::vector<uint8>& init_data) { | 369 const std::vector<uint8>& init_data) { |
| 367 DCHECK(!init_data.empty()); | 370 DCHECK(!init_data.empty()); |
| 368 CHECK(!need_key_cb_.is_null()); | 371 CHECK(!need_key_cb_.is_null()); |
| 369 need_key_cb_.Run(type, init_data); | 372 need_key_cb_.Run(type, init_data); |
| 370 } | 373 } |
| 371 | 374 |
| 375 base::TimeDelta last_timestamp_offset() const { |
| 376 return last_timestamp_offset_; |
| 377 } |
| 378 |
| 372 private: | 379 private: |
| 373 base::FilePath file_path_; | 380 base::FilePath file_path_; |
| 374 scoped_refptr<DecoderBuffer> file_data_; | 381 scoped_refptr<DecoderBuffer> file_data_; |
| 375 int current_position_; | 382 int current_position_; |
| 376 int initial_append_size_; | 383 int initial_append_size_; |
| 377 std::string mimetype_; | 384 std::string mimetype_; |
| 378 ChunkDemuxer* chunk_demuxer_; | 385 ChunkDemuxer* chunk_demuxer_; |
| 379 scoped_ptr<Demuxer> owned_chunk_demuxer_; | 386 scoped_ptr<Demuxer> owned_chunk_demuxer_; |
| 380 Demuxer::NeedKeyCB need_key_cb_; | 387 Demuxer::NeedKeyCB need_key_cb_; |
| 388 base::TimeDelta last_timestamp_offset_; |
| 381 }; | 389 }; |
| 382 | 390 |
| 383 class PipelineIntegrationTest | 391 class PipelineIntegrationTest |
| 384 : public testing::Test, | 392 : public testing::Test, |
| 385 public PipelineIntegrationTestBase { | 393 public PipelineIntegrationTestBase { |
| 386 public: | 394 public: |
| 387 void StartPipelineWithMediaSource(MockMediaSource* source) { | 395 void StartPipelineWithMediaSource(MockMediaSource* source) { |
| 388 EXPECT_CALL(*this, OnBufferingState(Pipeline::kHaveMetadata)) | 396 EXPECT_CALL(*this, OnBufferingState(Pipeline::kHaveMetadata)) |
| 389 .Times(AtMost(1)); | 397 .Times(AtMost(1)); |
| 390 EXPECT_CALL(*this, OnBufferingState(Pipeline::kPrerollCompleted)) | 398 EXPECT_CALL(*this, OnBufferingState(Pipeline::kPrerollCompleted)) |
| (...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 708 EXPECT_EQ(k320WebMFileDurationMs, | 716 EXPECT_EQ(k320WebMFileDurationMs, |
| 709 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); | 717 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); |
| 710 | 718 |
| 711 Play(); | 719 Play(); |
| 712 | 720 |
| 713 EXPECT_EQ(PIPELINE_ERROR_DECODE, WaitUntilEndedOrError()); | 721 EXPECT_EQ(PIPELINE_ERROR_DECODE, WaitUntilEndedOrError()); |
| 714 source.Abort(); | 722 source.Abort(); |
| 715 } | 723 } |
| 716 | 724 |
| 717 #if defined(USE_PROPRIETARY_CODECS) | 725 #if defined(USE_PROPRIETARY_CODECS) |
| 718 TEST_F(PipelineIntegrationTest, MediaSource_MP3) { | 726 TEST_F(PipelineIntegrationTest, MediaSource_ADTS) { |
| 719 MockMediaSource source("sfx.mp3", kMP3, kAppendWholeFile); | 727 MockMediaSource source("sfx.adts", kADTS, kAppendWholeFile); |
| 720 StartPipelineWithMediaSource(&source); | 728 StartPipelineWithMediaSource(&source); |
| 721 source.EndOfStream(); | 729 source.EndOfStream(); |
| 722 | 730 |
| 731 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); |
| 732 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); |
| 733 EXPECT_EQ(325, pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); |
| 734 |
| 723 Play(); | 735 Play(); |
| 724 | 736 |
| 725 EXPECT_TRUE(WaitUntilOnEnded()); | 737 EXPECT_TRUE(WaitUntilOnEnded()); |
| 726 } | 738 } |
| 727 | 739 |
| 740 TEST_F(PipelineIntegrationTest, MediaSource_ADTS_TimestampOffset) { |
| 741 MockMediaSource source("sfx.adts", kADTS, kAppendWholeFile); |
| 742 StartPipelineWithMediaSource(&source); |
| 743 EXPECT_EQ(325, source.last_timestamp_offset().InMilliseconds()); |
| 744 |
| 745 scoped_refptr<DecoderBuffer> second_file = ReadTestDataFile("sfx.adts"); |
| 746 source.AppendAtTime( |
| 747 source.last_timestamp_offset() - base::TimeDelta::FromMilliseconds(10), |
| 748 second_file->data(), |
| 749 second_file->data_size()); |
| 750 source.EndOfStream(); |
| 751 |
| 752 EXPECT_EQ(640, source.last_timestamp_offset().InMilliseconds()); |
| 753 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); |
| 754 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); |
| 755 EXPECT_EQ(640, pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); |
| 756 |
| 757 Play(); |
| 758 |
| 759 EXPECT_TRUE(WaitUntilOnEnded()); |
| 760 } |
| 761 |
| 762 TEST_F(PipelineIntegrationTest, MediaSource_MP3) { |
| 763 MockMediaSource source("sfx.mp3", kMP3, kAppendWholeFile); |
| 764 StartPipelineWithMediaSource(&source); |
| 765 source.EndOfStream(); |
| 766 |
| 767 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); |
| 768 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); |
| 769 EXPECT_EQ(339, pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); |
| 770 |
| 771 Play(); |
| 772 |
| 773 EXPECT_TRUE(WaitUntilOnEnded()); |
| 774 } |
| 775 |
| 776 TEST_F(PipelineIntegrationTest, MediaSource_MP3_TimestampOffset) { |
| 777 MockMediaSource source("sfx.mp3", kMP3, kAppendWholeFile); |
| 778 StartPipelineWithMediaSource(&source); |
| 779 EXPECT_EQ(339, source.last_timestamp_offset().InMilliseconds()); |
| 780 |
| 781 scoped_refptr<DecoderBuffer> second_file = ReadTestDataFile("sfx.mp3"); |
| 782 source.AppendAtTime( |
| 783 source.last_timestamp_offset() - base::TimeDelta::FromMilliseconds(10), |
| 784 second_file->data(), |
| 785 second_file->data_size()); |
| 786 source.EndOfStream(); |
| 787 |
| 788 EXPECT_EQ(669, source.last_timestamp_offset().InMilliseconds()); |
| 789 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); |
| 790 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); |
| 791 EXPECT_EQ(669, pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); |
| 792 |
| 793 Play(); |
| 794 |
| 795 EXPECT_TRUE(WaitUntilOnEnded()); |
| 796 } |
| 728 | 797 |
| 729 TEST_F(PipelineIntegrationTest, MediaSource_MP3_Icecast) { | 798 TEST_F(PipelineIntegrationTest, MediaSource_MP3_Icecast) { |
| 730 MockMediaSource source("icy_sfx.mp3", kMP3, kAppendWholeFile); | 799 MockMediaSource source("icy_sfx.mp3", kMP3, kAppendWholeFile); |
| 731 StartPipelineWithMediaSource(&source); | 800 StartPipelineWithMediaSource(&source); |
| 732 source.EndOfStream(); | 801 source.EndOfStream(); |
| 733 | 802 |
| 734 Play(); | 803 Play(); |
| 735 | 804 |
| 736 EXPECT_TRUE(WaitUntilOnEnded()); | 805 EXPECT_TRUE(WaitUntilOnEnded()); |
| 737 } | 806 } |
| (...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1112 // Verify that VP8 video with inband text track can be played back. | 1181 // Verify that VP8 video with inband text track can be played back. |
| 1113 TEST_F(PipelineIntegrationTest, | 1182 TEST_F(PipelineIntegrationTest, |
| 1114 BasicPlayback_VP8_WebVTT_WebM) { | 1183 BasicPlayback_VP8_WebVTT_WebM) { |
| 1115 ASSERT_TRUE(Start(GetTestDataFilePath("bear-vp8-webvtt.webm"), | 1184 ASSERT_TRUE(Start(GetTestDataFilePath("bear-vp8-webvtt.webm"), |
| 1116 PIPELINE_OK)); | 1185 PIPELINE_OK)); |
| 1117 Play(); | 1186 Play(); |
| 1118 ASSERT_TRUE(WaitUntilOnEnded()); | 1187 ASSERT_TRUE(WaitUntilOnEnded()); |
| 1119 } | 1188 } |
| 1120 | 1189 |
| 1121 } // namespace media | 1190 } // namespace media |
| OLD | NEW |