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

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

Issue 2605993002: Experiment with more aggressive MSE GC on memory pressure (Closed)
Patch Set: Allow MSE GC to happen in EOS state now Created 3 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
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 "media/filters/chunk_demuxer.h" 5 #include "media/filters/chunk_demuxer.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 return true; 113 return true;
114 } 114 }
115 115
116 void ChunkDemuxerStream::Remove(TimeDelta start, TimeDelta end, 116 void ChunkDemuxerStream::Remove(TimeDelta start, TimeDelta end,
117 TimeDelta duration) { 117 TimeDelta duration) {
118 base::AutoLock auto_lock(lock_); 118 base::AutoLock auto_lock(lock_);
119 stream_->Remove(start, end, duration); 119 stream_->Remove(start, end, duration);
120 } 120 }
121 121
122 bool ChunkDemuxerStream::EvictCodedFrames(DecodeTimestamp media_time, 122 bool ChunkDemuxerStream::EvictCodedFrames(DecodeTimestamp media_time,
123 size_t newDataSize) { 123 size_t eviction_size,
124 size_t* bytes_released) {
124 base::AutoLock auto_lock(lock_); 125 base::AutoLock auto_lock(lock_);
125 return stream_->GarbageCollectIfNeeded(media_time, newDataSize); 126 return stream_->GarbageCollectIfNeeded(media_time, eviction_size,
127 bytes_released);
126 } 128 }
127 129
128 void ChunkDemuxerStream::OnSetDuration(TimeDelta duration) { 130 void ChunkDemuxerStream::OnSetDuration(TimeDelta duration) {
129 base::AutoLock auto_lock(lock_); 131 base::AutoLock auto_lock(lock_);
130 stream_->OnSetDuration(duration); 132 stream_->OnSetDuration(duration);
131 } 133 }
132 134
133 Ranges<TimeDelta> ChunkDemuxerStream::GetBufferedRanges( 135 Ranges<TimeDelta> ChunkDemuxerStream::GetBufferedRanges(
134 TimeDelta duration) const { 136 TimeDelta duration) const {
135 base::AutoLock auto_lock(lock_); 137 base::AutoLock auto_lock(lock_);
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 TextTrackConfig ChunkDemuxerStream::text_track_config() { 313 TextTrackConfig ChunkDemuxerStream::text_track_config() {
312 CHECK_EQ(type_, TEXT); 314 CHECK_EQ(type_, TEXT);
313 base::AutoLock auto_lock(lock_); 315 base::AutoLock auto_lock(lock_);
314 return stream_->GetCurrentTextTrackConfig(); 316 return stream_->GetCurrentTextTrackConfig();
315 } 317 }
316 318
317 void ChunkDemuxerStream::SetStreamMemoryLimit(size_t memory_limit) { 319 void ChunkDemuxerStream::SetStreamMemoryLimit(size_t memory_limit) {
318 stream_->set_memory_limit(memory_limit); 320 stream_->set_memory_limit(memory_limit);
319 } 321 }
320 322
323 size_t ChunkDemuxerStream::stream_memory_limit() const {
324 DCHECK(stream_);
325 return stream_->memory_limit();
326 }
327
321 void ChunkDemuxerStream::SetLiveness(Liveness liveness) { 328 void ChunkDemuxerStream::SetLiveness(Liveness liveness) {
322 base::AutoLock auto_lock(lock_); 329 base::AutoLock auto_lock(lock_);
323 liveness_ = liveness; 330 liveness_ = liveness;
324 } 331 }
325 332
326 void ChunkDemuxerStream::ChangeState_Locked(State state) { 333 void ChunkDemuxerStream::ChangeState_Locked(State state) {
327 lock_.AssertAcquired(); 334 lock_.AssertAcquired();
328 DVLOG(1) << "ChunkDemuxerStream::ChangeState_Locked() : " 335 DVLOG(1) << "ChunkDemuxerStream::ChangeState_Locked() : "
329 << "type " << type_ 336 << "type " << type_
330 << " - " << state_ << " -> " << state; 337 << " - " << state_ << " -> " << state;
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after
729 DCHECK_EQ(DemuxerStream::VIDEO, stream->type()); 736 DCHECK_EQ(DemuxerStream::VIDEO, stream->type());
730 stream->set_enabled(false, currTime); 737 stream->set_enabled(false, currTime);
731 } 738 }
732 } 739 }
733 if (selected_stream) { 740 if (selected_stream) {
734 DVLOG(1) << __func__ << ": enabling stream " << selected_stream; 741 DVLOG(1) << __func__ << ": enabling stream " << selected_stream;
735 selected_stream->set_enabled(true, currTime); 742 selected_stream->set_enabled(true, currTime);
736 } 743 }
737 } 744 }
738 745
746 void ChunkDemuxer::OnMemoryPressure(
747 base::TimeDelta currentMediaTime,
748 base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level) {
749 if (memory_pressure_level <
750 base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_MODERATE)
751 return;
752
753 DecodeTimestamp media_time_dts =
754 DecodeTimestamp::FromPresentationTime(currentMediaTime);
755 base::AutoLock auto_lock(lock_);
756 for (const auto& itr : source_state_map_) {
757 itr.second->OnMemoryPressure(media_time_dts, memory_pressure_level);
758 }
759 }
760
739 bool ChunkDemuxer::EvictCodedFrames(const std::string& id, 761 bool ChunkDemuxer::EvictCodedFrames(const std::string& id,
740 base::TimeDelta currentMediaTime, 762 base::TimeDelta currentMediaTime,
741 size_t newDataSize) { 763 size_t eviction_size) {
742 DVLOG(1) << __func__ << "(" << id << ")" 764 DVLOG(1) << __func__ << "(" << id << ")"
743 << " media_time=" << currentMediaTime.InSecondsF() 765 << " media_time=" << currentMediaTime.InSecondsF()
744 << " newDataSize=" << newDataSize; 766 << " eviction_size=" << eviction_size;
745 base::AutoLock auto_lock(lock_); 767 base::AutoLock auto_lock(lock_);
746 768
747 // Note: The direct conversion from PTS to DTS is safe here, since we don't 769 // Note: The direct conversion from PTS to DTS is safe here, since we don't
748 // need to know currentTime precisely for GC. GC only needs to know which GOP 770 // need to know currentTime precisely for GC. GC only needs to know which GOP
749 // currentTime points to. 771 // currentTime points to.
750 DecodeTimestamp media_time_dts = 772 DecodeTimestamp media_time_dts =
751 DecodeTimestamp::FromPresentationTime(currentMediaTime); 773 DecodeTimestamp::FromPresentationTime(currentMediaTime);
752 774
753 DCHECK(!id.empty()); 775 DCHECK(!id.empty());
754 auto itr = source_state_map_.find(id); 776 auto itr = source_state_map_.find(id);
755 if (itr == source_state_map_.end()) { 777 if (itr == source_state_map_.end()) {
756 LOG(WARNING) << __func__ << " stream " << id << " not found"; 778 LOG(WARNING) << __func__ << " stream " << id << " not found";
757 return false; 779 return false;
758 } 780 }
759 return itr->second->EvictCodedFrames(media_time_dts, newDataSize); 781 return itr->second->EvictCodedFrames(media_time_dts, eviction_size);
760 } 782 }
761 783
762 bool ChunkDemuxer::AppendData(const std::string& id, 784 bool ChunkDemuxer::AppendData(const std::string& id,
763 const uint8_t* data, 785 const uint8_t* data,
764 size_t length, 786 size_t length,
765 TimeDelta append_window_start, 787 TimeDelta append_window_start,
766 TimeDelta append_window_end, 788 TimeDelta append_window_end,
767 TimeDelta* timestamp_offset) { 789 TimeDelta* timestamp_offset) {
768 DVLOG(1) << "AppendData(" << id << ", " << length << ")"; 790 DVLOG(1) << "AppendData(" << id << ", " << length << ")";
769 791
(...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after
1302 } 1324 }
1303 1325
1304 void ChunkDemuxer::ShutdownAllStreams() { 1326 void ChunkDemuxer::ShutdownAllStreams() {
1305 for (auto itr = source_state_map_.begin(); itr != source_state_map_.end(); 1327 for (auto itr = source_state_map_.begin(); itr != source_state_map_.end();
1306 ++itr) { 1328 ++itr) {
1307 itr->second->Shutdown(); 1329 itr->second->Shutdown();
1308 } 1330 }
1309 } 1331 }
1310 1332
1311 } // namespace media 1333 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698