Skip to content

Commit e43c486

Browse files
committed
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.
1 parent c85fc84 commit e43c486

File tree

1 file changed

+11
-41
lines changed

1 file changed

+11
-41
lines changed

index.bs

+11-41
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ enum RTCEncodedVideoFrameType {
279279
</pre>
280280
<table data-link-for="RTCEncodedVideoFrameType" data-dfn-for=
281281
"RTCEncodedVideoFrameType" class="simple">
282-
<caption>Enumeration description</caption>
282+
<caption>Enumeration description</caption>
283283
<thead>
284284
<tr>
285285
<th>Enum value</th><th>Description</th>
@@ -534,7 +534,7 @@ interface RTCRtpScriptTransformer {
534534
readonly attribute ReadableStream readable;
535535
readonly attribute WritableStream writable;
536536
readonly attribute any options;
537-
Promise&lt;unsigned long long&gt; generateKeyFrame(optional DOMString rid);
537+
undefined generateKeyFrame(optional sequence&lt;DOMString&gt; rids);
538538
Promise&lt;undefined&gt; sendKeyFrameRequest();
539539
};
540540

@@ -575,10 +575,8 @@ Each RTCRtpScriptTransform has the following set of [=association steps=], given
575575
1. Set |transformer|.`[[encoder]]` to |encoder|.
576576
1. Set |transformer|.`[[depacketizer]]` to |depacketizer|.
577577

578-
The <dfn method for="RTCRtpScriptTransformer">generateKeyFrame(|rid|)</dfn> method steps are:
579-
1. Let |promise| be a new promise.
580-
1. Run the [=generate key frame algorithm=] with |promise|, |this|.`[[encoder]]` and |rid|.
581-
1. Return |promise|.
578+
The <dfn method for="RTCRtpScriptTransformer">generateKeyFrame(|rids|)</dfn> method steps are:
579+
1. Run the [=generate key frame algorithm=] with the {{RTCRtpSender}} associated with |this|.`[[encoder]]` and |rids|.
582580

583581
The <dfn method for="RTCRtpScriptTransformer">sendKeyFrameRequest()</dfn> method steps are:
584582
1. Let |promise| be a new promise.
@@ -602,37 +600,11 @@ The <dfn attribute for="RTCRtpScriptTransformer">writable</dfn> getter steps are
602600

603601
## KeyFrame Algorithms ## {#KeyFrame-algorithms}
604602

605-
The <dfn>generate key frame algorithm</dfn>, given |promise|, |encoder| and |rid|, is defined by running these steps:
606-
1. If |encoder| is undefined, reject |promise| with {{InvalidStateError}}, abort these steps.
607-
1. If |encoder| is not processing video frames, reject |promise| with {{InvalidStateError}}, abort these steps.
608-
1. If |rid| is defined, validate its value. If invalid, reject |promise| with {{NotAllowedError}} and abort these steps.
609-
1. [=In parallel=], run the following steps:
610-
1. Gather a list of video encoders, named |videoEncoders| from |encoder|, ordered according negotiated RIDs if any.
611-
1. If |rid| is defined, remove from |videoEncoders| any video encoder that does not match |rid|.
612-
1. If |rid| is undefined, remove from |videoEncoders| all video encoders except the first one.
613-
1. If |videoEncoders| is empty, reject |promise| with {{NotFoundError}} and abort these steps.
614-
|videoEncoders| is expected to be empty if the corresponding {{RTCRtpSender}} is not active, or the corresponding {{RTCRtpSender}} track is ended.
615-
1. Let |videoEncoder| be the first encoder in |videoEncoders|.
616-
1. If |rid| is undefined, set |rid| to the RID value corresponding to |videoEncoder|.
617-
1. Create a pending key frame task called |task| with |task|.`[[rid]]` set to rid and |task|.`[[promise]]`| set to |promise|.
618-
1. If |encoder|.`[[pendingKeyFrameTasks]]` is undefined, initialize |encoder|.`[[pendingKeyFrameTasks]]` to an empty set.
619-
1. Let |shouldTriggerKeyFrame| be <code>true</code> if |encoder|.`[[pendingKeyFrameTasks]]` contains a task whose `[[rid]]`
620-
value is equal to |rid|, and <code>false</code> otherwise.
621-
1. Add |task| to |encoder|.`[[pendingKeyFrameTasks]]`.
622-
1. If |shouldTriggerKeyFrame| is <code>true</code>, instruct |videoEncoder| to generate a key frame for the next provided video frame.
623-
624-
For any {{RTCRtpScriptTransformer}} named |transformer|, the following steps are run just before any |frame| is enqueued in |transformer|.`[[readable]]`:
625-
1. Let |encoder| be |transformer|.`[[encoder]]`.
626-
1. If |encoder| or |encoder|.`[[pendingKeyFrameTasks]]` is undefined, abort these steps.
627-
1. If |frame| is not a video {{RTCEncodedVideoFrameType/"key"}} frame, abort these steps.
628-
1. For each |task| in |encoder|.`[[pendingKeyFrameTasks]]`, run the following steps:
629-
1. If |frame| was generated by a video encoder identified by |task|.`[[rid]]`, run the following steps:
630-
1. Remove |task| from |encoder|.`[[pendingKeyFrameTasks]]`.
631-
1. Resolve |task|.`[[promise]]` with |frame|'s timestamp.
632-
633-
By resolving the promises just before enqueuing the corresponding key frame in a {{RTCRtpScriptTransformer}}'s readable,
634-
the resolution callbacks of the promises are always executed just before the corresponding key frame is exposed.
635-
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.
603+
The <dfn>generate key frame algorithm</dfn>, given |sender| and |rids|, is defined by running these steps:
604+
1. If the sender's transceiver kind is not `video`, return an {{OperationError}} and abort these steps.
605+
1. If |rids| is defined, for each |rid| in rids,
606+
1. if |rid| is not associated with |sender|, return an {{InvalidAccessError}} and abort these steps.
607+
1. Instruct the encoder associated with |sender| to generate a key frame for |rids| or all layers when |rids| is empty.
636608

637609
The <dfn>send request key frame algorithm</dfn>, given |promise| and |depacketizer|, is defined by running these steps:
638610
1. If |depacketizer| is undefined, reject |promise| with {{InvalidStateError}}, abort these steps.
@@ -649,17 +621,15 @@ An additional API on {{RTCRtpSender}} is added to complement the generation of k
649621

650622
<pre class="idl">
651623
partial interface RTCRtpSender {
652-
Promise&lt;undefined&gt; generateKeyFrame(optional sequence &lt;DOMString&gt; rids);
624+
undefined generateKeyFrame(optional sequence&lt;DOMString&gt; rids);
653625
};
654626
</pre>
655627

656628
## Extension operation ## {#sender-operation}
657629

658630
The <dfn method for="RTCRtpSender">generateKeyFrame(|rids|)</dfn> method steps are:
659631

660-
1. Let |promise| be a new promise.
661-
1. [=In parallel=], run the [=generate key frame algorithm=] with |promise|, |this|'s encoder and |rids|.
662-
1. Return |promise|.
632+
1. Run the [=generate key frame algorithm=] with |this| and |rids|.
663633

664634
# Privacy and security considerations # {#privacy}
665635

0 commit comments

Comments
 (0)