Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update endpoint pair example and fix citation #1318

Merged
merged 6 commits into from
Jul 12, 2024

Conversation

jan-ivar
Copy link
Contributor

@jan-ivar jan-ivar commented Jul 9, 2024

Fixes #1317 (editorial).


Preview | Diff

Copy link
Collaborator

@ricea ricea left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. lgtm.

readable.pipeThrough(new TransformStream(...)).pipeTo(writable);
async function handleTransformer({readable, writable}) {
await readable.pipeThrough(new TransformStream(...)).pipeTo(writable);
}
</xmp>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This example has been simplified a bit too much I think. It talks about a platform-provided Transformer interface but that interface is now super-implicit, because of the destructuring of function arguments. I think reverting to something like

const { readable, writable } = createTransformer();
readable.pipeThrough(new TransformStream(...)).pipeTo(writable);

would work better.

Additionally, the point of createEndpointPair() was to match the official name given in the standard, "endpoint pair". So I think that that was even better.

Can you say more about why you changed this example?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I read "web-platform-provided function createEndpointPair()" as a callout to the same-shaped sender.createEncodedStreams() method removed in w3c/webrtc-encoded-transform#64.

I was trying to maintain this similarity to the API it's referencing. But the spec's worker-only API is different. From MDN and blog post examples:

// main.html
const worker = new Worker("worker.js");
sender.transform = new RTCRtpScriptTransform(worker);

// worker.js
onrtctransform = async ({transformer: {readable, writable}}) => {
  await readable.pipeThrough(new TransformStream(...)).pipeTo(writable);
};

The spec fires an event with the transformer which has no constructor. The event part seemed unnecessary but I can try to add it if the context is useful.

Copy link
Member

@domenic domenic Jul 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, this seems to have gone in the opposite direction of what I'm requesting. The point of this example is not to reference any other API. (That's the purpose of the note below, which you helpfully edited for accuracy.) It's to give an example of the simplest possible concept of an endpoint pair, i.e. a platform-provided API that returns a { readable, writable } object.

The naming is especially important, as we're trying to illustrate the "endpoint pair" concept defined above, not some sort of "transformer" concept which this document does not define.

Can you revert it to its previous version?

Copy link
Member

@domenic domenic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much!

@domenic domenic merged commit f63ec41 into whatwg:main Jul 12, 2024
3 checks passed
@jan-ivar jan-ivar deleted the endpointpair branch July 12, 2024 14:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

WebRTC endpoint pair example is out of date
3 participants