[PATCH] osmo-sip-connector[master]: dtmf: Forward DTMF from MNCC to SIP

Holger Freyther gerrit-no-reply at lists.osmocom.org
Wed Feb 22 13:13:44 UTC 2017


Review at  https://gerrit.osmocom.org/1874

dtmf: Forward DTMF from MNCC to SIP

We are not using the RTP telephony-event here but the older dtmf
relay. We also only have a fixed DTMF duration for now.

Change-Id: Icf770fae89f7aedf6eba9a119db9b8acc7f938df
---
M src/call.h
M src/mncc.c
M src/sip.c
3 files changed, 28 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-sip-connector refs/changes/74/1874/1

diff --git a/src/call.h b/src/call.h
index 7cb4932..5a11f6c 100644
--- a/src/call.h
+++ b/src/call.h
@@ -67,6 +67,11 @@
 	 * by the application to release the call.
 	 */
 	void (*release_call)(struct call_leg *);
+
+	/**
+	 * A DTMF key was entered. Forward it.
+	 */
+	void (*dtmf)(struct call_leg *, int keypad);
 };
 
 enum sip_cc_state {
diff --git a/src/mncc.c b/src/mncc.c
index ceb0fc1..d28010a 100644
--- a/src/mncc.c
+++ b/src/mncc.c
@@ -632,6 +632,7 @@
 	struct gsm_mncc out_mncc = { 0, };
 	struct gsm_mncc *data;
 	struct mncc_call_leg *leg;
+	struct call_leg *other_leg;
 
 	leg = find_leg(conn, buf, rc, &data);
 	if (!leg)
@@ -639,6 +640,10 @@
 
 	LOGP(DMNCC, LOGL_DEBUG, "leg(%u) DTMF key=%c\n", leg->callref, data->keypad);
 
+	other_leg = call_leg_other(&leg->base);
+	if (other_leg && other_leg->dtmf)
+		other_leg->dtmf(other_leg, data->keypad);
+
 	mncc_fill_header(&out_mncc, MNCC_START_DTMF_RSP, leg->callref);
 	out_mncc.keypad = data->keypad;
 	mncc_write(conn, &out_mncc, leg->callref);
diff --git a/src/sip.c b/src/sip.c
index afff393..178480c 100644
--- a/src/sip.c
+++ b/src/sip.c
@@ -37,6 +37,7 @@
 static void sip_release_call(struct call_leg *_leg);
 static void sip_ring_call(struct call_leg *_leg);
 static void sip_connect_call(struct call_leg *_leg);
+static void sip_dtmf_call(struct call_leg *_leg, int keypad);
 
 static void call_progress(struct sip_call_leg *leg, const sip_t *sip)
 {
@@ -131,6 +132,7 @@
 	leg->base.release_call = sip_release_call;
 	leg->base.ring_call = sip_ring_call;
 	leg->base.connect_call = sip_connect_call;
+	leg->base.dtmf = sip_dtmf_call;
 	leg->agent = agent;
 	leg->nua_handle = nh;
 	nua_handle_bind(nh, leg);
@@ -288,6 +290,22 @@
 	talloc_free(sdp);
 }
 
+static void sip_dtmf_call(struct call_leg *_leg, int keypad)
+{
+	struct sip_call_leg *leg;
+	char *buf;
+
+	OSMO_ASSERT(_leg->type == CALL_TYPE_SIP);
+	leg = (struct sip_call_leg *) _leg;
+
+	buf = talloc_asprintf(leg, "Signal=%c\nDuration=160\n", keypad);
+	nua_info(leg->nua_handle,
+		NUTAG_MEDIA_ENABLE(0),
+		SIPTAG_CONTENT_TYPE_STR("application/dtmf-relay"),
+		SIPTAG_PAYLOAD_STR(buf), TAG_END());
+	talloc_free(buf);
+}
+
 static int send_invite(struct sip_agent *agent, struct sip_call_leg *leg,
 			const char *calling_num, const char *called_num)
 {

-- 
To view, visit https://gerrit.osmocom.org/1874
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Icf770fae89f7aedf6eba9a119db9b8acc7f938df
Gerrit-PatchSet: 1
Gerrit-Project: osmo-sip-connector
Gerrit-Branch: master
Gerrit-Owner: Holger Freyther <holger at freyther.de>


More information about the gerrit-log mailing list