Closed Bug 1315211 Opened 8 years ago Closed 8 years ago

[MSE] trackBuffersManager process the entire buffer before continuing handling the metadata

Categories

(Core :: Audio/Video: Playback, defect)

defect
Not set
normal

Tracking

()

RESOLVED INVALID

People

(Reporter: jya, Unassigned)

References

(Blocks 1 open bug)

Details

Following bug 1314533 being corrected, this is the reason behind the test in media-source/mediasource-errors.html failing. The test append corrupted data, but with a valid init segment. It then checks that the loadedmetadata event is fired before the error events is fired. we fail because we fire error, and never fire loadedmetadata. The reason for this is that we process the entire buffer, including finding any errors prior continuing and demuxing the data. Per spec: https://w3c.github.io/media-source/index.html#sourcebuffer-init-segment-received "6. If the HTMLMediaElement.readyState attribute is HAVE_NOTHING, then run the following steps: If one or more objects in sourceBuffers have first initialization segment received flag set to false, then abort these steps. Set the HTMLMediaElement.readyState attribute to HAVE_METADATA. Note Per HTMLMediaElement ready states [HTML51] logic, HTMLMediaElement.readyState changes may trigger events on the HTMLMediaElement. This particular transition should trigger HTMLMediaElement logic to queue a task to fire a simple event named loadedmetadata at the media element. " So loadedmetadata should be fired as soon as we have received an init segment on all the active source buffers. This is no trivial task as the buffer is processed in the MediaSourceDemuxer task queue and the different source buffers aren't aware of one another. We need to have a mechanism where the TrackBuffersManager can suspend the parsing of the buffer until the media element fires loadedmetadata (that is after the MediaFormatReader has finished demuxing, the MDSM has received the Metadata Promise and then all the way back to the HTMLMediaElement. A mirror on the readState between the TrackBufferManager and the HTMLMediaElement would have helped, but tail dispatch isn't enabled on the MediaSourceDemuxer task queue. In any case, resolving this issue so we are spec compliant in regards to metadata is going to be messy.
Actually, I now believe the WPT test is invalid. https://w3c.github.io/media-source/index.html#sourcebuffer-segment-parser-loop "2. If the input buffer contains bytes that violate the SourceBuffer byte stream format specification, then run the append error algorithm and abort this algorithm." So if the input buffer contains any invalid data, it should be discarded entirely, even if there is valid init segment in it.
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.