From e2d138cac6f934ba3102a123fefc66b849b27e4f Mon Sep 17 00:00:00 2001 From: David Baker Date: Mon, 25 Jan 2021 16:09:39 +0000 Subject: [PATCH 1/3] Fix compatability with v0 calls https://github.com/matrix-org/matrix-js-sdk/pull/1567 introduced a bug where we'd leave opponentPartyId undefined, but we compared it to null later when testing for its presence. Fixes https://github.com/vector-im/element-web/issues/16239 --- src/webrtc/call.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/webrtc/call.ts b/src/webrtc/call.ts index 5cc1c5c45..b5c44de56 100644 --- a/src/webrtc/call.ts +++ b/src/webrtc/call.ts @@ -271,6 +271,9 @@ export class MatrixCall extends EventEmitter { this.type = null; this.forceTURN = opts.forceTURN; this.ourPartyId = this.client.deviceId; + // We compare this to null to checks the presence of a party ID: + // make sure it's null, not undefined + this.opponentPartyId = null; // Array of Objects with urls, username, credential keys this.turnServers = opts.turnServers || []; if (this.turnServers.length === 0 && this.client.isFallbackICEServerAllowed()) { @@ -1364,7 +1367,7 @@ export class MatrixCall extends EventEmitter { // party ID must match (our chosen partner hanging up the call) or be undefined (we haven't chosen // a partner yet but we're treating the hangup as a reject as per VoIP v0) - if (this.partyIdMatches(msg) || this.opponentPartyId === undefined || this.state === CallState.Ringing) { + if (this.partyIdMatches(msg) || this.state === CallState.Ringing) { // default reason is user_hangup this.terminate(CallParty.Remote, msg.reason || CallErrorCode.UserHangup, true); } else { @@ -1468,6 +1471,11 @@ export class MatrixCall extends EventEmitter { private async terminate(hangupParty: CallParty, hangupReason: CallErrorCode, shouldEmit: boolean) { if (this.callHasEnded()) return; + const stats = await this.peerConn.getStats(); + for (const s of stats.keys()) { + console.log(stats.get(s)); + } + if (this.inviteTimeout) { clearTimeout(this.inviteTimeout); this.inviteTimeout = null; From 90dda0ca68e18eed4fa2514e382607460990e827 Mon Sep 17 00:00:00 2001 From: David Baker Date: Mon, 25 Jan 2021 16:13:13 +0000 Subject: [PATCH 2/3] Remove unintentional commit --- src/webrtc/call.ts | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/webrtc/call.ts b/src/webrtc/call.ts index b5c44de56..53f7bbe7c 100644 --- a/src/webrtc/call.ts +++ b/src/webrtc/call.ts @@ -1471,11 +1471,6 @@ export class MatrixCall extends EventEmitter { private async terminate(hangupParty: CallParty, hangupReason: CallErrorCode, shouldEmit: boolean) { if (this.callHasEnded()) return; - const stats = await this.peerConn.getStats(); - for (const s of stats.keys()) { - console.log(stats.get(s)); - } - if (this.inviteTimeout) { clearTimeout(this.inviteTimeout); this.inviteTimeout = null; From 1df69d259a0850d1dcda9ed53ce6a86a6004162c Mon Sep 17 00:00:00 2001 From: David Baker Date: Mon, 25 Jan 2021 16:34:28 +0000 Subject: [PATCH 3/3] We were using undefined here too --- src/webrtc/call.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/webrtc/call.ts b/src/webrtc/call.ts index 53f7bbe7c..dcea809b7 100644 --- a/src/webrtc/call.ts +++ b/src/webrtc/call.ts @@ -990,7 +990,7 @@ export class MatrixCall extends EventEmitter { return; } - if (this.opponentPartyId !== undefined) { + if (this.opponentPartyId !== null) { logger.info( `Ignoring answer from party ID ${event.getContent().party_id}: ` + `we already have an answer/reject from ${this.opponentPartyId}`,