Commit 9fc07690 authored by Sergey Volk's avatar Sergey Volk Committed by Commit Bot

Add a test for FFmpegDemuxer memory usage in the multi-track case

We had a bug where FFmpegDemuxer usage was too high due to excessive
buffering caused by not taking into account enabled/disabled stream
status. This unit test should provide test coverage for that.

BUG=740138

Change-Id: Ia29175a8c90be4465aeffe189d7d8e48e738ef68
Reviewed-on: https://chromium-review.googlesource.com/575390Reviewed-by: default avatarDale Curtis <dalecurtis@chromium.org>
Commit-Queue: Sergey Volk <servolk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#487306}
parent 1b7c8508
...@@ -1660,4 +1660,32 @@ TEST_F(FFmpegDemuxerTest, StreamStatusNotifications) { ...@@ -1660,4 +1660,32 @@ TEST_F(FFmpegDemuxerTest, StreamStatusNotifications) {
CheckStreamStatusNotifications(demuxer_.get(), video_stream); CheckStreamStatusNotifications(demuxer_.get(), video_stream);
} }
TEST_F(FFmpegDemuxerTest, MultitrackMemoryUsage) {
CreateDemuxer("multitrack-3video-2audio.webm");
InitializeDemuxer();
DemuxerStream* audio = GetStream(DemuxerStream::AUDIO);
// Read from the audio stream to make sure FFmpegDemuxer buffers data for all
// streams with available capacity, i.e all enabled streams. By default only
// the first audio and the first video stream are enabled, so the memory usage
// shouldn't be too high.
audio->Read(NewReadCB(FROM_HERE, 304, 0, true));
base::RunLoop().Run();
EXPECT_EQ(22134, demuxer_->GetMemoryUsage());
// Now enable all demuxer streams in the file and perform another read, this
// will buffer the data for additional streams and memory usage will increase.
std::vector<DemuxerStream*> streams = demuxer_->GetAllStreams();
for (auto* stream : streams)
static_cast<FFmpegDemuxerStream*>(stream)->SetEnabled(true,
base::TimeDelta());
audio->Read(NewReadCB(FROM_HERE, 166, 21000, true));
base::RunLoop().Run();
// With newly enabled demuxer streams the amount of memory used by the demuxer
// is much higher.
EXPECT_EQ(156011, demuxer_->GetMemoryUsage());
}
} // namespace media } // namespace media
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment