From dc1d8fbb44ffea615d43af08ede512fdff0c0269 Mon Sep 17 00:00:00 2001 From: cloudwebrtc Date: Wed, 21 Jun 2023 11:05:28 +0800 Subject: [PATCH] fix: Fix wrong override when options is not null when LocalTrack.create. --- lib/src/track/local/audio.dart | 2 +- lib/src/track/local/video.dart | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/src/track/local/audio.dart b/lib/src/track/local/audio.dart index 51809cce..dff72b82 100644 --- a/lib/src/track/local/audio.dart +++ b/lib/src/track/local/audio.dart @@ -99,7 +99,7 @@ class LocalAudioTrack extends LocalTrack static Future create([ AudioCaptureOptions? options, ]) async { - options = const AudioCaptureOptions(); + options ??= const AudioCaptureOptions(); final stream = await LocalTrack.createStream(options); return LocalAudioTrack( diff --git a/lib/src/track/local/video.dart b/lib/src/track/local/video.dart index 4078cbb5..78015cf2 100644 --- a/lib/src/track/local/video.dart +++ b/lib/src/track/local/video.dart @@ -128,7 +128,7 @@ class LocalVideoTrack extends LocalTrack with VideoTrack { static Future createCameraTrack([ CameraCaptureOptions? options, ]) async { - options = const CameraCaptureOptions(); + options ??= const CameraCaptureOptions(); final stream = await LocalTrack.createStream(options); return LocalVideoTrack._( @@ -165,8 +165,11 @@ class LocalVideoTrack extends LocalTrack with VideoTrack { static Future> createScreenShareTracksWithAudio([ ScreenShareCaptureOptions? options, ]) async { - options = const ScreenShareCaptureOptions(captureScreenAudio: true); - + if (options == null) { + options = const ScreenShareCaptureOptions(captureScreenAudio: true); + } else { + options = options.copyWith(captureScreenAudio: true); + } final stream = await LocalTrack.createStream(options); List tracks = [