Index: media/filters/chunk_demuxer.cc |
diff --git a/media/filters/chunk_demuxer.cc b/media/filters/chunk_demuxer.cc |
index ccd5d17368faffefdfb1c9dabbe80e4f67ac94fd..7ddee5a0ec6666f1138068a24923d2827336f84d 100644 |
--- a/media/filters/chunk_demuxer.cc |
+++ b/media/filters/chunk_demuxer.cc |
@@ -17,6 +17,7 @@ |
#include "media/base/bind_to_current_loop.h" |
#include "media/base/stream_parser_buffer.h" |
#include "media/base/video_decoder_config.h" |
+#include "media/filters/frame_processor.h" |
#include "media/filters/legacy_frame_processor.h" |
#include "media/filters/stream_parser_factory.h" |
@@ -137,8 +138,12 @@ class SourceState { |
// Sets |frame_processor_|'s sequence mode to |sequence_mode|. |
void SetSequenceMode(bool sequence_mode); |
+ // Signals the coded frame processor to update its group start timestamp to be |
+ // |timestamp_offset| if it is in sequence append mode. |
+ void SetGroupStartTimestampIfInSequenceMode(base::TimeDelta timestamp_offset); |
+ |
// Returns the range of buffered data in this source, capped at |duration|. |
- // |ended| - Set to true if end of stream has been signalled and the special |
+ // |ended| - Set to true if end of stream has been signaled and the special |
// end of stream range logic needs to be executed. |
Ranges<TimeDelta> GetBufferedRanges(TimeDelta duration, bool ended) const; |
@@ -292,15 +297,22 @@ void SourceState::SetSequenceMode(bool sequence_mode) { |
frame_processor_->SetSequenceMode(sequence_mode); |
} |
+void SourceState::SetGroupStartTimestampIfInSequenceMode( |
+ base::TimeDelta timestamp_offset) { |
+ DCHECK(!parsing_media_segment_); |
+ |
+ frame_processor_->SetGroupStartTimestampIfInSequenceMode(timestamp_offset); |
+} |
+ |
bool SourceState::Append(const uint8* data, size_t length, |
TimeDelta append_window_start, |
TimeDelta append_window_end, |
TimeDelta* timestamp_offset) { |
DCHECK(timestamp_offset); |
DCHECK(!timestamp_offset_during_append_); |
- timestamp_offset_during_append_ = timestamp_offset; |
append_window_start_during_append_ = append_window_start; |
append_window_end_during_append_ = append_window_end; |
+ timestamp_offset_during_append_ = timestamp_offset; |
// TODO(wolenetz/acolwell): Curry and pass a NewBuffersCB here bound with |
// append window and timestamp offset pointer. See http://crbug.com/351454. |
@@ -1131,6 +1143,11 @@ ChunkDemuxer::Status ChunkDemuxer::AddId(const std::string& id, |
base::Bind(&ChunkDemuxer::IncreaseDurationIfNecessary, |
base::Unretained(this)))); |
+ // BIG TODO remove! |
+ frame_processor.reset(new FrameProcessor( |
+ base::Bind(&ChunkDemuxer::IncreaseDurationIfNecessary, |
+ base::Unretained(this)))); |
+ |
scoped_ptr<SourceState> source_state( |
new SourceState(stream_parser.Pass(), |
frame_processor.Pass(), log_cb_, |
@@ -1351,6 +1368,20 @@ void ChunkDemuxer::SetSequenceMode(const std::string& id, |
source_state_map_[id]->SetSequenceMode(sequence_mode); |
} |
+void ChunkDemuxer::SetGroupStartTimestampIfInSequenceMode( |
+ const std::string& id, |
+ base::TimeDelta timestamp_offset) { |
+ base::AutoLock auto_lock(lock_); |
+ DVLOG(1) << "SetGroupStartTimestampIfInSequenceMode(" << id << ", " |
+ << timestamp_offset.InSecondsF() << ")"; |
+ CHECK(IsValidId(id)); |
+ DCHECK_NE(state_, ENDED); |
+ |
+ source_state_map_[id]->SetGroupStartTimestampIfInSequenceMode( |
+ timestamp_offset); |
+} |
+ |
+ |
void ChunkDemuxer::MarkEndOfStream(PipelineStatus status) { |
DVLOG(1) << "MarkEndOfStream(" << status << ")"; |
base::AutoLock auto_lock(lock_); |
@@ -1552,6 +1583,13 @@ void ChunkDemuxer::UpdateDuration(TimeDelta new_duration) { |
void ChunkDemuxer::IncreaseDurationIfNecessary(TimeDelta new_duration) { |
DCHECK(new_duration != kNoTimestamp()); |
+ DCHECK(new_duration != kInfiniteDuration()); |
+ |
+ // http://www.w3.org/TR/media-source/#sourcebuffer-coded-frame-processing |
+ // TODO(acolwell): Adjust the MSE spec text for this step to be like: |
+ // 5. If highest presentation end timestamp is beyond the current duration, |
+ // then run the duration change algorithm with new duration set to highest |
+ // presentation end timestamp. |
if (new_duration <= duration_) |
return; |