Comparing version 2.7.4 to 2.8.0
{ | ||
"name": "sdp", | ||
"version": "2.7.4", | ||
"version": "2.8.0", | ||
"description": "SDP parsing and serialization utilities", | ||
@@ -22,6 +22,6 @@ "main": "sdp.js", | ||
"chai": "^4.0.0", | ||
"codecov": "^2.2.0", | ||
"codecov": "^3.0.4", | ||
"eslint": "^2.8.0", | ||
"mocha": "^3.4.2", | ||
"nyc": "^10.3.2", | ||
"mocha": "^5.2.0", | ||
"nyc": "^13.0.0", | ||
"sinon": "^2.3.2", | ||
@@ -28,0 +28,0 @@ "sinon-chai": "^2.10.0" |
45
sdp.js
@@ -131,3 +131,3 @@ /* eslint-env node */ | ||
return line.substr(14).split(' '); | ||
} | ||
}; | ||
@@ -265,2 +265,12 @@ // Parses an rtpmap line, returns RTCRtpCoddecParameters. Sample input: | ||
SDPUtils.parseSsrcGroup = function(line) { | ||
var parts = line.substr(13).split(' '); | ||
return { | ||
semantics: parts.shift(), | ||
ssrcs: parts.map(function(ssrc) { | ||
return parseInt(ssrc, 10); | ||
}) | ||
}; | ||
}; | ||
// Extracts the MID (RFC 5888) from a media section. | ||
@@ -273,3 +283,3 @@ // returns the MID or undefined if no mid line was found. | ||
} | ||
} | ||
}; | ||
@@ -451,3 +461,3 @@ SDPUtils.parseFingerprint = function(line) { | ||
ssrc: primarySsrc, | ||
codecPayloadType: parseInt(codec.parameters.apt, 10), | ||
codecPayloadType: parseInt(codec.parameters.apt, 10) | ||
}; | ||
@@ -497,4 +507,3 @@ if (primarySsrc && secondarySsrc) { | ||
var cname; | ||
// Gets the first SSRC. Note that with RTX there might be multiple | ||
// Gets the first SSRC. Note tha with RTX there might be multiple | ||
// SSRCs. | ||
@@ -540,4 +549,4 @@ var remoteSsrc = SDPUtils.matchPrefix(mediaSection, 'a=ssrc:') | ||
}) | ||
.filter(function(parts) { | ||
return parts.attribute === 'msid'; | ||
.filter(function(msidParts) { | ||
return msidParts.attribute === 'msid'; | ||
}); | ||
@@ -572,3 +581,4 @@ if (planB.length > 0) { | ||
return 'v=0\r\n' + | ||
'o=thisisadapterortc ' + sessionId + ' ' + version + ' IN IP4 127.0.0.1\r\n' + | ||
'o=thisisadapterortc ' + sessionId + ' ' + version + | ||
' IN IP4 127.0.0.1\r\n' + | ||
's=-\r\n' + | ||
@@ -683,6 +693,21 @@ 't=0 0\r\n'; | ||
addressType: parts[4], | ||
address: parts[5], | ||
address: parts[5] | ||
}; | ||
} | ||
}; | ||
// a very naive interpretation of a valid SDP. | ||
SDPUtils.isValidSDP = function(blob) { | ||
if (typeof blob !== 'string' || blob.length === 0) { | ||
return false; | ||
} | ||
var lines = SDPUtils.splitLines(blob); | ||
for (var i = 0; i < lines.length; i++) { | ||
if (lines[i].length < 2 || lines[i].charAt(1) !== '=') { | ||
return false; | ||
} | ||
// TODO: check the modifier a bit more. | ||
} | ||
return true; | ||
}; | ||
// Expose public methods. | ||
@@ -689,0 +714,0 @@ if (typeof module === 'object') { |
84777
9
646