How to use sdp-transform - 10 common examples

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 Kurento / mediasoup-demos / mediasoup-kurento-filter / server.js View on Github external
`a=rtcp:${msListenPortRtcp}\r\n` +
    `a=rtpmap:${msPayloadType} VP8/90000\r\n` +
    "a=recvonly\r\n" +
    "";

  const kmsEndpoint = await kmsPipeline.create("RtpEndpoint");
  global.kurento.rtp.sendEndpoint = kmsEndpoint;

  console.log("SDP Offer from App to Kurento RTP SEND: %s\n", kmsSdpOffer);
  const kmsSdpAnswer = await kmsEndpoint.processOffer(kmsSdpOffer);
  console.log("SDP Answer from Kurento RTP SEND to App:\n%s", kmsSdpAnswer);

  // WARNING: A real application would need to parse this SDP Answer and adapt
  // to the parameters given in it, following the SDP Offer/Answer Model.

  const kmsSdpAnswerObj = SdpTransform.parse(kmsSdpAnswer);
  console.log("kmsSdpAnswerObj: %s", JSON.stringify(kmsSdpAnswerObj, null, 2));

  // Build an RtpSendParameters from the Kurento SDP Answer,
  // this gives us the Kurento RTP stream's SSRC, payload type, etc.

  const kmsRtpCapabilities = MediasoupSdpUtils.extractRtpCapabilities({
    sdpObject: kmsSdpAnswerObj
  });
  console.log(
    "kmsRtpCapabilities: %s",
    JSON.stringify(kmsRtpCapabilities, null, 2)
  );

  const msExtendedRtpCapabilities = MediasoupOrtc.getExtendedRtpCapabilities(
    kmsRtpCapabilities,
    global.mediasoup.router.rtpCapabilities
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 / Chrome74.ts View on Github external
encodings.forEach((encoding: any, idx: number) =>
			{
				encoding.rid = `r${idx}`;
			});
		}

		const mediaSectionIdx = this._remoteSdp.getNextMediaSectionIdx();
		const transceiver = this._pc.addTransceiver(
			track,
			{
				direction     : 'sendonly',
				streams       : [ this._stream ],
				sendEncodings : encodings
			});
		let offer = await this._pc.createOffer();
		let localSdpObject = sdpTransform.parse(offer.sdp);
		let offerMediaObject;
		const sendingRtpParameters =
			utils.clone(this._sendingRtpParametersByKind[track.kind]);

		if (!this._transportReady)
			await this._setupTransport({ localDtlsRole: 'server', localSdpObject });

		logger.debug(
			'send() | calling pc.setLocalDescription() [offer:%o]', offer);

		// Special case for VP9 with SVC.
		let hackVp9Svc = false;

		const layers =
			parseScalabilityMode((encodings || [ {} ])[0].scalabilityMode);
github davehorton / drachtio-siprec-recording-server / lib / freeswitch-call-handler.js View on Github external
function handleLeg2SiprecInvite(req, res, opts) {
  const logger = opts.logger;
  const sessionId = req.get('X-Return-Token');
  debug(`handleLeg2SiprecInvite: sessionId is ${sessionId}`);

  // add a=recvonly
  let sdp = transform.parse(req.body);
  sdp.media[0].direction = 'recvonly';
  sdp = transform.write(sdp);
  exchangeSdp(sessionId, sdp)
    .then((sdp) => req.srf.createUAS(req, res, {localSdp: sdp}))
    .catch((err) => {
      logger.error(err, 'Error replying to leg2 INVITE from Freeswitch');
      res.send(480);
    });
}
github skerit / rudeplay / lib / server / server.js View on Github external
req.getBody(function gotBody(err, buffer) {

		var status_code,
		    conf;

		if (err) {
			throw err;
		}

		// Parse the body, which is just an SDP string
		conf = Sdp.parse(buffer.toString());

		status_code = req.session.setSdp(conf);

		if (status_code != null) {
			res.status_code = status_code;
		}

		res.end();
	});
});
github versatica / mediasoup-client / src / handlers / Safari12.ts View on Github external
priority
		};

		logger.debug('DataChannel options:%o', options);

		const dataChannel = this._pc.createDataChannel(label, options);

		// Increase next id.
		this._nextSctpStreamId = ++this._nextSctpStreamId % SCTP_NUM_STREAMS.MIS;

		// If this is the first DataChannel we need to create the SDP answer with
		// m=application section.
		if (!this._hasDataChannelMediaSection)
		{
			const offer = await this._pc.createOffer();
			const localSdpObject = sdpTransform.parse(offer.sdp);
			const offerMediaObject = localSdpObject.media
				.find((m: any) => m.type === 'application');

			if (!this._transportReady)
				await this._setupTransport({ localDtlsRole: 'server', localSdpObject });

			logger.debug(
				'sendDataChannel() | calling pc.setLocalDescription() [offer:%o]', offer);

			await this._pc.setLocalDescription(offer);

			this._remoteSdp.sendSctpAssociation({ offerMediaObject });

			const answer = { type: 'answer', sdp: this._remoteSdp.getSdp() };

			logger.debug(
github versatica / mediasoup-client / src / handlers / ReactNative.ts View on Github external
async _setupTransport(
		{ localDtlsRole, localSdpObject = null }:
		{ localDtlsRole: DtlsRole; localSdpObject: any | null }
	): Promise
	{
		if (!localSdpObject)
			localSdpObject = sdpTransform.parse(this._pc.localDescription.sdp);

		// Get our local DTLS parameters.
		const dtlsParameters =
			sdpCommonUtils.extractDtlsParameters({ sdpObject: localSdpObject });

		// Set our DTLS role.
		dtlsParameters.role = localDtlsRole;

		// Update the remote DTLS role in the SDP.
		this._remoteSdp.updateDtlsRole(
			localDtlsRole === 'client' ? 'server' : 'client');

		// Need to tell the remote transport about our parameters.
		await this.safeEmitAsPromise('@connect', { dtlsParameters });

		this._transportReady = true;
github versatica / mediasoup-client / lib / handlers / Chrome69.js View on Github external
.then(() =>
			{
				// Get our local DTLS parameters.
				const transportLocalParameters = {};
				const sdp = this._pc.localDescription.sdp;
				const sdpObj = sdpTransform.parse(sdp);
				const dtlsParameters = sdpCommonUtils.extractDtlsParameters(sdpObj);

				// Let's decide that we'll be DTLS server (because we can).
				dtlsParameters.role = 'server';

				transportLocalParameters.dtlsParameters = dtlsParameters;

				// Provide the remote SDP handler with transport local parameters.
				this._remoteSdp.setTransportLocalParameters(transportLocalParameters);

				// We need transport remote parameters.
				return this.safeEmitAsPromise(
					'@needcreatetransport', transportLocalParameters);
			})
			.then((transportRemoteParameters) =>
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;
              }
            });
          }
        });
      }
    });


    return transform.write(res);
  }

sdp-transform

A simple parser/writer for the Session Description Protocol

MIT
Latest version published 3 months ago

Package Health Score

73 / 100
Full package analysis