-
-
Notifications
You must be signed in to change notification settings - Fork 361
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
Add PeerConnection::setConfiguration() method #920
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the PR, it looks good, basically my only comment is that I think setConfiguration()
should accept the configuration by value and move it instead of accepting a reference.
In order to fully support the WHIP stun/turn configuration I would need to add another change, but I am not sure exactly how to proceed. In browsers, the ICE gathering phase is started when the SLD is called, so the flow is as follows:
|
But in libdatachannel the createOffer and sLD are merged into a single method, so the flow is as follow:
The sLD call creates and starts the ICE transport, so not sure what happens to the ice gathering if there have not been any server specified in the config and if we can just update the ice servers before setting the set remote description and trigger the ice gathering phase or if we need to split the ICE transport creation (to get the offer) and the ICE transport start (to start the ICE gathering phase) in two phases. What do you think it is the best approach? |
@murillo128 Indeed libdatachannel features a simplified API where If I understand correctly, the WHIP flow in browsers prevents from transmitting ICE candidates from client to server, so you have to rely only on peer reflexive candidates on server-side. Is my understanding correct? In this case, it sounds like STUN servers won't make any difference as the server reflexive candidates will be ignored. Is this mechanism actually designed for TURN servers only? Currently ICE gathering starts on
Choosing this approach however makes this PR unnecessary. |
That is not exactly how WHIP is intended to work. WHIP servers are meant to be either on the same private network as the WHIP client or with an reachable public ip address. So the WHIP server will return an SDP answer containing the ICE candidates required by the WHIP client to connect to. In case that the client is behind a firewall, it will not be able to connect to the server ICE candidates, and that's were TURN helps. When the WHIP client gathers the TURN reflexive candidates, it should send a STUN request to the ICE candidates, so the WHIP server will learn dynamically about the client new candidate without even needing to signal it via a subsequent PATCH request. For completeness, the WHIP spec also allows the server to be behind a firewall (although I think this is an edge case), so that's when STUN makes sense. After exchanging the SDP O/A in the POST request, the WHIP client will send the gathered local candidates back to the WHIP server in an HTTP PATCH request. This way, the WHIP server can send back an STUN request to those candidates to open the NAT ports on its side. |
Regarding this PR, I think it still makes sense as one of the strong points of libdatachannel is that is has a similar API than the w3c one. So I would more prone of hiding the details internally. What would you think about this:
The behavior and apis would be quite similar to chrome/webrtc one (with the nits of missing createOffer/createAnswer) |
I have added an initial version of how updating the servers on |
I'm not really comfortable with fitting this in by changing the current behavior of sLD/sRD as I would break other people's use cases. For instance, users expect sLD to always start gathering and may rely on the gathering complete event to get the non-trickled description, and it is a perfectly normal use case to set no ICE servers when you know the peer is reachable. I'd also like to maintain a consistent behavior with datachannel-wasn, which calls the browser implementation under the hood. Updating the ice servers could indeed be done with In order to stick to an API closer to the W3C without requiring architectural changes, I think it could be a good compromise to add a |
I am fine for adding an flag for controlling if sLD triggerst the ice gathering or not, adding a new createOffer woiuld be ideal, although I would need more support from your side in order to understand the required changes. Regarding changing the rest of parameters in What we can do is to check if the configuration is actually changing any other parameter and raise an exception if so.
regarding turn dedup, are you performing any at the moment? what prevents a client inserting the same turn server twice? |
If I'm not mistaken, it would boil down to: namespace rtc {
string PeerConnection::createOffer() {
auto iceTransport = impl()->initIceTransport();
if (!iceTransport)
throw std::runtime_error("Peer connection is closed");
Description offer = iceTransport->getLocalDescription(Description::Type::Offer);
return impl()->populateLocalDescription(std::move(offer));
}
} where
This works for me!
Nothing prevents it, it should deduped in libjuice in the end (because otherwise the TURN server would get confused about the same client authentifying twice). I'm not sure about libnice though. |
e7aa166
to
0fc5365
Compare
@paullouisageneau I have updated this PR with your suggested API
|
d110c0c
to
653bb9b
Compare
f9abd05
to
bd64193
Compare
@paullouisageneau can I get another review please, thank you! |
When enabled PeerConnection::gatherLocalCandidates must be called explicitly to start the gathering process. This new API enabled ICE Servers to be used with WHIP/WHEP. For WHIP/WHEP the ICE Servers is only provided after the client makes the initial offer.
Ok last one I hope @paullouisageneau I think I got it this time :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the work, it will be great to introduce TURN support for WHIP/WHEP!
@paullouisageneau whats left for a new tag? I can take on the tasks! |
@Sean-Der I just released |
This PR allows changing the peerconnection configuration before the ICE transport has been inited on sLD or sRD.
This is needed in order to support setting the STUN/TURN servers received on the POST answer of a WHIP call.