Re: [webrtc-encoded-transform] Rename RTCRtpScriptTransform object (#216)

> My issue with the naming is that we have two objects (Transform and Transformer) that are both Web platform APIs, with very different responsibilities, but both controlling the user's Javascript function that we conventionally call a "transform".
> 
> That's 3 objects close to each other where the names are almost impossible to not confuse. We shouldn't do that.

That's one constructor, one event attribute, and one app function. They're only _"objects"_ in the most confusing sense.

The spec could perhaps do a better of job introducing concepts, but any confusion seems to disappear in [actual code](https://jsfiddle.net/jib1/wb2c0hr1/):
```js
// main.js
sender.transform = new RTCRtpScriptTransform(worker, {side: "sender"});
```
...on main, transform = transform.

```js
// worker.js
onrtctransform = async ({transformer: {readable, writable, options}}) => {
    await readable.pipeThrough(new TransformStream({transform})).pipeTo(writable);
    function transform(chunk, controller) { ... }
```
...over on worker, we react to an `rtctransform` event given a `transformer` object, much like a JS-driven stream is given a `controller`. I.e. _the transformer is the controller for the transform_.

This somewhat mimics the duality of the streams spec which separates an outside control surface from an inside controller surface. We're leveraging this split further by "outside" being on main thread, and "inside" on the worker.

Note: anything after the `await` above is app specific, and its use of `transform` is idiomatic with its use of [TransformStream](https://streams.spec.whatwg.org/#ts-class) in this example. It can of course call this function anything it likes.

This may be an issue with reading the spec more than anything else.

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


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

Received on Monday, 18 December 2023 18:22:00 UTC