How to use the sdp.getKind function in sdp

To help you get started, we’ve selected a few sdp examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github webrtcHacks / adapter / release / adapter.js View on Github external
sections.forEach(function(mediaSection, sdpMLineIndex) {
      var lines = SDPUtils.splitLines(mediaSection);
      var kind = SDPUtils.getKind(mediaSection);
      var rejected = SDPUtils.isRejected(mediaSection);
      var protocol = lines[0].substr(2).split(' ')[2];

      var direction = SDPUtils.getDirection(mediaSection, sessionpart);
      var remoteMsid = SDPUtils.parseMsid(mediaSection);

      var mid = SDPUtils.getMid(mediaSection) || SDPUtils.generateIdentifier();

      // Reject datachannels which are not implemented yet.
      if (kind === 'application' && protocol === 'DTLS/SCTP') {
        self.transceivers[sdpMLineIndex] = {
          mid: mid,
          isDatachannel: true
        };
        return;
      }
github legastero / stanza / src / jingle / sdp / Intermediate.ts View on Github external
const session: IntermediateSessionDescription = {
        groups: [],
        media: []
    };

    for (const groupLine of SDP.matchPrefix(sessionPart, 'a=group:')) {
        const parts = groupLine.split(' ');
        const semantics = parts.shift()!.substr(8);
        session.groups.push({
            mids: parts,
            semantics
        });
    }

    for (const mediaSection of mediaSections) {
        const kind = SDP.getKind(mediaSection);
        const isRejected = SDP.isRejected(mediaSection);
        const mLine = SDP.parseMLine(mediaSection);

        const media: IntermediateMediaDescription = {
            direction: SDP.getDirection(mediaSection, sessionPart),
            kind,
            mid: SDP.getMid(mediaSection),
            protocol: mLine.protocol
            // TODO: what about end-of-candidates?
        };

        if (!isRejected) {
            media.iceParameters = SDP.getIceParameters(mediaSection, sessionPart);
            media.dtlsParameters = SDP.getDtlsParameters(mediaSection, sessionPart);
            media.setup = SDP.matchPrefix(mediaSection, 'a=setup:')[0].substr(8);
        }
github webrtcHacks / adapter / src / js / edge / rtcpeerconnection_shim.js View on Github external
sections.forEach(function(mediaSection, sdpMLineIndex) {
      var lines = SDPUtils.splitLines(mediaSection);
      var kind = SDPUtils.getKind(mediaSection);
      var rejected = SDPUtils.isRejected(mediaSection);
      var protocol = lines[0].substr(2).split(' ')[2];

      var direction = SDPUtils.getDirection(mediaSection, sessionpart);
      var remoteMsid = SDPUtils.parseMsid(mediaSection);

      var mid = SDPUtils.getMid(mediaSection) || SDPUtils.generateIdentifier();

      // Reject datachannels which are not implemented yet.
      if (kind === 'application' && protocol === 'DTLS/SCTP') {
        self.transceivers[sdpMLineIndex] = {
          mid: mid,
          isDatachannel: true
        };
        return;
      }
github webrtcHacks / adapter / release / adapter_no_global.js View on Github external
sections.forEach(function(mediaSection, sdpMLineIndex) {
      var lines = SDPUtils.splitLines(mediaSection);
      var kind = SDPUtils.getKind(mediaSection);
      var rejected = SDPUtils.isRejected(mediaSection);
      var protocol = lines[0].substr(2).split(' ')[2];

      var direction = SDPUtils.getDirection(mediaSection, sessionpart);
      var remoteMsid = SDPUtils.parseMsid(mediaSection);

      var mid = SDPUtils.getMid(mediaSection) || SDPUtils.generateIdentifier();

      // Reject datachannels which are not implemented yet.
      if (kind === 'application' && protocol === 'DTLS/SCTP') {
        self.transceivers[sdpMLineIndex] = {
          mid: mid,
          isDatachannel: true
        };
        return;
      }
github open-webrtc-toolkit / owt-client-javascript / src / dependencies / adapter.js View on Github external
sections.forEach(function(mediaSection, sdpMLineIndex) {
      var lines = SDPUtils.splitLines(mediaSection);
      var kind = SDPUtils.getKind(mediaSection);
      var rejected = SDPUtils.isRejected(mediaSection);
      var protocol = lines[0].substr(2).split(' ')[2];

      var direction = SDPUtils.getDirection(mediaSection, sessionpart);
      var remoteMsid = SDPUtils.parseMsid(mediaSection);

      var mid = SDPUtils.getMid(mediaSection) || SDPUtils.generateIdentifier();

      // Reject datachannels which are not implemented yet.
      if (kind === 'application' && protocol === 'DTLS/SCTP') {
        self.transceivers[sdpMLineIndex] = {
          mid: mid,
          isDatachannel: true
        };
        return;
      }
github aws / connect-rtc-js / src / js / utils.js View on Github external
export function transformSdp(sdp, sdpOptions) {
    var sections = splitSections(sdp);
    for (var i = 1; i < sections.length; i++) {
        var mediaType = getKind(sections[i]);
        var rtpParams = parseRtpParameters(sections[i]);
        // a map from payload type (string) to codec object
        var codecMap = rtpParams.codecs.reduce((map, codec) => {
            map['' + codec.payloadType] = codec;
            return map;
        }, {});
        sections[i] = splitLines(sections[i]).map(line => {
            if (line.startsWith('m=')) {
                // modify m= line if SdpOptions#forceCodec specifies codec for current media type
                if (sdpOptions.forceCodec[mediaType]) {
                    var targetCodecPts = Object.keys(codecMap).filter(pt => !sdpOptions._shouldDeleteCodec(mediaType, codecMap[pt].name));
                    return /.*RTP\/S?AVPF? /.exec(line) + targetCodecPts.join(' ');
                } else {
                    return line;
                }
            } else if (line.startsWith('a=rtpmap:')) {
github fippo / testbed / unified.js View on Github external
.then(answer => {
    const sections = SDPUtils.splitSections(answer.sdp);
    t.ok(sections.length === 4, 'answer contains a session part and three mediaSections');
    t.ok(SDPUtils.getKind(sections[1]) === 'audio', 'first mediaSection is audio');
    t.ok(SDPUtils.getKind(sections[2]) === 'video', 'second mediaSection is video');
    t.ok(SDPUtils.getKind(sections[3]) === 'video', 'third mediaSection is video');
    return clientB.setLocalDescription(answer);
  })
  .then(answerWithCandidates => clientA.setRemoteDescription(answerWithCandidates))