Change in ...osmo-sip-connector[master]: Add media mode parameter to sdp_create_file()

keith gerrit-no-reply at lists.osmocom.org
Mon Aug 5 17:02:47 UTC 2019


keith has submitted this change and it was merged. ( https://gerrit.osmocom.org/c/osmo-sip-connector/+/14993 )

Change subject: Add media mode parameter to sdp_create_file()
......................................................................

Add media mode parameter to sdp_create_file()

This enables call hold implemented by subsequent commits

Prior to this commit, osmo-sip-connector would not send
any media mode attribute in the sdp. After this commit
we will by default always include a=sendrecv.

Given that a media mode attribute of "sendrecv" is default
and implicit it its absense, this does not represent any
functional change.

Change-Id: Ib4212d0174955042e7d80d3744ce632a4942ccb2
---
M src/sdp.c
M src/sdp.h
M src/sip.c
3 files changed, 29 insertions(+), 6 deletions(-)

Approvals:
  Jenkins Builder: Verified
  laforge: Looks good to me, but someone else must approve
  pespin: Looks good to me, approved



diff --git a/src/sdp.c b/src/sdp.c
index 17eb577..9bb55d4 100644
--- a/src/sdp.c
+++ b/src/sdp.c
@@ -163,16 +163,35 @@
 	return true;
 }
 
-char *sdp_create_file(struct sip_call_leg *leg, struct call_leg *other)
+char *sdp_create_file(struct sip_call_leg *leg, struct call_leg *other, sdp_mode_t mode)
 {
 	struct in_addr net = { .s_addr = htonl(other->ip) };
 	char *fmtp_str = NULL, *sdp;
+	char *mode_attribute;
 
 	leg->wanted_codec = app_media_name(other->payload_msg_type);
 
 	if (strcmp(leg->wanted_codec, "AMR") == 0)
 		fmtp_str = talloc_asprintf(leg, "a=fmtp:%d octet-align=1\r\n", other->payload_type);
 
+	switch (mode) {
+		case sdp_inactive:
+			mode_attribute = "a=inactive\r\n";
+			break;
+		case sdp_sendrecv:
+			mode_attribute = "a=sendrecv\r\n";
+			break;
+		case sdp_sendonly:
+			mode_attribute = "a=sendonly\r\n";
+			break;
+		case sdp_recvonly:
+			mode_attribute = "a=recvonly\r\n";
+			break;
+		default:
+			OSMO_ASSERT(false);
+			break;
+	}
+
 	sdp = talloc_asprintf(leg,
 				"v=0\r\n"
 				"o=Osmocom 0 0 IN IP4 %s\r\n"
@@ -181,12 +200,14 @@
 				"t=0 0\r\n"
 				"m=audio %d RTP/AVP %d\r\n"
 				"%s"
-				"a=rtpmap:%d %s/8000\r\n",
+				"a=rtpmap:%d %s/8000\r\n"
+				"%s",
 				inet_ntoa(net), inet_ntoa(net), /* never use diff. addr! */
 				other->port, other->payload_type,
 				fmtp_str ? fmtp_str : "",
 				other->payload_type,
-				leg->wanted_codec);
+				leg->wanted_codec,
+				mode_attribute);
 	talloc_free(fmtp_str);
 	return sdp;
 }
diff --git a/src/sdp.h b/src/sdp.h
index d716644..72ff6b7 100644
--- a/src/sdp.h
+++ b/src/sdp.h
@@ -1,6 +1,7 @@
 #pragma once
 
 #include <sofia-sip/sip.h>
+#include <sofia-sip/sdp.h>
 
 #include <stdbool.h>
 
@@ -10,4 +11,4 @@
 bool sdp_screen_sdp(const sip_t *sip);
 bool sdp_extract_sdp(struct sip_call_leg *leg, const sip_t *sip, bool any_codec);
 
-char *sdp_create_file(struct sip_call_leg *, struct call_leg *);
+char *sdp_create_file(struct sip_call_leg *, struct call_leg *, sdp_mode_t mode);
diff --git a/src/sip.c b/src/sip.c
index adf20d8..21401c6 100644
--- a/src/sip.c
+++ b/src/sip.c
@@ -28,6 +28,7 @@
 
 #include <sofia-sip/sip_status.h>
 #include <sofia-sip/su_log.h>
+#include <sofia-sip/sdp.h>
 
 #include <talloc.h>
 
@@ -385,7 +386,7 @@
 		return;
 	}
 
-	sdp = sdp_create_file(leg, other);
+	sdp = sdp_create_file(leg, other, sdp_sendrecv);
 
 	leg->state = SIP_CC_CONNECTED;
 	nua_respond(leg->nua_handle, SIP_200_OK,
@@ -425,7 +426,7 @@
 				called_num,
 				agent->app->sip.remote_addr,
 				agent->app->sip.remote_port);
-	char *sdp = sdp_create_file(leg, other);
+	char *sdp = sdp_create_file(leg, other, sdp_sendrecv);
 
 	leg->state = SIP_CC_INITIAL;
 	leg->dir = SIP_DIR_MT;

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-sip-connector/+/14993
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: Ib4212d0174955042e7d80d3744ce632a4942ccb2
Gerrit-Change-Number: 14993
Gerrit-PatchSet: 3
Gerrit-Owner: keith <keith at rhizomatica.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: keith <keith at rhizomatica.org>
Gerrit-Reviewer: laforge <laforge at gnumonks.org>
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-CC: neels <nhofmeyr at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190805/da995bb2/attachment.html>


More information about the gerrit-log mailing list