From: Andreas Eversberg Date: Sun, 16 Dec 2012 07:57:57 +0000 (+0100) Subject: Added option to change DTMF decoding threshold level X-Git-Url: http://git.eversberg.eu/gitweb.cgi?p=lcr.git;a=commitdiff_plain;h=4b85a2abcd708ad8d0e02dca9913db7bd6ab4fed;ds=sidebyside Added option to change DTMF decoding threshold level If not given, the DSP modules' default value is used, rather than setting it to 0. This was a bug. --- diff --git a/interface.c b/interface.c index b9dd275..33f0c10 100644 --- a/interface.c +++ b/interface.c @@ -751,6 +751,22 @@ static int inter_nodtmf(struct interface *interface, char *filename, int line, c ifport->nodtmf = 1; return(0); } +static int inter_dtmf_threshold(struct interface *interface, char *filename, int line, char *parameter, char *value) +{ + struct interface_port *ifport; + + /* port in chain ? */ + if (!interface->ifport) { + SPRINT(interface_error, "Error in %s (line %d): parameter '%s' expects previous 'port' definition.\n", filename, line, parameter); + return(-1); + } + /* goto end of chain */ + ifport = interface->ifport; + while(ifport->next) + ifport = ifport->next; + ifport->dtmf_threshold = atoi(value); + return(0); +} static int inter_filter(struct interface *interface, char *filename, int line, char *parameter, char *value) { char *p, *q; @@ -1294,6 +1310,10 @@ struct interface_param interface_param[] = { "Disables DTMF detection for this interface.\n" "This parameter must follow a 'port' parameter."}, + {"dtmf-threshold", &inter_dtmf_threshold, "", + "Set threshold value for minimum DTMF tone level.\n" + "This parameter must follow a 'port' parameter."}, + {"filter", &inter_filter, " ", "Adds/appends a filter. Filters are ordered in transmit direction.\n" "gain - Changes volume (-8 .. 8)\n" diff --git a/interface.h b/interface.h index e38987c..1f9b4b0 100644 --- a/interface.h +++ b/interface.h @@ -54,6 +54,7 @@ struct interface_port { unsigned int ss5; /* set, if SS5 signalling enabled, also holds feature bits */ int channel_force; /* forces channel by protocol */ int nodtmf; /* disables DTMF */ + int dtmf_threshold; /* DTMF level threshold */ struct select_channel *out_channel; /* list of channels to select */ struct select_channel *in_channel; /* the same for incoming channels */ int block; /* set if interface is blocked */ diff --git a/mISDN.cpp b/mISDN.cpp index 8ae5855..bb50a58 100644 --- a/mISDN.cpp +++ b/mISDN.cpp @@ -147,6 +147,7 @@ PmISDN::PmISDN(int type, mISDNport *mISDNport, char *portname, struct port_setti p_m_inband_send_on = 0; p_m_inband_receive_on = 0; p_m_dtmf = !mISDNport->ifport->nodtmf; + p_m_dtmf_threshold = mISDNport->ifport->dtmf_threshold; memset(&p_m_timeout, 0, sizeof(p_m_timeout)); add_timer(&p_m_timeout, mISDN_timeout, this, 0); SCPY(p_m_pipeline, mISDNport->ifport->interface->pipeline); @@ -348,15 +349,20 @@ void ph_control(struct mISDNport *mISDNport, class PmISDN *isdnport, int sock, u struct mISDNhead *ctrl = (struct mISDNhead *)buffer; unsigned int *d = (unsigned int *)(buffer+MISDN_HEADER_LEN); int ret; + int len = 8; if (sock < 0) return; + if (c1 == DTMF_TONE_START && c2 == 0) { + len = 4; + } + ctrl->prim = PH_CONTROL_REQ; ctrl->id = 0; *d++ = c1; *d++ = c2; - ret = sendto(sock, buffer, MISDN_HEADER_LEN+sizeof(int)*2, 0, NULL, 0); + ret = sendto(sock, buffer, MISDN_HEADER_LEN+len, 0, NULL, 0); if (ret <= 0) PERROR("Failed to send to socket %d\n", sock); chan_trace_header(mISDNport, isdnport, "BCHANNEL control", DIRECTION_OUT); @@ -507,7 +513,7 @@ static void _bchannel_configure(struct mISDNport *mISDNport, int i) // if (port->p_m_txmix && mode == B_MODE_TRANSPARENT) // ph_control(mISDNport, port, handle, DSP_MIX_ON, 0, "DSP-MIX", 1); if (port->p_m_dtmf && mode == B_MODE_TRANSPARENT) - ph_control(mISDNport, port, handle, DTMF_TONE_START, 0, "DSP-DTMF", 1); + ph_control(mISDNport, port, handle, DTMF_TONE_START, port->p_m_dtmf_threshold, "DSP-DTMF", 1); if (port->p_m_crypt && mode == B_MODE_TRANSPARENT) ph_control_block(mISDNport, port, handle, DSP_BF_ENABLE_KEY, port->p_m_crypt_key, port->p_m_crypt_key_len, "DSP-CRYPT", port->p_m_crypt_key_len); } diff --git a/mISDN.h b/mISDN.h index d8c504b..e3c278d 100644 --- a/mISDN.h +++ b/mISDN.h @@ -122,6 +122,7 @@ class PmISDN : public Port int p_m_rxoff; /* rx from driver is disabled */ int p_m_txdata; /* get what we transmit */ int p_m_dtmf; /* dtmf decoding is enabled */ + int p_m_dtmf_threshold; /* dtmf level threshold */ int bridge_rx(unsigned char *data, int len);