@webex/ts-sdp
Advanced tools
Comparing version 1.3.2 to 1.4.0
@@ -1000,3 +1000,3 @@ 'use strict'; | ||
this.pts = []; | ||
this.extMaps = []; | ||
this.extMaps = new Map(); | ||
this.rids = []; | ||
@@ -1063,3 +1063,6 @@ this.codecs = new Map(); | ||
if (line instanceof ExtMapLine) { | ||
this.extMaps.push(line); | ||
if (this.extMaps.has(line.id)) { | ||
throw new Error(`Tried to extension with duplicate ID: an extension already exists with ID ${line.id}`); | ||
} | ||
this.extMaps.set(line.id, line); | ||
return true; | ||
@@ -1111,2 +1114,22 @@ } | ||
} | ||
addExtension({ uri, direction, attributes, id, }) { | ||
const getFirstFreeId = () => { | ||
let freeId = 1; | ||
for (;;) { | ||
if (!this.extMaps.has(freeId)) { | ||
break; | ||
} | ||
freeId += 1; | ||
} | ||
return freeId; | ||
}; | ||
const extId = id || getFirstFreeId(); | ||
if (this.extMaps.has(extId)) { | ||
throw new Error(`Extension with ID ${id} already exists`); | ||
} | ||
if (extId === 0) { | ||
throw new Error(`Extension ID 0 is reserved`); | ||
} | ||
this.extMaps.set(extId, new ExtMapLine(extId, uri, direction, attributes)); | ||
} | ||
} | ||
@@ -1113,0 +1136,0 @@ |
@@ -996,3 +996,3 @@ const NUM = '\\d+'; | ||
this.pts = []; | ||
this.extMaps = []; | ||
this.extMaps = new Map(); | ||
this.rids = []; | ||
@@ -1059,3 +1059,6 @@ this.codecs = new Map(); | ||
if (line instanceof ExtMapLine) { | ||
this.extMaps.push(line); | ||
if (this.extMaps.has(line.id)) { | ||
throw new Error(`Tried to extension with duplicate ID: an extension already exists with ID ${line.id}`); | ||
} | ||
this.extMaps.set(line.id, line); | ||
return true; | ||
@@ -1107,2 +1110,22 @@ } | ||
} | ||
addExtension({ uri, direction, attributes, id, }) { | ||
const getFirstFreeId = () => { | ||
let freeId = 1; | ||
for (;;) { | ||
if (!this.extMaps.has(freeId)) { | ||
break; | ||
} | ||
freeId += 1; | ||
} | ||
return freeId; | ||
}; | ||
const extId = id || getFirstFreeId(); | ||
if (this.extMaps.has(extId)) { | ||
throw new Error(`Extension with ID ${id} already exists`); | ||
} | ||
if (extId === 0) { | ||
throw new Error(`Extension ID 0 is reserved`); | ||
} | ||
this.extMaps.set(extId, new ExtMapLine(extId, uri, direction, attributes)); | ||
} | ||
} | ||
@@ -1109,0 +1132,0 @@ |
@@ -69,2 +69,3 @@ declare abstract class Line { | ||
declare type ExtMapDirection = 'sendonly' | 'recvonly' | 'sendrecv' | 'inactive'; | ||
declare class ExtMapLine extends Line { | ||
@@ -77,3 +78,3 @@ id: number; | ||
private static regex; | ||
constructor(id: number, uri: string, direction?: 'sendonly' | 'recvonly' | 'sendrecv' | 'inactive', extensionAttributes?: string); | ||
constructor(id: number, uri: string, direction?: ExtMapDirection, extensionAttributes?: string); | ||
static fromSdpLine(line: string): ExtMapLine | undefined; | ||
@@ -357,3 +358,3 @@ toSdpLine(): string; | ||
pts: Array<number>; | ||
extMaps: Array<ExtMapLine>; | ||
extMaps: Map<number, ExtMapLine>; | ||
rids: Array<RidLine>; | ||
@@ -371,2 +372,8 @@ simulcast?: SimulcastLine; | ||
removePt(pt: number): void; | ||
addExtension({ uri, direction, attributes, id, }: { | ||
uri: string; | ||
direction?: ExtMapDirection; | ||
attributes?: string; | ||
id?: number; | ||
}): void; | ||
} | ||
@@ -423,2 +430,2 @@ | ||
export { ANY_NON_WS, ApplicationMediaDescription, AvMediaDescription, BandwidthLine, BandwidthType, BundleGroupLine, CandidateLine, CodecInfo, ConnectionLine, ContentLine, DefaultSdpGrammar, DirectionLine, ExtMapLine, FingerprintLine, FmtpLine, Grammar, IceInfo, IceOptionsLine, IcePwdLine, IceUfragLine, Line, MaxMessageSizeLine, MediaDescription, MediaDirection, MediaLine, MediaType, MidLine, NUM, OriginLine, REST, RidLine, RtcpFbLine, RtcpMuxLine, RtpMapLine, SDP_TOKEN, SP, SctpPortLine, Sdp, SdpBlock, SessionDescription, SessionInformationLine, SessionNameLine, Setup, SetupLine, SimulcastLayer, SimulcastLayerList, SimulcastLine, SsrcGroupLine, SsrcLine, TimingLine, VersionLine, WS, disableRemb, disableRtcpFbValue, hasCodec, parse, parseFmtpParams, parseToLines, parseToModel, removeCodec }; | ||
export { ANY_NON_WS, ApplicationMediaDescription, AvMediaDescription, BandwidthLine, BandwidthType, BundleGroupLine, CandidateLine, CodecInfo, ConnectionLine, ContentLine, DefaultSdpGrammar, DirectionLine, ExtMapDirection, ExtMapLine, FingerprintLine, FmtpLine, Grammar, IceInfo, IceOptionsLine, IcePwdLine, IceUfragLine, Line, MaxMessageSizeLine, MediaDescription, MediaDirection, MediaLine, MediaType, MidLine, NUM, OriginLine, REST, RidLine, RtcpFbLine, RtcpMuxLine, RtpMapLine, SDP_TOKEN, SP, SctpPortLine, Sdp, SdpBlock, SessionDescription, SessionInformationLine, SessionNameLine, Setup, SetupLine, SimulcastLayer, SimulcastLayerList, SimulcastLine, SsrcGroupLine, SsrcLine, TimingLine, VersionLine, WS, disableRemb, disableRtcpFbValue, hasCodec, parse, parseFmtpParams, parseToLines, parseToModel, removeCodec }; |
{ | ||
"name": "@webex/ts-sdp", | ||
"version": "1.3.2", | ||
"version": "1.4.0", | ||
"description": "Provides a simple interface to parse and munge SDP(session description protocol)", | ||
@@ -5,0 +5,0 @@ "main": "dist/cjs/index.js", |
118506
3042