changeset 199:e6c7ced3c031

mgw: accept zero-length RTP payload as BFI Mainline OsmoBTS now has an option (rtp continuous-streaming) that causes it to emit an RTP packet every 20 ms without gaps, sending a BFI marker in the form of zero-length RTP payload when it has nothing else to send. These codec-independent BFI markers don't indicate TAF, but this provision is a good start. Accept this BFI packet format in themwi-mgw.
author Mychaela Falconia <falcon@freecalypso.org>
date Wed, 29 Mar 2023 20:23:43 -0800
parents cf1ba5d65188
children 834656633fa0
files mgw/gsm2pstn.c
diffstat 1 files changed, 7 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mgw/gsm2pstn.c	Wed Mar 29 20:06:40 2023 -0800
+++ b/mgw/gsm2pstn.c	Wed Mar 29 20:23:43 2023 -0800
@@ -59,7 +59,7 @@
 		}
 		return;
 	}
-	if (pktsize < RTP_PACKET_SIZE_BFI) {
+	if (pktsize < RTP_PACKET_HDR_SIZE) {
 bad_rtp_pkt:	if (!(ep->g2p_err_flags & ERR_BAD_RTP_PACKET)) {
 			syslog(LOG_ERR, "Rx bad RTP packet on GSM side");
 			ep->g2p_err_flags |= ERR_BAD_RTP_PACKET;
@@ -71,11 +71,15 @@
 	if ((pkt.m_pt & 0x7F) != ep->gsm_payload_type)
 		goto bad_rtp_pkt;
 	if (pktsize == ep->gsm_rtp_pkt_size &&
-	    (pkt.payload[0] & 0xF0) == ep->gsm_payload_magic)
+	    (pkt.payload[0] & 0xF0) == ep->gsm_payload_magic) {
 		bfi = 0;
-	else if (pktsize == RTP_PACKET_SIZE_BFI && pkt.payload[0] == 0xBF) {
+		taf = 0;
+	} else if (pktsize == RTP_PACKET_SIZE_BFI && pkt.payload[0] == 0xBF) {
 		bfi = 1;
 		taf = pkt.payload[1] & 1;
+	} else if (pktsize == RTP_PACKET_HDR_SIZE) {
+		bfi = 1;
+		taf = 0;
 	} else
 		goto bad_rtp_pkt;
 	if (ep->g2p_state && pkt.ssrc != ep->g2p_ssrc) {