TrackPublishedEvent for local tracks
This commit is contained in:
+2
-2
@@ -72,8 +72,8 @@ class ActiveSpeakersChangedEvent with RoomEvent {
|
||||
/// joined. It will not fire for tracks that are already published.
|
||||
/// Emitted by [Room] and [RemoteParticipant].
|
||||
class TrackPublishedEvent with RoomEvent, ParticipantEvent {
|
||||
final RemoteParticipant participant;
|
||||
final RemoteTrackPublication publication;
|
||||
final Participant participant;
|
||||
final TrackPublication publication;
|
||||
const TrackPublishedEvent({
|
||||
required this.participant,
|
||||
required this.publication,
|
||||
|
||||
@@ -76,7 +76,12 @@ class LocalParticipant extends Participant {
|
||||
|
||||
final pub = LocalTrackPublication(trackInfo, track, this);
|
||||
addTrackPublication(pub);
|
||||
notifyListeners();
|
||||
|
||||
[events, roomEvents].emit(TrackPublishedEvent(
|
||||
participant: this,
|
||||
publication: pub,
|
||||
));
|
||||
|
||||
return pub;
|
||||
}
|
||||
|
||||
@@ -149,7 +154,11 @@ class LocalParticipant extends Participant {
|
||||
|
||||
final pub = LocalTrackPublication(trackInfo, track, this);
|
||||
addTrackPublication(pub);
|
||||
notifyListeners();
|
||||
|
||||
[events, roomEvents].emit(TrackPublishedEvent(
|
||||
participant: this,
|
||||
publication: pub,
|
||||
));
|
||||
|
||||
return pub;
|
||||
}
|
||||
|
||||
@@ -141,9 +141,9 @@ abstract class Participant extends DisposableChangeNotifier
|
||||
}
|
||||
|
||||
// Must implement
|
||||
Future<void> unpublishTrack(String trackSid, {bool notify = false});
|
||||
Future<void> unpublishTrack(String trackSid, {bool notify = true});
|
||||
|
||||
Future<void> unpublishAllTracks({bool notify = false}) async {
|
||||
Future<void> unpublishAllTracks({bool notify = true}) async {
|
||||
final trackSids = trackPublications.keys.toSet();
|
||||
for (final trackid in trackSids) {
|
||||
await unpublishTrack(trackid, notify: notify);
|
||||
|
||||
@@ -73,7 +73,7 @@ class RemoteParticipant extends Participant {
|
||||
reason: TrackSubscribeFailReason.notTrackMetadataFound,
|
||||
),
|
||||
);
|
||||
pub = event.publication;
|
||||
pub = event.publication as RemoteTrackPublication;
|
||||
logger.fine('addSubscribedMediaTrack() did receive pub');
|
||||
}
|
||||
|
||||
@@ -147,7 +147,7 @@ class RemoteParticipant extends Participant {
|
||||
final removeSids =
|
||||
trackPublications.keys.where((e) => !validSids.contains(e)).toSet();
|
||||
for (final sid in removeSids) {
|
||||
await unpublishTrack(sid, notify: true);
|
||||
await unpublishTrack(sid);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user