Commit e04193f7 authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Display user message when browser doesn't do WebRTC.

Thanks to mscherer for the report.
parent 183ab4fe
......@@ -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) {
......
......@@ -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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment