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

Unified Diff: media/filters/ffmpeg_demuxer_unittest.cc

Issue 23702007: Render inband text tracks in the media pipeline (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: fix compile errors 11/21 #6 Created 7 years, 1 month 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/ffmpeg_demuxer.cc ('k') | media/filters/pipeline_integration_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/filters/ffmpeg_demuxer_unittest.cc
diff --git a/media/filters/ffmpeg_demuxer_unittest.cc b/media/filters/ffmpeg_demuxer_unittest.cc
index f5b0e978fe4174b04afd192695c863600fe18938..7c6fcb5b11a77af289907715b71fa152357ae1a1 100644
--- a/media/filters/ffmpeg_demuxer_unittest.cc
+++ b/media/filters/ffmpeg_demuxer_unittest.cc
@@ -83,6 +83,7 @@ class FFmpegDemuxerTest : public testing::Test {
Demuxer::NeedKeyCB need_key_cb =
base::Bind(&FFmpegDemuxerTest::NeedKeyCB, base::Unretained(this));
+
demuxer_.reset(new FFmpegDemuxer(message_loop_.message_loop_proxy(),
data_source_.get(),
need_key_cb,
@@ -91,13 +92,17 @@ class FFmpegDemuxerTest : public testing::Test {
MOCK_METHOD1(CheckPoint, void(int v));
- void InitializeDemuxer() {
+ void InitializeDemuxerText(bool enable_text) {
EXPECT_CALL(host_, SetDuration(_));
WaitableMessageLoopEvent event;
- demuxer_->Initialize(&host_, event.GetPipelineStatusCB());
+ demuxer_->Initialize(&host_, event.GetPipelineStatusCB(), enable_text);
event.RunAndWaitForStatus(PIPELINE_OK);
}
+ void InitializeDemuxer() {
+ InitializeDemuxerText(false);
+ }
+
MOCK_METHOD2(OnReadDoneCalled, void(int, int64));
// Verifies that |buffer| has a specific |size| and |timestamp|.
@@ -199,7 +204,7 @@ TEST_F(FFmpegDemuxerTest, Initialize_OpenFails) {
// Simulate avformat_open_input() failing.
CreateDemuxer("ten_byte_file");
WaitableMessageLoopEvent event;
- demuxer_->Initialize(&host_, event.GetPipelineStatusCB());
+ demuxer_->Initialize(&host_, event.GetPipelineStatusCB(), true);
event.RunAndWaitForStatus(DEMUXER_ERROR_COULD_NOT_OPEN);
}
@@ -217,7 +222,7 @@ TEST_F(FFmpegDemuxerTest, Initialize_NoStreams) {
// Open a file with no streams whatsoever.
CreateDemuxer("no_streams.webm");
WaitableMessageLoopEvent event;
- demuxer_->Initialize(&host_, event.GetPipelineStatusCB());
+ demuxer_->Initialize(&host_, event.GetPipelineStatusCB(), true);
event.RunAndWaitForStatus(DEMUXER_ERROR_NO_SUPPORTED_STREAMS);
}
@@ -225,7 +230,7 @@ TEST_F(FFmpegDemuxerTest, Initialize_NoAudioVideo) {
// Open a file containing streams but none of which are audio/video streams.
CreateDemuxer("no_audio_video.webm");
WaitableMessageLoopEvent event;
- demuxer_->Initialize(&host_, event.GetPipelineStatusCB());
+ demuxer_->Initialize(&host_, event.GetPipelineStatusCB(), true);
event.RunAndWaitForStatus(DEMUXER_ERROR_NO_SUPPORTED_STREAMS);
}
@@ -298,6 +303,36 @@ TEST_F(FFmpegDemuxerTest, Initialize_Multitrack) {
EXPECT_FALSE(demuxer_->GetStream(DemuxerStream::UNKNOWN));
}
+TEST_F(FFmpegDemuxerTest, Initialize_MultitrackText) {
+ // Open a file containing the following streams:
+ // Stream #0: Video (VP8)
+ // Stream #1: Audio (Vorbis)
+ // Stream #2: Text (WebVTT)
+
+ CreateDemuxer("bear-vp8-webvtt.webm");
+ DemuxerStream* text_stream = NULL;
+ EXPECT_CALL(host_, AddTextStream(_, _))
+ .WillOnce(SaveArg<0>(&text_stream));
+ InitializeDemuxerText(true);
+ ASSERT_TRUE(text_stream);
+ EXPECT_EQ(DemuxerStream::TEXT, text_stream->type());
+
+ // Video stream should be VP8.
+ DemuxerStream* stream = demuxer_->GetStream(DemuxerStream::VIDEO);
+ ASSERT_TRUE(stream);
+ EXPECT_EQ(DemuxerStream::VIDEO, stream->type());
+ EXPECT_EQ(kCodecVP8, stream->video_decoder_config().codec());
+
+ // Audio stream should be Vorbis.
+ stream = demuxer_->GetStream(DemuxerStream::AUDIO);
+ ASSERT_TRUE(stream);
+ EXPECT_EQ(DemuxerStream::AUDIO, stream->type());
+ EXPECT_EQ(kCodecVorbis, stream->audio_decoder_config().codec());
+
+ // Unknown stream should never be present.
+ EXPECT_FALSE(demuxer_->GetStream(DemuxerStream::UNKNOWN));
+}
+
TEST_F(FFmpegDemuxerTest, Initialize_Encrypted) {
EXPECT_CALL(*this, NeedKeyCBMock(kWebMEncryptInitDataType, NotNull(),
DecryptConfig::kDecryptionKeySize))
@@ -337,6 +372,23 @@ TEST_F(FFmpegDemuxerTest, Read_Video) {
message_loop_.Run();
}
+TEST_F(FFmpegDemuxerTest, Read_Text) {
+ // We test that on a successful text packet read.
+ CreateDemuxer("bear-vp8-webvtt.webm");
+ DemuxerStream* text_stream = NULL;
+ EXPECT_CALL(host_, AddTextStream(_, _))
+ .WillOnce(SaveArg<0>(&text_stream));
+ InitializeDemuxerText(true);
+ ASSERT_TRUE(text_stream);
+ EXPECT_EQ(DemuxerStream::TEXT, text_stream->type());
+
+ text_stream->Read(NewReadCB(FROM_HERE, 31, 0));
+ message_loop_.Run();
+
+ text_stream->Read(NewReadCB(FROM_HERE, 19, 500000));
+ message_loop_.Run();
+}
+
TEST_F(FFmpegDemuxerTest, Read_VideoNonZeroStart) {
// Test the start time is the first timestamp of the video and audio stream.
CreateDemuxer("nonzero-start-time.webm");
@@ -365,6 +417,26 @@ TEST_F(FFmpegDemuxerTest, Read_EndOfStream) {
ReadUntilEndOfStream();
}
+TEST_F(FFmpegDemuxerTest, Read_EndOfStreamText) {
+ // Verify that end of stream buffers are created.
+ CreateDemuxer("bear-vp8-webvtt.webm");
+ DemuxerStream* text_stream = NULL;
+ EXPECT_CALL(host_, AddTextStream(_, _))
+ .WillOnce(SaveArg<0>(&text_stream));
+ InitializeDemuxerText(true);
+ ASSERT_TRUE(text_stream);
+ EXPECT_EQ(DemuxerStream::TEXT, text_stream->type());
+
+ bool got_eos_buffer = false;
+ const int kMaxBuffers = 10;
+ for (int i = 0; !got_eos_buffer && i < kMaxBuffers; i++) {
+ text_stream->Read(base::Bind(&EosOnReadDone, &got_eos_buffer));
+ message_loop_.Run();
+ }
+
+ EXPECT_TRUE(got_eos_buffer);
+}
+
TEST_F(FFmpegDemuxerTest, Read_EndOfStream_NoDuration) {
// Verify that end of stream buffers are created.
CreateDemuxer("bear-320x240.webm");
@@ -413,6 +485,58 @@ TEST_F(FFmpegDemuxerTest, Seek) {
message_loop_.Run();
}
+TEST_F(FFmpegDemuxerTest, SeekText) {
+ // We're testing that the demuxer frees all queued packets when it receives
+ // a Seek().
+ CreateDemuxer("bear-vp8-webvtt.webm");
+ DemuxerStream* text_stream = NULL;
+ EXPECT_CALL(host_, AddTextStream(_, _))
+ .WillOnce(SaveArg<0>(&text_stream));
+ InitializeDemuxerText(true);
+ ASSERT_TRUE(text_stream);
+ EXPECT_EQ(DemuxerStream::TEXT, text_stream->type());
+
+ // Get our streams.
+ DemuxerStream* video = demuxer_->GetStream(DemuxerStream::VIDEO);
+ DemuxerStream* audio = demuxer_->GetStream(DemuxerStream::AUDIO);
+ ASSERT_TRUE(video);
+ ASSERT_TRUE(audio);
+
+ // Read a text packet and release it.
+ text_stream->Read(NewReadCB(FROM_HERE, 31, 0));
+ message_loop_.Run();
+
+ // Issue a simple forward seek, which should discard queued packets.
+ WaitableMessageLoopEvent event;
+ demuxer_->Seek(base::TimeDelta::FromMicroseconds(1000000),
+ event.GetPipelineStatusCB());
+ event.RunAndWaitForStatus(PIPELINE_OK);
+
+ // Audio read #1.
+ audio->Read(NewReadCB(FROM_HERE, 145, 803000));
+ message_loop_.Run();
+
+ // Audio read #2.
+ audio->Read(NewReadCB(FROM_HERE, 148, 826000));
+ message_loop_.Run();
+
+ // Video read #1.
+ video->Read(NewReadCB(FROM_HERE, 5425, 801000));
+ message_loop_.Run();
+
+ // Video read #2.
+ video->Read(NewReadCB(FROM_HERE, 1906, 834000));
+ message_loop_.Run();
+
+ // Text read #1.
+ text_stream->Read(NewReadCB(FROM_HERE, 19, 500000));
+ message_loop_.Run();
+
+ // Text read #2.
+ text_stream->Read(NewReadCB(FROM_HERE, 19, 1000000));
+ message_loop_.Run();
+}
+
class MockReadCB {
public:
MockReadCB() {}
« no previous file with comments | « media/filters/ffmpeg_demuxer.cc ('k') | media/filters/pipeline_integration_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698