1
Fork 0
mirror of https://github.com/jech/galene.git synced 2024-11-08 17:55:59 +01:00

Protect against undefined navigator.mediaDevices.

This may happen if we're running over plain HTTP.
Thanks to kovmir.
This commit is contained in:
Juliusz Chroboczek 2023-12-08 18:46:23 +01:00
parent c0214c3350
commit 96e2db0347

View file

@ -478,25 +478,31 @@ function setVisibility(id, visible) {
function setButtonsVisibility() {
let connected = serverConnection && serverConnection.socket;
let permissions = serverConnection.permissions;
let present = permissions.indexOf('present') >= 0;
let local = !!findUpMedia('camera');
let canWebrtc = !(typeof RTCPeerConnection === 'undefined');
let canPresent = canWebrtc &&
('mediaDevices' in navigator) &&
('getUserMedia' in navigator.mediaDevices) &&
permissions.indexOf('present') >= 0;
let canShare = canWebrtc &&
('mediaDevices' in navigator) &&
('getDisplayMedia' in navigator.mediaDevices) &&
permissions.indexOf('present') >= 0;
let local = !!findUpMedia('camera');
let mediacount = document.getElementById('peers').childElementCount;
let mobilelayout = isMobileLayout();
// don't allow multiple presentations
setVisibility('presentbutton', canWebrtc && present && !local);
setVisibility('presentbutton', canPresent && !local);
setVisibility('unpresentbutton', local);
setVisibility('mutebutton', !connected || present);
setVisibility('mutebutton', !connected || canPresent);
// allow multiple shared documents
setVisibility('sharebutton', canWebrtc && present &&
('getDisplayMedia' in navigator.mediaDevices));
setVisibility('sharebutton', canShare);
setVisibility('mediaoptions', present);
setVisibility('sendform', present);
setVisibility('simulcastform', present);
setVisibility('mediaoptions', canPresent);
setVisibility('sendform', canPresent);
setVisibility('simulcastform', canPresent);
setVisibility('collapse-video', mediacount && mobilelayout);
}
@ -864,7 +870,8 @@ async function setMediaChoices(done) {
let devices = [];
try {
devices = await navigator.mediaDevices.enumerateDevices();
if('mediaDevices' in navigator)
devices = await navigator.mediaDevices.enumerateDevices();
} catch(e) {
console.error(e);
return;
@ -2487,7 +2494,9 @@ async function gotJoined(kind, group, perms, status, data, error, message) {
else
this.request(mapRequest(getSettings().request));
if(serverConnection.permissions.indexOf('present') >= 0 &&
if(('mediaDevices' in navigator) &&
('getUserMedia' in navigator.mediaDevices) &&
serverConnection.permissions.indexOf('present') >= 0 &&
!findUpMedia('camera')) {
if(present) {
if(present === 'mike')