call dispose on pub and track
This commit is contained in:
@@ -157,7 +157,10 @@ 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) return;
|
||||
if (pub is! LocalTrackPublication) {
|
||||
await pub?.dispose();
|
||||
return;
|
||||
}
|
||||
|
||||
final track = pub.track;
|
||||
if (track != null) {
|
||||
@@ -185,6 +188,8 @@ class LocalParticipant extends Participant {
|
||||
publication: pub,
|
||||
));
|
||||
}
|
||||
|
||||
await pub.dispose();
|
||||
}
|
||||
|
||||
/// Publish a new data payload to the room.
|
||||
|
||||
@@ -158,7 +158,14 @@ 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) return;
|
||||
|
||||
if (pub is! RemoteTrackPublication) {
|
||||
// no publication exists for trackSid
|
||||
// or publication is not RemoteTrackPublication
|
||||
// logger.warning('pub is not RemoteTrackPublication');
|
||||
await pub?.dispose();
|
||||
return;
|
||||
}
|
||||
|
||||
final track = pub.track;
|
||||
// if has track
|
||||
@@ -177,5 +184,7 @@ class RemoteParticipant extends Participant {
|
||||
publication: pub,
|
||||
));
|
||||
}
|
||||
|
||||
await pub.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,11 @@ class LocalTrackPublication extends TrackPublication {
|
||||
this._participant,
|
||||
) : super.fromInfo(info) {
|
||||
this.track = track;
|
||||
// register dispose func
|
||||
onDispose(() async {
|
||||
// this object is responsible for disposing track
|
||||
await track.dispose();
|
||||
});
|
||||
}
|
||||
|
||||
/// Mute or unmute the current track. When muted, track will stop sending data
|
||||
|
||||
@@ -17,6 +17,19 @@ class RemoteTrackPublication extends TrackPublication {
|
||||
lk_rtc.VideoQuality _videoQuality = lk_rtc.VideoQuality.HIGH;
|
||||
lk_rtc.VideoQuality get videoQuality => _videoQuality;
|
||||
|
||||
RemoteTrackPublication(
|
||||
lk_models.TrackInfo info,
|
||||
this._participant, [
|
||||
Track? track,
|
||||
]) : super.fromInfo(info) {
|
||||
this.track = track;
|
||||
// register dispose func
|
||||
onDispose(() async {
|
||||
// this object is responsible for disposing track
|
||||
await track?.dispose();
|
||||
});
|
||||
}
|
||||
|
||||
set videoQuality(lk_rtc.VideoQuality val) {
|
||||
if (val == _videoQuality) return;
|
||||
_videoQuality = val;
|
||||
@@ -76,14 +89,6 @@ class RemoteTrackPublication extends TrackPublication {
|
||||
}
|
||||
}
|
||||
|
||||
RemoteTrackPublication(
|
||||
lk_models.TrackInfo info,
|
||||
this._participant, [
|
||||
Track? track,
|
||||
]) : super.fromInfo(info) {
|
||||
this.track = track;
|
||||
}
|
||||
|
||||
void _sendUpdateSubscription({required bool subscribed}) {
|
||||
logger.fine('Sending update subscription... ${sid} ${subscribed}');
|
||||
final subscription = lk_rtc.UpdateSubscription(
|
||||
|
||||
Reference in New Issue
Block a user