vendor/opentok.js
function removeMediaEncoding (sdp, mediaType, encodingName) {
      var sdpLines = sdp.split('\r\n'),
          mLineIndex = SDPHelpers.getMLineIndex(sdpLines, mediaType),
          mLine = mLineIndex > -1 ? sdpLines[mLineIndex] : void 0,
          typesToRemove = [],
          payloadTypes,
          match;

      if (mLineIndex === -1) {
        // Error, missing M line
        return sdpLines.join('\r\n');
      }

      // Get all payload types that the line supports
      payloadTypes = SDPHelpers.getMLinePayloadTypes(mLine, mediaType);
      if (payloadTypes.length === 0) {
        // Error, invalid M line?
        return sdpLines.join('\r\n');
      }

      // Find the location of all the rtpmap lines that relate to +encodingName+
      // and any of the supported payload types
      var matcher = new RegExp('a=rtpmap:(' + payloadTypes.join('|') + ') ' +
                                            encodingName + '\\/\\d+', 'i');

      sdpLines = OT.$.filter(sdpLines, function(line, index) {
        match = line.match(matcher);
        if (match === null) return true;

        typesToRemove.push(match[1]);

        if (index < mLineIndex) {
          // This removal changed the index of the mline, track it
          mLineIndex--;
        }

        // remove this one
        return false;
      });

      if (typesToRemove.length > 0 && mLineIndex > -1) {
        // Remove all the payload types and we've removed from the media line
        sdpLines[mLineIndex] = SDPHelpers.removeTypesFromMLine(mLine, typesToRemove);
      }

      return sdpLines.join('\r\n');
    }
function removeMediaEncoding (sdp, mediaType, encodingName) {
      var sdpLines = sdp.split('\r\n'),
          mLineIndex = SDPHelpers.getMLineIndex(sdpLines, mediaType),
          mLine = mLineIndex > -1 ? sdpLines[mLineIndex] : void 0,
          typesToRemove = [],
          payloadTypes,
          match;

      if (mLineIndex === -1) {
        // Error, missing M line
        return sdpLines.join('\r\n');
      }

      // Get all payload types that the line supports
      payloadTypes = SDPHelpers.getMLinePayloadTypes(mLine, mediaType);
      if (payloadTypes.length === 0) {
        // Error, invalid M line?
        return sdpLines.join('\r\n');
      }

      // Find the location of all the rtpmap lines that relate to +encodingName+
      // and any of the supported payload types
      var matcher = new RegExp('a=rtpmap:(' + payloadTypes.join('|') + ') ' +
                                            encodingName + '\\/\\d+', 'i');

      sdpLines = OT.$.filter(sdpLines, function(line, index) {
        match = line.match(matcher);
        if (match === null) return true;

        typesToRemove.push(match[1]);

        if (index < mLineIndex) {
          // This removal changed the index of the mline, track it
          mLineIndex--;
        }

        // remove this one
        return false;
      });

      if (typesToRemove.length > 0 && mLineIndex > -1) {
        // Remove all the payload types and we've removed from the media line
        sdpLines[mLineIndex] = SDPHelpers.removeTypesFromMLine(mLine, typesToRemove);
      }

      return sdpLines.join('\r\n');
    }
function removeMediaEncoding ( sdp , mediaType , encodingName ) { var sdpLines = sdp . split ( '\r\n' ) , mLineIndex = SDPHelpers . getMLineIndex ( sdpLines , mediaType ) , mLine = mLineIndex > - 1 ? sdpLines [ mLineIndex ] : void 0 , typesToRemove = [ ] , payloadTypes , match ; if ( mLineIndex === - 1 ) { // Error, missing M line return sdpLines . join ( '\r\n' ) ; } // Get all payload types that the line supports payloadTypes = SDPHelpers . getMLinePayloadTypes ( mLine , mediaType ) ; if ( payloadTypes . length === 0 ) { // Error, invalid M line? return sdpLines . join ( '\r\n' ) ; } // Find the location of all the rtpmap lines that relate to +encodingName+ // and any of the supported payload types var matcher = new RegExp ( 'a=rtpmap:(' + payloadTypes . join ( '|' ) + ') ' + encodingName + '\\/\\d+' , 'i' ) ; sdpLines = OT . $ . filter ( sdpLines , function ( line , index ) { match = line . match ( matcher ) ; if ( match === null ) return true ; typesToRemove . push ( match [ 1 ] ) ; if ( index < mLineIndex ) { // This removal changed the index of the mline, track it mLineIndex -- ; } // remove this one return false ; } ) ; if ( typesToRemove . length > 0 && mLineIndex > - 1 ) { // Remove all the payload types and we've removed from the media line sdpLines [ mLineIndex ] = SDPHelpers . removeTypesFromMLine ( mLine , typesToRemove ) ; } return sdpLines . join ( '\r\n' ) ; }
Remove all references to a particular encodingName from a particular media type
Remove all references to a particular encodingName from a particular media type