-
Notifications
You must be signed in to change notification settings - Fork 136
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
What should the shape of the API be? #35
Comments
Based on our experience implementing VideoDecoder in Chromium, @chcunningham and I reviewed these options and we are implementing option D.
It still remains to be seen if |
After thinking on this over the weekend, I think option A/C is worth considering further. If we provide a |
Obsolete. See explainer updates (decouple from streams). |
A number of considerations all combine in somewhat complex ways, such as (re)initialization, buffering, failure recovery, and flushing. Obviously we'd like a good API for all of these, but there are tradeoffs between different options. This issue is for tracking the discussion of what we want the API to look like.
Here are some options. Note that it may be possible to have different options for encode and decode. For example, we could do a combination of B for encode and D for decode.
Option A: new Encoder/Decoder for each change
Every time you want to change something that requires (re)initialization, such as changing the codec or resolution, create a new Encoder/Decoder. Also reinit every time a flush is desired.
Pros:
Cons:
Option B: An Initialize() method for each change
If a change requires a reinitialization, call Initialize(), as many times as you want. The .writable and .readable are stable.
Pros:
Cons:
Option C: An Initialize() method that produces a new WritableStream
If a change requires a reinitialization, call Initialize(), as many times as you want. The .readable is stable, but not the .writable (if there is one).
Pros:
Cons:
Option D: In-band parameters
To reinitialize, put new parameters on the chunk passed into the .writable. Init failure is conveyed via a write failure.
Pros:
Cons:
Option E: Internal reinitialization
Instead of asking for an init, just give it what you want and have it (re)init when it needs. There is a fine line between this and Option D. But consider resolution changes. Instead of specifying that the codec reinit with a new size, you just give it whatever frame comes from a MediaStreamTrack and it reinits based on that size. Similarly, an EncodedVideoFrame could simple express what codec it is and the decoder deals with whatever it is.
Pros:
Cons:
The text was updated successfully, but these errors were encountered: