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
@@ -411,21 +411,40 @@ The <dfn>generate key frame algorithm</dfn>, given |promise|, |encoder| and |rid
411
411
1. If |encoder| is not processing video frames, reject |promise| with {{InvalidStateError}}, abort these steps.
412
412
1. If |rids| is defined, validate each of the RID values in |rids|.
413
413
If any RID value is invalid, reject |promise| with {{NotAllowedError}} and abort these steps.
414
-
1. Gather a list of video encoders, named |videoEncoders| from |encoder|.
415
-
1. If |rids| is not empty, remove from |videoEncoders| any video encoder that does not match a value in |rids|.
416
-
1. If |videoEncoders| is empty, reject |promise| with {{NotFoundError}} and abort these steps.
417
-
|videoEncoders| is expected to be empty if the corresponding {{RTCRtpSender}} is not active, or the corresponding {{RTCRtpSender}} track is ended.
418
-
1. For each |videoEncoder| in |videoEncoders|, instruct |videoEncoder| to generate a key frame for the next provided video frame.
419
-
1. Wait until a new video frame is provided to each |videoEncoder| in |videoEncoders|.
420
-
1. [=Resolve=] |promise| with undefined.
414
+
1. [=In parallel=], run the following steps:
415
+
1. Gather a list of video encoders, named |videoEncoders| from |encoder|.
416
+
1. If |rids| is not empty, remove from |videoEncoders| any video encoder that does not match a value in |rids|.
417
+
1. If |videoEncoders| is empty, reject |promise| with {{NotFoundError}} and abort these steps.
418
+
|videoEncoders| is expected to be empty if the corresponding {{RTCRtpSender}} is not active, or the corresponding {{RTCRtpSender}} track is ended.
419
+
1. For each |rid| in |rids|, run the following substeps:
420
+
1. Create a pending key frame task called |task| with ||task|.`[[rid]]` set to rid and |task|.`[[promise]]`| set to |promise|.
421
+
1. If |encoder|.`[[pendingKeyFrameTasks]]` is undefined, initialize |encoder|.`[[pendingKeyFrameTasks]]` to an empty set.
422
+
1. If |encoder|.`[[pendingKeyFrameTasks]]` contains a task which is matching |rid|, remove |rid| from |rids|.
423
+
1. Add |task| to |encoder|.`[[pendingKeyFrameTasks]]`.
424
+
1. If |rids| is not empty, remove from |videoEncoders| any video encoder that does not match a value in |rids|.
425
+
1. For each |videoEncoder| in |videoEncoders|, instruct |videoEncoder| to generate a key frame for the next provided video frame.
426
+
427
+
For any {{RTCRtpScriptTransformer}} named |transformer|, the following steps are run just before any |frame| is enqueued in |transformer|.`[[readable]]`:
428
+
1. Let |encoder| be |transformer|.`[[encoder]]`.
429
+
1. If |encoder| or |encoder|.`[[pendingKeyFrameTasks]]` is undefined, abort these steps.
430
+
1. If |frame| is not a video key frame, abort these steps.
431
+
1. For each |task| in |encoder|.`[[pendingKeyFrameTasks]]`, run the following steps:
432
+
1. If |frame| was generated by a video encoder identified by |task|.`[[rid]]`, run the following steps:
433
+
1. Remove |task| from |encoder|.`[[pendingKeyFrameTasks]]`.
434
+
1. Resolve |task|.`[[promise]]` with undefined.
435
+
436
+
By resolving the promises just before enqueuing the corresponding key frame in a {{RTCRtpScriptTransformer}}'s readable,
437
+
the resolution callbacks of the promises are always executed just before the corresponding key frame is exposed.
438
+
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.
421
439
422
440
The <dfn>send request key frame algorithm</dfn>, given |promise| and |depacketizer|, is defined by running these steps:
423
441
1. If |depacketizer| is undefined, reject |promise| with {{InvalidStateError}}, abort these steps.
424
442
1. If |depacketizer| is not processing video packets, reject |promise| with {{InvalidStateError}}, abort these steps.
425
-
1. If sending a Full Intra Request (FIR) by |depacketizer|'s receiver is not deemed appropriate, [=resolve=] |promise| with undefined and abort these steps.
426
-
Section 4.3.1 of [[RFC5104]] provides guidelines of how and when it is appropriate to sending a Full Intra Request.
427
-
1. Generate a Full Intra Request (FIR) packet as defined in section 4.3.1 of [[RFC5104]] and send it through |depacketizer|'s receiver.
428
-
1. [=Resolve=] |promise| with undefined.
443
+
1. [=In parallel=], run the following steps:
444
+
1. If sending a Full Intra Request (FIR) by |depacketizer|'s receiver is not deemed appropriate, [=resolve=] |promise| with undefined and abort these steps.
445
+
Section 4.3.1 of [[RFC5104]] provides guidelines of how and when it is appropriate to sending a Full Intra Request.
446
+
1. Generate a Full Intra Request (FIR) packet as defined in section 4.3.1 of [[RFC5104]] and send it through |depacketizer|'s receiver.
0 commit comments