{"id":21486959,"url":"https://github.com/ntsd/sdp-compact","last_synced_at":"2025-07-15T14:33:13.687Z","repository":{"id":153342000,"uuid":"621144192","full_name":"ntsd/sdp-compact","owner":"ntsd","description":"shorten WebRTC Session Description Protocol (SDP) based on Unified Plan SDP","archived":false,"fork":false,"pushed_at":"2023-08-15T10:53:30.000Z","size":213,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-05-02T05:51:26.650Z","etag":null,"topics":["p2p","sdp","webrtc"],"latest_commit_sha":null,"homepage":"https://ntsd.github.io/sdp-compact/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ntsd.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-03-30T04:31:21.000Z","updated_at":"2024-01-22T16:32:04.000Z","dependencies_parsed_at":null,"dependency_job_id":"f84733b0-0b91-4925-8334-e4bf0e3cd0bb","html_url":"https://github.com/ntsd/sdp-compact","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ntsd%2Fsdp-compact","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ntsd%2Fsdp-compact/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ntsd%2Fsdp-compact/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ntsd%2Fsdp-compact/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ntsd","download_url":"https://codeload.github.com/ntsd/sdp-compact/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225653891,"owners_count":17502939,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["p2p","sdp","webrtc"],"created_at":"2024-11-23T13:25:20.630Z","updated_at":"2024-11-23T13:25:21.593Z","avatar_url":"https://github.com/ntsd.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SDP Compact\n\n[![npm version](https://badge.fury.io/js/sdp-compact.svg)](https://www.npmjs.com/package/sdp-compact)\n\nShorten WebRTC Session Description Protocol (SDP) based on Unified Plan SDP\n\n## Why?\n\nA WebRTC SDP can remove some of the attributes to compress/compact and share config on both the offer and answer sides. \n\n## Features\n\n- Shorten WebRTC SDP.\n- Options to fixed parameters for both the offer and answer side.\n- Compress with zlib deflate.\n- Bytes based allow choosing any encoding.\n\n## Tri It Online\n\n\u003chttps://ntsd.github.io/sdp-compact\u003e\n\n## Installation\n\n`npm install sdp-compact`\n\n## Examples\n\n```TypeScript\nimport * as spdCompact from \"sdp-compact\";\n\nconst sessDesc: RTCSessionDescriptionInit = {\n  type: \"offer\",\n  sdp: `v=0\\r\\no=- 4109260023080860376 2 IN IP4 127.0.0.1\\r\\ns=-\\r\\nt=0 0\\r\\na=extmap-allow-mixed\\r\\na=msid-semantic: WMS\\r\\n`,\n};\n\n\nconst options: spdCompact.Options = { compress: true };\n\n// compact the `RTCSessionDescriptionInit`\nconst compactedSessDesc = spdCompact.compact(sessDesc, options);\nconst decompactedSessDesc = spdCompact.decompact(compactedSPD, options);\n\n// compact only the SDP string, will return base64 encoded if compress is enabled.\nconst compactedSPD = spdCompact.compactSDP(sessDesc.sdp, options);\n// for decompact need to specify if it's offer or answer because it's not include in SDP\nconst decompactedSPD = spdCompact.decompactSDP(compactedSPD, true, options);\n\n// compact only the SDP string to bytes\nconst compactedSPDBytes = spdCompact.compactSDPBytes(sessDesc.sdp, options);\n// decompact the compacted SDP bytes to decompacted string\nconst decompactedSPD = spdCompact.decompactSDPBytes(compactedSPDBytes, true, options);\n```\n\n## Options\n\nYou can override the default options to suit your application's requirements, while still keeping the default values for any unspecified properties.\n\n### Default Options\n\n```Typescript\nconst DefaultOptions: Options = {\n  compress: true,\n  replaceFieldNames: true,\n  sdpVersion: 0,\n  sessionName: \"-\",\n  origin: {\n    username: \"-\",\n    sessionId: \"4109260023080860376\",\n    netType: \"IN\",\n    addrtype: \"IP4\",\n    unicastAddress: \"127.0.0.1\",\n  },\n  timing: \"0 0\",\n  extmapAllowMixed: true,\n  msidSemantic: \"WMS\",\n  mediaOptions: {\n    removeMediaID: true,\n    removeSetup: true,\n    replaceCandidateString: true,\n    replaceMediaString: true,\n    forceTrickle: true,\n    compressFingerprint: true,\n  },\n};\n```\n\nHere is an explanation of each option and its default value:\n\n### compress (default: true)\n\nEnables compression using zlib deflate, followed by base64 encoding.\n\n### replaceFieldNames (default: true)\n\nReplaces field names using FieldReplaceMap and FieldReplaceMapReverse.\n\n### sdpVersion (default: 0)\n\nThe fixed SDP version (v=), which is usually 0 for now.\n\n### sessionName (default: \"-\")\n\nThe fixed session name (s=), which is usually \"-\".\n\n### origin (default: see below)\n\nFixed origin options (o=). This includes the following properties:\n\n- `username`: Fixed username, can be \"-\" for an undefined user. (default: \"-\")\n- `sessionId`: Fixed session ID, can be the same value on all peers. (default: \"4109260023080860376\")\n- `netType`: Fixed network type, must be \"IN\" for the internet. (default: \"IN\")\n- `addrtype`: Fixed address type, must be either \"IP4\" or \"IP6\". Usually, it will be \"IP4\". (default: \"IP4\")\n- `unicastAddress`: Fixed unicast address, usually \"127.0.0.1\". (default: \"127.0.0.1\")\n\n### timing (default: \"0 0\")\n\nThe fixed timing (t=). It can be \"0 0\" for unbounded.\n\n### extmapAllowMixed (default: true)\n\nAllows mixing attributes (a=extmap-allow-mixed), usually allowed by default.\n\n### msidSemantic (default: \"WMS\")\n\nThe fixed msid semantic (a=msid-semantic:). It should be \"WMS\" for WebRTC Media Stream.\n\n### mediaOptions (default: see below)\n\nCustomize media options. This includes the following properties:\n\n- `removeMediaID`: Remove media ID (a=mid:) and group (a=group:\u003ctype\u003e) (a=group:BUNDLE) to use sequence medias instead. (default: true)\n- `removeSetup`: Remove DTLS role (a=setup:). It will set to actpass for offer and active for answer. (default: true)\n- `replaceCandidateString`: replaced string in ice candidate (a=candidate:) following `CandidateReplaceList`. (default: true)\n- `replaceMediaString`: replace string in media (m=) following `MediaReplaceList`. (default: true)\n- `forceTrickle`: force ice-options to trickle (a=ice-options:trickle). (default: true)\n- `compressFingerprint`: compress fingerprint (a=fingerprint:). (default: true)\n- `compressConnection`: compress media connection (c=). (default: true)\n\n## WebRTC SDP Anatomy\n\nYou can read the WebRTC SDP Anatomy [Here](./sdp.md) for how it's works.\n\n## Projects using SDP Compact\n\n- [Zero Share](https://github.com/ntsd/zero-share) - A client-side secure P2P file sharing using WebRTC.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fntsd%2Fsdp-compact","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fntsd%2Fsdp-compact","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fntsd%2Fsdp-compact/lists"}