WEBRTC unable to fetch remote video and also don't know how to make it between two browser

34 views
Skip to first unread message

deepesh yadav

unread,
Jul 22, 2016, 7:14:33 AM7/22/16
to discuss-webrtc

I am trying to make a video call web app on local server and my task is to make video call on local server between two different browser. Currently i am stuck on two point

  1. iam unable to reterive the remote stream
  2. secondly dont know how can i make this when it is called from different browser (same call)

My code is as follow

<video  src="" id="localVideo"></video>
<video  src="" id="remoteVideo"></video>

<input type="button" id="start" value="Start">
<input type="button" id="call"  value="Call">
<input type="button" id="hangup" value="Hang Up">
<script src="jquery-min.js"></script>
var localStream;
var gotRemoteStream;
var localPeerConnection;
var remotePeerConnection;
navigator.getUserMedia  = navigator.getUserMedia ||
         navigator.webkitGetUserMedia ||
         navigator.mozGetUserMedia ||
         navigator.msGetUserMedia;
$("#start").click(function(){
          navigator.getUserMedia({video: true, audio: true},                                                    function(localMediaStream) {
                  localStream=localMediaStream;
                  var src=window.URL.createObjectURL(localMediaStream);
                  $("#localVideo").attr('src',src);
                  $("#localVideo").attr('autoplay',true);

            }
          , function(e){
                  console.log(e);});

        });

$("#call").click(function(){
        localPeerConnection=new webkitRTCPeerConnection(null);
        localPeerConnection.addStream(localStream);
        console.log('called');
        localPeerConnection.createOffer(gotLocalDescription);

          remotePeerConnection =
            new webkitRTCPeerConnection(null);  // eslint-disable-line new-cap
          remotePeerConnection.onaddstream = gotRemoteStream;
        console.log('Offer called');


        });


function gotLocalDescription(description) {
  localPeerConnection.setLocalDescription(description);
  trace('Offer from localPeerConnection: \n' + description.sdp);
  remotePeerConnection.setRemoteDescription(description);
  remotePeerConnection.createAnswer(gotRemoteDescription);
}
 function remoteStream(stream){

                var src=window.URL.createObjectURL(stream);
                  $("#remoteVideo").attr('src',src);
                  localPeerConnection.createOffer(gotLocalDescription);
        }

        function gotLocalDescription(description) {
          localPeerConnection.setLocalDescription(description);
          trace('Offer from localPeerConnection: \n' + description.sdp);
          remotePeerConnection.setRemoteDescription(description);
          remotePeerConnection.createAnswer(gotRemoteDescription);
        }

        function createOffer1(){
                console.log('waiting for offer');

                }

Eric Davies

unread,
Jul 22, 2016, 2:10:15 PM7/22/16
to discuss-webrtc
You have missed an important concept, the signalling server.
When one web app creates an offer, in addition to applying that offer to its own peer connection, it has to pass that offer to the remote web app so that it can apply the offer to the remote peers's own peer connection. Similarly with answers and candidates. Typically, those offers/answers/candidates are passed from one webapp to the other via server (the signalling server) using websockets, but that is up to you to provide.

Christoffer Jansson

unread,
Jul 25, 2016, 3:20:09 AM7/25/16
to discuss-webrtc

--

---
You received this message because you are subscribed to the Google Groups "discuss-webrtc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to discuss-webrt...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/discuss-webrtc/71cf640b-fd55-49c5-8d3d-3aa347a9ed40%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
/Chris
Reply all
Reply to author
Forward
0 new messages