Index: media/test/pipeline_integration_test.cc |
diff --git a/media/test/pipeline_integration_test.cc b/media/test/pipeline_integration_test.cc |
index d51bb2eaddd7c0b3f4ac3bedffc422030c584055..3b57543f1de7b0e74a2b8dc787bd1a051cad3310 100644 |
--- a/media/test/pipeline_integration_test.cc |
+++ b/media/test/pipeline_integration_test.cc |
@@ -540,8 +540,9 @@ class MockMediaSource { |
chunk_demuxer_->SetMemoryLimitsForTest(DemuxerStream::VIDEO, limit_bytes); |
} |
- void EvictCodedFrames(base::TimeDelta currentMediaTime, size_t newDataSize) { |
- chunk_demuxer_->EvictCodedFrames(kSourceId, currentMediaTime, newDataSize); |
+ bool EvictCodedFrames(base::TimeDelta currentMediaTime, size_t newDataSize) { |
+ return chunk_demuxer_->EvictCodedFrames(kSourceId, currentMediaTime, |
+ newDataSize); |
} |
void RemoveRange(base::TimeDelta start, base::TimeDelta end) { |
@@ -1565,6 +1566,36 @@ TEST_F(PipelineIntegrationTest, MediaSource_FillUp_Buffer) { |
Stop(); |
} |
+TEST_F(PipelineIntegrationTest, MediaSource_GCWithDisabledVideoStream) { |
+ const char* input_filename = "bear-320x240.webm"; |
+ MockMediaSource source(input_filename, kWebM, kAppendWholeFile); |
+ EXPECT_EQ(PIPELINE_OK, StartPipelineWithMediaSource(&source)); |
+ scoped_refptr<DecoderBuffer> file = ReadTestDataFile(input_filename); |
+ // The input file contains audio + video data. Assuming video data size is |
+ // larger than audio, so setting memory limits to half of file data_size will |
+ // ensure that video SourceBuffer is above memory limit and the audio |
+ // SourceBuffer is below the memory limit. |
+ source.SetMemoryLimits(file->data_size() / 2); |
+ |
+ // Disable the video track and start playback. Renderer won't read from the |
+ // disabled video stream, so the video stream read position should be 0. |
+ pipeline_->OnSelectedVideoTrackChanged(base::nullopt); |
+ Play(); |
+ |
+ // Wait until audio playback advances past 2 seconds and call MSE GC algorithm |
+ // to prepare for more data to be appended. |
+ base::TimeDelta media_time = base::TimeDelta::FromSeconds(2); |
+ ASSERT_TRUE(WaitUntilCurrentTimeIsAfter(media_time)); |
+ // At this point the video SourceBuffer is over the memory limit (see the |
+ // SetMemoryLimits comment above), but MSE GC should be able to remove some |
+ // of video data and return true indicating success, even though no data has |
+ // been read from the disabled video stream and its read position is 0. |
+ ASSERT_TRUE(source.EvictCodedFrames(media_time, 10)); |
+ |
+ source.Shutdown(); |
+ Stop(); |
+} |
+ |
TEST_F(PipelineIntegrationTest, |
MAYBE_EME(MediaSource_ConfigChange_Encrypted_WebM)) { |
MockMediaSource source("bear-320x240-16x9-aspect-av_enc-av.webm", kWebM, |