feat: Support setVideoFPS for subscribe. (#258)

* feat: Support setVideoFPS for subscribe.

* Update lib/src/publication/remote.dart

Co-authored-by: David Zhao <dz@livekit.io>

* Add comment for setVideoFPS.

---------

Co-authored-by: David Zhao <dz@livekit.io>
This commit is contained in:
CloudWebRTC
2023-03-15 15:51:15 +08:00
committed by GitHub
parent a992a27d0b
commit 59ee3105fb
2 changed files with 57 additions and 5 deletions
+13
View File
@@ -31,6 +31,10 @@ class RemoteTrackPublication<T extends RemoteTrack>
bool get enabled => _enabled;
bool _enabled = true;
/// The current desired FPS of the track. This is only available for video tracks that support SVC.
int? _fps;
int get fps => _fps ?? 0;
lk_models.VideoQuality _videoQuality = lk_models.VideoQuality.HIGH;
lk_models.VideoQuality get videoQuality => _videoQuality;
@@ -227,6 +231,14 @@ class RemoteTrackPublication<T extends RemoteTrack>
sendUpdateTrackSettings();
}
/// Set desired FPS, server will do its best to return FPS close to this.
/// It's only supported for video codecs that support SVC currently.
Future<void> setVideoFPS(int newValue) async {
if (newValue == _fps) return;
_fps = newValue;
sendUpdateTrackSettings();
}
Future<void> enable() async {
if (_enabled) return;
_enabled = true;
@@ -289,6 +301,7 @@ class RemoteTrackPublication<T extends RemoteTrack>
);
if (kind == lk_models.TrackType.VIDEO) {
settings.quality = _videoQuality;
if (_fps != null) settings.fps = _fps!;
}
participant.room.engine.signalClient.sendUpdateTrackSettings(settings);
}