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

Side by Side Diff: media/filters/chunk_demuxer_unittest.cc

Issue 1349973002: Fix seeking back in the new MSE GC algorithm (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 months 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <algorithm> 5 #include <algorithm>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "base/strings/string_split.h" 10 #include "base/strings/string_split.h"
(...skipping 3349 matching lines...) Expand 10 before | Expand all | Expand 10 after
3360 seek_time.InMilliseconds(), 5); 3360 seek_time.InMilliseconds(), 5);
3361 3361
3362 // We should delete first append, and be exactly at buffer limit 3362 // We should delete first append, and be exactly at buffer limit
3363 EXPECT_TRUE(demuxer_->EvictCodedFrames(kSourceId, seek_time, 0)); 3363 EXPECT_TRUE(demuxer_->EvictCodedFrames(kSourceId, seek_time, 0));
3364 3364
3365 // Verify that the old data, and nothing more, has been garbage collected. 3365 // Verify that the old data, and nothing more, has been garbage collected.
3366 CheckExpectedRanges(DemuxerStream::AUDIO, "{ [1000,1230) }"); 3366 CheckExpectedRanges(DemuxerStream::AUDIO, "{ [1000,1230) }");
3367 CheckExpectedRanges(DemuxerStream::VIDEO, "{ [1000,1165) }"); 3367 CheckExpectedRanges(DemuxerStream::VIDEO, "{ [1000,1165) }");
3368 } 3368 }
3369 3369
3370 TEST_F(ChunkDemuxerTest, GCDuringSeek_SingleRange_SeekForward) {
3371 ASSERT_TRUE(InitDemuxer(HAS_AUDIO));
3372 demuxer_->SetMemoryLimits(DemuxerStream::AUDIO, 10 * kBlockSize);
3373 // Append some data at position 1000ms
3374 AppendSingleStreamCluster(kSourceId, kAudioTrackNum, 1000, 10);
3375 CheckExpectedRanges(kSourceId, "{ [1000,1230) }");
3376
3377 // GC should be able to evict frames in the currently buffered range, since
3378 // those frames are earlier than the seek target position.
3379 base::TimeDelta seek_time = base::TimeDelta::FromMilliseconds(2000);
3380 Seek(seek_time);
3381 EXPECT_TRUE(demuxer_->EvictCodedFrames(kSourceId, seek_time, 5 * kBlockSize));
3382
3383 // Append data to complete seek operation
3384 AppendSingleStreamCluster(kSourceId, kAudioTrackNum, 2000, 5);
3385 CheckExpectedRanges(kSourceId, "{ [1115,1230) [2000,2115) }");
3386 }
3387
3388 TEST_F(ChunkDemuxerTest, GCDuringSeek_SingleRange_SeekBack) {
3389 ASSERT_TRUE(InitDemuxer(HAS_AUDIO));
3390 demuxer_->SetMemoryLimits(DemuxerStream::AUDIO, 10 * kBlockSize);
3391 // Append some data at position 1000ms
3392 AppendSingleStreamCluster(kSourceId, kAudioTrackNum, 1000, 10);
3393 CheckExpectedRanges(kSourceId, "{ [1000,1230) }");
3394
3395 // GC should be able to evict frames in the currently buffered range, since
3396 // seek target position has no data and so we should allow some frames to be
3397 // evicted to make space for the upcoming append at seek target position.
3398 base::TimeDelta seek_time = base::TimeDelta::FromMilliseconds(0);
3399 Seek(seek_time);
3400 EXPECT_TRUE(demuxer_->EvictCodedFrames(kSourceId, seek_time, 5 * kBlockSize));
3401
3402 // Append data to complete seek operation
3403 AppendSingleStreamCluster(kSourceId, kAudioTrackNum, 0, 5);
3404 CheckExpectedRanges(kSourceId, "{ [0,115) [1115,1230) }");
3405 }
3406
3407 TEST_F(ChunkDemuxerTest, GCDuringSeek_MultipleRanges_SeekForward) {
3408 ASSERT_TRUE(InitDemuxer(HAS_AUDIO));
3409 demuxer_->SetMemoryLimits(DemuxerStream::AUDIO, 10 * kBlockSize);
3410 // Append some data at position 1000ms then at 2000ms
3411 AppendSingleStreamCluster(kSourceId, kAudioTrackNum, 1000, 5);
3412 AppendSingleStreamCluster(kSourceId, kAudioTrackNum, 2000, 5);
3413 CheckExpectedRanges(kSourceId, "{ [1000,1115) [2000,2115) }");
3414
3415 // GC should be able to evict frames in the currently buffered range, since
wolenetz 2015/09/17 18:57:54 nit:s/range/ranges/
servolk 2015/09/18 01:29:27 Done.
3416 // those frames are earlier than the seek target position.
3417 base::TimeDelta seek_time = base::TimeDelta::FromMilliseconds(3000);
3418 Seek(seek_time);
3419 EXPECT_TRUE(demuxer_->EvictCodedFrames(kSourceId, seek_time, 8 * kBlockSize));
3420
3421 // Append data to complete seek operation
3422 AppendSingleStreamCluster(kSourceId, kAudioTrackNum, 3000, 5);
3423 CheckExpectedRanges(kSourceId, "{ [2069,2115) [3000,3115) }");
3424 }
3425
3426 TEST_F(ChunkDemuxerTest, GCDuringSeek_MultipleRanges_SeekInbetween) {
3427 ASSERT_TRUE(InitDemuxer(HAS_AUDIO));
3428 demuxer_->SetMemoryLimits(DemuxerStream::AUDIO, 10 * kBlockSize);
3429 // Append some data at position 1000ms then at 2000ms
3430 AppendSingleStreamCluster(kSourceId, kAudioTrackNum, 1000, 5);
3431 AppendSingleStreamCluster(kSourceId, kAudioTrackNum, 2000, 5);
3432 CheckExpectedRanges(kSourceId, "{ [1000,1115) [2000,2115) }");
3433
3434 // GC should be able to evict frames from the front, since
wolenetz 2015/09/17 18:57:54 nit: it's collecting from front conservatively, th
servolk 2015/09/18 01:29:28 Good point, I've expanded this comment to explain
3435 // those frames are earlier than the seek target position.
3436 base::TimeDelta seek_time = base::TimeDelta::FromMilliseconds(1500);
3437 Seek(seek_time);
3438 EXPECT_TRUE(demuxer_->EvictCodedFrames(kSourceId, seek_time, 8 * kBlockSize));
3439
3440 // Append data to complete seek operation
3441 AppendSingleStreamCluster(kSourceId, kAudioTrackNum, 1500, 5);
3442 CheckExpectedRanges(kSourceId, "{ [1500,1615) [2069,2115) }");
3443 }
3444
3445 TEST_F(ChunkDemuxerTest, GCDuringSeek_MultipleRanges_SeekBack) {
3446 ASSERT_TRUE(InitDemuxer(HAS_AUDIO));
3447 demuxer_->SetMemoryLimits(DemuxerStream::AUDIO, 10 * kBlockSize);
3448 // Append some data at position 1000ms then at 2000ms
3449 AppendSingleStreamCluster(kSourceId, kAudioTrackNum, 1000, 5);
3450 AppendSingleStreamCluster(kSourceId, kAudioTrackNum, 2000, 5);
3451 CheckExpectedRanges(kSourceId, "{ [1000,1115) [2000,2115) }");
3452
3453 // GC should be able to evict frames in the currently buffered range, since
3454 // those frames are earlier than the seek target position.
3455 base::TimeDelta seek_time = base::TimeDelta::FromMilliseconds(0);
wolenetz 2015/09/17 18:57:54 weak nit: here and elsewhere, just base::TimeDelta
servolk 2015/09/18 01:29:28 It makes sense in retrospect, but I just didn't re
3456 Seek(seek_time);
3457 EXPECT_TRUE(demuxer_->EvictCodedFrames(kSourceId, seek_time, 8 * kBlockSize));
3458
3459 // Append data to complete seek operation
3460 AppendSingleStreamCluster(kSourceId, kAudioTrackNum, 0, 5);
3461 CheckExpectedRanges(kSourceId, "{ [0,115) [2069,2115) }");
3462 }
3463
3370 TEST_F(ChunkDemuxerTest, GCDuringSeek) { 3464 TEST_F(ChunkDemuxerTest, GCDuringSeek) {
3371 ASSERT_TRUE(InitDemuxer(HAS_AUDIO)); 3465 ASSERT_TRUE(InitDemuxer(HAS_AUDIO));
3372 3466
3373 demuxer_->SetMemoryLimits(DemuxerStream::AUDIO, 5 * kBlockSize); 3467 demuxer_->SetMemoryLimits(DemuxerStream::AUDIO, 5 * kBlockSize);
3374 3468
3375 base::TimeDelta seek_time1 = base::TimeDelta::FromMilliseconds(1000); 3469 base::TimeDelta seek_time1 = base::TimeDelta::FromMilliseconds(1000);
3376 base::TimeDelta seek_time2 = base::TimeDelta::FromMilliseconds(500); 3470 base::TimeDelta seek_time2 = base::TimeDelta::FromMilliseconds(500);
3377 3471
3378 // Initiate a seek to |seek_time1|. 3472 // Initiate a seek to |seek_time1|.
3379 Seek(seek_time1); 3473 Seek(seek_time1);
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after
3848 // audio size is 80 bytes, new data is 28 bytes, we need to remove just one 10 3942 // audio size is 80 bytes, new data is 28 bytes, we need to remove just one 10
3849 // byte block to stay under 100 bytes memory limit after append 3943 // byte block to stay under 100 bytes memory limit after append
3850 // 80 - 10 + 28 = 98). 3944 // 80 - 10 + 28 = 98).
3851 // For video stream 150 + 52 = 202. Video limit is 150 bytes. We need to 3945 // For video stream 150 + 52 = 202. Video limit is 150 bytes. We need to
3852 // remove at least 6 blocks to stay under limit. 3946 // remove at least 6 blocks to stay under limit.
3853 CheckExpectedBuffers(audio_stream, "40K 80K 120K 160K 200K 240K 280K"); 3947 CheckExpectedBuffers(audio_stream, "40K 80K 120K 160K 200K 240K 280K");
3854 CheckExpectedBuffers(video_stream, "60K 70 80K 90 100K 110 120K 130 140K"); 3948 CheckExpectedBuffers(video_stream, "60K 70 80K 90 100K 110 120K 130 140K");
3855 } 3949 }
3856 3950
3857 } // namespace media 3951 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | media/filters/source_buffer_stream.cc » ('j') | media/filters/source_buffer_stream.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698