Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1235)

Unified Diff: media/filters/source_buffer_stream.cc

Issue 1091293005: MSE: Relax the 'media segment must begin with keyframe' requirement (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased. Checkpoint. Not ready for review yet. Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/filters/source_buffer_stream.h ('k') | media/filters/source_buffer_stream_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/filters/source_buffer_stream.cc
diff --git a/media/filters/source_buffer_stream.cc b/media/filters/source_buffer_stream.cc
index e17a4f1c91952b64cf280a9777404e4adeec71d2..b0b2add52db68bd84d180e0e9fe2cd5640f439f6 100644
--- a/media/filters/source_buffer_stream.cc
+++ b/media/filters/source_buffer_stream.cc
@@ -134,7 +134,7 @@ SourceBufferStream::SourceBufferStream(const AudioDecoderConfig& audio_config,
bool splice_frames_enabled)
: media_log_(media_log),
seek_buffer_timestamp_(kNoTimestamp()),
- media_segment_start_time_(kNoDecodeTimestamp()),
+ coded_frame_group_start_time_(kNoDecodeTimestamp()),
range_for_next_append_(ranges_.end()),
last_appended_buffer_timestamp_(kNoDecodeTimestamp()),
last_output_buffer_timestamp_(kNoDecodeTimestamp()),
@@ -150,7 +150,7 @@ SourceBufferStream::SourceBufferStream(const VideoDecoderConfig& video_config,
bool splice_frames_enabled)
: media_log_(media_log),
seek_buffer_timestamp_(kNoTimestamp()),
- media_segment_start_time_(kNoDecodeTimestamp()),
+ coded_frame_group_start_time_(kNoDecodeTimestamp()),
range_for_next_append_(ranges_.end()),
last_appended_buffer_timestamp_(kNoDecodeTimestamp()),
last_output_buffer_timestamp_(kNoDecodeTimestamp()),
@@ -167,7 +167,7 @@ SourceBufferStream::SourceBufferStream(const TextTrackConfig& text_config,
: media_log_(media_log),
text_track_config_(text_config),
seek_buffer_timestamp_(kNoTimestamp()),
- media_segment_start_time_(kNoDecodeTimestamp()),
+ coded_frame_group_start_time_(kNoDecodeTimestamp()),
range_for_next_append_(ranges_.end()),
last_appended_buffer_timestamp_(kNoDecodeTimestamp()),
last_output_buffer_timestamp_(kNoDecodeTimestamp()),
@@ -182,22 +182,25 @@ SourceBufferStream::~SourceBufferStream() {
}
}
-void SourceBufferStream::OnNewMediaSegment(
- DecodeTimestamp media_segment_start_time) {
- DVLOG(1) << __FUNCTION__ << " " << GetStreamTypeName()
- << " (" << media_segment_start_time.InSecondsF() << ")";
+void SourceBufferStream::OnStartOfCodedFrameGroup(
+ DecodeTimestamp coded_frame_group_start_time) {
+ DVLOG(1) << __FUNCTION__ << " " << GetStreamTypeName() << " ("
+ << coded_frame_group_start_time.InSecondsF() << ")";
DCHECK(!end_of_stream_);
- media_segment_start_time_ = media_segment_start_time;
- new_media_segment_ = true;
+ coded_frame_group_start_time_ = coded_frame_group_start_time;
+ new_coded_frame_group_ = true;
RangeList::iterator last_range = range_for_next_append_;
- range_for_next_append_ = FindExistingRangeFor(media_segment_start_time);
+ range_for_next_append_ = FindExistingRangeFor(coded_frame_group_start_time);
- // Only reset |last_appended_buffer_timestamp_| if this new media segment is
- // not adjacent to the previous media segment appended to the stream.
+ // Only reset |last_appended_buffer_timestamp_| if this new coded frame group
+ // is not adjacent to the previous coded frame group appended to the stream.
+ // TODO(wolenetz): Change this to DCHECK or MEDIA_LOG if found to be adjacent,
+ // and otherwise trust the caller to signal correctly only when there is a
+ // discontinuity detected by coded frame processor?
if (range_for_next_append_ == ranges_.end() ||
!AreAdjacentInSequence(last_appended_buffer_timestamp_,
- media_segment_start_time)) {
+ coded_frame_group_start_time)) {
last_appended_buffer_timestamp_ = kNoDecodeTimestamp();
last_appended_buffer_is_keyframe_ = false;
DVLOG(3) << __FUNCTION__ << " next appended buffers will be in a new range";
@@ -214,31 +217,38 @@ bool SourceBufferStream::Append(const BufferQueue& buffers) {
"buffers to append", buffers.size());
DCHECK(!buffers.empty());
- DCHECK(media_segment_start_time_ != kNoDecodeTimestamp());
- DCHECK(media_segment_start_time_ <= buffers.front()->GetDecodeTimestamp());
+ DCHECK(coded_frame_group_start_time_ != kNoDecodeTimestamp());
+ DCHECK(coded_frame_group_start_time_ <=
+ buffers.front()->GetDecodeTimestamp());
DCHECK(!end_of_stream_);
DVLOG(1) << __FUNCTION__ << " " << GetStreamTypeName()
<< ": buffers " << BufferQueueToLogString(buffers);
- // New media segments must begin with a keyframe.
- // TODO(wolenetz): Relax this requirement. See http://crbug.com/229412.
- if (new_media_segment_ && !buffers.front()->is_key_frame()) {
- MEDIA_LOG(ERROR, media_log_) << "Media segment did not begin with key "
- "frame. Support for such segments will be "
- "available in a future version. Please see "
- "https://crbug.com/229412.";
+ // New coded frame groups emitted by the coded frame processor must begin with
+ // a keyframe.
+ // TODO(wolenetz): Change this to a DCHECK, if not a CHECK, once the frame
+ // processor becomes aware of discontinuities introduced by the range removal
+ // algorithm. See http://crbug.com/229412.
+ // BIG TODO: ensure this new log is exercised in unit test; adjust tests for
+ // lack of old log "Media segment did not begin with key frame..."
+ if (new_coded_frame_group_ && !buffers.front()->is_key_frame()) {
+ MEDIA_LOG(ERROR, media_log_)
+ << "Coded frame group did not begin with key frame.";
return false;
}
- // Buffers within a media segment should be monotonically increasing.
- if (!IsMonotonicallyIncreasing(buffers))
+ // Buffers within a coded frame group should be monotonically increasing.
+ // TODO(wolenetz): Change this to a DCHECK in debug builds?
+ if (!IsMonotonicallyIncreasing(buffers)) {
return false;
+ }
- if (media_segment_start_time_ < DecodeTimestamp() ||
+ if (coded_frame_group_start_time_ < DecodeTimestamp() ||
buffers.front()->GetDecodeTimestamp() < DecodeTimestamp()) {
+ // BIG TODO: if necessary, adjust any existing test log expectation
MEDIA_LOG(ERROR, media_log_)
- << "Cannot append a media segment with negative timestamps.";
+ << "Cannot append a coded frame group with negative timestamps.";
return false;
}
@@ -269,15 +279,17 @@ bool SourceBufferStream::Append(const BufferQueue& buffers) {
last_appended_buffer_is_keyframe_ = buffers.back()->is_key_frame();
} else {
DecodeTimestamp new_range_start_time = std::min(
- media_segment_start_time_, buffers.front()->GetDecodeTimestamp());
+ coded_frame_group_start_time_, buffers.front()->GetDecodeTimestamp());
const BufferQueue* buffers_for_new_range = &buffers;
BufferQueue trimmed_buffers;
- // If the new range is not being created because of a new media
- // segment, then we must make sure that we start with a key frame.
- // This can happen if the GOP in the previous append gets destroyed
- // by a Remove() call.
- if (!new_media_segment_) {
+ // If the new range is not being created because of a new coded frame group,
+ // then we must make sure that we start with a key frame. This can happen
+ // if the GOP in the previous append gets destroyed by a Remove() call.
+ // TODO(wolenetz): Change this to at least a DCHECK once the frame processor
+ // becomes aware of discontinuities introduced by the range removal
+ // algorithm. See http://crbug.com/229412.
+ if (!new_coded_frame_group_) {
BufferQueue::const_iterator itr = buffers.begin();
// Scan past all the non-key-frames.
@@ -320,7 +332,7 @@ bool SourceBufferStream::Append(const BufferQueue& buffers) {
buffers_for_new_range->back()->is_key_frame();
}
- new_media_segment_ = false;
+ new_coded_frame_group_ = false;
MergeWithAdjacentRangeIfNecessary(range_for_next_append_);
@@ -560,9 +572,9 @@ bool SourceBufferStream::IsMonotonicallyIncreasing(
bool SourceBufferStream::IsNextTimestampValid(
DecodeTimestamp next_timestamp, bool next_is_keyframe) const {
return (last_appended_buffer_timestamp_ != next_timestamp) ||
- new_media_segment_ ||
- SourceBufferRange::AllowSameTimestamp(last_appended_buffer_is_keyframe_,
- next_is_keyframe);
+ new_coded_frame_group_ ||
+ SourceBufferRange::AllowSameTimestamp(
+ last_appended_buffer_is_keyframe_, next_is_keyframe);
}
« no previous file with comments | « media/filters/source_buffer_stream.h ('k') | media/filters/source_buffer_stream_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698