Change in osmo-mgw[master]: mgcp_sdp: restructure mgcp_write_response_sdp() (audio)

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Harald Welte gerrit-no-reply at lists.osmocom.org
Sun Aug 5 07:17:18 UTC 2018


Harald Welte has submitted this change and it was merged. ( https://gerrit.osmocom.org/10320 )

Change subject: mgcp_sdp: restructure mgcp_write_response_sdp() (audio)
......................................................................

mgcp_sdp: restructure mgcp_write_response_sdp() (audio)

The function mgcp_write_response_sdp() is responsible to write the
audio port and the list with the supported payload type numbers to
the sdp response. At the moment it can only write exactly one payload
type number to the response, but in the future we may want to write
several payload type numbers to the response. Lets add a function
for that so that now.

- add add_audio() helper function to add multiple payload type
  numbers, but keep the functionality as it is for now

Change-Id: I662c725f697b2ffb1e3ad4671a445f943cd79b63
Related: OS#3442
---
M src/libosmo-mgcp/mgcp_sdp.c
1 file changed, 30 insertions(+), 2 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/libosmo-mgcp/mgcp_sdp.c b/src/libosmo-mgcp/mgcp_sdp.c
index a6def41..4f66e85 100644
--- a/src/libosmo-mgcp/mgcp_sdp.c
+++ b/src/libosmo-mgcp/mgcp_sdp.c
@@ -304,6 +304,32 @@
 	return 0;
 }
 
+/* Add audio string to sdp payload */
+static int add_audio(struct msgb *sdp, int *payload_types, unsigned int payload_types_len, int local_port)
+{
+	int rc;
+	unsigned int i;
+
+	if (payload_types_len < 0)
+		return -EINVAL;
+
+	rc = msgb_printf(sdp, "m=audio %d RTP/AVP", local_port);
+	if (rc < 0)
+		return -EINVAL;
+
+	for (i = 0; i < payload_types_len; i++) {
+		rc = msgb_printf(sdp, " %d", payload_types[i]);
+		if (rc < 0)
+			return -EINVAL;
+	}
+
+	rc = msgb_printf(sdp, "\r\n");
+	if (rc < 0)
+		return -EINVAL;
+
+	return 0;
+}
+
 /*! Generate SDP response string.
  *  \param[in] endp trunk endpoint.
  *  \param[in] conn associated rtp connection.
@@ -318,6 +344,7 @@
 	const char *audio_name;
 	int payload_type;
 	int rc;
+	int payload_types[1];
 
 	OSMO_ASSERT(endp);
 	OSMO_ASSERT(conn);
@@ -341,8 +368,9 @@
 		goto buffer_too_small;
 
 	if (payload_type >= 0) {
-		rc = msgb_printf(sdp, "m=audio %d RTP/AVP %d\r\n",
-				 conn->end.local_port, payload_type);
+
+		payload_types[0] = payload_type;
+		rc = add_audio(sdp, payload_types, 1, conn->end.local_port);
 		if (rc < 0)
 			goto buffer_too_small;
 

-- 
To view, visit https://gerrit.osmocom.org/10320
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I662c725f697b2ffb1e3ad4671a445f943cd79b63
Gerrit-Change-Number: 10320
Gerrit-PatchSet: 4
Gerrit-Owner: dexter <pmaier at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20180805/cf0df2c7/attachment.htm>


More information about the gerrit-log mailing list