sdp
Advanced tools
Comparing version 2.7.2 to 2.7.3
{ | ||
"name": "sdp", | ||
"version": "2.7.2", | ||
"version": "2.7.3", | ||
"description": "SDP parsing and serialization utilities", | ||
@@ -5,0 +5,0 @@ "main": "sdp.js", |
@@ -145,4 +145,5 @@ /* eslint-env node */ | ||
parsed.clockRate = parseInt(parts[1], 10); // was: clockrate | ||
// was: channels | ||
parsed.numChannels = parts.length === 3 ? parseInt(parts[2], 10) : 1; | ||
parsed.channels = parts.length === 3 ? parseInt(parts[2], 10) : 1; | ||
// legacy alias, got renamed back to channels in ORTC. | ||
parsed.numChannels = parsed.channels; | ||
return parsed; | ||
@@ -158,4 +159,5 @@ }; | ||
} | ||
var channels = codec.channels || codec.numChannels || 1; | ||
return 'a=rtpmap:' + pt + ' ' + codec.name + '/' + codec.clockRate + | ||
(codec.numChannels !== 1 ? '/' + codec.numChannels : '') + '\r\n'; | ||
(channels !== 1 ? '/' + channels : '') + '\r\n'; | ||
}; | ||
@@ -162,0 +164,0 @@ |
@@ -223,3 +223,7 @@ /* jshint node: true */ | ||
it('parses numChannels as an integer', () => { | ||
it('parses channels as an integer', () => { | ||
expect(parsed.channels).to.equal(2); | ||
}); | ||
it('parses numChannels (legacy) as an integer', () => { | ||
expect(parsed.numChannels).to.equal(2); | ||
@@ -255,3 +259,3 @@ }); | ||
it('does not append numChannels when there is only one channel', () => { | ||
it('does not append channels when there is only one channel', () => { | ||
let out = SDPUtils.writeRtpMap({ | ||
@@ -261,6 +265,15 @@ payloadType: 0, | ||
clockRate: 8000, | ||
numChannels: 1 | ||
channels: 1 | ||
}).trim(); | ||
expect(out).to.equal('a=rtpmap:0 pcmu/8000'); | ||
}); | ||
it('does not append channels when channels is undefined', () => { | ||
let out = SDPUtils.writeRtpMap({ | ||
payloadType: 0, | ||
name: 'pcmu', | ||
clockRate: 8000 | ||
}).trim(); | ||
expect(out).to.equal('a=rtpmap:0 pcmu/8000'); | ||
}); | ||
}); | ||
@@ -267,0 +280,0 @@ }); |
52882
1357