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

Unified Diff: media/filters/chunk_demuxer_unittest.cc

Issue 563773002: Allow setting different memory limits for different stream types (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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 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_stream.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 4ac5616b72e6b5dda8dd7b7d2e3d3f7d64687565..57b49b1f57fbf33359603c24f8b2f141b0366bfd 100644
--- a/media/filters/chunk_demuxer_unittest.cc
+++ b/media/filters/chunk_demuxer_unittest.cc
@@ -962,8 +962,19 @@ class ChunkDemuxerTest : public ::testing::Test {
void CheckExpectedRanges(const std::string& id,
const std::string& expected) {
- Ranges<base::TimeDelta> r = demuxer_->GetBufferedRanges(id);
+ CheckExpectedRanges(demuxer_->GetBufferedRanges(id), expected);
+ }
+ void CheckExpectedRanges(DemuxerStream::Type type,
+ const std::string& expected) {
+ ChunkDemuxerStream* stream =
+ static_cast<ChunkDemuxerStream*>(demuxer_->GetStream(type));
+ CheckExpectedRanges(stream->GetBufferedRanges(kDefaultDuration()),
+ expected);
+ }
+
+ void CheckExpectedRanges(const Ranges<base::TimeDelta>& r,
+ const std::string& expected) {
std::stringstream ss;
ss << "{ ";
for (size_t i = 0; i < r.size(); ++i) {
@@ -3269,10 +3280,40 @@ TEST_F(ChunkDemuxerTest, CanceledSeekDuringInitialPreroll) {
AppendCluster(seek_time.InMilliseconds(), 10);
}
+TEST_F(ChunkDemuxerTest, SetMemoryLimitType) {
+ ASSERT_TRUE(InitDemuxer(HAS_AUDIO | HAS_VIDEO));
+
+ // Set different memory limits for audio and video.
+ demuxer_->SetMemoryLimits(DemuxerStream::AUDIO, 10 * kBlockSize);
+ demuxer_->SetMemoryLimits(DemuxerStream::VIDEO, 5 * kBlockSize);
+
+ base::TimeDelta seek_time = base::TimeDelta::FromMilliseconds(1000);
+
+ // Append data at the start that can be garbage collected:
+ AppendSingleStreamCluster(kSourceId, kAudioTrackNum, 0, 10);
+ AppendSingleStreamCluster(kSourceId, kVideoTrackNum, 0, 5);
+
+ CheckExpectedRanges(DemuxerStream::AUDIO, "{ [0,230) }");
+ CheckExpectedRanges(DemuxerStream::VIDEO, "{ [0,165) }");
+
+ // Seek so we can garbage collect the data appended above.
+ Seek(seek_time);
+
+ // Append data at seek_time.
+ AppendSingleStreamCluster(kSourceId, kAudioTrackNum,
+ seek_time.InMilliseconds(), 10);
+ AppendSingleStreamCluster(kSourceId, kVideoTrackNum,
+ seek_time.InMilliseconds(), 5);
+
+ // Verify that the old data, and nothing more, has been garbage collected.
+ CheckExpectedRanges(DemuxerStream::AUDIO, "{ [1000,1230) }");
+ CheckExpectedRanges(DemuxerStream::VIDEO, "{ [1000,1165) }");
+}
+
TEST_F(ChunkDemuxerTest, GCDuringSeek) {
ASSERT_TRUE(InitDemuxer(HAS_AUDIO));
- demuxer_->SetMemoryLimitsForTesting(5 * kBlockSize);
+ demuxer_->SetMemoryLimits(DemuxerStream::AUDIO, 5 * kBlockSize);
base::TimeDelta seek_time1 = base::TimeDelta::FromMilliseconds(1000);
base::TimeDelta seek_time2 = base::TimeDelta::FromMilliseconds(500);
« no previous file with comments | « media/filters/chunk_demuxer.cc ('k') | media/filters/source_buffer_stream.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698