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