How to use the sdp-transform.parseParams function in sdp-transform

To help you get started, we’ve selected a few sdp-transform 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 mbullington / yellowstone / lib / transports / H264Transport.ts View on Github external
processConnectionDetails(details: Details) {
    // Extract SPS and PPS from the MediaSource part of the SDP
    const fmtp = (details.mediaSource.fmtp as any)[0];
    
    if (!fmtp) {
      return;
    }
  
    const fmtpConfig = transform.parseParams(fmtp.config);
    const splitSpropParameterSets = fmtpConfig['sprop-parameter-sets'].toString().split(',');
    const sps_base64 = splitSpropParameterSets[0];
    const pps_base64 = splitSpropParameterSets[1];
    const sps = new Buffer(sps_base64, "base64");
    const pps = new Buffer(pps_base64, "base64");

    this.stream.write(H264_HEADER);
    this.stream.write(sps);
    this.stream.write(H264_HEADER);
    this.stream.write(pps);

    this._headerWritten = true;
  };
github mbullington / yellowstone / dist / transports / H264Transport.js View on Github external
processConnectionDetails(details) {
        // Extract SPS and PPS from the MediaSource part of the SDP
        const fmtp = details.mediaSource.fmtp[0];
        if (!fmtp) {
            return;
        }
        const fmtpConfig = transform.parseParams(fmtp.config);
        const splitSpropParameterSets = fmtpConfig['sprop-parameter-sets'].toString().split(',');
        const sps_base64 = splitSpropParameterSets[0];
        const pps_base64 = splitSpropParameterSets[1];
        const sps = new Buffer(sps_base64, "base64");
        const pps = new Buffer(pps_base64, "base64");
        this.stream.write(H264_HEADER);
        this.stream.write(sps);
        this.stream.write(H264_HEADER);
        this.stream.write(pps);
        this._headerWritten = true;
    }
    ;
github versatica / mediasoup-client / src / handlers / sdp / commonUtils.ts View on Github external
if (!rtp)
			continue;

		// Just in case.
		answerMediaObject.fmtp = answerMediaObject.fmtp || [];

		let fmtp = answerMediaObject.fmtp
			.find((f: { payload: any }) => f.payload === codec.payloadType);

		if (!fmtp)
		{
			fmtp = { payload: codec.payloadType, config: '' };
			answerMediaObject.fmtp.push(fmtp);
		}

		const parameters = sdpTransform.parseParams(fmtp.config);

		switch (mimeType)
		{
			case 'audio/opus':
			{
				const spropStereo = codec.parameters['sprop-stereo'];

				if (spropStereo !== undefined)
					parameters.stereo = spropStereo ? 1 : 0;

				break;
			}
		}

		// Write the codec fmtp.config back.
		fmtp.config = '';
github versatica / mediasoup-client / src / handlers / sdp / commonUtils.ts View on Github external
rtcpFeedback         : [],
				parameters           : {}
			};

			if (codec.kind !== 'audio')
				delete codec.channels;
			else if (!codec.channels)
				codec.channels = 1;

			codecsMap.set(codec.preferredPayloadType, codec);
		}

		// Get codec parameters.
		for (const fmtp of m.fmtp || [])
		{
			const parameters = sdpTransform.parseParams(fmtp.config);
			const codec = codecsMap.get(fmtp.payload);

			if (!codec)
				continue;

			// Specials case to convert parameter value to string.
			if (parameters && parameters['profile-level-id'])
				parameters['profile-level-id'] = String(parameters['profile-level-id']);

			codec.parameters = parameters;
		}

		// Get RTCP feedback for each codec.
		for (const fb of m.rtcpFb || [])
		{
			const codec = codecsMap.get(fb.payload);
github open-webrtc-toolkit / owt-server / source / agent / webrtc / sdp.js View on Github external
for (i = 0; i < mediaInfo.rtp.length; i++) {
        rtp = mediaInfo.rtp[i];
        if (rtp.codec.toLowerCase() === 'h264') {
          removePayloads.push(rtp.payload);
        }
      }

      for (i = 0; i < mediaInfo.fmtp.length; i++) {
        fmtp = mediaInfo.fmtp[i];
        if (removePayloads.indexOf(fmtp.payload) > -1) {
          // Skip packetization-mode=0
          if (fmtp.config.indexOf('packetization-mode=0') > -1)
            continue;

          if (fmtp.config.indexOf('profile-level-id') >= 0) {
            var params = transform.parseParams(fmtp.config);
            var prf = translateProfile(params['profile-level-id'].toString());
            if (firstPayload < 0) {
              firstPayload = fmtp.payload;
            }
            if (preferred) {
              if (!preferred.profile || preferred.profile === prf) {
                // Use preferred profile
                selectedPayload = fmtp.payload;
                finalProfile = prf;
                break;
              }
            }
            if (direction === 'in') {
              // For publish connection
              finalProfile = prf;
              selectedPayload = fmtp.payload;
github bigbluebutton / bbb-webrtc-sfu / lib / mcs-core / lib / utils / sdp-wrapper.js View on Github external
fmtps.forEach(fmtp => {
              let fmtpConfig = transform.parseParams(fmtp.config);
              // Reconfiguring the FMTP to coerce endpoints to obey to audio spec
              // IF audioCodec was defined in the spec
              if (spec[audioCodec]) {
                let configProfile = this._fetchOPUSProfileParams(spec[audioCodec]);
                fmtp.config = configProfile;
              }
            });
          }
github bigbluebutton / bigbluebutton / labs / bbb-webrtc-sfu / lib / mcs-core / lib / utils / SdpWrapper.js View on Github external
removeHighQualityFmtps (sdp) {
    let res = transform.parse(sdp);
    let maxProfileLevel = config.get('kurento.maximum_profile_level_hex');
    let pt = 0;
    let idx = 0;
    for(var ml of res.media) {
      if(ml.type == 'video') {
        for(var fmtp of ml.fmtp) {
          let fmtpConfig = transform.parseParams(fmtp.config);
          let profileId = fmtpConfig['profile-level-id'];
          if(typeof profileId !== 'undefined' && parseInt(profileId, 16) > parseInt(maxProfileLevel, 16)) {
            pt = fmtp.payload;
            delete ml.fmtp[idx];
            ml.rtp = ml.rtp.filter((rtp) => { return rtp.payload != pt});
          }
          else {
            // Remove fmtp further specifications
            //let configProfile = "profile-level-id="+profileId;
            //fmtp.config = configProfile;
          }
          idx++;
        }
      }
    }
    var mangledSdp = transform.write(res);
github medooze / semantic-sdp-js / lib / SDPInfo.js View on Github external
const rids = md.rids;
		//For each one
		for (let j in rids)
		{
			//Get map
			const rid = rids[j];
			//Crate info
			const ridInfo = new RIDInfo(rid.id,DirectionWay.byValue(rid.direction));
			//Create format info and param map
			let formats = [];
			const params = new Map();
			//If it has params
			if (rid.params)
			{
				//Process formats and params
				const list = SDPTransform.parseParams(rid.params);
				//For each rid param
				for (let k in list)
					//Check type
					if (k==='pt')
						//Get formats
						formats = list[k].split(',');
					else
						//Add it to params
						params.set(k,list[k]);
				//Add formats and params
				ridInfo.setFormats(formats);
				ridInfo.setParams(params);
			}
			//Add rid info
			mediaInfo.addRID(ridInfo);
		}

sdp-transform

A simple parser/writer for the Session Description Protocol

MIT
Latest version published 9 months ago

Package Health Score

66 / 100
Full package analysis