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

Side by Side Diff: media/test/pipeline_integration_test.cc

Issue 1526303004: Fix buffered range updates in media::Pipeline (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Android buildfix Created 4 years, 11 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
« no previous file with comments | « media/filters/ffmpeg_demuxer_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 pData, 553 pData,
554 size, 554 size,
555 append_window_start, 555 append_window_start,
556 append_window_end, 556 append_window_end,
557 &timestamp_offset, 557 &timestamp_offset,
558 base::Bind(&MockMediaSource::InitSegmentReceived, 558 base::Bind(&MockMediaSource::InitSegmentReceived,
559 base::Unretained(this))); 559 base::Unretained(this)));
560 last_timestamp_offset_ = timestamp_offset; 560 last_timestamp_offset_ = timestamp_offset;
561 } 561 }
562 562
563 void SetMemoryLimits(size_t limit_bytes) {
564 chunk_demuxer_->SetMemoryLimits(DemuxerStream::AUDIO, limit_bytes);
565 chunk_demuxer_->SetMemoryLimits(DemuxerStream::VIDEO, limit_bytes);
566 }
567
568 void EvictCodedFrames(base::TimeDelta currentMediaTime, size_t newDataSize) {
569 chunk_demuxer_->EvictCodedFrames(kSourceId, currentMediaTime, newDataSize);
570 }
571
572 void RemoveRange(base::TimeDelta start, base::TimeDelta end) {
573 chunk_demuxer_->Remove(kSourceId, start, end);
574 }
575
563 void EndOfStream() { 576 void EndOfStream() {
564 chunk_demuxer_->MarkEndOfStream(PIPELINE_OK); 577 chunk_demuxer_->MarkEndOfStream(PIPELINE_OK);
565 } 578 }
566 579
567 void Shutdown() { 580 void Shutdown() {
568 if (!chunk_demuxer_) 581 if (!chunk_demuxer_)
569 return; 582 return;
570 chunk_demuxer_->ResetParserState( 583 chunk_demuxer_->ResetParserState(
571 kSourceId, 584 kSourceId,
572 base::TimeDelta(), kInfiniteDuration(), &last_timestamp_offset_); 585 base::TimeDelta(), kInfiniteDuration(), &last_timestamp_offset_);
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after
1081 EXPECT_EQ(kAppendTimeMs + k640WebMFileDurationMs, 1094 EXPECT_EQ(kAppendTimeMs + k640WebMFileDurationMs,
1082 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); 1095 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds());
1083 1096
1084 Play(); 1097 Play();
1085 1098
1086 EXPECT_TRUE(WaitUntilOnEnded()); 1099 EXPECT_TRUE(WaitUntilOnEnded());
1087 source.Shutdown(); 1100 source.Shutdown();
1088 Stop(); 1101 Stop();
1089 } 1102 }
1090 1103
1104 TEST_F(PipelineIntegrationTest, MediaSource_Remove_Updates_BufferedRanges) {
1105 const char* input_filename = "bear-320x240.webm";
1106 MockMediaSource source(input_filename, kWebM, kAppendWholeFile);
1107 StartPipelineWithMediaSource(&source);
1108
1109 auto buffered_ranges = pipeline_->GetBufferedTimeRanges();
1110 EXPECT_EQ(1u, buffered_ranges.size());
1111 EXPECT_EQ(0, buffered_ranges.start(0).InMilliseconds());
1112 EXPECT_EQ(k320WebMFileDurationMs, buffered_ranges.end(0).InMilliseconds());
1113
1114 source.RemoveRange(base::TimeDelta::FromMilliseconds(1000),
1115 base::TimeDelta::FromMilliseconds(k320WebMFileDurationMs));
1116 buffered_ranges = pipeline_->GetBufferedTimeRanges();
1117 EXPECT_EQ(1u, buffered_ranges.size());
1118 EXPECT_EQ(0, buffered_ranges.start(0).InMilliseconds());
1119 EXPECT_EQ(1001, buffered_ranges.end(0).InMilliseconds());
1120
1121 source.Shutdown();
1122 Stop();
1123 }
1124
1125 // This test case imitates media playback with advancing media_time and
1126 // continuously adding new data. At some point we should reach the buffering
1127 // limit, after that MediaSource should evict some buffered data and that
1128 // evicted data shold be reflected in the change of media::Pipeline buffered
1129 // ranges (returned by GetBufferedTimeRanges). At that point the buffered ranges
1130 // will no longer start at 0.
1131 TEST_F(PipelineIntegrationTest, MediaSource_FillUp_Buffer) {
1132 const char* input_filename = "bear-320x240.webm";
1133 MockMediaSource source(input_filename, kWebM, kAppendWholeFile);
1134 StartPipelineWithMediaSource(&source);
1135 source.SetMemoryLimits(1048576);
1136
1137 scoped_refptr<DecoderBuffer> file = ReadTestDataFile(input_filename);
1138
1139 auto buffered_ranges = pipeline_->GetBufferedTimeRanges();
1140 EXPECT_EQ(1u, buffered_ranges.size());
1141 do {
1142 // Advance media_time to the end of the currently buffered data
1143 base::TimeDelta media_time = buffered_ranges.end(0);
1144 source.Seek(media_time);
1145 // Ask MediaSource to evict buffered data if buffering limit has been
1146 // reached (the data will be evicted from the front of the buffered range).
1147 source.EvictCodedFrames(media_time, file->data_size());
1148 source.AppendAtTime(media_time, file->data(), file->data_size());
1149 buffered_ranges = pipeline_->GetBufferedTimeRanges();
1150 } while (buffered_ranges.size() == 1 &&
1151 buffered_ranges.start(0) == base::TimeDelta::FromSeconds(0));
1152
1153 EXPECT_EQ(1u, buffered_ranges.size());
1154 source.Shutdown();
1155 Stop();
1156 }
1157
1091 #if !defined(DISABLE_EME_TESTS) 1158 #if !defined(DISABLE_EME_TESTS)
1092 TEST_F(PipelineIntegrationTest, MediaSource_ConfigChange_Encrypted_WebM) { 1159 TEST_F(PipelineIntegrationTest, MediaSource_ConfigChange_Encrypted_WebM) {
1093 MockMediaSource source("bear-320x240-16x9-aspect-av_enc-av.webm", kWebM, 1160 MockMediaSource source("bear-320x240-16x9-aspect-av_enc-av.webm", kWebM,
1094 kAppendWholeFile); 1161 kAppendWholeFile);
1095 FakeEncryptedMedia encrypted_media(new KeyProvidingApp()); 1162 FakeEncryptedMedia encrypted_media(new KeyProvidingApp());
1096 StartPipelineWithEncryptedMedia(&source, &encrypted_media); 1163 StartPipelineWithEncryptedMedia(&source, &encrypted_media);
1097 1164
1098 scoped_refptr<DecoderBuffer> second_file = 1165 scoped_refptr<DecoderBuffer> second_file =
1099 ReadTestDataFile("bear-640x360-av_enc-av.webm"); 1166 ReadTestDataFile("bear-640x360-av_enc-av.webm");
1100 1167
(...skipping 835 matching lines...) Expand 10 before | Expand all | Expand 10 after
1936 2003
1937 TEST_F(PipelineIntegrationTest, BasicPlaybackPositiveStartTime) { 2004 TEST_F(PipelineIntegrationTest, BasicPlaybackPositiveStartTime) {
1938 ASSERT_EQ(PIPELINE_OK, Start("nonzero-start-time.webm")); 2005 ASSERT_EQ(PIPELINE_OK, Start("nonzero-start-time.webm"));
1939 Play(); 2006 Play();
1940 ASSERT_TRUE(WaitUntilOnEnded()); 2007 ASSERT_TRUE(WaitUntilOnEnded());
1941 ASSERT_EQ(base::TimeDelta::FromMicroseconds(396000), 2008 ASSERT_EQ(base::TimeDelta::FromMicroseconds(396000),
1942 demuxer_->GetStartTime()); 2009 demuxer_->GetStartTime());
1943 } 2010 }
1944 2011
1945 } // namespace media 2012 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/ffmpeg_demuxer_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698