| 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 <list> | 9 #include <list> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 return range; | 150 return range; |
| 151 | 151 |
| 152 // Clamp the end of the stream's buffered ranges to fit within the duration. | 152 // Clamp the end of the stream's buffered ranges to fit within the duration. |
| 153 // This can be done by intersecting the stream's range with the valid time | 153 // This can be done by intersecting the stream's range with the valid time |
| 154 // range. | 154 // range. |
| 155 Ranges<TimeDelta> valid_time_range; | 155 Ranges<TimeDelta> valid_time_range; |
| 156 valid_time_range.Add(range.start(0), duration); | 156 valid_time_range.Add(range.start(0), duration); |
| 157 return range.IntersectionWith(valid_time_range); | 157 return range.IntersectionWith(valid_time_range); |
| 158 } | 158 } |
| 159 | 159 |
| 160 TimeDelta ChunkDemuxerStream::GetHighestPresentationTimestamp() const { |
| 161 return stream_->GetHighestPresentationTimestamp(); |
| 162 } |
| 163 |
| 160 TimeDelta ChunkDemuxerStream::GetBufferedDuration() const { | 164 TimeDelta ChunkDemuxerStream::GetBufferedDuration() const { |
| 161 return stream_->GetBufferedDuration(); | 165 return stream_->GetBufferedDuration(); |
| 162 } | 166 } |
| 163 | 167 |
| 164 size_t ChunkDemuxerStream::GetBufferedSize() const { | 168 size_t ChunkDemuxerStream::GetBufferedSize() const { |
| 165 return stream_->GetBufferedSize(); | 169 return stream_->GetBufferedSize(); |
| 166 } | 170 } |
| 167 | 171 |
| 168 void ChunkDemuxerStream::OnStartOfCodedFrameGroup( | 172 void ChunkDemuxerStream::OnStartOfCodedFrameGroup( |
| 169 DecodeTimestamp start_timestamp) { | 173 DecodeTimestamp start_timestamp) { |
| (...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 586 Ranges<TimeDelta> ChunkDemuxer::GetBufferedRanges(const std::string& id) const { | 590 Ranges<TimeDelta> ChunkDemuxer::GetBufferedRanges(const std::string& id) const { |
| 587 base::AutoLock auto_lock(lock_); | 591 base::AutoLock auto_lock(lock_); |
| 588 DCHECK(!id.empty()); | 592 DCHECK(!id.empty()); |
| 589 | 593 |
| 590 MediaSourceStateMap::const_iterator itr = source_state_map_.find(id); | 594 MediaSourceStateMap::const_iterator itr = source_state_map_.find(id); |
| 591 | 595 |
| 592 DCHECK(itr != source_state_map_.end()); | 596 DCHECK(itr != source_state_map_.end()); |
| 593 return itr->second->GetBufferedRanges(duration_, state_ == ENDED); | 597 return itr->second->GetBufferedRanges(duration_, state_ == ENDED); |
| 594 } | 598 } |
| 595 | 599 |
| 600 base::TimeDelta ChunkDemuxer::GetHighestPresentationTimestamp( |
| 601 const std::string& id) const { |
| 602 base::AutoLock auto_lock(lock_); |
| 603 DCHECK(!id.empty()); |
| 604 |
| 605 MediaSourceStateMap::const_iterator itr = source_state_map_.find(id); |
| 606 |
| 607 DCHECK(itr != source_state_map_.end()); |
| 608 return itr->second->GetHighestPresentationTimestamp(); |
| 609 } |
| 610 |
| 596 bool ChunkDemuxer::EvictCodedFrames(const std::string& id, | 611 bool ChunkDemuxer::EvictCodedFrames(const std::string& id, |
| 597 base::TimeDelta currentMediaTime, | 612 base::TimeDelta currentMediaTime, |
| 598 size_t newDataSize) { | 613 size_t newDataSize) { |
| 599 DVLOG(1) << __FUNCTION__ << "(" << id << ")" | 614 DVLOG(1) << __FUNCTION__ << "(" << id << ")" |
| 600 << " media_time=" << currentMediaTime.InSecondsF() | 615 << " media_time=" << currentMediaTime.InSecondsF() |
| 601 << " newDataSize=" << newDataSize; | 616 << " newDataSize=" << newDataSize; |
| 602 base::AutoLock auto_lock(lock_); | 617 base::AutoLock auto_lock(lock_); |
| 603 | 618 |
| 604 // Note: The direct conversion from PTS to DTS is safe here, since we don't | 619 // Note: The direct conversion from PTS to DTS is safe here, since we don't |
| 605 // need to know currentTime precisely for GC. GC only needs to know which GOP | 620 // need to know currentTime precisely for GC. GC only needs to know which GOP |
| (...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1161 } | 1176 } |
| 1162 | 1177 |
| 1163 void ChunkDemuxer::ShutdownAllStreams() { | 1178 void ChunkDemuxer::ShutdownAllStreams() { |
| 1164 for (MediaSourceStateMap::iterator itr = source_state_map_.begin(); | 1179 for (MediaSourceStateMap::iterator itr = source_state_map_.begin(); |
| 1165 itr != source_state_map_.end(); ++itr) { | 1180 itr != source_state_map_.end(); ++itr) { |
| 1166 itr->second->Shutdown(); | 1181 itr->second->Shutdown(); |
| 1167 } | 1182 } |
| 1168 } | 1183 } |
| 1169 | 1184 |
| 1170 } // namespace media | 1185 } // namespace media |
| OLD | NEW |