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

Unified Diff: media/filters/chunk_demuxer_unittest.cc

Issue 794343003: Implement evictFrames() to support MSE's coded frame eviction algorithm. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated existing SourceBufferStream unittests Created 6 years 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/chunk_demuxer.cc ('k') | media/filters/source_buffer_range.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/filters/chunk_demuxer_unittest.cc
diff --git a/media/filters/chunk_demuxer_unittest.cc b/media/filters/chunk_demuxer_unittest.cc
index 71e2e786bf9fd1482f744a125110b9e65b76155c..4352184e4c985fbb3bacc364a7a9102b2995e9b6 100644
--- a/media/filters/chunk_demuxer_unittest.cc
+++ b/media/filters/chunk_demuxer_unittest.cc
@@ -104,6 +104,10 @@ static void WriteInt64(uint8* buffer, int64 number) {
}
}
+base::TimeDelta DummyGetMediaTime(base::TimeDelta time) {
+ return time;
+}
+
MATCHER_P(HasTimestamp, timestamp_in_ms, "") {
return arg.get() && !arg->end_of_stream() &&
arg->timestamp().InMilliseconds() == timestamp_in_ms;
@@ -3335,7 +3339,7 @@ TEST_F(ChunkDemuxerTest, SetMemoryLimitType) {
// Set different memory limits for audio and video.
demuxer_->SetMemoryLimits(DemuxerStream::AUDIO, 10 * kBlockSize);
- demuxer_->SetMemoryLimits(DemuxerStream::VIDEO, 5 * kBlockSize);
+ demuxer_->SetMemoryLimits(DemuxerStream::VIDEO, 5 * kBlockSize + 1);
base::TimeDelta seek_time = base::TimeDelta::FromMilliseconds(1000);
@@ -3343,6 +3347,9 @@ TEST_F(ChunkDemuxerTest, SetMemoryLimitType) {
AppendSingleStreamCluster(kSourceId, kAudioTrackNum, 0, 10);
AppendSingleStreamCluster(kSourceId, kVideoTrackNum, 0, 5);
+ // We should be right at buffer limit, should pass
+ EXPECT_TRUE(demuxer_->EvictFrames());
+
CheckExpectedRanges(DemuxerStream::AUDIO, "{ [0,230) }");
CheckExpectedRanges(DemuxerStream::VIDEO, "{ [0,165) }");
@@ -3355,6 +3362,9 @@ TEST_F(ChunkDemuxerTest, SetMemoryLimitType) {
AppendSingleStreamCluster(kSourceId, kVideoTrackNum,
seek_time.InMilliseconds(), 5);
+ // We should delete first append, and be exactly at buffer limit
+ EXPECT_TRUE(demuxer_->EvictFrames());
+
// Verify that the old data, and nothing more, has been garbage collected.
CheckExpectedRanges(DemuxerStream::AUDIO, "{ [1000,1230) }");
CheckExpectedRanges(DemuxerStream::VIDEO, "{ [1000,1165) }");
@@ -3379,12 +3389,13 @@ TEST_F(ChunkDemuxerTest, GCDuringSeek) {
// Signal that the second seek is starting.
demuxer_->StartWaitingForSeek(seek_time2);
- // Append data to satisfy the second seek. This append triggers
- // the garbage collection logic since we set the memory limit to
- // 5 blocks.
+ // Append data to satisfy the second seek.
AppendSingleStreamCluster(kSourceId, kAudioTrackNum,
seek_time2.InMilliseconds(), 5);
+ // Should remove first append
+ EXPECT_TRUE(demuxer_->EvictFrames());
+
// Verify that the buffers that cover |seek_time2| do not get
// garbage collected.
CheckExpectedRanges(kSourceId, "{ [500,615) }");
@@ -3392,15 +3403,48 @@ TEST_F(ChunkDemuxerTest, GCDuringSeek) {
// Complete the seek.
demuxer_->Seek(seek_time2, NewExpectedStatusCB(PIPELINE_OK));
-
// Append more data and make sure that the blocks for |seek_time2|
// don't get removed.
- //
- // NOTE: The current GC algorithm tries to preserve the GOP at the
- // current position as well as the last appended GOP. This is
- // why there are 2 ranges in the expectations.
AppendSingleStreamCluster(kSourceId, kAudioTrackNum, 700, 5);
- CheckExpectedRanges(kSourceId, "{ [500,592) [792,815) }");
+
+ // We should not delete things between head and last append, so buffer
+ // remains overfull.
+ EXPECT_FALSE(demuxer_->EvictFrames());
+
+ CheckExpectedRanges(kSourceId, "{ [500,615) [700,815) }");
+}
+
+TEST_F(ChunkDemuxerTest, GCKeepPlayhead) {
+ ASSERT_TRUE(InitDemuxer(HAS_AUDIO));
+
+ // Set different memory limits for audio and video.
+ demuxer_->SetMemoryLimits(DemuxerStream::AUDIO, 5 * kBlockSize);
+
+ // Set media time provider to report playback head at 0ms
+ demuxer_->SetMediaTimeProvider(
+ base::Bind(DummyGetMediaTime, base::TimeDelta()));
+
+ // Append data at the start that can be garbage collected:
+ AppendSingleStreamCluster(kSourceId, kAudioTrackNum, 0, 10);
+
+ // We expect garbage collection to fail, as we don't want to spontaneously
+ // create gaps in source buffer stream. This could screw up playback for many
+ // clients, who don't bother to check ranges after append.
+ EXPECT_FALSE(demuxer_->EvictFrames());
+ CheckExpectedRanges(kSourceId, "{ [0,230) }");
+
+ // Seek, confirm that media time holds us at zero
+ base::TimeDelta seek_time = base::TimeDelta::FromMilliseconds(207);
+ Seek(seek_time);
+
+ EXPECT_FALSE(demuxer_->EvictFrames());
+ CheckExpectedRanges(kSourceId, "{ [0,230) }");
+
+ // Progress media time, show that we can collect up to that point
+ demuxer_->SetMediaTimeProvider(
+ base::Bind(DummyGetMediaTime, base::TimeDelta::FromMilliseconds(69)));
+ EXPECT_FALSE(demuxer_->EvictFrames());
+ CheckExpectedRanges(kSourceId, "{ [69,230) }");
}
TEST_F(ChunkDemuxerTest, AppendWindow_Video) {
« no previous file with comments | « media/filters/chunk_demuxer.cc ('k') | media/filters/source_buffer_range.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698