[asterisk-commits] file: branch 1.4 r97195 - /branches/1.4/channels/chan_mgcp.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Jan 8 14:48:21 CST 2008
Author: file
Date: Tue Jan 8 14:48:20 2008
New Revision: 97195
URL: http://svn.digium.com/view/asterisk?view=rev&rev=97195
Log:
Fix various DTMF issues in chan_mgcp.
(closes issue #11443)
Reported by: eferro
Patches:
dtmf_control_hybrid-inband-mode.patch uploaded by eferro (license 337)
Modified:
branches/1.4/channels/chan_mgcp.c
Modified: branches/1.4/channels/chan_mgcp.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/channels/chan_mgcp.c?view=diff&rev=97195&r1=97194&r2=97195
==============================================================================
--- branches/1.4/channels/chan_mgcp.c (original)
+++ branches/1.4/channels/chan_mgcp.c Tue Jan 8 14:48:20 2008
@@ -434,6 +434,7 @@
static int mgcp_senddigit_begin(struct ast_channel *ast, char digit);
static int mgcp_senddigit_end(struct ast_channel *ast, char digit, unsigned int duration);
static int mgcp_devicestate(void *data);
+static void add_header_offhook(struct mgcp_subchannel *sub, struct mgcp_request *resp);
static const struct ast_channel_tech mgcp_tech = {
.type = "MGCP",
@@ -1276,23 +1277,50 @@
static int mgcp_senddigit_begin(struct ast_channel *ast, char digit)
{
- /* Let asterisk play inband indications */
- return -1;
+ struct mgcp_subchannel *sub = ast->tech_pvt;
+ struct mgcp_endpoint *p = sub->parent;
+ int res = 0;
+
+ ast_mutex_lock(&sub->lock);
+ if (p->dtmfmode & MGCP_DTMF_INBAND || p->dtmfmode & MGCP_DTMF_HYBRID) {
+ ast_log(LOG_DEBUG, "Sending DTMF using inband/hybrid\n");
+ res = -1; /* Let asterisk play inband indications */
+ } else if (p->dtmfmode & MGCP_DTMF_RFC2833) {
+ ast_log(LOG_DEBUG, "Sending DTMF using RFC2833");
+ ast_rtp_senddigit_begin(sub->rtp, digit);
+ } else {
+ ast_log(LOG_ERROR, "Don't know about DTMF_MODE %d\n", p->dtmfmode);
+ }
+ ast_mutex_unlock(&sub->lock);
+
+ return res;
}
static int mgcp_senddigit_end(struct ast_channel *ast, char digit, unsigned int duration)
{
struct mgcp_subchannel *sub = ast->tech_pvt;
+ struct mgcp_endpoint *p = sub->parent;
+ int res = 0;
char tmp[4];
- tmp[0] = 'D';
- tmp[1] = '/';
- tmp[2] = digit;
- tmp[3] = '\0';
ast_mutex_lock(&sub->lock);
- transmit_notify_request(sub, tmp);
+ if (p->dtmfmode & MGCP_DTMF_INBAND || p->dtmfmode & MGCP_DTMF_HYBRID) {
+ ast_log(LOG_DEBUG, "Stopping DTMF using inband/hybrid\n");
+ res = -1; /* Tell Asterisk to stop inband indications */
+ } else if (p->dtmfmode & MGCP_DTMF_RFC2833) {
+ ast_log(LOG_DEBUG, "Stopping DTMF using RFC2833\n");
+ tmp[0] = 'D';
+ tmp[1] = '/';
+ tmp[2] = digit;
+ tmp[3] = '\0';
+ transmit_notify_request(sub, tmp);
+ ast_rtp_senddigit_end(sub->rtp, digit);
+ } else {
+ ast_log(LOG_ERROR, "Don't know about DTMF_MODE %d\n", p->dtmfmode);
+ }
ast_mutex_unlock(&sub->lock);
- return -1; /* Return non-zero so that Asterisk will stop the inband indications */
+
+ return res;
}
/*!
@@ -2193,7 +2221,7 @@
add_header(&resp, "R", "L/hd(N)");
break;
case MGCP_OFFHOOK:
- add_header(&resp, "R", (sub->rtp && (p->dtmfmode & MGCP_DTMF_INBAND)) ? "L/hu(N),L/hf(N)" : "L/hu(N),L/hf(N),D/[0-9#*](N)");
+ add_header_offhook(sub, &resp);
break;
}
if (!ast_strlen_zero(tone)) {
@@ -2236,7 +2264,7 @@
add_header(&resp, "R", "L/hd(N)");
break;
case MGCP_OFFHOOK:
- add_header(&resp, "R", (sub->rtp && (p->dtmfmode & MGCP_DTMF_INBAND)) ? "L/hu(N),L/hf(N)" : "L/hu(N),L/hf(N),D/[0-9#*](N)");
+ add_header_offhook(sub, &resp);
break;
}
if (!ast_strlen_zero(tone2)) {
@@ -2277,7 +2305,7 @@
add_header(&resp, "R", "L/hd(N)");
break;
case MGCP_OFFHOOK:
- add_header(&resp, "R", (sub->rtp && (p->dtmfmode & MGCP_DTMF_INBAND)) ? "L/hu(N), L/hf(N)" : "L/hu(N),L/hf(N),D/[0-9#*](N)");
+ add_header_offhook(sub, &resp);
break;
}
/* fill in new fields */
@@ -2286,6 +2314,16 @@
return send_request(p, sub, &resp, oseq); /* SC */
}
+
+static void add_header_offhook(struct mgcp_subchannel *sub, struct mgcp_request *resp)
+{
+ struct mgcp_endpoint *p = sub->parent;
+
+ if (p && p->sub && p->sub->owner && p->sub->owner->_state >= AST_STATE_RINGING && (p->dtmfmode & (MGCP_DTMF_INBAND | MGCP_DTMF_HYBRID)))
+ add_header(resp, "R", "L/hu(N),L/hf(N)");
+ else
+ add_header(resp, "R", "L/hu(N),L/hf(N),D/[0-9#*](N)");
+}
static int transmit_audit_endpoint(struct mgcp_endpoint *p)
{
More information about the asterisk-commits
mailing list