Change in ...osmo-sip-connector[master]: Prepare to support MO Call HOLD

keith gerrit-no-reply at lists.osmocom.org
Tue Jul 30 14:36:18 UTC 2019


keith has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-sip-connector/+/14995


Change subject: Prepare to support MO Call HOLD
......................................................................

Prepare to support MO Call HOLD

Add function pointers to the call_leg struct for call hold and retrieve.

Add function to send re-INVITE to SIP side when MNCC side puts call on HOLD/RETRIEVES.

Add MNCC/SIP CC_HOLD to call states.

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



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

diff --git a/src/call.c b/src/call.c
index 9be6b4d..67207e5 100644
--- a/src/call.c
+++ b/src/call.c
@@ -40,6 +40,7 @@
 	{ MNCC_CC_INITIAL,		"INITIAL"    },
 	{ MNCC_CC_PROCEEDING,		"PROCEEDING" },
 	{ MNCC_CC_CONNECTED,		"CONNECTED"  },
+	{ MNCC_CC_HOLD,			"ON HOLD"    },
 	{ 0, NULL },
 };
 
@@ -53,6 +54,7 @@
 	{ SIP_CC_INITIAL,		"INITIAL"   },
 	{ SIP_CC_DLG_CNFD,		"CONFIRMED" },
 	{ SIP_CC_CONNECTED,		"CONNECTED" },
+	{ SIP_CC_HOLD,			"ON HOLD"   },
 	{ 0, NULL },
 };
 
diff --git a/src/call.h b/src/call.h
index 65d1111..365b3eb 100644
--- a/src/call.h
+++ b/src/call.h
@@ -74,12 +74,24 @@
 	 * A DTMF key was entered. Forward it.
 	 */
 	void (*dtmf)(struct call_leg *, int keypad);
+
+	/**
+	 * Call HOLD requested
+	 */
+	void (*hold_call)(struct call_leg *);
+
+	/**
+	 * Call HOLD ended
+	 */
+	void (*retrieve_call)(struct call_leg *);
+
 };
 
 enum sip_cc_state {
 	SIP_CC_INITIAL,
 	SIP_CC_DLG_CNFD,
 	SIP_CC_CONNECTED,
+	SIP_CC_HOLD,
 };
 
 enum sip_dir {
@@ -110,6 +122,7 @@
 	MNCC_CC_INITIAL,
 	MNCC_CC_PROCEEDING, /* skip delivered state */
 	MNCC_CC_CONNECTED,
+	MNCC_CC_HOLD,
 };
 
 enum mncc_dir {
diff --git a/src/sip.c b/src/sip.c
index b5f856a..6507486 100644
--- a/src/sip.c
+++ b/src/sip.c
@@ -40,6 +40,9 @@
 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 sip_hold_call(struct call_leg *_leg);
+static void sip_retrieve_call(struct call_leg *_leg);
+
 
 /* Find a SIP Call leg by given nua_handle */
 static struct sip_call_leg *sip_find_leg(nua_handle_t *nh)
@@ -160,6 +163,8 @@
 	leg->base.ring_call = sip_ring_call;
 	leg->base.connect_call = sip_connect_call;
 	leg->base.dtmf = sip_dtmf_call;
+	leg->base.hold_call = sip_hold_call;
+	leg->base.retrieve_call = sip_retrieve_call;
 	leg->agent = agent;
 	leg->nua_handle = nh;
 	nua_handle_bind(nh, leg);
@@ -403,6 +408,7 @@
 		}
 		break;
 	case SIP_CC_CONNECTED:
+	case SIP_CC_HOLD:
 		LOGP(DSIP, LOGL_NOTICE, "Ending leg(%p) in con\n", leg);
 		nua_bye(leg->nua_handle, TAG_END());
 		break;
@@ -465,6 +471,40 @@
 	talloc_free(buf);
 }
 
+static void sip_hold_call(struct call_leg *_leg)
+{
+	struct sip_call_leg *leg;
+	struct call_leg *other_leg;
+	OSMO_ASSERT(_leg->type == CALL_TYPE_SIP);
+	leg = (struct sip_call_leg *) _leg;
+	other_leg = call_leg_other(&leg->base);
+	char *sdp = sdp_create_file(leg, other_leg, sdp_sendonly);
+	nua_invite(leg->nua_handle,
+		    NUTAG_MEDIA_ENABLE(0),
+		    SIPTAG_CONTENT_TYPE_STR("application/sdp"),
+		    SIPTAG_PAYLOAD_STR(sdp),
+		    TAG_END());
+	talloc_free(sdp);
+	leg->state = SIP_CC_HOLD;
+}
+
+static void sip_retrieve_call(struct call_leg *_leg)
+{
+	struct sip_call_leg *leg;
+	struct call_leg *other_leg;
+	OSMO_ASSERT(_leg->type == CALL_TYPE_SIP);
+	leg = (struct sip_call_leg *) _leg;
+	other_leg = call_leg_other(&leg->base);
+	char *sdp = sdp_create_file(leg, other_leg, sdp_sendrecv);
+	nua_invite(leg->nua_handle,
+		    NUTAG_MEDIA_ENABLE(0),
+		    SIPTAG_CONTENT_TYPE_STR("application/sdp"),
+		    SIPTAG_PAYLOAD_STR(sdp),
+		    TAG_END());
+	talloc_free(sdp);
+	leg->state = SIP_CC_CONNECTED;
+}
+
 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/c/osmo-sip-connector/+/14995
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-sip-connector
Gerrit-Branch: master
Gerrit-Change-Id: I2595626dfa50eb2f8e29a02540b708c9c1dce88c
Gerrit-Change-Number: 14995
Gerrit-PatchSet: 1
Gerrit-Owner: keith <keith at rhizomatica.org>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190730/92a3f9ad/attachment-0001.html>


More information about the gerrit-log mailing list