Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Encoded*Chunk interfaces immutable. #174

Merged
merged 5 commits into from
May 13, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 54 additions & 30 deletions index.src.html
Original file line number Diff line number Diff line change
Expand Up @@ -1784,7 +1784,9 @@
constructor(EncodedAudioChunkInit init);
readonly attribute EncodedAudioChunkType type;
readonly attribute unsigned long long timestamp; // microseconds
readonly attribute ArrayBuffer data;
readonly attribute unsigned long byteLength;

undefined copyTo(ArrayBufferView dst);
};

dictionary EncodedAudioChunkInit {
Expand All @@ -1799,27 +1801,38 @@
};
</xmp>

### Internal Slots ### {#encodedaudiochunk-internal-slots}
: <dfn attribute for=EncodedAudioChunk>[[internal data]]</dfn></dt>
:: An array of bytes representing the encoded chunk data.

### Constructors ###{#encodedaudiochunk-constructors}
<dfn constructor for=EncodedAudioChunk title="EncodedAudioChunk(init)">
EncodedAudioChunk(init)
</dfn>
1. Let |chunk| be a new {{EncodedAudioChunk}} object, initialized as follows
1. Assign `init.type` to `chunk.type`.
2. Assign `init.timestamp` to `chunk.timestamp`.
3. Assign a copy of `init.data` to `chunk.data`.
1. Assign `init.type` to {{EncodedAudioChunk/type}}.
2. Assign `init.timestamp` to {{EncodedAudioChunk/timestamp}}.
3. Assign a copy of `init.data` to {{EncodedAudioChunk/[[internal data]]}}.
4. Assign `init.data.byteLength` to {{EncodedAudioChunk/byteLength}};
5. Return |chunk|.

### Attributes ###{#encodedaudiochunk-attributes}
<dl>
<dt><dfn attribute for=EncodedAudioChunk>type</dfn></dt>
<dd>Describes whether the chunk is a key frame.</dd>
: <dfn attribute for=EncodedAudioChunk>type</dfn>
:: Describes whether the chunk is a key frame.

<dt><dfn attribute for=EncodedAudioChunk>timestamp</dfn></dt>
<dd>The presentation timestamp, given in microseconds.</dd>
: <dfn attribute for=EncodedAudioChunk>timestamp</dfn>
:: The presentation timestamp, given in microseconds.

<dt><dfn attribute for=EncodedAudioChunk>data</dfn></dt>
<dd>A sequence of bytes containing encoded audio data.</dd>
</dl>
: <dfn attribute for=EncodedAudioChunk>byteLength</dfn>
:: The byte length of {{EncodedAudioChunk/[[internal data]]}}.

### Methods ###{#encodedaudiochunk-methods}
: <dfn method for=EncodedAudioChunk>copyTo(dst)</dfn>
:: When invoked, run these steps:
1. If {{EncodedAudioChunk/byteLength}} is greater than
|dst|.`byteLength`,
throw a {{TypeError}}.
2. Copy the {{EncodedAudioChunk/[[internal data]]}} into |dst|.

EncodedVideoChunk Interface{#encodedvideochunk-interface}
-----------------------------------------------------------
Expand All @@ -1830,7 +1843,9 @@
readonly attribute EncodedVideoChunkType type;
readonly attribute unsigned long long timestamp; // microseconds
readonly attribute unsigned long long? duration; // microseconds
readonly attribute ArrayBuffer data;
readonly attribute unsigned long byteLength;

undefined copyTo(ArrayBufferView dst);
};

dictionary EncodedVideoChunkInit {
Expand All @@ -1846,32 +1861,44 @@
};
</xmp>

### Internal Slots ### {#encodedvideochunk-internal-slots}
: <dfn attribute for=EncodedVideoChunk>[[internal data]]</dfn></dt>
:: An array of bytes representing the encoded chunk data.

### Constructors ###{#encodedvideochunk-constructors}
<dfn constructor for=EncodedVideoChunk title="EncodedVideoChunk(init)">
EncodedVideoChunk(init)
</dfn>
1. Let |chunk| be a new {{EncodedVideoChunk}} object, initialized as follows
1. Assign `init.type` to `chunk.type`.
2. Assign `init.timestamp` to `chunk.timestamp`.
1. Assign `init.type` to {{EncodedVideoChunk/type}}.
2. Assign `init.timestamp` to {{EncodedVideoChunk/timestamp}}.
3. If duration is present in init, assign `init.duration` to
`chunk.duration`. Otherwise, assign null to `chunk.duration`.
2. Assign a copy of `init.data` to `chunk.data`.
{{EncodedVideoChunk/duration}}. Otherwise, assign `null` to
{{EncodedVideoChunk/duration}}.
4. Assign a copy of `init.data` to {{EncodedVideoChunk/[[internal data]]}}.
5. Assign `init.data.byteLength` to {{EncodedVideoChunk/byteLength}};
3. Return |chunk|.

### Attributes ###{#encodedvideochunk-attributes}
<dl>
<dt><dfn attribute for=EncodedVideoChunk>type</dfn></dt>
<dd>Describes whether the chunk is a key frame or not.</dd>
: <dfn attribute for=EncodedVideoChunk>type</dfn>
:: Describes whether the chunk is a key frame or not.

<dt><dfn attribute for=EncodedVideoChunk>timestamp</dfn></dt>
<dd>The presentation timestamp, given in microseconds.</dd>
: <dfn attribute for=EncodedVideoChunk>timestamp</dfn>
:: The presentation timestamp, given in microseconds.

<dt><dfn attribute for=EncodedVideoChunk>duration</dfn></dt>
<dd>The presentation duration, given in microseconds.</dd>
: <dfn attribute for=EncodedVideoChunk>duration</dfn>
:: The presentation duration, given in microseconds.

<dt><dfn attribute for=EncodedVideoChunk>data</dfn></dt>
<dd>A sequence of bytes containing encoded video data.</dd>
</dl>
: <dfn attribute for=EncodedVideoChunk>byteLength</dfn>
:: The byte length of {{EncodedVideoChunk/[[internal data]]}}.

### Methods ###{#encodedvideochunk-methods}
: <dfn method for=EncodedVideoChunk>copyTo(dst)</dfn>
:: When invoked, run these steps:
1. If {{EncodedVideoChunk/byteLength}} is greater than
|dst|.`byteLength`,
throw a {{TypeError}}.
2. Copy the {{EncodedVideoChunk/[[internal data]]}} into |dst|.


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

ISSUE: EncodedVideoChunk and EncodedAudioChunk currently expose a mutable
data. See <a href="https://github.com/w3c/webcodecs/issues/80">#80</a>.

Privacy Considerations{#privacy-considerations}
===============================================
The primary privacy impact is an increased ability to fingerprint users by
Expand Down