diff --git a/lib/src/core/engine.dart b/lib/src/core/engine.dart index 25b371af8..28f075816 100644 --- a/lib/src/core/engine.dart +++ b/lib/src/core/engine.dart @@ -34,7 +34,8 @@ import '../proto/livekit_models.pb.dart' as lk_models; import '../proto/livekit_rtc.pb.dart' as lk_rtc; import '../publication/local.dart'; import '../support/disposable.dart'; -import '../support/platform.dart' show lkPlatformIsTest, lkPlatformIs, PlatformType; +import '../support/platform.dart' + show lkPlatformIsTest, lkPlatformIs, PlatformType; import '../support/region_url_provider.dart'; import '../support/websocket.dart'; import '../track/local/local.dart'; diff --git a/lib/src/events.dart b/lib/src/events.dart index 31cbbaf09..a8e1b47bc 100644 --- a/lib/src/events.dart +++ b/lib/src/events.dart @@ -387,7 +387,8 @@ class ParticipantStateUpdatedEvent with RoomEvent, ParticipantEvent { /// [Pariticpant]'s [ConnectionQuality] has updated. /// Emitted by [Room] and [Participant]. -class ParticipantConnectionQualityUpdatedEvent with RoomEvent, ParticipantEvent { +class ParticipantConnectionQualityUpdatedEvent + with RoomEvent, ParticipantEvent { final Participant participant; final ConnectionQuality connectionQuality; const ParticipantConnectionQualityUpdatedEvent({ diff --git a/lib/src/participant/participant.dart b/lib/src/participant/participant.dart index 1d83ea3d4..d36d84aec 100644 --- a/lib/src/participant/participant.dart +++ b/lib/src/participant/participant.dart @@ -39,8 +39,8 @@ import '../utils.dart'; /// Base for [RemoteParticipant] and [LocalParticipant], /// can not be instantiated directly. -abstract class Participant extends DisposableChangeNotifier - with EventsEmittable { +abstract class Participant + extends DisposableChangeNotifier with EventsEmittable { /// Reference to [Room] @internal final Room room; @@ -81,7 +81,8 @@ abstract class Participant extends DisposableChangeN ParticipantPermissions get permissions => _permissions; /// Attributes associated with the participant - UnmodifiableMapView get attributes => UnmodifiableMapView(_attributes); + UnmodifiableMapView get attributes => + UnmodifiableMapView(_attributes); Map _attributes = {}; // Participant state @@ -92,7 +93,8 @@ abstract class Participant extends DisposableChangeN DateTime get joinedAt { final pi = _participantInfo; if (pi != null) { - return DateTime.fromMillisecondsSinceEpoch(pi.joinedAt.toInt() * 1000, isUtc: true); + return DateTime.fromMillisecondsSinceEpoch(pi.joinedAt.toInt() * 1000, + isUtc: true); } return DateTime.now(); } @@ -191,10 +193,14 @@ abstract class Participant extends DisposableChangeN } void _setAttributes(Map attrs) { - final diff = mapDiff(_attributes, attrs).map((k, v) => MapEntry(k as String, v as String)); + final diff = mapDiff(_attributes, attrs) + .map((k, v) => MapEntry(k as String, v as String)); _attributes = attrs; if (diff.isNotEmpty) { - [events, room.events].emit(ParticipantAttributesChanged(participant: this, attributes: diff)); + [ + events, + room.events + ].emit(ParticipantAttributesChanged(participant: this, attributes: diff)); } } @@ -211,7 +217,9 @@ abstract class Participant extends DisposableChangeN @internal Future updateFromInfo(lk_models.ParticipantInfo info) async { logger.fine('LocalParticipant.updateFromInfo(info: $info)'); - if (_participantInfo != null && _participantInfo!.sid == info.sid && _participantInfo!.version > info.version) { + if (_participantInfo != null && + _participantInfo!.sid == info.sid && + _participantInfo!.version > info.version) { return false; } @@ -287,14 +295,19 @@ abstract class Participant extends DisposableChangeN T? getTrackPublicationBySource(TrackSource source) { if (source == TrackSource.unknown) return null; // try to find by source - final result = trackPublications.values.firstWhereOrNull((e) => e.source == source); + final result = + trackPublications.values.firstWhereOrNull((e) => e.source == source); if (result != null) return result; // try to find by compatibility - return trackPublications.values.where((e) => e.source == TrackSource.unknown).firstWhereOrNull((e) => - (source == TrackSource.microphone && e.kind == TrackType.AUDIO) || - (source == TrackSource.camera && e.kind == TrackType.VIDEO) || - (source == TrackSource.screenShareVideo && e.kind == TrackType.VIDEO) || - (source == TrackSource.screenShareAudio && e.kind == TrackType.AUDIO)); + return trackPublications.values + .where((e) => e.source == TrackSource.unknown) + .firstWhereOrNull((e) => + (source == TrackSource.microphone && e.kind == TrackType.AUDIO) || + (source == TrackSource.camera && e.kind == TrackType.VIDEO) || + (source == TrackSource.screenShareVideo && + e.kind == TrackType.VIDEO) || + (source == TrackSource.screenShareAudio && + e.kind == TrackType.AUDIO)); } /// Convenience property to check whether [TrackSource.camera] is published or not. @@ -304,17 +317,20 @@ abstract class Participant extends DisposableChangeN /// Convenience property to check whether [TrackSource.microphone] is published or not. bool isMicrophoneEnabled() { - return !(getTrackPublicationBySource(TrackSource.microphone)?.muted ?? true); + return !(getTrackPublicationBySource(TrackSource.microphone)?.muted ?? + true); } /// Convenience property to check whether [TrackSource.screenShareVideo] is published or not. bool isScreenShareEnabled() { - return !(getTrackPublicationBySource(TrackSource.screenShareVideo)?.muted ?? true); + return !(getTrackPublicationBySource(TrackSource.screenShareVideo)?.muted ?? + true); } /// Convenience property to check whether [TrackSource.screenShareAudio] is published or not. bool isScreenShareAudioEnabled() { - return !(getTrackPublicationBySource(TrackSource.screenShareAudio)?.muted ?? true); + return !(getTrackPublicationBySource(TrackSource.screenShareAudio)?.muted ?? + true); } /// (Equality operator) [Participant.hashCode] is same as [sid.hashCode]. diff --git a/lib/src/types/participant_state.dart b/lib/src/types/participant_state.dart index 6691b5e5c..8f278686e 100644 --- a/lib/src/types/participant_state.dart +++ b/lib/src/types/participant_state.dart @@ -37,7 +37,8 @@ extension ParticipantStateExt on lk_models.ParticipantInfo_State { lk_models.ParticipantInfo_State.JOINING => ParticipantState.joining, lk_models.ParticipantInfo_State.JOINED => ParticipantState.joined, lk_models.ParticipantInfo_State.ACTIVE => ParticipantState.active, - lk_models.ParticipantInfo_State.DISCONNECTED => ParticipantState.disconnected, + lk_models.ParticipantInfo_State.DISCONNECTED => + ParticipantState.disconnected, _ => ParticipantState.unknown, }; } diff --git a/test/core/data_stream_test.dart b/test/core/data_stream_test.dart index 046722b1b..e550e31aa 100644 --- a/test/core/data_stream_test.dart +++ b/test/core/data_stream_test.dart @@ -20,7 +20,6 @@ import 'dart:io'; import 'dart:math'; import 'package:flutter_test/flutter_test.dart'; -import 'package:uuid/uuid.dart' show Uuid; import 'package:livekit_client/livekit_client.dart'; import '../mock/e2e_container.dart'; @@ -97,12 +96,8 @@ void main() { }); }); - final streamId = Uuid().v4(); var stream = await room.localParticipant?.streamText(StreamTextOptions( topic: 'chat-stream', - streamId: streamId, - totalSize: 10000, - attachedStreamIds: [], )); await stream?.write('a' * 10); await stream?.write('b' * 10); @@ -202,10 +197,8 @@ void main() { 'bytes content = ${content}, \n string content = ${utf8.decode(content)}'); }); - final streamId = Uuid().v4(); var stream = await room.localParticipant?.streamBytes(StreamBytesOptions( topic: 'bytes-stream', - streamId: streamId, totalSize: 30, )); await stream?.write(utf8.encode('a' * 10)); diff --git a/test/core/room_e2e_test.dart b/test/core/room_e2e_test.dart index caf4def7a..4fb51e595 100644 --- a/test/core/room_e2e_test.dart +++ b/test/core/room_e2e_test.dart @@ -52,6 +52,8 @@ void main() { expect( room.events.streamCtrl.stream, emitsInOrder([ + predicate( + (event) => event.participant.sid == remoteParticipantData.sid), predicate( (event) => event.participant.sid == remoteParticipantData.sid, ),