From b42257473b2622300b3dc6bf5d46c403b3e88377 Mon Sep 17 00:00:00 2001 From: Hiroshi Horie <548776+hiroshihorie@users.noreply.github.com> Date: Thu, 28 Oct 2021 15:55:25 +0900 Subject: [PATCH] `LocalTrackPublishedEvent` `LocalTrackUnpublishedEvent` --- lib/src/events.dart | 32 +++++++++++++++++++--- lib/src/participant/local_participant.dart | 6 ++-- 2 files changed, 31 insertions(+), 7 deletions(-) diff --git a/lib/src/events.dart b/lib/src/events.dart index 1d89d6c..4cb35aa 100644 --- a/lib/src/events.dart +++ b/lib/src/events.dart @@ -1,9 +1,11 @@ import 'package:flutter_webrtc/flutter_webrtc.dart' as rtc; +import 'participant/local_participant.dart'; import 'participant/participant.dart'; import 'participant/remote_participant.dart'; import 'proto/livekit_models.pb.dart' as lk_models; import 'proto/livekit_rtc.pb.dart' as lk_rtc; +import 'track/local_track_publication.dart'; import 'track/remote_track_publication.dart'; import 'track/track.dart'; import 'track/track_publication.dart'; @@ -72,8 +74,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 Participant participant; - final TrackPublication publication; + final RemoteParticipant participant; + final RemoteTrackPublication publication; const TrackPublishedEvent({ required this.participant, required this.publication, @@ -83,14 +85,36 @@ class TrackPublishedEvent with RoomEvent, ParticipantEvent { /// The participant has unpublished one of their [Track]. /// Emitted by [Room] and [RemoteParticipant]. class TrackUnpublishedEvent with RoomEvent, ParticipantEvent { - final Participant participant; - final TrackPublication publication; + final RemoteParticipant participant; + final RemoteTrackPublication publication; const TrackUnpublishedEvent({ required this.participant, required this.publication, }); } +/// When the local participant publishes a new [Track] to the room. +/// Emitted by [Room] and [LocalParticipant]. +class LocalTrackPublishedEvent with RoomEvent, ParticipantEvent { + final LocalParticipant participant; + final LocalTrackPublication publication; + const LocalTrackPublishedEvent({ + required this.participant, + required this.publication, + }); +} + +/// The local participant has unpublished one of their [Track]. +/// Emitted by [Room] and [LocalParticipant]. +class LocalTrackUnpublishedEvent with RoomEvent, ParticipantEvent { + final LocalParticipant participant; + final LocalTrackPublication publication; + const LocalTrackUnpublishedEvent({ + required this.participant, + required this.publication, + }); +} + /// [LocalParticipant] has subscribed to a new track published by a /// [RemoteParticipant]. /// Emitted by [Room] and [RemoteParticipant]. diff --git a/lib/src/participant/local_participant.dart b/lib/src/participant/local_participant.dart index 4540177..06d8d2d 100644 --- a/lib/src/participant/local_participant.dart +++ b/lib/src/participant/local_participant.dart @@ -77,7 +77,7 @@ class LocalParticipant extends Participant { final pub = LocalTrackPublication(trackInfo, track, this); addTrackPublication(pub); - [events, roomEvents].emit(TrackPublishedEvent( + [events, roomEvents].emit(LocalTrackPublishedEvent( participant: this, publication: pub, )); @@ -155,7 +155,7 @@ class LocalParticipant extends Participant { final pub = LocalTrackPublication(trackInfo, track, this); addTrackPublication(pub); - [events, roomEvents].emit(TrackPublishedEvent( + [events, roomEvents].emit(LocalTrackPublishedEvent( participant: this, publication: pub, )); @@ -194,7 +194,7 @@ class LocalParticipant extends Participant { } if (notify) { - [events, roomEvents].emit(TrackUnpublishedEvent( + [events, roomEvents].emit(LocalTrackUnpublishedEvent( participant: this, publication: pub, ));