- Added 'Default Call Volume' configuration option.
This commit is contained in:
+2
-2
@@ -8,8 +8,8 @@ android {
|
|||||||
applicationId = 'com.tutpro.baresip'
|
applicationId = 'com.tutpro.baresip'
|
||||||
minSdkVersion 21
|
minSdkVersion 21
|
||||||
targetSdkVersion 28
|
targetSdkVersion 28
|
||||||
versionCode = 55
|
versionCode = 56
|
||||||
versionName = '7.0.0'
|
versionName = '7.1.0'
|
||||||
externalNativeBuild {
|
externalNativeBuild {
|
||||||
cmake {
|
cmake {
|
||||||
cFlags '-DHAVE_INTTYPES_H'
|
cFlags '-DHAVE_INTTYPES_H'
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import java.io.File
|
|||||||
import java.nio.charset.StandardCharsets
|
import java.nio.charset.StandardCharsets
|
||||||
import java.io.InputStream
|
import java.io.InputStream
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
import kotlin.math.roundToInt
|
||||||
|
|
||||||
class BaresipService: Service() {
|
class BaresipService: Service() {
|
||||||
|
|
||||||
@@ -41,6 +42,7 @@ class BaresipService: Service() {
|
|||||||
internal var filesPath = ""
|
internal var filesPath = ""
|
||||||
internal var audioFocusRequest: AudioFocusRequest? = null
|
internal var audioFocusRequest: AudioFocusRequest? = null
|
||||||
internal var audioFocused = false
|
internal var audioFocused = false
|
||||||
|
internal var origCallVolume = 0
|
||||||
|
|
||||||
override fun onCreate() {
|
override fun onCreate() {
|
||||||
|
|
||||||
@@ -159,11 +161,16 @@ class BaresipService: Service() {
|
|||||||
contents = "prefer_ipv6 no\n${contents}"
|
contents = "prefer_ipv6 no\n${contents}"
|
||||||
write = true
|
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) {
|
if (write) {
|
||||||
Log.d(LOG_TAG, "Writing '$contents'")
|
Log.d(LOG_TAG, "Writing '$contents'")
|
||||||
Utils.putFileContents(file, contents)
|
Utils.putFileContents(file, contents)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -428,6 +435,13 @@ class BaresipService: Service() {
|
|||||||
am.mode = AudioManager.MODE_IN_COMMUNICATION
|
am.mode = AudioManager.MODE_IN_COMMUNICATION
|
||||||
requestAudioFocus(AudioManager.STREAM_VOICE_CALL)
|
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" -> {
|
"call verified", "call secure" -> {
|
||||||
val call = Call.find(callp)
|
val call = Call.find(callp)
|
||||||
@@ -507,6 +521,11 @@ class BaresipService: Service() {
|
|||||||
}
|
}
|
||||||
if (Call.calls().size == 0) {
|
if (Call.calls().size == 0) {
|
||||||
abandonAudioFocus()
|
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
|
am.mode = AudioManager.MODE_NORMAL
|
||||||
if (am.isSpeakerphoneOn) am.isSpeakerphoneOn = false
|
if (am.isSpeakerphoneOn) am.isSpeakerphoneOn = false
|
||||||
speakerPhone = false
|
speakerPhone = false
|
||||||
@@ -786,6 +805,7 @@ class BaresipService: Service() {
|
|||||||
var libraryLoaded = false
|
var libraryLoaded = false
|
||||||
var isServiceClean = false
|
var isServiceClean = false
|
||||||
var speakerPhone = false
|
var speakerPhone = false
|
||||||
|
var callVolume = 0
|
||||||
|
|
||||||
var uas = ArrayList<UserAgent>()
|
var uas = ArrayList<UserAgent>()
|
||||||
var status = ArrayList<Int>()
|
var status = ArrayList<Int>()
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ class ConfigActivity : AppCompatActivity() {
|
|||||||
private var oldOpusBitrate = ""
|
private var oldOpusBitrate = ""
|
||||||
private var oldIceMode = ""
|
private var oldIceMode = ""
|
||||||
private var oldLogLevel = ""
|
private var oldLogLevel = ""
|
||||||
|
private var callVolume = BaresipService.callVolume
|
||||||
private var save = false
|
private var save = false
|
||||||
private var restart = false
|
private var restart = false
|
||||||
private var config = ""
|
private var config = ""
|
||||||
@@ -72,6 +73,27 @@ class ConfigActivity : AppCompatActivity() {
|
|||||||
oldIceMode = if (imCv.size == 0) "full" else imCv[0]
|
oldIceMode = if (imCv.size == 0) "full" else imCv[0]
|
||||||
iceLite.isChecked = oldIceMode == "lite"
|
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
|
debug = findViewById(R.id.Debug) as CheckBox
|
||||||
val dbCv = Utils.getNameValue(config, "log_level")
|
val dbCv = Utils.getNameValue(config, "log_level")
|
||||||
if (dbCv.size == 0)
|
if (dbCv.size == 0)
|
||||||
@@ -150,6 +172,13 @@ class ConfigActivity : AppCompatActivity() {
|
|||||||
restart = true
|
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"
|
var logLevelString = "2"
|
||||||
if (debug.isChecked) logLevelString = "0"
|
if (debug.isChecked) logLevelString = "0"
|
||||||
if (oldLogLevel != logLevelString) {
|
if (oldLogLevel != logLevelString) {
|
||||||
@@ -212,6 +241,9 @@ class ConfigActivity : AppCompatActivity() {
|
|||||||
findViewById(R.id.IceLiteTitle) as TextView-> {
|
findViewById(R.id.IceLiteTitle) as TextView-> {
|
||||||
Utils.alertView(this, "ICE Lite Mode", getString(R.string.iceLite))
|
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-> {
|
findViewById(R.id.DebugTitle) as TextView-> {
|
||||||
Utils.alertView(this, "Debug", getString(R.string.debug))
|
Utils.alertView(this, "Debug", getString(R.string.debug))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,12 +13,12 @@
|
|||||||
android:paddingLeft="16dp"
|
android:paddingLeft="16dp"
|
||||||
android:paddingRight="16dp"
|
android:paddingRight="16dp"
|
||||||
android:paddingTop="16dp"
|
android:paddingTop="16dp"
|
||||||
android:paddingBottom="24dp"
|
|
||||||
android:focusableInTouchMode="true" >
|
android:focusableInTouchMode="true" >
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
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:orientation="horizontal" >
|
android:orientation="horizontal" >
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/AutoStartTitle"
|
android:id="@+id/AutoStartTitle"
|
||||||
@@ -45,6 +45,7 @@
|
|||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
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:orientation="horizontal" >
|
android:orientation="horizontal" >
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/PreferIPv6Title"
|
android:id="@+id/PreferIPv6Title"
|
||||||
@@ -73,7 +74,6 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_centerVertical="true"
|
android:layout_centerVertical="true"
|
||||||
android:paddingTop="6dp"
|
|
||||||
android:onClick="onClick"
|
android:onClick="onClick"
|
||||||
android:text="DNS Servers"
|
android:text="DNS Servers"
|
||||||
android:textColor="@android:color/black"
|
android:textColor="@android:color/black"
|
||||||
@@ -85,12 +85,14 @@
|
|||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_centerVertical="true"
|
android:layout_centerVertical="true"
|
||||||
|
android:layout_marginBottom="12dp"
|
||||||
android:textSize="18sp">
|
android:textSize="18sp">
|
||||||
</EditText>
|
</EditText>
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
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:orientation="horizontal" >
|
android:orientation="horizontal" >
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/OpusBitRateTitle"
|
android:id="@+id/OpusBitRateTitle"
|
||||||
@@ -119,6 +121,7 @@
|
|||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
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:orientation="horizontal" >
|
android:orientation="horizontal" >
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/IceLiteTitle"
|
android:id="@+id/IceLiteTitle"
|
||||||
@@ -145,6 +148,34 @@
|
|||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
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: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" >
|
android:orientation="horizontal" >
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/DebugTitle"
|
android:id="@+id/DebugTitle"
|
||||||
@@ -171,6 +202,7 @@
|
|||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
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:orientation="horizontal" >
|
android:orientation="horizontal" >
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/ResetTitle"
|
android:id="@+id/ResetTitle"
|
||||||
|
|||||||
@@ -62,6 +62,7 @@
|
|||||||
<string name="opusBitRate">Average maximum bit rate used by Opus audio stream.
|
<string name="opusBitRate">Average maximum bit rate used by Opus audio stream.
|
||||||
Valid value are 6000-510000. Factory default is 28000.</string>
|
Valid value are 6000-510000. Factory default is 28000.</string>
|
||||||
<string name="iceLite">If checked, ICE Lite Mode is used.</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="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>
|
<string name="reset">If checked, configuration is reset to factory default.</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
- Added 'Default Call Volume' configuration option.
|
||||||
Reference in New Issue
Block a user