From 1047d10aecfd84a7a30f24e2d4ad8a9ffafbf335 Mon Sep 17 00:00:00 2001 From: cloudwebrtc Date: Fri, 12 Jul 2024 09:41:09 +0800 Subject: [PATCH] fix: MediaStreamTrack.getSettings. --- CHANGELOG.md | 6 ++++++ lib/src/media_stream_track_impl.dart | 26 +++++++++++++++++++++++++- pubspec.yaml | 2 +- 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 369c91d..da7975b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,12 @@ # Changelog -------------------------------------------- +[1.4.7] - 2024-07-12 + +* fix: MediaStreamTrack.getSettings. + +[1.4.6+hotfix.2] - 2024-06-07 + [1.4.6+hotfix.1] - 2024-06-07 * Wider version dependencies for js/http. diff --git a/lib/src/media_stream_track_impl.dart b/lib/src/media_stream_track_impl.dart index 1c4b8d9..abdf807 100644 --- a/lib/src/media_stream_track_impl.dart +++ b/lib/src/media_stream_track_impl.dart @@ -6,6 +6,8 @@ import 'dart:typed_data'; import 'package:web/web.dart' as web; import 'package:webrtc_interface/webrtc_interface.dart'; +import 'utils.dart'; + class MediaStreamTrackWeb extends MediaStreamTrack { MediaStreamTrackWeb(this.jsTrack) { jsTrack.addEventListener('ended', ((event) => onEnded?.call()).toJS); @@ -64,7 +66,29 @@ class MediaStreamTrackWeb extends MediaStreamTrack { @override Map getSettings() { - return jsTrack.getSettings() as Map; + var settings = jsTrack.getSettings(); + var _converted = {}; + if (kind == 'audio') { + _converted['sampleRate'] = settings.sampleRate; + _converted['sampleSize'] = settings.sampleSize; + _converted['echoCancellation'] = settings.echoCancellation; + _converted['autoGainControl'] = settings.autoGainControl; + _converted['noiseSuppression'] = settings.noiseSuppression; + _converted['latency'] = settings.latency; + _converted['channelCount'] = settings.channelCount; + } else { + _converted['width'] = settings.width; + _converted['height'] = settings.height; + _converted['aspectRatio'] = settings.aspectRatio; + _converted['frameRate'] = settings.frameRate; + if (isMobile) { + _converted['facingMode'] = settings.facingMode; + } + _converted['resizeMode'] = settings.resizeMode; + } + _converted['deviceId'] = settings.deviceId; + _converted['groupId'] = settings.groupId; + return _converted; } @override diff --git a/pubspec.yaml b/pubspec.yaml index 7326e30..b8e9bbe 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: dart_webrtc description: Use the dart/js library to re-wrap the webrtc js interface of the browser, to adapted common browsers. -version: 1.4.6+hotfix.1 +version: 1.4.7 homepage: https://github.com/flutter-webrtc/dart-webrtc environment: