Skip to content

Commit 60b6c4a

Browse files
committed
Rework algorithm to function sans rids as well
1 parent fc9355e commit 60b6c4a

File tree

1 file changed

+15
-24
lines changed

1 file changed

+15
-24
lines changed

index.bs

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ spec:webidl; type:dfn; text:resolve
5353
</pre>
5454
<pre class=link-defaults>
5555
spec:streams; type:interface; text:ReadableStream
56+
spec:infra; type:dfn; text:list
5657
</pre>
5758

5859
# Introduction # {#introduction}
@@ -1003,45 +1004,35 @@ The <dfn abstract-op>generate key frame algorithm</dfn>, given |promise|, |encod
10031004
in Section 10 of [[!RFC8851]], then reject |promise| with {{TypeError}} and abort
10041005
these steps.
10051006
1. [=In parallel=], run the following steps:
1006-
1. Let |videoEncoders| be a list of video encoders from |encoder|, ordered according to their negotiated RIDs if any.
1007-
1. Let |allRids| be the list of rids from |videoEncoders|, using `null` in place of any missing rids.
1008-
1. Assert that |allRids| either [=list/contains=] no `null` values or a single entry that is `null`.
1007+
1. Let |layers| be a new [=list=] of the layers for this |encoder|, ordered by negotiated encoding index.
1008+
1. Remove from |layers| all layers that are not {{RTCRtpEncodingParameters/active}}, or whose
1009+
corresponding {{RTCRtpSender}} track has ended.
1010+
1. If |rid| is not undefined, remove from |layers| all layers whose rid is not |rid|.
10091011

1010-
Note: This algorithm internally uses `null` to identify the single video encoder in unicast.
1012+
Note: If no |rid| is passed in, keyframes are generated for all active layers.
10111013

1012-
1. If |rid| is not undefined, remove from |videoEncoders| any video encoder that does not match |rid|.
1013-
1014-
Note: If no |rid| is passed in, keyframes are generated for all layers.
1015-
1016-
1. If |videoEncoders| is empty, [=queue a task=] to reject |promise| with {{NotFoundError}} and abort these steps.
1017-
1018-
Note: |videoEncoders| is expected to be empty if the corresponding {{RTCRtpSender}} encoding is not
1019-
{{RTCRtpEncodingParameters/active}}, or the corresponding {{RTCRtpSender}} track is ended.
1020-
1021-
1. Let |rids| be [|rid|] if |rid| is not undefined, or |allRids| otherwise.
1022-
1. Create a pending key frame task called |task| with |task|.`[[rids]]` set to |rids| and |task|.`[[promise]]` set to |promise|.
1014+
1. If |layers| is now empty, [=queue a task=] to reject |promise| with {{NotFoundError}} and abort these steps.
1015+
1. Create a pending key frame task called |task| with |task|.`[[layers]]` set to |layers| and |task|.`[[promise]]` set to |promise|.
10231016
1. If |encoder|.`[[pendingKeyFrameTasks]]` is undefined, initialize |encoder|.`[[pendingKeyFrameTasks]]` to an empty set.
1024-
1. Remove from |videoEncoders| any video encoder whose identifying |rid| (or `null` value if it has no rid)
1025-
already [=list/contained|exists=] in any `[[rids]]` of any tasks in |encoder|.`[[pendingKeyFrameTasks]]`.
1017+
1. Remove from |layers| all layers already [=list/contained|found=] in any `[[layers]]` of any tasks in |encoder|.`[[pendingKeyFrameTasks]]`.
10261018
1. Add |task| to |encoder|.`[[pendingKeyFrameTasks]]`.
1027-
1. For each |videoEncoder| in |videoEncoders| (if any), instruct |videoEncoder| to generate a key frame for its
1028-
next provided video frame.
1019+
1. For each |layer| in |layers| (if any), instruct |encoder| to generate a key frame for its
1020+
next provided video frame to that |layer|.
10291021

10301022
For any {{RTCRtpScriptTransformer}} named |transformer|, the following steps are run just before any |frame| is enqueued in |transformer|.`[[readable]]`:
10311023
1. Let |encoder| be |transformer|.`[[encoder]]`.
10321024
1. If |encoder| or |encoder|.`[[pendingKeyFrameTasks]]` is undefined, abort these steps.
10331025
1. If |frame| is not a video {{RTCEncodedVideoFrameType/"key"}} frame, abort these steps.
10341026
1. For each |task| in |encoder|.`[[pendingKeyFrameTasks]]`, run the following steps:
1035-
1. If |frame| was generated by a video encoder identified by a value
1036-
[=list/contained=] in |task|.`[[rids]]`, and this brings to zero the number of
1037-
video encoders identified in |task|.`[[rids]]` that still haven't finished
1038-
generating its keyframe, then run the following steps:
1027+
1. If |frame| was generated for a layer
1028+
[=list/contained=] in |task|.`[[layers]]`, remove that layer from |task|.`[[layers]]`.
1029+
If this causes |task|.`[[layers]]` to become empty, then run the following steps:
10391030
1. Remove |task| from |encoder|.`[[pendingKeyFrameTasks]]`.
10401031
1. Resolve |task|.`[[promise]]` with |frame|'s timestamp.
10411032

10421033
By resolving the promises just before enqueuing the corresponding key frame in a {{RTCRtpScriptTransformer}}'s readable,
10431034
the resolution callbacks of the promises are always executed just before the corresponding key frame is exposed.
1044-
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.
1035+
If the promise is associated with several layers, it will be resolved once key frames have been enqueued for all of them.
10451036

10461037
The <dfn abstract-op>send request key frame algorithm</dfn>, given |promise| and |depacketizer|, is defined by running these steps:
10471038
1. If |depacketizer| is undefined, reject |promise| with {{InvalidStateError}}, abort these steps.

0 commit comments

Comments
 (0)