diff --git a/package.json b/package.json index ce52cca47..2fea39b08 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ "beefy": "^2.1.5", "browserify": "^4.1.8", "grunt": "~0.4.0", - "grunt-browserify": "^2.1.0", + "grunt-browserify": "^4.0.1", "grunt-cli": "~0.1.6", "grunt-contrib-copy": "^0.5.0", "grunt-contrib-jasmine": "~0.8.0", diff --git a/src/SanityCheck.js b/src/SanityCheck.js index ffe6ba3a0..a66825a7c 100644 --- a/src/SanityCheck.js +++ b/src/SanityCheck.js @@ -20,6 +20,33 @@ var sanityCheck, responses = [], all = []; +// Reply +function reply(status_code) { + var to, + response = SIP.Utils.buildStatusLine(status_code), + vias = message.getHeaders('via'), + length = vias.length, + idx = 0; + + for(idx; idx < length; idx++) { + response += "Via: " + vias[idx] + "\r\n"; + } + + to = message.getHeader('To'); + + if(!message.to_tag) { + to += ';tag=' + SIP.Utils.newTag(); + } + + response += "To: " + to + "\r\n"; + response += "From: " + message.getHeader('From') + "\r\n"; + response += "Call-ID: " + message.call_id + "\r\n"; + response += "CSeq: " + message.cseq + " " + message.method + "\r\n"; + response += "\r\n"; + + transport.send(response); +} + /* * Sanity Check for incoming Messages * @@ -145,33 +172,6 @@ function minimumHeaders() { } } -// Reply -function reply(status_code) { - var to, - response = SIP.Utils.buildStatusLine(status_code), - vias = message.getHeaders('via'), - length = vias.length, - idx = 0; - - for(idx; idx < length; idx++) { - response += "Via: " + vias[idx] + "\r\n"; - } - - to = message.getHeader('To'); - - if(!message.to_tag) { - to += ';tag=' + SIP.Utils.newTag(); - } - - response += "To: " + to + "\r\n"; - response += "From: " + message.getHeader('From') + "\r\n"; - response += "Call-ID: " + message.call_id + "\r\n"; - response += "CSeq: " + message.cseq + " " + message.method + "\r\n"; - response += "\r\n"; - - transport.send(response); -} - requests.push(rfc3261_8_2_2_1); requests.push(rfc3261_16_3_4); requests.push(rfc3261_18_3_request); diff --git a/src/Transport.js b/src/Transport.js index 877042356..07ed75fbe 100644 --- a/src/Transport.js +++ b/src/Transport.js @@ -18,6 +18,16 @@ var Transport, STATUS_ERROR: 2 }; +/** + * Compute an amount of time in seconds to wait before sending another + * keep-alive. + * @returns {Number} + */ +function computeKeepAliveTimeout(upperBound) { + var lowerBound = upperBound * 0.8; + return 1000 * (Math.random() * (upperBound - lowerBound) + lowerBound); +} + Transport = function(ua, server) { this.logger = ua.getLogger('sip.transport'); @@ -356,16 +366,6 @@ Transport.prototype = { } }; -/** - * Compute an amount of time in seconds to wait before sending another - * keep-alive. - * @returns {Number} - */ -function computeKeepAliveTimeout(upperBound) { - var lowerBound = upperBound * 0.8; - return 1000 * (Math.random() * (upperBound - lowerBound) + lowerBound); -} - Transport.C = C; return Transport; }; diff --git a/src/WebRTC/MediaStreamManager.js b/src/WebRTC/MediaStreamManager.js index fc14db8d1..93014f410 100644 --- a/src/WebRTC/MediaStreamManager.js +++ b/src/WebRTC/MediaStreamManager.js @@ -49,15 +49,6 @@ MediaStreamManager.render = function render (streams, elements) { throw new TypeError('elements must not be empty'); } - function attachAndPlay (elements, stream, index) { - if (typeof elements === 'function') { - elements = elements(); - } - var element = elements[index % elements.length]; - (environment.attachMediaStream || attachMediaStream)(element, stream); - ensureMediaPlaying(element); - } - function attachMediaStream(element, stream) { if (typeof element.src !== 'undefined') { environment.revokeObjectURL(element.src); @@ -83,6 +74,15 @@ MediaStreamManager.render = function render (streams, elements) { }, interval); } + function attachAndPlay (elements, stream, index) { + if (typeof elements === 'function') { + elements = elements(); + } + var element = elements[index % elements.length]; + (environment.attachMediaStream || attachMediaStream)(element, stream); + ensureMediaPlaying(element); + } + // [].concat "casts" `elements` into an array // so forEach works even if `elements` was a single element elements = [].concat(elements);