-
Notifications
You must be signed in to change notification settings - Fork 22.9k
FF145 RTCEncodedVideoFrame/RTCEncodedAudioFrame constructors #41519
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
Merged
hamishwillee
merged 3 commits into
mdn:main
from
hamishwillee:ff145_rtcencodedvideoframe_serialize
Oct 23, 2025
Merged
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
files/en-us/web/api/rtcencodedaudioframe/rtcencodedaudioframe/index.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| --- | ||
| title: "RTCEncodedAudioFrame: RTCEncodedAudioFrame() constructor" | ||
| short-title: RTCEncodedAudioFrame() | ||
| slug: Web/API/RTCEncodedAudioFrame/RTCEncodedAudioFrame | ||
| page-type: web-api-constructor | ||
| browser-compat: api.RTCEncodedAudioFrame.RTCEncodedAudioFrame | ||
| --- | ||
|
|
||
| {{APIRef("WebRTC")}}{{AvailableInWorkers("window_and_dedicated")}} | ||
|
|
||
| The **`RTCEncodedAudioFrame()`** constructor creates a new and fully independent {{domxref("RTCEncodedAudioFrame")}} object. | ||
|
|
||
| The new object is a deep clone of the original object data and metadata, with any metadata specified in the options parameter overwriting the copied values. | ||
|
|
||
| ## Syntax | ||
|
|
||
| ```js-nolint | ||
| new RTCEncodedAudioFrame(originalFrame); | ||
| new RTCEncodedAudioFrame(originalFrame, options); | ||
| ``` | ||
|
|
||
| ### Parameters | ||
|
|
||
| - `originalFrame` | ||
| - : The frame to be copied. | ||
| - `options` {{optional_inline}} | ||
| - : This is an object with the following property: | ||
| - `metadata` {{optional_inline}} | ||
| - : An object setting the frame metadata. | ||
| This is object has the same properties as the object returned by {{DOMxRef("RTCEncodedAudioFrame.getMetadata()")}}. | ||
hamishwillee marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
hamishwillee marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ### Exceptions | ||
|
|
||
hamishwillee marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| - {{jsxref("TypeError")}} | ||
| - The source buffer is detached. | ||
| - {{jsxref("RangeError")}} | ||
| - The allocation is too large. | ||
|
|
||
| ## Examples | ||
|
|
||
| ### Cloning a frame with modified metadata | ||
|
|
||
| This snippet shows how you might copy a frame and modify its metadata. | ||
| In this case we just update the capture time. | ||
|
|
||
| ```js | ||
| // Frame is an incoming RTCEncodedAudioFrame | ||
| frame.getMetadata(); | ||
|
|
||
| const newFrame = new RTCEncodedAudioFrame(frame, { | ||
| metadata: { | ||
| captureTime: frame.metadata.captureTime + 3, | ||
| }, | ||
| }); | ||
| ``` | ||
|
|
||
| This kind of modification might be useful if you need to create multiple outgoing frames from a single incoming frame, for example in order to relay media to another peer on the network. | ||
hamishwillee marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| Generally you will not need to modify the metadata for a frame. | ||
|
|
||
| ## Specifications | ||
|
|
||
| {{Specifications}} | ||
|
|
||
| ## Browser compatibility | ||
|
|
||
| {{Compat}} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
files/en-us/web/api/rtcencodedvideoframe/rtcencodedvideoframe/index.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| --- | ||
| title: "RTCEncodedVideoFrame: RTCEncodedVideoFrame() constructor" | ||
| short-title: RTCEncodedVideoFrame() | ||
| slug: Web/API/RTCEncodedVideoFrame/RTCEncodedVideoFrame | ||
| page-type: web-api-constructor | ||
| browser-compat: api.RTCEncodedVideoFrame.RTCEncodedVideoFrame | ||
| --- | ||
|
|
||
| {{APIRef("WebRTC")}}{{AvailableInWorkers("window_and_dedicated")}} | ||
|
|
||
| The **`RTCEncodedVideoFrame()`** constructor creates a new and fully independent {{domxref("RTCEncodedVideoFrame")}} object. | ||
|
|
||
| The new object is a deep clone of the original object data and metadata, with any metadata specified in the options parameter overwriting the copied values. | ||
|
|
||
| ## Syntax | ||
|
|
||
| ```js-nolint | ||
| new RTCEncodedVideoFrame(originalFrame); | ||
| new RTCEncodedVideoFrame(originalFrame, options); | ||
| ``` | ||
|
|
||
| ### Parameters | ||
|
|
||
| - `originalFrame` | ||
| - : The frame to be copied. | ||
| - `options` {{optional_inline}} | ||
| - : This is an object with the following property: | ||
| - `metadata` {{optional_inline}} | ||
| - : An object setting the frame metadata. | ||
| This is object has the same properties as the object returned by {{DOMxRef("RTCEncodedVideoFrame.getMetadata()")}}. | ||
hamishwillee marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ### Exceptions | ||
|
|
||
| - {{jsxref("TypeError")}} | ||
| - The source buffer is detached. | ||
| - {{jsxref("RangeError")}} | ||
| - The allocation is too large. | ||
|
|
||
| ## Examples | ||
|
|
||
| ### Cloning a frame with modified metadata | ||
|
|
||
| This snippet shows how you might copy a frame and modify its metadata. | ||
| In this case we just update the capture time. | ||
|
|
||
| ```js | ||
| // Frame is an incoming RTCEncodedVideoFrame | ||
| frame.getMetadata(); | ||
|
|
||
| const newFrame = new RTCEncodedVideoFrame(frame, { | ||
| metadata: { | ||
| captureTime: frame.metadata.captureTime + 3, | ||
| }, | ||
| }); | ||
| ``` | ||
|
|
||
| This kind of modification might be useful if you need to create multiple outgoing frames from a single incoming frame, for example in order to relay media to another peer on the network. | ||
hamishwillee marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| Generally you will not need to modify the metadata for a frame. | ||
|
|
||
| ## Specifications | ||
|
|
||
| {{Specifications}} | ||
|
|
||
| ## Browser compatibility | ||
|
|
||
| {{Compat}} | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.