Organize events (#13)
* move internal events & remove unused events * `TrackUnpublishedEvent` for local tracks * update example since we have local track unpublish events * use flutter_webrtc 0.6.9
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
/// Flutter Client SDK to LiveKit.
|
||||
library livekit_client;
|
||||
|
||||
export 'src/exceptions.dart';
|
||||
export 'src/events.dart';
|
||||
export 'src/exceptions.dart';
|
||||
export 'src/livekit.dart';
|
||||
export 'src/managers/event.dart';
|
||||
export 'src/options.dart';
|
||||
@@ -21,5 +21,5 @@ export 'src/track/remote_track_publication.dart';
|
||||
export 'src/track/track.dart';
|
||||
export 'src/track/track_publication.dart';
|
||||
export 'src/track/video_track.dart';
|
||||
export 'src/types.dart' show RTCConfiguration, RTCIceServer, RTCIceTransportPolicy, Reliability;
|
||||
export 'src/types.dart';
|
||||
export 'src/widget/video_track_renderer.dart';
|
||||
|
||||
+2
-67
@@ -68,10 +68,6 @@ class ActiveSpeakersChangedEvent with RoomEvent {
|
||||
});
|
||||
}
|
||||
|
||||
class AudioPlaybackChangedEvent with RoomEvent {
|
||||
const AudioPlaybackChangedEvent();
|
||||
}
|
||||
|
||||
/// When a new [Track] is published to [Room] *after* the current participant has
|
||||
/// joined. It will not fire for tracks that are already published.
|
||||
/// Emitted by [Room] and [RemoteParticipant].
|
||||
@@ -87,8 +83,8 @@ class TrackPublishedEvent with RoomEvent, ParticipantEvent {
|
||||
/// The participant has unpublished one of their [Track].
|
||||
/// Emitted by [Room] and [RemoteParticipant].
|
||||
class TrackUnpublishedEvent with RoomEvent, ParticipantEvent {
|
||||
final RemoteParticipant participant;
|
||||
final RemoteTrackPublication publication;
|
||||
final Participant participant;
|
||||
final TrackPublication publication;
|
||||
const TrackUnpublishedEvent({
|
||||
required this.participant,
|
||||
required this.publication,
|
||||
@@ -217,13 +213,6 @@ class EngineReconnectedEvent with EngineEvent {
|
||||
const EngineReconnectedEvent();
|
||||
}
|
||||
|
||||
// class EngineParticipantUpdateEvent with EngineEvent {
|
||||
// final List<lk_models.ParticipantInfo> participants;
|
||||
// const EngineParticipantUpdateEvent({
|
||||
// required this.participants,
|
||||
// });
|
||||
// }
|
||||
|
||||
class EngineTrackAddedEvent with EngineEvent {
|
||||
final rtc.MediaStreamTrack track;
|
||||
final rtc.MediaStream stream;
|
||||
@@ -253,60 +242,6 @@ class EngineRemoteMuteChangedEvent with EngineEvent {
|
||||
});
|
||||
}
|
||||
|
||||
// added
|
||||
abstract class EngineIceStateUpdatedEvent with EngineEvent {
|
||||
final rtc.RTCIceConnectionState iceState;
|
||||
final bool isPrimary;
|
||||
const EngineIceStateUpdatedEvent({
|
||||
required this.iceState,
|
||||
required this.isPrimary,
|
||||
});
|
||||
}
|
||||
|
||||
class EngineSubscriberIceStateUpdatedEvent extends EngineIceStateUpdatedEvent {
|
||||
const EngineSubscriberIceStateUpdatedEvent({
|
||||
required rtc.RTCIceConnectionState state,
|
||||
required bool isPrimary,
|
||||
}) : super(
|
||||
iceState: state,
|
||||
isPrimary: isPrimary,
|
||||
);
|
||||
}
|
||||
|
||||
class EnginePublisherIceStateUpdatedEvent extends EngineIceStateUpdatedEvent {
|
||||
const EnginePublisherIceStateUpdatedEvent({
|
||||
required rtc.RTCIceConnectionState state,
|
||||
required bool isPrimary,
|
||||
}) : super(
|
||||
iceState: state,
|
||||
isPrimary: isPrimary,
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Track events
|
||||
//
|
||||
|
||||
class TrackMessageEvent with TrackEvent {
|
||||
const TrackMessageEvent();
|
||||
}
|
||||
|
||||
class TrackUpdateSettingsEvent with TrackEvent {
|
||||
const TrackUpdateSettingsEvent();
|
||||
}
|
||||
|
||||
class TrackUpdateSubscriptionEvent with TrackEvent {
|
||||
const TrackUpdateSubscriptionEvent();
|
||||
}
|
||||
|
||||
class TrackAudioPlaybackStartedEvent with TrackEvent {
|
||||
const TrackAudioPlaybackStartedEvent();
|
||||
}
|
||||
|
||||
class TrackAudioPlaybackFailedEvent with TrackEvent {
|
||||
const TrackAudioPlaybackFailedEvent();
|
||||
}
|
||||
|
||||
//
|
||||
// Signal events
|
||||
//
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
// added
|
||||
import 'package:flutter_webrtc/flutter_webrtc.dart' as rtc;
|
||||
import 'package:meta/meta.dart';
|
||||
|
||||
import '../events.dart';
|
||||
|
||||
@internal
|
||||
abstract class EngineIceStateUpdatedEvent with EngineEvent {
|
||||
final rtc.RTCIceConnectionState iceState;
|
||||
final bool isPrimary;
|
||||
const EngineIceStateUpdatedEvent({
|
||||
required this.iceState,
|
||||
required this.isPrimary,
|
||||
});
|
||||
}
|
||||
|
||||
@internal
|
||||
class EngineSubscriberIceStateUpdatedEvent extends EngineIceStateUpdatedEvent {
|
||||
const EngineSubscriberIceStateUpdatedEvent({
|
||||
required rtc.RTCIceConnectionState state,
|
||||
required bool isPrimary,
|
||||
}) : super(
|
||||
iceState: state,
|
||||
isPrimary: isPrimary,
|
||||
);
|
||||
}
|
||||
|
||||
@internal
|
||||
class EnginePublisherIceStateUpdatedEvent extends EngineIceStateUpdatedEvent {
|
||||
const EnginePublisherIceStateUpdatedEvent({
|
||||
required rtc.RTCIceConnectionState state,
|
||||
required bool isPrimary,
|
||||
}) : super(
|
||||
iceState: state,
|
||||
isPrimary: isPrimary,
|
||||
);
|
||||
}
|
||||
@@ -151,14 +151,11 @@ class LocalParticipant extends Participant {
|
||||
|
||||
/// Unpublish a track that's already published
|
||||
@override
|
||||
Future<void> unpublishTrack(String trackSid, {bool notify = false}) async {
|
||||
Future<void> unpublishTrack(String trackSid, {bool notify = true}) async {
|
||||
logger.finer('Unpublish track sid: $trackSid, notify: $notify');
|
||||
final pub = trackPublications.remove(trackSid);
|
||||
if (pub is! LocalTrackPublication) return;
|
||||
|
||||
// final existing = tracks.values.where((element) => element.track == track);
|
||||
// if (existing.isEmpty) return;
|
||||
// final pub = existing.first;
|
||||
final track = pub.track;
|
||||
if (track != null) {
|
||||
await track.stop();
|
||||
@@ -178,6 +175,13 @@ class LocalParticipant extends Participant {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (notify) {
|
||||
[events, roomEvents].emit(TrackUnpublishedEvent(
|
||||
participant: this,
|
||||
publication: pub,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// Publish a new data payload to the room.
|
||||
|
||||
@@ -152,7 +152,7 @@ class RemoteParticipant extends Participant {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> unpublishTrack(String trackSid, {bool notify = false}) async {
|
||||
Future<void> unpublishTrack(String trackSid, {bool notify = true}) async {
|
||||
logger.finer('Unpublish track sid: $trackSid, notify: $notify');
|
||||
final pub = trackPublications.remove(trackSid);
|
||||
if (pub is! RemoteTrackPublication) return;
|
||||
@@ -166,10 +166,6 @@ class RemoteParticipant extends Participant {
|
||||
track: track,
|
||||
publication: pub,
|
||||
));
|
||||
|
||||
// if (track is AudioTrack) {
|
||||
// await AudioManager().decrementSubscriptionCounter();
|
||||
// }
|
||||
}
|
||||
|
||||
if (notify) {
|
||||
|
||||
@@ -9,6 +9,7 @@ import 'constants.dart';
|
||||
import 'events.dart';
|
||||
import 'exceptions.dart';
|
||||
import 'extensions.dart';
|
||||
import 'internal/events.dart';
|
||||
import 'logger.dart';
|
||||
import 'managers/delay.dart';
|
||||
import 'managers/event.dart';
|
||||
|
||||
Reference in New Issue
Block a user