Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Media Source Extensions for WebCodecs #576

Closed
1 task done
wolenetz opened this issue Nov 23, 2020 · 9 comments
Closed
1 task done

Media Source Extensions for WebCodecs #576

wolenetz opened this issue Nov 23, 2020 · 9 comments
Assignees
Labels
chromium-high-priority Something that the Chromium team would like the TAG to prioritise Progress: propose closing we think it should be closed but are waiting on some feedback or consensus Progress: review complete Resolution: satisfied The TAG is satisfied with this design Review type: CG early review An early review of general direction from a Community Group Topic: media Venue: Media WG

Comments

@wolenetz
Copy link

wolenetz commented Nov 23, 2020

HIQaH! QaH! TAG!

I'm requesting a TAG review of Media Source Extensions for WebCodecs.

The Media Source Extensions API (MSE) requires applications to provide fragments of containerized media (such as fragmented MP4, WebM, or MP3) to be able to buffer and play that media. If the application already has the media in a parsed and structured form, it can cost extra latency and code complexity to package that media into a container and feed it to MSE. As the web platform is evolving to give applications lower-level abstractions for efficiently encoding and decoding media via the WebCodecs API, MSE can use WebCodec's media structures to let applications more efficiently feed their media to MSE. We propose additional MSE methods to provide web authors easy ability to buffer "containerless" media as an alternative to existing MSE methods that required containerized, "muxed" media.

Further details:

  • I have reviewed the TAG's API Design Principles
  • The group where the incubation/design work on this is being done (or is intended to be done in the future): Media WG
  • The group where standardization of this work is intended to be done ("unknown" if not known): Media WG
  • Major unresolved issues with or opposition to this design: None. Minor open questions are listed in the Explainer's Open Questions section

You should also know that...

  • The review is early in the prototyping and design stage because we expect to learn from early implementation feedback more precise answers to the Explainer's Open Questions section, so we'd like to get a rough design reviewed to help refine eventual implementation and specification for this feature.

We'd prefer the TAG provide feedback as:

💬 leave review feedback as a comment in this issue and @-notify @wolenetz

@wolenetz wolenetz added Progress: untriaged Review type: CG early review An early review of general direction from a Community Group labels Nov 23, 2020
wolenetz added a commit to wolenetz/mse-for-webcodecs that referenced this issue Nov 23, 2020
Add link to w3ctag review request issue w3ctag/design-reviews#576
blueboxd pushed a commit to blueboxd/chromium-legacy that referenced this issue Nov 25, 2020
Stubs new MSE methods and overloads that, when fully implemented in
later changes, would allow:

1. use of WebCodecs decoder configs as addSourceBuffer() and
   changeType() arguments (in lieu of parsing initialization segments
   from a container bytestream), and
2. buffering of WebCodecs encoded chunks via appendEncodedChunks() (in
   lieu of parsing media segments from a container bytestream).

Much of the complexity of this initial change is in the coordination of
the IDL bindings generator to achieve disambiguated overload resolution,
primarily to keep the exposed API simple (only 1 actual new method name
is added, corresponding to bullet 2, above), using two approaches:

* Dictionary of Dictionaries: SourceBufferConfig wraps either a
  WebCodecs audio or video decoder configuration. Without such a
  distinct new type wrapping them, unioning or overloading would fail to
  resolve.

* Unions, with caveats: the new appendEncodedChunks method takes either
  sequences of audio or video chunks, or single audio or video chunks,
  all in a single argument of IDL union type.

  Caveat: "sequence<A> or sequence<V>" cannot be disambiguated by the
  bindings, so sequence<A or V> is used in this change. Regardless, the
  eventual implementation would need to validate that all in the
  sequence are either A or all are V (along with the usual validation
  that appended chunks or frames also appear to use the most recent
  SourceBufferConfig).

  Caveat: The bindings generator requires help when generated union type
  identifiers are too long for some platforms. This change adds a
  seventh case to the existing hard-coded lists of names that need
  shortening with the generator.

I2P: https://groups.google.com/a/chromium.org/g/blink-dev/c/bejy1nmoWmU/m/CQ90X3j5BQAJ
TAG early-design review request: w3ctag/design-reviews#576
Explainer: https://github.com/wolenetz/mse-for-webcodecs/blob/main/explainer.md
MSE spec bug: w3c/media-source#184

BUG=1144908

Change-Id: Ibc8bd806fe1790ae74fe5ce86865cdfebcdc3096
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2515199
Commit-Queue: Matthew Wolenetz <wolenetz@chromium.org>
Reviewed-by: Dale Curtis <dalecurtis@chromium.org>
Reviewed-by: Kentaro Hara <haraken@chromium.org>
Reviewed-by: Dan Sanders <sandersd@chromium.org>
Reviewed-by: Chrome Cunningham <chcunningham@chromium.org>
Cr-Commit-Position: refs/heads/master@{#830837}
@torgo torgo added this to the 2020-12-07-week milestone Nov 30, 2020
@cynthia
Copy link
Member

cynthia commented Feb 23, 2021

As it looks like WebCodecs is going through some design changes, we'd like to hold off on providing feedback until that part has been ossified.

@dalecurtis
Copy link

The EncodedAudioChunk/EncodedVideoChunk parts of the WebCodecs spec aren't in flux -- which are the only parts this depends on -- so this should be safe to look at.

@cynthia
Copy link
Member

cynthia commented Feb 24, 2021

Good to know! Thanks. Will take a look.

@cynthia
Copy link
Member

cynthia commented May 12, 2021

@ylafon and I discussed this today.

We think the use-cases and the proposed API design is fine. There seems to be a bit of unanswered questions in terms of implementation details (e.g. MSE is hardware decoded, WebCodecs should also be hardware decoded, what if you don't have enough decoder capacity?) and whether or not this is a proper solution to the use-case at hand. However, we'll leave that discussion up to the group.

For now, we're happy to see this move forward. Thanks for bringing this to our attention!

@cynthia cynthia added Progress: propose closing we think it should be closed but are waiting on some feedback or consensus Progress: review complete labels May 12, 2021
@cynthia cynthia added the Resolution: satisfied The TAG is satisfied with this design label May 12, 2021
@dalecurtis
Copy link

@cynthia Glad to hear! Can you elaborate on your questions though? I don't think those questions are relevant to MSE. MSE makes no guarantees about whether media is hardware or software decoded or even anything about how the underlying decoder configurations are managed (intentionally so to allow user agent management of such resources).

The proposed mechanism is only about allowing authors to append already demuxed data into MSE, thereby skipping the demuxing which normally happens implicitly through the byte based append methods. So it's a strict cost reduction mechanism with otherwise no impacts on how MSE functions.

Did y'all have any feedback on whether these new append methods should be added as promise based? Should the interface use the non-promise style (updating, updateend events) for consistency until byte-based promise methods are available? Should we only add the promise based method for chunks once we have a promise based method for bytes?

@torgo torgo added the chromium-high-priority Something that the Chromium team would like the TAG to prioritise label Aug 26, 2021
@wolenetz
Copy link
Author

wolenetz commented Sep 9, 2021

Raising these questions again here, as we haven't yet received a response about them:

Did y'all have any feedback on whether these new append methods should be added as promise based? Should the interface use the non-promise style (updating, updateend events) for consistency until byte-based promise methods are available? Should we only add the promise based method for chunks once we have a promise based method for bytes?

@cynthia
Copy link
Member

cynthia commented Sep 15, 2021

Apologies for the delay.

Did y'all have any feedback on whether these new append methods should be added as promise based? Should the interface use the non-promise style (updating, updateend events) for consistency until byte-based promise methods are available? Should we only add the promise based method for chunks once we have a promise based method for bytes?

@plinss, @atanassov and I discussed during our VF2F today. And one of the concerns we had were if promises would provide the latency guarantees that the downstream application needs (given that current MSE is event driven, it should be okay?), and if a domain specific application of promises would make it painful to upgrade when byte-based promises are available. We don't have a strong preference for either, but we'd like to hear your thoughts on this.

Does the current design propose a generic path forward for a byte-based promise API? If so, we think promises are probably the right answer.

@wolenetz
Copy link
Author

wolenetz commented Oct 1, 2021

Did y'all have any feedback on whether these new append methods should be added as promise based? Should the interface use the non-promise style (updating, updateend events) for consistency until byte-based promise methods are available? Should we only add the promise based method for chunks once we have a promise based method for bytes?

@plinss, @atanassov and I discussed during our VF2F today. And one of the concerns we had were if promises would provide the latency guarantees that the downstream application needs (given that current MSE is event driven, it should be okay?),

Since the current MSE is event driven, I don't expect worsened latency due to apps instead awaiting Promise resolution/rejection via this new promise-based method for appending chunks versus what that latency would have been had it been event driven chunk-appending instead. In passing, I've heard that at least some MSE API users have already wrapped the existing event-driven byte-based append operations inside promises in their applications.
Note also that the ergonomics of a promise-based API are simpler, too: the extra enqueueing of 'updatestart', and 'update' events are not done (nor 'abort' or 'error' in those rejection paths). It is unclear if existing API users depend on those events, or if their absence is negligible.

and if a domain specific application of promises would make it painful to upgrade when byte-based promises are available. We don't have a strong preference for either, but we'd like to hear your thoughts on this.

I'm not sure I understand this portion of your response. If and when Promisified versions of MSE appendBuffer() is available, it's unlikely that the event-driven versions would be deprecated. Hence, upgrading from event-driven to promisified byte-based append would not necessarily require urgent prioritization by the MSE API user, though (apart from the lack of probably superfluous extra events) there would not be a big change of actual functionality made available by the Promisified versions of those methods. I feel like I'm missing your point though.

Does the current design propose a generic path forward for a byte-based promise API? If so, we think promises are probably the right answer.

The path taken in MSE-for-WebCodecs' appendEncodedChunks() lays out a pattern that indeed could be followed by a Promisified version of the existing event-driven byte-based appendBuffer(): the draft specification PR (w3c/media-source#302) for the Promise portion of the new appendEncodedChunks() reuses much of the existing state machine structure: at most one asynchronous operation can be in-flight at a time for a particular SourceBuffer, with well-defined start/complete/error/abort paths for the existing event-driven async operation (and now also for the Promisified appendEncodedChunks() async operation.

@cynthia
Copy link
Member

cynthia commented Oct 12, 2021

Thank you for the response. To be upfront, from a review point-of-view this is complete - and we are happy to see this proposal move forward. Thank you for bringing this to us and apologies for the process delay.

Hence, upgrading from event-driven to promisified byte-based append would not necessarily require urgent prioritization by the MSE API user, though (apart from the lack of probably superfluous extra events) there would not be a big change of actual functionality made available by the Promisified versions of those methods. I feel like I'm missing your point though.

The question/concern here was whether or not the interoperability with generic byte-base promises (when it happens) can be a potential future pain point if this is too domain-specific, and the question was about whether or not there ideas have been exchanged around that. I think the response addresses some of the questions we had, although I'll have to check with the other reviewers to be sure.

@cynthia cynthia closed this as completed Oct 12, 2021
mjfroman pushed a commit to mjfroman/moz-libwebrtc-third-party that referenced this issue Oct 14, 2022
Stubs new MSE methods and overloads that, when fully implemented in
later changes, would allow:

1. use of WebCodecs decoder configs as addSourceBuffer() and
   changeType() arguments (in lieu of parsing initialization segments
   from a container bytestream), and
2. buffering of WebCodecs encoded chunks via appendEncodedChunks() (in
   lieu of parsing media segments from a container bytestream).

Much of the complexity of this initial change is in the coordination of
the IDL bindings generator to achieve disambiguated overload resolution,
primarily to keep the exposed API simple (only 1 actual new method name
is added, corresponding to bullet 2, above), using two approaches:

* Dictionary of Dictionaries: SourceBufferConfig wraps either a
  WebCodecs audio or video decoder configuration. Without such a
  distinct new type wrapping them, unioning or overloading would fail to
  resolve.

* Unions, with caveats: the new appendEncodedChunks method takes either
  sequences of audio or video chunks, or single audio or video chunks,
  all in a single argument of IDL union type.

  Caveat: "sequence<A> or sequence<V>" cannot be disambiguated by the
  bindings, so sequence<A or V> is used in this change. Regardless, the
  eventual implementation would need to validate that all in the
  sequence are either A or all are V (along with the usual validation
  that appended chunks or frames also appear to use the most recent
  SourceBufferConfig).

  Caveat: The bindings generator requires help when generated union type
  identifiers are too long for some platforms. This change adds a
  seventh case to the existing hard-coded lists of names that need
  shortening with the generator.

I2P: https://groups.google.com/a/chromium.org/g/blink-dev/c/bejy1nmoWmU/m/CQ90X3j5BQAJ
TAG early-design review request: w3ctag/design-reviews#576
Explainer: https://github.com/wolenetz/mse-for-webcodecs/blob/main/explainer.md
MSE spec bug: w3c/media-source#184

BUG=1144908

Change-Id: Ibc8bd806fe1790ae74fe5ce86865cdfebcdc3096
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2515199
Commit-Queue: Matthew Wolenetz <wolenetz@chromium.org>
Reviewed-by: Dale Curtis <dalecurtis@chromium.org>
Reviewed-by: Kentaro Hara <haraken@chromium.org>
Reviewed-by: Dan Sanders <sandersd@chromium.org>
Reviewed-by: Chrome Cunningham <chcunningham@chromium.org>
Cr-Commit-Position: refs/heads/master@{#830837}
GitOrigin-RevId: 6507c9cc4ae2d08d090d466da71741d8677380cf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chromium-high-priority Something that the Chromium team would like the TAG to prioritise Progress: propose closing we think it should be closed but are waiting on some feedback or consensus Progress: review complete Resolution: satisfied The TAG is satisfied with this design Review type: CG early review An early review of general direction from a Community Group Topic: media Venue: Media WG
Projects
None yet
Development

No branches or pull requests

6 participants