Added 'Audio Delay' Audio Setting
This commit is contained in:
@@ -18,6 +18,7 @@ class AudioActivity : AppCompatActivity() {
|
|||||||
private lateinit var opusBitRate: EditText
|
private lateinit var opusBitRate: EditText
|
||||||
private lateinit var opusPacketLoss: EditText
|
private lateinit var opusPacketLoss: EditText
|
||||||
private lateinit var aec: CheckBox
|
private lateinit var aec: CheckBox
|
||||||
|
private lateinit var audioDelay: EditText
|
||||||
|
|
||||||
private var save = false
|
private var save = false
|
||||||
private var reload = false
|
private var reload = false
|
||||||
@@ -26,6 +27,7 @@ class AudioActivity : AppCompatActivity() {
|
|||||||
private var oldOpusBitrate = ""
|
private var oldOpusBitrate = ""
|
||||||
private var oldOpusPacketLoss = ""
|
private var oldOpusPacketLoss = ""
|
||||||
private var oldAec = false
|
private var oldAec = false
|
||||||
|
private var oldAudioDelay = BaresipService.audioDelay.toString()
|
||||||
private val audioModules = listOf("opus", "amr", "g722", "g7221", "g726", "g729", "g711")
|
private val audioModules = listOf("opus", "amr", "g722", "g7221", "g726", "g729", "g711")
|
||||||
|
|
||||||
private val onBackPressedCallback = object : OnBackPressedCallback(true) {
|
private val onBackPressedCallback = object : OnBackPressedCallback(true) {
|
||||||
@@ -121,6 +123,9 @@ class AudioActivity : AppCompatActivity() {
|
|||||||
oldAec = aecCv.contains("webrtc_aecm.so")
|
oldAec = aecCv.contains("webrtc_aecm.so")
|
||||||
aec.isChecked = oldAec
|
aec.isChecked = oldAec
|
||||||
|
|
||||||
|
audioDelay = binding.AudioDelay
|
||||||
|
audioDelay.setText(oldAudioDelay)
|
||||||
|
|
||||||
bindTitles()
|
bindTitles()
|
||||||
|
|
||||||
onBackPressedDispatcher.addCallback(this, onBackPressedCallback)
|
onBackPressedDispatcher.addCallback(this, onBackPressedCallback)
|
||||||
@@ -219,6 +224,19 @@ class AudioActivity : AppCompatActivity() {
|
|||||||
save = true
|
save = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val audioDelay = audioDelay.text.toString().trim()
|
||||||
|
if (audioDelay != oldAudioDelay) {
|
||||||
|
if (!checkAudioDelay(audioDelay)) {
|
||||||
|
Utils.alertView(this, getString(R.string.notice),
|
||||||
|
String.format(getString(R.string.invalid_audio_delay), audioDelay))
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
Config.removeVariable("audio_delay")
|
||||||
|
Config.addLine("audio_delay $audioDelay")
|
||||||
|
BaresipService.audioDelay = audioDelay.toLong()
|
||||||
|
save = true
|
||||||
|
}
|
||||||
|
|
||||||
if (save) Config.save()
|
if (save) Config.save()
|
||||||
|
|
||||||
if (reload) Api.reload_config()
|
if (reload) Api.reload_config()
|
||||||
@@ -265,6 +283,10 @@ class AudioActivity : AppCompatActivity() {
|
|||||||
Utils.alertView(this, getString(R.string.aec),
|
Utils.alertView(this, getString(R.string.aec),
|
||||||
getString(R.string.aec_help))
|
getString(R.string.aec_help))
|
||||||
}
|
}
|
||||||
|
binding.AudioDelayTitle.setOnClickListener {
|
||||||
|
Utils.alertView(this, getString(R.string.audio_delay),
|
||||||
|
getString(R.string.audio_delay_help))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun checkOpusBitRate(opusBitRate: String): Boolean {
|
private fun checkOpusBitRate(opusBitRate: String): Boolean {
|
||||||
@@ -277,4 +299,8 @@ class AudioActivity : AppCompatActivity() {
|
|||||||
return (number >= 0) && (number <= 100)
|
return (number >= 0) && (number <= 100)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun checkAudioDelay(audioDelay: String): Boolean {
|
||||||
|
val number = audioDelay.toIntOrNull() ?: return false
|
||||||
|
return (number >= 100) && (number <= 3000)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1474,6 +1474,7 @@ class BaresipService: Service() {
|
|||||||
var isConfigInitialized = false
|
var isConfigInitialized = false
|
||||||
var libraryLoaded = false
|
var libraryLoaded = false
|
||||||
var callVolume = 0
|
var callVolume = 0
|
||||||
|
var audioDelay = if (VERSION.SDK_INT < 31) 1500L else 100L
|
||||||
var dynDns = false
|
var dynDns = false
|
||||||
var filesPath = ""
|
var filesPath = ""
|
||||||
var pName = ""
|
var pName = ""
|
||||||
|
|||||||
@@ -75,6 +75,10 @@ object Config {
|
|||||||
BaresipService.callVolume = variable("call_volume")[0].toInt()
|
BaresipService.callVolume = variable("call_volume")[0].toInt()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (config.contains("audio_delay")) {
|
||||||
|
BaresipService.audioDelay = variable("audio_delay")[0].toLong()
|
||||||
|
}
|
||||||
|
|
||||||
if (config.contains("net_af"))
|
if (config.contains("net_af"))
|
||||||
BaresipService.addressFamily = variable("net_af")[0]
|
BaresipService.addressFamily = variable("net_af")[0]
|
||||||
|
|
||||||
|
|||||||
@@ -1886,45 +1886,27 @@ class MainActivity : AppCompatActivity() {
|
|||||||
hangupButton.visibility = View.VISIBLE
|
hangupButton.visibility = View.VISIBLE
|
||||||
hangupButton.isEnabled = true
|
hangupButton.isEnabled = true
|
||||||
if (Build.VERSION.SDK_INT < 31) {
|
if (Build.VERSION.SDK_INT < 31) {
|
||||||
|
Log.d(TAG, "Setting audio mode to MODE_IN_COMMUNICATION")
|
||||||
am.mode = AudioManager.MODE_IN_COMMUNICATION
|
am.mode = AudioManager.MODE_IN_COMMUNICATION
|
||||||
callRunnable = Runnable {
|
runCall(ua, uri)
|
||||||
callRunnable = null
|
|
||||||
if (!call(ua, uri)) {
|
|
||||||
callButton.visibility = View.VISIBLE
|
|
||||||
callButton.isEnabled = true
|
|
||||||
hangupButton.visibility = View.INVISIBLE
|
|
||||||
hangupButton.isEnabled = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
callHandler.postDelayed(callRunnable!!, 1500)
|
|
||||||
} else {
|
} else {
|
||||||
audioModeChangedListener = AudioManager.OnModeChangedListener { mode ->
|
|
||||||
if (mode == AudioManager.MODE_IN_COMMUNICATION) {
|
|
||||||
Log.d(TAG, "Audio mode changed to MODE_IN_COMMUNICATION using " +
|
|
||||||
"device ${am.communicationDevice!!.type}")
|
|
||||||
if (audioModeChangedListener != null) {
|
|
||||||
am.removeOnModeChangedListener(audioModeChangedListener!!)
|
|
||||||
audioModeChangedListener = null
|
|
||||||
}
|
|
||||||
if (!call(ua, uri)) {
|
|
||||||
callButton.visibility = View.VISIBLE
|
|
||||||
callButton.isEnabled = true
|
|
||||||
hangupButton.visibility = View.INVISIBLE
|
|
||||||
hangupButton.isEnabled = false
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Log.d(TAG, "Audio mode changed to mode ${am.mode} using " +
|
|
||||||
"device ${am.communicationDevice!!.type}")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (am.mode == AudioManager.MODE_IN_COMMUNICATION) {
|
if (am.mode == AudioManager.MODE_IN_COMMUNICATION) {
|
||||||
if (!call(ua, uri)) {
|
runCall(ua, uri)
|
||||||
callButton.visibility = View.VISIBLE
|
|
||||||
callButton.isEnabled = true
|
|
||||||
hangupButton.visibility = View.INVISIBLE
|
|
||||||
hangupButton.isEnabled = false
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
|
audioModeChangedListener = AudioManager.OnModeChangedListener { mode ->
|
||||||
|
if (mode == AudioManager.MODE_IN_COMMUNICATION) {
|
||||||
|
Log.d(TAG, "Audio mode changed to MODE_IN_COMMUNICATION using " +
|
||||||
|
"device ${am.communicationDevice!!.type}")
|
||||||
|
if (audioModeChangedListener != null) {
|
||||||
|
am.removeOnModeChangedListener(audioModeChangedListener!!)
|
||||||
|
audioModeChangedListener = null
|
||||||
|
}
|
||||||
|
runCall(ua, uri)
|
||||||
|
} else {
|
||||||
|
Log.d(TAG, "Audio mode changed to mode ${am.mode} using " +
|
||||||
|
"device ${am.communicationDevice!!.type}")
|
||||||
|
}
|
||||||
|
}
|
||||||
am.addOnModeChangedListener(mainExecutor, audioModeChangedListener!!)
|
am.addOnModeChangedListener(mainExecutor, audioModeChangedListener!!)
|
||||||
Log.d(TAG, "Setting audio mode to MODE_IN_COMMUNICATION")
|
Log.d(TAG, "Setting audio mode to MODE_IN_COMMUNICATION")
|
||||||
am.mode = AudioManager.MODE_IN_COMMUNICATION
|
am.mode = AudioManager.MODE_IN_COMMUNICATION
|
||||||
@@ -1939,6 +1921,20 @@ class MainActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun runCall(ua: UserAgent, uri: String) {
|
||||||
|
callRunnable = Runnable {
|
||||||
|
callRunnable = null
|
||||||
|
if (!call(ua, uri)) {
|
||||||
|
am.mode = AudioManager.MODE_NORMAL
|
||||||
|
callButton.visibility = View.VISIBLE
|
||||||
|
callButton.isEnabled = true
|
||||||
|
hangupButton.visibility = View.INVISIBLE
|
||||||
|
hangupButton.isEnabled = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
callHandler.postDelayed(callRunnable!!, BaresipService.audioDelay)
|
||||||
|
}
|
||||||
|
|
||||||
private fun showCall(ua: UserAgent, showCall: Call? = null) {
|
private fun showCall(ua: UserAgent, showCall: Call? = null) {
|
||||||
val call = showCall ?: ua.currentCall()
|
val call = showCall ?: ua.currentCall()
|
||||||
if (call == null) {
|
if (call == null) {
|
||||||
|
|||||||
@@ -146,6 +146,36 @@
|
|||||||
</CheckBox>
|
</CheckBox>
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="12dp"
|
||||||
|
android:orientation="horizontal" >
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/AudioDelayTitle"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignParentStart="true"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
|
android:textSize="18sp"
|
||||||
|
android:text="@string/audio_delay" >
|
||||||
|
</TextView>
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/AudioDelay"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
|
android:layout_toEndOf="@+id/AudioDelayTitle"
|
||||||
|
android:layout_marginStart="10dp"
|
||||||
|
android:textSize="18sp"
|
||||||
|
android:scrollHorizontally="true"
|
||||||
|
android:inputType="number"
|
||||||
|
android:hint="@string/_0"
|
||||||
|
android:textColorHint="@color/colorSecondaryDark"
|
||||||
|
android:importantForAutofill="no" >
|
||||||
|
</EditText>
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
|||||||
@@ -232,7 +232,7 @@
|
|||||||
android:id="@+id/AudioSettingsTitle"
|
android:id="@+id/AudioSettingsTitle"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginBottom="12dp"
|
android:layout_marginBottom="18dp"
|
||||||
android:textSize="18sp"
|
android:textSize="18sp"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
android:text="@string/audio_settings" >
|
android:text="@string/audio_settings" >
|
||||||
|
|||||||
@@ -377,6 +377,10 @@
|
|||||||
ei ole käytössä.</string>
|
ei ole käytössä.</string>
|
||||||
<string name="invalid_opus_bitrate">Virheellinen Opus-koodekin bittinopeus</string>
|
<string name="invalid_opus_bitrate">Virheellinen Opus-koodekin bittinopeus</string>
|
||||||
<string name="invalid_opus_packet_loss">Virheellinen Opus-koodekin odotettu pakettihäviö</string>
|
<string name="invalid_opus_packet_loss">Virheellinen Opus-koodekin odotettu pakettihäviö</string>
|
||||||
|
<string name="audio_delay">Audioviive</string>
|
||||||
|
<string name="audio_delay_help">Audion odotusviive (millisekunneissa) soitetun puhelun alkaessa.
|
||||||
|
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="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.
|
asteikolla 1–10.
|
||||||
|
|||||||
@@ -354,6 +354,10 @@
|
|||||||
<string name="_0" translatable="false">0</string>
|
<string name="_0" translatable="false">0</string>
|
||||||
<string name="invalid_opus_bitrate">Invalid Opus bitrate</string>
|
<string name="invalid_opus_bitrate">Invalid Opus bitrate</string>
|
||||||
<string name="invalid_opus_packet_loss">Invalid Opus Packet Loss Percentage</string>
|
<string name="invalid_opus_packet_loss">Invalid Opus Packet Loss Percentage</string>
|
||||||
|
<string name="audio_delay">Audio Delay</string>
|
||||||
|
<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>
|
||||||
|
<string name="invalid_audio_delay">Invalid Audio Delay \'%1$s\'. Valid values are from 100 to 3000.</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="dark_theme">Dark Theme</string>
|
<string name="dark_theme">Dark Theme</string>
|
||||||
|
|||||||
Reference in New Issue
Block a user