- Added 'Default Call Volume' configuration option.
This commit is contained in:
@ -8,8 +8,8 @@ android {
|
||||
applicationId = 'com.tutpro.baresip'
|
||||
minSdkVersion 21
|
||||
targetSdkVersion 28
|
||||
versionCode = 55
|
||||
versionName = '7.0.0'
|
||||
versionCode = 56
|
||||
versionName = '7.1.0'
|
||||
externalNativeBuild {
|
||||
cmake {
|
||||
cFlags '-DHAVE_INTTYPES_H'
|
||||
|
||||
@ -25,6 +25,7 @@ import java.io.File
|
||||
import java.nio.charset.StandardCharsets
|
||||
import java.io.InputStream
|
||||
import java.util.*
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
class BaresipService: Service() {
|
||||
|
||||
@ -41,6 +42,7 @@ class BaresipService: Service() {
|
||||
internal var filesPath = ""
|
||||
internal var audioFocusRequest: AudioFocusRequest? = null
|
||||
internal var audioFocused = false
|
||||
internal var origCallVolume = 0
|
||||
|
||||
override fun onCreate() {
|
||||
|
||||
@ -159,11 +161,16 @@ class BaresipService: Service() {
|
||||
contents = "prefer_ipv6 no\n${contents}"
|
||||
write = true
|
||||
}
|
||||
if (!contents.contains("call_volume")) {
|
||||
contents = "${contents}call_volume 0\n"
|
||||
write = true
|
||||
} else {
|
||||
callVolume = Utils.getNameValue(contents, "call_volume")[0].toInt()
|
||||
}
|
||||
if (write) {
|
||||
Log.d(LOG_TAG, "Writing '$contents'")
|
||||
Utils.putFileContents(file, contents)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -428,6 +435,13 @@ class BaresipService: Service() {
|
||||
am.mode = AudioManager.MODE_IN_COMMUNICATION
|
||||
requestAudioFocus(AudioManager.STREAM_VOICE_CALL)
|
||||
}
|
||||
if (callVolume != 0) {
|
||||
origCallVolume = am.getStreamMaxVolume(am.mode)
|
||||
am.setStreamVolume(am.mode,
|
||||
(callVolume * 0.1 * am.getStreamMaxVolume(am.mode)).roundToInt(),
|
||||
0)
|
||||
}
|
||||
Log.d(LOG_TAG, "Call volume of stream ${am.mode} is ${am.getStreamVolume(am.mode)}")
|
||||
}
|
||||
"call verified", "call secure" -> {
|
||||
val call = Call.find(callp)
|
||||
@ -507,6 +521,11 @@ class BaresipService: Service() {
|
||||
}
|
||||
if (Call.calls().size == 0) {
|
||||
abandonAudioFocus()
|
||||
if (origCallVolume != 0) {
|
||||
am.setStreamVolume(am.mode, origCallVolume, 0)
|
||||
origCallVolume = 0
|
||||
}
|
||||
Log.d(LOG_TAG, "Call volume of stream ${am.mode} is ${am.getStreamVolume(am.mode)}")
|
||||
am.mode = AudioManager.MODE_NORMAL
|
||||
if (am.isSpeakerphoneOn) am.isSpeakerphoneOn = false
|
||||
speakerPhone = false
|
||||
@ -786,6 +805,7 @@ class BaresipService: Service() {
|
||||
var libraryLoaded = false
|
||||
var isServiceClean = false
|
||||
var speakerPhone = false
|
||||
var callVolume = 0
|
||||
|
||||
var uas = ArrayList<UserAgent>()
|
||||
var status = ArrayList<Int>()
|
||||
|
||||
@ -28,6 +28,7 @@ class ConfigActivity : AppCompatActivity() {
|
||||
private var oldOpusBitrate = ""
|
||||
private var oldIceMode = ""
|
||||
private var oldLogLevel = ""
|
||||
private var callVolume = BaresipService.callVolume
|
||||
private var save = false
|
||||
private var restart = false
|
||||
private var config = ""
|
||||
@ -72,6 +73,27 @@ class ConfigActivity : AppCompatActivity() {
|
||||
oldIceMode = if (imCv.size == 0) "full" else imCv[0]
|
||||
iceLite.isChecked = oldIceMode == "lite"
|
||||
|
||||
val callVolSpinner = findViewById(R.id.VolumeSpinner) as Spinner
|
||||
val volKeys = arrayListOf("None", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10")
|
||||
val volVals = arrayListOf(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
|
||||
val curVal = callVolume
|
||||
val curKey = volKeys[curVal]
|
||||
volKeys.removeAt(curVal)
|
||||
volVals.removeAt(curVal)
|
||||
volKeys.add(0, curKey)
|
||||
volVals.add(0, curVal)
|
||||
val callVolAdapter = ArrayAdapter<String>(this,android.R.layout.simple_spinner_item,
|
||||
volKeys)
|
||||
callVolAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item)
|
||||
callVolSpinner.adapter = callVolAdapter
|
||||
callVolSpinner.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
|
||||
override fun onItemSelected(parent: AdapterView<*>, view: View, position: Int, id: Long) {
|
||||
callVolume = volVals[volKeys.indexOf(parent.selectedItem.toString())]
|
||||
}
|
||||
override fun onNothingSelected(parent: AdapterView<*>) {
|
||||
}
|
||||
}
|
||||
|
||||
debug = findViewById(R.id.Debug) as CheckBox
|
||||
val dbCv = Utils.getNameValue(config, "log_level")
|
||||
if (dbCv.size == 0)
|
||||
@ -150,6 +172,13 @@ class ConfigActivity : AppCompatActivity() {
|
||||
restart = true
|
||||
}
|
||||
|
||||
if (BaresipService.callVolume != callVolume) {
|
||||
BaresipService.callVolume = callVolume
|
||||
config = Utils.removeLinesStartingWithName(config, "call_volume")
|
||||
config += "\ncall_volume $callVolume\n"
|
||||
save = true
|
||||
}
|
||||
|
||||
var logLevelString = "2"
|
||||
if (debug.isChecked) logLevelString = "0"
|
||||
if (oldLogLevel != logLevelString) {
|
||||
@ -212,6 +241,9 @@ class ConfigActivity : AppCompatActivity() {
|
||||
findViewById(R.id.IceLiteTitle) as TextView-> {
|
||||
Utils.alertView(this, "ICE Lite Mode", getString(R.string.iceLite))
|
||||
}
|
||||
findViewById(R.id.VolumeTitle) as TextView-> {
|
||||
Utils.alertView(this, "Call Volume", getString(R.string.callVolume))
|
||||
}
|
||||
findViewById(R.id.DebugTitle) as TextView-> {
|
||||
Utils.alertView(this, "Debug", getString(R.string.debug))
|
||||
}
|
||||
|
||||
@ -13,12 +13,12 @@
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingRight="16dp"
|
||||
android:paddingTop="16dp"
|
||||
android:paddingBottom="24dp"
|
||||
android:focusableInTouchMode="true" >
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="12dp"
|
||||
android:orientation="horizontal" >
|
||||
<TextView
|
||||
android:id="@+id/AutoStartTitle"
|
||||
@ -45,6 +45,7 @@
|
||||
<RelativeLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="12dp"
|
||||
android:orientation="horizontal" >
|
||||
<TextView
|
||||
android:id="@+id/PreferIPv6Title"
|
||||
@ -73,7 +74,6 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:paddingTop="6dp"
|
||||
android:onClick="onClick"
|
||||
android:text="DNS Servers"
|
||||
android:textColor="@android:color/black"
|
||||
@ -85,12 +85,14 @@
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginBottom="12dp"
|
||||
android:textSize="18sp">
|
||||
</EditText>
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="12dp"
|
||||
android:orientation="horizontal" >
|
||||
<TextView
|
||||
android:id="@+id/OpusBitRateTitle"
|
||||
@ -119,6 +121,7 @@
|
||||
<RelativeLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="12dp"
|
||||
android:orientation="horizontal" >
|
||||
<TextView
|
||||
android:id="@+id/IceLiteTitle"
|
||||
@ -145,6 +148,34 @@
|
||||
<RelativeLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="12dp"
|
||||
android:orientation="horizontal" >
|
||||
<TextView
|
||||
android:id="@+id/VolumeTitle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:textSize="18sp"
|
||||
android:textColor="@android:color/black"
|
||||
android:onClick="onClick"
|
||||
android:text="Default Call Volume" >
|
||||
</TextView>
|
||||
<Spinner
|
||||
android:id="@+id/VolumeSpinner"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_gravity="end"
|
||||
android:popupBackground="@drawable/spinner_background" >
|
||||
</Spinner>
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="12dp"
|
||||
android:orientation="horizontal" >
|
||||
<TextView
|
||||
android:id="@+id/DebugTitle"
|
||||
@ -171,6 +202,7 @@
|
||||
<RelativeLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="12dp"
|
||||
android:orientation="horizontal" >
|
||||
<TextView
|
||||
android:id="@+id/ResetTitle"
|
||||
|
||||
@ -62,6 +62,7 @@
|
||||
<string name="opusBitRate">Average maximum bit rate used by Opus audio stream.
|
||||
Valid value are 6000-510000. Factory default is 28000.</string>
|
||||
<string name="iceLite">If checked, ICE Lite Mode is used.</string>
|
||||
<string name="callVolume">If set, default call audio volume at scale 1-10.</string>
|
||||
<string name="debug">If checked, debug and info level log messages are available in logcat.</string>
|
||||
<string name="reset">If checked, configuration is reset to factory default.</string>
|
||||
</resources>
|
||||
|
||||
1
fastlane/metadata/android/en-US/changelogs/7.1.0.txt
Normal file
1
fastlane/metadata/android/en-US/changelogs/7.1.0.txt
Normal file
@ -0,0 +1 @@
|
||||
- Added 'Default Call Volume' configuration option.
|
||||
Reference in New Issue
Block a user