From e43721ba62b5e958aa9f090fa70f97d50f22576a Mon Sep 17 00:00:00 2001 From: Decoder07 Date: Wed, 21 Aug 2024 11:18:33 +0530 Subject: [PATCH] added music mode support --- .../lib/src/common/utility_functions.dart | 6 +++++- .../lib/src/hms_prebuilt_options.dart | 14 +++++++++++-- .../lib/src/hmssdk_interactor.dart | 8 ++++++-- .../lib/src/screen_controller.dart | 4 ++++ .../HMSTrackSettingsExtension.kt | 14 +++++++++++++ .../lib/assets/sdk-versions.json | 2 +- .../src/model/hms_audio_track_setting.dart | 20 ++++++++++++++++--- 7 files changed, 59 insertions(+), 9 deletions(-) diff --git a/packages/hms_room_kit/lib/src/common/utility_functions.dart b/packages/hms_room_kit/lib/src/common/utility_functions.dart index 5fe8a4657..88f8699c0 100644 --- a/packages/hms_room_kit/lib/src/common/utility_functions.dart +++ b/packages/hms_room_kit/lib/src/common/utility_functions.dart @@ -396,6 +396,8 @@ class Utilities { required bool joinWithMutedAudio, required bool isSoftwareDecoderDisabled, required bool isNoiseCancellationEnabled, + required bool isAutomaticGainControlEnabled, + required bool isNoiseSuppressionEnabled, HMSAudioMode? audioMode, }) { return HMSTrackSetting( @@ -414,7 +416,9 @@ class Utilities { ? HMSTrackInitState.MUTED : HMSTrackInitState.UNMUTED, audioMode: audioMode, - enableNoiseCancellation: isNoiseCancellationEnabled), + enableNoiseCancellation: isNoiseCancellationEnabled, + enableAutomaticGainControl: isAutomaticGainControlEnabled, + enableNoiseSupression: isNoiseSuppressionEnabled), videoTrackSetting: HMSVideoTrackSetting( trackInitialState: joinWithMutedVideo ? HMSTrackInitState.MUTED diff --git a/packages/hms_room_kit/lib/src/hms_prebuilt_options.dart b/packages/hms_room_kit/lib/src/hms_prebuilt_options.dart index 25399aa1a..fb582c750 100644 --- a/packages/hms_room_kit/lib/src/hms_prebuilt_options.dart +++ b/packages/hms_room_kit/lib/src/hms_prebuilt_options.dart @@ -30,9 +30,17 @@ class HMSPrebuiltOptions { final HMSIOSScreenshareConfig? iOSScreenshareConfig; ///To enable noise cancellation in prebuilt. - ///Default value is true + ///Default value is false final bool enableNoiseCancellation; + ///To enable automatic gain control in prebuilt. + ///Default value is false + final bool isAutomaticGainControlEnabled; + + ///To enable noise suppression in prebuilt. + ///Default value is false + final bool isNoiseSuppressionEnabled; + ///[HMSPrebuiltOptions] is a class that is used to pass the options to the prebuilt HMSPrebuiltOptions( {this.userName, @@ -40,5 +48,7 @@ class HMSPrebuiltOptions { this.endPoints, this.debugInfo = false, this.iOSScreenshareConfig, - this.enableNoiseCancellation = false}); + this.enableNoiseCancellation = false, + this.isAutomaticGainControlEnabled = false, + this.isNoiseSuppressionEnabled = false}); } diff --git a/packages/hms_room_kit/lib/src/hmssdk_interactor.dart b/packages/hms_room_kit/lib/src/hmssdk_interactor.dart index 785557e4b..5cae98cf9 100644 --- a/packages/hms_room_kit/lib/src/hmssdk_interactor.dart +++ b/packages/hms_room_kit/lib/src/hmssdk_interactor.dart @@ -38,7 +38,9 @@ class HMSSDKInteractor { bool isAudioMixerDisabled = true, HMSAudioMode audioMode = HMSAudioMode.VOICE, bool isPrebuilt = false, - bool isNoiseCancellationEnabled = false}) { + bool isNoiseCancellationEnabled = false, + bool isAutomaticGainControlEnabled = false, + bool isNoiseSuppressionEnabled = false}) { HMSLogSettings hmsLogSettings = HMSLogSettings( maxDirSizeInBytes: 1000000, isLogStorageEnabled: true, @@ -50,7 +52,9 @@ class HMSSDKInteractor { joinWithMutedAudio: joinWithMutedAudio, isSoftwareDecoderDisabled: isSoftwareDecoderDisabled, audioMode: audioMode, - isNoiseCancellationEnabled: isNoiseCancellationEnabled); + isNoiseCancellationEnabled: isNoiseCancellationEnabled, + isAutomaticGainControlEnabled: isAutomaticGainControlEnabled, + isNoiseSuppressionEnabled: isNoiseSuppressionEnabled); hmsSDK = HMSSDK( iOSScreenshareConfig: iOSScreenshareConfig, diff --git a/packages/hms_room_kit/lib/src/screen_controller.dart b/packages/hms_room_kit/lib/src/screen_controller.dart index b073d8f54..f957bbe2e 100644 --- a/packages/hms_room_kit/lib/src/screen_controller.dart +++ b/packages/hms_room_kit/lib/src/screen_controller.dart @@ -147,6 +147,10 @@ class _ScreenControllerState extends State { isAudioMixerDisabled: AppDebugConfig.isAudioMixerDisabled, isNoiseCancellationEnabled: widget.options?.enableNoiseCancellation ?? false, + isAutomaticGainControlEnabled: + widget.options?.isAutomaticGainControlEnabled ?? false, + isNoiseSuppressionEnabled: + widget.options?.isNoiseSuppressionEnabled ?? false, isPrebuilt: true); await _hmsSDKInteractor.build(); diff --git a/packages/hmssdk_flutter/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSTrackSettingsExtension.kt b/packages/hmssdk_flutter/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSTrackSettingsExtension.kt index 2a742e6a0..205423990 100644 --- a/packages/hmssdk_flutter/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSTrackSettingsExtension.kt +++ b/packages/hmssdk_flutter/android/src/main/kotlin/live/hms/hmssdk_flutter/HMSTrackSettingsExtension.kt @@ -58,6 +58,20 @@ class HMSTrackSettingsExtension { hmsAudioTrackSettings.enableNoiseCancellation(true) } } + + val enableAutomaticGainControl = audioHashMap["enable_automatic_gain_control"] as? Boolean + enableAutomaticGainControl?.let { + if(it){ + hmsAudioTrackSettings.enableAutomaticGainControl(true) + } + } + + val enableNoiseSupression = audioHashMap["enable_noise_supression"] as? Boolean + enableNoiseSupression?.let { + if(it){ + hmsAudioTrackSettings.enableNoiseSupression(true) + } + } } var hmsVideoTrackSettings = HMSVideoTrackSettings.Builder() diff --git a/packages/hmssdk_flutter/lib/assets/sdk-versions.json b/packages/hmssdk_flutter/lib/assets/sdk-versions.json index 9c42f3556..f805e49f4 100644 --- a/packages/hmssdk_flutter/lib/assets/sdk-versions.json +++ b/packages/hmssdk_flutter/lib/assets/sdk-versions.json @@ -4,5 +4,5 @@ "iOSBroadcastExtension": "0.0.9", "iOSHLSPlayerSDK": "0.0.2", "iOSNoiseCancellationModels": "1.0.0", - "android": "2.9.64" + "android": "2.9.65" } diff --git a/packages/hmssdk_flutter/lib/src/model/hms_audio_track_setting.dart b/packages/hmssdk_flutter/lib/src/model/hms_audio_track_setting.dart index baca57ed5..eccf3eb4d 100644 --- a/packages/hmssdk_flutter/lib/src/model/hms_audio_track_setting.dart +++ b/packages/hmssdk_flutter/lib/src/model/hms_audio_track_setting.dart @@ -40,6 +40,16 @@ class HMSAudioTrackSetting { ///Refer: Read more about noise cancellation [here](///) final bool enableNoiseCancellation; + ///[enableAutomaticGainControl] property sets the automatic gain control status in the room whether is enabled or not. + /// + ///Refer: Read more about automatic gain control [here](///) + final bool enableAutomaticGainControl; + + ///[enableNoiseSupression] property sets the noise suppression status in the room whether is enabled or not. + /// + ///Refer: Read more about noise suppression [here](///) + final bool enableNoiseSupression; + HMSAudioTrackSetting( {this.useHardwareAcousticEchoCanceler, this.audioSource, @@ -47,7 +57,9 @@ class HMSAudioTrackSetting { this.audioMode, this.phoneCallState = HMSAndroidPhoneCallState.DISABLE_MUTE_ON_VOIP_PHONE_CALL_RING, - this.enableNoiseCancellation = false}); + this.enableNoiseCancellation = false, + this.enableAutomaticGainControl = false, + this.enableNoiseSupression = false}); factory HMSAudioTrackSetting.fromMap(Map map) { List nodeList = []; @@ -82,7 +94,7 @@ class HMSAudioTrackSetting { if (map.containsKey("enable_noise_cancellation")) { isNoiseCancellationEnabled = map["enable_noise_cancellation"]; } - + return HMSAudioTrackSetting( useHardwareAcousticEchoCanceler: map['user_hardware_acoustic_echo_canceler'] ?? null, @@ -109,7 +121,9 @@ class HMSAudioTrackSetting { 'phone_call_state': HMSAndroidPhoneCallStateValue.getValuefromHMSPhoneCallState( phoneCallState), - 'enable_noise_cancellation': enableNoiseCancellation + 'enable_noise_cancellation': enableNoiseCancellation, + 'enable_automatic_gain_control': enableAutomaticGainControl, + 'enable_noise_supression': enableNoiseSupression }; } }