added possibility to hold/unhold calls
This commit is contained in:
@ -429,13 +429,32 @@ Java_com_tutpro_baresip_MainActivity_ua_1answer(JNIEnv *env, jobject thiz,
|
||||
const char *native_ua = (*env)->GetStringUTFChars(env, javaUA, 0);
|
||||
const char *native_call = (*env)->GetStringUTFChars(env, javaCall, 0);
|
||||
LOGD("answering call %s/%s\n", native_ua, native_call);
|
||||
struct ua *ua = (struct ua *)strtoul(native_ua, NULL, 10);
|
||||
struct call *call = (struct call *)strtoul(native_call, NULL, 10);
|
||||
struct ua *ua = (struct ua *) strtoul(native_ua, NULL, 10);
|
||||
struct call *call = (struct call *) strtoul(native_call, NULL, 10);
|
||||
ua_answer(ua, call);
|
||||
(*env)->ReleaseStringUTFChars(env, javaUA, native_ua);
|
||||
(*env)->ReleaseStringUTFChars(env, javaCall, native_call);
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_com_tutpro_baresip_MainActivity_call_1hold(JNIEnv *env, jobject thiz,
|
||||
jstring javaCall) {
|
||||
const char *native_call = (*env)->GetStringUTFChars(env, javaCall, 0);
|
||||
LOGD("holding call %s\n", native_call);
|
||||
int res = call_hold(ua_call(uag_current()), true);
|
||||
(*env)->ReleaseStringUTFChars(env, javaCall, native_call);
|
||||
return res;
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_com_tutpro_baresip_MainActivity_call_1unhold(JNIEnv *env, jobject thiz,
|
||||
jstring javaCall) {
|
||||
const char *native_call = (*env)->GetStringUTFChars(env, javaCall, 0);
|
||||
LOGD("holding call %s\n", native_call);
|
||||
int res = call_hold(ua_call(uag_current()), false);
|
||||
(*env)->ReleaseStringUTFChars(env, javaCall, native_call);
|
||||
return res;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
|
||||
@ -269,14 +269,6 @@ public class MainActivity extends AppCompatActivity {
|
||||
}
|
||||
}
|
||||
|
||||
public ArrayList<String> aorStatusList() {
|
||||
ArrayList<String> res = new ArrayList<>();
|
||||
for (Account a : Accounts) {
|
||||
res.add(a.getAoR() + " (" + a.getStatus() + ")");
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
public void addAccount(String ua) {
|
||||
String aor = ua_aor(ua);
|
||||
Log.d("Baresip", "Adding account " + ua + " with AoR " + aor);
|
||||
@ -363,7 +355,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
Button answer_button = (Button)layout.findViewById(answer_id);
|
||||
answer_button.setText("Hangup");
|
||||
Button reject_button = (Button)layout.findViewById(answer_id + 1);
|
||||
reject_button.setEnabled(false);
|
||||
reject_button.setText("Hold");
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -396,9 +388,21 @@ public class MainActivity extends AppCompatActivity {
|
||||
reject_button.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Log.i("Baresip", "UA " + call.getUA() +
|
||||
" rejecting incoming call " + call.getCall());
|
||||
ua_hangup(call.getUA(), call.getCall(), 486, "Rejected");
|
||||
switch (((Button)v).getText().toString()) {
|
||||
case "Reject":
|
||||
Log.i("Baresip", "UA " + call.getUA() +
|
||||
" rejecting incoming call " + call.getCall());
|
||||
ua_hangup(call.getUA(), call.getCall(), 486, "Rejected");
|
||||
break;
|
||||
case "Hold":
|
||||
call_hold(call.getCall());
|
||||
((Button)v).setText("Unhold");
|
||||
break;
|
||||
case "Unhold":
|
||||
call_unhold(call.getCall());
|
||||
((Button)v).setText("Hold");
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
LayoutParams reject_button_params = new LayoutParams(200,
|
||||
@ -565,6 +569,8 @@ public class MainActivity extends AppCompatActivity {
|
||||
public static native void ua_current_set(String s);
|
||||
public native String ua_connect(String s);
|
||||
public native void ua_answer(String ua, String call);
|
||||
public native Integer call_hold(String call);
|
||||
public native Integer call_unhold(String call);
|
||||
public native void ua_hangup(String ua, String call, int code, String reason);
|
||||
static public native void contacts_remove();
|
||||
static public native void contact_add(String contact);
|
||||
|
||||
Reference in New Issue
Block a user