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:
Hiroshi Horie
2021-10-01 16:56:36 +09:00
committed by GitHub
parent 84618cf56f
commit b67c807fd5
10 changed files with 62 additions and 103 deletions
+8 -4
View File
@@ -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.
+1 -5
View File
@@ -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) {