Skip to content

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
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 24 additions & 11 deletions index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -1003,26 +1003,39 @@ 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. Let |videoEncoders| be a list of video encoders from |encoder|, ordered according to their negotiated RIDs if any.
1. Let |allRids| be the list of rids from |videoEncoders|, using `null` in place of any missing rids.
1. Assert that |allRids| either [=list/contains=] no `null` values or a single entry that is `null`.

Note: This algorithm internally uses `null` to identify the single video encoder in unicast.

1. If |rid| is not undefined, remove from |videoEncoders| any video encoder that does not match |rid|.

Note: If no |rid| is passed in, keyframes are generated for all layers.

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|.

Note: |videoEncoders| is expected to be empty if the corresponding {{RTCRtpSender}} encoding is not
{{RTCRtpEncodingParameters/active}}, or the corresponding {{RTCRtpSender}} track is ended.

1. Let |rids| be [|rid|] if |rid| is not undefined, or |allRids| otherwise.
1. Create a pending key frame task called |task| with |task|.`[[rids]]` set to |rids| 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 |videoEncoders| any video encoder whose identifying |rid| (or `null` value if it has no rid)
already [=list/contained|exists=] in any `[[rids]]` 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 |videoEncoder| in |videoEncoders| (if any), instruct |videoEncoder| to generate a key frame for its
next provided video frame.

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 by a video encoder identified by a value
[=list/contained=] in |task|.`[[rids]]`, and this brings to zero the number of
video encoders identified in |task|.`[[rids]]` that still haven't finished
generating its keyframe, then run the following steps:
1. Remove |task| from |encoder|.`[[pendingKeyFrameTasks]]`.
1. Resolve |task|.`[[promise]]` with |frame|'s timestamp.

Expand Down