ICE loopback

by juberti

HTML

<html>
<body>
<div>
<label id="rtt"></label>
</div>
</body>
</html>

JavaScript

var localConnection;

setTimeout(createConnection, 0);

function trace(x) {
  console.log(x);
}

function createConnection() {
  var config = {};
  // SCTP is supported from Chrome 31 and is supported in FF.
  // No need to pass DTLS constraint as it is on by default in Chrome 31.
  // For SCTP, reliable and ordered is true by default.
  // Add localConnection to global scope to make it visible from the browser console.
  localConnection =
      new RTCPeerConnection(config, {   optional: [ {DtlsSrtpKeyAgreement: false}]});
  trace('Created local peer connection object localConnection');
  localConnection.addTransceiver('audio');
  localConnection.createOffer().then(sd => trace(sd.sdp));
}