falconia has submitted this change. ( 
https://gerrit.osmocom.org/c/osmo-bts/+/42166?usp=email )

Change subject: RTP: use new abstraction layer instead of direct osmo_ortp
......................................................................

RTP: use new abstraction layer instead of direct osmo_ortp

As of this patch in the series, the RTP library in active use
is still always ortp, but all BTS code now accesses it through
the new abstraction layer, paving the way for twrtp option.

Related: OS#6474
Change-Id: I5e3de4f84e8e8875437cb94a9b8feeb07f9cc1cf
---
M include/osmo-bts/l1sap.h
M include/osmo-bts/lchan.h
M src/common/l1sap.c
M src/common/lchan.c
M src/common/msg_utils.c
M src/common/rsl.c
M src/common/vty.c
7 files changed, 45 insertions(+), 62 deletions(-)

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




diff --git a/include/osmo-bts/l1sap.h b/include/osmo-bts/l1sap.h
index 34259bd..b90992a 100644
--- a/include/osmo-bts/l1sap.h
+++ b/include/osmo-bts/l1sap.h
@@ -93,7 +93,7 @@
        uint16_t arfcn, uint8_t block_nr, const uint8_t *data, uint8_t len);

 /* call-back function for incoming RTP */
-void l1sap_rtp_rx_cb(struct osmo_rtp_socket *rs, const uint8_t *rtp_pl,
+void l1sap_rtp_rx_cb(struct rtp_abst_socket *rs, const uint8_t *rtp_pl,
                     unsigned int rtp_pl_len, uint16_t seq_number,
                     uint32_t timestamp, bool marker);

diff --git a/include/osmo-bts/lchan.h b/include/osmo-bts/lchan.h
index 2b19c28..071197d 100644
--- a/include/osmo-bts/lchan.h
+++ b/include/osmo-bts/lchan.h
@@ -190,7 +190,7 @@
                        /* Used to build rtp messages we send to osmux */
                        struct osmo_rtp_handle *rtpst;
                } osmux;
-               struct osmo_rtp_socket *rtp_socket;
+               struct rtp_abst_socket *rtp_socket;
        } abis_ip;

        char *name;
diff --git a/src/common/l1sap.c b/src/common/l1sap.c
index e77f602..3d0263f 100644
--- a/src/common/l1sap.c
+++ b/src/common/l1sap.c
@@ -41,8 +41,6 @@

 #include <osmocom/codec/codec.h>

-#include <osmocom/trau/osmo_ortp.h>
-
 #include <osmo-bts/logging.h>
 #include <osmo-bts/gsm_data.h>
 #include <osmo-bts/l1sap.h>
@@ -56,6 +54,7 @@
 #include <osmo-bts/bts_model.h>
 #include <osmo-bts/handover.h>
 #include <osmo-bts/msg_utils.h>
+#include <osmo-bts/rtp_abstract.h>
 #include <osmo-bts/rtp_input_preen.h>
 #include <osmo-bts/pcuif_proto.h>
 #include <osmo-bts/cbch.h>
@@ -1532,10 +1531,8 @@
        OSMO_ASSERT(bits_per_20ms != 0);

        for (i = 0; i < ARRAY_SIZE(input_msg); i++) {
-               if (!lchan->loopback && lchan->abis_ip.rtp_socket) {
-                       osmo_rtp_socket_poll(lchan->abis_ip.rtp_socket);
-                       lchan->abis_ip.rtp_socket->rx_user_ts += 
GSM_RTP_DURATION;
-               }
+               if (!lchan->loopback && lchan->abis_ip.rtp_socket)
+                       rtp_abst_socket_poll(lchan->abis_ip.rtp_socket);
                input_msg[i] = msgb_dequeue_count(&lchan->dl_tch_queue,
                                                  &lchan->dl_tch_queue_len);
        }
@@ -1621,10 +1618,8 @@
        /* Input processing happens every 40 ms */
        if (csd_tchf48_nt_e2_map[fn % 26] == 0) {
                for (i = 0; i < 2; i++) {
-                       if (!lchan->loopback && lchan->abis_ip.rtp_socket) {
-                               osmo_rtp_socket_poll(lchan->abis_ip.rtp_socket);
-                               lchan->abis_ip.rtp_socket->rx_user_ts += 
GSM_RTP_DURATION;
-                       }
+                       if (!lchan->loopback && lchan->abis_ip.rtp_socket)
+                               rtp_abst_socket_poll(lchan->abis_ip.rtp_socket);
                        input_msg = msgb_dequeue_count(&lchan->dl_tch_queue,
                                                       
&lchan->dl_tch_queue_len);
                        if (input_msg) {
@@ -1735,16 +1730,8 @@
            lchan->csd_mode == LCHAN_CSD_M_NT)
                return tch_rts_ind_tchf48_nt(trx, lchan, rts_ind);

-       if (!lchan->loopback && lchan->abis_ip.rtp_socket) {
-               osmo_rtp_socket_poll(lchan->abis_ip.rtp_socket);
-               /* FIXME: we _assume_ that we never miss TDMA
-                * frames and that we always get to this point
-                * for every to-be-transmitted voice frame.  A
-                * better solution would be to compute
-                * rx_user_ts based on how many TDMA frames have
-                * elapsed since the last call */
-               lchan->abis_ip.rtp_socket->rx_user_ts += GSM_RTP_DURATION;
-       }
+       if (!lchan->loopback && lchan->abis_ip.rtp_socket)
+               rtp_abst_socket_poll(lchan->abis_ip.rtp_socket);
        /* get a msgb from the dl_tx_queue */
        resp_msg = msgb_dequeue_count(&lchan->dl_tch_queue, 
&lchan->dl_tch_queue_len);
        if (!resp_msg) {
@@ -2097,12 +2084,13 @@
 {
        struct gsm_bts *bts = lchan->ts->trx->bts;

+       fn_ms_adj(fn, lchan);   /* for diagnostics only */
        if (lchan->abis_ip.osmux.use) {
                lchan_osmux_send_frame(lchan, rtp_pl, rtp_pl_len,
-                                      fn_ms_adj(fn, lchan), 
lchan->rtp_tx_marker);
+                                      GSM_RTP_DURATION, lchan->rtp_tx_marker);
        } else if (lchan->abis_ip.rtp_socket != NULL) {
-               osmo_rtp_send_frame_ext(lchan->abis_ip.rtp_socket,
-                       rtp_pl, rtp_pl_len, fn_ms_adj(fn, lchan), 
lchan->rtp_tx_marker);
+               rtp_abst_send_frame(lchan->abis_ip.rtp_socket,
+                       rtp_pl, rtp_pl_len, lchan->rtp_tx_marker);
                rate_ctr_inc2(bts->ctrs, BTS_CTR_RTP_TX_TOTAL);
                if (lchan->rtp_tx_marker)
                        rate_ctr_inc2(bts->ctrs, BTS_CTR_RTP_TX_MARKER);
@@ -2120,10 +2108,8 @@
        struct gsm_bts *bts = lchan->ts->trx->bts;

        if (lchan->abis_ip.rtp_socket != NULL) {
-               osmo_rtp_send_frame_ext(lchan->abis_ip.rtp_socket,
-                                       rtp_pl, rtp_pl_len,
-                                       GSM_RTP_DURATION,
-                                       lchan->rtp_tx_marker);
+               rtp_abst_send_frame(lchan->abis_ip.rtp_socket,
+                       rtp_pl, rtp_pl_len, lchan->rtp_tx_marker);
                rate_ctr_inc2(bts->ctrs, BTS_CTR_RTP_TX_TOTAL);
                if (lchan->rtp_tx_marker)
                        rate_ctr_inc2(bts->ctrs, BTS_CTR_RTP_TX_MARKER);
@@ -2339,10 +2325,11 @@
         * in the outgoing RTP stream. */
        LOGPLCGT(lchan, g_time, DRTP, LOGL_DEBUG,
                 "Skipping RTP frame with lost payload\n");
+       fn_ms_adj(fn, lchan);   /* for diagnostics only */
        if (lchan->abis_ip.osmux.use)
-               lchan_osmux_skipped_frame(lchan, fn_ms_adj(fn, lchan));
+               lchan_osmux_skipped_frame(lchan, GSM_RTP_DURATION);
        else if (lchan->abis_ip.rtp_socket)
-               osmo_rtp_skipped_frame(lchan->abis_ip.rtp_socket, fn_ms_adj(fn, 
lchan));
+               rtp_abst_skipped_frame(lchan->abis_ip.rtp_socket);
        lchan->rtp_tx_marker = true;
 }

@@ -2881,7 +2868,7 @@
 }

 /*! \brief call-back function for incoming RTP */
-void l1sap_rtp_rx_cb(struct osmo_rtp_socket *rs, const uint8_t *rtp_pl,
+void l1sap_rtp_rx_cb(struct rtp_abst_socket *rs, const uint8_t *rtp_pl,
                      unsigned int rtp_pl_len, uint16_t seq_number,
                     uint32_t timestamp, bool marker)
 {
diff --git a/src/common/lchan.c b/src/common/lchan.c
index b115e1e..1e8b501 100644
--- a/src/common/lchan.c
+++ b/src/common/lchan.c
@@ -23,10 +23,9 @@

 #include <osmocom/core/logging.h>

-#include <osmocom/trau/osmo_ortp.h>
-
 #include <osmo-bts/logging.h>
 #include <osmo-bts/lchan.h>
+#include <osmo-bts/rtp_abstract.h>
 #include <osmo-bts/bts.h>
 #include <osmo-bts/rsl.h>
 #include <osmo-bts/pcu_if.h>
@@ -216,8 +215,8 @@

        if (lchan->abis_ip.rtp_socket) {
                rsl_tx_ipac_dlcx_ind(lchan, RSL_ERR_NORMAL_UNSPEC);
-               osmo_rtp_socket_log_stats(lchan->abis_ip.rtp_socket, DRTP, 
LOGL_INFO,
-                       "Closing RTP socket on Channel Release ");
+               rtp_abst_socket_log_stats(lchan->abis_ip.rtp_socket,
+                                         "Channel Release");
                lchan_rtp_socket_free(lchan);
        } else if (lchan->abis_ip.osmux.use) {
                lchan_osmux_release(lchan);
@@ -537,7 +536,7 @@
        }
 }

-static int bind_rtp(struct gsm_bts *bts, struct osmo_rtp_socket *rs, const 
char *ip)
+static int bind_rtp(struct gsm_bts *bts, struct rtp_abst_socket *rs, const 
char *ip)
 {
        int rc;
        unsigned int i;
@@ -549,7 +548,7 @@
                if (bts->rtp_port_range_next >= bts->rtp_port_range_end)
                        bts->rtp_port_range_next = bts->rtp_port_range_start;

-               rc = osmo_rtp_socket_bind(rs, ip, bts->rtp_port_range_next);
+               rc = rtp_abst_socket_bind(rs, ip, bts->rtp_port_range_next);

                bts->rtp_port_range_next += 2;

@@ -557,12 +556,12 @@
                        continue;

                if (bts->rtp_ip_dscp != -1) {
-                       if (osmo_rtp_socket_set_dscp(rs, bts->rtp_ip_dscp))
+                       if (rtp_abst_socket_set_dscp(rs, bts->rtp_ip_dscp))
                                LOGP(DRSL, LOGL_ERROR, "failed to set DSCP=%d: 
%s\n",
                                        bts->rtp_ip_dscp, strerror(errno));
                }
                if (bts->rtp_priority != -1) {
-                       if (osmo_rtp_socket_set_priority(rs, bts->rtp_priority))
+                       if (rtp_abst_socket_set_priority(rs, bts->rtp_priority))
                                LOGP(DRSL, LOGL_ERROR, "failed to set socket 
priority %d: %s\n",
                                        bts->rtp_priority, strerror(errno));
                }
@@ -587,8 +586,9 @@
        /* FIXME: select default value depending on speech_mode */
        //if (!payload_type)
        lchan->tch.last_fn = LCHAN_FN_DUMMY;
-       lchan->abis_ip.rtp_socket = osmo_rtp_socket_create(lchan->ts->trx,
-                                                       OSMO_RTP_F_POLL);
+       lchan->abis_ip.rtp_socket = rtp_abst_socket_create(lchan->ts->trx,
+                                                          false,
+                                                          bts->twjit_cfg);

        if (!lchan->abis_ip.rtp_socket) {
                LOGPLCHAN(lchan, DRTP, LOGL_ERROR, "IPAC Failed to create 
RTP/RTCP sockets\n");
@@ -599,10 +599,8 @@
                return -ENOTCONN;
        }

-       rc = osmo_rtp_socket_set_param(lchan->abis_ip.rtp_socket,
-                                      bts->rtp_jitter_adaptive ?
-                                      OSMO_RTP_P_JIT_ADAP :
-                                      OSMO_RTP_P_JITBUF,
+       rc = rtp_abst_socket_set_param(lchan->abis_ip.rtp_socket,
+                                      bts->rtp_jitter_adaptive,
                                       bts->rtp_jitter_buf_ms);
        if (rc < 0)
                LOGPLCHAN(lchan, DRTP, LOGL_ERROR,
@@ -626,7 +624,7 @@

        /* Ensure RTCP SDES contains some useful information */
        snprintf(cname, sizeof(cname), "bts@%s", bind_ip);
-       osmo_rtp_set_source_desc(lchan->abis_ip.rtp_socket, cname,
+       rtp_abst_set_source_desc(lchan->abis_ip.rtp_socket, cname,
                                 gsm_lchan_name(lchan), NULL, NULL,
                                 gsm_trx_unit_id(lchan->ts->trx),
                                 "OsmoBTS-" PACKAGE_VERSION, NULL);
@@ -640,8 +638,8 @@
        int bound_port = 0;
        int rc;

-       rc = osmo_rtp_socket_connect(lchan->abis_ip.rtp_socket,
-                                    inet_ntoa(*ia), connect_port);
+       rc = rtp_abst_socket_connect(lchan->abis_ip.rtp_socket,
+                                    ia, connect_port);
        if (rc < 0) {
                LOGPLCHAN(lchan, DRTP, LOGL_ERROR, "Failed to connect RTP/RTCP 
sockets\n");
                return -ECONNREFUSED;
@@ -650,7 +648,7 @@
        lchan->abis_ip.connect_ip = ntohl(ia->s_addr);
        lchan->abis_ip.connect_port = connect_port;

-       rc = osmo_rtp_get_bound_ip_port(lchan->abis_ip.rtp_socket,
+       rc = rtp_abst_get_bound_ip_port(lchan->abis_ip.rtp_socket,
                                        &lchan->abis_ip.bound_ip,
                                        &bound_port);
        if (rc < 0)
@@ -661,7 +659,7 @@

 void lchan_rtp_socket_free(struct gsm_lchan *lchan)
 {
-       osmo_rtp_socket_free(lchan->abis_ip.rtp_socket);
+       rtp_abst_socket_free(lchan->abis_ip.rtp_socket);
        lchan->abis_ip.rtp_socket = NULL;
        msgb_queue_free(&lchan->dl_tch_queue);
        lchan->dl_tch_queue_len = 0;
diff --git a/src/common/msg_utils.c b/src/common/msg_utils.c
index 04a0c34..113371f 100644
--- a/src/common/msg_utils.c
+++ b/src/common/msg_utils.c
@@ -24,13 +24,13 @@
 #include <osmo-bts/amr.h>
 #include <osmo-bts/rsl.h>
 #include <osmo-bts/bts.h>
+#include <osmo-bts/rtp_abstract.h>

 #include <osmocom/gsm/protocol/ipaccess.h>
 #include <osmocom/gsm/protocol/gsm_12_21.h>
 #include <osmocom/gsm/abis_nm.h>
 #include <osmocom/core/msgb.h>
 #include <osmocom/core/fsm.h>
-#include <osmocom/trau/osmo_ortp.h>

 #include <arpa/inet.h>
 #include <errno.h>
diff --git a/src/common/rsl.c b/src/common/rsl.c
index 8d9dd56..88a5f17 100644
--- a/src/common/rsl.c
+++ b/src/common/rsl.c
@@ -39,7 +39,6 @@
 #include <osmocom/gsm/protocol/gsm_08_58.h>
 #include <osmocom/gsm/protocol/gsm_04_08.h>
 #include <osmocom/gsm/protocol/ipaccess.h>
-#include <osmocom/trau/osmo_ortp.h>

 #include <osmo-bts/logging.h>
 #include <osmo-bts/gsm_data.h>
@@ -55,6 +54,7 @@
 #include <osmo-bts/cbch.h>
 #include <osmo-bts/l1sap.h>
 #include <osmo-bts/bts_model.h>
+#include <osmo-bts/rtp_abstract.h>
 #include <osmo-bts/pcuif_proto.h>
 #include <osmo-bts/notification.h>
 #include <osmo-bts/asci.h>
@@ -2756,7 +2756,7 @@
        msgb_tv_put(msg, RSL_IE_IPAC_CONN_STAT, sizeof(uint32_t) * 7);

        if (lchan->abis_ip.rtp_socket) {
-               osmo_rtp_socket_stats(lchan->abis_ip.rtp_socket,
+               rtp_abst_socket_stats(lchan->abis_ip.rtp_socket,
                                      &packets_sent, &octets_sent,
                                      &packets_recv, &octets_recv,
                                      &packets_lost, &arrival_jitter);
@@ -3144,13 +3144,13 @@
        if (payload_type) {
                lchan->abis_ip.rtp_payload = *payload_type;
                if (lchan->abis_ip.rtp_socket)
-                       osmo_rtp_socket_set_pt(lchan->abis_ip.rtp_socket,
+                       rtp_abst_socket_set_pt(lchan->abis_ip.rtp_socket,
                                                *payload_type);
        }
        if (payload_type2) {
                lchan->abis_ip.rtp_payload2 = *payload_type2;
                if (lchan->abis_ip.rtp_socket)
-                       osmo_rtp_socket_set_pt(lchan->abis_ip.rtp_socket,
+                       rtp_abst_socket_set_pt(lchan->abis_ip.rtp_socket,
                                                *payload_type2);
        }
        if (speech_mode)
@@ -3184,8 +3184,7 @@

        rc = rsl_tx_ipac_dlcx_ack(lchan, inc_conn_id);
        if (lchan->abis_ip.rtp_socket) {
-               osmo_rtp_socket_log_stats(lchan->abis_ip.rtp_socket, DRTP, 
LOGL_INFO,
-                                         "Closing RTP socket on DLCX ");
+               rtp_abst_socket_log_stats(lchan->abis_ip.rtp_socket, "DLCX");
                lchan_rtp_socket_free(lchan);
        }
        return rc;
diff --git a/src/common/vty.c b/src/common/vty.c
index 461e92f..0411060 100644
--- a/src/common/vty.c
+++ b/src/common/vty.c
@@ -42,7 +42,6 @@
 #include <osmocom/core/gsmtap.h>
 #include <osmocom/core/utils.h>
 #include <osmocom/core/sockaddr_str.h>
-#include <osmocom/trau/osmo_ortp.h>
 #include <osmocom/core/fsm.h>
 #include <osmocom/codec/codec.h>

@@ -62,6 +61,7 @@
 #include <osmo-bts/vty.h>
 #include <osmo-bts/l1sap.h>
 #include <osmo-bts/osmux.h>
+#include <osmo-bts/rtp_abstract.h>

 #define VTY_STR        "Configure the VTY\n"

@@ -2562,9 +2562,8 @@
                        VTY_NEWLINE);
                return CMD_WARNING;
        }
-       rc = osmo_rtp_socket_set_param(lchan->abis_ip.rtp_socket,
-                                 lchan->ts->trx->bts->rtp_jitter_adaptive ?
-                                 OSMO_RTP_P_JIT_ADAP : OSMO_RTP_P_JITBUF,
+       rc = rtp_abst_socket_set_param(lchan->abis_ip.rtp_socket,
+                                 lchan->ts->trx->bts->rtp_jitter_adaptive,
                                  jitbuf_ms);
        if (rc < 0)
                vty_out(vty, "%% error setting jitter parameters: %s%s",

--
To view, visit https://gerrit.osmocom.org/c/osmo-bts/+/42166?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings?usp=email

Gerrit-MessageType: merged
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Change-Id: I5e3de4f84e8e8875437cb94a9b8feeb07f9cc1cf
Gerrit-Change-Number: 42166
Gerrit-PatchSet: 3
Gerrit-Owner: falconia <[email protected]>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: falconia <[email protected]>
Gerrit-Reviewer: fixeria <[email protected]>
Gerrit-Reviewer: pespin <[email protected]>

Reply via email to