Skip to content

Commit fcada57

Browse files
authored
Merge pull request #174 from w3c/immutable_chunks
Make Encoded*Chunk interfaces immutable.
2 parents 731a471 + 877b646 commit fcada57

File tree

1 file changed

+54
-30
lines changed

1 file changed

+54
-30
lines changed

index.src.html

Lines changed: 54 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1784,7 +1784,9 @@
17841784
constructor(EncodedAudioChunkInit init);
17851785
readonly attribute EncodedAudioChunkType type;
17861786
readonly attribute unsigned long long timestamp; // microseconds
1787-
readonly attribute ArrayBuffer data;
1787+
readonly attribute unsigned long byteLength;
1788+
1789+
undefined copyTo(ArrayBufferView dst);
17881790
};
17891791

17901792
dictionary EncodedAudioChunkInit {
@@ -1799,27 +1801,38 @@
17991801
};
18001802
</xmp>
18011803

1804+
### Internal Slots ### {#encodedaudiochunk-internal-slots}
1805+
: <dfn attribute for=EncodedAudioChunk>[[internal data]]</dfn></dt>
1806+
:: An array of bytes representing the encoded chunk data.
1807+
18021808
### Constructors ###{#encodedaudiochunk-constructors}
18031809
<dfn constructor for=EncodedAudioChunk title="EncodedAudioChunk(init)">
18041810
EncodedAudioChunk(init)
18051811
</dfn>
18061812
1. Let |chunk| be a new {{EncodedAudioChunk}} object, initialized as follows
1807-
1. Assign `init.type` to `chunk.type`.
1808-
2. Assign `init.timestamp` to `chunk.timestamp`.
1809-
3. Assign a copy of `init.data` to `chunk.data`.
1813+
1. Assign `init.type` to {{EncodedAudioChunk/type}}.
1814+
2. Assign `init.timestamp` to {{EncodedAudioChunk/timestamp}}.
1815+
3. Assign a copy of `init.data` to {{EncodedAudioChunk/[[internal data]]}}.
1816+
4. Assign `init.data.byteLength` to {{EncodedAudioChunk/byteLength}};
18101817
5. Return |chunk|.
18111818

18121819
### Attributes ###{#encodedaudiochunk-attributes}
1813-
<dl>
1814-
<dt><dfn attribute for=EncodedAudioChunk>type</dfn></dt>
1815-
<dd>Describes whether the chunk is a key frame.</dd>
1820+
: <dfn attribute for=EncodedAudioChunk>type</dfn>
1821+
:: Describes whether the chunk is a key frame.
18161822

1817-
<dt><dfn attribute for=EncodedAudioChunk>timestamp</dfn></dt>
1818-
<dd>The presentation timestamp, given in microseconds.</dd>
1823+
: <dfn attribute for=EncodedAudioChunk>timestamp</dfn>
1824+
:: The presentation timestamp, given in microseconds.
18191825

1820-
<dt><dfn attribute for=EncodedAudioChunk>data</dfn></dt>
1821-
<dd>A sequence of bytes containing encoded audio data.</dd>
1822-
</dl>
1826+
: <dfn attribute for=EncodedAudioChunk>byteLength</dfn>
1827+
:: The byte length of {{EncodedAudioChunk/[[internal data]]}}.
1828+
1829+
### Methods ###{#encodedaudiochunk-methods}
1830+
: <dfn method for=EncodedAudioChunk>copyTo(dst)</dfn>
1831+
:: When invoked, run these steps:
1832+
1. If {{EncodedAudioChunk/byteLength}} is greater than
1833+
|dst|.`byteLength`,
1834+
throw a {{TypeError}}.
1835+
2. Copy the {{EncodedAudioChunk/[[internal data]]}} into |dst|.
18231836

18241837
EncodedVideoChunk Interface{#encodedvideochunk-interface}
18251838
-----------------------------------------------------------
@@ -1830,7 +1843,9 @@
18301843
readonly attribute EncodedVideoChunkType type;
18311844
readonly attribute unsigned long long timestamp; // microseconds
18321845
readonly attribute unsigned long long? duration; // microseconds
1833-
readonly attribute ArrayBuffer data;
1846+
readonly attribute unsigned long byteLength;
1847+
1848+
undefined copyTo(ArrayBufferView dst);
18341849
};
18351850

18361851
dictionary EncodedVideoChunkInit {
@@ -1846,32 +1861,44 @@
18461861
};
18471862
</xmp>
18481863

1864+
### Internal Slots ### {#encodedvideochunk-internal-slots}
1865+
: <dfn attribute for=EncodedVideoChunk>[[internal data]]</dfn></dt>
1866+
:: An array of bytes representing the encoded chunk data.
1867+
18491868
### Constructors ###{#encodedvideochunk-constructors}
18501869
<dfn constructor for=EncodedVideoChunk title="EncodedVideoChunk(init)">
18511870
EncodedVideoChunk(init)
18521871
</dfn>
18531872
1. Let |chunk| be a new {{EncodedVideoChunk}} object, initialized as follows
1854-
1. Assign `init.type` to `chunk.type`.
1855-
2. Assign `init.timestamp` to `chunk.timestamp`.
1873+
1. Assign `init.type` to {{EncodedVideoChunk/type}}.
1874+
2. Assign `init.timestamp` to {{EncodedVideoChunk/timestamp}}.
18561875
3. If duration is present in init, assign `init.duration` to
1857-
`chunk.duration`. Otherwise, assign null to `chunk.duration`.
1858-
2. Assign a copy of `init.data` to `chunk.data`.
1876+
{{EncodedVideoChunk/duration}}. Otherwise, assign `null` to
1877+
{{EncodedVideoChunk/duration}}.
1878+
4. Assign a copy of `init.data` to {{EncodedVideoChunk/[[internal data]]}}.
1879+
5. Assign `init.data.byteLength` to {{EncodedVideoChunk/byteLength}};
18591880
3. Return |chunk|.
18601881

18611882
### Attributes ###{#encodedvideochunk-attributes}
1862-
<dl>
1863-
<dt><dfn attribute for=EncodedVideoChunk>type</dfn></dt>
1864-
<dd>Describes whether the chunk is a key frame or not.</dd>
1883+
: <dfn attribute for=EncodedVideoChunk>type</dfn>
1884+
:: Describes whether the chunk is a key frame or not.
18651885

1866-
<dt><dfn attribute for=EncodedVideoChunk>timestamp</dfn></dt>
1867-
<dd>The presentation timestamp, given in microseconds.</dd>
1886+
: <dfn attribute for=EncodedVideoChunk>timestamp</dfn>
1887+
:: The presentation timestamp, given in microseconds.
18681888

1869-
<dt><dfn attribute for=EncodedVideoChunk>duration</dfn></dt>
1870-
<dd>The presentation duration, given in microseconds.</dd>
1889+
: <dfn attribute for=EncodedVideoChunk>duration</dfn>
1890+
:: The presentation duration, given in microseconds.
18711891

1872-
<dt><dfn attribute for=EncodedVideoChunk>data</dfn></dt>
1873-
<dd>A sequence of bytes containing encoded video data.</dd>
1874-
</dl>
1892+
: <dfn attribute for=EncodedVideoChunk>byteLength</dfn>
1893+
:: The byte length of {{EncodedVideoChunk/[[internal data]]}}.
1894+
1895+
### Methods ###{#encodedvideochunk-methods}
1896+
: <dfn method for=EncodedVideoChunk>copyTo(dst)</dfn>
1897+
:: When invoked, run these steps:
1898+
1. If {{EncodedVideoChunk/byteLength}} is greater than
1899+
|dst|.`byteLength`,
1900+
throw a {{TypeError}}.
1901+
2. Copy the {{EncodedVideoChunk/[[internal data]]}} into |dst|.
18751902

18761903

18771904
Raw Media Interfaces {#raw-media-interfaces}
@@ -3530,9 +3557,6 @@
35303557
This concern is mitigated by ensuring that input and output interfaces are
35313558
immutable.
35323559

3533-
ISSUE: EncodedVideoChunk and EncodedAudioChunk currently expose a mutable
3534-
data. See <a href="https://github.com/w3c/webcodecs/issues/80">#80</a>.
3535-
35363560
Privacy Considerations{#privacy-considerations}
35373561
===============================================
35383562
The primary privacy impact is an increased ability to fingerprint users by

0 commit comments

Comments
 (0)