Security News
JavaScript Leaders Demand Oracle Release the JavaScript Trademark
In an open letter, JavaScript community leaders urge Oracle to give up the JavaScript trademark, arguing that it has been effectively abandoned through nonuse.
@webex/ts-sdp
Advanced tools
Provides a simple interface to parse and munge SDP(session description protocol)
ts-sdp
is a library which allows for parsing, manipulation, and serialization of SDP.
To parse an SDP string, just call the parse
method.
const sdp = parse(sdpOffer);
Note: the given SDP string must terminate each line with either \r
, \r\n
or \n
.
Once parsed, the SDP can be manipulated. The model of the parsed object is as follows:
There are munging helper functions available in the munge.ts
file. For example:
removeCodec(parsedSdp, 'vp8');
disableRtcpFbValue(parsedSdp, 'goog-remb');
Manipulation can also be done manually:
TODO: more examples
When done, the SDP can be serialized to a string like so:
const sdpStr = sdp.toString();
The library currently contains much of the RGC4566 grammar, in addition to some additional attributes. Any lines without specific parser implementations are still parsed via the UnknownLine
type.
The grammar is extendable to allow for parsing custom attributes. First, a subclass of Line
must be defined:
class CustomLine extends Line {
value: number;
private static regex = /^foo:([0-9]+)$/;
constructor(value: number) {
super();
this.value = value;
}
static fromSdpLine(line: string): CustomLine | undefined {
if (!CustomLine.regex.test(line)) {
return undefined;
}
const tokens = line.match(CustomLine.regex) as RegExpMatchArray;
const value = parseInt(tokens[1], 10);
return new CustomLine(value);
}
toSdpLine(): string {
return `a=foo:${this.value}`;
}
}
Then the parser must be added to the grammar under the appropriate LineType
:
DefaultSdpGrammar.addParser('a', CustomLine.fromSdpLine);
// Result will contain a 'CustomLine' instance in whichever SdpBlock the attribute appears.
const result = parse(sdp);
Any implementation of Grammar
can also be passed to the parse
method:
class MyCustomGrammar extends Grammar {
...
}
const myGrammar = new MyCustomGrammar();
const result = parse(sdp, myGrammar);
FAQs
Provides a simple interface to parse and munge SDP(session description protocol)
The npm package @webex/ts-sdp receives a total of 3,080 weekly downloads. As such, @webex/ts-sdp popularity was classified as popular.
We found that @webex/ts-sdp demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
In an open letter, JavaScript community leaders urge Oracle to give up the JavaScript trademark, arguing that it has been effectively abandoned through nonuse.
Security News
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
Security News
Floating dependency ranges in npm can introduce instability and security risks into your project by allowing unverified or incompatible versions to be installed automatically, leading to unpredictable behavior and potential conflicts.