-
Notifications
You must be signed in to change notification settings - Fork 28
Default the generate key frame algorithm to all layers. #276
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
Open
jan-ivar
wants to merge
3
commits into
w3c:main
Choose a base branch
from
jan-ivar:gkfalgo
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+17
−13
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,6 +53,7 @@ spec:webidl; type:dfn; text:resolve | |
</pre> | ||
<pre class=link-defaults> | ||
spec:streams; type:interface; text:ReadableStream | ||
spec:infra; type:dfn; text:list | ||
</pre> | ||
|
||
# Introduction # {#introduction} | ||
|
@@ -1003,32 +1004,35 @@ The <dfn abstract-op>generate key frame algorithm</dfn>, given |promise|, |encod | |
in Section 10 of [[!RFC8851]], then reject |promise| with {{TypeError}} and abort | ||
these steps. | ||
1. [=In parallel=], run the following steps: | ||
1. Gather a list of video encoders, named |videoEncoders| from |encoder|, ordered according negotiated RIDs if any. | ||
1. If |rid| is defined, remove from |videoEncoders| any video encoder that does not match |rid|. | ||
1. If |rid| is undefined, remove from |videoEncoders| all video encoders except the first one. | ||
1. If |videoEncoders| is empty, [=queue a task=] to reject |promise| with {{NotFoundError}} and abort these steps. | ||
|videoEncoders| is expected to be empty if the corresponding {{RTCRtpSender}} is not active, or the corresponding {{RTCRtpSender}} track is ended. | ||
1. Let |videoEncoder| be the first encoder in |videoEncoders|. | ||
1. If |rid| is undefined, set |rid| to the RID value corresponding to |videoEncoder|. | ||
1. Create a pending key frame task called |task| with |task|.`[[rid]]` set to rid and |task|.`[[promise]]`| set to |promise|. | ||
1. Let |layers| be a new [=list=] of the layers for this |encoder|, ordered by negotiated encoding index. | ||
1. Remove from |layers| all layers that are not {{RTCRtpEncodingParameters/active}}, or whose | ||
corresponding {{RTCRtpSender}} track has ended. | ||
1. If |rid| is not undefined, remove from |layers| all layers whose RID is not |rid|. | ||
|
||
Note: If no |rid| is passed in, keyframes are generated for all active layers. | ||
|
||
1. If |layers| is now empty, [=queue a task=] to reject |promise| with {{NotFoundError}} and abort these steps. | ||
1. Create a pending key frame task called |task| with |task|.`[[layers]]` set to |layers| and |task|.`[[promise]]` set to |promise|. | ||
1. If |encoder|.`[[pendingKeyFrameTasks]]` is undefined, initialize |encoder|.`[[pendingKeyFrameTasks]]` to an empty set. | ||
1. Let |shouldTriggerKeyFrame| be <code>false</code> if |encoder|.`[[pendingKeyFrameTasks]]` contains a task whose `[[rid]]` | ||
value is equal to |rid|, and <code>true</code> otherwise. | ||
1. Remove from |layers| all layers already [=list/contained|found=] in any `[[layers]]` of any tasks in |encoder|.`[[pendingKeyFrameTasks]]`. | ||
1. Add |task| to |encoder|.`[[pendingKeyFrameTasks]]`. | ||
1. If |shouldTriggerKeyFrame| is <code>true</code>, instruct |videoEncoder| to generate a key frame for the next provided video frame. | ||
1. For each |layer| in |layers| (if any), instruct |encoder| to generate a key frame for its | ||
next provided video frame to that |layer|. | ||
|
||
For any {{RTCRtpScriptTransformer}} named |transformer|, the following steps are run just before any |frame| is enqueued in |transformer|.`[[readable]]`: | ||
1. Let |encoder| be |transformer|.`[[encoder]]`. | ||
1. If |encoder| or |encoder|.`[[pendingKeyFrameTasks]]` is undefined, abort these steps. | ||
1. If |frame| is not a video {{RTCEncodedVideoFrameType/"key"}} frame, abort these steps. | ||
1. For each |task| in |encoder|.`[[pendingKeyFrameTasks]]`, run the following steps: | ||
1. If |frame| was generated by a video encoder identified by |task|.`[[rid]]`, run the following steps: | ||
1. If |frame| was generated for a layer | ||
[=list/contained=] in |task|.`[[layers]]`, remove that layer from |task|.`[[layers]]`. | ||
If this causes |task|.`[[layers]]` to become empty, then run the following steps: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's resolve the promise as soon as we have a frame, that way, whether there are multiple key frames or just one, it is consistent. |
||
1. Remove |task| from |encoder|.`[[pendingKeyFrameTasks]]`. | ||
1. Resolve |task|.`[[promise]]` with |frame|'s timestamp. | ||
|
||
By resolving the promises just before enqueuing the corresponding key frame in a {{RTCRtpScriptTransformer}}'s readable, | ||
the resolution callbacks of the promises are always executed just before the corresponding key frame is exposed. | ||
If the promise is associated to several rid values, it will be resolved when the first key frame corresponding to one the rid value is enqueued. | ||
If the promise is associated with several layers, it will be resolved once key frames have been enqueued for all of them. | ||
|
||
The <dfn abstract-op>send request key frame algorithm</dfn>, given |promise| and |depacketizer|, is defined by running these steps: | ||
1. If |depacketizer| is undefined, reject |promise| with {{InvalidStateError}}, abort these steps. | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can do that step first before creating the pending key frame task.