Skip to content

Commit

Permalink
added music mode support
Browse files Browse the repository at this point in the history
  • Loading branch information
Decoder07 committed Aug 21, 2024
1 parent 7abd2da commit e43721b
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 9 deletions.
6 changes: 5 additions & 1 deletion packages/hms_room_kit/lib/src/common/utility_functions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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
Expand Down
14 changes: 12 additions & 2 deletions packages/hms_room_kit/lib/src/hms_prebuilt_options.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,25 @@ 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,
this.userId,
this.endPoints,
this.debugInfo = false,
this.iOSScreenshareConfig,
this.enableNoiseCancellation = false});
this.enableNoiseCancellation = false,
this.isAutomaticGainControlEnabled = false,
this.isNoiseSuppressionEnabled = false});
}
8 changes: 6 additions & 2 deletions packages/hms_room_kit/lib/src/hmssdk_interactor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -50,7 +52,9 @@ class HMSSDKInteractor {
joinWithMutedAudio: joinWithMutedAudio,
isSoftwareDecoderDisabled: isSoftwareDecoderDisabled,
audioMode: audioMode,
isNoiseCancellationEnabled: isNoiseCancellationEnabled);
isNoiseCancellationEnabled: isNoiseCancellationEnabled,
isAutomaticGainControlEnabled: isAutomaticGainControlEnabled,
isNoiseSuppressionEnabled: isNoiseSuppressionEnabled);

hmsSDK = HMSSDK(
iOSScreenshareConfig: iOSScreenshareConfig,
Expand Down
4 changes: 4 additions & 0 deletions packages/hms_room_kit/lib/src/screen_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,10 @@ class _ScreenControllerState extends State<ScreenController> {
isAudioMixerDisabled: AppDebugConfig.isAudioMixerDisabled,
isNoiseCancellationEnabled:
widget.options?.enableNoiseCancellation ?? false,
isAutomaticGainControlEnabled:
widget.options?.isAutomaticGainControlEnabled ?? false,
isNoiseSuppressionEnabled:
widget.options?.isNoiseSuppressionEnabled ?? false,
isPrebuilt: true);
await _hmsSDKInteractor.build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion packages/hmssdk_flutter/lib/assets/sdk-versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
"iOSBroadcastExtension": "0.0.9",
"iOSHLSPlayerSDK": "0.0.2",
"iOSNoiseCancellationModels": "1.0.0",
"android": "2.9.64"
"android": "2.9.65"
}
20 changes: 17 additions & 3 deletions packages/hmssdk_flutter/lib/src/model/hms_audio_track_setting.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,26 @@ 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,
this.trackInitialState = HMSTrackInitState.UNMUTED,
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<HMSAudioNode> nodeList = [];
Expand Down Expand Up @@ -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,
Expand All @@ -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
};
}
}

0 comments on commit e43721b

Please sign in to comment.