Chromium Code Reviews| Index: media/filters/chunk_demuxer.cc |
| diff --git a/media/filters/chunk_demuxer.cc b/media/filters/chunk_demuxer.cc |
| index 51511c8f69ad9dff37773d5d147c54b993211786..4faafac88f2614552086c2dfe36c7491f8d4a33c 100644 |
| --- a/media/filters/chunk_demuxer.cc |
| +++ b/media/filters/chunk_demuxer.cc |
| @@ -131,6 +131,14 @@ class SourceState { |
| // ChunkDemuxerStreams managed by this object. |
| void Remove(TimeDelta start, TimeDelta end, TimeDelta duration); |
| + // Attempts to perform garbage collection in SourceBuffers associated with |
|
wolenetz
2015/08/12 21:09:57
This comment seems ChunkDemuxer-focused. Move it t
servolk
2015/08/13 00:31:42
Will do
servolk
2015/08/20 02:45:27
Done.
|
| + // this ChunkDemuxer. Returns true if garbage collection was successful. |
| + // |media_time| parameter should indicate the current playback position. |
| + // If it's a valid time value, the garbage collection algorithm will make sure |
| + // to preserve unconsumed data buffers in the range between last read position |
| + // and the current playback position. |
| + bool EvictCodedFrames(DecodeTimestamp media_time); |
| + |
| // Returns true if currently parsing a media segment, or false otherwise. |
| bool parsing_media_segment() const { return parsing_media_segment_; } |
| @@ -369,6 +377,23 @@ void SourceState::Remove(TimeDelta start, TimeDelta end, TimeDelta duration) { |
| } |
| } |
| +bool SourceState::EvictCodedFrames(DecodeTimestamp media_time) { |
| + bool success = true; |
| + |
| + if (audio_) |
| + success = audio_->EvictCodedFrames(media_time) && success; |
| + |
| + if (video_) |
| + success = video_->EvictCodedFrames(media_time) && success; |
| + |
| + for (TextStreamMap::iterator itr = text_stream_map_.begin(); |
| + itr != text_stream_map_.end(); ++itr) { |
| + success = itr->second->EvictCodedFrames(media_time) && success; |
| + } |
| + |
| + return success; |
| +} |
| + |
| Ranges<TimeDelta> SourceState::GetBufferedRanges(TimeDelta duration, |
| bool ended) const { |
| // TODO(acolwell): When we start allowing disabled tracks we'll need to update |
| @@ -879,6 +904,11 @@ void ChunkDemuxerStream::Remove(TimeDelta start, TimeDelta end, |
| stream_->Remove(start, end, duration); |
| } |
| +bool ChunkDemuxerStream::EvictCodedFrames(DecodeTimestamp media_time) { |
| + base::AutoLock auto_lock(lock_); |
| + return stream_->GarbageCollectIfNeeded(media_time); |
| +} |
| + |
| void ChunkDemuxerStream::OnSetDuration(TimeDelta duration) { |
| base::AutoLock auto_lock(lock_); |
| stream_->OnSetDuration(duration); |
| @@ -1321,6 +1351,24 @@ Ranges<TimeDelta> ChunkDemuxer::GetBufferedRanges(const std::string& id) const { |
| return itr->second->GetBufferedRanges(duration_, state_ == ENDED); |
| } |
| +bool ChunkDemuxer::EvictCodedFrames(base::TimeDelta currentMediaTime) { |
| + DVLOG(1) << __FUNCTION__ << " media_time=" << currentMediaTime.InSecondsF(); |
| + base::AutoLock auto_lock(lock_); |
| + |
| + // Note: The direct conversion from PTS to DTS is safe here, since we don't |
| + // need to know currentTime precisely for GC. GC only needs to know which GOP |
| + // currentTime points to. |
| + DecodeTimestamp media_time_dts = |
| + DecodeTimestamp::FromPresentationTime(currentMediaTime); |
| + |
| + bool success = true; |
| + for (SourceStateMap::iterator itr = source_state_map_.begin(); |
| + itr != source_state_map_.end(); ++itr) { |
| + success = itr->second->EvictCodedFrames(media_time_dts) && success; |
| + } |
| + return success; |
| +} |
| + |
| void ChunkDemuxer::AppendData( |
| const std::string& id, |
| const uint8* data, |