From b45ab18b74b262f49562bdb8a48a7f0b9f459ae6 Mon Sep 17 00:00:00 2001 From: Brad Beeler Date: Thu, 5 Nov 2015 10:39:39 -0700 Subject: [PATCH] COLLAB-725 Adding max frame rate value to constraints, makeing video values pull from global config --- modules/RTC/RTC.js | 4 +- modules/RTC/RTCUtils.js | 48 +++++++++++++++++------- modules/desktopsharing/ScreenObtainer.js | 2 +- 3 files changed, 37 insertions(+), 17 deletions(-) diff --git a/modules/RTC/RTC.js b/modules/RTC/RTC.js index adef12e6b..e5764bbf8 100644 --- a/modules/RTC/RTC.js +++ b/modules/RTC/RTC.js @@ -128,10 +128,10 @@ var RTC = { }, getUserMediaWithConstraints:function(um, success_callback, failure_callback, resolution, - bandwidth, fps, desktopStream) + bandwidth, minFps, maxFps, desktopStream) { return this.rtcUtils.getUserMediaWithConstraints(um, success_callback, - failure_callback, resolution, bandwidth, fps, desktopStream); + failure_callback, resolution, bandwidth, minFps, maxFps, desktopStream); }, attachMediaStream: function (elSelector, stream) { this.rtcUtils.attachMediaStream(elSelector, stream); diff --git a/modules/RTC/RTCUtils.js b/modules/RTC/RTCUtils.js index 761c805b4..8ec91a4e1 100644 --- a/modules/RTC/RTCUtils.js +++ b/modules/RTC/RTCUtils.js @@ -49,7 +49,8 @@ function setResolutionConstraints(constraints, resolution) { constraints.video.mandatory.minHeight; } -function getConstraints(um, resolution, bandwidth, fps, desktopStream) { +function getConstraints(um, resolution, bandwidth, minFps, maxFps, desktopStream, isAndroid) +{ var constraints = {audio: false, video: false}; if (um.indexOf('video') >= 0) { @@ -131,14 +132,21 @@ function getConstraints(um, resolution, bandwidth, fps, desktopStream) { } constraints.video.optional.push({bandwidth: bandwidth}); } - if (fps) { - // for some cameras it might be necessary to request 30fps - // so they choose 30fps mjpg over 10fps yuy2 + + if (minFps || maxFps) { if (!constraints.video) { - // same behaviour as true; - constraints.video = {mandatory: {}, optional: []}; + constraints.video = { + mandatory: {}, + optional: [] + }; + } + if (minFps) { + constraints.video.mandatory.minFrameRate = minFps; + } + + if (maxFps) { + constraints.video.mandatory.maxFrameRate = maxFps; } - constraints.video.mandatory.minFrameRate = fps; } // we turn audio for both audio and video tracks, the fake audio & video seems to work @@ -304,12 +312,26 @@ function RTCUtils(RTCService, eventEmitter, onTemasysPluginReady) RTCUtils.prototype.getUserMediaWithConstraints = function( - um, success_callback, failure_callback, resolution,bandwidth, fps, - desktopStream) { + um, success_callback, failure_callback, resolution, bandwidth, + minFps, maxFps, desktopStream) { currentResolution = resolution; + var self = this, + minimumFps = minFps || config.video.minFps, + maximumFps = maxFps || config.video.maxFps, + bndwidth = bandwidth || config.video.bandwidth, + + // Check if we are running on Android device + isAndroid = navigator.userAgent.indexOf('Android') != -1; + + if (resolution) { + currentResolution = resolution; + } else if (config.video.resolution) { + currentResolution = config.video.resolution; + } var constraints = getConstraints( - um, resolution, bandwidth, fps, desktopStream); + um, resolution, bandwidth, minimumFps, maximumFps, desktopStream, + isAndroid); console.info("Get media constraints", constraints); @@ -411,8 +433,7 @@ RTCUtils.prototype.obtainAudioAndVideoPermissions = console.error( 'failed to obtain video stream - stop', error); self.errorCallback(error); - }, - config.resolution || '360'); + }); }; var obtainAudio = function () { self.getUserMediaWithConstraints( @@ -441,8 +462,7 @@ RTCUtils.prototype.obtainAudioAndVideoPermissions = }, function (error) { self.errorCallback(error); - }, - config.resolution || '360'); + }); } }; diff --git a/modules/desktopsharing/ScreenObtainer.js b/modules/desktopsharing/ScreenObtainer.js index 223f626df..7b9457c49 100644 --- a/modules/desktopsharing/ScreenObtainer.js +++ b/modules/desktopsharing/ScreenObtainer.js @@ -248,7 +248,7 @@ function doGetStreamFromExtension(streamCallback, failCallback) { streamCallback(stream); }, failCallback, - null, null, null, + null, null, null, null, response.streamId); } else { failCallback("Extension failed to get the stream");