Skip to content

Commit 678a265

Browse files
authored
Merge pull request #215 from w3c/keyframe-api
Add an API for a "keyframe has been requested" event
2 parents 12fa1cd + 0079fa4 commit 678a265

File tree

1 file changed

+39
-7
lines changed

1 file changed

+39
-7
lines changed

index.bs

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -750,18 +750,28 @@ partial interface DedicatedWorkerGlobalScope {
750750
};
751751

752752
[Exposed=DedicatedWorker]
753-
interface RTCRtpScriptTransformer {
753+
interface RTCRtpScriptTransformer : EventTarget {
754+
// Attributes and methods related to the transformer source
754755
readonly attribute ReadableStream readable;
755-
readonly attribute WritableStream writable;
756-
readonly attribute any options;
757756
Promise<unsigned long long> generateKeyFrame(optional DOMString rid);
758757
Promise<undefined> sendKeyFrameRequest();
758+
// Attributes and methods related to the transformer sink
759+
readonly attribute WritableStream writable;
760+
attribute EventHandler onkeyframerequest;
761+
// Attributes for configuring the Javascript code
762+
readonly attribute any options;
759763
};
760764

761765
[Exposed=Window]
762766
interface RTCRtpScriptTransform {
763767
constructor(Worker worker, optional any options, optional sequence<object> transfer);
764768
};
769+
770+
[Exposed=DedicatedWorker]
771+
interface KeyFrameRequestEvent : Event {
772+
constructor(DOMString type, optional DOMString rid);
773+
readonly attribute DOMString? rid;
774+
};
765775
</pre>
766776

767777
## Operations ## {#RTCRtpScriptTransform-operations}
@@ -795,12 +805,12 @@ Each RTCRtpScriptTransform has the following set of [$association steps$], given
795805
1. Set |transformer|.`[[encoder]]` to |encoder|.
796806
1. Set |transformer|.`[[depacketizer]]` to |depacketizer|.
797807

798-
The <dfn method for="RTCRtpScriptTransformer">generateKeyFrame(|rid|)</dfn> method steps are:
808+
The <dfn method for="RTCRtpScriptTransform">generateKeyFrame(|rid|)</dfn> method steps are:
799809
1. Let |promise| be a new promise.
800810
1. Run the [$generate key frame algorithm$] with |promise|, |this|.`[[encoder]]` and |rid|.
801811
1. Return |promise|.
802812

803-
The <dfn method for="RTCRtpScriptTransformer">sendKeyFrameRequest()</dfn> method steps are:
813+
The <dfn method for="RTCRtpScriptTransform">sendKeyFrameRequest()</dfn> method steps are:
804814
1. Let |promise| be a new promise.
805815
1. Run the [$send request key frame algorithm$] with |promise| and |this|.`[[depacketizer]]`.
806816
1. Return |promise|.
@@ -814,12 +824,34 @@ This allows algorithms to go from an {{RTCRtpScriptTransformer}} object to its {
814824
The <dfn attribute for="RTCRtpScriptTransformer">options</dfn> getter steps are:
815825
1. Return [=this=].`[[options]]`.
816826

817-
The <dfn attribute for="RTCRtpScriptTransformer">readable</dfn> getter steps are:
827+
The <dfn attribute for="RTCRtpScriptTransform">readable</dfn> getter steps are:
818828
1. Return [=this=].`[[readable]]`.
819829

820-
The <dfn attribute for="RTCRtpScriptTransformer">writable</dfn> getter steps are:
830+
The <dfn attribute for="RTCRtpScriptTransform">writable</dfn> getter steps are:
821831
1. Return [=this=].`[[writable]]`.
822832

833+
The <dfn attribute for="RTCRtpScriptTransform">onbandwidthestimate</dfn> EventHandler has type bandwidthestimate.
834+
835+
The <dfn attribute for="RTCRtpScriptTransform">onkeyframerequest</dfn> EventHandler has type keyframerequest.
836+
837+
## Events ## {#RTCRtpScriptTransformer-events}
838+
839+
The following event fires on an {{RTCRtpScriptTransformer}}:
840+
841+
* keyframerequest of type {{KeyFrameRequestEvent}} - fired when the sink determines that a key frame has been requested.
842+
843+
The steps that generate an event of type {{KeyFrameRequestEvent}} are as follows:
844+
845+
Given a {{RTCRtpScriptTransformer}} |transform|:
846+
847+
When |transform|'s `[[encoder]]` receives a keyframe request, for instance from an incoming RTCP Picture Loss Indication (PLI)
848+
or Full Intra Refresh (FIR), queue a task to perform the following steps:
849+
850+
1. Set |rid| to the RID of the appropriate layer, or undefined if the request is not for a specific layer.
851+
1. [=Fire an event=] named `keyframerequest` at |transform| using {{KeyFrameRequestEvent}} with its {{Event/cancelable}} attribute initialized to "true", and with {{KeyFrameRequestEvent/rid}} set to |rid|.
852+
1. If the event's [=Event/canceled flag=] is true, abort these steps.
853+
1. Run the [$generate key frame algorithm$] with a new promise, |transform|.`[[encoder]]` and |rid|.
854+
823855
## KeyFrame Algorithms ## {#KeyFrame-algorithms}
824856

825857
The <dfn abstract-op>generate key frame algorithm</dfn>, given |promise|, |encoder| and |rid|, is defined by running these steps:

0 commit comments

Comments
 (0)