1
Fork 0
mirror of https://github.com/jech/galene.git synced 2024-12-22 23:35:46 +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 share = !!findUpMedia('screenshare');
let video = !!findUpMedia('video');
let canWebrtc = !(typeof RTCPeerConnection === 'undefined');
let canFile =
/** @ts-ignore */
!!HTMLVideoElement.prototype.captureStream ||
@ -436,13 +437,13 @@ function setButtonsVisibility() {
!!HTMLVideoElement.prototype.mozCaptureStream;
// don't allow multiple presentations
setVisibility('presentbutton', permissions.present && !local);
setVisibility('presentbutton', canWebrtc && permissions.present && !local);
setVisibility('unpresentbutton', local);
setVisibility('mutebutton', !connected || permissions.present);
// allow multiple shared documents
setVisibility('sharebutton', permissions.present &&
setVisibility('sharebutton', canWebrtc && permissions.present &&
('getDisplayMedia' in navigator.mediaDevices));
setVisibility('unsharebutton', share);
@ -1069,7 +1070,15 @@ async function addLocalMedia(localId) {
setMediaChoices(true);
let c = newUpStream(localId);
let c;
try {
c = newUpStream(localId);
} catch(e) {
console.log(e);
displayError(e);
return;
}
c.kind = 'local';
c.stream = stream;
@ -1797,7 +1806,10 @@ async function gotJoined(kind, group, perms, message) {
input.placeholder = 'Type /help for help';
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(present) {

View file

@ -437,6 +437,9 @@ ServerConnection.prototype.newUpStream = function(localId) {
if(sc.up[id])
throw new Error('Eek!');
if(typeof RTCPeerConnection === 'undefined')
throw new Error("This browser doesn't support WebRTC");
let pc = new RTCPeerConnection(sc.rtcConfiguration);
if(!pc)
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) {
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;
@ -584,7 +594,17 @@ ServerConnection.prototype.gotOffer = async function(id, labels, source, usernam
console.error("Replacing duplicate stream");
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);
sc.down[id] = c;