Add RTCBrowserType.isAndroid().

This commit is contained in:
Boris Grozev 2015-08-17 16:00:09 -05:00
parent f60c1d9751
commit 9cc9e6132c
2 changed files with 16 additions and 8 deletions

View File

@ -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;

View File

@ -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);