Skip to content

Commit

Permalink
Merge branch 'master' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
egreenmachine committed Jan 10, 2018
2 parents f2630b5 + 3fbdab5 commit 8da38af
Show file tree
Hide file tree
Showing 8 changed files with 90 additions and 6 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sip.js",
"version": "0.9.1",
"version": "0.9.2",
"authors": [
"James Criscuolo <[email protected]>",
"Eric Green <[email protected]>",
Expand Down
3 changes: 2 additions & 1 deletion karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ module.exports = function(config) {
// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
'test/spec/WebRTC/SessionDescriptionHandler.spec.js': 'webpack'
'test/spec/WebRTC/SessionDescriptionHandler.spec.js': 'webpack',
'test/spec/WebRTC/Modifiers.spec.js': 'webpack'
},

// test results reporter to use
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "sip.js",
"title": "SIP.js",
"description": "A simple, intuitive, and powerful JavaScript signaling library",
"version": "0.9.1",
"version": "0.9.2",
"main": "dist/sip.min.js",
"browser": {
"./src/environment.js": "./src/environment_browser.js"
Expand Down
8 changes: 6 additions & 2 deletions src/Session.js
Original file line number Diff line number Diff line change
Expand Up @@ -567,25 +567,29 @@ Session.prototype = {
SIP.Timers.clearTimeout(self.timers.invite2xxTimer);
if (!this.sessionDescriptionHandler.hasDescription(response.getHeader('Content-Type'))) {
this.logger.error('2XX response received to re-invite but did not have a description');
this.emit('reinviteFailed', self);
this.emit('renegotiationError', new SIP.Exceptions.RenegotiationError('2XX response received to re-invite but did not have a description'));

break;
}

this.sessionDescriptionHandler.setDescription(response.body, this.sessionDescriptionHandlerOptions, this.modifiers)
.catch(function onFailure (e) {
self.logger.error('Could not set the description in 2XX response');
self.logger.error(e);
self.emit('reinviteFailed', self);
self.emit('renegotiationError', e);
self.sendRequest(SIP.C.BYE, {
extraHeaders: [SIP.Utils.getReasonHeaderValue(488, 'Not Acceptable Here')]
});
}).then(function() {
self.emit('reinviteAccepted', self);
});
break;
default:
this.disableRenegotiation = true;
this.pendingReinvite = false;
this.logger.log('Received a non 1XX or 2XX response to a re-invite');
this.emit('reinviteFailed', self);
this.emit('renegotiationError', new SIP.Exceptions.RenegotiationError('Invalid response to a re-invite'));
}
},
Expand Down Expand Up @@ -1557,7 +1561,7 @@ InviteClientContext.prototype = {
);
} else {
var earlyDialog = this.earlyDialogs[id];
var earlyMedia = earlyDialog.sessionDescriptionHandler = this.sessionDescriptionHandlerFactory(this, this.sessionDescriptionHandlerOptions);
var earlyMedia = earlyDialog.sessionDescriptionHandler = this.sessionDescriptionHandlerFactory(this, this.sessionDescriptionHandlerFactoryOptions);

earlyDialog.pracked.push(response.getHeader('rseq'));

Expand Down
2 changes: 1 addition & 1 deletion src/WebRTC/Modifiers.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Modifiers = {
},

stripTelephoneEvent: function(description) {
description.sdp = description.sdp.replace(/^a=rtpmap:\d+ telephone-event\/d+/img, "");
description.sdp = description.sdp.replace(/^a=rtpmap:\d+ telephone-event\/\d+\r\n/img, "");
return SIP.Utils.Promise.resolve(description);
},

Expand Down
2 changes: 2 additions & 0 deletions src/WebRTC/Simple.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ Simple.prototype.mute = function() {
}
this.logger.log('Muting Audio');
this.toggleMute(true);
this.emit('mute', this);
};

Simple.prototype.unmute = function() {
Expand All @@ -240,6 +241,7 @@ Simple.prototype.unmute = function() {
}
this.logger.log('Unmuting Audio');
this.toggleMute(false);
this.emit('unmute', this);
};

Simple.prototype.sendDTMF = function(tone) {
Expand Down
47 changes: 47 additions & 0 deletions test/helpers/sdp.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,3 +249,50 @@ Messages.Invite = {
},
}
};

SessionDescription = {};

SessionDescription.withTcpCandidatesAndTelephoneEvents = {
type: 'offer',
sdp: '\r\n' +
'v=0\r\n' +
'o=- 5677966312555193038 2 IN IP4 127.0.0.1\r\n' +
's=-\r\n' +
't=0 0\r\n' +
'a=group:BUNDLE audio\r\n' +
'a=msid-semantic: WMS iAR3IFaSOkZ5FIEfztgAwWF9xUvbq02PCVKC\r\n' +
'm=audio 53026 RTP/SAVPF 111 103 104 0 8 106 105 13 126\r\n' +
'c=IN IP4 199.7.173.162\r\n' +
'a=rtcp:53027 IN IP4 199.7.173.162\r\n' +
'a=candidate:2608808550 1 udp 2113937151 192.168.1.33 53974 typ host generation 0\r\n' +
'a=candidate:2608808550 2 tcp 2113937151 192.168.1.33 53974 typ host generation 0\r\n' +
'a=candidate:478089246 1 udp 1685987071 127.0.0.1 58170 typ srflx raddr 127.0.0.1 rport 58170 generation 0 network-id 1\r\n' +
'a=candidate:1099745028 1 udp 25042687 127.0.0.1 56353 typ relay raddr 127.0.0.1 rport 50998 generation 0 network-id 1\r\n' +
'a=ice-ufrag:yTSZ59T6XRf4f7+q\r\n' +
'a=ice-pwd:Qzco0YfB/GOFF9n3y1GAJyLK\r\n' +
'a=ice-options:google-ice\r\n' +
'a=fingerprint:sha-256 C8:36:3F:5B:EC:DD:D7:DB:BD:08:4A:18:68:B2:2A:57:19:29:C6:DF:00:52:3D:5D:33:A8:D6:50:48:22:B2:7F\r\n' +
'a=setup:actpass\r\n' +
'a=mid:audio\r\n' +
'a=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level\r\n' +
'a=sendrecv\r\n' +
'a=rtcp-mux\r\n' +
'a=crypto:0 AES_CM_128_HMAC_SHA1_32 inline:E0WyVK7CYWDzeiO6TFpPP6gJSC/XndKHRb8ciA9y\r\n' +
'a=crypto:1 AES_CM_128_HMAC_SHA1_80 inline:e71T3NtgK8PtmYvtNrbgi2fJL6e9xKhPPsXK7G3E\r\n' +
'a=rtpmap:111 opus/48000/2\r\n' +
'a=fmtp:111 minptime=10\r\n' +
'a=rtpmap:103 ISAC/16000\r\n' +
'a=rtpmap:104 ISAC/32000\r\n' +
'a=rtpmap:0 PCMU/8000\r\n' +
'a=rtpmap:8 PCMA/8000\r\n' +
'a=rtpmap:106 CN/32000\r\n' +
'a=rtpmap:105 CN/16000\r\n' +
'a=rtpmap:13 CN/8000\r\n' +
'a=rtpmap:126 telephone-event/8000\r\n' +
'a=maxptime:60\r\n' +
'a=ssrc:3254389050 cname:7x2CRZjJC+fBSDDl\r\n' +
'a=ssrc:3254389050 msid:iAR3IFaSOkZ5FIEfztgAwWF9xUvbq02PCVKC aa5e18ed-eb5f-4475-8383-6d6b5abae41d\r\n' +
'a=ssrc:3254389050 mslabel:iAR3IFaSOkZ5FIEfztgAwWF9xUvbq02PCVKC\r\n' +
'a=ssrc:3254389050 label:aa5e18ed-eb5f-4475-8383-6d6b5abae41d\r\n' +
'\r\n'
};
30 changes: 30 additions & 0 deletions test/spec/WebRTC/Modifiers.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
var Modifiers = require('../../../src/WebRTC/Modifiers')(SIP);

describe('WebRTC/Modifiers', function () {
var sdpWrapper;

beforeEach(function () {
sdpWrapper = SessionDescription.withTcpCandidatesAndTelephoneEvents;
});

it('should strip tcp candidates from sdp', function (done) {
Modifiers.stripTcpCandidates(sdpWrapper).then(function (description) {
expect(description.type).toBe('offer');
expect(description.sdp).toContain('a=candidate:2608808550 1 udp 2113937151 192.168.1.33 53974 typ host generation 0');
expect(description.sdp).not.toContain('a=candidate:2608808550 2 tcp 2113937151 192.168.1.33 53974 typ host generation 0');
expect(description.sdp).toContain('a=candidate:478089246 1 udp 1685987071 127.0.0.1 58170 typ srflx raddr 127.0.0.1 rport 58170 generation 0 network-id 1');
expect(description.sdp).toContain('a=candidate:1099745028 1 udp 25042687 127.0.0.1 56353 typ relay raddr 127.0.0.1 rport 50998 generation 0 network-id 1');

done();
});
});

it('should strip telephone events from sdp', function (done) {
Modifiers.stripTelephoneEvent(sdpWrapper).then(function (description) {
expect(description.type).toBe('offer');
expect(description.sdp).not.toContain('a=rtpmap:126 telephone-event/8000');

done();
});
});
})

0 comments on commit 8da38af

Please sign in to comment.