better type for Participant.trackPublications
This commit is contained in:
@@ -26,6 +26,9 @@ class LocalParticipant extends Participant {
|
||||
@internal
|
||||
final AudioPublishOptions? defaultAudioPublishOptions;
|
||||
|
||||
@override
|
||||
covariant Map<String, LocalTrackPublication> trackPublications = {};
|
||||
|
||||
LocalParticipant({
|
||||
required this.engine,
|
||||
required lk_models.ParticipantInfo info,
|
||||
@@ -173,10 +176,11 @@ class LocalParticipant extends Participant {
|
||||
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) {
|
||||
await pub?.dispose();
|
||||
if (pub == null) {
|
||||
logger.warning('Publication not found $trackSid');
|
||||
return;
|
||||
}
|
||||
await pub.dispose();
|
||||
|
||||
final track = pub.track;
|
||||
if (track != null) {
|
||||
|
||||
@@ -25,7 +25,7 @@ import 'remote_participant.dart';
|
||||
abstract class Participant extends DisposableChangeNotifier
|
||||
with EventsEmittable<ParticipantEvent> {
|
||||
/// map of track sid => published track
|
||||
final trackPublications = <String, TrackPublication>{};
|
||||
abstract final Map<String, TrackPublication> trackPublications;
|
||||
|
||||
/// audio level between 0-1, 1 being the loudest
|
||||
double audioLevel = 0;
|
||||
|
||||
@@ -21,6 +21,9 @@ class RemoteParticipant extends Participant {
|
||||
final RTCEngine _engine;
|
||||
RTCEngine get engine => _engine;
|
||||
|
||||
@override
|
||||
covariant Map<String, RemoteTrackPublication> trackPublications = {};
|
||||
|
||||
@override
|
||||
List<RemoteTrackPublication> get subscribedTracks =>
|
||||
super.subscribedTracks.cast<RemoteTrackPublication>().toList();
|
||||
@@ -178,14 +181,11 @@ class RemoteParticipant extends Participant {
|
||||
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) {
|
||||
// no publication exists for trackSid
|
||||
// or publication is not RemoteTrackPublication
|
||||
|
||||
await pub?.dispose();
|
||||
if (pub == null) {
|
||||
logger.warning('Publication not found $trackSid');
|
||||
return;
|
||||
}
|
||||
await pub.dispose();
|
||||
|
||||
final track = pub.track;
|
||||
// if has track
|
||||
|
||||
Reference in New Issue
Block a user