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

Constructor frame #223

Merged
merged 13 commits into from
Apr 19, 2024
63 changes: 63 additions & 0 deletions index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ spec:webidl; type:dfn; text:resolve
"href": "https://www.itu.int/rec/T-REC-G.722/",
"title": "G.722 : 7 kHz audio-coding within 64 kbit/s",
"publisher": "ITU"
},
"CloneArrayBuffer": {
"href": "https://tc39.es/ecma262/#sec-clonearraybuffer",
"title": "CloneArrayBuffer"
}
}
</pre>
Expand Down Expand Up @@ -422,16 +426,46 @@ dictionary RTCEncodedVideoFrameMetadata {

## <dfn interface>RTCEncodedVideoFrame</dfn> interface ## {#RTCEncodedVideoFrame-interface}
<pre class="idl">
dictionary RTCEncodedVideoFrameOptions {
RTCEncodedVideoFrameMetadata metadata;
};

// New interfaces to define encoded video and audio frames. Will eventually
// re-use or extend the equivalent defined in WebCodecs.
[Exposed=(Window,DedicatedWorker), Serializable]
interface RTCEncodedVideoFrame {
constructor(RTCEncodedVideoFrame originalFrame, optional RTCEncodedVideoFrameOptions options = {});
readonly attribute RTCEncodedVideoFrameType type;
attribute ArrayBuffer data;
RTCEncodedVideoFrameMetadata getMetadata();
};
</pre>

### Constructor ### {#RTCEncodedVideoFrame-members}
<dl dfn-for="RTCEncodedVideoFrame" class="dictionary-members">
<dt>
<dfn for="RTCEncodedVideoFrame" method>constructor()</dfn>
</dt>
<dd>
<p>
Creates a new {{RTCEncodedVideoFrame}} from the given |originalFrame| and
|options|.`[metadata]`. The newly created frame is completely independent of
|originalFrame|, with its `[[data]]` being a deep copy of |originalFrame|.`[[data]]`.
The new frame's `[[metadata]]` is a deep copy of |originalFrame|.`[[metadata]]`, with
fields replaced with deep copies of the fields present in |options|.`[metadata]`.

When called, run the following steps:

1. Set this.`[[type]]` to |originalFrame|.`[[type]]`.
1. Let this.`[[data]]` be the result of [[CloneArrayBuffer]](|originalFrame|.`[[data]]`, 0, |originalFrame|.`[[data]]`.`[[ArrayBufferByteLength]]`).
1. Let `[[metadata]]` represent the metadata associated with this newly constructed frame.
1. For each {`[[key]]`,`[[value]]`} pair of |originalFrame|.`[[getMetadata()]]`, set `[[metadata]]`.`[[key]]` to a deep copy of `[[value]]`.
1. For each {`[[key]]`,`[[value]]`} pair of |options|.`[metadata]`, set `[[metadata]]`.`[[key]]` to a deep copy of `[[value]]`.

</p>
</dd>
</dl>

### Members ### {#RTCEncodedVideoFrame-members}
<dl dfn-for="RTCEncodedVideoFrame" class="dictionary-members">
<dt>
Expand Down Expand Up @@ -624,13 +658,42 @@ dictionary RTCEncodedAudioFrameMetadata {

## <dfn interface>RTCEncodedAudioFrame</dfn> interface ## {#RTCEncodedAudioFrame-interface}
<pre class="idl">
dictionary RTCEncodedAudioFrameOptions {
RTCEncodedAudioFrameMetadata metadata;
};

[Exposed=(Window,DedicatedWorker), Serializable]
interface RTCEncodedAudioFrame {
constructor(RTCEncodedAudioFrame originalFrame, optional RTCEncodedAudioFrameOptions options = {});
attribute ArrayBuffer data;
RTCEncodedAudioFrameMetadata getMetadata();
};
</pre>

### Constructor ### {#RTCEncodedAudioFrame-members}
<dl dfn-for="RTCEncodedAudioFrame" class="dictionary-members">
<dt>
<dfn for="RTCEncodedAudioFrame" method>constructor()</dfn>
</dt>
<dd>
<p>
Creates a new {{RTCEncodedAudioFrame}} from the given |originalFrame| and
|options|.`[metadata]`. The newly created frame is completely independent of
|originalFrame|, with its `[[data]]` being a deep copy of |originalFrame|.`[[data]]`.
The new frame's `[[metadata]]` is a deep copy of |originalFrame|.`[[metadata]]`, with
fields replaced with deep copies of the fields present in |options|.`[metadata]`.

When called, run the following steps:

1. Let this.`[[data]]` be the result of [[CloneArrayBuffer]](|originalFrame|.`[[data]]`, 0, |originalFrame|.`[[data]]`.`[[ArrayBufferByteLength]]`).
1. Let `[[metadata]]` represent the metadata associated with this newly constructed frame.
1. For each {`[[key]]`,`[[value]]`} pair of |originalFrame|.`[[getMetadata()]]`, set `[[metadata]]`.`[[key]]` to a deep copy of `[[value]]`.
1. For each {`[[key]]`,`[[value]]`} pair of |options|.`[metadata]`, set `[[metadata]]`.`[[key]]` to a deep copy of `[[value]]`.

</p>
</dd>
</dl>

### Members ### {#RTCEncodedAudioFrame-members}
<dl dfn-for="RTCEncodedAudioFrame" class="dictionary-members">
<dt>
Expand Down