From: Max msuraev@sysmocom.de
Previously it was possible to send RTP data to port 0. This produce multiple errors during the beginning of RTP transmission.
To address this OSMO_RTP_F_DISABLED flag was introduced. It's set by default for all new RTP sessions. It can be manually unset after the call to osmo_rtp_socket_create(). When the flag is set it prevents transmission and reception of RTP frames for the session. The flag is unset automatically in osmo_rtp_socket_connect() when session is bound to non-zero remote port.
Fixes: OS#1662 --- include/osmocom/trau/osmo_ortp.h | 1 + src/trau/osmo_ortp.c | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/include/osmocom/trau/osmo_ortp.h b/include/osmocom/trau/osmo_ortp.h index c02cca8..2ca9cfc 100644 --- a/include/osmocom/trau/osmo_ortp.h +++ b/include/osmocom/trau/osmo_ortp.h @@ -29,6 +29,7 @@ enum osmo_rtp_param {
/*! \brief Flag to indicate the socket is in polling-only mode */ #define OSMO_RTP_F_POLL 0x0001 +#define OSMO_RTP_F_DISABLED 2
/*! \brief A structure representing one RTP socket */ struct osmo_rtp_socket { diff --git a/src/trau/osmo_ortp.c b/src/trau/osmo_ortp.c index 65ec269..22c5856 100644 --- a/src/trau/osmo_ortp.c +++ b/src/trau/osmo_ortp.c @@ -149,6 +149,8 @@ static void ortp_sig_cb_ts(RtpSession *rs, void *data) 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) { @@ -313,7 +315,7 @@ struct osmo_rtp_socket *osmo_rtp_socket_create(void *talloc_ctx, unsigned int fl if (!rs) return NULL;
- rs->flags = flags; + rs->flags = OSMO_RTP_F_DISABLED | flags; rs->sess = rtp_session_new(RTP_SESSION_SENDRECV); if (!rs->sess) { talloc_free(rs); @@ -382,11 +384,16 @@ 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 rc; - + if (!port) { + LOGP(DLMIB, LOGL_INFO, "osmo_rtp_socket_connect() refused to " + "set remote %s:%u\n", ip, port); + return 0; + } /* enable the use of connect() so later getsockname() will * actually return the IP address that was chosen for the local * sid of the connection */ rtp_session_set_connected_mode(rs->sess, 1); + rs->flags &= ~OSMO_RTP_F_DISABLED;
rc = rtp_session_set_remote_addr(rs->sess, ip, port); if (rc < 0) @@ -411,6 +418,9 @@ int osmo_rtp_send_frame(struct osmo_rtp_socket *rs, const uint8_t *payload, mblk_t *mblk; int rc;
+ if (rs->flags & OSMO_RTP_F_DISABLED) + return 0; + mblk = rtp_session_create_packet(rs->sess, RTP_FIXED_HEADER_SIZE, payload, payload_len); if (!mblk)
From: Max msuraev@sysmocom.de
Force use of random RTCP port if random RTP port is used. Before port 0 could be selected for RTCP. --- src/trau/osmo_ortp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/trau/osmo_ortp.c b/src/trau/osmo_ortp.c index 22c5856..5ab5bf5 100644 --- a/src/trau/osmo_ortp.c +++ b/src/trau/osmo_ortp.c @@ -357,7 +357,8 @@ int osmo_rtp_socket_bind(struct osmo_rtp_socket *rs, const char *ip, int port) { int rc; #if HAVE_ORTP_021 - rc = rtp_session_set_local_addr(rs->sess, ip, port, port+1); + int rtcp = (-1 != port) ? port + 1 : -1; + rc = rtp_session_set_local_addr(rs->sess, ip, port, rtcp); #else rc = rtp_session_set_local_addr(rs->sess, ip, port); #endif
From: Max msuraev@sysmocom.de
ortp: according to oRTP documentation rtp_session_set_connected_mode() uses the address set by rtp_session_set_remote_addr() - move the function call accordingly.
Fixes: OS#1661 --- src/trau/osmo_ortp.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/src/trau/osmo_ortp.c b/src/trau/osmo_ortp.c index 5ab5bf5..3313798 100644 --- a/src/trau/osmo_ortp.c +++ b/src/trau/osmo_ortp.c @@ -390,16 +390,17 @@ int osmo_rtp_socket_connect(struct osmo_rtp_socket *rs, const char *ip, uint16_t "set remote %s:%u\n", ip, port); return 0; } + + rc = rtp_session_set_remote_addr(rs->sess, ip, port); + if (rc < 0) + return rc; + /* enable the use of connect() so later getsockname() will * actually return the IP address that was chosen for the local * sid of the connection */ rtp_session_set_connected_mode(rs->sess, 1); rs->flags &= ~OSMO_RTP_F_DISABLED;
- rc = rtp_session_set_remote_addr(rs->sess, ip, port); - if (rc < 0) - return rc; - if (rs->flags & OSMO_RTP_F_POLL) return rc; else
On 29 Apr 2016, at 12:39, msuraev@sysmocom.de wrote:
From: Max msuraev@sysmocom.de
did you test:
* sysmoBTS with old oRTP after your change? What was the result?
holger
Yes, sure. The voice was working as expected.
On 04/29/2016 01:58 PM, Holger Freyther wrote:
On 29 Apr 2016, at 12:39, msuraev@sysmocom.de wrote:
From: Max msuraev@sysmocom.de
did you test:
- sysmoBTS with old oRTP after your change? What was the result?
holger