Re: [webrtc-encoded-transform] Generalize ScriptTransform constructor to allow main-thread processing (#89)

@alvestrand thanks I appreciate its illustrative power of our gap. But we can polyfill that.

Providing a polyfill shaped like you propose would take me a bit longer (making the transform a bona fide EventListener), but here's a [fiddle](https://jsfiddle.net/jib1/bf92opjh/) showing main-thread access in today's API (modulo [bug 1868223](bugzil.la/1868223)):
```js
const bouncer = new Worker(`data:text/javascript,(${bounce.toString()})()`);
function bounce() {
  onrtctransform = async ({transformer: {readable, writable}}) =>
    self.postMessage({transformer: {readable, writable}}, [readable, writable]);
}
```
To use this bouncer:
```js
sender.transform = new RTCRtpScriptTransform(bouncer, {});
const event = await new Promise(r => bouncer.onmessage = r);
```

-- 
GitHub Notification of comment by jan-ivar
Please view or discuss this issue at https://github.com/w3c/webrtc-encoded-transform/issues/89#issuecomment-1839577075 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Monday, 4 December 2023 22:15:38 UTC