summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorMatt O'Gorman <mogorman@digium.com>2006-02-14 23:30:18 +0000
committerMatt O'Gorman <mogorman@digium.com>2006-02-14 23:30:18 +0000
commit49a04b91a20de5f020f44fdbacad66e0eed66613 (patch)
treed855bd8301e485fe20303a2c5168cf07f15cfc47 /apps
parent6081d770c3a2391f6cb1b7ce0cb9255bddf11ca2 (diff)
changed naming scheme for variables so it matches
asterisk standard, changed it so it can take frames of sizes other than 20ms, allowed for the app to reload properly, and finalyl changed sample to general section as to follow standards. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@10086 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'apps')
-rw-r--r--apps/app_amd.c42
1 files changed, 22 insertions, 20 deletions
diff --git a/apps/app_amd.c b/apps/app_amd.c
index 6ae81bd75..5f84955bf 100644
--- a/apps/app_amd.c
+++ b/apps/app_amd.c
@@ -60,14 +60,14 @@ static char *descrip =
"This application sets the following channel variable upon completion:\n"
" AMDSTATUS - This is the status of the answering machine detection.\n"
" Possible values are:\n"
-" AMD_MACHINE | AMD_PERSON | AMD_NOTSURE | AMD_HANGUP\n"
+" AMDMACHINE | AMDPERSON | AMDNOTSURE | AMDHANGUP\n"
" AMDCAUSE - Indicates the cause that led to the conclusion.\n"
" Possible values are:\n"
-" AMD_TOOLONG-<%d total_time>\n"
-" AMD_INITIALSILENCE-<%d silenceDuration>-<%d initialSilence>\n"
-" AMD_HUMAN-<%d silenceDuration>-<%d afterGreetingSilence>\n"
-" AMD_MAXWORDS-<%d wordsCount>-<%d maximumNumberOfWords>\n"
-" AMD_LONGGREETING-<%d voiceDuration>-<%d greeting>\n";
+" AMDTOOLONG-<%d total_time>\n"
+" AMDINITIALSILENCE-<%d silenceDuration>-<%d initialSilence>\n"
+" AMDHUMAN-<%d silenceDuration>-<%d afterGreetingSilence>\n"
+" AMDMAXWORDS-<%d wordsCount>-<%d maximumNumberOfWords>\n"
+" AMDLONGGREETING-<%d voiceDuration>-<%d greeting>\n";
STANDARD_LOCAL_USER;
@@ -96,6 +96,7 @@ static void isAnsweringMachine(struct ast_channel *chan, void *data)
struct ast_dsp *silenceDetector; /* silence detector dsp */
int dspsilence = 0;
int readFormat;
+ int framelength;
int inInitialSilence = 1;
int inGreeting = 0;
@@ -208,16 +209,17 @@ static void isAnsweringMachine(struct ast_channel *chan, void *data)
/* No Frame: Called Party Must Have Dropped */
ast_verbose(VERBOSE_PREFIX_3 "AMD: HANGUP\n");
ast_log(LOG_DEBUG, "Got hangup\n");
- strcpy(amdStatus , "AMD_HANGUP" );
+ strcpy(amdStatus , "AMDHANGUP" );
strcpy(amdCause , "" );
break;
}
- iTotalTime += 20;
+ framelength = (ast_codec_get_samples(f) / 8);
+ iTotalTime += framelength;
if (iTotalTime >= totalAnalysisTime ) {
ast_verbose(VERBOSE_PREFIX_3 "AMD: Channel [%s]. Too long...\n", chan->name );
ast_frfree(f);
- strcpy(amdStatus , "AMD_NOTSURE" );
- sprintf(amdCause , "AMD_TOOLONG-%d", iTotalTime );
+ strcpy(amdStatus , "AMDNOTSURE" );
+ sprintf(amdCause , "AMDTOOLONG-%d", iTotalTime );
break;
}
if (f->frametype == AST_FRAME_VOICE ) {
@@ -238,8 +240,8 @@ static void isAnsweringMachine(struct ast_channel *chan, void *data)
ast_verbose(VERBOSE_PREFIX_3 "AMD: ANSWERING MACHINE: silenceDuration:%d initialSilence:%d\n",
silenceDuration, initialSilence );
ast_frfree(f);
- strcpy(amdStatus , "AMD_MACHINE" );
- sprintf(amdCause , "AMD_INITIALSILENCE-%d-%d", silenceDuration, initialSilence );
+ strcpy(amdStatus , "AMDMACHINE" );
+ sprintf(amdCause , "AMDINITIALSILENCE-%d-%d", silenceDuration, initialSilence );
break;
}
@@ -247,13 +249,13 @@ static void isAnsweringMachine(struct ast_channel *chan, void *data)
ast_verbose(VERBOSE_PREFIX_3 "AMD: HUMAN: silenceDuration:%d afterGreetingSilence:%d\n",
silenceDuration, afterGreetingSilence );
ast_frfree(f);
- strcpy(amdStatus , "AMD_PERSON" );
- sprintf(amdCause , "AMD_HUMAN-%d-%d", silenceDuration, afterGreetingSilence );
+ strcpy(amdStatus , "AMDPERSON" );
+ sprintf(amdCause , "AMDHUMAN-%d-%d", silenceDuration, afterGreetingSilence );
break;
}
} else {
- consecutiveVoiceDuration += 20;
- voiceDuration += 20;
+ consecutiveVoiceDuration += framelength;
+ voiceDuration += framelength;
/* ast_verbose(VERBOSE_PREFIX_3 "AMD: %d VOICE: ConsecutiveVoice:%d voiceDuration:%d inGreeting:%d\n", currentState, consecutiveVoiceDuration, voiceDuration, inGreeting ); */
/* If I have enough consecutive voice to say that I am in a Word, I can only increment the
@@ -270,8 +272,8 @@ static void isAnsweringMachine(struct ast_channel *chan, void *data)
if (iWordsCount >= maximumNumberOfWords ) {
ast_verbose(VERBOSE_PREFIX_3 "AMD: ANSWERING MACHINE: iWordsCount:%d\n", iWordsCount );
ast_frfree(f);
- strcpy(amdStatus , "AMD_MACHINE" );
- sprintf(amdCause , "AMD_MAXWORDS-%d-%d", iWordsCount, maximumNumberOfWords );
+ strcpy(amdStatus , "AMDMACHINE" );
+ sprintf(amdCause , "AMDMAXWORDS-%d-%d", iWordsCount, maximumNumberOfWords );
break;
}
@@ -279,8 +281,8 @@ static void isAnsweringMachine(struct ast_channel *chan, void *data)
ast_verbose(VERBOSE_PREFIX_3 "AMD: ANSWERING MACHINE: voiceDuration:%d greeting:%d\n",
voiceDuration, greeting );
ast_frfree(f);
- strcpy(amdStatus , "AMD_MACHINE" );
- sprintf(amdCause , "AMD_LONGGREETING-%d-%d", voiceDuration, greeting );
+ strcpy(amdStatus , "AMDMACHINE" );
+ sprintf(amdCause , "AMDLONGGREETING-%d-%d", voiceDuration, greeting );
break;
}
if (voiceDuration >= minimumWordLength ) {