| 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 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 DCHECK_LT(current_position_, file_data_->data_size()); | 298 DCHECK_LT(current_position_, file_data_->data_size()); |
| 299 DCHECK_LE(current_position_ + size, file_data_->data_size()); | 299 DCHECK_LE(current_position_ + size, file_data_->data_size()); |
| 300 | 300 |
| 301 // TODO(wolenetz): Test timestamp offset updating once "sequence" append | 301 // TODO(wolenetz): Test timestamp offset updating once "sequence" append |
| 302 // mode processing is implemented. See http://crbug.com/249422. | 302 // mode processing is implemented. See http://crbug.com/249422. |
| 303 base::TimeDelta timestamp_offset; | 303 base::TimeDelta timestamp_offset; |
| 304 chunk_demuxer_->AppendData( | 304 chunk_demuxer_->AppendData( |
| 305 kSourceId, file_data_->data() + current_position_, size, | 305 kSourceId, file_data_->data() + current_position_, size, |
| 306 base::TimeDelta(), kInfiniteDuration(), ×tamp_offset); | 306 base::TimeDelta(), kInfiniteDuration(), ×tamp_offset); |
| 307 current_position_ += size; | 307 current_position_ += size; |
| 308 last_timestamp_offset_ = timestamp_offset; |
| 308 } | 309 } |
| 309 | 310 |
| 310 void AppendAtTime(const base::TimeDelta& timestampOffset, | 311 void AppendAtTime(base::TimeDelta timestamp_offset, |
| 311 const uint8* pData, int size) { | 312 const uint8* pData, |
| 312 base::TimeDelta timestamp_offset = timestampOffset; | 313 int size) { |
| 313 CHECK(!chunk_demuxer_->IsParsingMediaSegment(kSourceId)); | 314 CHECK(!chunk_demuxer_->IsParsingMediaSegment(kSourceId)); |
| 314 chunk_demuxer_->AppendData(kSourceId, pData, size, | 315 chunk_demuxer_->AppendData(kSourceId, pData, size, |
| 315 base::TimeDelta(), kInfiniteDuration(), | 316 base::TimeDelta(), kInfiniteDuration(), |
| 316 ×tamp_offset); | 317 ×tamp_offset); |
| 318 last_timestamp_offset_ = timestamp_offset; |
| 317 } | 319 } |
| 318 | 320 |
| 319 void EndOfStream() { | 321 void EndOfStream() { |
| 320 chunk_demuxer_->MarkEndOfStream(PIPELINE_OK); | 322 chunk_demuxer_->MarkEndOfStream(PIPELINE_OK); |
| 321 } | 323 } |
| 322 | 324 |
| 323 void Abort() { | 325 void Abort() { |
| 324 if (!chunk_demuxer_) | 326 if (!chunk_demuxer_) |
| 325 return; | 327 return; |
| 326 chunk_demuxer_->Shutdown(); | 328 chunk_demuxer_->Shutdown(); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 AppendData(initial_append_size_); | 364 AppendData(initial_append_size_); |
| 363 } | 365 } |
| 364 | 366 |
| 365 void DemuxerNeedKey(const std::string& type, | 367 void DemuxerNeedKey(const std::string& type, |
| 366 const std::vector<uint8>& init_data) { | 368 const std::vector<uint8>& init_data) { |
| 367 DCHECK(!init_data.empty()); | 369 DCHECK(!init_data.empty()); |
| 368 CHECK(!need_key_cb_.is_null()); | 370 CHECK(!need_key_cb_.is_null()); |
| 369 need_key_cb_.Run(type, init_data); | 371 need_key_cb_.Run(type, init_data); |
| 370 } | 372 } |
| 371 | 373 |
| 374 base::TimeDelta last_timestamp_offset() const { |
| 375 return last_timestamp_offset_; |
| 376 } |
| 377 |
| 372 private: | 378 private: |
| 373 base::FilePath file_path_; | 379 base::FilePath file_path_; |
| 374 scoped_refptr<DecoderBuffer> file_data_; | 380 scoped_refptr<DecoderBuffer> file_data_; |
| 375 int current_position_; | 381 int current_position_; |
| 376 int initial_append_size_; | 382 int initial_append_size_; |
| 377 std::string mimetype_; | 383 std::string mimetype_; |
| 378 ChunkDemuxer* chunk_demuxer_; | 384 ChunkDemuxer* chunk_demuxer_; |
| 379 scoped_ptr<Demuxer> owned_chunk_demuxer_; | 385 scoped_ptr<Demuxer> owned_chunk_demuxer_; |
| 380 Demuxer::NeedKeyCB need_key_cb_; | 386 Demuxer::NeedKeyCB need_key_cb_; |
| 387 base::TimeDelta last_timestamp_offset_; |
| 381 }; | 388 }; |
| 382 | 389 |
| 383 class PipelineIntegrationTest | 390 class PipelineIntegrationTest |
| 384 : public testing::Test, | 391 : public testing::Test, |
| 385 public PipelineIntegrationTestBase { | 392 public PipelineIntegrationTestBase { |
| 386 public: | 393 public: |
| 387 void StartPipelineWithMediaSource(MockMediaSource* source) { | 394 void StartPipelineWithMediaSource(MockMediaSource* source) { |
| 388 EXPECT_CALL(*this, OnBufferingState(Pipeline::kHaveMetadata)) | 395 EXPECT_CALL(*this, OnBufferingState(Pipeline::kHaveMetadata)) |
| 389 .Times(AtMost(1)); | 396 .Times(AtMost(1)); |
| 390 EXPECT_CALL(*this, OnBufferingState(Pipeline::kPrerollCompleted)) | 397 EXPECT_CALL(*this, OnBufferingState(Pipeline::kPrerollCompleted)) |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 718 TEST_F(PipelineIntegrationTest, MediaSource_MP3) { | 725 TEST_F(PipelineIntegrationTest, MediaSource_MP3) { |
| 719 MockMediaSource source("sfx.mp3", kMP3, kAppendWholeFile); | 726 MockMediaSource source("sfx.mp3", kMP3, kAppendWholeFile); |
| 720 StartPipelineWithMediaSource(&source); | 727 StartPipelineWithMediaSource(&source); |
| 721 source.EndOfStream(); | 728 source.EndOfStream(); |
| 722 | 729 |
| 723 Play(); | 730 Play(); |
| 724 | 731 |
| 725 EXPECT_TRUE(WaitUntilOnEnded()); | 732 EXPECT_TRUE(WaitUntilOnEnded()); |
| 726 } | 733 } |
| 727 | 734 |
| 735 TEST_F(PipelineIntegrationTest, MediaSource_MP3_TimestampOffset) { |
| 736 MockMediaSource source("sfx.mp3", kMP3, kAppendWholeFile); |
| 737 StartPipelineWithMediaSource(&source); |
| 738 EXPECT_EQ(339, source.last_timestamp_offset().InMilliseconds()); |
| 739 |
| 740 scoped_refptr<DecoderBuffer> second_file = ReadTestDataFile("sfx.mp3"); |
| 741 source.AppendAtTime(base::TimeDelta::FromMilliseconds(-10), |
| 742 second_file->data(), |
| 743 second_file->data_size()); |
| 744 EXPECT_EQ(669, source.last_timestamp_offset().InMilliseconds()); |
| 745 ASSERT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); |
| 746 source.EndOfStream(); |
| 747 |
| 748 Play(); |
| 749 |
| 750 EXPECT_TRUE(WaitUntilOnEnded()); |
| 751 } |
| 728 | 752 |
| 729 TEST_F(PipelineIntegrationTest, MediaSource_MP3_Icecast) { | 753 TEST_F(PipelineIntegrationTest, MediaSource_MP3_Icecast) { |
| 730 MockMediaSource source("icy_sfx.mp3", kMP3, kAppendWholeFile); | 754 MockMediaSource source("icy_sfx.mp3", kMP3, kAppendWholeFile); |
| 731 StartPipelineWithMediaSource(&source); | 755 StartPipelineWithMediaSource(&source); |
| 732 source.EndOfStream(); | 756 source.EndOfStream(); |
| 733 | 757 |
| 734 Play(); | 758 Play(); |
| 735 | 759 |
| 736 EXPECT_TRUE(WaitUntilOnEnded()); | 760 EXPECT_TRUE(WaitUntilOnEnded()); |
| 737 } | 761 } |
| (...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. | 1136 // Verify that VP8 video with inband text track can be played back. |
| 1113 TEST_F(PipelineIntegrationTest, | 1137 TEST_F(PipelineIntegrationTest, |
| 1114 BasicPlayback_VP8_WebVTT_WebM) { | 1138 BasicPlayback_VP8_WebVTT_WebM) { |
| 1115 ASSERT_TRUE(Start(GetTestDataFilePath("bear-vp8-webvtt.webm"), | 1139 ASSERT_TRUE(Start(GetTestDataFilePath("bear-vp8-webvtt.webm"), |
| 1116 PIPELINE_OK)); | 1140 PIPELINE_OK)); |
| 1117 Play(); | 1141 Play(); |
| 1118 ASSERT_TRUE(WaitUntilOnEnded()); | 1142 ASSERT_TRUE(WaitUntilOnEnded()); |
| 1119 } | 1143 } |
| 1120 | 1144 |
| 1121 } // namespace media | 1145 } // namespace media |
| OLD | NEW |