Merge pull request #1836 from famedly/td/participantChangeStreams

feat: add participant changed streams
This commit is contained in:
td 2024-05-30 18:50:01 +05:30 committed by GitHub
commit 0330d9b37c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 28 additions and 0 deletions

View File

@ -42,6 +42,7 @@ export 'src/voip/models/call_events.dart';
export 'src/voip/models/webrtc_delegate.dart';
export 'src/voip/models/call_participant.dart';
export 'src/voip/models/key_provider.dart';
export 'src/voip/models/matrixrtc_call_event.dart';
export 'src/voip/utils/conn_tester.dart';
export 'src/voip/utils/voip_constants.dart';
export 'src/voip/utils/rtc_candidate_extension.dart';

View File

@ -58,6 +58,9 @@ class GroupCallSession {
final CachedStreamController<GroupCallStateChange> onGroupCallEvent =
CachedStreamController();
final CachedStreamController<MatrixRTCCallEvent> matrixRTCEventStream =
CachedStreamController();
Timer? _resendMemberStateEventTimer;
factory GroupCallSession.withAutoGenId(
@ -254,6 +257,8 @@ class GroupCallSession {
await backend.onNewParticipant(this, nonLocalAnyJoined.toList());
}
_participants.addAll(anyJoined);
matrixRTCEventStream
.add(ParticipantsJoinEvent(participants: anyJoined.toList()));
}
if (anyLeft.isNotEmpty) {
final nonLocalAnyLeft = Set<CallParticipant>.from(anyLeft)
@ -264,6 +269,8 @@ class GroupCallSession {
await backend.onLeftParticipant(this, nonLocalAnyLeft.toList());
}
_participants.removeAll(anyLeft);
matrixRTCEventStream
.add(ParticipantsLeftEvent(participants: anyLeft.toList()));
}
onGroupCallEvent.add(GroupCallStateChange.participantsChanged);

View File

@ -0,0 +1,20 @@
import 'package:matrix/matrix.dart';
/// UNSTABLE API WARNING
/// The class herirachy is currently experimental and could have breaking changes
/// often.
sealed class MatrixRTCCallEvent {}
sealed class ParticipantsChangeEvent implements MatrixRTCCallEvent {}
final class ParticipantsJoinEvent implements ParticipantsChangeEvent {
final List<CallParticipant> participants;
ParticipantsJoinEvent({required this.participants});
}
final class ParticipantsLeftEvent implements ParticipantsChangeEvent {
final List<CallParticipant> participants;
ParticipantsLeftEvent({required this.participants});
}