Main Page | Alphabetical List | Data Structures | File List | Data Fields | Globals

dsp.c File Reference

#include <sys/types.h>
#include <asterisk/frame.h>
#include <asterisk/channel.h>
#include <asterisk/channel_pvt.h>
#include <asterisk/logger.h>
#include <asterisk/dsp.h>
#include <asterisk/ulaw.h>
#include <asterisk/alaw.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <math.h>
#include <errno.h>
#include <stdio.h>

Include dependency graph for dsp.c:

Include dependency graph

Go to the source code of this file.

Data Structures

struct  progalias
struct  progress
struct  goertzel_state_t
struct  dtmf_detect_state_t
struct  mf_detect_state_t
struct  ast_dsp

Defines

#define GSAMP_SIZE_NA   183 /* North America - 350, 440, 480, 620, 950, 1400, 1800 Hz */
#define GSAMP_SIZE_CR   188 /* Costa Rica - Only care about 425 Hz */
#define PROG_MODE_NA   0
#define PROG_MODE_CR   1
#define HZ_350   0
#define HZ_440   1
#define HZ_480   2
#define HZ_620   3
#define HZ_950   4
#define HZ_1400   5
#define HZ_1800   6
#define HZ_425   0
#define DEFAULT_THRESHOLD   1024
#define BUSY_PERCENT   10 /* The percentage diffrence between the two last silence periods */
#define BUSY_THRESHOLD   100 /* Max number of ms difference between max and min times in busy */
#define BUSY_MIN   75 /* Busy must be at least 80 ms in half-cadence */
#define BUSY_MAX   1100 /* Busy can't be longer than 1100 ms in half-cadence */
#define DSP_HISTORY   15
#define FAX_DETECT
#define TONE_THRESH   10.0 /* How much louder the tone should be than channel energy */
#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 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 DTMF_THRESHOLD   8.0e7
#define FAX_THRESHOLD   8.0e7
#define FAX_2ND_HARMONIC   2.0 /* 4dB */
#define DTMF_NORMAL_TWIST   6.3 /* 8dB */
#define DTMF_REVERSE_TWIST   ((digitmode & DSP_DIGITMODE_RELAXDTMF) ? 4.0 : 2.5) /* 4dB normal */
#define DTMF_RELATIVE_PEAK_ROW   6.3 /* 8dB */
#define DTMF_RELATIVE_PEAK_COL   6.3 /* 8dB */
#define DTMF_2ND_HARMONIC_ROW   ((digitmode & DSP_DIGITMODE_RELAXDTMF) ? 1.7 : 2.5) /* 4dB normal */
#define DTMF_2ND_HARMONIC_COL   63.1 /* 18dB */
#define DTMF_TO_TOTAL_ENERGY   42.0
#define BELL_MF_THRESHOLD   1.6e9
#define BELL_MF_TWIST   4.0 /* 6dB */
#define BELL_MF_RELATIVE_PEAK   12.6 /* 11dB */
#define MF_GSIZE   120
#define FIX_INF(inf)

Functions

int ast_dsp_digitdetect (struct ast_dsp *dsp, struct ast_frame *inf)
int ast_dsp_getdigits (struct ast_dsp *dsp, char *buf, int max)
int ast_dsp_call_progress (struct ast_dsp *dsp, struct ast_frame *inf)
int ast_dsp_silence (struct ast_dsp *dsp, struct ast_frame *f, int *totalsilence)
ast_frameast_dsp_process (struct ast_channel *chan, struct ast_dsp *dsp, struct ast_frame *af)
ast_dspast_dsp_new (void)
void ast_dsp_set_features (struct ast_dsp *dsp, int features)
void ast_dsp_free (struct ast_dsp *dsp)
void ast_dsp_set_threshold (struct ast_dsp *dsp, int threshold)
void ast_dsp_set_busy_count (struct ast_dsp *dsp, int cadences)
void ast_dsp_digitreset (struct ast_dsp *dsp)
void ast_dsp_reset (struct ast_dsp *dsp)
int ast_dsp_digitmode (struct ast_dsp *dsp, int digitmode)
int ast_dsp_set_call_progress_zone (struct ast_dsp *dsp, char *zone)


Define Documentation

#define BELL_MF_RELATIVE_PEAK   12.6 /* 11dB */
 

Definition at line 148 of file dsp.c.

#define BELL_MF_THRESHOLD   1.6e9
 

Definition at line 146 of file dsp.c.

#define BELL_MF_TWIST   4.0 /* 6dB */
 

Definition at line 147 of file dsp.c.

#define BUSY_MAX   1100 /* Busy can't be longer than 1100 ms in half-cadence */
 

Definition at line 87 of file dsp.c.

#define BUSY_MIN   75 /* Busy must be at least 80 ms in half-cadence */
 

Definition at line 86 of file dsp.c.

#define BUSY_PERCENT   10 /* The percentage diffrence between the two last silence periods */
 

Definition at line 84 of file dsp.c.

#define BUSY_THRESHOLD   100 /* Max number of ms difference between max and min times in busy */
 

Definition at line 85 of file dsp.c.

#define COUNT_THRESH   3 /* Need at least 50ms of stuff to count it */
 

Definition at line 97 of file dsp.c.

#define DEFAULT_THRESHOLD   1024
 

Definition at line 82 of file dsp.c.

Referenced by ast_dsp_new().

#define DSP_HISTORY   15
 

Definition at line 90 of file dsp.c.

Referenced by ast_dsp_new(), and ast_dsp_set_busy_count().

#define DTMF_2ND_HARMONIC_COL   63.1 /* 18dB */
 

Definition at line 134 of file dsp.c.

#define DTMF_2ND_HARMONIC_ROW   ((digitmode & DSP_DIGITMODE_RELAXDTMF) ? 1.7 : 2.5) /* 4dB normal */
 

Definition at line 133 of file dsp.c.

#define DTMF_NORMAL_TWIST   6.3 /* 8dB */
 

Definition at line 125 of file dsp.c.

#define DTMF_RELATIVE_PEAK_COL   6.3 /* 8dB */
 

Definition at line 132 of file dsp.c.

#define DTMF_RELATIVE_PEAK_ROW   6.3 /* 8dB */
 

Definition at line 131 of file dsp.c.

#define DTMF_REVERSE_TWIST   ((digitmode & DSP_DIGITMODE_RELAXDTMF) ? 4.0 : 2.5) /* 4dB normal */
 

Definition at line 129 of file dsp.c.

#define DTMF_THRESHOLD   8.0e7
 

Definition at line 122 of file dsp.c.

#define DTMF_TO_TOTAL_ENERGY   42.0
 

Definition at line 136 of file dsp.c.

#define FAX_2ND_HARMONIC   2.0 /* 4dB */
 

Definition at line 124 of file dsp.c.

#define FAX_DETECT
 

Definition at line 93 of file dsp.c.

#define FAX_THRESHOLD   8.0e7
 

Definition at line 123 of file dsp.c.

#define FIX_INF inf   ) 
 

Referenced by ast_dsp_process().

#define GSAMP_SIZE_CR   188 /* Costa Rica - Only care about 425 Hz */
 

Definition at line 48 of file dsp.c.

#define GSAMP_SIZE_NA   183 /* North America - 350, 440, 480, 620, 950, 1400, 1800 Hz */
 

Definition at line 47 of file dsp.c.

#define HZ_1400   5
 

Definition at line 59 of file dsp.c.

#define HZ_1800   6
 

Definition at line 60 of file dsp.c.

#define HZ_350   0
 

Definition at line 54 of file dsp.c.

#define HZ_425   0
 

Definition at line 63 of file dsp.c.

#define HZ_440   1
 

Definition at line 55 of file dsp.c.

#define HZ_480   2
 

Definition at line 56 of file dsp.c.

#define HZ_620   3
 

Definition at line 57 of file dsp.c.

#define HZ_950   4
 

Definition at line 58 of file dsp.c.

#define MAX_DTMF_DIGITS   128
 

Definition at line 108 of file dsp.c.

#define MF_GSIZE   120
 

Definition at line 708 of file dsp.c.

#define PROG_MODE_CR   1
 

Definition at line 51 of file dsp.c.

#define PROG_MODE_NA   0
 

Definition at line 50 of file dsp.c.

#define TONE_MIN_THRESH   1e8 /* How much tone there should be at least to attempt */
 

Definition at line 96 of file dsp.c.

#define TONE_STATE_BUSY   4
 

Definition at line 103 of file dsp.c.

#define TONE_STATE_DIALTONE   2
 

Definition at line 101 of file dsp.c.

#define TONE_STATE_RINGING   1
 

Definition at line 100 of file dsp.c.

#define TONE_STATE_SILENCE   0
 

Definition at line 99 of file dsp.c.

#define TONE_STATE_SPECIAL1   5
 

Definition at line 104 of file dsp.c.

#define TONE_STATE_SPECIAL2   6
 

Definition at line 105 of file dsp.c.

#define TONE_STATE_SPECIAL3   7
 

Definition at line 106 of file dsp.c.

#define TONE_STATE_TALKING   3
 

Definition at line 102 of file dsp.c.

#define TONE_THRESH   10.0 /* How much louder the tone should be than channel energy */
 

Definition at line 95 of file dsp.c.


Function Documentation

int ast_dsp_call_progress struct ast_dsp dsp,
struct ast_frame inf
 

Definition at line 1215 of file dsp.c.

References AST_FORMAT_SLINEAR, AST_FRAME_VOICE, ast_log(), ast_frame::data, ast_frame::datalen, ast_frame::frametype, LOG_WARNING, and ast_frame::subclass.

01216 { 01217 if (inf->frametype != AST_FRAME_VOICE) { 01218 ast_log(LOG_WARNING, "Can't check call progress of non-voice frames\n"); 01219 return 0; 01220 } 01221 if (inf->subclass != AST_FORMAT_SLINEAR) { 01222 ast_log(LOG_WARNING, "Can only check call progress in signed-linear frames\n"); 01223 return 0; 01224 } 01225 return __ast_dsp_call_progress(dsp, inf->data, inf->datalen / 2); 01226 }

int ast_dsp_digitdetect struct ast_dsp dsp,
struct ast_frame inf
 

Definition at line 1049 of file dsp.c.

References AST_FORMAT_SLINEAR, AST_FRAME_VOICE, ast_log(), ast_frame::data, ast_frame::datalen, ast_frame::frametype, LOG_WARNING, s, and ast_frame::subclass.

01050 { 01051 short *s; 01052 int len; 01053 int ign=0; 01054 if (inf->frametype != AST_FRAME_VOICE) { 01055 ast_log(LOG_WARNING, "Can't check call progress of non-voice frames\n"); 01056 return 0; 01057 } 01058 if (inf->subclass != AST_FORMAT_SLINEAR) { 01059 ast_log(LOG_WARNING, "Can only check call progress in signed-linear frames\n"); 01060 return 0; 01061 } 01062 s = inf->data; 01063 len = inf->datalen / 2; 01064 return __ast_dsp_digitdetect(dsp, s, len, &ign); 01065 }

int ast_dsp_digitmode struct ast_dsp dsp,
int  digitmode
 

Definition at line 1716 of file dsp.c.

References ast_dsp::digitmode, DSP_DIGITMODE_DTMF, DSP_DIGITMODE_MF, DSP_DIGITMODE_MUTECONF, DSP_DIGITMODE_MUTEMAX, and ast_dsp::td.

01717 { 01718 int new, old; 01719 old = dsp->digitmode & (DSP_DIGITMODE_DTMF | DSP_DIGITMODE_MF | DSP_DIGITMODE_MUTECONF | DSP_DIGITMODE_MUTEMAX); 01720 new = digitmode & (DSP_DIGITMODE_DTMF | DSP_DIGITMODE_MF | DSP_DIGITMODE_MUTECONF | DSP_DIGITMODE_MUTEMAX); 01721 if (old != new) { 01722 /* Must initialize structures if switching from MF to DTMF or vice-versa */ 01723 if (new & DSP_DIGITMODE_MF) 01724 ast_mf_detect_init(&dsp->td.mf); 01725 else 01726 ast_dtmf_detect_init(&dsp->td.dtmf); 01727 } 01728 dsp->digitmode = digitmode; 01729 return 0; 01730 }

void ast_dsp_digitreset struct ast_dsp dsp  ) 
 

Definition at line 1655 of file dsp.c.

References ast_dsp::digitmode, DSP_DIGITMODE_MF, ast_dsp::td, and ast_dsp::thinkdigit.

01656 { 01657 int i; 01658 dsp->thinkdigit = 0; 01659 if (dsp->digitmode & DSP_DIGITMODE_MF) { 01660 memset(dsp->td.mf.digits, 0, sizeof(dsp->td.mf.digits)); 01661 dsp->td.mf.current_digits = 0; 01662 /* Reinitialise the detector for the next block */ 01663 for (i = 0; i < 6; i++) { 01664 goertzel_reset(&dsp->td.mf.tone_out[i]); 01665 #ifdef OLD_DSP_ROUTINES 01666 goertzel_reset(&dsp->td.mf.tone_out2nd[i]); 01667 #endif 01668 } 01669 #ifdef OLD_DSP_ROUTINES 01670 dsp->td.mf.energy = 0.0; 01671 dsp->td.mf.hit1 = dsp->td.mf.hit2 = dsp->td.mf.hit3 = dsp->td.mf.hit4 = dsp->td.mf.mhit = 0; 01672 #else 01673 dsp->td.mf.hits[4] = dsp->td.mf.hits[3] = dsp->td.mf.hits[2] = dsp->td.mf.hits[1] = dsp->td.mf.hits[0] = dsp->td.mf.mhit = 0; 01674 #endif 01675 dsp->td.mf.current_sample = 0; 01676 } else { 01677 memset(dsp->td.dtmf.digits, 0, sizeof(dsp->td.dtmf.digits)); 01678 dsp->td.dtmf.current_digits = 0; 01679 /* Reinitialise the detector for the next block */ 01680 for (i = 0; i < 4; i++) { 01681 goertzel_reset(&dsp->td.dtmf.row_out[i]); 01682 goertzel_reset(&dsp->td.dtmf.col_out[i]); 01683 #ifdef OLD_DSP_ROUTINES 01684 goertzel_reset(&dsp->td.dtmf.row_out2nd[i]); 01685 goertzel_reset(&dsp->td.dtmf.col_out2nd[i]); 01686 #endif 01687 } 01688 #ifdef FAX_DETECT 01689 goertzel_reset (&dsp->td.dtmf.fax_tone); 01690 #endif 01691 #ifdef OLD_DSP_ROUTINES 01692 #ifdef FAX_DETECT 01693 goertzel_reset (&dsp->td.dtmf.fax_tone2nd); 01694 #endif 01695 dsp->td.dtmf.hit1 = dsp->td.dtmf.hit2 = dsp->td.dtmf.hit3 = dsp->td.dtmf.hit4 = dsp->td.dtmf.mhit = 0; 01696 #else 01697 dsp->td.dtmf.hits[2] = dsp->td.dtmf.hits[1] = dsp->td.dtmf.hits[0] = dsp->td.dtmf.mhit = 0; 01698 #endif 01699 dsp->td.dtmf.energy = 0.0; 01700 dsp->td.dtmf.current_sample = 0; 01701 } 01702 }

void ast_dsp_free struct ast_dsp dsp  ) 
 

Definition at line 1636 of file dsp.c.

References free.

Referenced by ast_app_getvoice().

01637 { 01638 free(dsp); 01639 }

int ast_dsp_getdigits struct ast_dsp dsp,
char *  buf,
int  max
 

Definition at line 1087 of file dsp.c.

References ast_dsp::digitmode, DSP_DIGITMODE_MF, and ast_dsp::td.

01090 { 01091 if (dsp->digitmode & DSP_DIGITMODE_MF) { 01092 if (max > dsp->td.mf.current_digits) 01093 max = dsp->td.mf.current_digits; 01094 if (max > 0) 01095 { 01096 memcpy (buf, dsp->td.mf.digits, max); 01097 memmove (dsp->td.mf.digits, dsp->td.mf.digits + max, dsp->td.mf.current_digits - max); 01098 dsp->td.mf.current_digits -= max; 01099 } 01100 buf[max] = '\0'; 01101 return max; 01102 } else { 01103 if (max > dsp->td.dtmf.current_digits) 01104 max = dsp->td.dtmf.current_digits; 01105 if (max > 0) 01106 { 01107 memcpy (buf, dsp->td.dtmf.digits, max); 01108 memmove (dsp->td.dtmf.digits, dsp->td.dtmf.digits + max, dsp->td.dtmf.current_digits - max); 01109 dsp->td.dtmf.current_digits -= max; 01110 } 01111 buf[max] = '\0'; 01112 return max; 01113 } 01114 }

struct ast_dsp* ast_dsp_new void   ) 
 

Definition at line 1614 of file dsp.c.

References ast_dsp::busycount, DEFAULT_THRESHOLD, DSP_FEATURE_SILENCE_SUPPRESS, DSP_HISTORY, ast_dsp::features, malloc, ast_dsp::td, and ast_dsp::threshold.

Referenced by ast_app_getvoice().

01615 { 01616 struct ast_dsp *dsp; 01617 dsp = malloc(sizeof(struct ast_dsp)); 01618 if (dsp) { 01619 memset(dsp, 0, sizeof(struct ast_dsp)); 01620 dsp->threshold = DEFAULT_THRESHOLD; 01621 dsp->features = DSP_FEATURE_SILENCE_SUPPRESS; 01622 dsp->busycount = DSP_HISTORY; 01623 /* Initialize DTMF detector */ 01624 ast_dtmf_detect_init(&dsp->td.dtmf); 01625 /* Initialize initial DSP progress detect parameters */ 01626 ast_dsp_prog_reset(dsp); 01627 } 01628 return dsp; 01629 }

struct ast_frame* ast_dsp_process struct ast_channel chan,
struct ast_dsp dsp,
struct ast_frame af
 

Definition at line 1408 of file dsp.c.

References ast_channel::_softhangup, AST_ALAW, AST_CONTROL_ANSWER, AST_CONTROL_BUSY, AST_CONTROL_CONGESTION, AST_CONTROL_RINGING, ast_dsp_busydetect(), AST_FORMAT_ALAW, AST_FORMAT_SLINEAR, AST_FORMAT_ULAW, AST_FRAME_CONTROL, AST_FRAME_DTMF, AST_FRAME_NULL, AST_FRAME_VOICE, ast_frfree(), ast_log(), AST_MULAW, ast_queue_frame(), AST_SOFTHANGUP_DEV, ast_frame::data, ast_frame::datalen, ast_dsp::digitmode, DSP_DIGITMODE_MF, DSP_DIGITMODE_MUTECONF, DSP_DIGITMODE_MUTEMAX, DSP_FEATURE_BUSY_DETECT, DSP_FEATURE_CALL_PROGRESS, DSP_FEATURE_DTMF_DETECT, DSP_FEATURE_SILENCE_SUPPRESS, ast_dsp::f, ast_dsp::features, FIX_INF, ast_frame::frametype, LOG_DEBUG, LOG_WARNING, ast_channel::name, ast_frame::subclass, ast_dsp::td, and ast_dsp::thinkdigit.

01409 { 01410 int silence; 01411 int res; 01412 int digit; 01413 int x; 01414 unsigned short *shortdata; 01415 unsigned char *odata; 01416 int len; 01417 int writeback = 0; 01418 01419 #define FIX_INF(inf) do { \ 01420 if (writeback) { \ 01421 switch(inf->subclass) { \ 01422 case AST_FORMAT_SLINEAR: \ 01423 break; \ 01424 case AST_FORMAT_ULAW: \ 01425 for (x=0;x<len;x++) \ 01426 odata[x] = AST_LIN2MU(shortdata[x]); \ 01427 break; \ 01428 case AST_FORMAT_ALAW: \ 01429 for (x=0;x<len;x++) \ 01430 odata[x] = AST_LIN2A(shortdata[x]); \ 01431 break; \ 01432 } \ 01433 } \ 01434 } while(0) 01435 01436 if (!af) 01437 return NULL; 01438 if (af->frametype != AST_FRAME_VOICE) 01439 return af; 01440 odata = af->data; 01441 len = af->datalen; 01442 /* Make sure we have short data */ 01443 switch(af->subclass) { 01444 case AST_FORMAT_SLINEAR: 01445 shortdata = af->data; 01446 len = af->datalen / 2; 01447 break; 01448 case AST_FORMAT_ULAW: 01449 shortdata = alloca(af->datalen * 2); 01450 if (!shortdata) { 01451 ast_log(LOG_WARNING, "Unable to allocate stack space for data: %s\n", strerror(errno)); 01452 return af; 01453 } 01454 for (x=0;x<len;x++) 01455 shortdata[x] = AST_MULAW(odata[x]); 01456 break; 01457 case AST_FORMAT_ALAW: 01458 shortdata = alloca(af->datalen * 2); 01459 if (!shortdata) { 01460 ast_log(LOG_WARNING, "Unable to allocate stack space for data: %s\n", strerror(errno)); 01461 return af; 01462 } 01463 for (x=0;x<len;x++) 01464 shortdata[x] = AST_ALAW(odata[x]); 01465 break; 01466 default: 01467 ast_log(LOG_WARNING, "Unable to process inband DTMF on %d frames\n", af->subclass); 01468 return af; 01469 } 01470 silence = __ast_dsp_silence(dsp, shortdata, len, NULL); 01471 if ((dsp->features & DSP_FEATURE_SILENCE_SUPPRESS) && silence) { 01472 memset(&dsp->f, 0, sizeof(dsp->f)); 01473 dsp->f.frametype = AST_FRAME_NULL; 01474 return &dsp->f; 01475 } 01476 if ((dsp->features & DSP_FEATURE_BUSY_DETECT) && ast_dsp_busydetect(dsp)) { 01477 chan->_softhangup |= AST_SOFTHANGUP_DEV; 01478 memset(&dsp->f, 0, sizeof(dsp->f)); 01479 dsp->f.frametype = AST_FRAME_CONTROL; 01480 dsp->f.subclass = AST_CONTROL_BUSY; 01481 ast_log(LOG_DEBUG, "Requesting Hangup because the busy tone was detected on channel %s\n", chan->name); 01482 return &dsp->f; 01483 } 01484 if ((dsp->features & DSP_FEATURE_DTMF_DETECT)) { 01485 digit = __ast_dsp_digitdetect(dsp, shortdata, len, &writeback); 01486 #if 0 01487 if (digit) 01488 printf("Performing digit detection returned %d, digitmode is %d\n", digit, dsp->digitmode); 01489 #endif 01490 if (dsp->digitmode & (DSP_DIGITMODE_MUTECONF | DSP_DIGITMODE_MUTEMAX)) { 01491 if (!dsp->thinkdigit) { 01492 if (digit) { 01493 /* Looks like we might have something. Request a conference mute for the moment */ 01494 memset(&dsp->f, 0, sizeof(dsp->f)); 01495 dsp->f.frametype = AST_FRAME_DTMF; 01496 dsp->f.subclass = 'm'; 01497 dsp->thinkdigit = 'x'; 01498 FIX_INF(af); 01499 if (chan) 01500 ast_queue_frame(chan, af); 01501 ast_frfree(af); 01502 return &dsp->f; 01503 } 01504 } else { 01505 if (digit) { 01506 /* Thought we saw one last time. Pretty sure we really have now */ 01507 if (dsp->thinkdigit) { 01508 if ((dsp->thinkdigit != 'x') && (dsp->thinkdigit != digit)) { 01509 /* If we found a digit, and we're changing digits, go 01510 ahead and send this one, but DON'T stop confmute because 01511 we're detecting something else, too... */ 01512 memset(&dsp->f, 0, sizeof(dsp->f)); 01513 dsp->f.frametype = AST_FRAME_DTMF; 01514 dsp->f.subclass = dsp->thinkdigit; 01515 FIX_INF(af); 01516 if (chan) 01517 ast_queue_frame(chan, af); 01518 ast_frfree(af); 01519 } 01520 dsp->thinkdigit = digit; 01521 return &dsp->f; 01522 } 01523 dsp->thinkdigit = digit; 01524 } else { 01525 if (dsp->thinkdigit) { 01526 memset(&dsp->f, 0, sizeof(dsp->f)); 01527 if (dsp->thinkdigit != 'x') { 01528 /* If we found a digit, send it now */ 01529 dsp->f.frametype = AST_FRAME_DTMF; 01530 dsp->f.subclass = dsp->thinkdigit; 01531 dsp->thinkdigit = 0; 01532 } else { 01533 dsp->f.frametype = AST_FRAME_DTMF; 01534 dsp->f.subclass = 'u'; 01535 dsp->thinkdigit = 0; 01536 } 01537 FIX_INF(af); 01538 if (chan) 01539 ast_queue_frame(chan, af); 01540 ast_frfree(af); 01541 return &dsp->f; 01542 } 01543 } 01544 } 01545 } else if (!digit) { 01546 /* Only check when there is *not* a hit... */ 01547 if (dsp->digitmode & DSP_DIGITMODE_MF) { 01548 if (dsp->td.mf.current_digits) { 01549 memset(&dsp->f, 0, sizeof(dsp->f)); 01550 dsp->f.frametype = AST_FRAME_DTMF; 01551 dsp->f.subclass = dsp->td.mf.digits[0]; 01552 memmove(dsp->td.mf.digits, dsp->td.mf.digits + 1, dsp->td.mf.current_digits); 01553 dsp->td.mf.current_digits--; 01554 FIX_INF(af); 01555 if (chan) 01556 ast_queue_frame(chan, af); 01557 ast_frfree(af); 01558 return &dsp->f; 01559 } 01560 } else { 01561 if (dsp->td.dtmf.current_digits) { 01562 memset(&dsp->f, 0, sizeof(dsp->f)); 01563 dsp->f.frametype = AST_FRAME_DTMF; 01564 dsp->f.subclass = dsp->td.dtmf.digits[0]; 01565 memmove(dsp->td.dtmf.digits, dsp->td.dtmf.digits + 1, dsp->td.dtmf.current_digits); 01566 dsp->td.dtmf.current_digits--; 01567 FIX_INF(af); 01568 if (chan) 01569 ast_queue_frame(chan, af); 01570 ast_frfree(af); 01571 return &dsp->f; 01572 } 01573 } 01574 } 01575 } 01576 if ((dsp->features & DSP_FEATURE_CALL_PROGRESS)) { 01577 res = __ast_dsp_call_progress(dsp, shortdata, len); 01578 memset(&dsp->f, 0, sizeof(dsp->f)); 01579 dsp->f.frametype = AST_FRAME_CONTROL; 01580 if (res) { 01581 switch(res) { 01582 case AST_CONTROL_ANSWER: 01583 case AST_CONTROL_BUSY: 01584 case AST_CONTROL_RINGING: 01585 case AST_CONTROL_CONGESTION: 01586 dsp->f.subclass = res; 01587 if (chan) 01588 ast_queue_frame(chan, &dsp->f); 01589 break; 01590 default: 01591 ast_log(LOG_WARNING, "Don't know how to represent call progress message %d\n", res); 01592 } 01593 } 01594 } 01595 FIX_INF(af); 01596 return af; 01597 }

void ast_dsp_reset struct ast_dsp dsp  ) 
 

Definition at line 1704 of file dsp.c.

References ast_dsp::freqs, ast_dsp::gsamps, ast_dsp::historicnoise, ast_dsp::historicsilence, ast_dsp::totalsilence, goertzel_state_t::v2, and goertzel_state_t::v3.

01705 { 01706 int x; 01707 dsp->totalsilence = 0; 01708 dsp->gsamps = 0; 01709 for (x=0;x<4;x++) 01710 dsp->freqs[x].v2 = dsp->freqs[x].v3 = 0.0; 01711 memset(dsp->historicsilence, 0, sizeof(dsp->historicsilence)); 01712 memset(dsp->historicnoise, 0, sizeof(dsp->historicnoise)); 01713 01714 }

void ast_dsp_set_busy_count struct ast_dsp dsp,
int  cadences
 

Definition at line 1646 of file dsp.c.

References ast_dsp::busycount, and DSP_HISTORY.

01647 { 01648 if (cadences < 4) 01649 cadences = 4; 01650 if (cadences > DSP_HISTORY) 01651 cadences = DSP_HISTORY; 01652 dsp->busycount = cadences; 01653 }

int ast_dsp_set_call_progress_zone struct ast_dsp dsp,
char *  zone
 

Definition at line 1732 of file dsp.c.

References ast_dsp::progmode.

01733 { 01734 int x; 01735 for (x=0;x<sizeof(aliases) / sizeof(aliases[0]);x++) { 01736 if (!strcasecmp(aliases[x].name, zone)) { 01737 dsp->progmode = aliases[x].mode; 01738 ast_dsp_prog_reset(dsp); 01739 return 0; 01740 } 01741 } 01742 return -1; 01743 }

void ast_dsp_set_features struct ast_dsp dsp,
int  features
 

Definition at line 1631 of file dsp.c.

References ast_dsp::features.

01632 { 01633 dsp->features = features; 01634 }

void ast_dsp_set_threshold struct ast_dsp dsp,
int  threshold
 

Definition at line 1641 of file dsp.c.

References ast_dsp::threshold.

01642 { 01643 dsp->threshold = threshold; 01644 }

int ast_dsp_silence struct ast_dsp dsp,
struct ast_frame f,
int *  totalsilence
 

Definition at line 1390 of file dsp.c.

References AST_FORMAT_SLINEAR, AST_FRAME_VOICE, ast_log(), ast_frame::data, ast_frame::datalen, ast_frame::frametype, LOG_WARNING, s, and ast_frame::subclass.

Referenced by ast_app_getvoice().

01391 { 01392 short *s; 01393 int len; 01394 01395 if (f->frametype != AST_FRAME_VOICE) { 01396 ast_log(LOG_WARNING, "Can't calculate silence on a non-voice frame\n"); 01397 return 0; 01398 } 01399 if (f->subclass != AST_FORMAT_SLINEAR) { 01400 ast_log(LOG_WARNING, "Can only calculate silence on signed-linear frames :(\n"); 01401 return 0; 01402 } 01403 s = f->data; 01404 len = f->datalen/2; 01405 return __ast_dsp_silence(dsp, s, len, totalsilence); 01406 }


Generated on Sat Jun 12 16:41:31 2004 for Asterisk by doxygen 1.3.7