falconia has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/libosmo-abis/+/41158?usp=email )


Change subject: trau/clearmode.h: add OSMO_CLEARMODE_20MS definition
......................................................................

trau/clearmode.h: add OSMO_CLEARMODE_20MS definition

RFC4040_RTP_PLEN was previously defined privately in OsmoBTS and
in trau_rtp_conv.c module in this library, but there was no official
definition in any of Osmocom headers.  Add <osmocom/trau/clearmode.h>
header with OSMO_CLEARMODE_20MS definition.

Change-Id: I4b2e49b085574336820468dc8cfb8e32377788bf
---
M include/Makefile.am
A include/osmocom/trau/clearmode.h
M src/trau/trau_rtp_conv.c
3 files changed, 38 insertions(+), 16 deletions(-)



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

diff --git a/include/Makefile.am b/include/Makefile.am
index e9820c8..565e3cb 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -24,6 +24,7 @@
        osmocom/abis/trau_frame.h \
        osmocom/abis/unixsocket_proto.h \
        osmocom/abis/version.h \
+       osmocom/trau/clearmode.h \
        osmocom/trau/csd_ra2.h \
        osmocom/trau/csd_raa_prime.h \
        osmocom/trau/tfo_frame.h \
diff --git a/include/osmocom/trau/clearmode.h b/include/osmocom/trau/clearmode.h
new file mode 100644
index 0000000..60fbc5a
--- /dev/null
+++ b/include/osmocom/trau/clearmode.h
@@ -0,0 +1,23 @@
+/*
+ * This header file contains some definitions for CSD in CLEARMODE RTP
+ * representation.
+ *
+ * Author: Mychaela N. Falconia <[email protected]>, 2025 - however,
+ * Mother Mychaela's contributions are NOT subject to copyright.
+ * No rights reserved, all rights relinquished.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#pragma once
+
+/* RFC4040 CLEARMODE RTP payload length for 20 ms as specified in TS 48.103 */
+#define        OSMO_CLEARMODE_20MS     160
diff --git a/src/trau/trau_rtp_conv.c b/src/trau/trau_rtp_conv.c
index f2e0022..f670578 100644
--- a/src/trau/trau_rtp_conv.c
+++ b/src/trau/trau_rtp_conv.c
@@ -30,12 +30,10 @@

 #include <osmocom/trau/trau_frame.h>
 #include <osmocom/trau/trau_rtp.h>
+#include <osmocom/trau/clearmode.h>
 #include <osmocom/trau/csd_ra2.h>
 #include <osmocom/trau/csd_raa_prime.h>

-/* RFC4040 "clearmode" RTP payload length */
-#define RFC4040_RTP_PLEN 160
-
 /* this corresponds to the bit-lengths of the individual codec
  * parameters as indicated in Table 1.1 of TS 46.010 */
 static const uint8_t gsm_fr_map[] = {
@@ -1304,7 +1302,7 @@
        /* function interface preliminaries */
        if (tf->type != OSMO_TRAU16_FT_DATA)
                return -EINVAL;
-       if (out_len < RFC4040_RTP_PLEN)
+       if (out_len < OSMO_CLEARMODE_20MS)
                return -ENOSPC;

        /* Is it TCH/F9.6 with 16 kbit/s IR,
@@ -1319,7 +1317,7 @@
                trau2v110_ir8(out + 80, tf->d_bits + 63 * 2);
        }

-       return RFC4040_RTP_PLEN;
+       return OSMO_CLEARMODE_20MS;
 }

 static int trau2rtp_data_hr16(uint8_t *out, size_t out_len,
@@ -1328,7 +1326,7 @@
        /* function interface preliminaries */
        if (tf->type != OSMO_TRAU16_FT_DATA_HR)
                return -EINVAL;
-       if (out_len < RFC4040_RTP_PLEN)
+       if (out_len < OSMO_CLEARMODE_20MS)
                return -ENOSPC;

        /* Note that Osmocom trau_frame decoding and encoding API
@@ -1338,7 +1336,7 @@
        trau2v110_ir8(out, tf->d_bits);
        trau2v110_ir8(out + 80, tf->d_bits + 63);

-       return RFC4040_RTP_PLEN;
+       return OSMO_CLEARMODE_20MS;
 }

 static int trau2rtp_data_hr8(uint8_t *out, size_t out_len,
@@ -1347,13 +1345,13 @@
        /* function interface preliminaries */
        if (tf->type != OSMO_TRAU8_DATA)
                return -EINVAL;
-       if (out_len < RFC4040_RTP_PLEN)
+       if (out_len < OSMO_CLEARMODE_20MS)
                return -ENOSPC;

        trau2v110_ir8(out, tf->d_bits);
        trau2v110_ir8(out + 80, tf->d_bits + 63);

-       return RFC4040_RTP_PLEN;
+       return OSMO_CLEARMODE_20MS;
 }

 static int trau2rtp_edata(uint8_t *out, size_t out_len,
@@ -1362,7 +1360,7 @@
        /* function interface preliminaries */
        if (tf->type != OSMO_TRAU16_FT_EDATA)
                return -EINVAL;
-       if (out_len < RFC4040_RTP_PLEN)
+       if (out_len < OSMO_CLEARMODE_20MS)
                return -ENOSPC;

        /* Per TS 48.020 section 11.1:
@@ -1370,7 +1368,7 @@
         * A-TRAU bit C5 comes from E-TRAU bit C6 */
        osmo_csd144_to_atrau_ra2(out, tf->m_bits, tf->d_bits, 1, tf->c_bits[5]);

-       return RFC4040_RTP_PLEN;
+       return OSMO_CLEARMODE_20MS;
 }
 
 /*
@@ -1436,11 +1434,11 @@
 {
        ubit_t ra_bits[80 * 2];

-       if (data_len != RFC4040_RTP_PLEN)
+       if (data_len != OSMO_CLEARMODE_20MS)
                goto idle_fill;

        /* reverse RA2 first */
-       osmo_csd_ra2_8k_unpack(ra_bits, data, RFC4040_RTP_PLEN);
+       osmo_csd_ra2_8k_unpack(ra_bits, data, OSMO_CLEARMODE_20MS);

        /* enforce two properly aligned V.110 frames */
        if (!check_v110_align(ra_bits))
@@ -1464,11 +1462,11 @@
 {
        ubit_t ra_bits[80 * 4];

-       if (data_len != RFC4040_RTP_PLEN)
+       if (data_len != OSMO_CLEARMODE_20MS)
                goto idle_fill;

        /* reverse RA2 first */
-       osmo_csd_ra2_16k_unpack(ra_bits, data, RFC4040_RTP_PLEN);
+       osmo_csd_ra2_16k_unpack(ra_bits, data, OSMO_CLEARMODE_20MS);

        /* enforce 4 properly aligned V.110 frames */
        if (!check_v110_align(ra_bits))
@@ -1606,7 +1604,7 @@
        /* set C6=0: indicate good reception of TRAU-UL frames */
        tf->c_bits[5] = 0;

-       if (data_len == RFC4040_RTP_PLEN &&
+       if (data_len == OSMO_CLEARMODE_20MS &&
            osmo_csd144_from_atrau_ra2(tf->m_bits, tf->d_bits, &atrau_c4, NULL,
                                        data) >= 0) {
                /* We got good A-TRAU input.  3GPP specs define the following

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

Gerrit-MessageType: newchange
Gerrit-Project: libosmo-abis
Gerrit-Branch: master
Gerrit-Change-Id: I4b2e49b085574336820468dc8cfb8e32377788bf
Gerrit-Change-Number: 41158
Gerrit-PatchSet: 1
Gerrit-Owner: falconia <[email protected]>

Reply via email to