demo · v141

Encoded Transform V2

Set up a loopback peer connection, attach an Encoded Transform that XOR-stamps every video frame, and watch frame counts climb in real time. The probe surfaces the V2 surface (RTCRtpScriptTransform with a Worker) and falls back to the older event-style API when needed.

probing RTCRtpScriptTransform…

frames seen (sender)

frames seen (receiver)

last bytes

No session running.

the call (V2)

// Spawn a worker, hand it a script transform, and the encoded RTP frames
// stream through readable/writable in the worker thread.
const worker = new Worker("./xform.js");
sender.transform   = new RTCRtpScriptTransform(worker, { side: "sender" });
receiver.transform = new RTCRtpScriptTransform(worker, { side: "receiver" });

// inside xform.js:
self.onrtctransform = (event) => {
  const { readable, writable } = event.transformer;
  readable.pipeTo(new WritableStream({
    write(frame) { /* mutate frame.data */; writable.getWriter().write(frame); },
  }));
};

see also