Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting options to Control AEC, NS and AGC #308

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,9 @@ class MeetingViewModel(
.audio(
HMSAudioTrackSettings.Builder()
.setUseHardwareAcousticEchoCanceler(settings.enableHardwareAEC)
.enableEchoCancellation(settings.enableAEC)
.enableNoiseSupression(settings.enableNS)
.enableAutomaticGainControl(settings.enableAGC)
.initialState(getAudioTrackState())
.build()
)
Expand Down
18 changes: 18 additions & 0 deletions app/src/main/java/live/hms/app2/ui/settings/SettingsFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,24 @@ class SettingsFragment : Fragment() {
forceSoftwareDecoder
) { commitHelper.setForceSoftwareDecoder(it) }

initSwitch(
EnumSet.of(SettingsMode.HOME),
settings.enableAEC,
enableEchoCancellation
) { commitHelper.setEnableAEC(it) }

initSwitch(
EnumSet.of(SettingsMode.HOME),
settings.enableNS,
enableNoiseSupression
) { commitHelper.setEnableNS(it) }

initSwitch(
EnumSet.of(SettingsMode.HOME),
settings.enableAGC,
enableAutomaticGainControl
) { commitHelper.setEnableAGC(it) }


initSwitch(
EnumSet.of(SettingsMode.HOME),
Expand Down
18 changes: 18 additions & 0 deletions app/src/main/java/live/hms/app2/ui/settings/SettingsStore.kt
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ class SettingsStore(context: Context) {
const val SHOW_STATS = "show-video-stats"
const val DISABLE_AUTO_RESIZE = "disable-auto-resize"
const val FORCE_SOFTWARE_DECODER = "force-software-decoder"
const val ENABLE_ECHO_CANCELLATION = "enable_echo_cancellation"
const val ENABLE_NOISE_SUPRESSION = "enable_noise_supression"
const val ENABLE_AUTOMATIC_GAIN_CONTROL = "enable_automatic_gain_control"

val APPLY_CONSTRAINTS_KEYS = arrayOf(
VIDEO_FRAME_RATE,
Expand Down Expand Up @@ -134,6 +137,18 @@ class SettingsStore(context: Context) {
get() = sharedPreferences.getBoolean(FORCE_SOFTWARE_DECODER, false)
set(value) = putBoolean(FORCE_SOFTWARE_DECODER, value)

var enableAEC: Boolean
get() = sharedPreferences.getBoolean(ENABLE_ECHO_CANCELLATION, true)
set(value) = putBoolean(ENABLE_ECHO_CANCELLATION, value)

var enableNS: Boolean
get() = sharedPreferences.getBoolean(ENABLE_NOISE_SUPRESSION, true)
set(value) = putBoolean(ENABLE_NOISE_SUPRESSION, value)

var enableAGC: Boolean
get() = sharedPreferences.getBoolean(ENABLE_AUTOMATIC_GAIN_CONTROL, true)
set(value) = putBoolean(ENABLE_AUTOMATIC_GAIN_CONTROL, value)

var publishVideo: Boolean
get() = sharedPreferences.getBoolean(PUBLISH_VIDEO, true)
set(value) = putBoolean(PUBLISH_VIDEO, value)
Expand Down Expand Up @@ -316,6 +331,9 @@ class SettingsStore(context: Context) {
fun setShowStats(value: Boolean) = apply { editor.putBoolean(SHOW_STATS, value) }
fun setDisableAutoResize(value: Boolean) = apply { editor.putBoolean(DISABLE_AUTO_RESIZE, value) }
fun setForceSoftwareDecoder(value: Boolean) = apply { editor.putBoolean(FORCE_SOFTWARE_DECODER, value) }
fun setEnableAEC(value: Boolean) = apply { editor.putBoolean(ENABLE_ECHO_CANCELLATION, value) }
fun setEnableNS(value: Boolean) = apply { editor.putBoolean(ENABLE_NOISE_SUPRESSION, value) }
fun setEnableAGC(value: Boolean) = apply { editor.putBoolean(ENABLE_AUTOMATIC_GAIN_CONTROL, value) }


fun commit() {
Expand Down
25 changes: 25 additions & 0 deletions app/src/main/res/layout/fragment_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,31 @@
android:visibility="visible" />


<com.google.android.material.switchmaterial.SwitchMaterial
android:id="@+id/enable_echo_cancellation"
style="@style/MaterialSwitch"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/enable_echo_cancellation"
android:visibility="visible" />

<com.google.android.material.switchmaterial.SwitchMaterial
android:id="@+id/enable_noise_supression"
style="@style/MaterialSwitch"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/enable_noise_supression"
android:visibility="visible" />

<com.google.android.material.switchmaterial.SwitchMaterial
android:id="@+id/enable_automatic_gain_control"
style="@style/MaterialSwitch"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/enable_automatic_gain_control"
android:visibility="visible" />



<com.google.android.material.switchmaterial.SwitchMaterial
android:id="@+id/switch_use_hardware_echo_cancellation"
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,9 @@
<string name="show_stats">Show stats</string>
<string name="disable_auto_resize">Disable Auto Resize</string>
<string name="force_software_decoder">Force Software Decoder</string>
<string name="enable_echo_cancellation">Enable echo_cancellation</string>
<string name="enable_noise_supression">Enable noise suppression</string>
<string name="enable_automatic_gain_control">Enable automatic gain control</string>
<string name="raise_hand">✋ Raise Hand</string>
<string name="pip_mode">PIP mode</string>
<string name="lower_hand">Lower Hand</string>
Expand Down