# HG changeset patch
# User Mychaela Falconia <falcon@freecalypso.org>
# Date 1680150223 28800
# Node ID e6c7ced3c03129285a1645dcfa30c9f6623a7dd3
# Parent  cf1ba5d65188769eebca55c364bd155038ea07df
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.

diff -r cf1ba5d65188 -r e6c7ced3c031 mgw/gsm2pstn.c
--- 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) {