Reland: MSE: Relax the 'media segment must begin with keyframe' requirement
The current version of the MSE spec no longer requires that media segments
start with a keyframe. This change reworks the MSE implementation
so that it now allows tracks within media segments to not begin
with a keyframe.
To accomplish this requirement's relaxation, this CL:
1) Separates media segment signaling from coded frame group signaling:
MSE stream parsers need to report whether or not they are currently
in the middle of parsing a media segment, such as a WebM cluster, to
comply with spec disallowance of certain operations like changing
SourceBuffer appendMode when appendState is PARSING_MEDIA_SEGMENT.
However, SourceBufferStream only needs to be signaled when a new coded
frame group is beginning, for example when buffers are appended
following a discontinuity.
2) Since the FrameProcessor now can transitively signal SourceBufferStreams
when a new coded frame group is beginning (which might span multiple
media segments), the SourceBufferStream can rely upon the fact
that the next buffer appended must be a keyframe if it's been told
that a new coded frame group is starting. A CHECK() is included.
3) New ChunkDemuxerTests.
4) Various test cleanup to conform to the distinct "new coded frame group"
and "new media segment" signaling separation, as well as removal
of decode error verification when a media segment doesn't begin
with a keyframe.
5) Fixes regression found in previous attempt, tracked in bug 581125. In
short, relaxes the restriction on same timestamp sequences. A
MediaLog is added where decode error would occur previously.
6) Fixes regression found in previous attempt, tracked in bug 581458. In
short, prevents tiny gaps under the FrameProcessor's discontinuity
threshold from triggering buffered range gaps in SourceBufferStream if
there is an intervening removal of media from the range last appended
to, but the last appended GOP survived the removal.
7) Uses coded frame group start time more intelligently to determine
range adjacency on appends. This allows extremely jagged start
coded frame group appends to overlap an existing range, fixing a
DCHECK which could occur otherwise (and adhering more correctly
to muxed buffered range expectations.) Improves handling of range
removals that may occur between SBS::OnStartOfCodedFrameGroup()
Note that the FrameProcessor already drops non-keyframes prior to the
first keyframe processed for a track following a discontinuity,
and the SourceBufferStream already drops non-keyframes prior to the
first keyframe processed for a track following a range removal that
removed the last appended position in the current coded frame group.
TEST=Updated ChunkDemuxerTests, SourceBufferStreamTests,
FrameProcessorTests. Also locally tested: bug 459546's
original report no longer fails. A sample webm VP9 file
from b/26524063 no longer fails. GPM webm vp9/opus test no
longer fails. Bug 518854's original report's "flags_all.mp4"
no longer fails. Bugs 581125 and 581458 no longer repro.
Review URL: https://codereview.chromium.org/1670033002
15 files changed