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 | 10 |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
126 | 126 |
127 // Aborts the current append sequence and resets the parser. | 127 // Aborts the current append sequence and resets the parser. |
128 void Abort(TimeDelta append_window_start, | 128 void Abort(TimeDelta append_window_start, |
129 TimeDelta append_window_end, | 129 TimeDelta append_window_end, |
130 TimeDelta* timestamp_offset); | 130 TimeDelta* timestamp_offset); |
131 | 131 |
132 // Calls Remove(|start|, |end|, |duration|) on all | 132 // Calls Remove(|start|, |end|, |duration|) on all |
133 // ChunkDemuxerStreams managed by this object. | 133 // ChunkDemuxerStreams managed by this object. |
134 void Remove(TimeDelta start, TimeDelta end, TimeDelta duration); | 134 void Remove(TimeDelta start, TimeDelta end, TimeDelta duration); |
135 | 135 |
136 bool EvictFrames(); | |
137 | |
136 // Returns true if currently parsing a media segment, or false otherwise. | 138 // Returns true if currently parsing a media segment, or false otherwise. |
137 bool parsing_media_segment() const { return parsing_media_segment_; } | 139 bool parsing_media_segment() const { return parsing_media_segment_; } |
138 | 140 |
139 // Sets |frame_processor_|'s sequence mode to |sequence_mode|. | 141 // Sets |frame_processor_|'s sequence mode to |sequence_mode|. |
140 void SetSequenceMode(bool sequence_mode); | 142 void SetSequenceMode(bool sequence_mode); |
141 | 143 |
142 // Signals the coded frame processor to update its group start timestamp to be | 144 // Signals the coded frame processor to update its group start timestamp to be |
143 // |timestamp_offset| if it is in sequence append mode. | 145 // |timestamp_offset| if it is in sequence append mode. |
144 void SetGroupStartTimestampIfInSequenceMode(base::TimeDelta timestamp_offset); | 146 void SetGroupStartTimestampIfInSequenceMode(base::TimeDelta timestamp_offset); |
145 | 147 |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
368 | 370 |
369 if (video_) | 371 if (video_) |
370 video_->Remove(start, end, duration); | 372 video_->Remove(start, end, duration); |
371 | 373 |
372 for (TextStreamMap::iterator itr = text_stream_map_.begin(); | 374 for (TextStreamMap::iterator itr = text_stream_map_.begin(); |
373 itr != text_stream_map_.end(); ++itr) { | 375 itr != text_stream_map_.end(); ++itr) { |
374 itr->second->Remove(start, end, duration); | 376 itr->second->Remove(start, end, duration); |
375 } | 377 } |
376 } | 378 } |
377 | 379 |
380 bool SourceState::EvictFrames() { | |
381 bool success = true; | |
382 | |
383 if(audio_) | |
384 success = audio_->EvictFrames() && success; | |
385 | |
386 if (video_) | |
387 success = video_->EvictFrames() && success; | |
388 | |
389 for (TextStreamMap::iterator itr = text_stream_map_.begin(); | |
philipj_slow
2014/12/10 09:26:08
If C++11 range-based for loops work here, that wou
kjoswiak
2014/12/10 19:35:28
I did it this way because this is how it's done el
philipj_slow
2014/12/10 19:39:56
OK, owners get to decide.
| |
390 itr != text_stream_map_.end(); ++itr) { | |
391 success = itr->second->EvictFrames() && success; | |
392 } | |
393 | |
394 return success; | |
395 } | |
396 | |
378 Ranges<TimeDelta> SourceState::GetBufferedRanges(TimeDelta duration, | 397 Ranges<TimeDelta> SourceState::GetBufferedRanges(TimeDelta duration, |
379 bool ended) const { | 398 bool ended) const { |
380 // TODO(acolwell): When we start allowing disabled tracks we'll need to update | 399 // TODO(acolwell): When we start allowing disabled tracks we'll need to update |
381 // this code to only add ranges from active tracks. | 400 // this code to only add ranges from active tracks. |
382 RangesList ranges_list; | 401 RangesList ranges_list; |
383 if (audio_) | 402 if (audio_) |
384 ranges_list.push_back(audio_->GetBufferedRanges(duration)); | 403 ranges_list.push_back(audio_->GetBufferedRanges(duration)); |
385 | 404 |
386 if (video_) | 405 if (video_) |
387 ranges_list.push_back(video_->GetBufferedRanges(duration)); | 406 ranges_list.push_back(video_->GetBufferedRanges(duration)); |
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
876 | 895 |
877 return true; | 896 return true; |
878 } | 897 } |
879 | 898 |
880 void ChunkDemuxerStream::Remove(TimeDelta start, TimeDelta end, | 899 void ChunkDemuxerStream::Remove(TimeDelta start, TimeDelta end, |
881 TimeDelta duration) { | 900 TimeDelta duration) { |
882 base::AutoLock auto_lock(lock_); | 901 base::AutoLock auto_lock(lock_); |
883 stream_->Remove(start, end, duration); | 902 stream_->Remove(start, end, duration); |
884 } | 903 } |
885 | 904 |
905 bool ChunkDemuxerStream::EvictFrames() { | |
906 base::AutoLock auto_lock(lock_); | |
907 return stream_->GarbageCollectIfNeeded(); | |
908 } | |
909 | |
886 void ChunkDemuxerStream::OnSetDuration(TimeDelta duration) { | 910 void ChunkDemuxerStream::OnSetDuration(TimeDelta duration) { |
887 base::AutoLock auto_lock(lock_); | 911 base::AutoLock auto_lock(lock_); |
888 stream_->OnSetDuration(duration); | 912 stream_->OnSetDuration(duration); |
889 } | 913 } |
890 | 914 |
891 Ranges<TimeDelta> ChunkDemuxerStream::GetBufferedRanges( | 915 Ranges<TimeDelta> ChunkDemuxerStream::GetBufferedRanges( |
892 TimeDelta duration) const { | 916 TimeDelta duration) const { |
893 base::AutoLock auto_lock(lock_); | 917 base::AutoLock auto_lock(lock_); |
894 | 918 |
895 if (type_ == TEXT) { | 919 if (type_ == TEXT) { |
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1309 Ranges<TimeDelta> ChunkDemuxer::GetBufferedRanges(const std::string& id) const { | 1333 Ranges<TimeDelta> ChunkDemuxer::GetBufferedRanges(const std::string& id) const { |
1310 base::AutoLock auto_lock(lock_); | 1334 base::AutoLock auto_lock(lock_); |
1311 DCHECK(!id.empty()); | 1335 DCHECK(!id.empty()); |
1312 | 1336 |
1313 SourceStateMap::const_iterator itr = source_state_map_.find(id); | 1337 SourceStateMap::const_iterator itr = source_state_map_.find(id); |
1314 | 1338 |
1315 DCHECK(itr != source_state_map_.end()); | 1339 DCHECK(itr != source_state_map_.end()); |
1316 return itr->second->GetBufferedRanges(duration_, state_ == ENDED); | 1340 return itr->second->GetBufferedRanges(duration_, state_ == ENDED); |
1317 } | 1341 } |
1318 | 1342 |
1343 bool ChunkDemuxer::EvictFrames() { | |
1344 bool success = true; | |
1345 for (SourceStateMap::iterator itr = source_state_map_.begin(); | |
1346 itr != source_state_map_.end(); ++itr) { | |
1347 success = itr->second->EvictFrames() && success; | |
1348 } | |
1349 return success; | |
1350 } | |
1351 | |
1319 void ChunkDemuxer::AppendData( | 1352 void ChunkDemuxer::AppendData( |
1320 const std::string& id, | 1353 const std::string& id, |
1321 const uint8* data, | 1354 const uint8* data, |
1322 size_t length, | 1355 size_t length, |
1323 TimeDelta append_window_start, | 1356 TimeDelta append_window_start, |
1324 TimeDelta append_window_end, | 1357 TimeDelta append_window_end, |
1325 TimeDelta* timestamp_offset, | 1358 TimeDelta* timestamp_offset, |
1326 const InitSegmentReceivedCB& init_segment_received_cb) { | 1359 const InitSegmentReceivedCB& init_segment_received_cb) { |
1327 DVLOG(1) << "AppendData(" << id << ", " << length << ")"; | 1360 DVLOG(1) << "AppendData(" << id << ", " << length << ")"; |
1328 | 1361 |
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1852 } | 1885 } |
1853 | 1886 |
1854 void ChunkDemuxer::ShutdownAllStreams() { | 1887 void ChunkDemuxer::ShutdownAllStreams() { |
1855 for (SourceStateMap::iterator itr = source_state_map_.begin(); | 1888 for (SourceStateMap::iterator itr = source_state_map_.begin(); |
1856 itr != source_state_map_.end(); ++itr) { | 1889 itr != source_state_map_.end(); ++itr) { |
1857 itr->second->Shutdown(); | 1890 itr->second->Shutdown(); |
1858 } | 1891 } |
1859 } | 1892 } |
1860 | 1893 |
1861 } // namespace media | 1894 } // namespace media |
OLD | NEW |