Merge branch 'voip/fix-glare-mr-side-effects' into 'main'

fix: fix glare side effects for group calls.

See merge request famedly/company/frontend/famedlysdk!1227
This commit is contained in:
Malin Errenst 2023-01-30 07:48:19 +00:00
commit bc300ac2af
2 changed files with 38 additions and 29 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), () {

View File

@ -535,7 +535,9 @@ class VoIP {
return Null as CallSession;
}
final callId = 'cid${DateTime.now().millisecondsSinceEpoch}';
if (currentGroupCID == null) {
incomingCallRoomId[roomId] = callId;
}
final opts = CallOptions()
..callId = callId
..type = type