| 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 "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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 newDataSize) { |
| 124 base::AutoLock auto_lock(lock_); | 124 base::AutoLock auto_lock(lock_); |
| 125 return stream_->GarbageCollectIfNeeded(media_time, newDataSize); | 125 return stream_->GarbageCollectIfNeeded(media_time, newDataSize); |
| 126 } | 126 } |
| 127 | 127 |
| 128 void ChunkDemuxerStream::OnMemoryPressure( |
| 129 DecodeTimestamp media_time, |
| 130 base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level, |
| 131 bool force_instant_gc) { |
| 132 base::AutoLock auto_lock(lock_); |
| 133 return stream_->OnMemoryPressure(media_time, memory_pressure_level, |
| 134 force_instant_gc); |
| 135 } |
| 136 |
| 128 void ChunkDemuxerStream::OnSetDuration(TimeDelta duration) { | 137 void ChunkDemuxerStream::OnSetDuration(TimeDelta duration) { |
| 129 base::AutoLock auto_lock(lock_); | 138 base::AutoLock auto_lock(lock_); |
| 130 stream_->OnSetDuration(duration); | 139 stream_->OnSetDuration(duration); |
| 131 } | 140 } |
| 132 | 141 |
| 133 Ranges<TimeDelta> ChunkDemuxerStream::GetBufferedRanges( | 142 Ranges<TimeDelta> ChunkDemuxerStream::GetBufferedRanges( |
| 134 TimeDelta duration) const { | 143 TimeDelta duration) const { |
| 135 base::AutoLock auto_lock(lock_); | 144 base::AutoLock auto_lock(lock_); |
| 136 | 145 |
| 137 if (type_ == TEXT) { | 146 if (type_ == TEXT) { |
| (...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 729 DCHECK_EQ(DemuxerStream::VIDEO, stream->type()); | 738 DCHECK_EQ(DemuxerStream::VIDEO, stream->type()); |
| 730 stream->set_enabled(false, currTime); | 739 stream->set_enabled(false, currTime); |
| 731 } | 740 } |
| 732 } | 741 } |
| 733 if (selected_stream) { | 742 if (selected_stream) { |
| 734 DVLOG(1) << __func__ << ": enabling stream " << selected_stream; | 743 DVLOG(1) << __func__ << ": enabling stream " << selected_stream; |
| 735 selected_stream->set_enabled(true, currTime); | 744 selected_stream->set_enabled(true, currTime); |
| 736 } | 745 } |
| 737 } | 746 } |
| 738 | 747 |
| 748 void ChunkDemuxer::OnMemoryPressure( |
| 749 base::TimeDelta currentMediaTime, |
| 750 base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level, |
| 751 bool force_instant_gc) { |
| 752 DecodeTimestamp media_time_dts = |
| 753 DecodeTimestamp::FromPresentationTime(currentMediaTime); |
| 754 base::AutoLock auto_lock(lock_); |
| 755 for (const auto& itr : source_state_map_) { |
| 756 itr.second->OnMemoryPressure(media_time_dts, memory_pressure_level, |
| 757 force_instant_gc); |
| 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 newDataSize) { |
| 742 DVLOG(1) << __func__ << "(" << id << ")" | 764 DVLOG(1) << __func__ << "(" << id << ")" |
| 743 << " media_time=" << currentMediaTime.InSecondsF() | 765 << " media_time=" << currentMediaTime.InSecondsF() |
| 744 << " newDataSize=" << newDataSize; | 766 << " newDataSize=" << newDataSize; |
| 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 |
| (...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1307 } | 1329 } |
| 1308 | 1330 |
| 1309 void ChunkDemuxer::ShutdownAllStreams() { | 1331 void ChunkDemuxer::ShutdownAllStreams() { |
| 1310 for (auto itr = source_state_map_.begin(); itr != source_state_map_.end(); | 1332 for (auto itr = source_state_map_.begin(); itr != source_state_map_.end(); |
| 1311 ++itr) { | 1333 ++itr) { |
| 1312 itr->second->Shutdown(); | 1334 itr->second->Shutdown(); |
| 1313 } | 1335 } |
| 1314 } | 1336 } |
| 1315 | 1337 |
| 1316 } // namespace media | 1338 } // namespace media |
| OLD | NEW |