[Asterisk-Users] [PATCH] allow announcements in app_dial
Brancaleoni Matteo
mbrancaleoni at espia.it
Tue Oct 7 15:11:37 MST 2003
Hi.
Since a customer requested us that feature, I wrote this
little patch for app_dial to allow to play an
announcement to the called party, as soon he answers.
you can define the file to play in the dial() option,
using A(filename).
for example:
exten => blah,1,Dial(Zap/blah,30,rA(/my/own/announce)Tt)
that doesn't break anything ...
feel free to blame me for anything bad this patch could do ;)
if for the list is ok, I'll submit to the bug tracker, under
a feature-request.
Matteo
--
Brancaleoni Matteo <mbrancaleoni at espia.it>
Espia - Emmegi Srl
-------------- next part --------------
--- asterisk/apps/app_dial.c 2003-10-08 00:05:43.000000000 +0200
+++ dial-asterisk/apps/app_dial.c 2003-10-08 00:04:20.000000000 +0200
@@ -337,6 +337,7 @@
struct localuser *u;
char info[256], *peers, *timeout, *tech, *number, *rest, *cur;
char privdb[256] = "", *s;
+ char announcemsg[256] = "", *ann;
struct localuser *outgoing=NULL, *tmp;
struct ast_channel *peer;
int to;
@@ -344,8 +345,10 @@
int allowredir_out=0;
int allowdisconnect=0;
int privacy=0;
+ int announce=0;
int resetcdr=0;
int clearchannel=0;
+ int cnt=0;
char numsubst[AST_MAX_EXTENSION];
char restofit[AST_MAX_EXTENSION];
char *transfer = NULL;
@@ -419,6 +422,16 @@
} else if (strchr(transfer, 'C')) {
resetcdr = 1;
}
+ /* XXX ANNOUNCE SUPPORT */
+ else if ((ann = strstr(transfer, "A("))) {
+ announce = 1;
+ strncpy(announcemsg, ann + 2, sizeof(announcemsg) - 1);
+ cnt=0;
+ while(announcemsg[cnt] != ')') {
+ cnt++;
+ }
+ announcemsg[cnt]='\0';
+ }
}
if (resetcdr && chan->cdr)
ast_cdr_reset(chan->cdr, 0);
@@ -670,6 +683,11 @@
ast_channel_setoption(chan,AST_OPTION_AUDIO_MODE,&x,sizeof(char),0);
ast_channel_setoption(peer,AST_OPTION_AUDIO_MODE,&x,sizeof(char),0);
}
+ if (announce && announcemsg)
+ {
+ res = ast_streamfile(peer,announcemsg,peer->language);
+ res = ast_waitstream(peer,"");
+ }
res = ast_bridge_call(chan, peer, allowredir_in, allowredir_out, allowdisconnect | clearchannel);
if (clearchannel)
{
More information about the asterisk-users
mailing list