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