mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-04 11:58:52 +00:00
Expose tone state and threshold (bug #2830)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@4274 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
57
dsp.c
57
dsp.c
@@ -96,15 +96,6 @@ static struct progress {
|
|||||||
#define TONE_MIN_THRESH 1e8 /* How much tone there should be at least to attempt */
|
#define TONE_MIN_THRESH 1e8 /* How much tone there should be at least to attempt */
|
||||||
#define COUNT_THRESH 3 /* Need at least 50ms of stuff to count it */
|
#define COUNT_THRESH 3 /* Need at least 50ms of stuff to count it */
|
||||||
|
|
||||||
#define TONE_STATE_SILENCE 0
|
|
||||||
#define TONE_STATE_RINGING 1
|
|
||||||
#define TONE_STATE_DIALTONE 2
|
|
||||||
#define TONE_STATE_TALKING 3
|
|
||||||
#define TONE_STATE_BUSY 4
|
|
||||||
#define TONE_STATE_SPECIAL1 5
|
|
||||||
#define TONE_STATE_SPECIAL2 6
|
|
||||||
#define TONE_STATE_SPECIAL3 7
|
|
||||||
|
|
||||||
#define MAX_DTMF_DIGITS 128
|
#define MAX_DTMF_DIGITS 128
|
||||||
|
|
||||||
/* Basic DTMF specs:
|
/* Basic DTMF specs:
|
||||||
@@ -1116,7 +1107,7 @@ static int __ast_dsp_call_progress(struct ast_dsp *dsp, short *s, int len)
|
|||||||
int x;
|
int x;
|
||||||
int y;
|
int y;
|
||||||
int pass;
|
int pass;
|
||||||
int newstate = TONE_STATE_SILENCE;
|
int newstate = DSP_TONE_STATE_SILENCE;
|
||||||
int res = 0;
|
int res = 0;
|
||||||
while(len) {
|
while(len) {
|
||||||
/* Take the lesser of the number of samples we need and what we have */
|
/* Take the lesser of the number of samples we need and what we have */
|
||||||
@@ -1142,31 +1133,31 @@ static int __ast_dsp_call_progress(struct ast_dsp *dsp, short *s, int len)
|
|||||||
switch(dsp->progmode) {
|
switch(dsp->progmode) {
|
||||||
case PROG_MODE_NA:
|
case PROG_MODE_NA:
|
||||||
if (pair_there(hz[HZ_480], hz[HZ_620], hz[HZ_350], hz[HZ_440], dsp->genergy)) {
|
if (pair_there(hz[HZ_480], hz[HZ_620], hz[HZ_350], hz[HZ_440], dsp->genergy)) {
|
||||||
newstate = TONE_STATE_BUSY;
|
newstate = DSP_TONE_STATE_BUSY;
|
||||||
} else if (pair_there(hz[HZ_440], hz[HZ_480], hz[HZ_350], hz[HZ_620], dsp->genergy)) {
|
} else if (pair_there(hz[HZ_440], hz[HZ_480], hz[HZ_350], hz[HZ_620], dsp->genergy)) {
|
||||||
newstate = TONE_STATE_RINGING;
|
newstate = DSP_TONE_STATE_RINGING;
|
||||||
} else if (pair_there(hz[HZ_350], hz[HZ_440], hz[HZ_480], hz[HZ_620], dsp->genergy)) {
|
} else if (pair_there(hz[HZ_350], hz[HZ_440], hz[HZ_480], hz[HZ_620], dsp->genergy)) {
|
||||||
newstate = TONE_STATE_DIALTONE;
|
newstate = DSP_TONE_STATE_DIALTONE;
|
||||||
} else if (hz[HZ_950] > TONE_MIN_THRESH * TONE_THRESH) {
|
} else if (hz[HZ_950] > TONE_MIN_THRESH * TONE_THRESH) {
|
||||||
newstate = TONE_STATE_SPECIAL1;
|
newstate = DSP_TONE_STATE_SPECIAL1;
|
||||||
} else if (hz[HZ_1400] > TONE_MIN_THRESH * TONE_THRESH) {
|
} else if (hz[HZ_1400] > TONE_MIN_THRESH * TONE_THRESH) {
|
||||||
if (dsp->tstate == TONE_STATE_SPECIAL1)
|
if (dsp->tstate == DSP_TONE_STATE_SPECIAL1)
|
||||||
newstate = TONE_STATE_SPECIAL2;
|
newstate = DSP_TONE_STATE_SPECIAL2;
|
||||||
} else if (hz[HZ_1800] > TONE_MIN_THRESH * TONE_THRESH) {
|
} else if (hz[HZ_1800] > TONE_MIN_THRESH * TONE_THRESH) {
|
||||||
if (dsp->tstate == TONE_STATE_SPECIAL2)
|
if (dsp->tstate == DSP_TONE_STATE_SPECIAL2)
|
||||||
newstate = TONE_STATE_SPECIAL3;
|
newstate = DSP_TONE_STATE_SPECIAL3;
|
||||||
} else if (dsp->genergy > TONE_MIN_THRESH * TONE_THRESH) {
|
} else if (dsp->genergy > TONE_MIN_THRESH * TONE_THRESH) {
|
||||||
newstate = TONE_STATE_TALKING;
|
newstate = DSP_TONE_STATE_TALKING;
|
||||||
} else
|
} else
|
||||||
newstate = TONE_STATE_SILENCE;
|
newstate = DSP_TONE_STATE_SILENCE;
|
||||||
break;
|
break;
|
||||||
case PROG_MODE_CR:
|
case PROG_MODE_CR:
|
||||||
if (hz[HZ_425] > TONE_MIN_THRESH * TONE_THRESH) {
|
if (hz[HZ_425] > TONE_MIN_THRESH * TONE_THRESH) {
|
||||||
newstate = TONE_STATE_RINGING;
|
newstate = DSP_TONE_STATE_RINGING;
|
||||||
} else if (dsp->genergy > TONE_MIN_THRESH * TONE_THRESH) {
|
} else if (dsp->genergy > TONE_MIN_THRESH * TONE_THRESH) {
|
||||||
newstate = TONE_STATE_TALKING;
|
newstate = DSP_TONE_STATE_TALKING;
|
||||||
} else
|
} else
|
||||||
newstate = TONE_STATE_SILENCE;
|
newstate = DSP_TONE_STATE_SILENCE;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ast_log(LOG_WARNING, "Can't process in unknown prog mode '%d'\n", dsp->progmode);
|
ast_log(LOG_WARNING, "Can't process in unknown prog mode '%d'\n", dsp->progmode);
|
||||||
@@ -1174,15 +1165,15 @@ static int __ast_dsp_call_progress(struct ast_dsp *dsp, short *s, int len)
|
|||||||
if (newstate == dsp->tstate) {
|
if (newstate == dsp->tstate) {
|
||||||
dsp->tcount++;
|
dsp->tcount++;
|
||||||
if (dsp->tcount == COUNT_THRESH) {
|
if (dsp->tcount == COUNT_THRESH) {
|
||||||
if ((dsp->features & DSP_PROGRESS_BUSY) && dsp->tstate == TONE_STATE_BUSY) {
|
if ((dsp->features & DSP_PROGRESS_BUSY) && dsp->tstate == DSP_TONE_STATE_BUSY) {
|
||||||
res = AST_CONTROL_BUSY;
|
res = AST_CONTROL_BUSY;
|
||||||
dsp->features &= ~DSP_FEATURE_CALL_PROGRESS;
|
dsp->features &= ~DSP_FEATURE_CALL_PROGRESS;
|
||||||
} else if ((dsp->features & DSP_PROGRESS_TALK) && dsp->tstate == TONE_STATE_TALKING) {
|
} else if ((dsp->features & DSP_PROGRESS_TALK) && dsp->tstate == DSP_TONE_STATE_TALKING) {
|
||||||
res = AST_CONTROL_ANSWER;
|
res = AST_CONTROL_ANSWER;
|
||||||
dsp->features &= ~DSP_FEATURE_CALL_PROGRESS;
|
dsp->features &= ~DSP_FEATURE_CALL_PROGRESS;
|
||||||
} else if ((dsp->features & DSP_PROGRESS_RINGING) && dsp->tstate == TONE_STATE_RINGING)
|
} else if ((dsp->features & DSP_PROGRESS_RINGING) && dsp->tstate == DSP_TONE_STATE_RINGING)
|
||||||
res = AST_CONTROL_RINGING;
|
res = AST_CONTROL_RINGING;
|
||||||
else if ((dsp->features & DSP_PROGRESS_CONGESTION) && dsp->tstate == TONE_STATE_SPECIAL3) {
|
else if ((dsp->features & DSP_PROGRESS_CONGESTION) && dsp->tstate == DSP_TONE_STATE_SPECIAL3) {
|
||||||
res = AST_CONTROL_CONGESTION;
|
res = AST_CONTROL_CONGESTION;
|
||||||
dsp->features &= ~DSP_FEATURE_CALL_PROGRESS;
|
dsp->features &= ~DSP_FEATURE_CALL_PROGRESS;
|
||||||
}
|
}
|
||||||
@@ -1743,3 +1734,15 @@ int ast_dsp_set_call_progress_zone(struct ast_dsp *dsp, char *zone)
|
|||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ast_dsp_get_tstate(struct ast_dsp *dsp)
|
||||||
|
{
|
||||||
|
return dsp->tstate;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int ast_dsp_get_tcount(struct ast_dsp *dsp)
|
||||||
|
{
|
||||||
|
return dsp->tcount;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -33,6 +33,15 @@
|
|||||||
#define DSP_PROGRESS_CONGESTION (1 << 19) /* Enable congestion tone detection */
|
#define DSP_PROGRESS_CONGESTION (1 << 19) /* Enable congestion tone detection */
|
||||||
#define DSP_FEATURE_CALL_PROGRESS (DSP_PROGRESS_TALK | DSP_PROGRESS_RINGING | DSP_PROGRESS_BUSY | DSP_PROGRESS_CONGESTION)
|
#define DSP_FEATURE_CALL_PROGRESS (DSP_PROGRESS_TALK | DSP_PROGRESS_RINGING | DSP_PROGRESS_BUSY | DSP_PROGRESS_CONGESTION)
|
||||||
|
|
||||||
|
#define DSP_TONE_STATE_SILENCE 0
|
||||||
|
#define DSP_TONE_STATE_RINGING 1
|
||||||
|
#define DSP_TONE_STATE_DIALTONE 2
|
||||||
|
#define DSP_TONE_STATE_TALKING 3
|
||||||
|
#define DSP_TONE_STATE_BUSY 4
|
||||||
|
#define DSP_TONE_STATE_SPECIAL1 5
|
||||||
|
#define DSP_TONE_STATE_SPECIAL2 6
|
||||||
|
#define DSP_TONE_STATE_SPECIAL3 7
|
||||||
|
|
||||||
struct ast_dsp;
|
struct ast_dsp;
|
||||||
|
|
||||||
struct ast_dsp *ast_dsp_new(void);
|
struct ast_dsp *ast_dsp_new(void);
|
||||||
@@ -79,4 +88,9 @@ int ast_dsp_getdigits(struct ast_dsp *dsp, char *buf, int max);
|
|||||||
/* Set digit mode */
|
/* Set digit mode */
|
||||||
int ast_dsp_digitmode(struct ast_dsp *dsp, int digitmode);
|
int ast_dsp_digitmode(struct ast_dsp *dsp, int digitmode);
|
||||||
|
|
||||||
|
/* Get tstate (Tone State) */
|
||||||
|
int ast_dsp_get_tstate(struct ast_dsp *dsp);
|
||||||
|
|
||||||
|
/* Get tcount (Threshold counter) */
|
||||||
|
int ast_dsp_get_tcount(struct ast_dsp *dsp);
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user