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
1.4
Matt O'Gorman 19 years ago
parent 6081d770c3
commit 49a04b91a2

@ -60,14 +60,14 @@ static char *descrip =
"This application sets the following channel variable upon completion:\n" "This application sets the following channel variable upon completion:\n"
" AMDSTATUS - This is the status of the answering machine detection.\n" " AMDSTATUS - This is the status of the answering machine detection.\n"
" Possible values are:\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" " AMDCAUSE - Indicates the cause that led to the conclusion.\n"
" Possible values are:\n" " Possible values are:\n"
" AMD_TOOLONG-<%d total_time>\n" " AMDTOOLONG-<%d total_time>\n"
" AMD_INITIALSILENCE-<%d silenceDuration>-<%d initialSilence>\n" " AMDINITIALSILENCE-<%d silenceDuration>-<%d initialSilence>\n"
" AMD_HUMAN-<%d silenceDuration>-<%d afterGreetingSilence>\n" " AMDHUMAN-<%d silenceDuration>-<%d afterGreetingSilence>\n"
" AMD_MAXWORDS-<%d wordsCount>-<%d maximumNumberOfWords>\n" " AMDMAXWORDS-<%d wordsCount>-<%d maximumNumberOfWords>\n"
" AMD_LONGGREETING-<%d voiceDuration>-<%d greeting>\n"; " AMDLONGGREETING-<%d voiceDuration>-<%d greeting>\n";
STANDARD_LOCAL_USER; STANDARD_LOCAL_USER;
@ -96,6 +96,7 @@ static void isAnsweringMachine(struct ast_channel *chan, void *data)
struct ast_dsp *silenceDetector; /* silence detector dsp */ struct ast_dsp *silenceDetector; /* silence detector dsp */
int dspsilence = 0; int dspsilence = 0;
int readFormat; int readFormat;
int framelength;
int inInitialSilence = 1; int inInitialSilence = 1;
int inGreeting = 0; int inGreeting = 0;
@ -208,16 +209,17 @@ static void isAnsweringMachine(struct ast_channel *chan, void *data)
/* No Frame: Called Party Must Have Dropped */ /* No Frame: Called Party Must Have Dropped */
ast_verbose(VERBOSE_PREFIX_3 "AMD: HANGUP\n"); ast_verbose(VERBOSE_PREFIX_3 "AMD: HANGUP\n");
ast_log(LOG_DEBUG, "Got hangup\n"); ast_log(LOG_DEBUG, "Got hangup\n");
strcpy(amdStatus , "AMD_HANGUP" ); strcpy(amdStatus , "AMDHANGUP" );
strcpy(amdCause , "" ); strcpy(amdCause , "" );
break; break;
} }
iTotalTime += 20; framelength = (ast_codec_get_samples(f) / 8);
iTotalTime += framelength;
if (iTotalTime >= totalAnalysisTime ) { if (iTotalTime >= totalAnalysisTime ) {
ast_verbose(VERBOSE_PREFIX_3 "AMD: Channel [%s]. Too long...\n", chan->name ); ast_verbose(VERBOSE_PREFIX_3 "AMD: Channel [%s]. Too long...\n", chan->name );
ast_frfree(f); ast_frfree(f);
strcpy(amdStatus , "AMD_NOTSURE" ); strcpy(amdStatus , "AMDNOTSURE" );
sprintf(amdCause , "AMD_TOOLONG-%d", iTotalTime ); sprintf(amdCause , "AMDTOOLONG-%d", iTotalTime );
break; break;
} }
if (f->frametype == AST_FRAME_VOICE ) { 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", ast_verbose(VERBOSE_PREFIX_3 "AMD: ANSWERING MACHINE: silenceDuration:%d initialSilence:%d\n",
silenceDuration, initialSilence ); silenceDuration, initialSilence );
ast_frfree(f); ast_frfree(f);
strcpy(amdStatus , "AMD_MACHINE" ); strcpy(amdStatus , "AMDMACHINE" );
sprintf(amdCause , "AMD_INITIALSILENCE-%d-%d", silenceDuration, initialSilence ); sprintf(amdCause , "AMDINITIALSILENCE-%d-%d", silenceDuration, initialSilence );
break; 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", ast_verbose(VERBOSE_PREFIX_3 "AMD: HUMAN: silenceDuration:%d afterGreetingSilence:%d\n",
silenceDuration, afterGreetingSilence ); silenceDuration, afterGreetingSilence );
ast_frfree(f); ast_frfree(f);
strcpy(amdStatus , "AMD_PERSON" ); strcpy(amdStatus , "AMDPERSON" );
sprintf(amdCause , "AMD_HUMAN-%d-%d", silenceDuration, afterGreetingSilence ); sprintf(amdCause , "AMDHUMAN-%d-%d", silenceDuration, afterGreetingSilence );
break; break;
} }
} else { } else {
consecutiveVoiceDuration += 20; consecutiveVoiceDuration += framelength;
voiceDuration += 20; voiceDuration += framelength;
/* ast_verbose(VERBOSE_PREFIX_3 "AMD: %d VOICE: ConsecutiveVoice:%d voiceDuration:%d inGreeting:%d\n", currentState, consecutiveVoiceDuration, voiceDuration, inGreeting ); */ /* 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 /* 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 ) { if (iWordsCount >= maximumNumberOfWords ) {
ast_verbose(VERBOSE_PREFIX_3 "AMD: ANSWERING MACHINE: iWordsCount:%d\n", iWordsCount ); ast_verbose(VERBOSE_PREFIX_3 "AMD: ANSWERING MACHINE: iWordsCount:%d\n", iWordsCount );
ast_frfree(f); ast_frfree(f);
strcpy(amdStatus , "AMD_MACHINE" ); strcpy(amdStatus , "AMDMACHINE" );
sprintf(amdCause , "AMD_MAXWORDS-%d-%d", iWordsCount, maximumNumberOfWords ); sprintf(amdCause , "AMDMAXWORDS-%d-%d", iWordsCount, maximumNumberOfWords );
break; 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", ast_verbose(VERBOSE_PREFIX_3 "AMD: ANSWERING MACHINE: voiceDuration:%d greeting:%d\n",
voiceDuration, greeting ); voiceDuration, greeting );
ast_frfree(f); ast_frfree(f);
strcpy(amdStatus , "AMD_MACHINE" ); strcpy(amdStatus , "AMDMACHINE" );
sprintf(amdCause , "AMD_LONGGREETING-%d-%d", voiceDuration, greeting ); sprintf(amdCause , "AMDLONGGREETING-%d-%d", voiceDuration, greeting );
break; break;
} }
if (voiceDuration >= minimumWordLength ) { if (voiceDuration >= minimumWordLength ) {

@ -12,7 +12,7 @@
; If exceeded then MACHINE ; If exceeded then MACHINE
[AnsweringMachineDetector] [general]
initial_silence = 2500 initial_silence = 2500
greeting = 1500 greeting = 1500
after_greeting_silence = 300 after_greeting_silence = 300

Loading…
Cancel
Save