summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorxhwang@chromium.org <xhwang@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-29 04:10:12 +0000
committerxhwang@chromium.org <xhwang@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-29 04:10:12 +0000
commitb3eb3b8bde63b74acf97dbc20966f03469fd6b59 (patch)
tree761219e153ac738b5e039fe3406d56f88d6218bc /media
parentca43568db4c8e1d54bddeac27fa8e95387476556 (diff)
downloadchromium_src-b3eb3b8bde63b74acf97dbc20966f03469fd6b59.zip
chromium_src-b3eb3b8bde63b74acf97dbc20966f03469fd6b59.tar.gz
chromium_src-b3eb3b8bde63b74acf97dbc20966f03469fd6b59.tar.bz2
ChunkDemuxerStream always calls read callback asynchronously.
BUG=168270 TEST=All unittests still pass. Review URL: https://chromiumcodereview.appspot.com/12603018 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@191289 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media')
-rw-r--r--media/filters/chunk_demuxer.cc4
-rw-r--r--media/filters/chunk_demuxer_unittest.cc487
2 files changed, 202 insertions, 289 deletions
diff --git a/media/filters/chunk_demuxer.cc b/media/filters/chunk_demuxer.cc
index afce174..fdd47e7 100644
--- a/media/filters/chunk_demuxer.cc
+++ b/media/filters/chunk_demuxer.cc
@@ -6,6 +6,7 @@
#include <algorithm>
#include <deque>
+#include <limits>
#include "base/bind.h"
#include "base/callback_helpers.h"
@@ -303,7 +304,8 @@ void ChunkDemuxerStream::Read(const ReadCB& read_cb) {
}
}
- read_cb.Run(status, buffer);
+ base::MessageLoopProxy::current()->PostTask(FROM_HERE, base::Bind(
+ read_cb, status, buffer));
}
DemuxerStream::Type ChunkDemuxerStream::type() { return type_; }
diff --git a/media/filters/chunk_demuxer_unittest.cc b/media/filters/chunk_demuxer_unittest.cc
index 2a32ca6..0d0da35 100644
--- a/media/filters/chunk_demuxer_unittest.cc
+++ b/media/filters/chunk_demuxer_unittest.cc
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include <algorithm>
+
#include "base/bind.h"
#include "base/message_loop.h"
#include "media/base/audio_decoder_config.h"
@@ -119,28 +121,6 @@ static void OnReadDone_EOSExpected(bool* called,
*called = true;
}
-static void StoreStatusAndBuffer(DemuxerStream::Status* status_out,
- scoped_refptr<DecoderBuffer>* buffer_out,
- DemuxerStream::Status status,
- const scoped_refptr<DecoderBuffer>& buffer) {
- *status_out = status;
- *buffer_out = buffer;
-}
-
-static void ReadUntilNotOkOrEndOfStream(
- const scoped_refptr<DemuxerStream>& stream,
- DemuxerStream::Status* status,
- base::TimeDelta* last_timestamp) {
- scoped_refptr<DecoderBuffer> buffer;
-
- *last_timestamp = kNoTimestamp();
- do {
- stream->Read(base::Bind(&StoreStatusAndBuffer, status, &buffer));
- if (*status == DemuxerStream::kOk && !buffer->IsEndOfStream())
- *last_timestamp = buffer->GetTimestamp();
- } while (*status == DemuxerStream::kOk && !buffer->IsEndOfStream());
-}
-
class ChunkDemuxerTest : public testing::Test {
protected:
enum CodecsIndex {
@@ -581,20 +561,31 @@ class ChunkDemuxerTest : public testing::Test {
return cb.Finish();
}
- void GenerateExpectedReads(int timecode, int block_count,
- DemuxerStream* audio,
- DemuxerStream* video) {
- GenerateExpectedReads(timecode, timecode, block_count, audio, video);
+ void Read(DemuxerStream::Type type, const DemuxerStream::ReadCB& read_cb) {
+ scoped_refptr<DemuxerStream> stream = demuxer_->GetStream(type);
+ stream->Read(read_cb);
+ message_loop_.RunUntilIdle();
+ }
+
+ void ReadAudio(const DemuxerStream::ReadCB& read_cb) {
+ Read(DemuxerStream::AUDIO, read_cb);
+ }
+
+ void ReadVideo(const DemuxerStream::ReadCB& read_cb) {
+ Read(DemuxerStream::VIDEO, read_cb);
+ }
+
+ void GenerateExpectedReads(int timecode, int block_count) {
+ GenerateExpectedReads(timecode, timecode, block_count);
}
void GenerateExpectedReads(int start_audio_timecode,
int start_video_timecode,
- int block_count, DemuxerStream* audio,
- DemuxerStream* video) {
+ int block_count) {
CHECK_GT(block_count, 0);
if (block_count == 1) {
- ExpectRead(audio, start_audio_timecode);
+ ExpectRead(DemuxerStream::AUDIO, start_audio_timecode);
return;
}
@@ -603,28 +594,39 @@ class ChunkDemuxerTest : public testing::Test {
for (int i = 0; i < block_count; i++) {
if (audio_timecode <= video_timecode) {
- ExpectRead(audio, audio_timecode);
+ ExpectRead(DemuxerStream::AUDIO, audio_timecode);
audio_timecode += kAudioBlockDuration;
continue;
}
- ExpectRead(video, video_timecode);
+ ExpectRead(DemuxerStream::VIDEO, video_timecode);
video_timecode += kVideoBlockDuration;
}
}
- void GenerateSingleStreamExpectedReads(
- int timecode, int block_count, DemuxerStream* stream,
- int block_duration) {
+ void GenerateSingleStreamExpectedReads(int timecode,
+ int block_count,
+ DemuxerStream::Type type,
+ int block_duration) {
CHECK_GT(block_count, 0);
int stream_timecode = timecode;
for (int i = 0; i < block_count; i++) {
- ExpectRead(stream, stream_timecode);
+ ExpectRead(type, stream_timecode);
stream_timecode += block_duration;
}
}
+ void GenerateAudioStreamExpectedReads(int timecode, int block_count) {
+ GenerateSingleStreamExpectedReads(
+ timecode, block_count, DemuxerStream::AUDIO, kAudioBlockDuration);
+ }
+
+ void GenerateVideoStreamExpectedReads(int timecode, int block_count) {
+ GenerateSingleStreamExpectedReads(
+ timecode, block_count, DemuxerStream::VIDEO, kVideoBlockDuration);
+ }
+
scoped_ptr<Cluster> GenerateEmptyCluster(int timecode) {
ClusterBuilder cb;
cb.SetClusterTimecode(timecode);
@@ -652,23 +654,53 @@ class ChunkDemuxerTest : public testing::Test {
MOCK_METHOD2(ReadDone, void(DemuxerStream::Status status,
const scoped_refptr<DecoderBuffer>&));
- void ExpectEndOfStream(DemuxerStream* stream) {
+ void StoreStatusAndBuffer(DemuxerStream::Status* status_out,
+ scoped_refptr<DecoderBuffer>* buffer_out,
+ DemuxerStream::Status status,
+ const scoped_refptr<DecoderBuffer>& buffer) {
+ *status_out = status;
+ *buffer_out = buffer;
+ }
+
+ void ReadUntilNotOkOrEndOfStream(DemuxerStream::Type type,
+ DemuxerStream::Status* status,
+ base::TimeDelta* last_timestamp) {
+ scoped_refptr<DemuxerStream> stream = demuxer_->GetStream(type);
+ scoped_refptr<DecoderBuffer> buffer;
+
+ *last_timestamp = kNoTimestamp();
+ do {
+ stream->Read(base::Bind(&ChunkDemuxerTest::StoreStatusAndBuffer,
+ base::Unretained(this), status, &buffer));
+ MessageLoop::current()->RunUntilIdle();
+ if (*status == DemuxerStream::kOk && !buffer->IsEndOfStream())
+ *last_timestamp = buffer->GetTimestamp();
+ } while (*status == DemuxerStream::kOk && !buffer->IsEndOfStream());
+ }
+
+ void ExpectEndOfStream(DemuxerStream::Type type) {
+ scoped_refptr<DemuxerStream> stream = demuxer_->GetStream(type);
EXPECT_CALL(*this, ReadDone(DemuxerStream::kOk, IsEndOfStream()));
stream->Read(base::Bind(&ChunkDemuxerTest::ReadDone,
base::Unretained(this)));
+ message_loop_.RunUntilIdle();
}
- void ExpectRead(DemuxerStream* stream, int64 timestamp_in_ms) {
+ void ExpectRead(DemuxerStream::Type type, int64 timestamp_in_ms) {
+ scoped_refptr<DemuxerStream> stream = demuxer_->GetStream(type);
EXPECT_CALL(*this, ReadDone(DemuxerStream::kOk,
HasTimestamp(timestamp_in_ms)));
stream->Read(base::Bind(&ChunkDemuxerTest::ReadDone,
base::Unretained(this)));
+ message_loop_.RunUntilIdle();
}
- void ExpectConfigChanged(DemuxerStream* stream) {
+ void ExpectConfigChanged(DemuxerStream::Type type) {
+ scoped_refptr<DemuxerStream> stream = demuxer_->GetStream(type);
EXPECT_CALL(*this, ReadDone(DemuxerStream::kConfigChanged, _));
stream->Read(base::Bind(&ChunkDemuxerTest::ReadDone,
base::Unretained(this)));
+ message_loop_.RunUntilIdle();
}
MOCK_METHOD1(Checkpoint, void(int id));
@@ -706,11 +738,6 @@ class ChunkDemuxerTest : public testing::Test {
scoped_refptr<DecoderBuffer> buffer = ReadTestDataFile(filename);
AppendDataInPieces(buffer->GetData(), buffer->GetDataSize(), 512);
- scoped_refptr<DemuxerStream> audio =
- demuxer_->GetStream(DemuxerStream::AUDIO);
- scoped_refptr<DemuxerStream> video =
- demuxer_->GetStream(DemuxerStream::VIDEO);
-
// Verify that the timestamps on the first few packets match what we
// expect.
for (size_t i = 0;
@@ -721,21 +748,18 @@ class ChunkDemuxerTest : public testing::Test {
bool video_read_done = false;
if (timestamps[i].audio_time_ms != kSkip) {
- DCHECK(audio);
- audio->Read(base::Bind(&OnReadDone,
- base::TimeDelta::FromMilliseconds(
- timestamps[i].audio_time_ms),
- &audio_read_done));
+ ReadAudio(base::Bind(&OnReadDone,
+ base::TimeDelta::FromMilliseconds(
+ timestamps[i].audio_time_ms),
+ &audio_read_done));
EXPECT_TRUE(audio_read_done);
}
if (timestamps[i].video_time_ms != kSkip) {
- DCHECK(video);
- video->Read(base::Bind(&OnReadDone,
- base::TimeDelta::FromMilliseconds(
- timestamps[i].video_time_ms),
- &video_read_done));
-
+ ReadVideo(base::Bind(&OnReadDone,
+ base::TimeDelta::FromMilliseconds(
+ timestamps[i].video_time_ms),
+ &video_read_done));
EXPECT_TRUE(video_read_done);
}
}
@@ -881,11 +905,6 @@ TEST_F(ChunkDemuxerTest, TestErrorWhileParsingClusterAfterInit) {
TEST_F(ChunkDemuxerTest, TestSeekWhileParsingCluster) {
ASSERT_TRUE(InitDemuxer(true, true));
- scoped_refptr<DemuxerStream> audio =
- demuxer_->GetStream(DemuxerStream::AUDIO);
- scoped_refptr<DemuxerStream> video =
- demuxer_->GetStream(DemuxerStream::VIDEO);
-
InSequence s;
scoped_ptr<Cluster> cluster_a(GenerateCluster(0, 6));
@@ -897,27 +916,26 @@ TEST_F(ChunkDemuxerTest, TestSeekWhileParsingCluster) {
// Append the first part of the cluster.
AppendData(cluster_a->data(), first_append_size);
- ExpectRead(audio, 0);
- ExpectRead(video, 0);
- ExpectRead(audio, kAudioBlockDuration);
+ ExpectRead(DemuxerStream::AUDIO, 0);
+ ExpectRead(DemuxerStream::VIDEO, 0);
+ ExpectRead(DemuxerStream::AUDIO, kAudioBlockDuration);
// Note: We skip trying to read a video buffer here because computing
// the duration for this block relies on successfully parsing the last block
// in the cluster the cluster.
- ExpectRead(audio, 2 * kAudioBlockDuration);
+ ExpectRead(DemuxerStream::AUDIO, 2 * kAudioBlockDuration);
demuxer_->StartWaitingForSeek();
demuxer_->Seek(base::TimeDelta::FromSeconds(5),
NewExpectedStatusCB(PIPELINE_OK));
// Append the rest of the cluster.
- AppendData(cluster_a->data() + first_append_size,
- second_append_size);
+ AppendData(cluster_a->data() + first_append_size, second_append_size);
// Append the new cluster and verify that only the blocks
// in the new cluster are returned.
scoped_ptr<Cluster> cluster_b(GenerateCluster(5000, 6));
AppendData(cluster_b->data(), cluster_b->size());
- GenerateExpectedReads(5000, 6, audio, video);
+ GenerateExpectedReads(5000, 6);
}
// Test the case where AppendData() is called before Init().
@@ -936,19 +954,14 @@ TEST_F(ChunkDemuxerTest, TestRead) {
scoped_ptr<Cluster> cluster(kDefaultFirstCluster());
AppendData(cluster->data(), cluster->size());
- scoped_refptr<DemuxerStream> audio =
- demuxer_->GetStream(DemuxerStream::AUDIO);
- scoped_refptr<DemuxerStream> video =
- demuxer_->GetStream(DemuxerStream::VIDEO);
-
bool audio_read_done = false;
bool video_read_done = false;
- audio->Read(base::Bind(&OnReadDone,
- base::TimeDelta::FromMilliseconds(0),
- &audio_read_done));
- video->Read(base::Bind(&OnReadDone,
- base::TimeDelta::FromMilliseconds(0),
- &video_read_done));
+ ReadAudio(base::Bind(&OnReadDone,
+ base::TimeDelta::FromMilliseconds(0),
+ &audio_read_done));
+ ReadVideo(base::Bind(&OnReadDone,
+ base::TimeDelta::FromMilliseconds(0),
+ &video_read_done));
EXPECT_TRUE(audio_read_done);
EXPECT_TRUE(video_read_done);
@@ -1131,11 +1144,9 @@ class EndOfStreamHelper {
scoped_refptr<DemuxerStream> video =
demuxer_->GetStream(DemuxerStream::VIDEO);
- audio->Read(base::Bind(&OnEndOfStreamReadDone,
- &audio_read_done_));
-
- video->Read(base::Bind(&OnEndOfStreamReadDone,
- &video_read_done_));
+ audio->Read(base::Bind(&OnEndOfStreamReadDone, &audio_read_done_));
+ video->Read(base::Bind(&OnEndOfStreamReadDone, &video_read_done_));
+ MessageLoop::current()->RunUntilIdle();
}
// Check to see if |audio_read_done_| and |video_read_done_| variables
@@ -1170,23 +1181,17 @@ TEST_F(ChunkDemuxerTest, TestEndOfStreamWithPendingReads) {
scoped_ptr<Cluster> cluster(GenerateCluster(0, 2));
AppendData(cluster->data(), cluster->size());
- scoped_refptr<DemuxerStream> audio =
- demuxer_->GetStream(DemuxerStream::AUDIO);
- scoped_refptr<DemuxerStream> video =
- demuxer_->GetStream(DemuxerStream::VIDEO);
-
bool audio_read_done_1 = false;
bool video_read_done_1 = false;
EndOfStreamHelper end_of_stream_helper_1(demuxer_);
EndOfStreamHelper end_of_stream_helper_2(demuxer_);
- audio->Read(base::Bind(&OnReadDone,
- base::TimeDelta::FromMilliseconds(0),
- &audio_read_done_1));
-
- video->Read(base::Bind(&OnReadDone,
- base::TimeDelta::FromMilliseconds(0),
- &video_read_done_1));
+ ReadAudio(base::Bind(&OnReadDone,
+ base::TimeDelta::FromMilliseconds(0),
+ &audio_read_done_1));
+ ReadVideo(base::Bind(&OnReadDone,
+ base::TimeDelta::FromMilliseconds(0),
+ &video_read_done_1));
end_of_stream_helper_1.RequestReads();
end_of_stream_helper_2.RequestReads();
@@ -1212,24 +1217,18 @@ TEST_F(ChunkDemuxerTest, TestReadsAfterEndOfStream) {
scoped_ptr<Cluster> cluster(GenerateCluster(0, 2));
AppendData(cluster->data(), cluster->size());
- scoped_refptr<DemuxerStream> audio =
- demuxer_->GetStream(DemuxerStream::AUDIO);
- scoped_refptr<DemuxerStream> video =
- demuxer_->GetStream(DemuxerStream::VIDEO);
-
bool audio_read_done_1 = false;
bool video_read_done_1 = false;
EndOfStreamHelper end_of_stream_helper_1(demuxer_);
EndOfStreamHelper end_of_stream_helper_2(demuxer_);
EndOfStreamHelper end_of_stream_helper_3(demuxer_);
- audio->Read(base::Bind(&OnReadDone,
- base::TimeDelta::FromMilliseconds(0),
- &audio_read_done_1));
-
- video->Read(base::Bind(&OnReadDone,
- base::TimeDelta::FromMilliseconds(0),
- &video_read_done_1));
+ ReadAudio(base::Bind(&OnReadDone,
+ base::TimeDelta::FromMilliseconds(0),
+ &audio_read_done_1));
+ ReadVideo(base::Bind(&OnReadDone,
+ base::TimeDelta::FromMilliseconds(0),
+ &video_read_done_1));
end_of_stream_helper_1.RequestReads();
@@ -1254,10 +1253,6 @@ TEST_F(ChunkDemuxerTest, TestReadsAfterEndOfStream) {
TEST_F(ChunkDemuxerTest, TestEndOfStreamDuringCanceledSeek) {
ASSERT_TRUE(InitDemuxer(true, true));
- scoped_refptr<DemuxerStream> audio =
- demuxer_->GetStream(DemuxerStream::AUDIO);
- scoped_refptr<DemuxerStream> video =
- demuxer_->GetStream(DemuxerStream::VIDEO);
AppendCluster(0, 10);
EXPECT_CALL(host_, SetDuration(base::TimeDelta::FromMilliseconds(138)));
@@ -1283,11 +1278,11 @@ TEST_F(ChunkDemuxerTest, TestEndOfStreamDuringCanceledSeek) {
base::TimeDelta last_timestamp;
// Make sure audio can reach end of stream.
- ReadUntilNotOkOrEndOfStream(audio, &status, &last_timestamp);
+ ReadUntilNotOkOrEndOfStream(DemuxerStream::AUDIO, &status, &last_timestamp);
ASSERT_EQ(status, DemuxerStream::kOk);
// Make sure video can reach end of stream.
- ReadUntilNotOkOrEndOfStream(video, &status, &last_timestamp);
+ ReadUntilNotOkOrEndOfStream(DemuxerStream::VIDEO, &status, &last_timestamp);
ASSERT_EQ(status, DemuxerStream::kOk);
}
@@ -1320,15 +1315,7 @@ TEST_F(ChunkDemuxerTest, TestAppendingInPieces) {
AppendDataInPieces(buffer.get(), buffer_size);
- scoped_refptr<DemuxerStream> audio =
- demuxer_->GetStream(DemuxerStream::AUDIO);
- scoped_refptr<DemuxerStream> video =
- demuxer_->GetStream(DemuxerStream::VIDEO);
-
- ASSERT_TRUE(audio);
- ASSERT_TRUE(video);
-
- GenerateExpectedReads(0, 9, audio, video);
+ GenerateExpectedReads(0, 9);
}
TEST_F(ChunkDemuxerTest, TestWebMFile_AudioAndVideo) {
@@ -1409,20 +1396,15 @@ TEST_F(ChunkDemuxerTest, TestIncrementalClusterParsing) {
AppendEmptyCluster(0);
scoped_ptr<Cluster> cluster(GenerateCluster(0, 6));
- scoped_refptr<DemuxerStream> audio =
- demuxer_->GetStream(DemuxerStream::AUDIO);
- scoped_refptr<DemuxerStream> video =
- demuxer_->GetStream(DemuxerStream::VIDEO);
bool audio_read_done = false;
bool video_read_done = false;
- audio->Read(base::Bind(&OnReadDone,
- base::TimeDelta::FromMilliseconds(0),
- &audio_read_done));
-
- video->Read(base::Bind(&OnReadDone,
- base::TimeDelta::FromMilliseconds(0),
- &video_read_done));
+ ReadAudio(base::Bind(&OnReadDone,
+ base::TimeDelta::FromMilliseconds(0),
+ &audio_read_done));
+ ReadVideo(base::Bind(&OnReadDone,
+ base::TimeDelta::FromMilliseconds(0),
+ &video_read_done));
// Make sure the reads haven't completed yet.
EXPECT_FALSE(audio_read_done);
@@ -1449,13 +1431,12 @@ TEST_F(ChunkDemuxerTest, TestIncrementalClusterParsing) {
audio_read_done = false;
video_read_done = false;
- audio->Read(base::Bind(&OnReadDone,
- base::TimeDelta::FromMilliseconds(23),
- &audio_read_done));
-
- video->Read(base::Bind(&OnReadDone,
- base::TimeDelta::FromMilliseconds(33),
- &video_read_done));
+ ReadAudio(base::Bind(&OnReadDone,
+ base::TimeDelta::FromMilliseconds(23),
+ &audio_read_done));
+ ReadVideo(base::Bind(&OnReadDone,
+ base::TimeDelta::FromMilliseconds(33),
+ &video_read_done));
// Make sure the reads haven't completed yet.
EXPECT_FALSE(audio_read_done);
@@ -1512,11 +1493,6 @@ TEST_F(ChunkDemuxerTest, TestAVHeadersWithVideoOnlyType) {
TEST_F(ChunkDemuxerTest, TestMultipleHeaders) {
ASSERT_TRUE(InitDemuxer(true, true));
- scoped_refptr<DemuxerStream> audio =
- demuxer_->GetStream(DemuxerStream::AUDIO);
- scoped_refptr<DemuxerStream> video =
- demuxer_->GetStream(DemuxerStream::VIDEO);
-
scoped_ptr<Cluster> cluster_a(kDefaultFirstCluster());
AppendData(cluster_a->data(), cluster_a->size());
@@ -1526,7 +1502,7 @@ TEST_F(ChunkDemuxerTest, TestMultipleHeaders) {
scoped_ptr<Cluster> cluster_b(kDefaultSecondCluster());
AppendData(cluster_b->data(), cluster_b->size());
- GenerateExpectedReads(0, 9, audio, video);
+ GenerateExpectedReads(0, 9);
}
TEST_F(ChunkDemuxerTest, TestAddSeparateSourcesForAudioAndVideo) {
@@ -1534,11 +1510,6 @@ TEST_F(ChunkDemuxerTest, TestAddSeparateSourcesForAudioAndVideo) {
std::string video_id = "video1";
ASSERT_TRUE(InitDemuxerAudioAndVideoSources(audio_id, video_id));
- scoped_refptr<DemuxerStream> audio =
- demuxer_->GetStream(DemuxerStream::AUDIO);
- scoped_refptr<DemuxerStream> video =
- demuxer_->GetStream(DemuxerStream::VIDEO);
-
scoped_ptr<Cluster> cluster_a(
GenerateSingleStreamCluster(0, 92, kAudioTrackNum, kAudioBlockDuration));
@@ -1547,9 +1518,9 @@ TEST_F(ChunkDemuxerTest, TestAddSeparateSourcesForAudioAndVideo) {
// Append audio and video data into separate source ids.
AppendData(audio_id, cluster_a->data(), cluster_a->size());
- GenerateSingleStreamExpectedReads(0, 4, audio, kAudioBlockDuration);
+ GenerateAudioStreamExpectedReads(0, 4);
AppendData(video_id, cluster_v->data(), cluster_v->size());
- GenerateSingleStreamExpectedReads(0, 4, video, kVideoBlockDuration);
+ GenerateVideoStreamExpectedReads(0, 4);
}
TEST_F(ChunkDemuxerTest, TestAddIdFailures) {
@@ -1588,23 +1559,18 @@ TEST_F(ChunkDemuxerTest, TestRemoveId) {
AppendData(video_id, cluster_v->data(), cluster_v->size());
// Read() from audio should return normal buffers.
- scoped_refptr<DemuxerStream> audio =
- demuxer_->GetStream(DemuxerStream::AUDIO);
- GenerateSingleStreamExpectedReads(0, 4, audio, kAudioBlockDuration);
+ GenerateAudioStreamExpectedReads(0, 4);
// Remove the audio id.
demuxer_->RemoveId(audio_id);
// Read() from audio should return "end of stream" buffers.
bool audio_read_done = false;
- audio->Read(base::Bind(&OnReadDone_EOSExpected,
- &audio_read_done));
+ ReadAudio(base::Bind(&OnReadDone_EOSExpected, &audio_read_done));
EXPECT_TRUE(audio_read_done);
// Read() from video should still return normal buffers.
- scoped_refptr<DemuxerStream> video =
- demuxer_->GetStream(DemuxerStream::VIDEO);
- GenerateSingleStreamExpectedReads(0, 4, video, kVideoBlockDuration);
+ GenerateVideoStreamExpectedReads(0, 4);
}
// Test that removing an ID immediately after adding it does not interfere with
@@ -1621,11 +1587,6 @@ TEST_F(ChunkDemuxerTest, TestRemoveAndAddId) {
TEST_F(ChunkDemuxerTest, TestSeekCanceled) {
ASSERT_TRUE(InitDemuxer(true, true));
- scoped_refptr<DemuxerStream> audio =
- demuxer_->GetStream(DemuxerStream::AUDIO);
- scoped_refptr<DemuxerStream> video =
- demuxer_->GetStream(DemuxerStream::VIDEO);
-
// Append cluster at the beginning of the stream.
scoped_ptr<Cluster> start_cluster(GenerateCluster(0, 4));
AppendData(start_cluster->data(), start_cluster->size());
@@ -1638,8 +1599,8 @@ TEST_F(ChunkDemuxerTest, TestSeekCanceled) {
// Attempt to read in unbuffered area; should not fulfill the read.
bool audio_read_done = false;
bool video_read_done = false;
- audio->Read(base::Bind(&OnReadDone_AbortExpected, &audio_read_done));
- video->Read(base::Bind(&OnReadDone_AbortExpected, &video_read_done));
+ ReadAudio(base::Bind(&OnReadDone_AbortExpected, &audio_read_done));
+ ReadVideo(base::Bind(&OnReadDone_AbortExpected, &video_read_done));
EXPECT_FALSE(audio_read_done);
EXPECT_FALSE(video_read_done);
@@ -1653,17 +1614,12 @@ TEST_F(ChunkDemuxerTest, TestSeekCanceled) {
demuxer_->StartWaitingForSeek();
demuxer_->Seek(base::TimeDelta::FromSeconds(0),
NewExpectedStatusCB(PIPELINE_OK));
- GenerateExpectedReads(0, 4, audio, video);
+ GenerateExpectedReads(0, 4);
}
TEST_F(ChunkDemuxerTest, TestSeekCanceledWhileWaitingForSeek) {
ASSERT_TRUE(InitDemuxer(true, true));
- scoped_refptr<DemuxerStream> audio =
- demuxer_->GetStream(DemuxerStream::AUDIO);
- scoped_refptr<DemuxerStream> video =
- demuxer_->GetStream(DemuxerStream::VIDEO);
-
// Append cluster at the beginning of the stream.
scoped_ptr<Cluster> start_cluster(GenerateCluster(0, 4));
AppendData(start_cluster->data(), start_cluster->size());
@@ -1679,8 +1635,8 @@ TEST_F(ChunkDemuxerTest, TestSeekCanceledWhileWaitingForSeek) {
// Read requests should be fulfilled with empty buffers.
bool audio_read_done = false;
bool video_read_done = false;
- audio->Read(base::Bind(&OnReadDone_AbortExpected, &audio_read_done));
- video->Read(base::Bind(&OnReadDone_AbortExpected, &video_read_done));
+ ReadAudio(base::Bind(&OnReadDone_AbortExpected, &audio_read_done));
+ ReadVideo(base::Bind(&OnReadDone_AbortExpected, &video_read_done));
EXPECT_TRUE(audio_read_done);
EXPECT_TRUE(video_read_done);
@@ -1688,7 +1644,7 @@ TEST_F(ChunkDemuxerTest, TestSeekCanceledWhileWaitingForSeek) {
demuxer_->StartWaitingForSeek();
demuxer_->Seek(base::TimeDelta::FromSeconds(0),
NewExpectedStatusCB(PIPELINE_OK));
- GenerateExpectedReads(0, 4, audio, video);
+ GenerateExpectedReads(0, 4);
}
// Test that Seek() successfully seeks to all source IDs.
@@ -1709,17 +1665,12 @@ TEST_F(ChunkDemuxerTest, TestSeekAudioAndVideoSources) {
// Read() should return buffers at 0.
bool audio_read_done = false;
bool video_read_done = false;
- scoped_refptr<DemuxerStream> audio =
- demuxer_->GetStream(DemuxerStream::AUDIO);
- scoped_refptr<DemuxerStream> video =
- demuxer_->GetStream(DemuxerStream::VIDEO);
-
- audio->Read(base::Bind(&OnReadDone,
- base::TimeDelta::FromMilliseconds(0),
- &audio_read_done));
- video->Read(base::Bind(&OnReadDone,
- base::TimeDelta::FromMilliseconds(0),
- &video_read_done));
+ ReadAudio(base::Bind(&OnReadDone,
+ base::TimeDelta::FromMilliseconds(0),
+ &audio_read_done));
+ ReadVideo(base::Bind(&OnReadDone,
+ base::TimeDelta::FromMilliseconds(0),
+ &video_read_done));
EXPECT_TRUE(audio_read_done);
EXPECT_TRUE(video_read_done);
@@ -1730,13 +1681,12 @@ TEST_F(ChunkDemuxerTest, TestSeekAudioAndVideoSources) {
audio_read_done = false;
video_read_done = false;
- audio->Read(base::Bind(&OnReadDone,
- base::TimeDelta::FromSeconds(3),
- &audio_read_done));
- video->Read(base::Bind(&OnReadDone,
- base::TimeDelta::FromSeconds(3),
- &video_read_done));
-
+ ReadAudio(base::Bind(&OnReadDone,
+ base::TimeDelta::FromSeconds(3),
+ &audio_read_done));
+ ReadVideo(base::Bind(&OnReadDone,
+ base::TimeDelta::FromSeconds(3),
+ &video_read_done));
// Read()s should not return until after data is appended at the Seek point.
EXPECT_FALSE(audio_read_done);
EXPECT_FALSE(video_read_done);
@@ -1924,18 +1874,13 @@ TEST_F(ChunkDemuxerTest, GetBufferedRanges_EndOfStream) {
TEST_F(ChunkDemuxerTest, TestDifferentStreamTimecodes) {
ASSERT_TRUE(InitDemuxer(true, true));
- scoped_refptr<DemuxerStream> audio =
- demuxer_->GetStream(DemuxerStream::AUDIO);
- scoped_refptr<DemuxerStream> video =
- demuxer_->GetStream(DemuxerStream::VIDEO);
-
// Create a cluster where the video timecode begins 25ms after the audio.
scoped_ptr<Cluster> start_cluster(GenerateCluster(0, 25, 8));
AppendData(start_cluster->data(), start_cluster->size());
demuxer_->Seek(base::TimeDelta::FromSeconds(0),
NewExpectedStatusCB(PIPELINE_OK));
- GenerateExpectedReads(0, 25, 8, audio, video);
+ GenerateExpectedReads(0, 25, 8);
// Seek to 5 seconds.
demuxer_->StartWaitingForSeek();
@@ -1946,7 +1891,7 @@ TEST_F(ChunkDemuxerTest, TestDifferentStreamTimecodes) {
// after the video.
scoped_ptr<Cluster> middle_cluster(GenerateCluster(5025, 5000, 8));
AppendData(middle_cluster->data(), middle_cluster->size());
- GenerateExpectedReads(5025, 5000, 8, audio, video);
+ GenerateExpectedReads(5025, 5000, 8);
}
TEST_F(ChunkDemuxerTest, TestDifferentStreamTimecodesSeparateSources) {
@@ -1954,11 +1899,6 @@ TEST_F(ChunkDemuxerTest, TestDifferentStreamTimecodesSeparateSources) {
std::string video_id = "video1";
ASSERT_TRUE(InitDemuxerAudioAndVideoSources(audio_id, video_id));
- scoped_refptr<DemuxerStream> audio =
- demuxer_->GetStream(DemuxerStream::AUDIO);
- scoped_refptr<DemuxerStream> video =
- demuxer_->GetStream(DemuxerStream::VIDEO);
-
// Generate two streams where the video stream starts 5ms after the audio
// stream and append them.
scoped_ptr<Cluster> cluster_v(
@@ -1973,8 +1913,8 @@ TEST_F(ChunkDemuxerTest, TestDifferentStreamTimecodesSeparateSources) {
// Both streams should be able to fulfill a seek to 25.
demuxer_->Seek(base::TimeDelta::FromMilliseconds(25),
NewExpectedStatusCB(PIPELINE_OK));
- GenerateSingleStreamExpectedReads(25, 4, audio, kAudioBlockDuration);
- GenerateSingleStreamExpectedReads(30, 4, video, kVideoBlockDuration);
+ GenerateAudioStreamExpectedReads(25, 4);
+ GenerateVideoStreamExpectedReads(30, 4);
}
TEST_F(ChunkDemuxerTest, TestDifferentStreamTimecodesOutOfRange) {
@@ -1982,11 +1922,6 @@ TEST_F(ChunkDemuxerTest, TestDifferentStreamTimecodesOutOfRange) {
std::string video_id = "video1";
ASSERT_TRUE(InitDemuxerAudioAndVideoSources(audio_id, video_id));
- scoped_refptr<DemuxerStream> audio =
- demuxer_->GetStream(DemuxerStream::AUDIO);
- scoped_refptr<DemuxerStream> video =
- demuxer_->GetStream(DemuxerStream::VIDEO);
-
// Generate two streams where the video stream starts 10s after the audio
// stream and append them.
scoped_ptr<Cluster> cluster_v(
@@ -2001,8 +1936,8 @@ TEST_F(ChunkDemuxerTest, TestDifferentStreamTimecodesOutOfRange) {
// Should not be able to fulfill a seek to 0.
demuxer_->Seek(base::TimeDelta::FromMilliseconds(0),
NewExpectedStatusCB(PIPELINE_ERROR_ABORT));
- ExpectRead(audio, 0);
- ExpectEndOfStream(video);
+ ExpectRead(DemuxerStream::AUDIO, 0);
+ ExpectEndOfStream(DemuxerStream::VIDEO);
}
TEST_F(ChunkDemuxerTest, TestClusterWithNoBuffers) {
@@ -2014,12 +1949,8 @@ TEST_F(ChunkDemuxerTest, TestClusterWithNoBuffers) {
// Sanity check that data can be appended after this cluster correctly.
scoped_ptr<Cluster> media_data(GenerateCluster(0, 2));
AppendData(media_data->data(), media_data->size());
- scoped_refptr<DemuxerStream> audio =
- demuxer_->GetStream(DemuxerStream::AUDIO);
- scoped_refptr<DemuxerStream> video =
- demuxer_->GetStream(DemuxerStream::VIDEO);
- ExpectRead(audio, 0);
- ExpectRead(video, 0);
+ ExpectRead(DemuxerStream::AUDIO, 0);
+ ExpectRead(DemuxerStream::VIDEO, 0);
}
TEST_F(ChunkDemuxerTest, TestCodecPrefixMatching) {
@@ -2133,19 +2064,15 @@ TEST_F(ChunkDemuxerTest, TestEndOfStreamStillSetAfterSeek) {
AppendData(cluster_b->data(), cluster_b->size());
demuxer_->EndOfStream(PIPELINE_OK);
- scoped_refptr<DemuxerStream> audio =
- demuxer_->GetStream(DemuxerStream::AUDIO);
- scoped_refptr<DemuxerStream> video =
- demuxer_->GetStream(DemuxerStream::VIDEO);
DemuxerStream::Status status;
base::TimeDelta last_timestamp;
// Verify that we can read audio & video to the end w/o problems.
- ReadUntilNotOkOrEndOfStream(audio, &status, &last_timestamp);
+ ReadUntilNotOkOrEndOfStream(DemuxerStream::AUDIO, &status, &last_timestamp);
EXPECT_EQ(DemuxerStream::kOk, status);
EXPECT_EQ(kLastAudioTimestamp, last_timestamp);
- ReadUntilNotOkOrEndOfStream(video, &status, &last_timestamp);
+ ReadUntilNotOkOrEndOfStream(DemuxerStream::VIDEO, &status, &last_timestamp);
EXPECT_EQ(DemuxerStream::kOk, status);
EXPECT_EQ(kLastVideoTimestamp, last_timestamp);
@@ -2154,11 +2081,11 @@ TEST_F(ChunkDemuxerTest, TestEndOfStreamStillSetAfterSeek) {
demuxer_->Seek(base::TimeDelta::FromMilliseconds(0),
NewExpectedStatusCB(PIPELINE_OK));
- ReadUntilNotOkOrEndOfStream(audio, &status, &last_timestamp);
+ ReadUntilNotOkOrEndOfStream(DemuxerStream::AUDIO, &status, &last_timestamp);
EXPECT_EQ(DemuxerStream::kOk, status);
EXPECT_EQ(kLastAudioTimestamp, last_timestamp);
- ReadUntilNotOkOrEndOfStream(video, &status, &last_timestamp);
+ ReadUntilNotOkOrEndOfStream(DemuxerStream::VIDEO, &status, &last_timestamp);
EXPECT_EQ(DemuxerStream::kOk, status);
EXPECT_EQ(kLastVideoTimestamp, last_timestamp);
}
@@ -2194,13 +2121,8 @@ TEST_F(ChunkDemuxerTest, TestEndOfStreamDuringSeek) {
demuxer_->Seek(base::TimeDelta::FromSeconds(0),
NewExpectedStatusCB(PIPELINE_OK));
- scoped_refptr<DemuxerStream> audio =
- demuxer_->GetStream(DemuxerStream::AUDIO);
- scoped_refptr<DemuxerStream> video =
- demuxer_->GetStream(DemuxerStream::VIDEO);
-
- GenerateExpectedReads(0, 4, audio, video);
- GenerateExpectedReads(46, 66, 5, audio, video);
+ GenerateExpectedReads(0, 4);
+ GenerateExpectedReads(46, 66, 5);
EndOfStreamHelper end_of_stream_helper(demuxer_);
end_of_stream_helper.RequestReads();
@@ -2212,45 +2134,46 @@ TEST_F(ChunkDemuxerTest, TestConfigChange_Video) {
ASSERT_TRUE(InitDemuxerWithConfigChangeData());
- scoped_refptr<DemuxerStream> stream =
- demuxer_->GetStream(DemuxerStream::VIDEO);
DemuxerStream::Status status;
base::TimeDelta last_timestamp;
+ scoped_refptr<DemuxerStream> video =
+ demuxer_->GetStream(DemuxerStream::VIDEO);
+
// Fetch initial video config and verify it matches what we expect.
- const VideoDecoderConfig& video_config_1 = stream->video_decoder_config();
+ const VideoDecoderConfig& video_config_1 = video->video_decoder_config();
ASSERT_TRUE(video_config_1.IsValidConfig());
EXPECT_EQ(video_config_1.natural_size().width(), 320);
EXPECT_EQ(video_config_1.natural_size().height(), 240);
- ExpectRead(stream, 0);
+ ExpectRead(DemuxerStream::VIDEO, 0);
- ReadUntilNotOkOrEndOfStream(stream, &status, &last_timestamp);
+ ReadUntilNotOkOrEndOfStream(DemuxerStream::VIDEO, &status, &last_timestamp);
ASSERT_EQ(status, DemuxerStream::kConfigChanged);
EXPECT_EQ(last_timestamp.InMilliseconds(), 501);
// Fetch the new decoder config.
- const VideoDecoderConfig& video_config_2 = stream->video_decoder_config();
+ const VideoDecoderConfig& video_config_2 = video->video_decoder_config();
ASSERT_TRUE(video_config_2.IsValidConfig());
EXPECT_EQ(video_config_2.natural_size().width(), 640);
EXPECT_EQ(video_config_2.natural_size().height(), 360);
- ExpectRead(stream, 527);
+ ExpectRead(DemuxerStream::VIDEO, 527);
// Read until the next config change.
- ReadUntilNotOkOrEndOfStream(stream, &status, &last_timestamp);
+ ReadUntilNotOkOrEndOfStream(DemuxerStream::VIDEO, &status, &last_timestamp);
ASSERT_EQ(status, DemuxerStream::kConfigChanged);
EXPECT_EQ(last_timestamp.InMilliseconds(), 793);
// Get the new config and verify that it matches the first one.
- ASSERT_TRUE(video_config_1.Matches(stream->video_decoder_config()));
+ ASSERT_TRUE(video_config_1.Matches(video->video_decoder_config()));
- ExpectRead(stream, 801);
+ ExpectRead(DemuxerStream::VIDEO, 801);
// Read until the end of the stream just to make sure there aren't any other
// config changes.
- ReadUntilNotOkOrEndOfStream(stream, &status, &last_timestamp);
+ ReadUntilNotOkOrEndOfStream(DemuxerStream::VIDEO, &status, &last_timestamp);
ASSERT_EQ(status, DemuxerStream::kOk);
}
@@ -2259,45 +2182,46 @@ TEST_F(ChunkDemuxerTest, TestConfigChange_Audio) {
ASSERT_TRUE(InitDemuxerWithConfigChangeData());
- scoped_refptr<DemuxerStream> stream =
- demuxer_->GetStream(DemuxerStream::AUDIO);
DemuxerStream::Status status;
base::TimeDelta last_timestamp;
+ scoped_refptr<DemuxerStream> audio =
+ demuxer_->GetStream(DemuxerStream::AUDIO);
+
// Fetch initial audio config and verify it matches what we expect.
- const AudioDecoderConfig& audio_config_1 = stream->audio_decoder_config();
+ const AudioDecoderConfig& audio_config_1 = audio->audio_decoder_config();
ASSERT_TRUE(audio_config_1.IsValidConfig());
EXPECT_EQ(audio_config_1.samples_per_second(), 44100);
EXPECT_EQ(audio_config_1.extra_data_size(), 3863u);
- ExpectRead(stream, 0);
+ ExpectRead(DemuxerStream::AUDIO, 0);
- ReadUntilNotOkOrEndOfStream(stream, &status, &last_timestamp);
+ ReadUntilNotOkOrEndOfStream(DemuxerStream::AUDIO, &status, &last_timestamp);
ASSERT_EQ(status, DemuxerStream::kConfigChanged);
EXPECT_EQ(last_timestamp.InMilliseconds(), 524);
// Fetch the new decoder config.
- const AudioDecoderConfig& audio_config_2 = stream->audio_decoder_config();
+ const AudioDecoderConfig& audio_config_2 = audio->audio_decoder_config();
ASSERT_TRUE(audio_config_2.IsValidConfig());
EXPECT_EQ(audio_config_2.samples_per_second(), 44100);
EXPECT_EQ(audio_config_2.extra_data_size(), 3935u);
- ExpectRead(stream, 527);
+ ExpectRead(DemuxerStream::AUDIO, 527);
// Read until the next config change.
- ReadUntilNotOkOrEndOfStream(stream, &status, &last_timestamp);
+ ReadUntilNotOkOrEndOfStream(DemuxerStream::AUDIO, &status, &last_timestamp);
ASSERT_EQ(status, DemuxerStream::kConfigChanged);
EXPECT_EQ(last_timestamp.InMilliseconds(), 759);
// Get the new config and verify that it matches the first one.
- ASSERT_TRUE(audio_config_1.Matches(stream->audio_decoder_config()));
+ ASSERT_TRUE(audio_config_1.Matches(audio->audio_decoder_config()));
- ExpectRead(stream, 779);
+ ExpectRead(DemuxerStream::AUDIO, 779);
// Read until the end of the stream just to make sure there aren't any other
// config changes.
- ReadUntilNotOkOrEndOfStream(stream, &status, &last_timestamp);
+ ReadUntilNotOkOrEndOfStream(DemuxerStream::AUDIO, &status, &last_timestamp);
ASSERT_EQ(status, DemuxerStream::kOk);
}
@@ -2306,39 +2230,39 @@ TEST_F(ChunkDemuxerTest, TestConfigChange_Seek) {
ASSERT_TRUE(InitDemuxerWithConfigChangeData());
- scoped_refptr<DemuxerStream> stream =
+ scoped_refptr<DemuxerStream> video =
demuxer_->GetStream(DemuxerStream::VIDEO);
// Fetch initial video config and verify it matches what we expect.
- const VideoDecoderConfig& video_config_1 = stream->video_decoder_config();
+ const VideoDecoderConfig& video_config_1 = video->video_decoder_config();
ASSERT_TRUE(video_config_1.IsValidConfig());
EXPECT_EQ(video_config_1.natural_size().width(), 320);
EXPECT_EQ(video_config_1.natural_size().height(), 240);
- ExpectRead(stream, 0);
+ ExpectRead(DemuxerStream::VIDEO, 0);
// Seek to a location with a different config.
demuxer_->Seek(base::TimeDelta::FromMilliseconds(527),
NewExpectedStatusCB(PIPELINE_OK));
// Verify that the config change is signalled.
- ExpectConfigChanged(stream);
+ ExpectConfigChanged(DemuxerStream::VIDEO);
// Fetch the new decoder config and verify it is what we expect.
- const VideoDecoderConfig& video_config_2 = stream->video_decoder_config();
+ const VideoDecoderConfig& video_config_2 = video->video_decoder_config();
ASSERT_TRUE(video_config_2.IsValidConfig());
EXPECT_EQ(video_config_2.natural_size().width(), 640);
EXPECT_EQ(video_config_2.natural_size().height(), 360);
// Verify that Read() will return a buffer now.
- ExpectRead(stream, 527);
+ ExpectRead(DemuxerStream::VIDEO, 527);
// Seek back to the beginning and verify we get another config change.
demuxer_->Seek(base::TimeDelta::FromMilliseconds(0),
NewExpectedStatusCB(PIPELINE_OK));
- ExpectConfigChanged(stream);
- ASSERT_TRUE(video_config_1.Matches(stream->video_decoder_config()));
- ExpectRead(stream, 0);
+ ExpectConfigChanged(DemuxerStream::VIDEO);
+ ASSERT_TRUE(video_config_1.Matches(video->video_decoder_config()));
+ ExpectRead(DemuxerStream::VIDEO, 0);
// Seek to a location that requires a config change and then
// seek to a new location that has the same configuration as
@@ -2349,8 +2273,8 @@ TEST_F(ChunkDemuxerTest, TestConfigChange_Seek) {
NewExpectedStatusCB(PIPELINE_OK));
// Verify that no config change is signalled.
- ExpectRead(stream, 801);
- ASSERT_TRUE(video_config_1.Matches(stream->video_decoder_config()));
+ ExpectRead(DemuxerStream::VIDEO, 801);
+ ASSERT_TRUE(video_config_1.Matches(video->video_decoder_config()));
}
TEST_F(ChunkDemuxerTest, TestTimestampPositiveOffset) {
@@ -2365,11 +2289,7 @@ TEST_F(ChunkDemuxerTest, TestTimestampPositiveOffset) {
demuxer_->Seek(base::TimeDelta::FromMilliseconds(30000),
NewExpectedStatusCB(PIPELINE_OK));
- scoped_refptr<DemuxerStream> audio =
- demuxer_->GetStream(DemuxerStream::AUDIO);
- scoped_refptr<DemuxerStream> video =
- demuxer_->GetStream(DemuxerStream::VIDEO);
- GenerateExpectedReads(30000, 2, audio, video);
+ GenerateExpectedReads(30000, 2);
}
TEST_F(ChunkDemuxerTest, TestTimestampNegativeOffset) {
@@ -2380,11 +2300,7 @@ TEST_F(ChunkDemuxerTest, TestTimestampNegativeOffset) {
scoped_ptr<Cluster> cluster = GenerateCluster(1000, 2);
AppendData(cluster->data(), cluster->size());
- scoped_refptr<DemuxerStream> audio =
- demuxer_->GetStream(DemuxerStream::AUDIO);
- scoped_refptr<DemuxerStream> video =
- demuxer_->GetStream(DemuxerStream::VIDEO);
- GenerateExpectedReads(0, 2, audio, video);
+ GenerateExpectedReads(0, 2);
}
TEST_F(ChunkDemuxerTest, TestTimestampOffsetSeparateStreams) {
@@ -2392,11 +2308,6 @@ TEST_F(ChunkDemuxerTest, TestTimestampOffsetSeparateStreams) {
std::string video_id = "video1";
ASSERT_TRUE(InitDemuxerAudioAndVideoSources(audio_id, video_id));
- scoped_refptr<DemuxerStream> audio =
- demuxer_->GetStream(DemuxerStream::AUDIO);
- scoped_refptr<DemuxerStream> video =
- demuxer_->GetStream(DemuxerStream::VIDEO);
-
scoped_ptr<Cluster> cluster_a1(
GenerateSingleStreamCluster(
2500, 2500 + kAudioBlockDuration * 4, kAudioTrackNum,
@@ -2421,8 +2332,8 @@ TEST_F(ChunkDemuxerTest, TestTimestampOffsetSeparateStreams) {
video_id, base::TimeDelta::FromMilliseconds(-2500)));
AppendData(audio_id, cluster_a1->data(), cluster_a1->size());
AppendData(video_id, cluster_v1->data(), cluster_v1->size());
- GenerateSingleStreamExpectedReads(0, 4, audio, kAudioBlockDuration);
- GenerateSingleStreamExpectedReads(0, 4, video, kVideoBlockDuration);
+ GenerateAudioStreamExpectedReads(0, 4);
+ GenerateVideoStreamExpectedReads(0, 4);
demuxer_->StartWaitingForSeek();
demuxer_->Seek(base::TimeDelta::FromMilliseconds(27300),
@@ -2434,8 +2345,8 @@ TEST_F(ChunkDemuxerTest, TestTimestampOffsetSeparateStreams) {
video_id, base::TimeDelta::FromMilliseconds(27300)));
AppendData(audio_id, cluster_a2->data(), cluster_a2->size());
AppendData(video_id, cluster_v2->data(), cluster_v2->size());
- GenerateSingleStreamExpectedReads(27300, 4, video, kVideoBlockDuration);
- GenerateSingleStreamExpectedReads(27300, 4, audio, kAudioBlockDuration);
+ GenerateVideoStreamExpectedReads(27300, 4);
+ GenerateAudioStreamExpectedReads(27300, 4);
}
TEST_F(ChunkDemuxerTest, TestTimestampOffsetMidParse) {