1
Fork 0
mirror of https://github.com/jech/galene.git synced 2024-11-10 02:35:58 +01:00

Control preprocessing and high-quality audio.

This commit is contained in:
Juliusz Chroboczek 2022-02-21 18:07:49 +01:00
parent aa30c34863
commit 3c98e15229
2 changed files with 54 additions and 3 deletions

View file

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

View file

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