@@ -142,10 +142,10 @@ The <dfn abstract-op>writeEncodedData</dfn> algorithm is given a |rtcObject| as
142
142
1. Set |rtcObject|.`[[lastReceivedFrameCounter]] ` to |frame|`[[counter]] `.
143
143
1. Let |data| be |frame|.`[[data]] `.
144
144
1. Let |serializedFrame| be [$StructuredSerializeWithTransfer$] (|frame|, « |data| »).
145
- 1. Let |frameCopy | be [$StructuredDeserialize $] (|serializedFrame|, |frame|'s [=relevant realm=] ).
146
- 1. Enqueue |frameCopy | for processing as if it came directly from the encoded data source, by running one of the following steps:
147
- * If |rtcObject| is a {{RTCRtpSender}} , enqueue |frameCopy | to |rtcObject|'s packetizer, to be processed [=in parallel=] .
148
- * If |rtcObject| is a {{RTCRtpReceiver}} , enqueue |frameCopy | it to |rtcObject|'s decoder, to be processed [=in parallel=] .
145
+ 1. Let |transferredFrame | be [$StructuredDeserializeWithTransfer $] (|serializedFrame|, |frame|'s [=relevant realm=] ).
146
+ 1. Enqueue |transferredFrame | for processing as if it came directly from the encoded data source, by running one of the following steps:
147
+ * If |rtcObject| is a {{RTCRtpSender}} , enqueue |transferredFrame | to |rtcObject|'s packetizer, to be processed [=in parallel=] .
148
+ * If |rtcObject| is a {{RTCRtpReceiver}} , enqueue |transferredFrame | it to |rtcObject|'s decoder, to be processed [=in parallel=] .
149
149
1. Return [=a promise resolved with=] undefined.
150
150
151
151
On sender side, as part of [$readEncodedData$] , frames produced by |rtcObject|'s encoder MUST be enqueued in |rtcObject|.`[[readable]]` in the encoder' s output order.
@@ -451,7 +451,7 @@ dictionary RTCEncodedVideoFrameOptions {
451
451
452
452
// New interfaces to define encoded video and audio frames. Will eventually
453
453
// re-use or extend the equivalent defined in WebCodecs.
454
- [Exposed=(Window,DedicatedWorker), Serializable]
454
+ [Exposed=(Window,DedicatedWorker), Serializable, Transferable ]
455
455
interface RTCEncodedVideoFrame {
456
456
constructor(RTCEncodedVideoFrame originalFrame, optional RTCEncodedVideoFrameOptions options = {});
457
457
readonly attribute RTCEncodedVideoFrameType type;
@@ -580,26 +580,41 @@ interface RTCEncodedVideoFrame {
580
580
</dd>
581
581
</dl>
582
582
583
- ### Serialization ### {#RTCEncodedVideoFrame-serialization}
583
+ ### Transfer and Serialization ### {#RTCEncodedVideoFrame-serialization}
584
+
585
+ {{RTCEncodedVideoFrame}} objects are [=serializable objects=] and [=transferable objects=] .
584
586
585
- {{RTCEncodedVideoFrame}} objects are serializable objects [[HTML]] .
586
587
Their [=serialization steps=] , given |value|, |serialized|, and |forStorage|, are:
587
588
588
589
1. If |forStorage| is true, then throw a {{DataCloneError}} .
589
- 1. Set |serialized|.`[[type]] ` to the value of |value|.{{RTCEncodedVideoFrame/type}}
590
+ 1. Set |serialized|.`[[type]] ` to the value of |value|.{{RTCEncodedVideoFrame/type}} .
590
591
1. Set |serialized|.`[[metadata]] ` to an internal representation of |value|'s metadata.
591
- 1. Set |serialized|.`[[data]] ` to |value|.`[[data]] `
592
+ 1. Set |serialized|.`[[data]] ` to a copy of |value|.`[[data]] `.
592
593
593
594
Their [=deserialization steps=] , given |serialized|, |value| and |realm|, are:
594
595
595
- 1. Set |value|.{{RTCEncodedVideoFrame/type}} to |serialized|.`[[type]] `
596
- 1. Set |value|'s metadata to the platform object representation of |serialized|.`[[metadata]] `
596
+ 1. Set |value|.{{RTCEncodedVideoFrame/type}} to |serialized|.`[[type]] `.
597
+ 1. Set |value|'s metadata to the platform object representation of |serialized|.`[[metadata]] `.
597
598
1. Set |value|.`[[data]] ` to |serialized|.`[[data]] `.
598
599
600
+ Their [=transfer steps=] , given |value| and |dataHolder|, are:
601
+
602
+ 1. Set |dataHolder|.`[[type]] ` to the value of |value|.{{RTCEncodedVideoFrame/type}} .
603
+ 1. Set |dataHolder|.`[[metadata]] ` to an internal representation of |value|'s metadata.
604
+ 1. Set |dataHolder|.`[[data]] ` to |value|.`[[data]] `.
605
+ 1. Unset |value|.`[[data]] `.
606
+
607
+ Their [=transfer-receiving steps=] , given |dataHolder| and |value|, are:
608
+
609
+ 1. Set |value|.{{RTCEncodedVideoFrame/type}} to |dataHolder|.`[[type]] `
610
+ 1. Set |value|'s metadata to the platform object representation of |dataHolder|.`[[metadata]] `.
611
+ 1. Set |value|.`[[data]] ` to |dataHolder|.`[[data]] `.
612
+
599
613
<p class="note">
600
614
The internal form of a serialized RTCEncodedVideoFrame is not observable;
601
- it is defined chiefly so that it can be used with frame cloning in the
602
- [$writeEncodedData$] algorithm and in the {{WindowOrWorkerGlobalScope/structuredClone()}} operation.
615
+ transfer is used to hand off frames in the
616
+ [$writeEncodedData$] algorithm, and serialization is used in the
617
+ {{WindowOrWorkerGlobalScope/structuredClone()}} operation.
603
618
An implementation is therefore free to choose whatever method works best.
604
619
</p>
605
620
@@ -681,7 +696,7 @@ dictionary RTCEncodedAudioFrameOptions {
681
696
RTCEncodedAudioFrameMetadata metadata;
682
697
};
683
698
684
- [Exposed=(Window,DedicatedWorker), Serializable]
699
+ [Exposed=(Window,DedicatedWorker), Serializable, Transferable ]
685
700
interface RTCEncodedAudioFrame {
686
701
constructor(RTCEncodedAudioFrame originalFrame, optional RTCEncodedAudioFrameOptions options = {});
687
702
attribute ArrayBuffer data;
@@ -806,20 +821,32 @@ interface RTCEncodedAudioFrame {
806
821
</dl>
807
822
808
823
809
- ### Serialization ### {#RTCEncodedAudioFrame-serialization}
824
+ ### Transfer and Serialization ### {#RTCEncodedAudioFrame-serialization}
825
+
826
+ {{RTCEncodedAudioFrame}} objects are [=serializable objects=] and [=transferable objects=] .
810
827
811
- {{RTCEncodedAudioFrame}} objects are serializable objects [[HTML]] .
812
828
Their [=serialization steps=] , given |value|, |serialized|, and |forStorage|, are:
813
829
814
830
1. If |forStorage| is true, then throw a {{DataCloneError}} .
815
831
1. Set |serialized|.`[[metadata]] ` to an internal representation of |value|'s metadata.
816
- 1. Set |serialized|.`[[data]] ` to |value|.`[[data]] `
832
+ 1. Set |serialized|.`[[data]] ` to a copy of |value|.`[[data]] `
817
833
818
834
Their [=deserialization steps=] , given |serialized|, |value| and |realm|, are:
819
835
820
836
1. Set |value|'s metadata to the platform object representation of |serialized|.`[[metadata]] `
821
837
1. Set |value|.`[[data]] ` to |serialized|.`[[data]] `.
822
838
839
+ Their [=transfer steps=] , given |value| and |dataHolder|, are:
840
+
841
+ 1. Set |dataHolder|.`[[metadata]] ` to an internal representation of |value|'s metadata.
842
+ 1. Set |dataHolder|.`[[data]] ` to |value|.`[[data]] `.
843
+ 1. Unset |value|.`[[data]] `.
844
+
845
+ Their [=transfer-receiving steps=] , given |dataHolder| and |value|, are:
846
+
847
+ 1. Set |value|'s metadata to the platform object representation of |dataHolder|.`[[metadata]] `.
848
+ 1. Set |value|.`[[data]] ` to |dataHolder|.`[[data]] `.
849
+
823
850
## Interfaces ## {#RTCRtpScriptTransformer-interfaces}
824
851
<pre class="idl">
825
852
[Exposed=DedicatedWorker]
@@ -867,9 +894,9 @@ The <dfn constructor for="RTCRtpScriptTransform" lt="RTCRtpScriptTransform(worke
867
894
6. Let |serializedReadable| be the result of [$StructuredSerializeWithTransfer$] (|t1|.`[[readable]] `, « |t1|.`[[readable]] ` »).
868
895
7. Let |serializedWritable| be the result of [$StructuredSerializeWithTransfer$] (|t2|.`[[writable]] `, « |t2|.`[[writable]] ` »).
869
896
8. [=Queue a task=] on the DOM manipulation [=task source=] |worker|'s global scope to run the following steps:
870
- 1. Let |transformerOptions| be the result of [$StructuredDeserialize $] (|serializedOptions|, the current Realm).
871
- 2. Let |readable| be the result of [$StructuredDeserialize $] (|serializedReadable|, the current Realm).
872
- 3. Let |writable| be the result of [$StructuredDeserialize $] (|serializedWritable|, the current Realm).
897
+ 1. Let |transformerOptions| be the result of [$StructuredDeserializeWithTransfer $] (|serializedOptions|, the current Realm).
898
+ 2. Let |readable| be the result of [$StructuredDeserializeWithTransfer $] (|serializedReadable|, the current Realm).
899
+ 3. Let |writable| be the result of [$StructuredDeserializeWithTransfer $] (|serializedWritable|, the current Realm).
873
900
4. Let |transformer| be a new {{RTCRtpScriptTransformer}} .
874
901
5. Set |transformer|.`[[options]] ` to |transformerOptions|.
875
902
6. Set |transformer|.`[[readable]] ` to |readable|.
0 commit comments