Movatterモバイル変換


[0]ホーム

URL:


MDN Web Docs

RTCRtpScriptTransform: RTCRtpScriptTransform() constructor

Limited availability

TheRTCRtpScriptTransform() constructor creates a newRTCRtpScriptTransform object.

Constructing theRTCRtpScriptTransform creates a counterpartRTCRtpScriptTransformer in the specified worker, along with passed options (if any). Objects in the third parameter to the constructor are transferred.

Thertctransform event is then fired at the worker global object.Worker code can use theevent.transformer property to get the counterpartRTCRtpScriptTransformer, andevent.transformer.options is used to get the options.

Note that the options are primarily used to inform the worker whether the transformer is processing incoming or outgoing frames, so that it can apply an appropriate transform.

Syntax

js
new RTCRtpScriptTransform(worker)new RTCRtpScriptTransform(worker, options)new RTCRtpScriptTransform(worker, options, transfer)

Parameters

worker

AWorker, which will define code for one or more WebRTC transform streams.

optionsOptional

An arbitrary object that will be made available in the worker.This is most commonly used to inform the worker whether it injected into the WebRTC sender or receiver pipeline, and hence which transform should be applied.However it may also be used to send any other object, such as aMessagePort for communicating dynamically with the transformer.

transferOptional

An optionalarray oftransferable objects that will be transferred to the worker.After transfer, these objects are unusable in the main thread.

Exceptions

DataCloneErrorDOMException

Thrown if an object intransfer cannot be transferred.

Examples

The first example below shows construction of aRTCRtpScriptTransform that is then assigned to aRTCRtpSender.transform.The constructor takes an optional object with the propertyname andsenderTransform.The worker can use this option to understand when it is transforming encoded frames from the encoder (rather than incoming frames from the packetizer).

js
// Create a worker containing a TransformStreamconst worker = new Worker("worker.js");videoSender.transform = new RTCRtpScriptTransform(worker, {  name: "senderTransform",});

Any property name and value can be used in the options, as long as they can be serialized (andtransferred if specified in the last constructor parameter).The code below transfers the second port of aMessageChannel to the worker, which we might do in order to dynamically update transform code with (say) a new encryption key.

js
// Create a worker containing a TransformStreamconst worker = new Worker("worker.js");const channel = new MessageChannel();const transform = new RTCRtpScriptTransform(  worker,  { purpose: "encrypt", port: channel.port2 },  [channel.port2],);

Specifications

Specification
WebRTC Encoded Transform
# dom-rtcrtpscripttransform-rtcrtpscripttransform

Browser compatibility

See also

Help improve MDN

Learn how to contribute.

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp