This commit is contained in:
Bruno Windels 2022-07-12 11:59:52 +02:00
parent e9649ec7c2
commit 3346f68d25
3 changed files with 49 additions and 30 deletions

View file

@ -177,6 +177,7 @@ export class PeerCall implements IDisposable {
if (this._state !== CallState.Fledgling) { if (this._state !== CallState.Fledgling) {
return; return;
} }
log.set("signalingState", this.peerConnection.signalingState);
this.direction = CallDirection.Outbound; this.direction = CallDirection.Outbound;
this.setState(CallState.CreateOffer, log); this.setState(CallState.CreateOffer, log);
this.localMuteSettings = localMuteSettings; this.localMuteSettings = localMuteSettings;
@ -309,13 +310,14 @@ export class PeerCall implements IDisposable {
}, async log => { }, async log => {
logItem = log; logItem = log;
const callIdMatches = this.callId === message.content.call_id;
if (message.type === EventType.Invite && !callIdMatches) {
await this.handleInviteGlare(message.content, partyId, log);
} else if (callIdMatches) {
switch (message.type) { switch (message.type) {
case EventType.Invite: case EventType.Invite:
if (this.callId !== message.content.call_id) {
await this.handleInviteGlare(message.content, partyId, log);
} else {
await this.handleFirstInvite(message.content, partyId, log); await this.handleFirstInvite(message.content, partyId, log);
}
break; break;
case EventType.Answer: case EventType.Answer:
await this.handleAnswer(message.content, partyId, log); await this.handleAnswer(message.content, partyId, log);
@ -339,6 +341,9 @@ export class PeerCall implements IDisposable {
log.log(`Unknown event type for call: ${message.type}`); log.log(`Unknown event type for call: ${message.type}`);
break; break;
} }
} else if (!callIdMatches) {
log.set("wrongCallId", true);
}
}); });
return logItem; return logItem;
} }
@ -879,6 +884,7 @@ export class PeerCall implements IDisposable {
this.setState(CallState.Ended, log); this.setState(CallState.Ended, log);
this.localMedia = undefined; this.localMedia = undefined;
// TODO: change signalingState to connectionState?
if (this.peerConnection && this.peerConnection.signalingState !== 'closed') { if (this.peerConnection && this.peerConnection.signalingState !== 'closed') {
this.peerConnection.close(); this.peerConnection.close();
} }

View file

@ -283,7 +283,7 @@ export class Member {
} }
} }
if (!hasBeenDequeued) { if (!hasBeenDequeued) {
syncLog.refDetached(connection.logItem.log({l: "queued signalling message", type: message.type})); syncLog.refDetached(connection.logItem.log({l: "queued signalling message", type: message.type, seq: message.content.seq}));
} }
} else { } else {
syncLog.log({l: "member not connected", userId: this.userId, deviceId: this.deviceId}); syncLog.log({l: "member not connected", userId: this.userId, deviceId: this.deviceId});

View file

@ -24,11 +24,24 @@ const SPEAKING_SAMPLE_COUNT = 8; // samples
export class DOMWebRTC implements WebRTC { export class DOMWebRTC implements WebRTC {
createPeerConnection(forceTURN: boolean, turnServers: RTCIceServer[], iceCandidatePoolSize): PeerConnection { createPeerConnection(forceTURN: boolean, turnServers: RTCIceServer[], iceCandidatePoolSize): PeerConnection {
return new RTCPeerConnection({ const peerConn = new RTCPeerConnection({
iceTransportPolicy: forceTURN ? 'relay' : undefined, iceTransportPolicy: forceTURN ? 'relay' : undefined,
iceServers: turnServers, iceServers: turnServers,
iceCandidatePoolSize: iceCandidatePoolSize, iceCandidatePoolSize: iceCandidatePoolSize,
}) as PeerConnection; }) as PeerConnection;
return new Proxy(peerConn, {
get(target, prop, receiver) {
if (prop === "close") {
console.trace("calling peerConnection.close");
}
const value = target[prop];
if (typeof value === "function") {
return value.bind(target);
} else {
return value;
}
}
});
} }
prepareSenderForPurpose(peerConnection: PeerConnection, sender: Sender, purpose: SDPStreamMetadataPurpose): void { prepareSenderForPurpose(peerConnection: PeerConnection, sender: Sender, purpose: SDPStreamMetadataPurpose): void {