1
Fork 0
mirror of https://github.com/jech/galene.git synced 2024-12-22 07:15:47 +01:00

Handle errors in filter init.

We used to ignore errors in filter init, which could cause us
to send unblurred videos to the server.
This commit is contained in:
Juliusz Chroboczek 2024-12-14 12:20:41 +01:00
parent 2c72a27453
commit 3fbe274785

View file

@ -1369,12 +1369,7 @@ async function setUpStream(c, stream) {
c.setStream(stream);
try {
await setFilter(c);
} catch(e) {
displayWarning("Couldn't set filter: " + e);
}
// set up the handler early, in case setFilter fails.
c.onclose = async replace => {
await removeFilter(c);
if(!replace) {
@ -1385,6 +1380,8 @@ async function setUpStream(c, stream) {
}
}
await setFilter(c);
/**
* @param {MediaStreamTrack} t
*/
@ -1507,10 +1504,20 @@ async function replaceUpStream(c) {
cn.userdata.onclose = c.userdata.onclose;
let media = /** @type{HTMLVideoElement} */
(document.getElementById('media-' + c.localId));
await setUpStream(cn, c.stream);
try {
await setUpStream(cn, c.stream);
} catch(e) {
console.error(e);
displayError(e);
cn.close();
c.close();
return null;
}
await setMedia(cn,
cn.label == 'camera' && getSettings().mirrorView,
cn.label == 'video' && media);
return cn;
}
@ -1611,8 +1618,14 @@ async function addLocalMedia(localId) {
displayWarning(`Unknown filter ${settings.filter}`);
}
await setUpStream(c, stream);
await setMedia(c, settings.mirrorView);
try {
await setUpStream(c, stream);
await setMedia(c, settings.mirrorView);
} catch(e) {
console.error(e);
displayError(e);
c.close();
}
setButtonsVisibility();
}