You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -1028,32 +1029,36 @@ The <dfn abstract-op>generate key frame algorithm</dfn>, given |promise|, |encod
1028
1029
in Section 10 of [[!RFC8851]], then reject |promise| with {{TypeError}} and abort
1029
1030
these steps.
1030
1031
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|.
1039
1042
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|.
1044
1046
1045
1047
For any {{RTCRtpScriptTransformer}} named |transformer|, the following steps are run just before any |frame| is enqueued in |transformer|.`[[readable]]`:
1046
1048
1. Let |encoder| be |transformer|.`[[encoder]]`.
1047
1049
1. If |encoder| or |encoder|.`[[pendingKeyFrameTasks]]` is undefined, abort these steps.
1048
1050
1. If |frame| is not a video {{RTCEncodedVideoFrameType/"key"}} frame, abort these steps.
1049
1051
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.
1053
1058
1054
1059
By resolving the promises just before enqueuing the corresponding key frame in a {{RTCRtpScriptTransformer}}'s readable,
1055
1060
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.
1057
1062
1058
1063
The <dfn abstract-op>send request key frame algorithm</dfn>, given |promise| and |depacketizer|, is defined by running these steps:
1059
1064
1. If |depacketizer| is undefined, reject |promise| with {{InvalidStateError}}, abort these steps.
0 commit comments