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

View File

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