summaryrefslogtreecommitdiff
path: root/channels/chan_vpb.c
diff options
context:
space:
mode:
authorBen Kramer <bkramer@voicetronix.com.au>2004-12-15 22:59:47 +0000
committerBen Kramer <bkramer@voicetronix.com.au>2004-12-15 22:59:47 +0000
commitf08b28975bbc06aa7218d5ff117052d554544889 (patch)
treef77792fd2e57ba3c05533d163882281291dc61a3 /channels/chan_vpb.c
parentd1956e855de88343403e30970dbce0c569cb56d0 (diff)
/ finished off support for DTMF caller ID (brazil) using patch provided by
/ Daniel Bichara git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@4464 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'channels/chan_vpb.c')
-rwxr-xr-xchannels/chan_vpb.c31
1 files changed, 29 insertions, 2 deletions
diff --git a/channels/chan_vpb.c b/channels/chan_vpb.c
index 4fe9658f4..29397331a 100755
--- a/channels/chan_vpb.c
+++ b/channels/chan_vpb.c
@@ -64,6 +64,10 @@ extern "C" {
#define MAX_VPB_GAIN 12.0
+#define DTMF_CALLERID
+#define DTMF_CID_START 'D'
+#define DTMF_CID_STOP 'C'
+
/**/
#if defined(__cplusplus) || defined(c_plusplus)
extern "C" {
@@ -237,7 +241,7 @@ static struct vpb_pvt {
char language[MAX_LANGUAGE]; /* language being used */
char callerid[AST_MAX_EXTENSION]; /* CallerId used for directly connected phone */
- int brcallerpos; /* Brazilian CallerID detection */
+ int dtmf_caller_pos; /* DTMF CallerID detection (Brazil)*/
int lastoutput; /* Holds the last Audio format output'ed */
int lastinput; /* Holds the last Audio format input'ed */
@@ -891,6 +895,7 @@ static inline int monitor_handle_owned(struct vpb_pvt *p, VPB_EVENT *e)
static inline int monitor_handle_notowned(struct vpb_pvt *p, VPB_EVENT *e)
{
char s[2] = {0};
+ struct ast_channel *owner = p->owner;
if (option_verbose > 3) {
char str[VPB_MAX_STR];
@@ -921,9 +926,9 @@ static inline int monitor_handle_notowned(struct vpb_pvt *p, VPB_EVENT *e)
else {
ast_verbose(VERBOSE_PREFIX_4 "%s: handle_notowned: playing dialtone\n",p->dev);
playtone(p->handle, &Dialtone);
+ p->state=VPB_STATE_PLAYDIAL;
p->wantdtmf = 1;
p->ext[0] = 0; /* Just to be sure & paranoid.*/
- p->state=VPB_STATE_PLAYDIAL;
}
break;
@@ -961,6 +966,28 @@ static inline int monitor_handle_notowned(struct vpb_pvt *p, VPB_EVENT *e)
case VPB_DTMF:
if (p->state == VPB_STATE_ONHOOK){
/* DTMF's being passed while on-hook maybe Caller ID */
+ if ( p->mode == MODE_FXO ) {
+ if ( e->data == DTMF_CID_START ) { /* CallerID Start signal */
+ p->dtmf_caller_pos = 0; /* Leaves the first digit out */
+ memset(p->callerid,0,AST_MAX_EXTENSION);
+ }
+ else if ( e->data == DTMF_CID_STOP ) { /* CallerID End signal */
+ p->callerid[p->dtmf_caller_pos] = '\0';
+ if (option_verbose > 2)
+ ast_verbose(VERBOSE_PREFIX_3 " %s: DTMF CallerID %s\n",p->dev,p->callerid);
+ if (owner->cid.cid_num)
+ free(owner->cid.cid_num);
+ owner->cid.cid_num=NULL;
+ if (owner->cid.cid_name)
+ free(owner->cid.cid_name);
+ owner->cid.cid_name=NULL;
+ owner->cid.cid_num = strdup(p->callerid);
+ } else if ( p->dtmf_caller_pos < AST_MAX_EXTENSION ) {
+ if ( p->dtmf_caller_pos >= 0 )
+ p->callerid[p->dtmf_caller_pos] = e->data;
+ p->dtmf_caller_pos++;
+ }
+ }
break;
}
if (p->wantdtmf == 1) {