view libutil/tfo_msg_enc.c @ 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 05d01e810217
children
line wrap: on
line source

/*
 * The function implemented in this module encodes a GSM 08.62 Extension_Block.
 */

#include <stdint.h>
#include "osmo_bits.h"

/*
 * EFR TRAU parity
 *
 * g(x) = x^3 + x^1 + 1
 */
static const struct osmo_crc8gen_code gsm0860_efr_crc3 = {
	.bits = 3,
	.poly = 0x3,
	.init = 0x0,
	.remainder = 0x7,
};

void
encode_tfo_ext_words(bits_2_10, bits_12_15, ex, out)
	unsigned bits_2_10, bits_12_15, ex;
	uint16_t *out;
{
	ubit_t crc_in[13];
	uint8_t crc;

	uint16_to_bits(bits_2_10, crc_in, 9);
	uint16_to_bits(bits_12_15, crc_in + 9, 4);
	crc = osmo_crc8gen_compute_bits(&gsm0860_efr_crc3, crc_in, 13);
	out[0] = bits_2_10;
	out[1] = (bits_12_15 << 5) | (crc << 2) | ex;
}