Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
| 7 #include "base/memory/ref_counted.h" | 7 #include "base/memory/ref_counted.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/strings/string_split.h" | 9 #include "base/strings/string_split.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 548 pData, | 548 pData, |
| 549 size, | 549 size, |
| 550 append_window_start, | 550 append_window_start, |
| 551 append_window_end, | 551 append_window_end, |
| 552 ×tamp_offset, | 552 ×tamp_offset, |
| 553 base::Bind(&MockMediaSource::InitSegmentReceived, | 553 base::Bind(&MockMediaSource::InitSegmentReceived, |
| 554 base::Unretained(this))); | 554 base::Unretained(this))); |
| 555 last_timestamp_offset_ = timestamp_offset; | 555 last_timestamp_offset_ = timestamp_offset; |
| 556 } | 556 } |
| 557 | 557 |
| 558 void SetMemoryLimits(size_t limit_bytes) { | |
| 559 chunk_demuxer_->SetMemoryLimits(DemuxerStream::AUDIO, limit_bytes); | |
| 560 chunk_demuxer_->SetMemoryLimits(DemuxerStream::VIDEO, limit_bytes); | |
| 561 } | |
| 562 | |
| 563 void EvictCodedFrames(base::TimeDelta currentMediaTime, size_t newDataSize) { | |
| 564 chunk_demuxer_->EvictCodedFrames(kSourceId, currentMediaTime, newDataSize); | |
| 565 } | |
| 566 | |
| 558 void EndOfStream() { | 567 void EndOfStream() { |
| 559 chunk_demuxer_->MarkEndOfStream(PIPELINE_OK); | 568 chunk_demuxer_->MarkEndOfStream(PIPELINE_OK); |
| 560 } | 569 } |
| 561 | 570 |
| 562 void Shutdown() { | 571 void Shutdown() { |
| 563 if (!chunk_demuxer_) | 572 if (!chunk_demuxer_) |
| 564 return; | 573 return; |
| 565 chunk_demuxer_->ResetParserState( | 574 chunk_demuxer_->ResetParserState( |
| 566 kSourceId, | 575 kSourceId, |
| 567 base::TimeDelta(), kInfiniteDuration(), &last_timestamp_offset_); | 576 base::TimeDelta(), kInfiniteDuration(), &last_timestamp_offset_); |
| (...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1075 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); | 1084 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); |
| 1076 EXPECT_EQ(kAppendTimeMs + k640WebMFileDurationMs, | 1085 EXPECT_EQ(kAppendTimeMs + k640WebMFileDurationMs, |
| 1077 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); | 1086 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); |
| 1078 | 1087 |
| 1079 Play(); | 1088 Play(); |
| 1080 | 1089 |
| 1081 EXPECT_TRUE(WaitUntilOnEnded()); | 1090 EXPECT_TRUE(WaitUntilOnEnded()); |
| 1082 source.Shutdown(); | 1091 source.Shutdown(); |
| 1083 Stop(); | 1092 Stop(); |
| 1084 } | 1093 } |
| 1085 | 1094 |
|
wolenetz
2016/01/06 19:28:41
I think explicit SourceBuffer.Remove() operations
servolk
2016/01/06 21:05:05
Good catch, done: added signalling from ChunkDemux
| |
| 1095 // This test case imitates media playback with advancing media_time and | |
| 1096 // continuously adding new data. At some point we should reach the buffering | |
| 1097 // limit, after that MediaSource should evict some buffered data and that | |
| 1098 // evicted data shold be reflected in the change of media::Pipeline buffered | |
| 1099 // ranges (returned by GetBufferedTimeRanges). At that point the buffered ranges | |
| 1100 // will no longer start at 0. | |
| 1101 TEST_F(PipelineIntegrationTest, MediaSource_FillUp_Buffer) { | |
| 1102 const char* input_filename = "bear-320x240.webm"; | |
| 1103 MockMediaSource source(input_filename, kWebM, kAppendWholeFile); | |
| 1104 StartPipelineWithMediaSource(&source); | |
| 1105 source.SetMemoryLimits(1048576); | |
| 1106 | |
| 1107 scoped_refptr<DecoderBuffer> file = ReadTestDataFile(input_filename); | |
| 1108 | |
| 1109 auto buffered_ranges = pipeline_->GetBufferedTimeRanges(); | |
| 1110 do { | |
|
wolenetz
2016/01/06 19:28:41
nit: before do, EXPECT_EQ(1u, buffered_ranges.size
servolk
2016/01/06 21:05:05
Done.
| |
| 1111 // Advance media_time to the end of the currently buffered data | |
| 1112 base::TimeDelta media_time = buffered_ranges.end(0); | |
| 1113 source.Seek(media_time); | |
| 1114 // Ask MediaSource to evict buffered data if buffering limit has been | |
| 1115 // reached (the data will be evicted from the front of the buffered range). | |
| 1116 source.EvictCodedFrames(media_time, file->data_size()); | |
| 1117 source.AppendAtTime(media_time, file->data(), file->data_size()); | |
| 1118 buffered_ranges = pipeline_->GetBufferedTimeRanges(); | |
| 1119 } while (buffered_ranges.size() == 1 && | |
| 1120 buffered_ranges.start(0) == base::TimeDelta::FromSeconds(0)); | |
| 1121 | |
| 1122 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); | |
| 1123 source.Shutdown(); | |
| 1124 Stop(); | |
| 1125 } | |
| 1126 | |
| 1086 #if !defined(DISABLE_EME_TESTS) | 1127 #if !defined(DISABLE_EME_TESTS) |
| 1087 TEST_F(PipelineIntegrationTest, MediaSource_ConfigChange_Encrypted_WebM) { | 1128 TEST_F(PipelineIntegrationTest, MediaSource_ConfigChange_Encrypted_WebM) { |
| 1088 MockMediaSource source("bear-320x240-16x9-aspect-av_enc-av.webm", kWebM, | 1129 MockMediaSource source("bear-320x240-16x9-aspect-av_enc-av.webm", kWebM, |
| 1089 kAppendWholeFile); | 1130 kAppendWholeFile); |
| 1090 FakeEncryptedMedia encrypted_media(new KeyProvidingApp()); | 1131 FakeEncryptedMedia encrypted_media(new KeyProvidingApp()); |
| 1091 StartPipelineWithEncryptedMedia(&source, &encrypted_media); | 1132 StartPipelineWithEncryptedMedia(&source, &encrypted_media); |
| 1092 | 1133 |
| 1093 scoped_refptr<DecoderBuffer> second_file = | 1134 scoped_refptr<DecoderBuffer> second_file = |
| 1094 ReadTestDataFile("bear-640x360-av_enc-av.webm"); | 1135 ReadTestDataFile("bear-640x360-av_enc-av.webm"); |
| 1095 | 1136 |
| (...skipping 835 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1931 | 1972 |
| 1932 TEST_F(PipelineIntegrationTest, BasicPlaybackPositiveStartTime) { | 1973 TEST_F(PipelineIntegrationTest, BasicPlaybackPositiveStartTime) { |
| 1933 ASSERT_EQ(PIPELINE_OK, Start("nonzero-start-time.webm")); | 1974 ASSERT_EQ(PIPELINE_OK, Start("nonzero-start-time.webm")); |
| 1934 Play(); | 1975 Play(); |
| 1935 ASSERT_TRUE(WaitUntilOnEnded()); | 1976 ASSERT_TRUE(WaitUntilOnEnded()); |
| 1936 ASSERT_EQ(base::TimeDelta::FromMicroseconds(396000), | 1977 ASSERT_EQ(base::TimeDelta::FromMicroseconds(396000), |
| 1937 demuxer_->GetStartTime()); | 1978 demuxer_->GetStartTime()); |
| 1938 } | 1979 } |
| 1939 | 1980 |
| 1940 } // namespace media | 1981 } // namespace media |
| OLD | NEW |