fix: fix glare side effects for group calls.

This commit is contained in:
duanweiwei1982@gmail.com 2023-01-28 01:10:29 +08:00
parent 0eb8dc96c1
commit 0deb8d9e6e
1 changed files with 35 additions and 28 deletions

View File

@ -422,6 +422,7 @@ class CallSession {
Future<void> initWithInvite(CallType type, RTCSessionDescription offer,
SDPStreamMetadata? metadata, int lifetime, bool isGroupCall) async {
if (!isGroupCall) {
// glare fixes
final prevCallId = voip.incomingCallRoomId[room.id];
if (prevCallId != null) {
@ -453,6 +454,7 @@ class CallSession {
}
}
}
}
await _preparePeerConnection();
if (metadata != null) {
@ -1082,10 +1084,11 @@ class CallSession {
if (!isGroupCall) {
if (callId != voip.currentCID) return;
voip.currentCID = null;
voip.incomingCallRoomId.removeWhere((key, value) => value == callId);
}
voip.calls.remove(callId);
voip.incomingCallRoomId.removeWhere((key, value) => value == callId);
await cleanUp();
if (shouldEmit) {
onCallHangup.add(this);
@ -1156,8 +1159,12 @@ class CallSession {
return;
}
inviteOrAnswerSent = true;
if (!isGroupCall) {
Logs().d('[glare] set callid because new invite sent');
voip.incomingCallRoomId[room.id] = callId;
}
setCallState(CallState.kInviteSent);
inviteTimer = Timer(Duration(seconds: Timeouts.callTimeoutSec), () {