Work on informing user when call is held by the peer

This commit is contained in:
Juha Heinanen
2021-12-16 11:02:36 +02:00
parent 07147e80c5
commit f8d3c0060e
7 changed files with 60 additions and 15 deletions

View File

@ -200,6 +200,12 @@ static void ua_event_handler(struct ua *ua, enum ua_event ev,
case UA_EVENT_CALL_ESTABLISHED:
len = re_snprintf(event_buf, sizeof event_buf, "call established");
break;
case UA_EVENT_CALL_REMOTE_SDP:
if (strcmp(prm, "offer") != 0)
return;
ardir = sdp_media_rdir(stream_sdpmedia(audio_strm(call_audio(call))));
len = re_snprintf(event_buf, sizeof event_buf, "call update,%d", ardir);
break;
case UA_EVENT_CALL_MENC:
if (prm[0] == '0')
len = re_snprintf(event_buf, sizeof event_buf, "call secure");

View File

@ -691,6 +691,17 @@ class BaresipService: Service() {
if (!Utils.isVisible())
return
}
"call update" -> {
val call = Call.ofCallp(callp)
if (call == null) {
Log.w("Baresip", "Call $callp that is updated is not found")
return
}
when (ev[1]) {
"0", "1" -> call.held = true
"2", "3" -> call.held = false
}
}
"call verified", "call secure" -> {
val call = Call.ofCallp(callp)
if (call == null) {

View File

@ -7,6 +7,7 @@ class Call(val callp: String, val ua: UserAgent, val peerUri: String, val dir: S
var status: String, val dtmfWatcher: TextWatcher?) {
var onhold = false
var held = false
var security = 0
var zid = ""
var hasHistory = false
@ -24,11 +25,11 @@ class Call(val callp: String, val ua: UserAgent, val peerUri: String, val dir: S
return call_connect(callp, uri)
}
fun startAudio() {
call_start_audio(callp)
fun hold(): Int {
return call_hold(callp, true)
}
fun hold(): Int {
fun isOnHold(): Int {
return call_hold(callp, true)
}

View File

@ -64,6 +64,7 @@ class MainActivity : AppCompatActivity() {
private lateinit var dtmf: EditText
private var dtmfWatcher: TextWatcher? = null
private lateinit var infoButton: ImageButton
private lateinit var onHoldNotice: TextView
private lateinit var uaAdapter: UaSpinnerAdapter
private lateinit var aorSpinner: Spinner
private lateinit var imm: InputMethodManager
@ -140,6 +141,7 @@ class MainActivity : AppCompatActivity() {
transferButton = binding.transferButton
dtmf = binding.dtmf
infoButton = binding.info
onHoldNotice = binding.onHoldNotice
voicemailButton = binding.voicemailButton
contactsButton = binding.contactsButton
messagesButton = binding.messagesButton
@ -943,6 +945,9 @@ class MainActivity : AppCompatActivity() {
showCall(ua)
}
}
"call update" -> {
showCall(ua)
}
"call verify" -> {
val callp = params[1]
val call = Call.ofCallp(callp)
@ -1674,6 +1679,7 @@ class MainActivity : AppCompatActivity() {
BaresipService.isMicMuted = false
micIcon!!.setIcon(R.drawable.mic_on)
}
onHoldNotice.visibility = View.GONE
} else {
swipeRefresh.isEnabled = false
val call = showCall ?: Call.uaCalls(ua, "")[0]
@ -1691,6 +1697,7 @@ class MainActivity : AppCompatActivity() {
answerButton.visibility = View.INVISIBLE
rejectButton.visibility = View.INVISIBLE
callControl.visibility = View.INVISIBLE
onHoldNotice.visibility = View.GONE
dialpadButton.isEnabled = false
}
"incoming" -> {
@ -1706,6 +1713,7 @@ class MainActivity : AppCompatActivity() {
rejectButton.visibility = View.VISIBLE
rejectButton.isEnabled = true
callControl.visibility = View.INVISIBLE
onHoldNotice.visibility = View.GONE
dialpadButton.isEnabled = false
}
"connected" -> {
@ -1756,6 +1764,13 @@ class MainActivity : AppCompatActivity() {
dialpadButton.isEnabled = false
infoButton.isEnabled = true
callControl.visibility = View.VISIBLE
if (call.held) {
imm.hideSoftInputFromWindow(dtmf.windowToken, 0)
onHoldNotice.text = getString(R.string.call_on_hold_by_peer)
onHoldNotice.visibility = View.VISIBLE
} else {
onHoldNotice.visibility = View.GONE
}
}
}
}

View File

@ -214,17 +214,34 @@
</ScrollView>
<TextView
android:id="@+id/onHoldNotice"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@id/buttons"
android:gravity="center"
android:visibility="gone"
android:textSize="18sp"
android:textColor="@color/colorAccent"
android:text="@string/call_on_hold_by_peer" >
</TextView>
<LinearLayout
android:id="@+id/buttons"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="end"
android:layout_alignParentBottom="true" >
<ImageButton
android:id="@+id/voicemailButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@null"
android:src="@drawable/voicemail"
android:layout_toStartOf="@id/contactsButton"
android:layout_marginEnd="10dp"
android:layout_alignParentBottom="true"
android:layout_marginBottom="5dp"
android:visibility="invisible"
android:contentDescription="@string/voicemail" >
</ImageButton>
@ -234,9 +251,7 @@
android:layout_height="wrap_content"
android:background="@null"
android:src="@drawable/contacts"
android:layout_toStartOf="@id/messagesButton"
android:layout_marginEnd="10dp"
android:layout_alignParentBottom="true"
android:layout_marginBottom="5dp"
android:contentDescription="@string/contacts" >
</ImageButton>
@ -247,9 +262,7 @@
android:layout_height="wrap_content"
android:background="@null"
android:src="@drawable/messages"
android:layout_toStartOf="@id/callsButton"
android:layout_marginEnd="10dp"
android:layout_alignParentBottom="true"
android:layout_marginBottom="5dp"
android:contentDescription="@string/messages" >
</ImageButton>
@ -258,9 +271,7 @@
android:id="@+id/callsButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toStartOf="@id/dialpadButton"
android:layout_marginEnd="10dp"
android:layout_alignParentBottom="true"
android:layout_marginBottom="5dp"
android:padding="0dp"
android:background="@null"
@ -273,12 +284,12 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="15dp"
android:layout_alignParentBottom="true"
android:layout_marginBottom="8dp"
android:layout_alignParentEnd="true"
android:background="@null"
android:src="@drawable/dialpad_off"
android:contentDescription="@string/dialpad" >
</ImageButton>
</LinearLayout>
</RelativeLayout>

View File

@ -426,6 +426,7 @@
<string name="call_is_secure">This call is SECURE and peer is VERIFIED!
Do you want to unverify the peer?
</string>
<string name="call_on_hold_by_peer">Call is on hold by peer</string>
<string name="unverify">Unverify</string>
<string name="backed_up">Application data has been backed up to file \'%1$s\'. In Android
versions 9 and below, the file is in Download folder.</string>

View File

@ -1,7 +1,7 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.6.0'
ext.kotlin_version = '1.6.10'
repositories {
google()
mavenCentral()