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 69ed64491..785f6665c 100644 --- a/modules/RTC/RTCUtils.js +++ b/modules/RTC/RTCUtils.js @@ -29,7 +29,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; @@ -51,8 +52,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) { @@ -61,7 +61,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()) { @@ -222,7 +222,7 @@ var RTCUtils = { // https://code.google.com/p/webrtc/issues/detail?id=2828 this.pc_constraints.optional.push({googIPv6: true}); } - if (navigator.userAgent.indexOf('Android') != -1) { + if (RTCBrowserType.isAndroid()) { this.pc_constraints = {}; // disable DTLS on Android } if (!webkitMediaStream.prototype.getVideoTracks) { @@ -298,11 +298,8 @@ var RTCUtils = { getUserMediaWithConstraints: function (RTC, um, success_callback, failure_callback, resolution, bandwidth, fps, desktopStream) { - // 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);