Skip to content

Commit 45066af

Browse files
authored
Default the generate key frame algorithm to all layers. (#276)
* Default the generate key frame algorithm to all layers and use infra more
1 parent c181f8b commit 45066af

File tree

1 file changed

+21
-16
lines changed

1 file changed

+21
-16
lines changed

index.bs

Lines changed: 21 additions & 16 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}
@@ -1028,32 +1029,36 @@ The <dfn abstract-op>generate key frame algorithm</dfn>, given |promise|, |encod
10281029
in Section 10 of [[!RFC8851]], then reject |promise| with {{TypeError}} and abort
10291030
these steps.
10301031
1. [=In parallel=], run the following steps:
1031-
1. Gather a list of video encoders, named |videoEncoders| from |encoder|, ordered according negotiated RIDs if any.
1032-
1. If |rid| is defined, remove from |videoEncoders| any video encoder that does not match |rid|.
1033-
1. If |rid| is undefined, remove from |videoEncoders| all video encoders except the first one.
1034-
1. If |videoEncoders| is empty, [=queue a task=] to reject |promise| with {{NotFoundError}} and abort these steps.
1035-
|videoEncoders| is expected to be empty if the corresponding {{RTCRtpSender}} is not active, or the corresponding {{RTCRtpSender}} track is ended.
1036-
1. Let |videoEncoder| be the first encoder in |videoEncoders|.
1037-
1. If |rid| is undefined, set |rid| to the RID value corresponding to |videoEncoder|.
1038-
1. Create a pending key frame task called |task| with |task|.`[[rid]]` set to rid and |task|.`[[promise]]`| set to |promise|.
1032+
1. Let |layers| be a new [=list=] of the layers for this |encoder|, ordered by negotiated encoding index.
1033+
1. [=list/Remove=] from |layers| all layers that are not {{RTCRtpEncodingParameters/active}}, or whose
1034+
corresponding {{RTCRtpSender}} track has ended.
1035+
1. If |rid| is not undefined, [=list/remove=] from |layers| all layers whose RID is not |rid|.
1036+
1037+
Note: If no |rid| is passed in, keyframes are generated for all active layers.
1038+
1039+
1. If |layers| is now empty, [=queue a task=] to reject |promise| with {{NotFoundError}} and abort these steps.
1040+
1. [=list/Remove=] from |layers| all layers already [=list/contained|found=] in any `[[layers]]` of any tasks in |encoder|.`[[pendingKeyFrameTasks]]`.
1041+
1. Create a pending key frame task called |task| with |task|.`[[layers]]` set to |layers| and |task|.`[[promise]]` set to |promise|.
10391042
1. If |encoder|.`[[pendingKeyFrameTasks]]` is undefined, initialize |encoder|.`[[pendingKeyFrameTasks]]` to an empty set.
1040-
1. Let |shouldTriggerKeyFrame| be <code>false</code> if |encoder|.`[[pendingKeyFrameTasks]]` contains a task whose `[[rid]]`
1041-
value is equal to |rid|, and <code>true</code> otherwise.
1042-
1. Add |task| to |encoder|.`[[pendingKeyFrameTasks]]`.
1043-
1. If |shouldTriggerKeyFrame| is <code>true</code>, instruct |videoEncoder| to generate a key frame for the next provided video frame.
1043+
1. [=set/Append=] |task| to |encoder|.`[[pendingKeyFrameTasks]]`.
1044+
1. For each |layer| in |layers| (if any), instruct |encoder| to generate a key frame for its
1045+
next provided video frame to that |layer|.
10441046

10451047
For any {{RTCRtpScriptTransformer}} named |transformer|, the following steps are run just before any |frame| is enqueued in |transformer|.`[[readable]]`:
10461048
1. Let |encoder| be |transformer|.`[[encoder]]`.
10471049
1. If |encoder| or |encoder|.`[[pendingKeyFrameTasks]]` is undefined, abort these steps.
10481050
1. If |frame| is not a video {{RTCEncodedVideoFrameType/"key"}} frame, abort these steps.
10491051
1. For each |task| in |encoder|.`[[pendingKeyFrameTasks]]`, run the following steps:
1050-
1. If |frame| was generated by a video encoder identified by |task|.`[[rid]]`, run the following steps:
1051-
1. Remove |task| from |encoder|.`[[pendingKeyFrameTasks]]`.
1052-
1. Resolve |task|.`[[promise]]` with undefined.
1052+
1. If |frame| was generated for a layer [=list/contained=] in |task|.`[[layers]]`,
1053+
then run the following steps:
1054+
1. [=list/Remove=] that layer from |task|.`[[layers]]`.
1055+
1. If |task|.`[[layers]]` is now empty, then [=list/remove=] |task| from
1056+
|encoder|.`[[pendingKeyFrameTasks]]`.
1057+
1. [=Resolve=] |task|.`[[promise]]` with undefined.
10531058

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

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

0 commit comments

Comments
 (0)