-
-
Notifications
You must be signed in to change notification settings - Fork 237
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
minimizing signaling round trips required to set up connections #164
Comments
While having the DTLS parameters in advance may help reducing a round-trip, this is not implemented in all WebRTC clients, and AFAIK there is not way to get ICE parameters until you add a track or DataChannel into it. As you say, it does not work in Firefox, which proves what I say. I'm open to consider this improvements but we need to provide a unified API that works in all modern and recent WebRTC clients. |
Huh; but that isn't what I said? I said that Firefox doesn't implement .getFingerprints(), but that we definitely don't need that to make this work... I even offered to port it to Firefox. (I guess I should maybe take your response as a challenge? ;P)
The current architecture of mediasoup doesn't actually use ICE parameters from the client (and hence why I was able to not just claim this worked, but actually implement it quickly). Are you intending to change this (I'd probably find that exciting)? FWIW, the minimal concrete request I'd thereby have could just be "can there be a way to get un-sanitized additionalSettings through createRecvTransport?" as that would potentially be useful for other purposes in addition to reducing round trips. |
Do you mean implementing
That's right, but in case we eventually move mediasoup to full ICE (instead of ICE-Lite) then we are gonna need client's ICE parameters, and those are just generated after adding the first track or DataChannel into the PeerConnerction.
"Un-sanitized" means that, for instance, TypeScript won't catch type errors. Not sure why we need un-sanitized (so TypeScript Regarding the main proposal here (if I'right), saving a round-trip for signaling DTLS parameters to the server:
|
No... so, I'm saying I can make the code work on Firefox, in JavaScript, quite easily using the way I described: creating a dummy peer connection. This is a "weird" way to do it, but I'd bet I can do even better--just screwing around with the one peer connection--if I have a chance to mess with the original RTCPeerConnection object (which I can't do sitting outside the mediasoup-client API). (That said, I'm pretty sure Firefox has said they intend to implement .getFingerprints().)
According to MDN, both RTCCertificate and .getFingerprints() has been supported on iOS Safari since iOS 12.2. https://developer.mozilla.org/en-US/docs/Web/API/RTCCertificate
Here: I've updated the proof of concept at saurik/mediasoup-sample-app@roundtrips to use a way of doing this which avoids .getFingerprints(); the core code is just the following (with the if statement to show the old version using .getFingerprints() and the new version using SDP parsing). Again, I will repeat: if I were "inside" mediasoup-client's handler, I'd bet (but am not 100% sure) I could avoid the extra peer connection. var dtlsParameters;
if (true) {
const peer = new RTCPeerConnection({ certificates: [certificate] });
await peer.createDataChannel({});
const fingerprint = (await peer.createOffer()).sdp.match(/a=fingerprint:([^ ]*) ([:0-9A-Fa-f]*)/);
dtlsParameters = { role: 'client', fingerprints: [{ algorithm: fingerprint[1], value: fingerprint[2] }] };
} else {
dtlsParameters = { role: 'client', fingerprints: certificate.getFingerprints() };
dtlsParameters.fingerprints[0].value = dtlsParameters.fingerprints[0].value.toUpperCase();
}
Is it not possible to add a data channel to the peer connectionto get the ICE parameters to be built, and then add the media tracks later? (FWIW, I'd totally believe that that isn't possible, but I'd like to think that that is possible; I honestly wish very deeply that every mediasoup transport supported simultaneous data channel production/consumption--I appreciate the issues for media tracks, but would hope they don't apply to data channels--but that's a different sadness.)
Yeah, so the issue is that I need |
You can fork mediasoup-client for development purposes.
As you noticed, we don't need local ICE parameters if mediasoup remains being ICE Lite, so we are safe here. Otherwise, if we made mediasoup full ICE, we are not gonna create a fake
We don't need to pass Coming back to the origin of the topic, I agree there is room for improvement and I'll consider passing |
Hello! I've recently begun looking at mediasoup in some level of earnestness, and one of the things I've noticed is that setting up a connection--let's say a consumer--involves a number of round-trips to the server, which causes quite a bit of delay in receiving the video feed.
The steps in one random nicely-simple demo that I found (a weird one, though, which carries some "state" on the server) seems to be the following four requests (still for the consumer), which "adds up" and causes a noticeable delay when clicking the "subscribe" button.
FWIW, I feel like the first two of these being separate steps might just be the random demo I found being "naive", but the API surface of mediasoup-client seems to really want that third step to be separate: it doesn't give you the dtls parameters until after you give it the rtp parameters.
Only, that's not a requirement of the WebRTC API: it is totally possible to get the fingerprints required for DTLS before having an offer in hand. (FWIW, Firefox doesn't support RTCCertificate.getFingerprints, but "worst case" you can create a dummy peer connection and parse its offer.)
I've thereby put together a "proof of concept" in the form of a fork of that random demo I found with a commit on a branch to show how to get the interaction with the server down to a single signaling round-trip for the consumer: saurik/mediasoup-sample-app@roundtrips
The one problem I ran into with this proof-of-concept in the existing mediasoup-client is that it takes the "additionalSettings" parameter and "sanitizes" it through utils.clone, which prevents me from smuggling an RTCCertificate object through the certificates array. The hack for that in Transport.ts:
Is better supporting this architecture something you'd consider for mediasoup{,-client}? For the consumer, arguably the minimum required would involve providing some way to pass through un-sanitized arguments to the RTCPeerConnection (so I could do it like this proof of concept).
But for the producer, I believe a different API is required, even though it is way more obvious why the producer should only need a single round trip :(... the client should be able to send the dtls fingerprint and rtp parameters at the same time, but it doesn't have a way to get the rtp parameters until after you have the remote ice candidates, which clearly isn't something the client actually needs to calculate those: it should only need the server's rtp capabilities. To fix this would seem to require a more different API of some kind (I haven't bothered to put any thought into what I'd personally do for this yet, as I'm kind of hoping that seeing that this is possible is "inspiring" enough ;P).
(If you need me to prove I can make this kind of flow work in Firefox without .getFingerprints()--potentially with deeper changes to the setup of the RTCPeerConnection, as I'd probably prefer to avoid creating a temporary RTCPeerConnection just to pull the fingerprints--I'd be happy to do that.)
The text was updated successfully, but these errors were encountered: