Fixes GUM failure with the latest FF nightly plus cleanup.

This commit is contained in:
paweldomas 2015-08-06 10:30:12 +02:00
parent 59147f059d
commit e5d03d1d11
1 changed files with 27 additions and 37 deletions

View File

@ -23,22 +23,18 @@ function getPreviousResolution(resolution) {
} }
function setResolutionConstraints(constraints, resolution, isAndroid) { function setResolutionConstraints(constraints, resolution, isAndroid) {
if (resolution && !constraints.video || isAndroid) {
// same behaviour as true
constraints.video = { mandatory: {}, optional: [] };
}
if (Resolutions[resolution]) { if (Resolutions[resolution]) {
constraints.video.mandatory.minWidth = Resolutions[resolution].width; constraints.video.mandatory.minWidth = Resolutions[resolution].width;
constraints.video.mandatory.minHeight = Resolutions[resolution].height; constraints.video.mandatory.minHeight = Resolutions[resolution].height;
} }
else { else if (isAndroid) {
if (isAndroid) { // FIXME can't remember if the purpose of this was to always request
// low resolution on Android ? if yes it should be moved up front
constraints.video.mandatory.minWidth = 320; constraints.video.mandatory.minWidth = 320;
constraints.video.mandatory.minHeight = 240; constraints.video.mandatory.minHeight = 240;
constraints.video.mandatory.maxFrameRate = 15; constraints.video.mandatory.maxFrameRate = 15;
} }
}
if (constraints.video.mandatory.minWidth) if (constraints.video.mandatory.minWidth)
constraints.video.mandatory.maxWidth = constraints.video.mandatory.maxWidth =
@ -55,10 +51,28 @@ function getConstraints(um, resolution, bandwidth, fps, desktopStream, isAndroid
if (um.indexOf('video') >= 0) { if (um.indexOf('video') >= 0) {
// same behaviour as true // same behaviour as true
constraints.video = { mandatory: {}, optional: [] }; constraints.video = { mandatory: {}, optional: [] };
constraints.video.optional.push({ googLeakyBucket: true });
setResolutionConstraints(constraints, resolution, isAndroid);
} }
if (um.indexOf('audio') >= 0) { if (um.indexOf('audio') >= 0) {
if (!RTCBrowserType.isFirefox()) {
// same behaviour as true // same behaviour as true
constraints.audio = { mandatory: {}, optional: []}; constraints.audio = { mandatory: {}, optional: []};
// if it is good enough for hangouts...
constraints.audio.optional.push(
{googEchoCancellation: true},
{googAutoGainControl: true},
{googNoiseSupression: true},
{googHighpassFilter: true},
{googNoisesuppression2: true},
{googEchoCancellation2: true},
{googAutoGainControl2: true}
);
} else {
constraints.audio = true;
}
} }
if (um.indexOf('screen') >= 0) { if (um.indexOf('screen') >= 0) {
if (RTCBrowserType.isChrome()) { if (RTCBrowserType.isChrome()) {
@ -100,30 +114,6 @@ function getConstraints(um, resolution, bandwidth, fps, desktopStream, isAndroid
}; };
} }
if (constraints.audio) {
// if it is good enough for hangouts...
constraints.audio.optional.push(
{googEchoCancellation: true},
{googAutoGainControl: true},
{googNoiseSupression: true},
{googHighpassFilter: true},
{googNoisesuppression2: true},
{googEchoCancellation2: true},
{googAutoGainControl2: true}
);
}
if (constraints.video) {
if (um.indexOf('video') >= 0) {
constraints.video.optional.push(
{googLeakyBucket: true}
);
}
}
if (um.indexOf('video') >= 0) {
setResolutionConstraints(constraints, resolution, isAndroid);
}
if (bandwidth) { if (bandwidth) {
if (!constraints.video) { if (!constraints.video) {
//same behaviour as true //same behaviour as true