Skip to content

Commit 09f618e

Browse files
authored
Merge pull request #182 from w3c/alvestrand-patch-1
Add Serializable attributes to encoded video frames
2 parents c18f6ae + 0c3c5ea commit 09f618e

File tree

1 file changed

+59
-19
lines changed

1 file changed

+59
-19
lines changed

index.bs

+59-19
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ enum RTCEncodedVideoFrameType {
287287
};
288288
</pre>
289289
<table dfn-for="RTCEncodedVideoFrameType" class="simple">
290-
<caption>Enumeration description</caption>
290+
<caption>Enumeration description</caption>
291291
<thead>
292292
<tr>
293293
<th>Enum value</th><th>Description</th>
@@ -347,7 +347,7 @@ dictionary RTCEncodedVideoFrameMetadata {
347347

348348
<dl dfn-for="RTCEncodedVideoFrameMetadata" class="dictionary-members">
349349
<dt>
350-
<dfn dict-member>synchronizationSource</dfn> of type <span class="idlMemberType">unsigned long</span>
350+
<dfn dict-member>synchronizationSource</dfn> <span class="idlMemberType">unsigned long</span>
351351
</dt>
352352
<dd>
353353
<p>
@@ -356,7 +356,7 @@ dictionary RTCEncodedVideoFrameMetadata {
356356
</p>
357357
</dd>
358358
<dt>
359-
<dfn dict-member>payloadType</dfn> of type <span class="idlMemberType">octet</span>
359+
<dfn dict-member>payloadType</dfn> <span class="idlMemberType">octet</span>
360360
</dt>
361361
<dd>
362362
<p>
@@ -365,7 +365,7 @@ dictionary RTCEncodedVideoFrameMetadata {
365365
</p>
366366
</dd>
367367
<dt>
368-
<dfn dict-member>contributingSources</dfn> of type <span class=
368+
<dfn dict-member>contributingSources</dfn> <span class=
369369
"idlMemberType">sequence&lt;unsigned long&gt;</span>
370370
</dt>
371371
<dd>
@@ -374,13 +374,13 @@ dictionary RTCEncodedVideoFrameMetadata {
374374
</p>
375375
</dd>
376376
<dt>
377-
<dfn>timestamp</dfn> of type <span class=
377+
<dfn>timestamp</dfn> <span class=
378378
"idlMemberType">long long</span>
379379
</dt>
380380
<dd>
381381
<p>
382382
The media presentation timestamp (PTS) in microseconds of raw frame, matching the
383-
{{VideoFrame/timestamp}} for raw frames which correspond to this frame.
383+
{{VideoFrame/timestamp}} for raw frames which correspond to this frame.
384384
</p>
385385
</dd>
386386
</dl>
@@ -390,7 +390,7 @@ dictionary RTCEncodedVideoFrameMetadata {
390390
<pre class="idl">
391391
// New interfaces to define encoded video and audio frames. Will eventually
392392
// re-use or extend the equivalent defined in WebCodecs.
393-
[Exposed=(Window,DedicatedWorker)]
393+
[Exposed=(Window,DedicatedWorker), Serializable]
394394
interface RTCEncodedVideoFrame {
395395
readonly attribute RTCEncodedVideoFrameType type;
396396
readonly attribute unsigned long timestamp;
@@ -402,7 +402,7 @@ interface RTCEncodedVideoFrame {
402402
### Members ### {#RTCEncodedVideoFrame-members}
403403
<dl dfn-for="RTCEncodedVideoFrame" class="dictionary-members">
404404
<dt>
405-
<dfn attribute>type</dfn> of type <span class="idlMemberType">RTCEncodedVideoFrameType</span>
405+
<dfn attribute>type</dfn> <span class="idlMemberType">RTCEncodedVideoFrameType</span>
406406
</dt>
407407
<dd>
408408
<p>
@@ -412,7 +412,7 @@ interface RTCEncodedVideoFrame {
412412
</dd>
413413

414414
<dt>
415-
<dfn attribute>timestamp</dfn> of type <span class="idlMemberType">unsigned long</span>
415+
<dfn attribute>timestamp</dfn> <span class="idlMemberType">unsigned long</span>
416416
</dt>
417417
<dd>
418418
<p>
@@ -421,7 +421,7 @@ interface RTCEncodedVideoFrame {
421421
</p>
422422
</dd>
423423
<dt>
424-
<dfn attribute>data</dfn> of type <span class="idlMemberType">ArrayBuffer</span>
424+
<dfn attribute>data</dfn> <span class="idlMemberType">ArrayBuffer</span>
425425
</dt>
426426
<dd>
427427
<p>
@@ -442,6 +442,31 @@ interface RTCEncodedVideoFrame {
442442
</dd>
443443
</dl>
444444

445+
### Serialization ### {#RTCEncodedVideoFrame-serialization}
446+
447+
{{RTCEncodedVideoFrame}} objects are serializable objects [[HTML]].
448+
Their [=serialization steps=], given |value|, |serialized|, and |forStorage|, are:
449+
450+
1. If |forStorage| is true, then throw a {{DataCloneError}}.
451+
1. Set |serialized|.`[[type]]` to the value of |value|.{{RTCEncodedVideoFrame/type}}
452+
1. Set |serialized|.`[[timestamp]]` to the value of |value|.{{RTCEncodedVideoFrame/timestamp}}
453+
1. Set |serialized|.`[[metadata]]` to an internal representation of |value|'s metadata.
454+
1. Set |serialized|.`[[data]]` to |value|.`[[data]]`
455+
456+
Their [=deserialization steps=], given |serialized|, |value| and |realm|, are:
457+
458+
1. Set |value|.{{RTCEncodedVideoFrame/type}} to |serialized|.`[[type]]`
459+
1. Set |value|.{{RTCEncodedVideoFrame/timestamp}} to |serialized|.`[[timestamp]]`
460+
1. Set |value|'s metadata to the platform object representation of |serialized|.`[[metadata]]`
461+
1. Set |value|.`[[data]]` to |serialized|.`[[data]]`.
462+
463+
<p class="note">
464+
The internal form of a serialized RTCEncodedVideoFrame is not observable;
465+
it is defined chiefly so that it can be used with frame cloning in the
466+
[$writeEncodedData$] algorithm and in the {{WindowOrWorkerGlobalScope/structuredClone()}} operation.
467+
An implementation is therefore free to choose whatever method works best.
468+
</p>
469+
445470
## <dfn dictionary>RTCEncodedAudioFrameMetadata</dfn> dictionary ## {#RTCEncodedAudioFrameMetadata}
446471
<pre class="idl">
447472
dictionary RTCEncodedAudioFrameMetadata {
@@ -454,7 +479,7 @@ dictionary RTCEncodedAudioFrameMetadata {
454479
### Members ### {#RTCEncodedAudioFrameMetadata-members}
455480
<dl dfn-for="RTCEncodedAudioFrameMetadata" class="dictionary-members">
456481
<dt>
457-
<dfn dict-member>synchronizationSource</dfn> of type <span class="idlMemberType">unsigned long</span>
482+
<dfn dict-member>synchronizationSource</dfn> <span class="idlMemberType">unsigned long</span>
458483
</dt>
459484
<dd>
460485
<p>
@@ -463,7 +488,7 @@ dictionary RTCEncodedAudioFrameMetadata {
463488
</p>
464489
</dd>
465490
<dt>
466-
<dfn dict-member>payloadType</dfn> of type <span class="idlMemberType">octet</span>
491+
<dfn dict-member>payloadType</dfn> <span class="idlMemberType">octet</span>
467492
</dt>
468493
<dd>
469494
<p>
@@ -472,7 +497,7 @@ dictionary RTCEncodedAudioFrameMetadata {
472497
</p>
473498
</dd>
474499
<dt>
475-
<dfn dict-member>contributingSources</dfn> of type <span class=
500+
<dfn dict-member>contributingSources</dfn> <span class=
476501
"idlMemberType">sequence&lt;unsigned long&gt;</span>
477502
</dt>
478503
<dd>
@@ -481,7 +506,7 @@ dictionary RTCEncodedAudioFrameMetadata {
481506
</p>
482507
</dd>
483508
<dt>
484-
<dfn dict-member>sequenceNumber</dfn> of type <span class=
509+
<dfn dict-member>sequenceNumber</dfn> <span class=
485510
"idlMemberType">short</span>
486511
</dt>
487512
<dd>
@@ -496,7 +521,7 @@ dictionary RTCEncodedAudioFrameMetadata {
496521

497522
## <dfn interface>RTCEncodedAudioFrame</dfn> interface ## {#RTCEncodedAudioFrame-interface}
498523
<pre class="idl">
499-
[Exposed=(Window,DedicatedWorker)]
524+
[Exposed=(Window,DedicatedWorker), Serializable]
500525
interface RTCEncodedAudioFrame {
501526
readonly attribute unsigned long timestamp;
502527
attribute ArrayBuffer data;
@@ -507,7 +532,7 @@ interface RTCEncodedAudioFrame {
507532
### Members ### {#RTCEncodedAudioFrame-members}
508533
<dl dfn-for="RTCEncodedAudioFrame" class="dictionary-members">
509534
<dt>
510-
<dfn attribute>timestamp</dfn> of type <span class="idlMemberType">unsigned long</span>
535+
<dfn attribute>timestamp</dfn> <span class="idlMemberType">unsigned long</span>
511536
</dt>
512537
<dd>
513538
<p>
@@ -516,7 +541,7 @@ interface RTCEncodedAudioFrame {
516541
</p>
517542
</dd>
518543
<dt>
519-
<dfn attribute>data</dfn> of type <span class="idlMemberType">ArrayBuffer</span>
544+
<dfn attribute>data</dfn> <span class="idlMemberType">ArrayBuffer</span>
520545
</dt>
521546
<dd>
522547
<p>
@@ -538,8 +563,23 @@ interface RTCEncodedAudioFrame {
538563
</dl>
539564

540565

541-
// New interfaces to expose JavaScript-based transforms.
542-
##Interfaces
566+
### Serialization ### {#RTCEncodedAudioFrame-serialization}
567+
568+
{{RTCEncodedAudioFrame}} objects are serializable objects [[HTML]].
569+
Their [=serialization steps=], given |value|, |serialized|, and |forStorage|, are:
570+
571+
1. If |forStorage| is true, then throw a {{DataCloneError}}.
572+
1. Set |serialized|.`[[timestamp]]` to the value of |value|.{{RTCEncodedAudioFrame/timestamp}}
573+
1. Set |serialized|.`[[metadata]]` to an internal representation of |value|'s metadata.
574+
1. Set |serialized|.`[[data]]` to |value|.`[[data]]`
575+
576+
Their [=deserialization steps=], given |serialized|, |value| and |realm|, are:
577+
578+
1. Set |value|.{{RTCEncodedAudioFrame/timestamp}} to |serialized|.`[[timestamp]]`
579+
1. Set |value|'s metadata to the platform object representation of |serialized|.`[[metadata]]`
580+
1. Set |value|.`[[data]]` to |serialized|.`[[data]]`.
581+
582+
## Interfaces ## {#RTCRtpScriptTransformer-interfaces}
543583
<pre class="idl">
544584
[Exposed=DedicatedWorker]
545585
interface RTCTransformEvent : Event {

0 commit comments

Comments
 (0)