diff --git a/modules/RTC/RTCBrowserType.js b/modules/RTC/RTCBrowserType.js index 1aa9ddd11..2427fae17 100644 --- a/modules/RTC/RTCBrowserType.js +++ b/modules/RTC/RTCBrowserType.js @@ -3,6 +3,8 @@ var currentBrowser; var browserVersion; +var isAndroid; + var RTCBrowserType = { RTC_BROWSER_CHROME: "rtc_browser.chrome", @@ -55,6 +57,13 @@ var RTCBrowserType = { usesUnifiedPlan: function() { return RTCBrowserType.isFirefox(); + }, + + /** + * Whether the browser is running on an android device. + */ + isAndroid: function() { + return isAndroid; } // Add version getters for other browsers when needed @@ -157,5 +166,6 @@ function detectBrowser() { } browserVersion = detectBrowser(); +isAndroid = navigator.userAgent.indexOf('Android') != -1; module.exports = RTCBrowserType; \ No newline at end of file diff --git a/modules/RTC/RTCUtils.js b/modules/RTC/RTCUtils.js index dbd1331d0..9f29dc257 100644 --- a/modules/RTC/RTCUtils.js +++ b/modules/RTC/RTCUtils.js @@ -22,7 +22,8 @@ function getPreviousResolution(resolution) { return resName; } -function setResolutionConstraints(constraints, resolution, isAndroid) { +function setResolutionConstraints(constraints, resolution) { + var isAndroid = RTCBrowserType.isAndroid(); if (Resolutions[resolution]) { constraints.video.mandatory.minWidth = Resolutions[resolution].width; @@ -44,8 +45,7 @@ function setResolutionConstraints(constraints, resolution, isAndroid) { constraints.video.mandatory.minHeight; } -function getConstraints(um, resolution, bandwidth, fps, desktopStream, isAndroid) -{ +function getConstraints(um, resolution, bandwidth, fps, desktopStream) { var constraints = {audio: false, video: false}; if (um.indexOf('video') >= 0) { @@ -54,7 +54,7 @@ function getConstraints(um, resolution, bandwidth, fps, desktopStream, isAndroid constraints.video.optional.push({ googLeakyBucket: true }); - setResolutionConstraints(constraints, resolution, isAndroid); + setResolutionConstraints(constraints, resolution); } if (um.indexOf('audio') >= 0) { if (!RTCBrowserType.isFirefox()) { @@ -209,7 +209,7 @@ function RTCUtils(RTCService, onTemasysPluginReady) }; // DTLS should now be enabled by default but.. this.pc_constraints = {'optional': [{'DtlsSrtpKeyAgreement': 'true'}]}; - if (navigator.userAgent.indexOf('Android') != -1) { + if (RTCBrowserType.isAndroid()) { this.pc_constraints = {}; // disable DTLS on Android } if (!webkitMediaStream.prototype.getVideoTracks) { @@ -286,11 +286,9 @@ RTCUtils.prototype.getUserMediaWithConstraints = function( um, success_callback, failure_callback, resolution,bandwidth, fps, desktopStream) { currentResolution = resolution; - // Check if we are running on Android device - var isAndroid = navigator.userAgent.indexOf('Android') != -1; var constraints = getConstraints( - um, resolution, bandwidth, fps, desktopStream, isAndroid); + um, resolution, bandwidth, fps, desktopStream); console.info("Get media constraints", constraints);