Commit 3c98e152 authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Control preprocessing and high-quality audio.

parent aa30c348
......@@ -183,6 +183,16 @@
<label for="blackboardbox">Blackboard mode</label>
</form>
<form>
<input id="preprocessingbox" type="checkbox"/ checked>
<label for="preprocessingbox">Noise suppression</label>
</form>
<form>
<input id="hqaudiobox" type="checkbox"/>
<label for="hqaudiobox">High-quality audio</label>
</form>
</fieldset>
</div>
......
......@@ -45,6 +45,8 @@ let token = null;
* @property {boolean} [mirrorView]
* @property {boolean} [blackboardMode]
* @property {string} [filter]
* @property {boolean} [preprocessing]
* @property {boolean} [hqaudio]
*/
/** @type{settings} */
......@@ -216,6 +218,20 @@ function reflectSettings() {
store = true;
}
if(settings.hasOwnProperty('preprocessing')) {
getInputElement('preprocessingbox').checked = settings.preprocessing;
} else {
settings.preprocessing = getInputElement('preprocessingbox').checked;
store = true;
}
if(settings.hasOwnProperty('hqaudio')) {
getInputElement('hqaudiobox').checked = settings.hqaudio;
} else {
settings.hqaudio = getInputElement('hqaudiobox').checked;
store = true;
}
if(store)
storeSettings(settings);
}
......@@ -479,6 +495,22 @@ getInputElement('blackboardbox').onchange = function(e) {
replaceCameraStream();
};
getInputElement('preprocessingbox').onchange = function(e) {
e.preventDefault();
if(!(this instanceof HTMLInputElement))
throw new Error('Unexpected type for this');
updateSettings({preprocessing: this.checked});
replaceCameraStream();
};
getInputElement('hqaudiobox').onchange = function(e) {
e.preventDefault();
if(!(this instanceof HTMLInputElement))
throw new Error('Unexpected type for this');
updateSettings({hqaudio: this.checked});
replaceCameraStream();
};
document.getElementById('mutebutton').onclick = function(e) {
e.preventDefault();
let localMute = getSettings().localMute;
......@@ -1075,6 +1107,7 @@ function isSafari() {
const unlimitedRate = 1000000000;
const simulcastRate = 100000;
const hqAudioRate = 128000;
/**
* Decide whether we want to send simulcast.
......@@ -1137,8 +1170,8 @@ function setUpStream(c, stream) {
* @param {MediaStreamTrack} t
*/
function addUpTrack(t) {
if(c.label === 'camera') {
let settings = getSettings();
if(c.label === 'camera') {
if(t.kind == 'audio') {
if(settings.localMute)
t.enabled = false;
......@@ -1169,9 +1202,9 @@ function setUpStream(c, stream) {
maxBitrate: simulcastRate,
});
} else {
if(c.label === 'video') {
if(c.label !== 'camera' || settings.hqaudio) {
encodings.push({
maxBitrate: 192000,
maxBitrate: hqAudioRate,
});
}
}
......@@ -1300,6 +1333,14 @@ async function addLocalMedia(localId) {
}
}
if(audio) {
if(!settings.preprocessing) {
audio.echoCancellation = false;
audio.noiseSuppression = false;
audio.autoGainControl = false;
}
}
let old = serverConnection.findByLocalId(localId);
if(old) {
// make sure that the camera is released before we try to reopen it
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment