FreeCalypso > hg > e1-fake-trau
diff ft16/dl_frames.c @ 2:5c18cd38c8ad
ft16: import from ice1-trau-tester/abis
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Thu, 29 Aug 2024 13:07:16 +0000 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ft16/dl_frames.c Thu Aug 29 13:07:16 2024 +0000 @@ -0,0 +1,72 @@ +/* + * 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); + tf.dl_ta_usec = 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); + tf.dl_ta_usec = 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(); +}