Skip to content

Commit 306e516

Browse files
authored
Merge pull request #728 from Djuffin/transfer
Add EncodedVideoChunkInit.transfer and EncodedAudioChunkInit.transfer
2 parents 77944c3 + fb9184d commit 306e516

File tree

1 file changed

+40
-8
lines changed

1 file changed

+40
-8
lines changed

index.src.html

Lines changed: 40 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2485,6 +2485,7 @@
24852485
[EnforceRange] required long long timestamp; // microseconds
24862486
[EnforceRange] unsigned long long duration; // microseconds
24872487
required BufferSource data;
2488+
sequence<ArrayBuffer> transfer = [];
24882489
};
24892490

24902491
enum EncodedAudioChunkType {
@@ -2509,13 +2510,28 @@
25092510
<dfn constructor for=EncodedAudioChunk title="EncodedAudioChunk(init)">
25102511
EncodedAudioChunk(init)
25112512
</dfn>
2512-
1. Let |chunk| be a new {{EncodedAudioChunk}} object, initialized as follows
2513+
1. If |init|.{{EncodedAudioChunkInit/transfer}} contains more than one reference
2514+
to the same {{ArrayBuffer}}, then throw a {{DataCloneError}} {{DOMException}}.
2515+
2. For each |transferable| in |init|.{{EncodedAudioChunkInit/transfer}}:
2516+
1. If {{platform object/[[Detached]]}} internal slot is `true`,
2517+
then throw a {{DataCloneError}} {{DOMException}}.
2518+
3. Let |chunk| be a new {{EncodedAudioChunk}} object, initialized as follows
25132519
1. Assign `init.type` to {{EncodedAudioChunk/[[type]]}}.
25142520
2. Assign `init.timestamp` to {{EncodedAudioChunk/[[timestamp]]}}.
25152521
3. If `init.duration` exists, assign it to
25162522
{{EncodedAudioChunk/[[duration]]}}, or assign `null` otherwise.
2517-
4. Assign a copy of `init.data` to {{EncodedAudioChunk/[[internal data]]}}.
2518-
5. Assign `init.data.byteLength` to {{EncodedAudioChunk/[[byte length]]}};
2523+
4. Assign `init.data.byteLength` to {{EncodedAudioChunk/[[byte length]]}};
2524+
5. If |init|.{{EncodedAudioChunkInit/transfer}} contains an {{ArrayBuffer}}
2525+
referenced by |init|.{{EncodedAudioChunkInit/data}} the User Agent
2526+
<em class="rfc2119">MAY</em> choose to:
2527+
1. Let |resource| be a new [=media resource=] referencing sample data
2528+
in |init|.{{EncodedAudioChunkInit/data}}.
2529+
6. Otherwise:
2530+
1. Assign a copy of |init|.{{EncodedAudioChunkInit/data}}
2531+
to {{EncodedAudioChunk/[[internal data]]}}.
2532+
4. For each |transferable| in |init|.{{EncodedAudioChunkInit/transfer}}:
2533+
1. Perform [DetachArrayBuffer](https://tc39.es/ecma262/#sec-detacharraybuffer)
2534+
on |transferable|
25192535
5. Return |chunk|.
25202536

25212537
### Attributes ###{#encodedaudiochunk-attributes}
@@ -2575,6 +2591,7 @@
25752591
[EnforceRange] required long long timestamp; // microseconds
25762592
[EnforceRange] unsigned long long duration; // microseconds
25772593
required AllowSharedBufferSource data;
2594+
sequence<ArrayBuffer> transfer = [];
25782595
};
25792596

25802597
enum EncodedVideoChunkType {
@@ -2599,15 +2616,30 @@
25992616
<dfn constructor for=EncodedVideoChunk title="EncodedVideoChunk(init)">
26002617
EncodedVideoChunk(init)
26012618
</dfn>
2602-
1. Let |chunk| be a new {{EncodedVideoChunk}} object, initialized as follows
2619+
1. If |init|.{{EncodedVideoChunkInit/transfer}} contains more than one reference
2620+
to the same {{ArrayBuffer}}, then throw a {{DataCloneError}} {{DOMException}}.
2621+
2. For each |transferable| in |init|.{{EncodedVideoChunkInit/transfer}}:
2622+
1. If {{platform object/[[Detached]]}} internal slot is `true`,
2623+
then throw a {{DataCloneError}} {{DOMException}}.
2624+
3. Let |chunk| be a new {{EncodedVideoChunk}} object, initialized as follows
26032625
1. Assign `init.type` to {{EncodedVideoChunk/[[type]]}}.
26042626
2. Assign `init.timestamp` to {{EncodedVideoChunk/[[timestamp]]}}.
26052627
3. If duration is present in init, assign `init.duration` to
26062628
{{EncodedVideoChunk/[[duration]]}}. Otherwise, assign `null` to
26072629
{{EncodedVideoChunk/[[duration]]}}.
2608-
4. Assign a copy of `init.data` to {{EncodedVideoChunk/[[internal data]]}}.
2609-
5. Assign `init.data.byteLength` to {{EncodedVideoChunk/[[byte length]]}};
2610-
3. Return |chunk|.
2630+
4. Assign `init.data.byteLength` to {{EncodedVideoChunk/[[byte length]]}};
2631+
5. If |init|.{{EncodedVideoChunkInit/transfer}} contains an {{ArrayBuffer}}
2632+
referenced by |init|.{{EncodedVideoChunkInit/data}} the User Agent
2633+
<em class="rfc2119">MAY</em> choose to:
2634+
1. Let |resource| be a new [=media resource=] referencing sample data
2635+
in |init|.{{EncodedVideoChunkInit/data}}.
2636+
6. Otherwise:
2637+
1. Assign a copy of |init|.{{EncodedVideoChunkInit/data}}
2638+
to {{EncodedVideoChunk/[[internal data]]}}.
2639+
4. For each |transferable| in |init|.{{EncodedVideoChunkInit/transfer}}:
2640+
1. Perform [DetachArrayBuffer](https://tc39.es/ecma262/#sec-detacharraybuffer)
2641+
on |transferable|
2642+
5. Return |chunk|.
26112643

26122644
### Attributes ###{#encodedvideochunk-attributes}
26132645
: <dfn attribute for=EncodedVideoChunk>type</dfn>
@@ -5596,7 +5628,7 @@
55965628

55975629
<div class=non-normative>
55985630
This section is non-normative.
5599-
5631+
56005632
The primary security impact is that features of this API make it easier for an
56015633
attacker to exploit vulnerabilities in the underlying platform codecs.
56025634
Additionally, new abilities to configure and control the codecs can allow for

0 commit comments

Comments
 (0)