I'm building a web app for cam broadcasting. I'm using Django for web app and coturn as (STUN/TURN) signalling server. My goal is to do it with WebRTC.
I don't know how to connect a peer to the signalling server in order to be reachable by other peer. So what I need to know is how to stablish "PeerConnection". In web application, I have all I need (I think): user.id, shared secret, signalling server IP and port, ... But I don't know how to mix it in HTML JS scripts to connect with coturn server.
I've read coturn server docs and searched for some examples but can't find examples for this part.
Can anybody show me an a example?
I think you are bit confused, coturn
is not a signalling server, it is a TURN/ STUN server.
Signalling server is something though which you exchange sdp, ice candidates and other data between the peers before they get a direct peer to peer connection, coturn
does not do that.
I cannot explain all the bits, but gist is STUN is used for providing public IP of a peer, and TURN is used for a proxy point for transmitting and receving data from a peer when it cannot be directly accessed, and in most cases all you require is a STUN server. The only time they get involved in your WebRTC application is when you create the PeerConnection
object, you pass the STUN/TURN server details in the config object, example:
let pc = new RTCPeerConnection({
"iceServers": [
{"urls": "stun:example.com"}, // STUN Server address
{"urls": "turn:example.com", "credential": "test", "username": "test"} // TURN Server address
]
});