Merge branch 'td/trySetTrackenabled' into 'main'

fix: update mute status on participants changed.

See merge request famedly/company/frontend/famedlysdk!1263
This commit is contained in:
td 2023-04-13 14:57:04 +00:00
commit 412bd71b23
2 changed files with 18 additions and 12 deletions

View File

@ -970,7 +970,7 @@ class CallSession {
} }
} }
localUserMediaStream?.setVideoMuted(muted); localUserMediaStream?.setVideoMuted(muted);
await _updateMuteStatus(); await updateMuteStatus();
} }
// used for upgrading 1:1 calls // used for upgrading 1:1 calls
@ -1039,7 +1039,7 @@ class CallSession {
Future<void> setMicrophoneMuted(bool muted) async { Future<void> setMicrophoneMuted(bool muted) async {
localUserMediaStream?.setAudioMuted(muted); localUserMediaStream?.setAudioMuted(muted);
await _updateMuteStatus(); await updateMuteStatus();
} }
bool get isMicrophoneMuted => localUserMediaStream?.isAudioMuted() ?? false; bool get isMicrophoneMuted => localUserMediaStream?.isAudioMuted() ?? false;
@ -1053,7 +1053,7 @@ class CallSession {
? TransceiverDirection.SendOnly ? TransceiverDirection.SendOnly
: TransceiverDirection.SendRecv); : TransceiverDirection.SendRecv);
} }
await _updateMuteStatus(); await updateMuteStatus();
fireCallEvent(CallEvent.kRemoteHoldUnhold); fireCallEvent(CallEvent.kRemoteHoldUnhold);
} }
@ -1400,7 +1400,7 @@ class CallSession {
} }
} }
Future<void> _updateMuteStatus() async { Future<void> updateMuteStatus() async {
final micShouldBeMuted = (localUserMediaStream != null && final micShouldBeMuted = (localUserMediaStream != null &&
localUserMediaStream!.isAudioMuted()) || localUserMediaStream!.isAudioMuted()) ||
remoteOnHold; remoteOnHold;

View File

@ -416,7 +416,7 @@ class GroupCall {
await initLocalStream(); await initLocalStream();
} }
_addParticipant( await _addParticipant(
(await room.requestUser(client.userID!, ignoreErrors: true))!); (await room.requestUser(client.userID!, ignoreErrors: true))!);
await sendMemberStateEvent(); await sendMemberStateEvent();
@ -462,7 +462,7 @@ class GroupCall {
localDesktopCapturerSourceId = null; localDesktopCapturerSourceId = null;
} }
_removeParticipant(client.userID!); await _removeParticipant(client.userID!);
await removeMemberStateEvent(); await removeMemberStateEvent();
@ -800,7 +800,7 @@ class GroupCall {
if (callsState is List) { if (callsState is List) {
Logs() Logs()
.w('Ignoring member state from ${user.id} member not in any calls.'); .w('Ignoring member state from ${user.id} member not in any calls.');
_removeParticipant(user.id); await _removeParticipant(user.id);
return; return;
} }
@ -818,7 +818,7 @@ class GroupCall {
if (callState == null) { if (callState == null) {
Logs().w( Logs().w(
'Room member ${user.id} does not have a valid m.call_id set. Ignoring.'); 'Room member ${user.id} does not have a valid m.call_id set. Ignoring.');
_removeParticipant(user.id); await _removeParticipant(user.id);
return; return;
} }
@ -826,11 +826,11 @@ class GroupCall {
if (callId != null && callId != groupCallId) { if (callId != null && callId != groupCallId) {
Logs().w( Logs().w(
'Call id $callId does not match group call id $groupCallId, ignoring.'); 'Call id $callId does not match group call id $groupCallId, ignoring.');
_removeParticipant(user.id); await _removeParticipant(user.id);
return; return;
} }
_addParticipant(user); await _addParticipant(user);
// Don't process your own member. // Don't process your own member.
final localUserId = client.userID; final localUserId = client.userID;
@ -1264,7 +1264,7 @@ class GroupCall {
onGroupCallEvent.add(GroupCallEvent.ScreenshareStreamsChanged); onGroupCallEvent.add(GroupCallEvent.ScreenshareStreamsChanged);
} }
void _addParticipant(User user) { Future<void> _addParticipant(User user) async {
if (participants.indexWhere((m) => m.id == user.id) != -1) { if (participants.indexWhere((m) => m.id == user.id) != -1) {
return; return;
} }
@ -1272,9 +1272,12 @@ class GroupCall {
participants.add(user); participants.add(user);
onGroupCallEvent.add(GroupCallEvent.ParticipantsChanged); onGroupCallEvent.add(GroupCallEvent.ParticipantsChanged);
for (final call in calls) {
await call.updateMuteStatus();
}
} }
void _removeParticipant(String userid) { Future<void> _removeParticipant(String userid) async {
final index = participants.indexWhere((m) => m.id == userid); final index = participants.indexWhere((m) => m.id == userid);
if (index == -1) { if (index == -1) {
@ -1284,5 +1287,8 @@ class GroupCall {
participants.removeAt(index); participants.removeAt(index);
onGroupCallEvent.add(GroupCallEvent.ParticipantsChanged); onGroupCallEvent.add(GroupCallEvent.ParticipantsChanged);
for (final call in calls) {
await call.updateMuteStatus();
}
} }
} }