api/easyrtc.js
function addStreamToPeerConnection(stream, peerConnection) {
       if( peerConnection.addStream ) {
           var existingStreams = peerConnection.getLocalStreams();
           if (existingStreams.indexOf(stream) === -1) {
              peerConnection.addStream(stream);
           }
       }
       else {
          var existingTracks = peerConnection.getSenders();
          var tracks = stream.getAudioTracks();
          var i;
          for( i = 0; i < tracks.length; i++ ) {
            if (existingTracks.indexOf(tracks[i]) === -1) {
             peerConnection.addTrack( tracks[i]);
            }
          }
          tracks = stream.getVideoTracks();
          for( i = 0; i < tracks.length; i++ ) {
            if (existingTracks.indexOf(tracks[i]) === -1) {
             peerConnection.addTrack( tracks[i]);
            }
          }
       }
    }
function addStreamToPeerConnection(stream, peerConnection) {
       if( peerConnection.addStream ) {
           var existingStreams = peerConnection.getLocalStreams();
           if (existingStreams.indexOf(stream) === -1) {
              peerConnection.addStream(stream);
           }
       }
       else {
          var existingTracks = peerConnection.getSenders();
          var tracks = stream.getAudioTracks();
          var i;
          for( i = 0; i < tracks.length; i++ ) {
            if (existingTracks.indexOf(tracks[i]) === -1) {
             peerConnection.addTrack( tracks[i]);
            }
          }
          tracks = stream.getVideoTracks();
          for( i = 0; i < tracks.length; i++ ) {
            if (existingTracks.indexOf(tracks[i]) === -1) {
             peerConnection.addTrack( tracks[i]);
            }
          }
       }
    }
function addStreamToPeerConnection ( stream , peerConnection ) { if ( peerConnection . addStream ) { var existingStreams = peerConnection . getLocalStreams ( ) ; if ( existingStreams . indexOf ( stream ) === - 1 ) { peerConnection . addStream ( stream ) ; } } else { var existingTracks = peerConnection . getSenders ( ) ; var tracks = stream . getAudioTracks ( ) ; var i ; for ( i = 0 ; i < tracks . length ; i ++ ) { if ( existingTracks . indexOf ( tracks [ i ] ) === - 1 ) { peerConnection . addTrack ( tracks [ i ] ) ; } } tracks = stream . getVideoTracks ( ) ; for ( i = 0 ; i < tracks . length ; i ++ ) { if ( existingTracks . indexOf ( tracks [ i ] ) === - 1 ) { peerConnection . addTrack ( tracks [ i ] ) ; } } } }
this private method handles adding a stream to a peer connection. chrome only supports adding streams, safari only supports adding tracks.
this private method handles adding a stream to a peer connection . chrome only supports adding streams safari only supports adding tracks .