Chromium Code Reviews| 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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 122 // error occurred. |*timestamp_offset| is used and possibly updated by the | 122 // error occurred. |*timestamp_offset| is used and possibly updated by the |
| 123 // append. |append_window_start| and |append_window_end| correspond to the MSE | 123 // append. |append_window_start| and |append_window_end| correspond to the MSE |
| 124 // spec's similarly named source buffer attributes that are used in coded | 124 // spec's similarly named source buffer attributes that are used in coded |
| 125 // frame processing. | 125 // frame processing. |
| 126 bool Append(const uint8* data, size_t length, | 126 bool Append(const uint8* data, size_t length, |
| 127 TimeDelta append_window_start_, | 127 TimeDelta append_window_start_, |
| 128 TimeDelta append_window_end_, | 128 TimeDelta append_window_end_, |
| 129 TimeDelta* timestamp_offset); | 129 TimeDelta* timestamp_offset); |
| 130 | 130 |
| 131 // Aborts the current append sequence and resets the parser. | 131 // Aborts the current append sequence and resets the parser. |
| 132 void Abort(); | 132 void Abort(base::TimeDelta timestamp_offset); |
| 133 | 133 |
| 134 // Calls Remove(|start|, |end|, |duration|) on all | 134 // Calls Remove(|start|, |end|, |duration|) on all |
| 135 // ChunkDemuxerStreams managed by this object. | 135 // ChunkDemuxerStreams managed by this object. |
| 136 void Remove(TimeDelta start, TimeDelta end, TimeDelta duration); | 136 void Remove(TimeDelta start, TimeDelta end, TimeDelta duration); |
| 137 | 137 |
| 138 // Returns true if currently parsing a media segment, or false otherwise. | 138 // Returns true if currently parsing a media segment, or false otherwise. |
| 139 bool parsing_media_segment() const { return parsing_media_segment_; } | 139 bool parsing_media_segment() const { return parsing_media_segment_; } |
| 140 | 140 |
| 141 // Sets |frame_processor_|'s sequence mode to |sequence_mode|. | 141 // Sets |frame_processor_|'s sequence mode to |sequence_mode|. |
| 142 void SetSequenceMode(bool sequence_mode); | 142 void SetSequenceMode(bool sequence_mode); |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 307 append_window_start_during_append_ = append_window_start; | 307 append_window_start_during_append_ = append_window_start; |
| 308 append_window_end_during_append_ = append_window_end; | 308 append_window_end_during_append_ = append_window_end; |
| 309 | 309 |
| 310 // TODO(wolenetz/acolwell): Curry and pass a NewBuffersCB here bound with | 310 // TODO(wolenetz/acolwell): Curry and pass a NewBuffersCB here bound with |
| 311 // append window and timestamp offset pointer. See http://crbug.com/351454. | 311 // append window and timestamp offset pointer. See http://crbug.com/351454. |
| 312 bool err = stream_parser_->Parse(data, length); | 312 bool err = stream_parser_->Parse(data, length); |
| 313 timestamp_offset_during_append_ = NULL; | 313 timestamp_offset_during_append_ = NULL; |
| 314 return err; | 314 return err; |
| 315 } | 315 } |
| 316 | 316 |
| 317 void SourceState::Abort() { | 317 void SourceState::Abort(base::TimeDelta timestamp_offset) { |
| 318 DCHECK(!timestamp_offset_during_append_); | |
| 319 timestamp_offset_during_append_ = ×tamp_offset; | |
| 318 stream_parser_->Flush(); | 320 stream_parser_->Flush(); |
| 321 timestamp_offset_during_append_ = NULL; | |
| 322 | |
| 319 frame_processor_->Reset(); | 323 frame_processor_->Reset(); |
| 320 parsing_media_segment_ = false; | 324 parsing_media_segment_ = false; |
| 321 } | 325 } |
| 322 | 326 |
| 323 void SourceState::Remove(TimeDelta start, TimeDelta end, TimeDelta duration) { | 327 void SourceState::Remove(TimeDelta start, TimeDelta end, TimeDelta duration) { |
| 324 if (audio_) | 328 if (audio_) |
| 325 audio_->Remove(start, end, duration); | 329 audio_->Remove(start, end, duration); |
| 326 | 330 |
| 327 if (video_) | 331 if (video_) |
| 328 video_->Remove(start, end, duration); | 332 video_->Remove(start, end, duration); |
| (...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 653 DVLOG(2) << "OnEndOfMediaSegment()"; | 657 DVLOG(2) << "OnEndOfMediaSegment()"; |
| 654 parsing_media_segment_ = false; | 658 parsing_media_segment_ = false; |
| 655 new_media_segment_ = false; | 659 new_media_segment_ = false; |
| 656 } | 660 } |
| 657 | 661 |
| 658 bool SourceState::OnNewBuffers( | 662 bool SourceState::OnNewBuffers( |
| 659 const StreamParser::BufferQueue& audio_buffers, | 663 const StreamParser::BufferQueue& audio_buffers, |
| 660 const StreamParser::BufferQueue& video_buffers, | 664 const StreamParser::BufferQueue& video_buffers, |
| 661 const StreamParser::TextBufferQueueMap& text_map) { | 665 const StreamParser::TextBufferQueueMap& text_map) { |
| 662 DVLOG(2) << "OnNewBuffers()"; | 666 DVLOG(2) << "OnNewBuffers()"; |
| 663 DCHECK(timestamp_offset_during_append_); | 667 DCHECK(timestamp_offset_during_append_); |
|
wolenetz
2014/04/25 21:00:32
Now would be a good time to add DCHECK(parsing_med
damienv1
2014/05/05 22:39:13
Done.
| |
| 664 | 668 |
| 665 const TimeDelta timestamp_offset_before_processing = | 669 const TimeDelta timestamp_offset_before_processing = |
| 666 *timestamp_offset_during_append_; | 670 *timestamp_offset_during_append_; |
| 667 | 671 |
| 668 // Calculate the new timestamp offset for audio/video tracks if the stream | 672 // Calculate the new timestamp offset for audio/video tracks if the stream |
| 669 // parser has requested automatic updates. | 673 // parser has requested automatic updates. |
| 670 TimeDelta new_timestamp_offset = timestamp_offset_before_processing; | 674 TimeDelta new_timestamp_offset = timestamp_offset_before_processing; |
| 671 if (auto_update_timestamp_offset_) { | 675 if (auto_update_timestamp_offset_) { |
| 672 const bool have_audio_buffers = !audio_buffers.empty(); | 676 const bool have_audio_buffers = !audio_buffers.empty(); |
| 673 const bool have_video_buffers = !video_buffers.empty(); | 677 const bool have_video_buffers = !video_buffers.empty(); |
| (...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1268 base::ResetAndReturn(&seek_cb_).Run(PIPELINE_OK); | 1272 base::ResetAndReturn(&seek_cb_).Run(PIPELINE_OK); |
| 1269 } | 1273 } |
| 1270 | 1274 |
| 1271 ranges = GetBufferedRanges_Locked(); | 1275 ranges = GetBufferedRanges_Locked(); |
| 1272 } | 1276 } |
| 1273 | 1277 |
| 1274 for (size_t i = 0; i < ranges.size(); ++i) | 1278 for (size_t i = 0; i < ranges.size(); ++i) |
| 1275 host_->AddBufferedTimeRange(ranges.start(i), ranges.end(i)); | 1279 host_->AddBufferedTimeRange(ranges.start(i), ranges.end(i)); |
| 1276 } | 1280 } |
| 1277 | 1281 |
| 1278 void ChunkDemuxer::Abort(const std::string& id) { | 1282 void ChunkDemuxer::Abort(const std::string& id, |
| 1283 base::TimeDelta timestamp_offset) { | |
| 1279 DVLOG(1) << "Abort(" << id << ")"; | 1284 DVLOG(1) << "Abort(" << id << ")"; |
| 1280 base::AutoLock auto_lock(lock_); | 1285 base::AutoLock auto_lock(lock_); |
| 1281 DCHECK(!id.empty()); | 1286 DCHECK(!id.empty()); |
| 1282 CHECK(IsValidId(id)); | 1287 CHECK(IsValidId(id)); |
| 1283 source_state_map_[id]->Abort(); | 1288 source_state_map_[id]->Abort(timestamp_offset); |
| 1284 } | 1289 } |
| 1285 | 1290 |
| 1286 void ChunkDemuxer::Remove(const std::string& id, TimeDelta start, | 1291 void ChunkDemuxer::Remove(const std::string& id, TimeDelta start, |
| 1287 TimeDelta end) { | 1292 TimeDelta end) { |
| 1288 DVLOG(1) << "Remove(" << id << ", " << start.InSecondsF() | 1293 DVLOG(1) << "Remove(" << id << ", " << start.InSecondsF() |
| 1289 << ", " << end.InSecondsF() << ")"; | 1294 << ", " << end.InSecondsF() << ")"; |
| 1290 base::AutoLock auto_lock(lock_); | 1295 base::AutoLock auto_lock(lock_); |
| 1291 | 1296 |
| 1292 DCHECK(!id.empty()); | 1297 DCHECK(!id.empty()); |
| 1293 CHECK(IsValidId(id)); | 1298 CHECK(IsValidId(id)); |
| (...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1668 } | 1673 } |
| 1669 | 1674 |
| 1670 void ChunkDemuxer::ShutdownAllStreams() { | 1675 void ChunkDemuxer::ShutdownAllStreams() { |
| 1671 for (SourceStateMap::iterator itr = source_state_map_.begin(); | 1676 for (SourceStateMap::iterator itr = source_state_map_.begin(); |
| 1672 itr != source_state_map_.end(); ++itr) { | 1677 itr != source_state_map_.end(); ++itr) { |
| 1673 itr->second->Shutdown(); | 1678 itr->second->Shutdown(); |
| 1674 } | 1679 } |
| 1675 } | 1680 } |
| 1676 | 1681 |
| 1677 } // namespace media | 1682 } // namespace media |
| OLD | NEW |