Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.6.3",
"version": "0.6.4",
"authors": [
"Will Mitchell <will@onsip.com>",
"James Criscuolo <james@onsip.com>",
Expand Down
93 changes: 66 additions & 27 deletions dist/sip.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* SIP version 0.6.3
* SIP version 0.6.4
* Copyright (c) 2014-2014 Junction Networks, Inc <http://www.onsip.com>
* Homepage: http://sipjs.com
* License: http://sipjs.com/license/
Expand Down Expand Up @@ -37,7 +37,7 @@ module.exports={
"name": "sip.js",
"title": "SIP.js",
"description": "A simple, intuitive, and powerful JavaScript signaling library",
"version": "0.6.3",
"version": "0.6.4",
"main": "src/SIP.js",
"homepage": "http://sipjs.com",
"author": "Will Mitchell <will@onsip.com>",
Expand Down Expand Up @@ -2445,12 +2445,8 @@ module.exports = function(SIP) {
* as to most easily track when particular hacks may not be necessary anymore.
*/

module.exports = function (window) {

var Hacks;

Hacks = {

module.exports = function (SIP) {
var Hacks = {
AllBrowsers: {
maskDtls: function (message) {
if (message.body) {
Expand Down Expand Up @@ -2478,12 +2474,6 @@ Hacks = {
return window.mozRTCPeerConnection !== undefined;
},

cannotHandleRelayCandidates: function (message) {
if (this.isFirefox() && message.body) {
message.body = message.body.replace(/relay/g, 'host generation 0');
}
},

cannotHandleExtraWhitespace: function (message) {
if (this.isFirefox() && message.body) {
message.body = message.body.replace(/ \r\n/g, "\r\n");
Expand Down Expand Up @@ -2516,7 +2506,7 @@ Hacks = {
if (mlines[i].toString().search(/i=.*/) >= 0) {
insertAt = sdp.indexOf(mlines[i].toString())+mlines[i].toString().length;
if (sdp.substr(insertAt,2)!=='c=') {
sdp = sdp.substr(0,insertAt) + '\r\nc=IN IP 4 0.0.0.0' + sdp.substr(insertAt);
sdp = sdp.substr(0,insertAt) + '\r\nc=IN IP4 0.0.0.0' + sdp.substr(insertAt);
}

// else add the C line if it's missing
Expand All @@ -2527,6 +2517,19 @@ Hacks = {
}
}
return sdp;
},

hasIncompatibleCLineWithSomeSIPEndpoints: function(sdp) {
/*
* Firefox appears to be following https://tools.ietf.org/html/rfc5245#section-9.1.1.1
* and using a c line IP address of 0.0.0.0. This is completely valid, however it is
* causing some endpoints (such as FreeSWITCH) to interpret the SDP as being on hold
* https://freeswitch.org/jira/browse/FS-6955. To get around this issue we pull the
* replace the c line with 1.1.1.1 which SIP clients do not interpret as hold.
* This makes the other endpoint believe that the call is not on hold and audio flows
* because ICE determines the media pathway (not the c line).
*/
return sdp.replace(/(0\.0\.0\.0)/gmi, SIP.Utils.getRandomTestNetIP());
}
},

Expand Down Expand Up @@ -2554,10 +2557,10 @@ Hacks = {
}
};


return Hacks;
};


},{}],11:[function(_dereq_,module,exports){

module.exports = (function() {
Expand Down Expand Up @@ -3623,7 +3626,7 @@ module.exports = (function(window) {
var WebRTCMediaStreamManager = _dereq_('./WebRTC/MediaStreamManager.js')(SIP);
SIP.WebRTC = _dereq_('./WebRTC.js')(SIP.Utils, window, WebRTCMediaHandler, WebRTCMediaStreamManager);
_dereq_('./UA.js')(SIP, window);
SIP.Hacks = _dereq_('./Hacks.js')(window);
SIP.Hacks = _dereq_('./Hacks.js')(SIP);
_dereq_('./SanityCheck.js')(SIP);
SIP.DigestAuthentication = _dereq_('./DigestAuthentication.js')(SIP.Utils);
SIP.Grammar = _dereq_('./Grammar/dist/Grammar')(SIP);
Expand Down Expand Up @@ -5507,7 +5510,6 @@ InviteServerContext = function(ua, request) {
}

//TODO: move this into media handler
SIP.Hacks.Firefox.cannotHandleRelayCandidates(request);
SIP.Hacks.Firefox.cannotHandleExtraWhitespace(request);
SIP.Hacks.AllBrowsers.maskDtls(request);

Expand Down Expand Up @@ -5805,7 +5807,7 @@ InviteServerContext.prototype = {
*/
accept: function(options) {
options = options || {};

options = SIP.Utils.desugarSessionOptions(options);
SIP.Utils.optionsOverride(options, 'media', 'mediaConstraints', true, this.logger, this.ua.configuration.media);
this.mediaHint = options.media;

Expand Down Expand Up @@ -5983,7 +5985,6 @@ InviteServerContext.prototype = {
if (!this.hasAnswer) {
if(request.body && request.getHeader('content-type') === 'application/sdp') {
// ACK contains answer to an INVITE w/o SDP negotiation
SIP.Hacks.Firefox.cannotHandleRelayCandidates(request);
SIP.Hacks.Firefox.cannotHandleExtraWhitespace(request);
SIP.Hacks.AllBrowsers.maskDtls(request);

Expand Down Expand Up @@ -6353,7 +6354,6 @@ InviteClientContext.prototype = {
return;
}

SIP.Hacks.Firefox.cannotHandleRelayCandidates(response);
SIP.Hacks.Firefox.cannotHandleExtraWhitespace(response);
SIP.Hacks.AllBrowsers.maskDtls(response);

Expand Down Expand Up @@ -6480,7 +6480,6 @@ InviteClientContext.prototype = {
break;
}

SIP.Hacks.Firefox.cannotHandleRelayCandidates(response);
SIP.Hacks.Firefox.cannotHandleExtraWhitespace(response);
SIP.Hacks.AllBrowsers.maskDtls(response);

Expand Down Expand Up @@ -8486,6 +8485,7 @@ UA.prototype.isConnected = function() {
*/
UA.prototype.invite = function(target, options) {
options = options || {};
options = SIP.Utils.desugarSessionOptions(options);
SIP.Utils.optionsOverride(options, 'media', 'mediaConstraints', true, this.logger);

var context = new SIP.InviteClientContext(this, target, options);
Expand Down Expand Up @@ -9132,6 +9132,7 @@ UA.prototype.loadConfig = function(configuration) {
// Hacks
hackViaTcp: false,
hackIpInContact: false,
hackWssInTransport: false,

//autostarting
autostart: true,
Expand Down Expand Up @@ -9181,14 +9182,19 @@ UA.prototype.loadConfig = function(configuration) {

SIP.Utils.optionsOverride(configuration, 'rel100', 'reliable', true, this.logger, SIP.C.supported.UNSUPPORTED);

var emptyArraysAllowed = ['stunServers', 'turnServers'];

// Check Optional parameters
for(parameter in UA.configuration_check.optional) {
aliasUnderscored(parameter, this.logger);
if(configuration.hasOwnProperty(parameter)) {
value = configuration[parameter];

// If the parameter value is null, empty string,undefined, or empty array then apply its default value.
if(value === null || value === "" || value === undefined || (value instanceof Array && value.length === 0)) { continue; }
// If the parameter value is an empty array, but shouldn't be, apply its default value.
if (value instanceof Array && value.length === 0 && emptyArraysAllowed.indexOf(parameter) < 0) { continue; }

// If the parameter value is null, empty string, or undefined then apply its default value.
if(value === null || value === "" || value === undefined) { continue; }
// If it's a number with NaN value then also apply its default value.
// NOTE: JS does not allow "value === NaN", the following does the work:
else if(typeof(value) === 'number' && isNaN(value)) { continue; }
Expand Down Expand Up @@ -9254,7 +9260,7 @@ UA.prototype.loadConfig = function(configuration) {
this.contact = {
pub_gruu: null,
temp_gruu: null,
uri: new SIP.URI('sip', SIP.Utils.createRandomToken(8), settings.viaHost, null, {transport: 'ws'}),
uri: new SIP.URI('sip', SIP.Utils.createRandomToken(8), settings.viaHost, null, {transport: ((settings.hackWssInTransport)?'wss':'ws')}),
toString: function(options){
options = options || {};

Expand All @@ -9264,7 +9270,7 @@ UA.prototype.loadConfig = function(configuration) {
contact = '<';

if (anonymous) {
contact += (this.temp_gruu || 'sip:anonymous@anonymous.invalid;transport=ws').toString();
contact += (this.temp_gruu || ('sip:anonymous@anonymous.invalid;transport='+(settings.hackWssInTransport)?'wss':'ws')).toString();
} else {
contact += (this.pub_gruu || this.uri).toString();
}
Expand Down Expand Up @@ -9334,6 +9340,7 @@ UA.configuration_skeleton = (function() {
"displayName",
"hackViaTcp", // false.
"hackIpInContact", //false
"hackWssInTransport", //false
"instanceId",
"noAnswerTimeout", // 30 seconds.
"password",
Expand Down Expand Up @@ -9508,6 +9515,12 @@ UA.configuration_check = {
}
},

hackWssInTransport: function(hackWssInTransport) {
if (typeof hackWssInTransport === 'boolean') {
return hackWssInTransport;
}
},

instanceId: function(instanceId) {
if(typeof instanceId !== 'string') {
return;
Expand Down Expand Up @@ -9912,6 +9925,7 @@ SIP.URI = URI;
};

},{}],30:[function(_dereq_,module,exports){
(function (global){
/**
* @fileoverview Utils
*/
Expand Down Expand Up @@ -9948,6 +9962,25 @@ Utils= {
options[winner] = options[winner] || options[loser] || defaultValue;
},

desugarSessionOptions: function desugarSessionOptions (options) {
if (global.HTMLMediaElement && options instanceof global.HTMLMediaElement) {
options = {
media: {
constraints: {
audio: true,
video: options.tagName === 'VIDEO'
},
render: {
remote: {
video: options
}
}
}
};
}
return options;
},

str_utf8_length: function(string) {
return encodeURIComponent(string).replace(/%[A-F\d]{2}/g, 'U').length;
},
Expand Down Expand Up @@ -10376,6 +10409,7 @@ Utils= {
SIP.Utils = Utils;
};

}).call(this,typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
},{}],31:[function(_dereq_,module,exports){
/**
* @fileoverview WebRTC
Expand Down Expand Up @@ -10435,6 +10469,7 @@ var MediaHandler = function(session, options) {
'userMedia',
'userMediaFailed',
'iceGathering',
'iceCandidate',
'iceComplete',
'iceFailed',
'getDescription',
Expand Down Expand Up @@ -10472,7 +10507,9 @@ var MediaHandler = function(session, options) {
/* Change 'url' to 'urls' whenever this issue is solved:
* https://code.google.com/p/webrtc/issues/detail?id=2096
*/
servers.push({'url': stunServers});
[].concat(stunServers).forEach(function (server) {
servers.push({'url': server});
});

length = turnServers.length;
for (idx = 0; idx < length; idx++) {
Expand All @@ -10497,6 +10534,7 @@ var MediaHandler = function(session, options) {
};

this.peerConnection.onicecandidate = function(e) {
self.emit('iceCandidate', e);
if (e.candidate) {
self.logger.log('ICE candidate received: '+ (e.candidate.candidate === null ? null : e.candidate.candidate.trim()));
} else if (self.onIceCompleted !== undefined) {
Expand Down Expand Up @@ -10831,6 +10869,7 @@ MediaHandler.prototype = Object.create(SIP.MediaHandler.prototype, {

sdp = SIP.Hacks.Chrome.needsExplicitlyInactiveSDP(sdp);
sdp = SIP.Hacks.AllBrowsers.unmaskDtls(sdp);
sdp = SIP.Hacks.Firefox.hasIncompatibleCLineWithSomeSIPEndpoints(sdp);

var sdpWrapper = {
type: methodName === 'createOffer' ? 'offer' : 'answer',
Expand Down
14 changes: 7 additions & 7 deletions dist/sip.min.js

Large diffs are not rendered by default.

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.6.3",
"version": "0.6.4",
"main": "src/SIP.js",
"homepage": "http://sipjs.com",
"author": "Will Mitchell <will@onsip.com>",
Expand Down
2 changes: 1 addition & 1 deletion plugin.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='utf-8'?>
<plugin id="com.sipjs" version="0.6.3" xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android">
<plugin id="com.sipjs" version="0.6.4" xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android">
<name>sip.js</name>
<!--
Using src/SIP.js has issues with require('../package.json')
Expand Down
31 changes: 17 additions & 14 deletions src/Hacks.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,8 @@
* as to most easily track when particular hacks may not be necessary anymore.
*/

module.exports = function (window) {

var Hacks;

Hacks = {

module.exports = function (SIP) {
var Hacks = {
AllBrowsers: {
maskDtls: function (message) {
if (message.body) {
Expand Down Expand Up @@ -39,12 +35,6 @@ Hacks = {
return window.mozRTCPeerConnection !== undefined;
},

cannotHandleRelayCandidates: function (message) {
if (this.isFirefox() && message.body) {
message.body = message.body.replace(/relay/g, 'host generation 0');
}
},

cannotHandleExtraWhitespace: function (message) {
if (this.isFirefox() && message.body) {
message.body = message.body.replace(/ \r\n/g, "\r\n");
Expand Down Expand Up @@ -77,7 +67,7 @@ Hacks = {
if (mlines[i].toString().search(/i=.*/) >= 0) {
insertAt = sdp.indexOf(mlines[i].toString())+mlines[i].toString().length;
if (sdp.substr(insertAt,2)!=='c=') {
sdp = sdp.substr(0,insertAt) + '\r\nc=IN IP 4 0.0.0.0' + sdp.substr(insertAt);
sdp = sdp.substr(0,insertAt) + '\r\nc=IN IP4 0.0.0.0' + sdp.substr(insertAt);
}

// else add the C line if it's missing
Expand All @@ -88,6 +78,19 @@ Hacks = {
}
}
return sdp;
},

hasIncompatibleCLineWithSomeSIPEndpoints: function(sdp) {
/*
* Firefox appears to be following https://tools.ietf.org/html/rfc5245#section-9.1.1.1
* and using a c line IP address of 0.0.0.0. This is completely valid, however it is
* causing some endpoints (such as FreeSWITCH) to interpret the SDP as being on hold
* https://freeswitch.org/jira/browse/FS-6955. To get around this issue we pull the
* replace the c line with 1.1.1.1 which SIP clients do not interpret as hold.
* This makes the other endpoint believe that the call is not on hold and audio flows
* because ICE determines the media pathway (not the c line).
*/
return sdp.replace(/(0\.0\.0\.0)/gmi, SIP.Utils.getRandomTestNetIP());
}
},

Expand Down Expand Up @@ -115,6 +118,6 @@ Hacks = {
}
};


return Hacks;
};

2 changes: 1 addition & 1 deletion src/SIP.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ module.exports = (function(window) {
var WebRTCMediaStreamManager = require('./WebRTC/MediaStreamManager.js')(SIP);
SIP.WebRTC = require('./WebRTC.js')(SIP.Utils, window, WebRTCMediaHandler, WebRTCMediaStreamManager);
require('./UA.js')(SIP, window);
SIP.Hacks = require('./Hacks.js')(window);
SIP.Hacks = require('./Hacks.js')(SIP);
require('./SanityCheck.js')(SIP);
SIP.DigestAuthentication = require('./DigestAuthentication.js')(SIP.Utils);
SIP.Grammar = require('./Grammar/dist/Grammar')(SIP);
Expand Down
Loading