From e43c486e7c06f9bff844cfae582fc51980b33806 Mon Sep 17 00:00:00 2001 From: Philipp Hancke Date: Wed, 9 Nov 2022 14:07:51 +0100 Subject: [PATCH 1/3] make generateKeyFrame take a list of rids and return undefined making it request a key frame for each rid or all of them if the list is empty. Returning a promise resolving with a timestamp is not necessary since requesting a key frame is something the encoder might not be able or willing to satisfy. --- index.bs | 52 +++++++++++----------------------------------------- 1 file changed, 11 insertions(+), 41 deletions(-) diff --git a/index.bs b/index.bs index 75dea47..709824e 100644 --- a/index.bs +++ b/index.bs @@ -279,7 +279,7 @@ enum RTCEncodedVideoFrameType { - + @@ -534,7 +534,7 @@ interface RTCRtpScriptTransformer { readonly attribute ReadableStream readable; readonly attribute WritableStream writable; readonly attribute any options; - Promise<unsigned long long> generateKeyFrame(optional DOMString rid); + undefined generateKeyFrame(optional sequence<DOMString> rids); Promise<undefined> sendKeyFrameRequest(); }; @@ -575,10 +575,8 @@ Each RTCRtpScriptTransform has the following set of [=association steps=], given 1. Set |transformer|.`[[encoder]]` to |encoder|. 1. Set |transformer|.`[[depacketizer]]` to |depacketizer|. -The generateKeyFrame(|rid|) method steps are: -1. Let |promise| be a new promise. -1. Run the [=generate key frame algorithm=] with |promise|, |this|.`[[encoder]]` and |rid|. -1. Return |promise|. +The generateKeyFrame(|rids|) method steps are: +1. Run the [=generate key frame algorithm=] with the {{RTCRtpSender}} associated with |this|.`[[encoder]]` and |rids|. The sendKeyFrameRequest() method steps are: 1. Let |promise| be a new promise. @@ -602,37 +600,11 @@ The writable getter steps are ## KeyFrame Algorithms ## {#KeyFrame-algorithms} -The generate key frame algorithm, given |promise|, |encoder| and |rid|, is defined by running these steps: -1. If |encoder| is undefined, reject |promise| with {{InvalidStateError}}, abort these steps. -1. If |encoder| is not processing video frames, reject |promise| with {{InvalidStateError}}, abort these steps. -1. If |rid| is defined, validate its value. If invalid, reject |promise| with {{NotAllowedError}} 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. If |videoEncoders| is empty, 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|. - 1. If |encoder|.`[[pendingKeyFrameTasks]]` is undefined, initialize |encoder|.`[[pendingKeyFrameTasks]]` to an empty set. - 1. Let |shouldTriggerKeyFrame| be true if |encoder|.`[[pendingKeyFrameTasks]]` contains a task whose `[[rid]]` - value is equal to |rid|, and false otherwise. - 1. Add |task| to |encoder|.`[[pendingKeyFrameTasks]]`. - 1. If |shouldTriggerKeyFrame| is true, instruct |videoEncoder| to generate a key frame for the 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. Remove |task| from |encoder|.`[[pendingKeyFrameTasks]]`. - 1. Resolve |task|.`[[promise]]` with |frame|'s timestamp. - -By resolving the promises just before enqueuing the corresponding key frame in a {{RTCRtpScriptTransformer}}'s readable, -the resolution callbacks of the promises are always executed just before the corresponding key frame is exposed. -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. +The generate key frame algorithm, given |sender| and |rids|, is defined by running these steps: +1. If the sender's transceiver kind is not `video`, return an {{OperationError}} and abort these steps. +1. If |rids| is defined, for each |rid| in rids, + 1. if |rid| is not associated with |sender|, return an {{InvalidAccessError}} and abort these steps. +1. Instruct the encoder associated with |sender| to generate a key frame for |rids| or all layers when |rids| is empty. The send request key frame algorithm, given |promise| and |depacketizer|, is defined by running these steps: 1. If |depacketizer| is undefined, reject |promise| with {{InvalidStateError}}, abort these steps. @@ -649,7 +621,7 @@ An additional API on {{RTCRtpSender}} is added to complement the generation of k
 partial interface RTCRtpSender {
-    Promise<undefined> generateKeyFrame(optional sequence <DOMString> rids);
+    undefined generateKeyFrame(optional sequence<DOMString> rids);
 };
 
@@ -657,9 +629,7 @@ partial interface RTCRtpSender { The generateKeyFrame(|rids|) method steps are: -1. Let |promise| be a new promise. -1. [=In parallel=], run the [=generate key frame algorithm=] with |promise|, |this|'s encoder and |rids|. -1. Return |promise|. +1. Run the [=generate key frame algorithm=] with |this| and |rids|. # Privacy and security considerations # {#privacy} From 0c676389beb1693c484e5ffaae5d9b282f5c6f51 Mon Sep 17 00:00:00 2001 From: Philipp Hancke Date: Tue, 13 Dec 2022 09:58:22 +0100 Subject: [PATCH 2/3] return a promise --- index.bs | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/index.bs b/index.bs index 709824e..a7d2f2b 100644 --- a/index.bs +++ b/index.bs @@ -534,7 +534,7 @@ interface RTCRtpScriptTransformer { readonly attribute ReadableStream readable; readonly attribute WritableStream writable; readonly attribute any options; - undefined generateKeyFrame(optional sequence<DOMString> rids); + Promise<undefined> generateKeyFrame(optional sequence<DOMString> rids); Promise<undefined> sendKeyFrameRequest(); }; @@ -576,7 +576,9 @@ Each RTCRtpScriptTransform has the following set of [=association steps=], given 1. Set |transformer|.`[[depacketizer]]` to |depacketizer|. The generateKeyFrame(|rids|) method steps are: -1. Run the [=generate key frame algorithm=] with the {{RTCRtpSender}} associated with |this|.`[[encoder]]` and |rids|. +1. Let |promise| be a new promise. +1. Run the [=generate key frame algorithm=] with |promise|, the {{RTCRtpSender}} associated with |this|.`[[encoder]]` and |rids|. +1. Return |promise|. The sendKeyFrameRequest() method steps are: 1. Let |promise| be a new promise. @@ -600,11 +602,12 @@ The writable getter steps are ## KeyFrame Algorithms ## {#KeyFrame-algorithms} -The generate key frame algorithm, given |sender| and |rids|, is defined by running these steps: -1. If the sender's transceiver kind is not `video`, return an {{OperationError}} and abort these steps. +The generate key frame algorithm, given |promise|, |sender| and |rids|, is defined by running these steps: +1. If the sender's transceiver kind is not `video`, reject |promise| with an {{OperationError}} and abort these steps. 1. If |rids| is defined, for each |rid| in rids, - 1. if |rid| is not associated with |sender|, return an {{InvalidAccessError}} and abort these steps. + 1. if |rid| is not associated with |sender|, reject Promise with an {{InvalidAccessError}} and abort these steps. 1. Instruct the encoder associated with |sender| to generate a key frame for |rids| or all layers when |rids| is empty. +1. Resolve |promise| with `undefined`. The send request key frame algorithm, given |promise| and |depacketizer|, is defined by running these steps: 1. If |depacketizer| is undefined, reject |promise| with {{InvalidStateError}}, abort these steps. @@ -621,7 +624,7 @@ An additional API on {{RTCRtpSender}} is added to complement the generation of k
 partial interface RTCRtpSender {
-    undefined generateKeyFrame(optional sequence<DOMString> rids);
+    Promise<undefined> generateKeyFrame(optional sequence<DOMString> rids);
 };
 
@@ -629,7 +632,9 @@ partial interface RTCRtpSender { The generateKeyFrame(|rids|) method steps are: -1. Run the [=generate key frame algorithm=] with |this| and |rids|. +1. Let |promise| be a new promise. +1. Run the [=generate key frame algorithm=] with |promise|, |this| and |rids|. +1. Return |promise|. # Privacy and security considerations # {#privacy} From 0b22d779db95d12e6b69a620b2072afc0931f94e Mon Sep 17 00:00:00 2001 From: Philipp Hancke Date: Tue, 10 Jan 2023 11:52:28 +0100 Subject: [PATCH 3/3] in parallel... --- index.bs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/index.bs b/index.bs index a7d2f2b..cf46ccd 100644 --- a/index.bs +++ b/index.bs @@ -577,12 +577,12 @@ Each RTCRtpScriptTransform has the following set of [=association steps=], given The generateKeyFrame(|rids|) method steps are: 1. Let |promise| be a new promise. -1. Run the [=generate key frame algorithm=] with |promise|, the {{RTCRtpSender}} associated with |this|.`[[encoder]]` and |rids|. +1. [=In parallel=], run the [=generate key frame algorithm=] with |promise|, the {{RTCRtpSender}} associated with |this|.`[[encoder]]` and |rids|. 1. Return |promise|. The sendKeyFrameRequest() method steps are: 1. Let |promise| be a new promise. -1. Run the [=send request key frame algorithm=] with |promise| and |this|.`[[depacketizer]]`. +1. [=In parallel=], run the [=send request key frame algorithm=] with |promise| and |this|.`[[depacketizer]]`. 1. Return |promise|. ## Attributes ## {#RTCRtpScriptTransformer-attributes} @@ -633,7 +633,7 @@ partial interface RTCRtpSender { The generateKeyFrame(|rids|) method steps are: 1. Let |promise| be a new promise. -1. Run the [=generate key frame algorithm=] with |promise|, |this| and |rids|. +1. [=In parallel=], run the [=generate key frame algorithm=] with |promise|, |this| and |rids|. 1. Return |promise|. # Privacy and security considerations # {#privacy}
Enumeration descriptionEnumeration description
Enum valueDescription