From d2c4ca4fa91d9496f5b7a5f2dc1c6b66bb52ced8 Mon Sep 17 00:00:00 2001 From: Andreas Eversberg Date: Sun, 1 May 2016 19:51:56 +0200 Subject: Implementation of Advanced Mobile Phone Service (AMPS) --- src/common/call.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++-------- src/common/debug.c | 1 + src/common/debug.h | 11 +++++---- 3 files changed, 65 insertions(+), 15 deletions(-) (limited to 'src/common') diff --git a/src/common/call.c b/src/common/call.c index d49ff1f..e656409 100644 --- a/src/common/call.c +++ b/src/common/call.c @@ -34,17 +34,26 @@ extern int use_mncc_sock; extern int send_patterns; /* stream patterns/announcements */ -int16_t *outoforder_spl = NULL; int16_t *ringback_spl = NULL; +int16_t *hangup_spl = NULL; int16_t *busy_spl = NULL; +int16_t *noanswer_spl = NULL; +int16_t *outoforder_spl = NULL; +int16_t *invalidnumber_spl = NULL; int16_t *congestion_spl = NULL; -int outoforder_size = 0; int ringback_size = 0; +int hangup_size = 0; int busy_size = 0; +int noanswer_size = 0; +int outoforder_size = 0; +int invalidnumber_size = 0; int congestion_size = 0; -int outoforder_max = 0; int ringback_max = 0; +int hangup_max = 0; int busy_max = 0; +int noanswer_max = 0; +int outoforder_max = 0; +int invalidnumber_max = 0; int congestion_max = 0; enum call_state { @@ -59,9 +68,12 @@ enum call_state { enum audio_pattern { PATTERN_NONE = 0, PATTERN_RINGBACK, + PATTERN_HANGUP, PATTERN_BUSY, - PATTERN_CONGESTION, + PATTERN_NOANSWER, PATTERN_OUTOFORDER, + PATTERN_INVALIDNUMBER, + PATTERN_CONGESTION, }; void get_pattern(const int16_t **spl, int *size, int *max, enum audio_pattern pattern) @@ -76,16 +88,26 @@ void get_pattern(const int16_t **spl, int *size, int *max, enum audio_pattern pa *size = ringback_size; *max = ringback_max; break; + case PATTERN_HANGUP: + if (!hangup_spl) + goto no_hangup; + *spl = hangup_spl; + *size = hangup_size; + *max = hangup_max; + break; case PATTERN_BUSY: +no_hangup: +no_noanswer: *spl = busy_spl; *size = busy_size; *max = busy_max; break; - case PATTERN_CONGESTION: -no_outoforder: - *spl = congestion_spl; - *size = congestion_size; - *max = congestion_max; + case PATTERN_NOANSWER: + if (!noanswer_spl) + goto no_noanswer; + *spl = noanswer_spl; + *size = noanswer_size; + *max = noanswer_max; break; case PATTERN_OUTOFORDER: if (!outoforder_spl) @@ -94,6 +116,20 @@ no_outoforder: *size = outoforder_size; *max = outoforder_max; break; + case PATTERN_INVALIDNUMBER: + if (!invalidnumber_spl) + goto no_invalidnumber; + *spl = invalidnumber_spl; + *size = invalidnumber_size; + *max = invalidnumber_max; + break; + case PATTERN_CONGESTION: +no_outoforder: +no_invalidnumber: + *spl = congestion_spl; + *size = congestion_size; + *max = congestion_max; + break; default: ; } @@ -150,14 +186,26 @@ static enum audio_pattern cause2pattern(int cause) int pattern; switch (cause) { + case CAUSE_NORMAL: + pattern = PATTERN_HANGUP; + break; case CAUSE_BUSY: pattern = PATTERN_BUSY; break; + case CAUSE_NOANSWER: + pattern = PATTERN_NOANSWER; + break; case CAUSE_OUTOFORDER: pattern = PATTERN_OUTOFORDER; break; - default: + case CAUSE_INVALNUMBER: + pattern = PATTERN_INVALIDNUMBER; + break; + case CAUSE_NOCHANNEL: pattern = PATTERN_CONGESTION; + break; + default: + pattern = PATTERN_HANGUP; } return pattern; diff --git a/src/common/debug.c b/src/common/debug.c index 61f303c..296b189 100644 --- a/src/common/debug.c +++ b/src/common/debug.c @@ -44,6 +44,7 @@ struct debug_cat { { "bnetz", "\033[1;34m" }, { "cnetz", "\033[1;34m" }, { "nmt", "\033[1;34m" }, + { "amps", "\033[1;34m" }, { "frame", "\033[0;36m" }, { "call", "\033[1;37m" }, { "mncc", "\033[1;32m" }, diff --git a/src/common/debug.h b/src/common/debug.h index 67b020a..a6c07b9 100644 --- a/src/common/debug.h +++ b/src/common/debug.h @@ -11,11 +11,12 @@ #define DBNETZ 4 #define DCNETZ 5 #define DNMT 6 -#define DFRAME 7 -#define DCALL 8 -#define DMNCC 9 -#define DDB 10 -#define DTRANS 11 +#define DAMPS 7 +#define DFRAME 8 +#define DCALL 9 +#define DMNCC 10 +#define DDB 11 +#define DTRANS 12 #define PDEBUG(cat, level, fmt, arg...) _printdebug(__FILE__, __FUNCTION__, __LINE__, cat, level, fmt, ## arg) void _printdebug(const char *file, const char *function, int line, int cat, int level, const char *fmt, ...); -- cgit v1.2.3