Comparing version 3.0.2 to 3.0.3
@@ -1,1 +0,1 @@ | ||
{"processes":{"1ddd53c3-dc5d-4371-8daa-31cded495a06":{"parent":null,"children":[]}},"files":{"/media/fippo/houseparty/webrtc/sdp/sdp.js":["1ddd53c3-dc5d-4371-8daa-31cded495a06"]},"externalIds":{}} | ||
{"processes":{"d12e8ec5-0ac8-468a-ac39-70a07d494b89":{"parent":null,"children":[]}},"files":{"/media/fippo/houseparty/webrtc/sdp/sdp.js":["d12e8ec5-0ac8-468a-ac39-70a07d494b89"]},"externalIds":{}} |
@@ -33,3 +33,3 @@ /* eslint-env node */ | ||
// returns the session description. | ||
// Returns the session description. | ||
SDPUtils.getDescription = function (blob) { | ||
@@ -40,3 +40,3 @@ var sections = SDPUtils.splitSections(blob); | ||
// returns the individual media sections. | ||
// Returns the individual media sections. | ||
SDPUtils.getMediaSections = function (blob) { | ||
@@ -58,2 +58,3 @@ var sections = SDPUtils.splitSections(blob); | ||
// rport 55996" | ||
// Input can be prefixed with a=. | ||
SDPUtils.parseCandidate = function (line) { | ||
@@ -70,3 +71,3 @@ var parts = void 0; | ||
foundation: parts[0], | ||
component: { 1: 'rtp', 2: 'rtcp' }[parts[1]], | ||
component: { 1: 'rtp', 2: 'rtcp' }[parts[1]] || parts[1], | ||
protocol: parts[2].toLowerCase(), | ||
@@ -108,2 +109,3 @@ priority: parseInt(parts[3], 10), | ||
// Translates a candidate object into SDP candidate attribute. | ||
// This does not include the a= prefix! | ||
SDPUtils.writeCandidate = function (candidate) { | ||
@@ -147,2 +149,3 @@ var sdp = []; | ||
// Parses an ice-options line, returns an array of option tags. | ||
// Sample input: | ||
// a=ice-options:foo bar | ||
@@ -153,3 +156,3 @@ SDPUtils.parseIceOptions = function (line) { | ||
// Parses an rtpmap line, returns RTCRtpCoddecParameters. Sample input: | ||
// Parses a rtpmap line, returns RTCRtpCoddecParameters. Sample input: | ||
// a=rtpmap:111 opus/48000/2 | ||
@@ -172,3 +175,3 @@ SDPUtils.parseRtpMap = function (line) { | ||
// Generate an a=rtpmap line from RTCRtpCodecCapability or | ||
// Generates a rtpmap line from RTCRtpCodecCapability or | ||
// RTCRtpCodecParameters. | ||
@@ -184,3 +187,3 @@ SDPUtils.writeRtpMap = function (codec) { | ||
// Parses an a=extmap line (headerextension from RFC 5285). Sample input: | ||
// Parses a extmap line (headerextension from RFC 5285). Sample input: | ||
// a=extmap:2 urn:ietf:params:rtp-hdrext:toffset | ||
@@ -197,3 +200,3 @@ // a=extmap:2/sendonly urn:ietf:params:rtp-hdrext:toffset | ||
// Generates a=extmap line from RTCRtpHeaderExtensionParameters or | ||
// Generates an extmap line from RTCRtpHeaderExtensionParameters or | ||
// RTCRtpHeaderExtension. | ||
@@ -204,3 +207,3 @@ SDPUtils.writeExtmap = function (headerExtension) { | ||
// Parses an ftmp line, returns dictionary. Sample input: | ||
// Parses a fmtp line, returns dictionary. Sample input: | ||
// a=fmtp:96 vbr=on;cng=on | ||
@@ -219,3 +222,3 @@ // Also deals with vbr=on; cng=on | ||
// Generates an a=ftmp line from RTCRtpCodecCapability or RTCRtpCodecParameters. | ||
// Generates a fmtp line from RTCRtpCodecCapability or RTCRtpCodecParameters. | ||
SDPUtils.writeFmtp = function (codec) { | ||
@@ -230,3 +233,3 @@ var line = ''; | ||
Object.keys(codec.parameters).forEach(function (param) { | ||
if (codec.parameters[param]) { | ||
if (codec.parameters[param] !== undefined) { | ||
params.push(param + '=' + codec.parameters[param]); | ||
@@ -242,3 +245,3 @@ } else { | ||
// Parses an rtcp-fb line, returns RTCPRtcpFeedback object. Sample input: | ||
// Parses a rtcp-fb line, returns RTCPRtcpFeedback object. Sample input: | ||
// a=rtcp-fb:98 nack rpsi | ||
@@ -252,2 +255,3 @@ SDPUtils.parseRtcpFb = function (line) { | ||
}; | ||
// Generate a=rtcp-fb lines from RTCRtpCodecCapability or RTCRtpCodecParameters. | ||
@@ -269,3 +273,3 @@ SDPUtils.writeRtcpFb = function (codec) { | ||
// Parses an RFC 5576 ssrc media attribute. Sample input: | ||
// Parses a RFC 5576 ssrc media attribute. Sample input: | ||
// a=ssrc:3735928559 cname:something | ||
@@ -287,2 +291,4 @@ SDPUtils.parseSsrcMedia = function (line) { | ||
// Parse a ssrc-group line (see RFC 5576). Sample input: | ||
// a=ssrc-group:semantics 12 34 | ||
SDPUtils.parseSsrcGroup = function (line) { | ||
@@ -299,3 +305,3 @@ var parts = line.substr(13).split(' '); | ||
// Extracts the MID (RFC 5888) from a media section. | ||
// returns the MID or undefined if no mid line was found. | ||
// Returns the MID or undefined if no mid line was found. | ||
SDPUtils.getMid = function (mediaSection) { | ||
@@ -308,2 +314,3 @@ var mid = SDPUtils.matchPrefix(mediaSection, 'a=mid:')[0]; | ||
// Parses a fingerprint line for DTLS-SRTP. | ||
SDPUtils.parseFingerprint = function (line) { | ||
@@ -313,3 +320,3 @@ var parts = line.substr(14).split(' '); | ||
algorithm: parts[0].toLowerCase(), // algorithm is case-sensitive in Edge. | ||
value: parts[1] | ||
value: parts[1].toUpperCase() // the definition is upper-case in RFC 4572. | ||
}; | ||
@@ -323,4 +330,3 @@ }; | ||
var lines = SDPUtils.matchPrefix(mediaSection + sessionpart, 'a=fingerprint:'); | ||
// Note: a=setup line is ignored since we use the 'auto' role. | ||
// Note2: 'algorithm' is not case sensitive except in Edge. | ||
// Note: a=setup line is ignored since we use the 'auto' role in Edge. | ||
return { | ||
@@ -327,0 +333,0 @@ role: 'auto', |
{ | ||
"name": "sdp", | ||
"version": "3.0.2", | ||
"version": "3.0.3", | ||
"description": "SDP parsing and serialization utilities", | ||
@@ -14,3 +14,3 @@ "main": "dist/sdp.js", | ||
"build": "babel sdp.js --presets babel-preset-env --out-dir dist", | ||
"coverage": "nyc report --reporter=text-lcov > coverage.lcov && codecov", | ||
"coverage": "nyc report --reporter=text-lcov > coverage.lcov", | ||
"prepare": "npm run build", | ||
@@ -17,0 +17,0 @@ "test": "eslint sdp.js test/sdp.js && nyc --reporter html mocha test/sdp.js" |
38
sdp.js
@@ -27,3 +27,3 @@ /* eslint-env node */ | ||
// returns the session description. | ||
// Returns the session description. | ||
SDPUtils.getDescription = function(blob) { | ||
@@ -34,3 +34,3 @@ const sections = SDPUtils.splitSections(blob); | ||
// returns the individual media sections. | ||
// Returns the individual media sections. | ||
SDPUtils.getMediaSections = function(blob) { | ||
@@ -50,2 +50,3 @@ const sections = SDPUtils.splitSections(blob); | ||
// rport 55996" | ||
// Input can be prefixed with a=. | ||
SDPUtils.parseCandidate = function(line) { | ||
@@ -62,3 +63,3 @@ let parts; | ||
foundation: parts[0], | ||
component: {1: 'rtp', 2: 'rtcp'}[parts[1]], | ||
component: {1: 'rtp', 2: 'rtcp'}[parts[1]] || parts[1], | ||
protocol: parts[2].toLowerCase(), | ||
@@ -99,2 +100,3 @@ priority: parseInt(parts[3], 10), | ||
// Translates a candidate object into SDP candidate attribute. | ||
// This does not include the a= prefix! | ||
SDPUtils.writeCandidate = function(candidate) { | ||
@@ -139,2 +141,3 @@ const sdp = []; | ||
// Parses an ice-options line, returns an array of option tags. | ||
// Sample input: | ||
// a=ice-options:foo bar | ||
@@ -145,3 +148,3 @@ SDPUtils.parseIceOptions = function(line) { | ||
// Parses an rtpmap line, returns RTCRtpCoddecParameters. Sample input: | ||
// Parses a rtpmap line, returns RTCRtpCoddecParameters. Sample input: | ||
// a=rtpmap:111 opus/48000/2 | ||
@@ -164,3 +167,3 @@ SDPUtils.parseRtpMap = function(line) { | ||
// Generate an a=rtpmap line from RTCRtpCodecCapability or | ||
// Generates a rtpmap line from RTCRtpCodecCapability or | ||
// RTCRtpCodecParameters. | ||
@@ -177,3 +180,3 @@ SDPUtils.writeRtpMap = function(codec) { | ||
// Parses an a=extmap line (headerextension from RFC 5285). Sample input: | ||
// Parses a extmap line (headerextension from RFC 5285). Sample input: | ||
// a=extmap:2 urn:ietf:params:rtp-hdrext:toffset | ||
@@ -190,3 +193,3 @@ // a=extmap:2/sendonly urn:ietf:params:rtp-hdrext:toffset | ||
// Generates a=extmap line from RTCRtpHeaderExtensionParameters or | ||
// Generates an extmap line from RTCRtpHeaderExtensionParameters or | ||
// RTCRtpHeaderExtension. | ||
@@ -201,3 +204,3 @@ SDPUtils.writeExtmap = function(headerExtension) { | ||
// Parses an ftmp line, returns dictionary. Sample input: | ||
// Parses a fmtp line, returns dictionary. Sample input: | ||
// a=fmtp:96 vbr=on;cng=on | ||
@@ -216,3 +219,3 @@ // Also deals with vbr=on; cng=on | ||
// Generates an a=ftmp line from RTCRtpCodecCapability or RTCRtpCodecParameters. | ||
// Generates a fmtp line from RTCRtpCodecCapability or RTCRtpCodecParameters. | ||
SDPUtils.writeFmtp = function(codec) { | ||
@@ -227,3 +230,3 @@ let line = ''; | ||
Object.keys(codec.parameters).forEach(param => { | ||
if (codec.parameters[param]) { | ||
if (codec.parameters[param] !== undefined) { | ||
params.push(param + '=' + codec.parameters[param]); | ||
@@ -239,3 +242,3 @@ } else { | ||
// Parses an rtcp-fb line, returns RTCPRtcpFeedback object. Sample input: | ||
// Parses a rtcp-fb line, returns RTCPRtcpFeedback object. Sample input: | ||
// a=rtcp-fb:98 nack rpsi | ||
@@ -249,2 +252,3 @@ SDPUtils.parseRtcpFb = function(line) { | ||
}; | ||
// Generate a=rtcp-fb lines from RTCRtpCodecCapability or RTCRtpCodecParameters. | ||
@@ -268,3 +272,3 @@ SDPUtils.writeRtcpFb = function(codec) { | ||
// Parses an RFC 5576 ssrc media attribute. Sample input: | ||
// Parses a RFC 5576 ssrc media attribute. Sample input: | ||
// a=ssrc:3735928559 cname:something | ||
@@ -286,2 +290,4 @@ SDPUtils.parseSsrcMedia = function(line) { | ||
// Parse a ssrc-group line (see RFC 5576). Sample input: | ||
// a=ssrc-group:semantics 12 34 | ||
SDPUtils.parseSsrcGroup = function(line) { | ||
@@ -296,3 +302,3 @@ const parts = line.substr(13).split(' '); | ||
// Extracts the MID (RFC 5888) from a media section. | ||
// returns the MID or undefined if no mid line was found. | ||
// Returns the MID or undefined if no mid line was found. | ||
SDPUtils.getMid = function(mediaSection) { | ||
@@ -305,2 +311,3 @@ const mid = SDPUtils.matchPrefix(mediaSection, 'a=mid:')[0]; | ||
// Parses a fingerprint line for DTLS-SRTP. | ||
SDPUtils.parseFingerprint = function(line) { | ||
@@ -310,3 +317,3 @@ const parts = line.substr(14).split(' '); | ||
algorithm: parts[0].toLowerCase(), // algorithm is case-sensitive in Edge. | ||
value: parts[1], | ||
value: parts[1].toUpperCase(), // the definition is upper-case in RFC 4572. | ||
}; | ||
@@ -321,4 +328,3 @@ }; | ||
'a=fingerprint:'); | ||
// Note: a=setup line is ignored since we use the 'auto' role. | ||
// Note2: 'algorithm' is not case sensitive except in Edge. | ||
// Note: a=setup line is ignored since we use the 'auto' role in Edge. | ||
return { | ||
@@ -325,0 +331,0 @@ role: 'auto', |
1583
125879
11