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) {
return;
}
log.set("signalingState", this.peerConnection.signalingState);
this.direction = CallDirection.Outbound;
this.setState(CallState.CreateOffer, log);
this.localMuteSettings = localMuteSettings;
@ -309,13 +310,14 @@ export class PeerCall implements IDisposable {
}, async 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) {
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);
}
break;
case EventType.Answer:
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}`);
break;
}
} else if (!callIdMatches) {
log.set("wrongCallId", true);
}
});
return logItem;
}
@ -879,6 +884,7 @@ export class PeerCall implements IDisposable {
this.setState(CallState.Ended, log);
this.localMedia = undefined;
// TODO: change signalingState to connectionState?
if (this.peerConnection && this.peerConnection.signalingState !== 'closed') {
this.peerConnection.close();
}

View file

@ -283,7 +283,7 @@ export class Member {
}
}
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 {
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 {
createPeerConnection(forceTURN: boolean, turnServers: RTCIceServer[], iceCandidatePoolSize): PeerConnection {
return new RTCPeerConnection({
const peerConn = new RTCPeerConnection({
iceTransportPolicy: forceTURN ? 'relay' : undefined,
iceServers: turnServers,
iceCandidatePoolSize: iceCandidatePoolSize,
}) 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 {