Movatterモバイル変換


[0]ホーム

URL:


MDN Web Docs

DedicatedWorkerGlobalScope: rtctransform event

Limited availability

Note: This feature is only available inDedicated Web Workers.

Thertctransform event is fired at a worker'sDedicatedWorkerGlobalScope object when an encoded video or audio frame has been queued for processing by aWebRTC Encoded Transform.

The event'stransformer property returns aRTCRtpScriptTransformer that exposes theReadableStream on which the frame is queued, and aWritableStream where the frame can be written to inject it back into the WebRTC pipeline.

This event is not cancellable and does not bubble.

Syntax

Use the event name in methods likeaddEventListener(), or set an event handler property.

js
addEventListener("rtctransform", (event) => { })onrtctransform = (event) => { }

Event type

Event properties

This interface also inherits properties from its parent,Event.

RTCTransformEvent.transformerRead only

Returns theRTCRtpScriptTransformer associated with the event.

Example

The following code snippet shows a handler for thertctransform event in the worker, added to the global scope usingaddEventListener().Theevent.transformer is aRTCRtpScriptTransformer, the worker side counterpart toRTCRtpScriptTransform.

js
addEventListener("rtctransform", (event) => {  let transform;  // Select a transform based on passed options  if (event.transformer.options.name === "senderTransform")    transform = createSenderTransform(); // A TransformStream  else if (event.transformer.options.name === "receiverTransform")    transform = createReceiverTransform(); // A TransformStream  else return;  // Pipe frames from the readable to writeable through TransformStream  event.transformer.readable    .pipeThrough(transform)    .pipeTo(event.transformer.writable);});

Thertctransform event is fired when an encoded frame is enqueued on theRTCRtpScriptTransformer and just once when the transformer's correspondingRTCRtpScriptTransformer is constructed.The code first determines what transform to apply usingname value passed in the options (this allowsRTCRtpScriptTransform instances added to the incoming and outgoing WebRTC pipelines to share a single worker).Encoded frames are then piped from the readable, through the selected transformTransformStream, to a writeable.The actual transforming code is not shown.

Note that this code is part of a more complete example provided inUsing WebRTC Encoded Transforms.

Specifications

Specification
WebRTC Encoded Transform
# dom-dedicatedworkerglobalscope-onrtctransform

Browser compatibility

See also

Help improve MDN

Learn how to contribute.

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp