[MSE][WebCodecs] Plumb appendEncodedChunks to WebSourceBuffer::AppendChunks
This change: 1) Implements SourceBuffer::appendEncodedChunks(). This is the first promise-based MSE API. Like async appendBuffer(), once the synchronous prepareAppend steps are complete, an async task is scheduled to complete the chunks' append. Unlike async appendBuffer(), the 'update', 'updateend', 'abort', 'error' events involved in an async chunk append are not enqueued, as the same information is exposed instead in promise rejections. Also, mixing event-notification with promise resolution/rejection is confusing and redundant, and w3ctag guidelines for promise-based APIs need such events originating in a promise's async execution to be dispatched (not just enqueued) prior to promise resolution/rejection occurring. 2) Converts (using new local helpers in SourceBuffer) the chunks directly into the type used in the underlying MSE buffering implementation (StreamParserBuffers in a circular_deque) during the synchronous portion of appendEncodedChunks(). 3) The async chunk task is canceled during contextDestruction; it also is used to gate hasPendingActivity. Essentially, it's a 3rd async operation the SourceBuffer could do (in addition to pre-existing async appendBuffer and async remove). At most one of these three async operations may be pending at a time. This keeps the behavior unsurprising and aligns better w.r.t. previous similar async MSE operations. 4) Adds a new WebSourceBuffer AppendChunks method and a stubbed implementation of it in WebSourceBufferImpl. Later changes will update WSBI::AppendChunks() to send the buffers through ChunkDemuxer to the WebCodecsEncodedChunkStreamParser, and add tests for promise rejection/abort/success scenarios and basic end-to-end buffering and playback of encoded chunks with MSE. Refinements, such as supporting h264 chunk buffering, using non-hardcoded audio chunk duration (from a new optional duration, but required-for-MSE, EncodedAudioChunkInit attribute), and letting the app provide decode timestamp in EncodedVideoChunkInit, may also come later. BUG=1144908 Change-Id: Ieb5d0942e68f48156bee9290dcb99dad2e280e85 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2574534Reviewed-by:Daniel Cheng <dcheng@chromium.org> Reviewed-by:
Dan Sanders <sandersd@chromium.org> Commit-Queue: Matthew Wolenetz <wolenetz@chromium.org> Cr-Commit-Position: refs/heads/master@{#836201}
Showing
This diff is collapsed.
Please register or sign in to comment