Skip to content

Commit ff25691

Browse files
authored
Add decryption/encryption dedicated APIs (#288)
* Add decryption/encryption dedicated APIs
1 parent 47531dd commit ff25691

File tree

1 file changed

+58
-20
lines changed

1 file changed

+58
-20
lines changed

index.bs

Lines changed: 58 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,16 @@ It uses an additional API on {{RTCRtpSender}} and {{RTCRtpReceiver}} to
8181
insert the processing into the pipeline.
8282

8383
<pre class="idl">
84-
typedef (SFrameTransform or RTCRtpScriptTransform) RTCRtpTransform;
84+
typedef (SFrameSenderTransform or RTCRtpScriptTransform) RTCRtpSenderTransform;
85+
typedef (SFrameReceiverTransform or RTCRtpScriptTransform) RTCRtpReceiverTransform;
8586

8687
// New methods for RTCRtpSender and RTCRtpReceiver
8788
partial interface RTCRtpSender {
88-
attribute RTCRtpTransform? transform;
89+
attribute RTCRtpSenderTransform? transform;
8990
};
9091

9192
partial interface RTCRtpReceiver {
92-
attribute RTCRtpTransform? transform;
93+
attribute RTCRtpReceiverTransform? transform;
9394
};
9495
</pre>
9596

@@ -203,7 +204,7 @@ There is no guarantee on which frame will happen the switch from the previous tr
203204
If a web application sets the transform synchronously at creation of the {{RTCRtpSender}} (for instance when calling addTrack), the transform will receive the first frame generated by the {{RTCRtpSender}}'s encoder.
204205
Similarly, if a web application sets the transform synchronously at creation of the {{RTCRtpReceiver}} (for instance when calling addTrack, or at track event handler), the transform will receive the first full frame generated by the {{RTCRtpReceiver}}'s packetizer.
205206

206-
# SFrameTransform # {#sframe}
207+
# SFrame transforms # {#sframe}
207208

208209
<p>
209210
The APIs presented in this section allow applications to process SFrame data using specific cipher suites defined in [[RFC9605]].
@@ -226,30 +227,42 @@ dictionary SFrameTransformOptions {
226227
typedef [EnforceRange] unsigned long long SmallCryptoKeyID;
227228
typedef (SmallCryptoKeyID or bigint) CryptoKeyID;
228229

229-
interface mixin SFrameKeyManagement {
230-
Promise<undefined> setEncryptionKey(CryptoKey key, optional CryptoKeyID keyID);
230+
interface mixin SFrameEncrypterManager {
231+
Promise<undefined> setEncryptionKey(CryptoKey key, CryptoKeyID keyId);
231232
attribute EventHandler onerror;
232233
};
233234

235+
interface mixin SFrameDecrypterManager {
236+
Promise<undefined> addDecryptionKey(CryptoKey key, CryptoKeyID keyId);
237+
Promise<undefined> removeDecryptionKey(CryptoKeyID keyId);
238+
attribute EventHandler onerror;
239+
};
240+
241+
[Exposed=Window]
242+
interface SFrameSenderTransform {
243+
constructor(optional SFrameTransformOptions options = {});
244+
};
245+
SFrameSenderTransform includes SFrameEncrypterManager;
246+
234247
[Exposed=Window]
235-
interface SFrameTransform : EventTarget {
248+
interface SFrameReceiverTransform : EventTarget {
236249
constructor(optional SFrameTransformOptions options = {});
237250
};
238-
SFrameTransform includes SFrameKeyManagement;
251+
SFrameReceiverTransform includes SFrameDecrypterManager;
239252

240253
[Exposed=(Window,DedicatedWorker)]
241254
interface SFrameEncrypterStream : EventTarget {
242255
constructor(optional SFrameTransformOptions options = {});
243256
};
244257
SFrameEncrypterStream includes GenericTransformStream;
245-
SFrameEncrypterStream includes SFrameKeyManagement;
258+
SFrameEncrypterStream includes SFrameEncrypterManager;
246259

247260
[Exposed=(Window,DedicatedWorker)]
248261
interface SFrameDecrypterStream : EventTarget {
249262
constructor(optional SFrameTransformOptions options = {});
250263
};
251264
SFrameDecrypterStream includes GenericTransformStream;
252-
SFrameDecrypterStream includes SFrameKeyManagement;
265+
SFrameDecrypterStream includes SFrameDecrypterManager;
253266

254267
enum SFrameTransformErrorEventType {
255268
"authentication",
@@ -273,9 +286,15 @@ dictionary SFrameTransformErrorEventInit : EventInit {
273286
};
274287
</xmp>
275288

276-
The <dfn constructor for="SFrameTransform" lt="SFrameTransform(options)"><code>new SFrameTransform(<var>options</var>)</code></dfn> constructor steps are:
289+
The <dfn constructor for="SFrameSenderTransform" lt="SFrameSenderTransform(options)"><code>new SFrameSenderTransform(<var>options</var>)</code></dfn> constructor steps are:
277290
1. Let |options| be the method's first argument.
278291
1. Run the [=SFrame initialization algorithm=] with |this| and |options|.
292+
1. Set |this|.`[[role]]` to 'encrypt'.
293+
294+
The <dfn constructor for="SFrameReceiverTransform" lt="SFrameReceiverTransform(options)"><code>new SFrameReceiverTransform(<var>options</var>)</code></dfn> constructor steps are:
295+
1. Let |options| be the method's first argument.
296+
1. Run the [=SFrame initialization algorithm=] with |this| and |options|.
297+
1. Set |this|.`[[role]]` to 'decrypt'.
279298

280299
The <dfn constructor for="SFrameEncrypterStream" lt="SFrameEncrypterStream(options)"><code>new SFrameEncrypterStream(<var>options</var>)</code></dfn> constructor steps are:
281300
1. Let |options| be the method's first argument.
@@ -324,14 +343,33 @@ The <dfn>SFrame transform algorithm</dfn>, given |this| and |frame|, runs these
324343
1. [=ReadableStream/Enqueue=] |frame| in |this|.`[[transform]]`.
325344

326345
## Methods ## {#sframe-transform-methods}
327-
The <dfn method for="SFrameTransform">setEncryptionKey(|key|, |keyID|)</dfn> method steps are:
346+
The <dfn method for="SFrameEncrypterManager">setEncryptionKey(|key|, |keyId|)</dfn> method steps are:
328347
1. Let |promise| be [=a new promise=].
329-
2. If |keyID| is a {{bigint}} which cannot be represented as a integer between 0 and 2<sup>64</sup>-1 inclusive, [=reject=] |promise| with a {{RangeError}} exception.
330-
3. Otherwise, [=in parallel=], run the following steps:
331-
1. Set |key| with its optional |keyID| as key material to use for the SFrame transform algorithm, as defined by [[RFC9605]].
332-
2. If setting the key material fails, [=reject=] |promise| with an {{InvalidModificationError}} exception and abort these steps.
333-
3. [=Resolve=] |promise| with undefined.
334-
4. Return |promise|.
348+
1. If |keyId| is a {{bigint}} which cannot be represented as a integer between 0 and 2<sup>64</sup>-1 inclusive, [=reject=] |promise| with a {{RangeError}} exception and abort these steps.
349+
1. [=In parallel=], run the following steps:
350+
1. Set the SFrame transform encryption algorithm's key material to |key| and |keyId|, as defined by [[RFC9605]].
351+
1. If setting the key material fails, [=queue a task=] to [=reject=] |promise| with an {{InvalidModificationError}} exception and abort these steps.
352+
1. [=Queue a task=] to [=resolve=] |promise| with undefined.
353+
1. Return |promise|.
354+
355+
The <dfn method for="SFrameDecrypterManager">addDecryptionKey(|key|, |keyId|)</dfn> method steps are:
356+
1. Let |promise| be [=a new promise=].
357+
1. If |keyId| is a {{bigint}} which cannot be represented as a integer between 0 and 2<sup>64</sup>-1 inclusive, [=reject=] |promise| with a {{RangeError}} exception, and abort these steps.
358+
1. [=In parallel=], run the following steps:
359+
1. Let |keyStore| be the key store used for the SFrame transform algorithm, as defined by [[RFC9605]].
360+
1. [=map/set|Set=] |keyStore|[|keyId|] to |keyValue|.
361+
1. If setting the key material fails, [=queue a task=] to [=reject=] |promise| with an {{InvalidModificationError}} exception and abort these steps.
362+
1. [=Queue a task=] to [=resolve=] |promise| with undefined.
363+
1. Return |promise|.
364+
365+
The <dfn method for="SFrameDecrypterManager">removeDecryptionKey(|keyId|)</dfn> method steps are:
366+
1. Let |promise| be [=a new promise=].
367+
1. If |keyId| is a {{bigint}} which cannot be represented as a integer between 0 and 2<sup>64</sup>-1 inclusive, [=reject=] |promise| with a {{RangeError}} exception, and abort these steps.
368+
1. [=In parallel=], run the following steps:
369+
1. Let |keyStore| be the key store used for the SFrame transform algorithm, as defined by [[RFC9605]].
370+
1. [=map/remove|Remove=] |keyStore|[|keyId|].
371+
1. [=Queue a task=] to [=resolve=] |promise| with undefined.
372+
1. Return |promise|.
335373

336374

337375
# Script Transform # {#scriptTransform}
@@ -528,7 +566,7 @@ interface RTCEncodedVideoFrame {
528566
### Members ### {#RTCEncodedVideoFrame-members}
529567
<dl dfn-for="RTCEncodedVideoFrame" class="dictionary-members">
530568
<dt>
531-
<dfn attribute>type</dfn> <span class="idlMemberType">RTCEncodedVideoFrameType</span>
569+
<dfn attribute>type</dfn> <span class="idlMemberType">EncodedVideoChunkType</span>
532570
</dt>
533571
<dd>
534572
<p>
@@ -1087,7 +1125,7 @@ The <dfn abstract-op>generate key frame algorithm</dfn>, given |promise|, |frame
10871125
For any [=encoder=] associated with an {{RTCRtpScriptTransformer}} |transformer|, the user agent MUST run the following steps just before any |frame| is [=ReadableStream/enqueued=] into |transformer|.{{[[readable]]}}:
10881126
1. Let |encoder| be |transformer|.{{[[frameSource]]}}.
10891127
1. If |encoder|.`[[pendingKeyFrameTasks]]` is undefined, abort these steps.
1090-
1. If |frame| is not a video {{RTCEncodedVideoFrameType/"key"}} frame, abort these steps.
1128+
1. If |frame| is not a video {{EncodedVideoChunkType/"key"}} frame, abort these steps.
10911129
1. For each |task| in |encoder|.`[[pendingKeyFrameTasks]]`, run the following steps:
10921130
1. If |frame| was generated for a layer [=list/contained=] in |task|.`[[layers]]`,
10931131
then run the following steps:

0 commit comments

Comments
 (0)