SdpParser

Source: SdpParser.js:29

Simplify SDP parser.


Instance Methods

setSimulcast(sdp: String, codec: String): String

Parse SDP for support simulcast. Only available in Chromium based browsers.

Parameters

  • sdp (String) — Current SDP.
  • codec (String) — Codec.

Returns

  • String — SDP parsed with simulcast support.

Example

CODE
SdpParser.setSimulcast(sdp, 'h264')

setStereo(sdp: String): String

Parse SDP for support stereo.

Parameters

  • sdp (String) — Current SDP.

Returns

  • String — SDP parsed with stereo support.

Example

CODE
SdpParser.setStereo(sdp)

setDTX(sdp: String): String

Set DTX (Discontinuous Transmission) to the connection. Advanced configuration of the opus audio codec that allows for a large reduction in the audio traffic. For example, when a participant is silent, the audio packets won't be transmitted.

Parameters

  • sdp (String) — Current SDP.

Returns

  • String — SDP parsed with dtx support.

Example

CODE
SdpParser.setDTX(sdp)

setAbsoluteCaptureTime(sdp: String): String

Mangle SDP for adding absolute capture time header extension.

Parameters

  • sdp (String) — Current SDP.

Returns

  • String — SDP mungled with abs-capture-time header extension.

Example

CODE
SdpParser.setAbsoluteCaptureTime(sdp)

setDependencyDescriptor(sdp: String): String

Mangle SDP for adding dependency descriptor header extension.

Parameters

  • sdp (String) — Current SDP.

Returns

  • String — SDP mungled with abs-capture-time header extension.

Example

CODE
SdpParser.setAbsoluteCaptureTime(sdp)

setVideoBitrate(sdp: String, bitrate: Number): String

Parse SDP for desired bitrate.

Parameters

  • sdp (String) — Current SDP.
  • bitrate (Number) — Bitrate value in kbps or 0 for unlimited bitrate.

Returns

  • String — SDP parsed with desired bitrate.

Example

CODE
SdpParser.setVideoBitrate(sdp, 1000)

removeSdpLine(sdp: String, sdpLine: String): String

Remove SDP line.

Parameters

  • sdp (String) — Current SDP.
  • sdpLine (String) — SDP line to remove.

Returns

  • String — SDP without the line.

Example

CODE
SdpParser.removeSdpLine(sdp, 'custom line')

adaptCodecName( sdp: String, codec: String, newCodecName: String, ): String

Replace codec name of a SDP.

Parameters

  • sdp (String) — Current SDP.
  • codec (String) — Codec name to be replaced.
  • newCodecName (String) — New codec name to replace.

Returns

  • String — SDP updated with new codec name.

setMultiopus(sdp: String, mediaStream: MediaStream): String

Parse SDP for support multiopus. Only available in Google Chrome.

Parameters

  • sdp (String) — Current SDP.
  • mediaStream (MediaStream) — MediaStream offered in the stream.

Returns

  • String — SDP parsed with multiopus support.

Example

CODE
SdpParser.setMultiopus(sdp, mediaStream)

getAvailablePayloadTypeRange(sdp: String): Array.<Number>

Gets all available payload type IDs of the current Session Description.

Parameters

  • sdp (String) — Current SDP.

Returns

  • Array.<Number> — All available payload type ids.

getAvailableHeaderExtensionIdRange(sdp: String): Array.<Number>

Gets all available header extension IDs of the current Session Description.

Parameters

  • sdp (String) — Current SDP.

Returns

  • Array.<Number> — All available header extension IDs.

renegotiate(localDescription: String, remoteDescription: String)

Renegotiate remote sdp based on previous description. This function will fill missing m-lines cloning on the remote description by cloning the codec and extensions already negotiated for that media

Parameters

  • localDescription (String) — Updated local sdp
  • remoteDescription (String) — Previous remote sdp

updateMissingVideoExtensions( localDescription: String, remoteDescription: String, ): String

Adds missing extensions of each video section in the localDescription

Parameters

  • localDescription (String) — Previous local sdp
  • remoteDescription (String) — Remote sdp

Returns

  • String — SDP updated with missing extensions.