Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(57)

Unified Diff: media/filters/chunk_demuxer_unittest.cc

Issue 276573002: Add gapless playback support for AAC playback. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. Add config change test. Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/filters/chunk_demuxer.cc ('k') | media/filters/frame_processor.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..4fd2563405757916b2128f3aaa82ab6315f53a4a 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, ' ', &timestamps);
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));
@@ -3035,8 +3038,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 +3052,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 +3066,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 +3079,25 @@ 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
// 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) }");
- // Extend the append window to [20,650).
+ // 50 shows up twice in the expected buffers since the first one should be a
+ // preroll buffer; this is tested more carefully in SourceBufferStream tests.
+ //
+ // The first "50" is the "0" buffer marked for complete discard. The second
+ // "50" is the "30" buffer marked with 20ms of start discard.
+ CheckExpectedBuffers(stream, "50 50 60 90 120 150 180 210 240");
acolwell GONE FROM CHROMIUM 2014/05/24 00:58:21 Oh. I thought you'd keep the P suffix so you didn'
DaleCurtis 2014/05/27 23:59:32 Done.
+
+ // 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 +3115,71 @@ 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,150).
+ 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);
+ // 50 shows up twice in the expected buffers since the first one should be a
+ // preroll buffer; this is tested more carefully in SourceBufferStream tests.
+ CheckExpectedBuffers(stream, "50 50 62 86 109 122 125 128");
+}
+
+TEST_P(ChunkDemuxerTest, AppendWindow_AudioConfigUpdateRemovesPreroll) {
+ 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 timestamp offset so everything in the first file is before zero.
+ const base::TimeDelta duration_1 = base::TimeDelta::FromMilliseconds(2746);
+ ASSERT_TRUE(SetTimestampOffset(kSourceId, -duration_1));
+
+ // Set the append window such that the first file is completely before the
+ // append window.
+ append_window_start_for_next_append_ = base::TimeDelta();
+
+ // Read a WebM file into memory and append the data.
+ scoped_refptr<DecoderBuffer> buffer =
+ ReadTestDataFile("bear-320x240-audio-only.webm");
+ AppendDataInPieces(buffer->data(), buffer->data_size(), 512);
+ CheckExpectedRanges(kSourceId, "{ }");
+
+ DemuxerStream* stream = demuxer_->GetStream(DemuxerStream::AUDIO);
+ AudioDecoderConfig config_1 = stream->audio_decoder_config();
+
+ if (use_legacy_frame_processor_)
+ ASSERT_TRUE(SetTimestampOffset(kSourceId, base::TimeDelta()));
+
+ // Read a second WebM with a different config in and append the data.
+ scoped_refptr<DecoderBuffer> buffer2 =
+ ReadTestDataFile("bear-320x240-audio-only-48khz.webm");
+ EXPECT_CALL(host_, SetDuration(base::TimeDelta::FromMilliseconds(2773)));
+ AppendDataInPieces(buffer2->data(), buffer2->data_size(), 512);
+ CheckExpectedRanges(kSourceId, "{ [0,2773) }");
+
+ ExpectConfigChanged(DemuxerStream::AUDIO);
+ ASSERT_FALSE(config_1.Matches(stream->audio_decoder_config()));
+ CheckExpectedBuffers(stream, "0 21 43 64");
+}
+
TEST_P(ChunkDemuxerTest, AppendWindow_Text) {
DemuxerStream* text_stream = NULL;
EXPECT_CALL(host_, AddTextStream(_, _))
« no previous file with comments | « media/filters/chunk_demuxer.cc ('k') | media/filters/frame_processor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698