From b1ea4e574f3d76c28de0c79ce253d5d9634c00cf Mon Sep 17 00:00:00 2001 From: Andreas Eversberg Date: Sun, 12 Jan 2020 16:45:16 +0100 Subject: [PATCH] Add option to allow early audio towards call interface --- src/libmobile/call.c | 20 +++++++++++++------- src/libmobile/call.h | 1 + src/libmobile/main_mobile.c | 2 +- src/libmobile/main_mobile.h | 1 + 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/libmobile/call.c b/src/libmobile/call.c index 1338f9d..6d12b30 100644 --- a/src/libmobile/call.c +++ b/src/libmobile/call.c @@ -51,7 +51,7 @@ static double level_of(double *samples, int count) } #endif -static int send_patterns; /* send patterns towards fixed network */ +static int connect_on_setup; /* send patterns towards fixed network */ static int release_on_disconnect; /* release towards mobile phone, if MNCC call disconnects, don't send disconnect tone */ /* stream patterns/announcements */ @@ -353,7 +353,7 @@ static void process_timeout(struct timer *timer) int call_init(int _send_patterns, int _release_on_disconnect) { - send_patterns = _send_patterns; + connect_on_setup = _send_patterns; release_on_disconnect = _release_on_disconnect; return 0; @@ -439,12 +439,18 @@ void call_up_alerting(int callref) PDEBUG(DCALL, DEBUG_INFO, "Call is alerting\n"); - if (!send_patterns) + if (!connect_on_setup) _indicate_alerting(callref); set_pattern_process(callref, PATTERN_RINGBACK); new_state_process(callref, PROCESS_ALERTING_RT); } +/* Transceiver indicates early audio */ +void call_up_early(int callref) +{ + set_pattern_process(callref, PATTERN_NONE); +} + /* Transceiver indicates answer. */ static void _indicate_answer(int callref, const char *connect_id) { @@ -477,7 +483,7 @@ void call_up_answer(int callref, const char *connect_id) PDEBUG(DCALL, DEBUG_INFO, "Call has been answered by '%s'\n", connect_id); - if (!send_patterns) + if (!connect_on_setup) _indicate_answer(callref, connect_id); set_pattern_process(callref, PATTERN_NONE); new_state_process(callref, PROCESS_CONNECT); @@ -517,7 +523,7 @@ void call_up_release(int callref, int cause) if (process) { /* just keep MNCC connection if tones shall be sent. * no tones while setting up / alerting the call. */ - if (send_patterns + if (connect_on_setup && process->state != PROCESS_SETUP_RO && process->state != PROCESS_ALERTING_RO) disconnect_process(callref, cause); @@ -721,7 +727,7 @@ void mncc_down(uint8_t *buf, int length) rc = call_down_setup(callref, caller_id, caller_type, number); if (rc < 0) { PDEBUG(DCALL, DEBUG_NOTICE, "Call rejected, cause %d\n", -rc); - if (send_patterns) { + if (connect_on_setup) { PDEBUG(DCALL, DEBUG_DEBUG, "Early connecting after setup\n"); _indicate_answer(callref, number); } else { @@ -732,7 +738,7 @@ void mncc_down(uint8_t *buf, int length) break; } - if (send_patterns) { + if (connect_on_setup) { PDEBUG(DCALL, DEBUG_DEBUG, "Early connecting after setup\n"); _indicate_answer(callref, number); break; diff --git a/src/libmobile/call.h b/src/libmobile/call.h index f87051d..5537042 100644 --- a/src/libmobile/call.h +++ b/src/libmobile/call.h @@ -21,6 +21,7 @@ void mncc_flush(void); /* received messages */ int call_up_setup(int callref, const char *callerid, const char *dialing); void call_up_alerting(int callref); +void call_up_early(int callref); void call_up_answer(int callref, const char *connect_id); void call_up_release(int callref, int cause); void call_tone_recall(int callref, int on); diff --git a/src/libmobile/main_mobile.c b/src/libmobile/main_mobile.c index 6b26e4e..ac3ac61 100644 --- a/src/libmobile/main_mobile.c +++ b/src/libmobile/main_mobile.c @@ -67,7 +67,7 @@ static int echo_test = 0; static int use_mncc_sock = 0; static int use_mncc_cross = 0; const char *mncc_name = ""; -static int send_patterns = 1; +int send_patterns = 1; static int release_on_disconnect = 1; int loopback = 0; int rt_prio = 1; diff --git a/src/libmobile/main_mobile.h b/src/libmobile/main_mobile.h index 954b2d2..9742f6d 100644 --- a/src/libmobile/main_mobile.h +++ b/src/libmobile/main_mobile.h @@ -12,6 +12,7 @@ extern int uses_emphasis; extern int do_pre_emphasis; extern int do_de_emphasis; extern double rx_gain; +extern int send_patterns; extern int loopback; extern int rt_prio; extern int fast_math;