2
votes

I'm trying to learn how to use webRTC in applications so I wrote a code sample available in the following link: http://wklej.org/hash/fd599a32e8e/

At the beginning I need to say that I don't care about browsers compatibility, All I need is to support Chromium web engine without any external adapters/other libraries.

The web application should allow me to establish a connection between two browser tabs running on the same host — by manually exchange of appropriate data (SDP and ICE candidates).

Steps to follow:

  1. Click on "create offer button", copy local SDP;
  2. Go to other tab and insert previously copied SDP into "remote SDP" area, then press "create answer";
  3. Copy generated local SDP, go to first tab, insert into "remote SDP" area and click on "set remote sdp" button (not create answer button);
  4. Exchange ice candidates — copy them from one tab, insert to the second one and press "addCandidates" button. Do the same in the other way.

The main problem is that this function:

peer.iceconnectionstatechange = function(event) {
    console.log("ice connection state: " + peer.iceConnectionState)
}

won't be triggered. I tried to play with STUN/TURN servers without success. The remote video won't run. If somebody could point out where I made mistake?

1
The create answer button does nothing following your steps ?Roko C. Buljan
yes it does, the create answer button takes offerer sdp which has been copied from the first tab. It tries to set it as remote descriptor and then create an answer which has to be used as remote sdp in the first tab (step 2 and 3)krzysztof
the TURN servers you use are probably from some tutorial that claims that you can use those credentials, right? Those credentials don't work because nobody is going to give you access to their TURN servers for free. Try the credentials here, you will see that you don't get any candidates with type=relayPhilipp Hancke

1 Answers

3
votes

Try mine (cut'n'paste): https://jsfiddle.net/7vv2vxtt/

Or automatic (localStorage): https://jsfiddle.net/2v1Lnpmx/

This code intentionally left blank.

ICE candidates get added to the local offer/answer over time, so it simply waits for end-of-candidates before producing SDP with all candidates embedded.

Should work in all browsers.