comparison osmo-patches/osmo-bts-rtp-bfi.patch @ 176:f5c4f9a764be

osmo-bts-rtp-bfi.patch: updated version This version of the osmo-bts patch sets the TAF bit correctly in generated RTP BFI packets, correctly generates RTP BFI in the case of FACCH stealing on sysmoBTS, and removes one EFR-specific bogon from sysmoBTS code.
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 17 Feb 2023 18:27:03 -0800
parents 60e2d6379fce
children c76f42e0cd3f
comparison
equal deleted inserted replaced
175:623c64ae6102 176:f5c4f9a764be
1 diff --git a/src/common/l1sap.c b/src/common/l1sap.c 1 diff --git a/src/common/l1sap.c b/src/common/l1sap.c
2 index 8bcd417..bfdc37f 100644 2 index 8bcd417..42c97c4 100644
3 --- a/src/common/l1sap.c 3 --- a/src/common/l1sap.c
4 +++ b/src/common/l1sap.c 4 +++ b/src/common/l1sap.c
5 @@ -1244,6 +1244,12 @@ static bool rtppayload_is_octet_aligned(const uint8_t *rtp_pl, uint8_t payload_l 5 @@ -1244,6 +1244,12 @@ static bool rtppayload_is_octet_aligned(const uint8_t *rtp_pl, uint8_t payload_l
6 6
7 static bool rtppayload_is_valid(struct gsm_lchan *lchan, struct msgb *resp_msg) 7 static bool rtppayload_is_valid(struct gsm_lchan *lchan, struct msgb *resp_msg)
35 - osmo_rtp_skipped_frame(lchan->abis_ip.rtp_socket, fn_ms_adj(fn, lchan)); 35 - osmo_rtp_skipped_frame(lchan->abis_ip.rtp_socket, fn_ms_adj(fn, lchan));
36 - lchan->rtp_tx_marker = true; 36 - lchan->rtp_tx_marker = true;
37 + /* Themyscira change: send explicit BFI packets instead of 37 + /* Themyscira change: send explicit BFI packets instead of
38 + * gaps in the RTP stream. */ 38 + * gaps in the RTP stream. */
39 + bfi[0] = 0xBF; 39 + bfi[0] = 0xBF;
40 + bfi[1] = 0; /* TAF will go here */ 40 + bfi[1] = (fn % 104 == 52); /* TAF */
41 + if (lchan->abis_ip.osmux.use) { 41 + if (lchan->abis_ip.osmux.use) {
42 + lchan_osmux_send_frame(lchan, bfi, 2, 42 + lchan_osmux_send_frame(lchan, bfi, 2,
43 + fn_ms_adj(fn, lchan), lchan->rtp_tx_marker); 43 + fn_ms_adj(fn, lchan), lchan->rtp_tx_marker);
44 + } else if (lchan->abis_ip.rtp_socket) { 44 + } else if (lchan->abis_ip.rtp_socket) {
45 + osmo_rtp_send_frame_ext(lchan->abis_ip.rtp_socket, 45 + osmo_rtp_send_frame_ext(lchan->abis_ip.rtp_socket,
48 + /* clear the marker like in the regular code path */ 48 + /* clear the marker like in the regular code path */
49 + lchan->rtp_tx_marker = false; 49 + lchan->rtp_tx_marker = false;
50 } 50 }
51 51
52 lchan->tch.last_fn = fn; 52 lchan->tch.last_fn = fn;
53 diff --git a/src/osmo-bts-sysmo/l1_if.c b/src/osmo-bts-sysmo/l1_if.c
54 index 5c99824..e35fc2e 100644
55 --- a/src/osmo-bts-sysmo/l1_if.c
56 +++ b/src/osmo-bts-sysmo/l1_if.c
57 @@ -981,6 +981,10 @@ static int handle_ph_data_ind(struct femtol1_hdl *fl1, GsmL1_PhDataInd_t *data_i
58 return rc;
59 }
60
61 + /* Themyscira addition: empty RTP "ticks" on FACCH */
62 + if (data_ind->sapi == GsmL1_Sapi_FacchF)
63 + l1if_tch_rx_facch(trx, chan_nr, l1p_msg);
64 +
65 /* fill L1SAP header */
66 sap_msg = l1sap_msgb_alloc(data_ind->msgUnitParam.u8Size);
67 l1sap = msgb_l1sap_prim(sap_msg);
68 diff --git a/src/osmo-bts-sysmo/l1_if.h b/src/osmo-bts-sysmo/l1_if.h
69 index 8691eef..5b2da04 100644
70 --- a/src/osmo-bts-sysmo/l1_if.h
71 +++ b/src/osmo-bts-sysmo/l1_if.h
72 @@ -129,6 +129,8 @@ int l1if_tch_encode(struct gsm_lchan *lchan, uint8_t *data, uint8_t *len,
73 const uint8_t *rtp_pl, unsigned int rtp_pl_len, uint32_t fn,
74 bool use_cache, bool marker);
75 int l1if_tch_rx(struct gsm_bts_trx *trx, uint8_t chan_nr, struct msgb *l1p_msg);
76 +int l1if_tch_rx_facch(struct gsm_bts_trx *trx, uint8_t chan_nr,
77 + struct msgb *l1p_msg);
78 int l1if_tch_fill(struct gsm_lchan *lchan, uint8_t *l1_buffer);
79 struct msgb *gen_empty_tch_msg(struct gsm_lchan *lchan, uint32_t fn);
80
81 diff --git a/src/osmo-bts-sysmo/tch.c b/src/osmo-bts-sysmo/tch.c
82 index a390c8c..f38d9fe 100644
83 --- a/src/osmo-bts-sysmo/tch.c
84 +++ b/src/osmo-bts-sysmo/tch.c
85 @@ -131,12 +131,16 @@ static struct msgb *l1_to_rtppayload_efr(uint8_t *l1_payload,
86
87 cur[0] |= 0xC0;
88 #endif /* USE_L1_RTP_MODE */
89 +
90 +/* this code is a bogon: osmo_amr_rtp_dec() won't grok EFR RTP format! */
91 +#if 0
92 enum osmo_amr_type ft;
93 enum osmo_amr_quality bfi;
94 uint8_t cmr;
95 int8_t sti, cmi;
96 osmo_amr_rtp_dec(l1_payload, payload_len, &cmr, &cmi, &ft, &bfi, &sti);
97 lchan_set_marker(ft == AMR_GSM_EFR_SID, lchan);
98 +#endif
99
100 return msg;
101 }
102 @@ -630,6 +634,38 @@ err_payload_match:
103 return -EINVAL;
104 }
105
106 +/*
107 + * The following function is a Themyscira Wireless addition: we want to have
108 + * an RTP packet sent out on *every* 20 ms "tick", even during times when
109 + * TCH was stolen for FACCH. During FACCH stealing times, it appears that
110 + * sysmoBTS PHY sends GsmL1_Sapi_FacchF and no GsmL1_Sapi_TchF, and with
111 + * the original code l1if_tch_rx(), the function that feeds "ticks" to the
112 + * RTP output mechanism, was never called. Our added l1if_tch_rx_facch()
113 + * function sends an empty payload to the upper layers, and we call it
114 + * from the GsmL1_Sapi_FacchF code path.
115 + */
116 +int l1if_tch_rx_facch(struct gsm_bts_trx *trx, uint8_t chan_nr,
117 + struct msgb *l1p_msg)
118 +{
119 + GsmL1_Prim_t *l1p = msgb_l1prim(l1p_msg);
120 + GsmL1_PhDataInd_t *data_ind = &l1p->u.phDataInd;
121 + struct msgb *rmsg = NULL;
122 + struct gsm_lchan *lchan = &trx->ts[L1SAP_CHAN2TS(chan_nr)].lchan[l1sap_chan2ss(chan_nr)];
123 +
124 + if (is_recv_only(lchan->abis_ip.speech_mode))
125 + return -EAGAIN;
126 +
127 + LOGPFN(DL1P, LOGL_DEBUG, data_ind->u32Fn, "chan_nr %d Rx FACCH\n", chan_nr);
128 + /* Push empty payload to upper layers */
129 + rmsg = msgb_alloc_headroom(256, 128, "L1P-to-RTP");
130 + return add_l1sap_header(trx, rmsg, lchan, chan_nr, data_ind->u32Fn,
131 + data_ind->measParam.fBer * 10000,
132 + data_ind->measParam.fLinkQuality * 10,
133 + 0, /* suppress RSSI like in osmo-bts-trx */
134 + data_ind->measParam.i16BurstTiming * 64,
135 + 0);
136 +}
137 +
138 struct msgb *gen_empty_tch_msg(struct gsm_lchan *lchan, uint32_t fn)
139 {
140 struct msgb *msg;