| 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_gc) { |
| 132 base::AutoLock auto_lock(lock_); |
| 133 return stream_->OnMemoryPressure(media_time, memory_pressure_level, force_gc); |
| 134 } |
| 135 |
| 128 void ChunkDemuxerStream::OnSetDuration(TimeDelta duration) { | 136 void ChunkDemuxerStream::OnSetDuration(TimeDelta duration) { |
| 129 base::AutoLock auto_lock(lock_); | 137 base::AutoLock auto_lock(lock_); |
| 130 stream_->OnSetDuration(duration); | 138 stream_->OnSetDuration(duration); |
| 131 } | 139 } |
| 132 | 140 |
| 133 Ranges<TimeDelta> ChunkDemuxerStream::GetBufferedRanges( | 141 Ranges<TimeDelta> ChunkDemuxerStream::GetBufferedRanges( |
| 134 TimeDelta duration) const { | 142 TimeDelta duration) const { |
| 135 base::AutoLock auto_lock(lock_); | 143 base::AutoLock auto_lock(lock_); |
| 136 | 144 |
| 137 if (type_ == TEXT) { | 145 if (type_ == TEXT) { |
| (...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 729 DCHECK_EQ(DemuxerStream::VIDEO, stream->type()); | 737 DCHECK_EQ(DemuxerStream::VIDEO, stream->type()); |
| 730 stream->set_enabled(false, currTime); | 738 stream->set_enabled(false, currTime); |
| 731 } | 739 } |
| 732 } | 740 } |
| 733 if (selected_stream) { | 741 if (selected_stream) { |
| 734 DVLOG(1) << __func__ << ": enabling stream " << selected_stream; | 742 DVLOG(1) << __func__ << ": enabling stream " << selected_stream; |
| 735 selected_stream->set_enabled(true, currTime); | 743 selected_stream->set_enabled(true, currTime); |
| 736 } | 744 } |
| 737 } | 745 } |
| 738 | 746 |
| 747 void ChunkDemuxer::OnMemoryPressure( |
| 748 base::TimeDelta currentMediaTime, |
| 749 base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level, |
| 750 bool force_gc) { |
| 751 DecodeTimestamp media_time_dts = |
| 752 DecodeTimestamp::FromPresentationTime(currentMediaTime); |
| 753 base::AutoLock auto_lock(lock_); |
| 754 for (const auto& itr : source_state_map_) { |
| 755 itr.second->OnMemoryPressure(media_time_dts, memory_pressure_level, |
| 756 force_gc); |
| 757 } |
| 758 } |
| 759 |
| 739 bool ChunkDemuxer::EvictCodedFrames(const std::string& id, | 760 bool ChunkDemuxer::EvictCodedFrames(const std::string& id, |
| 740 base::TimeDelta currentMediaTime, | 761 base::TimeDelta currentMediaTime, |
| 741 size_t newDataSize) { | 762 size_t newDataSize) { |
| 742 DVLOG(1) << __func__ << "(" << id << ")" | 763 DVLOG(1) << __func__ << "(" << id << ")" |
| 743 << " media_time=" << currentMediaTime.InSecondsF() | 764 << " media_time=" << currentMediaTime.InSecondsF() |
| 744 << " newDataSize=" << newDataSize; | 765 << " newDataSize=" << newDataSize; |
| 745 base::AutoLock auto_lock(lock_); | 766 base::AutoLock auto_lock(lock_); |
| 746 | 767 |
| 747 // Note: The direct conversion from PTS to DTS is safe here, since we don't | 768 // 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 | 769 // 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 } | 1328 } |
| 1308 | 1329 |
| 1309 void ChunkDemuxer::ShutdownAllStreams() { | 1330 void ChunkDemuxer::ShutdownAllStreams() { |
| 1310 for (auto itr = source_state_map_.begin(); itr != source_state_map_.end(); | 1331 for (auto itr = source_state_map_.begin(); itr != source_state_map_.end(); |
| 1311 ++itr) { | 1332 ++itr) { |
| 1312 itr->second->Shutdown(); | 1333 itr->second->Shutdown(); |
| 1313 } | 1334 } |
| 1314 } | 1335 } |
| 1315 | 1336 |
| 1316 } // namespace media | 1337 } // namespace media |
| OLD | NEW |