view abis/dl_frames.c @ 32:94f11dc0d474

abis: Rx osmo_trau_sync hooked in
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 13 Aug 2024 22:07:49 +0000
parents 5dd30224b70a
children f0b026615f3b
line wrap: on
line source

/*
 * In this module we generate canned TRAU-DL frames for FR and EFR,
 * which will later be transmitted on Abis when individual subslots
 * come alive.
 */

#include <stdint.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <osmocom/core/bits.h>
#include <osmocom/core/utils.h>
#include <osmocom/trau/trau_frame.h>
#include <osmocom/trau/trau_rtp.h>

#include "dl_frames.h"

ubit_t dl_frame_fr[DL_OUTPUT_BUFLEN];
ubit_t dl_frame_efr[DL_OUTPUT_BUFLEN];

static const uint8_t gsmfr_silence_frame[33] = {
	0xDA, 0xA7, 0xAA, 0xA5, 0x1A,
	0x50, 0x20, 0x38, 0xE4, 0x6D, 0xB9, 0x1B,
	0x50, 0x20, 0x38, 0xE4, 0x6D, 0xB9, 0x1B,
	0x50, 0x20, 0x38, 0xE4, 0x6D, 0xB9, 0x1B,
	0x50, 0x20, 0x38, 0xE4, 0x6D, 0xB9, 0x1B,
};

static const uint8_t efr_dhf_rtp[31] = {
	0xC0, 0x85, 0xEB, 0x49, 0x0F, 0xAA, 0xD6, 0x03,
	0xE3, 0xA1, 0x86, 0x07, 0xB0, 0xC4, 0x2C, 0x08,
	0x04, 0x80, 0x55, 0x80, 0x00, 0x00, 0x00, 0x00,
	0x03, 0x6B, 0x00, 0x00, 0x00, 0x00, 0x00
};

static void gen_dl_fr(void)
{
	struct osmo_trau_frame tf;
	struct osmo_trau2rtp_state st;
	int rc;

	tf.dir = OSMO_TRAU_DIR_DL;
	st.type = OSMO_TRAU16_FT_FR;
	rc = osmo_rtp2trau(&tf, gsmfr_silence_frame, 33, &st);
	OSMO_ASSERT(rc == 0);
	rc = osmo_trau_frame_encode(dl_frame_fr, DL_OUTPUT_BUFLEN, &tf);
	OSMO_ASSERT(rc == DL_OUTPUT_LEN);
}

static void gen_dl_efr(void)
{
	struct osmo_trau_frame tf;
	struct osmo_trau2rtp_state st;
	int rc;

	tf.dir = OSMO_TRAU_DIR_DL;
	st.type = OSMO_TRAU16_FT_EFR;
	rc = osmo_rtp2trau(&tf, efr_dhf_rtp, 31, &st);
	OSMO_ASSERT(rc == 0);
	rc = osmo_trau_frame_encode(dl_frame_efr, DL_OUTPUT_BUFLEN, &tf);
	OSMO_ASSERT(rc == DL_OUTPUT_LEN);
}

void init_canned_dl_frames(void)
{
	gen_dl_fr();
	gen_dl_efr();
}