[Asterisk-Users] DTMF with IConnectHere fix
Klaus-Peter Junghanns
kpj at junghanns.net
Sat Mar 1 13:10:39 MST 2003
Hi there,
to stop my inbox from being filled with those "...iconnect
inband dtmf .. yadda yadda..." mails, i am sending this patch
to the list ;-)
thanks to lele for updating it to patch against latest cvs :)
you can enable inband dtmf by adding the line inbanddtmf=1
to the sip pvt in sip.conf.
Mark, i will send you a disclaimer on monday (really!), hope
you will merge it (although you dont like the idea...).
regards
kapejod
--
Klaus-Peter Junghanns
CEO,CTO
Junghanns.NET GmbH
Breite Strasse 13 - 12167 Berlin - Germany
fon: +49 30 79705390
fax: +49 30 79705391
iaxtel: 1-700-157-8753
email: kpj at junghanns.net
Am Fre, 2003-02-28 um 18.08 schrieb Mark Spencer:
> I am looking for someone to confirm that Iconnecthere sends DTMF either
> in-band or out-of-band. If it is out-of-band, then I'll need to work with
> someone to figure out the issue. If it is in-band then I will need to add
> in-band DTMF detection to SIP.
>
> Mark
>
> On Thu, 27 Feb 2003, Ben Clark wrote:
>
> > Is anyone working on a fix to send / receive DTMF with IConnectHere?
> >
> > _______________________________________________
> > Asterisk-Users mailing list
> > Asterisk-Users at lists.digium.com
> > http://lists.digium.com/mailman/listinfo/asterisk-users
> >
>
> _______________________________________________
> Asterisk-Users mailing list
> Asterisk-Users at lists.digium.com
> http://lists.digium.com/mailman/listinfo/asterisk-users
-------------- next part --------------
--- asterisk.wml-T50/channels/chan_sip.c 2003-02-27 09:10:52.000000000 +0100
+++ asterisk.wml-T50-dtmf/channels/chan_sip.c 2003-02-28 01:35:35.000000000 +0100
@@ -33,6 +33,7 @@
#include <asterisk/md5.h>
#include <asterisk/app.h>
#include <asterisk/musiconhold.h>
+#include <asterisk/dsp.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <net/if.h>
@@ -170,6 +171,9 @@
int maxtime; /* Max time for first response */
int initid; /* Auto-congest ID if appropriate */
+
+ int inbanddtmf;
+ struct ast_dsp *vad;
struct sip_peer *peerpoke; /* If this calls is to poke a peer, which one */
struct sip_registry *registry; /* If this is a REGISTER call, to which registry */
@@ -197,6 +201,7 @@
int amaflags;
int insecure;
int canreinvite;
+ int inbanddtmf;
struct ast_ha *ha;
struct sip_user *next;
};
@@ -216,6 +221,7 @@
int capability;
int insecure;
int canreinvite;
+ int inbanddtmf;
struct sockaddr_in addr;
struct in_addr mask;
@@ -368,6 +374,7 @@
r->insecure = p->insecure;
r->canreinvite = p->canreinvite;
r->maxtime = p->maxms;
+ r->inbanddtmf = p->inbanddtmf;
strncpy(r->context, p->context,sizeof(r->context)-1);
if ((p->addr.sin_addr.s_addr || p->defaddr.sin_addr.s_addr) &&
(!p->maxms || ((p->lastms > 0) && (p->lastms <= p->maxms)))) {
@@ -671,6 +678,9 @@
needcancel = 1;
/* Disconnect */
p = ast->pvt->pvt;
+ if ((p->inbanddtmf == 1) && (p->vad != NULL)) {
+ ast_dsp_free(p->vad);
+ }
p->owner = NULL;
ast->pvt->pvt = NULL;
@@ -916,6 +926,10 @@
else
snprintf(tmp->name, sizeof(tmp->name), "SIP/%s:%d", inet_ntoa(i->sa.sin_addr), ntohs(i->sa.sin_port));
tmp->type = type;
+ if (i->inbanddtmf == 1) {
+ i->vad = ast_dsp_new();
+ ast_dsp_set_features(i->vad, DSP_FEATURE_DTMF_DETECT);
+ }
tmp->fds[0] = ast_rtp_fd(i->rtp);
ast_setstate(tmp, state);
if (state == AST_STATE_RING)
@@ -1035,6 +1049,9 @@
ast_set_read_format(p->owner, p->owner->readformat);
ast_set_write_format(p->owner, p->owner->writeformat);
}
+ if (p->inbanddtmf == 1) {
+ f = ast_dsp_process(p->owner,p->vad,f,0);
+ }
}
}
return f;
@@ -2458,6 +2475,7 @@
strncpy(p->accountcode, user->accountcode, sizeof(p->accountcode) -1);
p->canreinvite = user->canreinvite;
p->amaflags = user->amaflags;
+ p->inbanddtmf = user->inbanddtmf;
}
break;
}
@@ -2489,13 +2507,18 @@
if (p->owner) {
if (sipdebug)
ast_verbose("Message received: '%s'\n", buf);
- memset(&f, 0, sizeof(f));
- f.frametype = AST_FRAME_TEXT;
- f.subclass = 0;
- f.offset = 0;
- f.data = buf;
- f.datalen = strlen(buf);
- ast_queue_frame(p->owner, &f, 1);
+ if (p->inbanddtmf == 0) {
+
+ memset(&f, 0, sizeof(f));
+ f.frametype = AST_FRAME_TEXT;
+ f.subclass = 0;
+ f.offset = 0;
+ f.data = buf;
+ f.datalen = strlen(buf);
+ ast_queue_frame(p->owner, &f, 1);
+ } else {
+ // drop out of band dtmfs when doing inband detection!
+ }
}
}
@@ -3671,7 +3694,9 @@
} else if (!strcasecmp(v->name, "auth")) {
strncpy(user->methods, v->value, sizeof(user->methods)-1);
} else if (!strcasecmp(v->name, "secret")) {
- strncpy(user->secret, v->value, sizeof(user->secret)-1);
+ strncpy(user->secret, v->value, sizeof(user->secret)-1);
+ } else if (!strcasecmp(v->name, "inbanddtmf")) {
+ user->inbanddtmf=atoi(v->value);
} else if (!strcasecmp(v->name, "canreinvite")) {
user->canreinvite = ast_true(v->value);
} else if (!strcasecmp(v->name, "callerid")) {
@@ -3752,6 +3777,8 @@
peer->canreinvite = ast_true(v->value);
else if (!strcasecmp(v->name, "context"))
strncpy(peer->context, v->value, sizeof(peer->context)-1);
+ else if (!strcasecmp(v->name, "inbanddtmf"))
+ peer->inbanddtmf=atoi(v->value);
else if (!strcasecmp(v->name, "host")) {
if (!strcasecmp(v->value, "dynamic")) {
/* They'll register with us */
More information about the asterisk-users
mailing list