FreeCalypso > hg > ice1-trau-tester
diff ater/tx_func.c @ 51:db39e8855f3d
ater: implement play-d144
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Wed, 25 Sep 2024 05:53:38 +0000 |
parents | 40f781efdbe1 |
children | 626180a15857 |
line wrap: on
line diff
--- a/ater/tx_func.c Tue Sep 24 06:15:40 2024 +0000 +++ b/ater/tx_func.c Wed Sep 25 05:53:38 2024 +0000 @@ -9,6 +9,7 @@ #include <string.h> #include <unistd.h> +#include <osmocom/core/bits.h> #include <osmocom/core/msgb.h> #include <osmocom/core/select.h> #include <osmocom/isdn/i460_mux.h> @@ -136,11 +137,46 @@ memset(fr->d_bits, 1, 63 * 4); } +static void d144_play_frame(struct ater_subslot *at, const uint8_t *filerec) +{ + struct osmo_trau_frame *fr = &at->ul_frame; + struct msgb *msg; + int len; + + msg = msgb_alloc_c(g_ctx, 320, "TRAU-UL-frame"); + if (!msg) + return; + fr->type = OSMO_TRAU16_FT_EDATA; + fr->dir = OSMO_TRAU_DIR_UL; + fr->c_bits[5] = 0; + memset(fr->c_bits + 6, 1, 7); + fr->m_bits[0] = (filerec[1] & 2) >> 1; + fr->m_bits[1] = filerec[1] & 1; + osmo_pbit2ubit(fr->d_bits, filerec + 2, 288); + len = osmo_trau_frame_encode(msg->tail, msgb_tailroom(msg), fr); + if (len <= 0) { + msgb_free(msg); + return; + } + msgb_put(msg, len); + osmo_i460_mux_enqueue(at->schan, msg); +} + static void handle_d144(int nr) { struct ater_subslot *at = &subslots[nr]; struct msgb *msg; + if (at->play_buffer) { + d144_play_frame(at, at->play_buffer + at->play_buf_ptr * 38); + at->play_buf_ptr++; + if (at->play_buf_ptr < at->play_buf_total) + return; + free(at->play_buffer); + at->play_buffer = NULL; + printf("file play finished\n"); + return; + } msg = msgb_alloc_c(g_ctx, 320, "TRAU-UL-frame"); if (!msg) return;