{"id":18782974,"url":"https://github.com/webex/ts-sdp","last_synced_at":"2025-10-19T21:39:17.080Z","repository":{"id":53342116,"uuid":"521374731","full_name":"webex/ts-sdp","owner":"webex","description":null,"archived":false,"fork":false,"pushed_at":"2025-03-20T12:30:15.000Z","size":447,"stargazers_count":1,"open_issues_count":1,"forks_count":5,"subscribers_count":11,"default_branch":"main","last_synced_at":"2025-04-13T12:09:22.113Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/webex.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2022-08-04T18:28:27.000Z","updated_at":"2025-03-20T12:30:22.000Z","dependencies_parsed_at":"2023-12-19T08:34:39.053Z","dependency_job_id":"e6315177-3f2b-4e8d-bd81-4e07c99eb2c3","html_url":"https://github.com/webex/ts-sdp","commit_stats":{"total_commits":106,"total_committers":9,"mean_commits":"11.777777777777779","dds":"0.41509433962264153","last_synced_commit":"2599a0e88b917f0dc5dc699c791b33ca966467ec"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webex%2Fts-sdp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webex%2Fts-sdp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webex%2Fts-sdp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webex%2Fts-sdp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/webex","download_url":"https://codeload.github.com/webex/ts-sdp/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248710448,"owners_count":21149190,"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":[],"created_at":"2024-11-07T20:37:40.144Z","updated_at":"2025-10-19T21:39:12.040Z","avatar_url":"https://github.com/webex.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ts-sdp\n\n`ts-sdp` is a library which allows for parsing, manipulation, and serialization of SDP.\n\n### Examples\n##### Parsing\nTo parse an SDP string, just call the `parse` method.\n```typescript\nconst sdp = parse(sdpOffer);\n```\nNote: the given SDP string must terminate each line with either `\\r`, `\\r\\n` or `\\n`.\n\n##### Manipulation\nOnce parsed, the SDP can be manipulated.  The model of the parsed object is as follows:\n![image](https://sqbu-github.cisco.com/storage/user/8795/files/82d641f2-6446-41ce-89b0-aa3de492a83a)\n\nThere are munging helper functions available in the `munge.ts` file.  For example:\n```typescript\nremoveCodec(parsedSdp, 'vp8');\ndisableRtcpFbValue(parsedSdp, 'goog-remb');\n```\nManipulation can also be done manually:\n```typescript\nTODO: more examples\n```\n\n##### Serialization\nWhen done, the SDP can be serialized to a string like so:\n```typescript\nconst sdpStr = sdp.toString();\n```\n\n#### Grammar\nThe library currently contains much of the [RGC4566 grammar](https://datatracker.ietf.org/doc/html/rfc4566), in addition to some additional attributes.  Any lines without specific parser implementations are still parsed via the `UnknownLine` type.\n\nThe grammar is extendable to allow for parsing custom attributes.  First, a subclass of `Line` must be defined:\n```typescript\n  class CustomLine extends Line {\n    value: number;\n\n    private static regex = /^foo:([0-9]+)$/;\n\n    constructor(value: number) {\n      super();\n      this.value = value;\n    }\n\n    static fromSdpLine(line: string): CustomLine | undefined {\n      if (!CustomLine.regex.test(line)) {\n        return undefined;\n      }\n\n      const tokens = line.match(CustomLine.regex) as RegExpMatchArray;\n      const value = parseInt(tokens[1], 10);\n      return new CustomLine(value);\n    }\n\n    toSdpLine(): string {\n      return `a=foo:${this.value}`;\n    }\n  }\n```\nThen the parser must be added to the grammar under the appropriate `LineType`:\n```typescript\nDefaultSdpGrammar.addParser('a', CustomLine.fromSdpLine);\n// Result will contain a 'CustomLine' instance in whichever SdpBlock the attribute appears.\nconst result = parse(sdp);\n```\nAny implementation of `Grammar` can also be passed to the `parse` method:\n```typescript\nclass MyCustomGrammar extends Grammar {\n    ...\n}\nconst myGrammar = new MyCustomGrammar();\nconst result = parse(sdp, myGrammar);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebex%2Fts-sdp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwebex%2Fts-sdp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebex%2Fts-sdp/lists"}