1
Fork 0
mirror of https://github.com/jech/galene.git synced 2024-11-22 16:45:58 +01:00

Display user message when browser doesn't do WebRTC.

Thanks to mscherer for the report.
This commit is contained in:
Juliusz Chroboczek 2021-02-14 18:06:50 +01:00
parent 183ab4fed7
commit e04193f78c
2 changed files with 39 additions and 7 deletions

View file

@ -429,6 +429,7 @@ function setButtonsVisibility() {
let local = !!findUpMedia('local'); let local = !!findUpMedia('local');
let share = !!findUpMedia('screenshare'); let share = !!findUpMedia('screenshare');
let video = !!findUpMedia('video'); let video = !!findUpMedia('video');
let canWebrtc = !(typeof RTCPeerConnection === 'undefined');
let canFile = let canFile =
/** @ts-ignore */ /** @ts-ignore */
!!HTMLVideoElement.prototype.captureStream || !!HTMLVideoElement.prototype.captureStream ||
@ -436,13 +437,13 @@ function setButtonsVisibility() {
!!HTMLVideoElement.prototype.mozCaptureStream; !!HTMLVideoElement.prototype.mozCaptureStream;
// don't allow multiple presentations // don't allow multiple presentations
setVisibility('presentbutton', permissions.present && !local); setVisibility('presentbutton', canWebrtc && permissions.present && !local);
setVisibility('unpresentbutton', local); setVisibility('unpresentbutton', local);
setVisibility('mutebutton', !connected || permissions.present); setVisibility('mutebutton', !connected || permissions.present);
// allow multiple shared documents // allow multiple shared documents
setVisibility('sharebutton', permissions.present && setVisibility('sharebutton', canWebrtc && permissions.present &&
('getDisplayMedia' in navigator.mediaDevices)); ('getDisplayMedia' in navigator.mediaDevices));
setVisibility('unsharebutton', share); setVisibility('unsharebutton', share);
@ -1069,7 +1070,15 @@ async function addLocalMedia(localId) {
setMediaChoices(true); setMediaChoices(true);
let c = newUpStream(localId); let c;
try {
c = newUpStream(localId);
} catch(e) {
console.log(e);
displayError(e);
return;
}
c.kind = 'local'; c.kind = 'local';
c.stream = stream; c.stream = stream;
@ -1797,7 +1806,10 @@ async function gotJoined(kind, group, perms, message) {
input.placeholder = 'Type /help for help'; input.placeholder = 'Type /help for help';
setTimeout(() => {input.placeholder = '';}, 8000); setTimeout(() => {input.placeholder = '';}, 8000);
this.request(getSettings().request); if(typeof RTCPeerConnection === 'undefined')
displayWarning("This browser doesn't support WebRTC");
else
this.request(getSettings().request);
if(serverConnection.permissions.present && !findUpMedia('local')) { if(serverConnection.permissions.present && !findUpMedia('local')) {
if(present) { if(present) {

View file

@ -437,6 +437,9 @@ ServerConnection.prototype.newUpStream = function(localId) {
if(sc.up[id]) if(sc.up[id])
throw new Error('Eek!'); throw new Error('Eek!');
if(typeof RTCPeerConnection === 'undefined')
throw new Error("This browser doesn't support WebRTC");
let pc = new RTCPeerConnection(sc.rtcConfiguration); let pc = new RTCPeerConnection(sc.rtcConfiguration);
if(!pc) if(!pc)
throw new Error("Couldn't create peer connection"); throw new Error("Couldn't create peer connection");
@ -565,8 +568,15 @@ ServerConnection.prototype.groupAction = function(kind, message) {
*/ */
ServerConnection.prototype.gotOffer = async function(id, labels, source, username, sdp, replace) { ServerConnection.prototype.gotOffer = async function(id, labels, source, username, sdp, replace) {
let sc = this; let sc = this;
if(sc.up[id])
throw new Error('Duplicate connection id'); if(sc.up[id]) {
console.error("Duplicate connection id");
sc.send({
type: 'abort',
id: id,
});
return;
}
let oldLocalId = null; let oldLocalId = null;
@ -584,7 +594,17 @@ ServerConnection.prototype.gotOffer = async function(id, labels, source, usernam
console.error("Replacing duplicate stream"); console.error("Replacing duplicate stream");
if(!c) { if(!c) {
let pc = new RTCPeerConnection(sc.rtcConfiguration); let pc;
try {
pc = new RTCPeerConnection(sc.rtcConfiguration);
} catch(e) {
console.error(e);
sc.send({
type: 'abort',
id: id,
});
return;
}
c = new Stream(this, id, oldLocalId || newLocalId(), pc, false); c = new Stream(this, id, oldLocalId || newLocalId(), pc, false);
sc.down[id] = c; sc.down[id] = c;