From 1366ff26de2e128cf5d5268f2ca9093b31487247 Mon Sep 17 00:00:00 2001 From: CloudWebRTC Date: Thu, 16 Nov 2023 18:07:19 +0800 Subject: [PATCH] fix: fix getStats for remote track. (#399) --- lib/src/track/local/audio.dart | 2 +- lib/src/track/local/video.dart | 2 +- lib/src/track/remote/audio.dart | 2 +- lib/src/track/remote/video.dart | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/src/track/local/audio.dart b/lib/src/track/local/audio.dart index f44a84ee..9dcf5ae7 100644 --- a/lib/src/track/local/audio.dart +++ b/lib/src/track/local/audio.dart @@ -48,7 +48,7 @@ class LocalAudioTrack extends LocalTrack @override Future monitorStats() async { - if (sender == null || events.isDisposed) { + if (sender == null || events.isDisposed || !isActive) { _currentBitrate = 0; return false; } diff --git a/lib/src/track/local/video.dart b/lib/src/track/local/video.dart index af17c98c..7096021b 100644 --- a/lib/src/track/local/video.dart +++ b/lib/src/track/local/video.dart @@ -62,7 +62,7 @@ class LocalVideoTrack extends LocalTrack with VideoTrack { @override Future monitorStats() async { - if (sender == null || events.isDisposed) { + if (sender == null || events.isDisposed || !isActive) { _currentBitrate = 0; return false; } diff --git a/lib/src/track/remote/audio.dart b/lib/src/track/remote/audio.dart index a2b9b127..b0a86e31 100644 --- a/lib/src/track/remote/audio.dart +++ b/lib/src/track/remote/audio.dart @@ -81,7 +81,7 @@ class RemoteAudioTrack extends RemoteTrack @override Future monitorStats() async { - if (receiver == null && events.isDisposed) { + if (receiver == null || events.isDisposed || !isActive) { _currentBitrate = 0; return false; } diff --git a/lib/src/track/remote/video.dart b/lib/src/track/remote/video.dart index 625e9fee..e057958e 100644 --- a/lib/src/track/remote/video.dart +++ b/lib/src/track/remote/video.dart @@ -46,7 +46,7 @@ class RemoteVideoTrack extends RemoteTrack with VideoTrack { @override Future monitorStats() async { - if (receiver == null && events.isDisposed) { + if (receiver == null || events.isDisposed || !isActive) { _currentBitrate = 0; return false; }