Change in libosmo-abis[master]: rtp: Add 'autoconnect' feature to the osmo_rtp_socket

Harald Welte gerrit-no-reply at lists.osmocom.org
Tue Mar 19 13:57:06 UTC 2019


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

Change subject: rtp: Add 'autoconnect' feature to the osmo_rtp_socket
......................................................................

rtp: Add 'autoconnect' feature to the osmo_rtp_socket

The bound RTP socket will wait for incoming RTP packets and as soon as it
sees one, will 'connect' to it, so all replies will go to that sources and
incoming messages from other sources will be discarded. This obviously only
works once.

Change-Id: I5b54ca4296901fcf37794faf29e0b2acca27bd1b
Signed-off-by: Sylvain Munaut <tnt at 246tNt.com>
---
M include/osmocom/trau/osmo_ortp.h
M src/trau/osmo_ortp.c
2 files changed, 23 insertions(+), 0 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Max: Looks good to me, but someone else must approve
  Jenkins Builder: Verified



diff --git a/include/osmocom/trau/osmo_ortp.h b/include/osmocom/trau/osmo_ortp.h
index 5fb2960..54afcf0 100644
--- a/include/osmocom/trau/osmo_ortp.h
+++ b/include/osmocom/trau/osmo_ortp.h
@@ -74,6 +74,7 @@
 struct osmo_rtp_socket *osmo_rtp_socket_create(void *talloc_ctx, unsigned int flags);
 int osmo_rtp_socket_bind(struct osmo_rtp_socket *rs, const char *ip, int port);
 int osmo_rtp_socket_connect(struct osmo_rtp_socket *rs, const char *ip, uint16_t port);
+int osmo_rtp_socket_autoconnect(struct osmo_rtp_socket *rs);
 int osmo_rtp_socket_set_pt(struct osmo_rtp_socket *rs, int payload_type);
 int osmo_rtp_socket_free(struct osmo_rtp_socket *rs);
 int osmo_rtp_skipped_frame(struct osmo_rtp_socket *rs, unsigned int duration);
diff --git a/src/trau/osmo_ortp.c b/src/trau/osmo_ortp.c
index 0eb1661..1d652cb 100644
--- a/src/trau/osmo_ortp.c
+++ b/src/trau/osmo_ortp.c
@@ -468,6 +468,28 @@
 		return osmo_rtp_socket_fdreg(rs);
 }
 
+/*! \brief Automatically associates a RTP socket with the first incoming UDP packet
+ *  \param[in] rs OsmoRTP socket
+ *
+ * The bound RTP socket will wait for incoming RTP packets and as soon as it
+ * sees one, will 'connect' to it, so all replies will go to that sources and
+ * incoming messages from other sources will be discarded. This obviously only
+ * works once.
+ *
+ *  \returns 0 on success, <0 in case of error.
+ */
+int osmo_rtp_socket_autoconnect(struct osmo_rtp_socket *rs)
+{
+	rtp_session_set_symmetric_rtp(rs->sess, 1);
+	rtp_session_set_connected_mode(rs->sess, 1);
+	rs->flags &= ~OSMO_RTP_F_DISABLED;
+
+	if (rs->flags & OSMO_RTP_F_POLL)
+		return 0;
+	else
+		return osmo_rtp_socket_fdreg(rs);
+}
+
 /*! \brief Increment timestamp on a RTP socket without sending any packet
  *  \param[in] rs OsmoRTP socket
  *  \param[in] duration duration in number of RTP clock ticks

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

Gerrit-Project: libosmo-abis
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I5b54ca4296901fcf37794faf29e0b2acca27bd1b
Gerrit-Change-Number: 13203
Gerrit-PatchSet: 2
Gerrit-Owner: tnt <tnt at 246tNt.com>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder (1000002)
Gerrit-Reviewer: Max <msuraev at sysmocom.de>
Gerrit-Reviewer: tnt <tnt at 246tNt.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190319/0ba170a9/attachment.html>


More information about the gerrit-log mailing list