Minimal RTCSimpleConnection demo

Simple WebRTC

by jib1

HTML

<video id="video1" width="240" height="180" autoplay muted></video>
<video id="video2" width="240" height="180" autoplay></video><br>
<script src="https://webrtc.github.io/adapter/adapter-latest.js"></script>
<script src="https://rawgit.com/jan-ivar/localSocket/master/localSocket.js"></script>
<script src="https://rawgit.com/jan-ivar/simpleconnect/master/simpleconnect.js"></script>

JavaScript

var pc1 = new RTCSimpleConnection(null, new localSocket());
var pc2 = new RTCSimpleConnection(null, new localSocket());

navigator.mediaDevices.getUserMedia({video: true})
  .then(s => (pc1.addStream(video1.srcObject = s), pc1.connect()))
  .catch(e => log(e));

pc2.ontrack = e => video2.srcObject = e.streams[0];