{"id":13988,"library":"sdp-transform","title":"SDP Transform","description":"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.","status":"active","version":"3.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/clux/sdp-transform","tags":["javascript","sdp","webrtc","serializer"],"install":[{"cmd":"npm install sdp-transform","lang":"bash","label":"npm"},{"cmd":"yarn add sdp-transform","lang":"bash","label":"yarn"},{"cmd":"pnpm add sdp-transform","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Provides TypeScript definitions for the sdp-transform library.","package":"@types/sdp-transform","optional":true}],"imports":[{"note":"For ES Modules, prefer named imports. CommonJS users can destructure or access via the module object.","wrong":"const parse = require('sdp-transform').parse;","symbol":"parse","correct":"import { parse } from 'sdp-transform';"},{"note":"For ES Modules, prefer named imports. CommonJS users can destructure or access via the module object.","wrong":"const write = require('sdp-transform').write;","symbol":"write","correct":"import { write } from 'sdp-transform';"},{"note":"This package uses named exports. When importing all as a namespace, use `* as sdpTransform`. The CommonJS `require()` returns the module object directly.","wrong":"import sdpTransform from 'sdp-transform';","symbol":"sdpTransform (namespace import)","correct":"import * as sdpTransform from 'sdp-transform';"},{"note":"The `parseFmtpConfig` function was deprecated in v2.x and removed/aliased in v3.0.0; use `parseParams` instead for parsing fmtp and other parameters.","wrong":"import { parseFmtpConfig } from 'sdp-transform';","symbol":"parseParams","correct":"import { parseParams } from 'sdp-transform';"}],"quickstart":{"code":"import { parse, write } from 'sdp-transform';\n\nconst sdpStr = \"v=0\\r\\n\" +\n  \"o=- 20518 0 IN IP4 203.0.113.1\\r\\n\" +\n  \"s= \\r\\n\" +\n  \"t=0 0\\r\\n\" +\n  \"c=IN IP4 203.0.113.1\\r\\n\" +\n  \"a=ice-ufrag:F7gI\\r\\n\" +\n  \"a=ice-pwd:x9cml/YzichV2+XlhiMu8g\\r\\n\" +\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\" +\n  \"m=audio 54400 RTP/SAVPF 0 96\\r\\n\" +\n  \"a=rtpmap:0 PCMU/8000\\r\\n\" +\n  \"a=rtpmap:96 opus/48000\\r\\n\" +\n  \"a=ptime:20\\r\\n\" +\n  \"a=sendrecv\\r\\n\" +\n  \"a=candidate:0 1 UDP 2113667327 203.0.113.1 54400 typ host\\r\\n\" +\n  \"a=candidate:1 2 UDP 2113667326 203.0.113.1 54401 typ host\\r\\n\" +\n  \"m=video 55400 RTP/SAVPF 97 98\\r\\n\" +\n  \"a=rtpmap:97 H264/90000\\r\\n\" +\n  \"a=fmtp:97 profile-level-id=4d0028;packetization-mode=1\\r\\n\" +\n  \"a=rtpmap:98 VP8/90000\\r\\n\" +\n  \"a=sendrecv\\r\\n\" +\n  \"a=candidate:0 1 UDP 2113667327 203.0.113.1 55400 typ host\\r\\n\" +\n  \"a=candidate:1 2 UDP 2113667326 203.0.113.1 55401 typ host\\r\\n\";\n\nconst parsedSdp = parse(sdpStr);\nconsole.log('Parsed SDP object:', JSON.stringify(parsedSdp, null, 2));\n\n// Modify the parsed SDP object (example: change audio port)\nif (parsedSdp.media && parsedSdp.media[0]) {\n  parsedSdp.media[0].port = 54402;\n}\n\nconst modifiedSdpStr = write(parsedSdp);\nconsole.log('Modified SDP string:\\n', modifiedSdpStr);\n\n// Example of using a helper parser\nif (parsedSdp.media && parsedSdp.media[1] && parsedSdp.media[1].fmtp && parsedSdp.media[1].fmtp[0]) {\n  import { parseParams } from 'sdp-transform';\n  const fmtpParams = parseParams(parsedSdp.media[1].fmtp[0].config);\n  console.log('Parsed fmtp parameters:', fmtpParams);\n}","lang":"typescript","description":"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`."},"warnings":[{"fix":"Review your code for `msid` attribute handling and adapt to the new parsing structure. Consult issue #104 and the changelog for details.","message":"Version 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.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Replace all occurrences of `sdpTransform.parseFmtpConfig()` with `sdpTransform.parseParams()`.","message":"The `parseFmtpConfig` helper function has been deprecated and removed in version 3.0.0. Its functionality has been superseded by `parseParams`.","severity":"deprecated","affected_versions":">=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.","message":"There is a known open issue (GitHub #106) where `msid` parsing may be broken for SDPs originating from Firefox when using version 3.0.0.","severity":"gotcha","affected_versions":">=3.0.0"},{"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.","message":"The 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.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'2025':41 '3.0.0':37 'activ':124 'adher':47 'applic':88 'automat':51 'built':68 'cadenc':120 'coerc':52 'convert':94 'core':91 'current':33 'custom':74 'defin':24 'descript':17 'design':11 'differenti':43 'easili':71 'explicit':118 'extend':72 'facilit':106 'follow':21 'function':92 'generat':109 'grammar':23,75 'integ':56 'isn':115 'javascript':9,100,134 'keep':60 'late':40 'librari':10,66 'mainten':125 'make':76 'manipul':107 'messag':112 'multimedia':86 'numer':53 'object':101 'pars':13,58 'prior':129 'project':122 'protocol':18 'provid':90 'publish':38 'rang':82 'regular':127 'releas':119,133 'relev':30 'rfc':49 'rfc4566':26 'rfc5245':27 'rigor':46 'robust':8 'sdp':1,4,19,95,111,135 'sdp-transform':3 'serial':137 'session':16 'show':123 'signal':87 'specif':50 'stabl':34 'standard':31 'string':20,64,96 'structur':99 'suitabl':78 'transform':2,5 'updat':128 'v3':132 'valu':54,62 'versa':105 'version':35 'vice':104 'vice-versa':103 'webrtc':84,136 'wide':81 'write':15","created_at":"2026-04-20T01:57:21.343585+00:00","updated_at":"2026-04-20T01:57:21.343585+00:00","problems":[{"fix":"Update your code to use `sdpTransform.parseParams()` instead of `sdpTransform.parseFmtpConfig()`.","cause":"Attempting to use the deprecated `parseFmtpConfig` function in sdp-transform v3.0.0 or later.","error":"TypeError: sdpTransform.parseFmtpConfig is not a function"},{"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.","cause":"Specific parsing logic for `msid` attributes in sdp-transform v3.0.0 is reportedly broken when processing SDPs generated by Firefox browsers.","error":"Incorrect MSID parsing for Firefox SDPs (GitHub Issue #106)"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"1.1.0","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/clux/sdp-transform","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/sdp-transform","openapi_spec":null,"status_page":null,"smithery":null,"categories":["http-networking","communication"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-17","next_check":"2026-07-18","install_tag":null}}