[PATCH] libosmo-abis[master]: Unify RTP receiving

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/.

Max gerrit-no-reply at lists.osmocom.org
Mon Sep 26 13:57:51 UTC 2016


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

Unify RTP receiving

* Remove code duplication
* Use return value of rtp_get_payload() instead of pointer arithmetic

Change-Id: Id42e85b55eab33c5eb81ac7a2cdea7962b2e30ef
---
M src/trau/osmo_ortp.c
1 file changed, 18 insertions(+), 27 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmo-abis refs/changes/48/948/1

diff --git a/src/trau/osmo_ortp.c b/src/trau/osmo_ortp.c
index 5441337..b1d762c 100644
--- a/src/trau/osmo_ortp.c
+++ b/src/trau/osmo_ortp.c
@@ -142,6 +142,19 @@
 	     "osmo-ortp(%d): timestamp_jump, new TS %d\n", port, ts);
 }
 
+static inline bool recv_with_cb(struct osmo_rtp_socket *rs)
+{
+	mblk_t *mblk = rtp_session_recvm_with_ts(rs->sess, rs->rx_user_ts);
+	if (!mblk)
+		return false;
+
+	int plen = rtp_get_payload(mblk, &mblk->b_rptr);
+	/* hand into receiver */
+	if (rs->rx_cb)
+		rs->rx_cb(rs, mblk->b_rptr, plen, rtp_get_markbit(mblk));
+	freemsg(mblk);
+	return true;
+}
 
 /*! \brief poll the socket for incoming data
  *  \param[in] rs the socket to be polled
@@ -149,26 +162,14 @@
  */
 int osmo_rtp_socket_poll(struct osmo_rtp_socket *rs)
 {
-	mblk_t *mblk;
 	if (rs->flags & OSMO_RTP_F_DISABLED)
 		return 0;
 
-	mblk = rtp_session_recvm_with_ts(rs->sess, rs->rx_user_ts);
-	if (mblk) {
-		rtp_get_payload(mblk, &mblk->b_rptr);
-		/* hand into receiver */
-		if (rs->rx_cb)
-			rs->rx_cb(rs, mblk->b_rptr,
-				  mblk->b_wptr - mblk->b_rptr,
-				  rtp_get_markbit(mblk));
-		//rs->rx_user_ts += 160;
-		freemsg(mblk);
+	if (recv_with_cb(rs))
 		return 1;
-	} else {
-		LOGP(DLMIB, LOGL_INFO, "osmo_rtp_poll(%u): ERROR!\n",
-		     rs->rx_user_ts);
-		return 0;
-	}
+
+	LOGP(DLMIB, LOGL_INFO, "osmo_rtp_poll(%u): ERROR!\n", rs->rx_user_ts);
+	return 0;
 }
 
 /* Osmo FD callbacks */
@@ -176,7 +177,6 @@
 static int osmo_rtp_fd_cb(struct osmo_fd *fd, unsigned int what)
 {
 	struct osmo_rtp_socket *rs = fd->data;
-	mblk_t *mblk;
 
 	if (what & BSC_FD_READ) {
 		/* in polling mode, we don't want to be called here */
@@ -184,16 +184,7 @@
 			fd->when &= ~BSC_FD_READ;
 			return 0;
 		}
-		mblk = rtp_session_recvm_with_ts(rs->sess, rs->rx_user_ts);
-		if (mblk) {
-			rtp_get_payload(mblk, &mblk->b_rptr);
-			/* hand into receiver */
-			if (rs->rx_cb)
-				rs->rx_cb(rs, mblk->b_rptr,
-					  mblk->b_wptr - mblk->b_rptr,
-					  rtp_get_markbit(mblk));
-			freemsg(mblk);
-		} else
+		if (!recv_with_cb(rs))
 			LOGP(DLMIB, LOGL_INFO, "recvm_with_ts(%u): ERROR!\n",
 			     rs->rx_user_ts);
 		rs->rx_user_ts += 160;

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id42e85b55eab33c5eb81ac7a2cdea7962b2e30ef
Gerrit-PatchSet: 1
Gerrit-Project: libosmo-abis
Gerrit-Branch: master
Gerrit-Owner: Max <msuraev at sysmocom.de>



More information about the gerrit-log mailing list