const worker = new Worker("worker.js");
const channel = new MessageChannel();
videoReceiver.transform = new RTCRtpScriptTransform(
worker,
{ name: "receiverTransform", port: channel.port2 },
[channel.port2],
);
// Post new key to the receiver
channel.port1.start();
channel.port1.postMessage({
key: "93ae0927a4f8e527f1gce6d10bc6ab6c",
});RTCRtpScriptTransformer: sendKeyFrameRequest() method
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.
event.transformer.options.port.onmessage = (event) => {
const { key } = event.data;
// key is used by the transformer to decrypt frames (not shown)
// Request sender to emit a key frame.
// Here 'rcEvent' is the rtctransform event.
rcEvent.transformer.sendKeyFrameRequest();
};