Chromium Code Reviews| Index: media/filters/chunk_demuxer_unittest.cc |
| diff --git a/media/filters/chunk_demuxer_unittest.cc b/media/filters/chunk_demuxer_unittest.cc |
| index 55815c169026fcf5923fcef52bb495bed85fa221..22f62be8bf0fae4ccd6ec545a188bbb6025a76e7 100644 |
| --- a/media/filters/chunk_demuxer_unittest.cc |
| +++ b/media/filters/chunk_demuxer_unittest.cc |
| @@ -867,7 +867,10 @@ class ChunkDemuxerTest : public ::testing::TestWithParam<bool> { |
| base::SplitString(expected, ' ', ×tamps); |
| std::stringstream ss; |
| for (size_t i = 0; i < timestamps.size(); ++i) { |
| - DemuxerStream::Status status; |
| + // Initialize status to kAborted since it's possible for Read() to return |
| + // without calling StoreStatusAndBuffer() if it doesn't have any buffers |
| + // left to return. |
| + DemuxerStream::Status status = DemuxerStream::kAborted; |
| scoped_refptr<DecoderBuffer> buffer; |
| stream->Read(base::Bind(&ChunkDemuxerTest::StoreStatusAndBuffer, |
| base::Unretained(this), &status, &buffer)); |
| @@ -878,6 +881,23 @@ class ChunkDemuxerTest : public ::testing::TestWithParam<bool> { |
| if (i > 0) |
| ss << " "; |
| ss << buffer->timestamp().InMilliseconds(); |
| + |
| + // Handle preroll buffers. |
| + if (EndsWith(timestamps[i], "P", true)) { |
| + scoped_refptr<DecoderBuffer> preroll_buffer; |
| + preroll_buffer.swap(buffer); |
| + |
| + // When a preroll buffer is encountered we should be able to request one |
| + // more buffer. The first buffer should have a timestamp equal to the |
| + // second buffer and its discard_padding() should be its duration. |
| + stream->Read(base::Bind(&ChunkDemuxerTest::StoreStatusAndBuffer, |
| + base::Unretained(this), &status, &buffer)); |
| + base::MessageLoop::current()->RunUntilIdle(); |
| + ASSERT_EQ(buffer->timestamp(), preroll_buffer->timestamp()); |
|
acolwell GONE FROM CHROMIUM
2014/05/23 17:27:30
nit: remove? The expectations string should be abl
DaleCurtis
2014/05/23 21:46:26
Done.
|
| + ASSERT_EQ(kInfiniteDuration(), preroll_buffer->discard_padding().first); |
| + ASSERT_EQ(base::TimeDelta(), preroll_buffer->discard_padding().second); |
| + ss << "P"; |
| + } |
| } |
| EXPECT_EQ(expected, ss.str()); |
| } |
| @@ -3035,8 +3055,8 @@ TEST_P(ChunkDemuxerTest, AppendWindow_Video) { |
| ASSERT_TRUE(InitDemuxer(HAS_VIDEO)); |
| DemuxerStream* stream = demuxer_->GetStream(DemuxerStream::VIDEO); |
| - // Set the append window to [20,280). |
| - append_window_start_for_next_append_ = base::TimeDelta::FromMilliseconds(20); |
| + // Set the append window to [50,280). |
| + append_window_start_for_next_append_ = base::TimeDelta::FromMilliseconds(50); |
| append_window_end_for_next_append_ = base::TimeDelta::FromMilliseconds(280); |
| // Append a cluster that starts before and ends after the append window. |
| @@ -3049,7 +3069,7 @@ TEST_P(ChunkDemuxerTest, AppendWindow_Video) { |
| CheckExpectedRanges(kSourceId, "{ [120,270) }"); |
| CheckExpectedBuffers(stream, "120 150 180 210 240"); |
| - // Extend the append window to [20,650). |
| + // Extend the append window to [50,650). |
| append_window_end_for_next_append_ = base::TimeDelta::FromMilliseconds(650); |
| // Append more data and verify that adding buffers start at the next |
| @@ -3063,8 +3083,8 @@ TEST_P(ChunkDemuxerTest, AppendWindow_Audio) { |
| ASSERT_TRUE(InitDemuxer(HAS_AUDIO)); |
| DemuxerStream* stream = demuxer_->GetStream(DemuxerStream::AUDIO); |
| - // Set the append window to [20,280). |
| - append_window_start_for_next_append_ = base::TimeDelta::FromMilliseconds(20); |
| + // Set the append window to [50,280). |
| + append_window_start_for_next_append_ = base::TimeDelta::FromMilliseconds(50); |
| append_window_end_for_next_append_ = base::TimeDelta::FromMilliseconds(280); |
| // Append a cluster that starts before and ends after the append window. |
| @@ -3076,19 +3096,19 @@ TEST_P(ChunkDemuxerTest, AppendWindow_Audio) { |
| // in the buffer. Also verify that buffers that start inside the |
| // window and extend beyond the end of the window are not included. |
| // |
| - // The first 20ms of the first buffer should be trimmed off since it |
| + // The first 50ms of the first buffer should be trimmed off since it |
|
wolenetz
2014/05/23 19:59:45
nit: include mention in comment that the 'first bu
DaleCurtis
2014/05/23 21:46:26
Done.
|
| // overlaps the start of the append window. |
| - CheckExpectedRanges(kSourceId, "{ [20,270) }"); |
| - CheckExpectedBuffers(stream, "20 30 60 90 120 150 180 210 240"); |
| + CheckExpectedRanges(kSourceId, "{ [50,270) }"); |
| + CheckExpectedBuffers(stream, "50P 60 90 120 150 180 210 240"); |
| - // Extend the append window to [20,650). |
| + // Extend the append window to [50,650). |
| append_window_end_for_next_append_ = base::TimeDelta::FromMilliseconds(650); |
| // Append more data and verify that a new range is created. |
| AppendSingleStreamCluster( |
| kSourceId, kAudioTrackNum, |
| "360K 390K 420K 450K 480K 510K 540K 570K 600K 630K"); |
| - CheckExpectedRanges(kSourceId, "{ [20,270) [360,630) }"); |
| + CheckExpectedRanges(kSourceId, "{ [50,270) [360,630) }"); |
| } |
| TEST_P(ChunkDemuxerTest, AppendWindow_AudioOverlapStartAndEnd) { |
| @@ -3106,6 +3126,29 @@ TEST_P(ChunkDemuxerTest, AppendWindow_AudioOverlapStartAndEnd) { |
| CheckExpectedRanges(kSourceId, "{ }"); |
| } |
| +TEST_P(ChunkDemuxerTest, AppendWindow_WebMFile_AudioOnly) { |
| + EXPECT_CALL(*this, DemuxerOpened()); |
| + demuxer_->Initialize( |
| + &host_, |
| + CreateInitDoneCB(base::TimeDelta::FromMilliseconds(2744), PIPELINE_OK), |
| + true); |
| + ASSERT_EQ(ChunkDemuxer::kOk, AddId(kSourceId, HAS_AUDIO)); |
| + |
| + // Set the append window to [50,100). |
|
acolwell GONE FROM CHROMIUM
2014/05/23 17:27:30
nit: s/100/150/ since the comment doesn't match th
DaleCurtis
2014/05/23 21:46:26
Done.
|
| + append_window_start_for_next_append_ = base::TimeDelta::FromMilliseconds(50); |
| + append_window_end_for_next_append_ = base::TimeDelta::FromMilliseconds(150); |
| + |
| + // Read a WebM file into memory and send the data to the demuxer. The chunk |
| + // size has been chosen carefully to ensure the preroll buffer used by the |
| + // partial append window trim must come from a previous Append() call. |
| + scoped_refptr<DecoderBuffer> buffer = |
| + ReadTestDataFile("bear-320x240-audio-only.webm"); |
| + AppendDataInPieces(buffer->data(), buffer->data_size(), 128); |
| + |
| + DemuxerStream* stream = demuxer_->GetStream(DemuxerStream::AUDIO); |
| + CheckExpectedBuffers(stream, "50P 62 86 109 122 125 128"); |
| +} |
| + |
| TEST_P(ChunkDemuxerTest, AppendWindow_Text) { |
| DemuxerStream* text_stream = NULL; |
| EXPECT_CALL(host_, AddTextStream(_, _)) |