Merge branch 'td/fixStateIssuesMuteStatus' into 'main'

fix: updateMuteStatus after kConnected

See merge request famedly/company/frontend/famedlysdk!1283
This commit is contained in:
Nicolas Werner 2023-05-03 06:35:52 +00:00
commit fc032649cf
2 changed files with 17 additions and 7 deletions

View File

@ -1359,15 +1359,17 @@ class CallSession {
}
}
};
pc!.onIceConnectionState = (RTCIceConnectionState state) {
pc!.onIceConnectionState = (RTCIceConnectionState state) async {
Logs().v('[VOIP] RTCIceConnectionState => ${state.toString()}');
if (state == RTCIceConnectionState.RTCIceConnectionStateConnected) {
localCandidates.clear();
remoteCandidates.clear();
setCallState(CallState.kConnected);
// fix any state/race issues we had with sdp packets and cloned streams
await updateMuteStatus();
missedCall = false;
} else if (state == RTCIceConnectionState.RTCIceConnectionStateFailed) {
hangup(CallErrorCode.IceFailed, false);
await hangup(CallErrorCode.IceFailed, false);
}
};
} catch (e) {

View File

@ -981,8 +981,9 @@ class GroupCall {
throw Exception('Cannot init call without user id');
}
call.onCallStateChanged.stream
.listen(((event) => onCallStateChanged(call, event)));
call.onCallStateChanged.stream.listen(((event) async {
await onCallStateChanged(call, event);
}));
call.onCallReplaced.stream.listen((CallSession newCall) async {
await replaceCall(call, newCall);
@ -1173,7 +1174,8 @@ class GroupCall {
void onActiveSpeakerLoop() async {
String? nextActiveSpeaker;
// idc about screen sharing atm.
for (final stream in userMediaStreams) {
final userMediaStreamsCopyList = List.from(userMediaStreams);
for (final stream in userMediaStreamsCopyList) {
if (stream.userId == client.userID && stream.pc == null) {
continue;
}
@ -1282,7 +1284,10 @@ class GroupCall {
participants.add(user);
onGroupCallEvent.add(GroupCallEvent.ParticipantsChanged);
for (final call in calls) {
final callsCopylist = List.from(calls);
for (final call in callsCopylist) {
await call.updateMuteStatus();
}
}
@ -1297,7 +1302,10 @@ class GroupCall {
participants.removeAt(index);
onGroupCallEvent.add(GroupCallEvent.ParticipantsChanged);
for (final call in calls) {
final callsCopylist = List.from(calls);
for (final call in callsCopylist) {
await call.updateMuteStatus();
}
}