Removed iLBC Mode audio setting
This commit is contained in:
@ -175,7 +175,6 @@ private fun AudioContent(viewModel: AudioViewModel, contentPadding: PaddingValue
|
|||||||
AudioModules(viewModel)
|
AudioModules(viewModel)
|
||||||
OpusBitRate(viewModel)
|
OpusBitRate(viewModel)
|
||||||
OpusPacketLoss(viewModel)
|
OpusPacketLoss(viewModel)
|
||||||
IlbcMode(viewModel)
|
|
||||||
AudioDelay(viewModel)
|
AudioDelay(viewModel)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -500,65 +499,6 @@ private fun OpusPacketLoss(viewModel: AudioViewModel) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
|
||||||
private fun IlbcMode(viewModel: AudioViewModel) {
|
|
||||||
Row(
|
|
||||||
Modifier.fillMaxWidth().padding(end = 10.dp),
|
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
|
||||||
horizontalArrangement = Arrangement.Start
|
|
||||||
) {
|
|
||||||
val ilbcModeTitle = stringResource(R.string.ilbc_mode)
|
|
||||||
val ilbcModeHelp = stringResource(R.string.ilbc_mode_help)
|
|
||||||
Text(
|
|
||||||
text = ilbcModeTitle,
|
|
||||||
modifier = Modifier
|
|
||||||
.weight(1f)
|
|
||||||
.clickable {
|
|
||||||
alertTitle.value = ilbcModeTitle
|
|
||||||
alertMessage.value = ilbcModeHelp
|
|
||||||
showAlert.value = true
|
|
||||||
},
|
|
||||||
fontSize = 18.sp
|
|
||||||
)
|
|
||||||
val currentIlbcMode by viewModel.ilbcMode.collectAsState()
|
|
||||||
val isDropDownExpanded = remember { mutableStateOf(false) }
|
|
||||||
val modeNames = listOf("20ms", "30ms")
|
|
||||||
val modeValues = listOf("20", "30")
|
|
||||||
val itemPosition = modeValues.indexOf(currentIlbcMode).let { if (it != -1) it else 1 }
|
|
||||||
|
|
||||||
Box {
|
|
||||||
Row(
|
|
||||||
horizontalArrangement = Arrangement.Center,
|
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
|
||||||
modifier = Modifier.clickable { isDropDownExpanded.value = true }
|
|
||||||
) {
|
|
||||||
Text(text = modeNames[itemPosition])
|
|
||||||
Icon(
|
|
||||||
imageVector = Icons.Filled.ArrowDropDown,
|
|
||||||
contentDescription = null,
|
|
||||||
modifier = Modifier.size(36.dp)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
DropdownMenu(
|
|
||||||
expanded = isDropDownExpanded.value,
|
|
||||||
onDismissRequest = { isDropDownExpanded.value = false }
|
|
||||||
) {
|
|
||||||
modeNames.forEachIndexed { index, name ->
|
|
||||||
DropdownMenuItem(
|
|
||||||
text = { Text(text = name) },
|
|
||||||
onClick = {
|
|
||||||
isDropDownExpanded.value = false
|
|
||||||
viewModel.ilbcMode.value = modeValues[index]
|
|
||||||
}
|
|
||||||
)
|
|
||||||
if (index < modeNames.size - 1)
|
|
||||||
HorizontalDivider(thickness = 1.dp)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun AudioDelay(viewModel: AudioViewModel) {
|
private fun AudioDelay(viewModel: AudioViewModel) {
|
||||||
Row(
|
Row(
|
||||||
|
|||||||
@ -14,7 +14,6 @@ class AudioViewModel : ViewModel() {
|
|||||||
val audioModules = MutableStateFlow(mutableMapOf<String, Boolean>())
|
val audioModules = MutableStateFlow(mutableMapOf<String, Boolean>())
|
||||||
val opusBitrate = MutableStateFlow("")
|
val opusBitrate = MutableStateFlow("")
|
||||||
val opusPacketLoss = MutableStateFlow("")
|
val opusPacketLoss = MutableStateFlow("")
|
||||||
val ilbcMode = MutableStateFlow("")
|
|
||||||
val audioDelay = MutableStateFlow("")
|
val audioDelay = MutableStateFlow("")
|
||||||
val toneCountry = MutableStateFlow("")
|
val toneCountry = MutableStateFlow("")
|
||||||
val ringtoneUri = MutableStateFlow("")
|
val ringtoneUri = MutableStateFlow("")
|
||||||
@ -26,7 +25,6 @@ class AudioViewModel : ViewModel() {
|
|||||||
var oldAudioModules = ArrayList<String>()
|
var oldAudioModules = ArrayList<String>()
|
||||||
var oldOpusBitrate = ""
|
var oldOpusBitrate = ""
|
||||||
var oldOpusPacketLoss = ""
|
var oldOpusPacketLoss = ""
|
||||||
var oldIlbcMode = ""
|
|
||||||
var oldAudioDelay = ""
|
var oldAudioDelay = ""
|
||||||
var oldToneCountry = ""
|
var oldToneCountry = ""
|
||||||
var oldRingtoneUri = ""
|
var oldRingtoneUri = ""
|
||||||
@ -58,9 +56,6 @@ class AudioViewModel : ViewModel() {
|
|||||||
oldOpusPacketLoss = Config.variable("opus_packet_loss")
|
oldOpusPacketLoss = Config.variable("opus_packet_loss")
|
||||||
opusPacketLoss.value = oldOpusPacketLoss
|
opusPacketLoss.value = oldOpusPacketLoss
|
||||||
|
|
||||||
oldIlbcMode = Config.variable("ilbc_mode")
|
|
||||||
ilbcMode.value = oldIlbcMode
|
|
||||||
|
|
||||||
oldAudioDelay = Config.variable("audio_delay")
|
oldAudioDelay = Config.variable("audio_delay")
|
||||||
if (oldAudioDelay == "") oldAudioDelay = BaresipService.audioDelay.toString()
|
if (oldAudioDelay == "") oldAudioDelay = BaresipService.audioDelay.toString()
|
||||||
audioDelay.value = oldAudioDelay
|
audioDelay.value = oldAudioDelay
|
||||||
@ -153,12 +148,6 @@ class AudioViewModel : ViewModel() {
|
|||||||
save = true
|
save = true
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ilbcMode.value != oldIlbcMode) {
|
|
||||||
Config.replaceVariable("ilbc_mode", ilbcMode.value)
|
|
||||||
restart = true
|
|
||||||
save = true
|
|
||||||
}
|
|
||||||
|
|
||||||
val delay = audioDelay.value.trim()
|
val delay = audioDelay.value.trim()
|
||||||
if (delay != oldAudioDelay) {
|
if (delay != oldAudioDelay) {
|
||||||
if (!checkAudioDelay(delay)) return Result.ERROR
|
if (!checkAudioDelay(delay)) return Result.ERROR
|
||||||
|
|||||||
@ -559,19 +559,19 @@ class BaresipService: Service() {
|
|||||||
file = File("${filesPath}/$a")
|
file = File("${filesPath}/$a")
|
||||||
if (!file.exists() && a != "config") {
|
if (!file.exists() && a != "config") {
|
||||||
Log.i(TAG, "Copying asset '$a'")
|
Log.i(TAG, "Copying asset '$a'")
|
||||||
Utils.copyAssetToFile(this, a, "$filesPath/$a")
|
Utils.copyAssetToFile(applicationContext, a, "$filesPath/$a")
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Log.i(TAG, "Asset '$a' already copied")
|
Log.i(TAG, "Asset '$a' already copied")
|
||||||
if (a == "config")
|
if (a == "config")
|
||||||
Config.initialize(this)
|
Config.initialize(applicationContext)
|
||||||
}
|
}
|
||||||
|
|
||||||
Thread {
|
Thread {
|
||||||
if (contactsMode != "android")
|
if (contactsMode != "android")
|
||||||
Contact.restoreBaresipContacts()
|
Contact.restoreBaresipContacts()
|
||||||
if (contactsMode != "baresip") {
|
if (contactsMode != "baresip") {
|
||||||
Contact.loadAndroidContacts(this)
|
Contact.loadAndroidContacts(applicationContext)
|
||||||
registerAndroidContactsObserver()
|
registerAndroidContactsObserver()
|
||||||
}
|
}
|
||||||
Contact.contactsUpdate()
|
Contact.contactsUpdate()
|
||||||
@ -1125,7 +1125,7 @@ class BaresipService: Service() {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
val name = "callwaiting_$toneCountry"
|
val name = "callwaiting_$toneCountry"
|
||||||
val resourceId = resources.getIdentifier(
|
val resourceId = applicationContext.resources.getIdentifier(
|
||||||
name,
|
name,
|
||||||
"raw",
|
"raw",
|
||||||
packageName
|
packageName
|
||||||
@ -2727,7 +2727,7 @@ class BaresipService: Service() {
|
|||||||
private fun playRingBack() {
|
private fun playRingBack() {
|
||||||
if (mediaPlayer == null) {
|
if (mediaPlayer == null) {
|
||||||
val name = "ringback_$toneCountry"
|
val name = "ringback_$toneCountry"
|
||||||
val resourceId = resources.getIdentifier(name, "raw", packageName)
|
val resourceId = applicationContext.resources.getIdentifier(name, "raw", packageName)
|
||||||
if (resourceId != 0) {
|
if (resourceId != 0) {
|
||||||
val audioAttributes = AudioAttributes.Builder()
|
val audioAttributes = AudioAttributes.Builder()
|
||||||
.setUsage(AudioAttributes.USAGE_VOICE_COMMUNICATION)
|
.setUsage(AudioAttributes.USAGE_VOICE_COMMUNICATION)
|
||||||
@ -2735,7 +2735,7 @@ class BaresipService: Service() {
|
|||||||
.build()
|
.build()
|
||||||
mediaPlayer = MediaPlayer().apply {
|
mediaPlayer = MediaPlayer().apply {
|
||||||
setAudioAttributes(audioAttributes)
|
setAudioAttributes(audioAttributes)
|
||||||
val afd = resources.openRawResourceFd(resourceId)
|
val afd = applicationContext.resources.openRawResourceFd(resourceId)
|
||||||
setDataSource(afd.fileDescriptor, afd.startOffset, afd.length)
|
setDataSource(afd.fileDescriptor, afd.startOffset, afd.length)
|
||||||
afd.close()
|
afd.close()
|
||||||
isLooping = true
|
isLooping = true
|
||||||
@ -2752,7 +2752,7 @@ class BaresipService: Service() {
|
|||||||
private fun playBusy() {
|
private fun playBusy() {
|
||||||
if (mediaPlayer == null) {
|
if (mediaPlayer == null) {
|
||||||
val name = "busy_$toneCountry"
|
val name = "busy_$toneCountry"
|
||||||
val resourceId = resources.getIdentifier(name, "raw", packageName)
|
val resourceId = applicationContext.resources.getIdentifier(name, "raw", packageName)
|
||||||
if (resourceId != 0) {
|
if (resourceId != 0) {
|
||||||
val audioAttributes = AudioAttributes.Builder()
|
val audioAttributes = AudioAttributes.Builder()
|
||||||
.setUsage(AudioAttributes.USAGE_VOICE_COMMUNICATION)
|
.setUsage(AudioAttributes.USAGE_VOICE_COMMUNICATION)
|
||||||
@ -2760,7 +2760,7 @@ class BaresipService: Service() {
|
|||||||
.build()
|
.build()
|
||||||
mediaPlayer = MediaPlayer().apply {
|
mediaPlayer = MediaPlayer().apply {
|
||||||
setAudioAttributes(audioAttributes)
|
setAudioAttributes(audioAttributes)
|
||||||
val afd = resources.openRawResourceFd(resourceId)
|
val afd = applicationContext.resources.openRawResourceFd(resourceId)
|
||||||
setDataSource(afd.fileDescriptor, afd.startOffset, afd.length)
|
setDataSource(afd.fileDescriptor, afd.startOffset, afd.length)
|
||||||
afd.close()
|
afd.close()
|
||||||
setOnCompletionListener {
|
setOnCompletionListener {
|
||||||
|
|||||||
@ -237,12 +237,6 @@ object Config {
|
|||||||
else
|
else
|
||||||
"${config}opus_packet_loss $opusPacketLoss\n"
|
"${config}opus_packet_loss $opusPacketLoss\n"
|
||||||
|
|
||||||
val ilbcMode = previousVariable("ilbc_mode")
|
|
||||||
config = if (ilbcMode == "")
|
|
||||||
"${config}ilbc_mode 30\n"
|
|
||||||
else
|
|
||||||
"${config}ilbc_mode $ilbcMode\n"
|
|
||||||
|
|
||||||
val audioDelay = previousVariable("audio_delay")
|
val audioDelay = previousVariable("audio_delay")
|
||||||
if (audioDelay != "") {
|
if (audioDelay != "") {
|
||||||
config = "${config}audio_delay $audioDelay\n"
|
config = "${config}audio_delay $audioDelay\n"
|
||||||
|
|||||||
@ -566,7 +566,7 @@ object Utils {
|
|||||||
|
|
||||||
fun copyAssetToFile(context: Context, asset: String, path: String) {
|
fun copyAssetToFile(context: Context, asset: String, path: String) {
|
||||||
try {
|
try {
|
||||||
context.assets.open(asset).use { `is` ->
|
context.applicationContext.assets.open(asset).use { `is` ->
|
||||||
FileOutputStream(path).use { os ->
|
FileOutputStream(path).use { os ->
|
||||||
val buffer = ByteArray(512)
|
val buffer = ByteArray(512)
|
||||||
var byteRead: Int = `is`.read(buffer)
|
var byteRead: Int = `is`.read(buffer)
|
||||||
|
|||||||
@ -450,9 +450,6 @@
|
|||||||
<string name="audio_delay_help">Audion odotusviive (millisekunneissa) soitetun puhelun alkaessa.
|
<string name="audio_delay_help">Audion odotusviive (millisekunneissa) soitetun puhelun alkaessa.
|
||||||
Aseta korkeampi arvo, jos et kuule vastaajan ääntä heti, kun puhelu alkaa.</string>
|
Aseta korkeampi arvo, jos et kuule vastaajan ääntä heti, kun puhelu alkaa.</string>
|
||||||
<string name="invalid_audio_delay">Virheellinen audioviive \'%1$s\'. Sallittu arvo on välillä 100–3000.</string>
|
<string name="invalid_audio_delay">Virheellinen audioviive \'%1$s\'. Sallittu arvo on välillä 100–3000.</string>
|
||||||
<string name="ilbc_mode">iLBC-moodi</string>
|
|
||||||
<string name="ilbc_mode_help">Valitsee iLBC-koodekin kehyksen keston.
|
|
||||||
30ms tarjoaa paremman äänenlaadun alhaisilla bittinopeuksilla, kun taas 20ms:ssä on pienempi viive.</string>
|
|
||||||
<string name="default_call_volume">Oletus äänen voimakkuus</string>
|
<string name="default_call_volume">Oletus äänen voimakkuus</string>
|
||||||
<string name="default_call_volume_help">Jos valittu, puhelun äänen voimakkuus
|
<string name="default_call_volume_help">Jos valittu, puhelun äänen voimakkuus
|
||||||
asteikolla 1–10.</string>
|
asteikolla 1–10.</string>
|
||||||
|
|||||||
@ -429,9 +429,6 @@
|
|||||||
<string name="audio_delay_help">Time (in milliseconds) to wait audio from callee when call is established.
|
<string name="audio_delay_help">Time (in milliseconds) to wait audio from callee when call is established.
|
||||||
Set to a higher value if you miss audio from callee at the beginning of the call.</string>
|
Set to a higher value if you miss audio from callee at the beginning of the call.</string>
|
||||||
<string name="invalid_audio_delay">Invalid Audio Delay \'%1$s\'. Valid values are from 100 to 3000.</string>
|
<string name="invalid_audio_delay">Invalid Audio Delay \'%1$s\'. Valid values are from 100 to 3000.</string>
|
||||||
<string name="ilbc_mode">iLBC Mode</string>
|
|
||||||
<string name="ilbc_mode_help">Selects the default iLBC frame duration.
|
|
||||||
30ms provides better low-bitrate quality, while 20ms has lower latency.</string>
|
|
||||||
<string name="default_call_volume">Default Call Volume</string>
|
<string name="default_call_volume">Default Call Volume</string>
|
||||||
<string name="default_call_volume_help">If set, default call audio volume at scale 1–10.</string>
|
<string name="default_call_volume_help">If set, default call audio volume at scale 1–10.</string>
|
||||||
<string name="tone_country">Tone Country</string>
|
<string name="tone_country">Tone Country</string>
|
||||||
|
|||||||
Reference in New Issue
Block a user