title: How to addTrack in MediaStream in WebRTC
body: <p>I'm using webrtc to communicate between to peers. I wan't to add new track to old generated stream, as I wan't to give functionality to users to switch their microphones during audio communications. The code I'm using is,</p>
  
  <p>Let "pc" be the peerConnection object through which audio communication takes place &amp; "newStream" be the new generated MediaStream got from getUserMedia function with new selected microphone device.</p>
  
  <pre><code>            var localStreams = pc.getLocalStreams()[0];
              localStreams.removeTrack(localStreams.getAudioTracks()[0]);
  
  
              var audioTrack = newStream.getAudioTracks()[0];
              localStreams.addTrack(audioTrack);
  </code></pre>
  
  <p>Is their any way that the newly added track starts reaching to the other previously connected peer without offering him again the whole SDP?</p>
  
  <p>What would be the optimized way to use in such case of switch media device, i.e., microphones when the connections is already established between peers?</p>