title: Unable to change camera / stream for WebRTC call
body: <p>Source: <a href="https://github.com/anoek/webrtc-group-chat-example/blob/master/client.html" rel="nofollow noreferrer">https://github.com/anoek/webrtc-group-chat-example/blob/master/client.html</a></p>
  
  <p>I'm trying to modify this Webrtc example to add the ability of changing camera (Cross-browser support).</p>
  
  <p>Normal usage works perfectly, after changing camera, failed in renegotiation.</p>
  
  <p>1) Get a list of devices via <code>navigator.mediaDevices.enumerateDevices()</code></p>
  
  <p>2) Change local_media_stream after getting new stream</p>
  
  <pre><code>local_media_stream.getTracks().forEach(function(track) {
      track.stop();
  });
  local_media_stream = stream; 
  </code></pre>
  
  <p>3) Trigger renegotiation function (Copied from line 132 of Source code)</p>
  
  <pre><code>function renegotiate(){
      console.log("Creating RTC offer to ", peer_id);
      peer_connection.createOffer(
                      function (local_description) { 
                          console.log("Local offer description is: ", local_description);
                          peer_connection.setLocalDescription(local_description,
              function() { 
                  signaling_socket.emit('relaySessionDescription', 
                      {'peer_id': peer_id, 'session_description': local_description});
                  console.log("Offer setLocalDescription succeeded"); 
              },
              function() { Alert("Offer setLocalDescription failed!"); }
          );
      },
      function (error) {
          console.log("Error sending offer: ", error);
      });
  };
  </code></pre>
  
  <p>I believe that my approaches are wrong, but I've tried many different ways found on google to edit the codes for renegotiation, however I'm not familiar to WebRTC and Socket.io, still can't make the thing works.</p>
  
  <p>After changing the camera, the video shown on other participant just became a static image from video last frame.</p>
  
  <p>Can anybody please help to point my mistake? Thanks in advance.</p>