Comparing version 2.9.0 to 2.10.0
{ | ||
"name": "sdp", | ||
"version": "2.9.0", | ||
"version": "2.10.0", | ||
"description": "SDP parsing and serialization utilities", | ||
@@ -23,5 +23,5 @@ "main": "sdp.js", | ||
"codecov": "^3.0.4", | ||
"eslint": "^2.8.0", | ||
"eslint": "^6.0.1", | ||
"mocha": "^5.2.0", | ||
"nyc": "^13.0.0", | ||
"nyc": "^14.1.1", | ||
"sinon": "^2.3.2", | ||
@@ -28,0 +28,0 @@ "sinon-chai": "^2.10.0" |
126
sdp.js
@@ -1,2 +0,2 @@ | ||
/* eslint-env node */ | ||
/* eslint-env node */ | ||
'use strict'; | ||
@@ -181,4 +181,4 @@ | ||
(headerExtension.direction && headerExtension.direction !== 'sendrecv' | ||
? '/' + headerExtension.direction | ||
: '') + | ||
? '/' + headerExtension.direction | ||
: '') + | ||
' ' + headerExtension.uri + '\r\n'; | ||
@@ -298,3 +298,3 @@ }; | ||
var lines = SDPUtils.matchPrefix(mediaSection + sessionpart, | ||
'a=fingerprint:'); | ||
'a=fingerprint:'); | ||
// Note: a=setup line is ignored since we use the 'auto' role. | ||
@@ -353,11 +353,11 @@ // Note2: 'algorithm' is not case sensitive except in Edge. | ||
var rtpmapline = SDPUtils.matchPrefix( | ||
mediaSection, 'a=rtpmap:' + pt + ' ')[0]; | ||
mediaSection, 'a=rtpmap:' + pt + ' ')[0]; | ||
if (rtpmapline) { | ||
var codec = SDPUtils.parseRtpMap(rtpmapline); | ||
var fmtps = SDPUtils.matchPrefix( | ||
mediaSection, 'a=fmtp:' + pt + ' '); | ||
mediaSection, 'a=fmtp:' + pt + ' '); | ||
// Only the first a=fmtp:<pt> is considered. | ||
codec.parameters = fmtps.length ? SDPUtils.parseFmtp(fmtps[0]) : {}; | ||
codec.rtcpFeedback = SDPUtils.matchPrefix( | ||
mediaSection, 'a=rtcp-fb:' + pt + ' ') | ||
mediaSection, 'a=rtcp-fb:' + pt + ' ') | ||
.map(SDPUtils.parseRtcpFb); | ||
@@ -438,8 +438,8 @@ description.codecs.push(codec); | ||
var ssrcs = SDPUtils.matchPrefix(mediaSection, 'a=ssrc:') | ||
.map(function(line) { | ||
return SDPUtils.parseSsrcMedia(line); | ||
}) | ||
.filter(function(parts) { | ||
return parts.attribute === 'cname'; | ||
}); | ||
.map(function(line) { | ||
return SDPUtils.parseSsrcMedia(line); | ||
}) | ||
.filter(function(parts) { | ||
return parts.attribute === 'cname'; | ||
}); | ||
var primarySsrc = ssrcs.length > 0 && ssrcs[0].ssrc; | ||
@@ -449,8 +449,8 @@ var secondarySsrc; | ||
var flows = SDPUtils.matchPrefix(mediaSection, 'a=ssrc-group:FID') | ||
.map(function(line) { | ||
var parts = line.substr(17).split(' '); | ||
return parts.map(function(part) { | ||
return parseInt(part, 10); | ||
.map(function(line) { | ||
var parts = line.substr(17).split(' '); | ||
return parts.map(function(part) { | ||
return parseInt(part, 10); | ||
}); | ||
}); | ||
}); | ||
if (flows.length > 0 && flows[0].length > 1 && flows[0][0] === primarySsrc) { | ||
@@ -512,8 +512,8 @@ secondarySsrc = flows[0][1]; | ||
var remoteSsrc = SDPUtils.matchPrefix(mediaSection, 'a=ssrc:') | ||
.map(function(line) { | ||
return SDPUtils.parseSsrcMedia(line); | ||
}) | ||
.filter(function(obj) { | ||
return obj.attribute === 'cname'; | ||
})[0]; | ||
.map(function(line) { | ||
return SDPUtils.parseSsrcMedia(line); | ||
}) | ||
.filter(function(obj) { | ||
return obj.attribute === 'cname'; | ||
})[0]; | ||
if (remoteSsrc) { | ||
@@ -548,8 +548,8 @@ rtcpParameters.cname = remoteSsrc.value; | ||
var planB = SDPUtils.matchPrefix(mediaSection, 'a=ssrc:') | ||
.map(function(line) { | ||
return SDPUtils.parseSsrcMedia(line); | ||
}) | ||
.filter(function(msidParts) { | ||
return msidParts.attribute === 'msid'; | ||
}); | ||
.map(function(line) { | ||
return SDPUtils.parseSsrcMedia(line); | ||
}) | ||
.filter(function(msidParts) { | ||
return msidParts.attribute === 'msid'; | ||
}); | ||
if (planB.length > 0) { | ||
@@ -561,2 +561,62 @@ parts = planB[0].value.split(' '); | ||
// SCTP | ||
// parses draft-ietf-mmusic-sctp-sdp-26 first and falls back | ||
// to draft-ietf-mmusic-sctp-sdp-05 | ||
SDPUtils.parseSctpDescription = function(mediaSection) { | ||
var mline = SDPUtils.parseMLine(mediaSection); | ||
var maxSizeLine = SDPUtils.matchPrefix(mediaSection, 'a=max-message-size:'); | ||
var maxMessageSize; | ||
if (maxSizeLine.length > 0) { | ||
maxMessageSize = parseInt(maxSizeLine[0].substr(19), 10); | ||
} | ||
if (isNaN(maxMessageSize)) { | ||
maxMessageSize = 65536; | ||
} | ||
var sctpPort = SDPUtils.matchPrefix(mediaSection, 'a=sctp-port:'); | ||
if (sctpPort.length > 0) { | ||
return { | ||
port: parseInt(sctpPort[0].substr(12), 10), | ||
protocol: mline.fmt, | ||
maxMessageSize: maxMessageSize | ||
}; | ||
} | ||
var sctpMapLines = SDPUtils.matchPrefix(mediaSection, 'a=sctpmap:'); | ||
if (sctpMapLines.length > 0) { | ||
var parts = SDPUtils.matchPrefix(mediaSection, 'a=sctpmap:')[0] | ||
.substr(10) | ||
.split(' '); | ||
return { | ||
port: parseInt(parts[0], 10), | ||
protocol: parts[1], | ||
maxMessageSize: maxMessageSize | ||
}; | ||
} | ||
}; | ||
// SCTP | ||
// outputs the draft-ietf-mmusic-sctp-sdp-26 version that all browsers | ||
// support by now receiving in this format, unless we originally parsed | ||
// as the draft-ietf-mmusic-sctp-sdp-05 format (indicated by the m-line | ||
// protocol of DTLS/SCTP -- without UDP/ or TCP/) | ||
SDPUtils.writeSctpDescription = function(media, sctp) { | ||
var output = []; | ||
if (media.protocol !== 'DTLS/SCTP') { | ||
output = [ | ||
'm=' + media.kind + ' 9 ' + media.protocol + ' ' + sctp.protocol + '\r\n', | ||
'c=IN IP4 0.0.0.0\r\n', | ||
'a=sctp-port:' + sctp.port + '\r\n' | ||
]; | ||
} else { | ||
output = [ | ||
'm=' + media.kind + ' 9 ' + media.protocol + ' ' + sctp.port + '\r\n', | ||
'c=IN IP4 0.0.0.0\r\n', | ||
'a=sctpmap:' + sctp.port + ' ' + sctp.protocol + ' 65535\r\n' | ||
]; | ||
} | ||
if (sctp.maxMessageSize !== undefined) { | ||
output.push('a=max-message-size:' + sctp.maxMessageSize + '\r\n'); | ||
} | ||
return output.join(''); | ||
}; | ||
// Generate a session ID for SDP. | ||
@@ -597,8 +657,8 @@ // https://tools.ietf.org/html/draft-ietf-rtcweb-jsep-20#section-5.2.1 | ||
sdp += SDPUtils.writeIceParameters( | ||
transceiver.iceGatherer.getLocalParameters()); | ||
transceiver.iceGatherer.getLocalParameters()); | ||
// Map DTLS parameters to SDP. | ||
sdp += SDPUtils.writeDtlsParameters( | ||
transceiver.dtlsTransport.getLocalParameters(), | ||
type === 'offer' ? 'actpass' : 'active'); | ||
transceiver.dtlsTransport.getLocalParameters(), | ||
type === 'offer' ? 'actpass' : 'active'); | ||
@@ -605,0 +665,0 @@ sdp += 'a=mid:' + transceiver.mid + '\r\n'; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
89692
12
707