Merge branch 'develop' into fix-screen-sharing

Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
This commit is contained in:
Šimon Brandner
2021-01-05 20:41:06 +01:00
16 changed files with 521 additions and 9 deletions

View File

@@ -83,6 +83,9 @@ import {UIFeature} from "./settings/UIFeature";
import { CallError } from "matrix-js-sdk/src/webrtc/call";
import { logger } from 'matrix-js-sdk/src/logger';
import DesktopCapturerSourcePicker from "./components/views/elements/DesktopCapturerSourcePicker"
import { Action } from './dispatcher/actions';
const CHECK_PSTN_SUPPORT_ATTEMPTS = 3;
enum AudioID {
Ring = 'ringAudio',
@@ -120,6 +123,8 @@ export default class CallHandler {
private calls = new Map<string, MatrixCall>(); // roomId -> call
private audioPromises = new Map<AudioID, Promise<void>>();
private dispatcherRef: string = null;
private supportsPstnProtocol = null;
private pstnSupportCheckTimer: NodeJS.Timeout; // number actually because we're in the browser
static sharedInstance() {
if (!window.mxCallHandler) {
@@ -146,6 +151,8 @@ export default class CallHandler {
if (SettingsStore.getValue(UIFeature.Voip)) {
MatrixClientPeg.get().on('Call.incoming', this.onCallIncoming);
}
this.checkForPstnSupport(CHECK_PSTN_SUPPORT_ATTEMPTS);
}
stop() {
@@ -159,6 +166,33 @@ export default class CallHandler {
}
}
private async checkForPstnSupport(maxTries) {
try {
const protocols = await MatrixClientPeg.get().getThirdpartyProtocols();
if (protocols['im.vector.protocol.pstn'] !== undefined) {
this.supportsPstnProtocol = protocols['im.vector.protocol.pstn'];
} else if (protocols['m.protocol.pstn'] !== undefined) {
this.supportsPstnProtocol = protocols['m.protocol.pstn'];
} else {
this.supportsPstnProtocol = null;
}
dis.dispatch({action: Action.PstnSupportUpdated});
} catch (e) {
if (maxTries === 1) {
console.log("Failed to check for pstn protocol support and no retries remain: assuming no support", e);
} else {
console.log("Failed to check for pstn protocol support: will retry", e);
this.pstnSupportCheckTimer = setTimeout(() => {
this.checkForPstnSupport(maxTries - 1);
}, 10000);
}
}
}
getSupportsPstnProtocol() {
return this.supportsPstnProtocol;
}
private onCallIncoming = (call) => {
// we dispatch this synchronously to make sure that the event
// handlers on the call are set up immediately (so that if