Index: media/filters/ffmpeg_demuxer_unittest.cc |
=================================================================== |
--- media/filters/ffmpeg_demuxer_unittest.cc (revision 105891) |
+++ media/filters/ffmpeg_demuxer_unittest.cc (working copy) |
@@ -60,7 +60,12 @@ |
demuxer_ = NULL; |
} |
- scoped_refptr<DataSource> CreateDataSource(const std::string& name) { |
+ scoped_refptr<FileDataSource> CreateDataSource(const std::string& name) { |
+ return CreateDataSource(name, false); |
+ } |
+ |
+ scoped_refptr<FileDataSource> CreateDataSource(const std::string& name, |
+ bool disable_file_size) { |
FilePath file_path; |
EXPECT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &file_path)); |
@@ -69,7 +74,8 @@ |
.Append(FILE_PATH_LITERAL("data")) |
.AppendASCII(name); |
- scoped_refptr<FileDataSource> data_source = new FileDataSource(); |
+ scoped_refptr<FileDataSource> data_source = new FileDataSource( |
+ disable_file_size); |
EXPECT_EQ(PIPELINE_OK, data_source->Initialize(file_path.MaybeAsASCII())); |
@@ -101,6 +107,18 @@ |
buffer->GetTimestamp()); |
} |
+ // Creates a data source with the given |file_name|. If |disable_file_size| |
+ // then the data source pretends it does not know the file size (e.g. often |
+ // when streaming video). Uses this data source to initialize a demuxer, then |
+ // returns true if the bitrate is valid, false otherwise. |
+ bool VideoHasValidBitrate( |
+ const std::string& file_name, bool disable_file_size) { |
+ scoped_refptr<FileDataSource> data_source = |
+ CreateDataSource(file_name, disable_file_size); |
+ InitializeDemuxer(data_source); |
+ return demuxer_->GetBitrate() > 0; |
+ } |
+ |
// Fixture members. |
scoped_refptr<FFmpegDemuxer> demuxer_; |
StrictMock<MockFilterHost> host_; |
@@ -498,6 +516,22 @@ |
message_loop_.RunAllPending(); |
} |
+TEST_F(FFmpegDemuxerTest, GetBitrate_SetInContainer) { |
+ EXPECT_TRUE(VideoHasValidBitrate("bear.ogv", false)); |
+} |
+ |
+TEST_F(FFmpegDemuxerTest, GetBitrate_UnsetInContainer_KnownSize) { |
+ EXPECT_TRUE(VideoHasValidBitrate("bear-320x240.webm", false)); |
+} |
+ |
+TEST_F(FFmpegDemuxerTest, GetBitrate_SetInContainer_NoFileSize) { |
+ EXPECT_TRUE(VideoHasValidBitrate("bear.ogv", true)); |
+} |
+ |
+TEST_F(FFmpegDemuxerTest, GetBitrate_UnsetInContainer_NoFileSize) { |
+ EXPECT_FALSE(VideoHasValidBitrate("bear-320x240.webm", true)); |
+} |
+ |
TEST_F(FFmpegDemuxerTest, ProtocolGetSetPosition) { |
scoped_refptr<DataSource> data_source = CreateDataSource("bear-320x240.webm"); |
InitializeDemuxer(data_source); |