Move bitrate, FEC and redundancy to a Network settings page
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
package com.ts3client.android.ui
|
||||
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.ts3client.android.SessionController
|
||||
import com.ts3client.config.Settings
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
private const val MIN_BITRATE_KBITS = 8f
|
||||
private const val MAX_BITRATE_KBITS = 160f
|
||||
|
||||
/** What voice costs and survives on the wire: bitrate, error correction and duplicate packets. */
|
||||
@Composable
|
||||
fun NetworkSettingsScreen(vm: SessionController, onBack: () -> Unit) {
|
||||
val settings = vm.settings
|
||||
fun change(edit: Settings.() -> Unit) {
|
||||
settings.edit()
|
||||
vm.applySettings()
|
||||
}
|
||||
var vbr by remember { mutableStateOf(settings.vbr) }
|
||||
var fec by remember { mutableStateOf(settings.fec) }
|
||||
var redundancy by remember { mutableStateOf(settings.redundancyDelay) }
|
||||
var copies by remember { mutableStateOf(settings.redundancyCopies) }
|
||||
|
||||
SubScreen("Network", onBack) { padding ->
|
||||
Column(Modifier.padding(padding).verticalScroll(rememberScrollState()).padding(bottom = 8.dp)) {
|
||||
Section("Encoder")
|
||||
Level("Bitrate", settings.bitrate / 1000f, MIN_BITRATE_KBITS..MAX_BITRATE_KBITS, { "${it.roundToInt()} kbit/s" }) {
|
||||
change { bitrate = it.roundToInt() * 1000 }
|
||||
}
|
||||
Toggle("Variable bitrate (VBR)", vbr) {
|
||||
vbr = it
|
||||
change { this.vbr = it }
|
||||
}
|
||||
Toggle("Forward error correction (FEC)", fec) {
|
||||
fec = it
|
||||
change { this.fec = it }
|
||||
}
|
||||
|
||||
Section("Redundancy")
|
||||
Picker("Delay", Settings.REDUNDANCY_DELAYS.map { it to if (it == 0) "Off" else "$it ms" }, redundancy) {
|
||||
redundancy = it
|
||||
change { redundancyDelay = it }
|
||||
}
|
||||
if (redundancy > 0) {
|
||||
Picker("Copies", (1..Settings.MAX_REDUNDANCY_COPIES).map { it to "$it" }, copies) {
|
||||
copies = it
|
||||
change { redundancyCopies = it }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,7 @@ import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
|
||||
private enum class SettingsPage { SOUND, DESIGN, IDENTITIES, MY_TEAMSPEAK }
|
||||
private enum class SettingsPage { SOUND, NETWORK, DESIGN, IDENTITIES, MY_TEAMSPEAK }
|
||||
|
||||
/**
|
||||
* The settings, by category. Every change is saved and put into effect at once,
|
||||
@@ -32,6 +32,7 @@ fun SettingsScreen(vm: SessionController, onContacts: () -> Unit, onBack: () ->
|
||||
var page by rememberSaveable { mutableStateOf<SettingsPage?>(null) }
|
||||
when (page) {
|
||||
SettingsPage.SOUND -> return SoundSettingsScreen(vm, onBack = { page = null })
|
||||
SettingsPage.NETWORK -> return NetworkSettingsScreen(vm, onBack = { page = null })
|
||||
SettingsPage.DESIGN -> return DesignScreen(vm, onBack = { page = null })
|
||||
SettingsPage.IDENTITIES -> return IdentitiesScreen(vm.identities, onBack = { page = null })
|
||||
SettingsPage.MY_TEAMSPEAK -> return MyTeamSpeakScreen(vm, onBack = { page = null })
|
||||
@@ -44,6 +45,9 @@ fun SettingsScreen(vm: SessionController, onContacts: () -> Unit, onBack: () ->
|
||||
LinkRow("Sound Settings", "Devices, transmission, voice activation, processing, volume", "PLAYBACK") {
|
||||
page = SettingsPage.SOUND
|
||||
}
|
||||
LinkRow("Network", "Bitrate, error correction, redundancy", "PING_4") {
|
||||
page = SettingsPage.NETWORK
|
||||
}
|
||||
LinkRow("Design", "Icon pack, country flags, description pictures", "GUISETUP") {
|
||||
page = SettingsPage.DESIGN
|
||||
}
|
||||
|
||||
@@ -39,8 +39,6 @@ import com.ts3client.config.Settings
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
private val DENOISE_LEVELS = listOf("Off", "6 dB", "12 dB", "18 dB", "21 dB")
|
||||
private const val MIN_BITRATE_KBITS = 8f
|
||||
private const val MAX_BITRATE_KBITS = 160f
|
||||
|
||||
/** Audio devices, transmission, voice activation, processing and playback. */
|
||||
@Composable
|
||||
@@ -53,11 +51,7 @@ fun SoundSettingsScreen(vm: SessionController, onBack: () -> Unit) {
|
||||
var inputMode by remember { mutableStateOf(settings.inputMode) }
|
||||
var vadMode by remember { mutableStateOf(settings.vadMode) }
|
||||
var agc by remember { mutableStateOf(settings.agc) }
|
||||
var vbr by remember { mutableStateOf(settings.vbr) }
|
||||
var fec by remember { mutableStateOf(settings.fec) }
|
||||
var music by remember { mutableStateOf(settings.music) }
|
||||
var redundancy by remember { mutableStateOf(settings.redundancyDelay) }
|
||||
var copies by remember { mutableStateOf(settings.redundancyCopies) }
|
||||
var mutedTalkWarning by remember { mutableStateOf(settings.mutedTalkWarning) }
|
||||
var threshold by remember { mutableFloatStateOf(settings.vadThresholdDb.toFloat()) }
|
||||
var inputDevice by remember { mutableStateOf(settings.inputDevice) }
|
||||
@@ -155,34 +149,13 @@ fun SoundSettingsScreen(vm: SessionController, onBack: () -> Unit) {
|
||||
}
|
||||
|
||||
Section("Encoder")
|
||||
Level("Bitrate", settings.bitrate / 1000f, MIN_BITRATE_KBITS..MAX_BITRATE_KBITS, { "${it.roundToInt()} kbit/s" }) {
|
||||
change { bitrate = it.roundToInt() * 1000 }
|
||||
}
|
||||
Level("Complexity", settings.complexity.toFloat(), 0f..10f, { "${it.roundToInt()}" }, steps = 9) {
|
||||
change { complexity = it.roundToInt() }
|
||||
}
|
||||
Toggle("Variable bitrate (VBR)", vbr) {
|
||||
vbr = it
|
||||
change { this.vbr = it }
|
||||
}
|
||||
Toggle("Forward error correction (FEC)", fec) {
|
||||
fec = it
|
||||
change { this.fec = it }
|
||||
}
|
||||
Toggle("Music codec (stereo, higher fidelity)", music) {
|
||||
music = it
|
||||
change { this.music = it }
|
||||
}
|
||||
Picker("Redundancy", Settings.REDUNDANCY_DELAYS.map { it to if (it == 0) "Off" else "$it ms" }, redundancy) {
|
||||
redundancy = it
|
||||
change { redundancyDelay = it }
|
||||
}
|
||||
if (redundancy > 0) {
|
||||
Picker("Copies", (1..Settings.MAX_REDUNDANCY_COPIES).map { it to "$it" }, copies) {
|
||||
copies = it
|
||||
change { redundancyCopies = it }
|
||||
}
|
||||
}
|
||||
|
||||
Section("Playback")
|
||||
Level("Volume", settings.outputVolume.toFloat(), 0f..2f, { "${(it * 100).roundToInt()} %" }) {
|
||||
|
||||
Reference in New Issue
Block a user