Add calling party DTMF (bug #3994)

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@5445 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Mark Spencer
2005-04-11 02:46:25 +00:00
parent 16661cc58f
commit 922d62c39d

View File

@@ -92,8 +92,9 @@ static char *descrip =
" 'G(context^exten^pri)' -- If the call is answered transfer both parties to the specified exten.\n" " 'G(context^exten^pri)' -- If the call is answered transfer both parties to the specified exten.\n"
" 'A(x)' -- play an announcement to the called party, using x as file\n" " 'A(x)' -- play an announcement to the called party, using x as file\n"
" 'S(x)' -- hangup the call after x seconds AFTER called party picked up\n" " 'S(x)' -- hangup the call after x seconds AFTER called party picked up\n"
" 'D([digits])' -- Send DTMF digit string *after* called party has answered\n" " 'D([called][:calling])' -- Send DTMF strings *after* called party has answered, but before the\n"
" but before the bridge. (w=500ms sec pause)\n" " call gets bridged. The 'called' DTMF string is sent to the called party, and the\n"
" 'calling' DTMF string is sent to the calling party. Both parameters can be used alone.\n"
" 'L(x[:y][:z])' -- Limit the call to 'x' ms warning when 'y' ms are left\n" " 'L(x[:y][:z])' -- Limit the call to 'x' ms warning when 'y' ms are left\n"
" repeated every 'z' ms) Only 'x' is required, 'y' and 'z' are optional.\n" " repeated every 'z' ms) Only 'x' is required, 'y' and 'z' are optional.\n"
" The following special variables are optional:\n" " The following special variables are optional:\n"
@@ -630,7 +631,7 @@ static int dial_exec_full(struct ast_channel *chan, void *data, struct ast_flags
char *limitptr; char *limitptr;
char limitdata[256]; char limitdata[256];
char *sdtmfptr; char *sdtmfptr;
char sdtmfdata[256] = ""; char *dtmfcalled=NULL, *dtmfcalling=NULL;
char *stack,*var; char *stack,*var;
char *mac = NULL, *macroname = NULL; char *mac = NULL, *macroname = NULL;
char status[256]=""; char status[256]="";
@@ -698,22 +699,26 @@ static int dial_exec_full(struct ast_channel *chan, void *data, struct ast_flags
ast_verbose(VERBOSE_PREFIX_3 "Setting call duration limit to %i seconds.\n",calldurationlimit); ast_verbose(VERBOSE_PREFIX_3 "Setting call duration limit to %i seconds.\n",calldurationlimit);
} }
/* DTMF SCRIPT*/ /* Extract DTMF strings to send upon successfull connect */
if ((sdtmfptr = strstr(transfer, "D("))) { if ((sdtmfptr = strstr(transfer, "D("))) {
strncpy(sdtmfdata, sdtmfptr + 2, sizeof(sdtmfdata) - 1); dtmfcalled = ast_strdupa(sdtmfptr + 2);
dtmfcalling = strchr(dtmfcalled, ')');
if (dtmfcalling)
*dtmfcalling = '\0';
dtmfcalling = strchr(dtmfcalled, ':');
if (dtmfcalling) {
*dtmfcalling = '\0';
dtmfcalling++;
}
/* Overwrite with X's what was the sdtmf info */ /* Overwrite with X's what was the sdtmf info */
while (*sdtmfptr && (*sdtmfptr != ')')) while (*sdtmfptr && (*sdtmfptr != ')'))
*(sdtmfptr++) = 'X'; *(sdtmfptr++) = 'X';
if (*sdtmfptr) if (*sdtmfptr)
*sdtmfptr = 'X'; *sdtmfptr = 'X';
/* Now find the end */
sdtmfptr = strchr(sdtmfdata, ')');
if (sdtmfptr)
*sdtmfptr = '\0';
else else
ast_log(LOG_WARNING, "D( Data lacking trailing ')'\n"); ast_log(LOG_WARNING, "D( Data lacking trailing ')'\n");
} }
/* XXX LIMIT SUPPORT */ /* XXX LIMIT SUPPORT */
if ((limitptr = strstr(transfer, "L("))) { if ((limitptr = strstr(transfer, "L("))) {
strncpy(limitdata, limitptr + 2, sizeof(limitdata) - 1); strncpy(limitdata, limitptr + 2, sizeof(limitdata) - 1);
@@ -1259,8 +1264,16 @@ static int dial_exec_full(struct ast_channel *chan, void *data, struct ast_flags
time(&now); time(&now);
chan->whentohangup = now + calldurationlimit; chan->whentohangup = now + calldurationlimit;
} }
if (!ast_strlen_zero(sdtmfdata)) if (dtmfcalled && !ast_strlen_zero(dtmfcalled)) {
res = ast_dtmf_stream(peer,chan,sdtmfdata,250); if (option_verbose > 2)
ast_verbose(VERBOSE_PREFIX_3 "Sending DTMF '%s' to the called party.\n",dtmfcalled);
res = ast_dtmf_stream(peer,chan,dtmfcalled,250);
}
if (dtmfcalling && !ast_strlen_zero(dtmfcalling)) {
if (option_verbose > 2)
ast_verbose(VERBOSE_PREFIX_3 "Sending DTMF '%s' to the calling party.\n",dtmfcalling);
res = ast_dtmf_stream(chan,peer,dtmfcalling,250);
}
} }
if (!res) { if (!res) {