Registry / http-networking / sdp-transform

sdp-transform

JSON →
library1.1.0jsnpmunverified

sdp-transform is a robust JavaScript library designed for parsing and writing Session Description Protocol (SDP) strings, following the grammar defined by RFC4566, RFC5245, and other relevant standards. The current stable version is 3.0.0, published in late 2025. It differentiates itself by rigorously adhering to RFC specifications, automatically coercing numerical values to integers during parsing while keeping other values as strings. The library is built to be easily extendable for custom grammar, making it suitable for a wide range of WebRTC and multimedia signaling applications. It provides core functionalities to convert SDP strings into a structured JavaScript object and vice-versa, facilitating manipulation and generation of SDP messages. While there isn't an explicit release cadence, the project shows active maintenance with regular updates prior to the v3 release.

npm install sdp-transform
INSTALL
IMPORT
SIG · SDP-TRANSFORM
S
sdp-transform
http-networkingjavascriptv1.1.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

parse
import { parse } from 'sdp-transform';
const parse = require('sdp-transform').parse;
For ES Modules, prefer named imports. CommonJS users can destructure or access via the module object.
write
import { write } from 'sdp-transform';
const write = require('sdp-transform').write;
For ES Modules, prefer named imports. CommonJS users can destructure or access via the module object.
sdpTransform (namespace import)
import * as sdpTransform from 'sdp-transform';
import sdpTransform from 'sdp-transform';
This package uses named exports. When importing all as a namespace, use `* as sdpTransform`. The CommonJS `require()` returns the module object directly.
parseParams
import { parseParams } from 'sdp-transform';
import { parseFmtpConfig } from 'sdp-transform';
The `parseFmtpConfig` function was deprecated in v2.x and removed/aliased in v3.0.0; use `parseParams` instead for parsing fmtp and other parameters.

This quickstart demonstrates parsing an SDP string into a structured object, modifying it, and then writing the object back to an SDP string. It also shows how to use a helper function like `parseParams`.

import { parse, write } from 'sdp-transform'; const sdpStr = "v=0\r\n" + "o=- 20518 0 IN IP4 203.0.113.1\r\n" + "s= \r\n" + "t=0 0\r\n" + "c=IN IP4 203.0.113.1\r\n" + "a=ice-ufrag:F7gI\r\n" + "a=ice-pwd:x9cml/YzichV2+XlhiMu8g\r\n" + "a=fingerprint:sha-1 42:89:c5:c6:55:9d:6e:c8:e8:83:55:2a:39:f9:b6:eb:e9:a3:a9:e7\r\n" + "m=audio 54400 RTP/SAVPF 0 96\r\n" + "a=rtpmap:0 PCMU/8000\r\n" + "a=rtpmap:96 opus/48000\r\n" + "a=ptime:20\r\n" + "a=sendrecv\r\n" + "a=candidate:0 1 UDP 2113667327 203.0.113.1 54400 typ host\r\n" + "a=candidate:1 2 UDP 2113667326 203.0.113.1 54401 typ host\r\n" + "m=video 55400 RTP/SAVPF 97 98\r\n" + "a=rtpmap:97 H264/90000\r\n" + "a=fmtp:97 profile-level-id=4d0028;packetization-mode=1\r\n" + "a=rtpmap:98 VP8/90000\r\n" + "a=sendrecv\r\n" + "a=candidate:0 1 UDP 2113667327 203.0.113.1 55400 typ host\r\n" + "a=candidate:1 2 UDP 2113667326 203.0.113.1 55401 typ host\r\n"; const parsedSdp = parse(sdpStr); console.log('Parsed SDP object:', JSON.stringify(parsedSdp, null, 2)); // Modify the parsed SDP object (example: change audio port) if (parsedSdp.media && parsedSdp.media[0]) { parsedSdp.media[0].port = 54402; } const modifiedSdpStr = write(parsedSdp); console.log('Modified SDP string:\n', modifiedSdpStr); // Example of using a helper parser if (parsedSdp.media && parsedSdp.media[1] && parsedSdp.media[1].fmtp && parsedSdp.media[1].fmtp[0]) { import { parseParams } from 'sdp-transform'; const fmtpParams = parseParams(parsedSdp.media[1].fmtp[0].config); console.log('Parsed fmtp parameters:', fmtpParams); }
Debug
Known issues
breakingVersion 3.0.0 introduces breaking changes in how `msid` attributes are handled. Specifically, it allows for multiple `msid` attributes, which may alter the structure of parsed SDP objects compared to earlier versions.
fix
Review your code for `msid` attribute handling and adapt to the new parsing structure. Consult issue #104 and the changelog for details.
affects: >=3.0.0
deprecatedThe `parseFmtpConfig` helper function has been deprecated and removed in version 3.0.0. Its functionality has been superseded by `parseParams`.
fix
Replace all occurrences of `sdpTransform.parseFmtpConfig()` with `sdpTransform.parseParams()`.
affects: >=3.0.0
gotchaThere is a known open issue (GitHub #106) where `msid` parsing may be broken for SDPs originating from Firefox when using version 3.0.0.
fix
Be aware of potential parsing inaccuracies for Firefox-generated SDPs. Monitor GitHub issue #106 for updates or consider custom pre-processing for `msid` lines if encountering issues.
affects: >=3.0.0
gotchaThe parser explicitly forces values that are integers in the SDP string to be parsed as JavaScript integers, while everything else remains a string. This can lead to unexpected type coercions for fields like `candidates[i].foundation` if it's expected to always be a string.
fix
Always validate the type of numeric-like fields in the parsed object if strict type adherence (e.g., all strings) is required for further processing. Convert back to string if necessary.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: sdpTransform.parseFmtpConfig is not a function
Attempting to use the deprecated `parseFmtpConfig` function in sdp-transform v3.0.0 or later.
fix
Update your code to use `sdpTransform.parseParams()` instead of `sdpTransform.parseFmtpConfig()`.
Incorrect MSID parsing for Firefox SDPs (GitHub Issue #106)
Specific parsing logic for `msid` attributes in sdp-transform v3.0.0 is reportedly broken when processing SDPs generated by Firefox browsers.
fix
This is an open issue. A direct fix is not yet available within the library. Workarounds might involve pre-processing Firefox SDPs to normalize `msid` lines or manually parsing them if accurate `msid` data is critical. Monitor GitHub issue #106 for resolution.
Upgrade
Version history
1.1.0latest on npm
Audit
Dependencies
@types/sdp-transformoptionalProvides TypeScript definitions for the sdp-transform library.
Agent activity
7 hits · last 30 days
node
6
OpenAI (training)
1
Resources
sdp-transform — npm install sdp-transform · libregistry