Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an API for a "keyframe has been requested" event #215

Merged
merged 9 commits into from
Dec 12, 2023
42 changes: 34 additions & 8 deletions index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -590,19 +590,35 @@ partial interface DedicatedWorkerGlobalScope {
attribute EventHandler onrtctransform;
};

[Exposed=DedicatedWorker]
interface RTCRtpScriptTransformer {
interface mixin RTCRtpScriptSource {
alvestrand marked this conversation as resolved.
Show resolved Hide resolved
readonly attribute ReadableStream readable;
readonly attribute WritableStream writable;
readonly attribute any options;
Promise<unsigned long long> generateKeyFrame(optional DOMString rid);
Promise<undefined> sendKeyFrameRequest();
};

interface mixin RTCRtpScriptSink {
alvestrand marked this conversation as resolved.
Show resolved Hide resolved
readonly attribute WritableStream writable;
attribute EventHandler onkeyframerequest;
};
alvestrand marked this conversation as resolved.
Show resolved Hide resolved

[Exposed=DedicatedWorker]
interface RTCRtpScriptTransformer {
readonly attribute any options;
};

RTCRtpScriptTransformer includes RTCRtpScriptSource;
alvestrand marked this conversation as resolved.
Show resolved Hide resolved
RTCRtpScriptTransformer includes RTCRtpScriptSink;

[Exposed=Window]
interface RTCRtpScriptTransform {
constructor(Worker worker, optional any options, optional sequence<object> transfer);
};

[Exposed=DedicatedWorker]
interface KeyFrameRequestEvent : Event {
constructor(DOMString type, optional DOMString rid);
readonly attribute DOMString? rid;
};
</pre>

## Operations ## {#RTCRtpScriptTransform-operations}
Expand Down Expand Up @@ -636,12 +652,12 @@ Each RTCRtpScriptTransform has the following set of [$association steps$], given
1. Set |transformer|.`[[encoder]]` to |encoder|.
1. Set |transformer|.`[[depacketizer]]` to |depacketizer|.

The <dfn method for="RTCRtpScriptTransformer">generateKeyFrame(|rid|)</dfn> method steps are:
The <dfn method for="RTCRtpScriptSource">generateKeyFrame(|rid|)</dfn> 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 <dfn method for="RTCRtpScriptTransformer">sendKeyFrameRequest()</dfn> method steps are:
The <dfn method for="RTCRtpScriptSource">sendKeyFrameRequest()</dfn> method steps are:
1. Let |promise| be a new promise.
1. Run the [$send request key frame algorithm$] with |promise| and |this|.`[[depacketizer]]`.
1. Return |promise|.
Expand All @@ -655,12 +671,22 @@ This allows algorithms to go from an {{RTCRtpScriptTransformer}} object to its {
The <dfn attribute for="RTCRtpScriptTransformer">options</dfn> getter steps are:
1. Return [=this=].`[[options]]`.

The <dfn attribute for="RTCRtpScriptTransformer">readable</dfn> getter steps are:
The <dfn attribute for="RTCRtpScriptSource">readable</dfn> getter steps are:
1. Return [=this=].`[[readable]]`.

The <dfn attribute for="RTCRtpScriptTransformer">writable</dfn> getter steps are:
The <dfn attribute for="RTCRtpScriptSink">writable</dfn> getter steps are:
1. Return [=this=].`[[writable]]`.

The <dfn attribute for="RTCRtpScriptSink">onbandwidthestimate</dfn> EventHandler has type bandwidthestimate.

The <dfn attribute for="RTCRtpScriptSink">onkeyframerequest</dfn> EventHandler has type keyframerequest.

## Events ## {#RTCRtpScriptTransformer-events}

The following events fire on an {{RTCRtpScriptTransformer}}:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should rewrite as "when the UA decides that a key frame has been requested, the UA will queue a task to fire an event...."

alvestrand marked this conversation as resolved.
Show resolved Hide resolved

* keyframerequest of type {{KeyFrameRequestEvent}} - fired when the sink determines that a key frame has been requested. In the context of {{RTCRtpScriptTransform}}, if the event is not cancelled, the information will be passed to the source as if the generateKeyFrame() function had been called. <!-- NOTE IN DRAFT: generateKeyFrame() and requestKeyFrame() should merge -->

## KeyFrame Algorithms ## {#KeyFrame-algorithms}

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