FreeCalypso > hg > ice1-trau-tester
comparison 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 |
comparison
equal
deleted
inserted
replaced
50:6ba4de500532 | 51:db39e8855f3d |
---|---|
7 #include <stdio.h> | 7 #include <stdio.h> |
8 #include <stdlib.h> | 8 #include <stdlib.h> |
9 #include <string.h> | 9 #include <string.h> |
10 #include <unistd.h> | 10 #include <unistd.h> |
11 | 11 |
12 #include <osmocom/core/bits.h> | |
12 #include <osmocom/core/msgb.h> | 13 #include <osmocom/core/msgb.h> |
13 #include <osmocom/core/select.h> | 14 #include <osmocom/core/select.h> |
14 #include <osmocom/isdn/i460_mux.h> | 15 #include <osmocom/isdn/i460_mux.h> |
15 #include <osmocom/trau/trau_frame.h> | 16 #include <osmocom/trau/trau_frame.h> |
16 | 17 |
134 fr->c_bits[5] = ir_16k; | 135 fr->c_bits[5] = ir_16k; |
135 memset(fr->c_bits + 6, 1, 9); | 136 memset(fr->c_bits + 6, 1, 9); |
136 memset(fr->d_bits, 1, 63 * 4); | 137 memset(fr->d_bits, 1, 63 * 4); |
137 } | 138 } |
138 | 139 |
140 static void d144_play_frame(struct ater_subslot *at, const uint8_t *filerec) | |
141 { | |
142 struct osmo_trau_frame *fr = &at->ul_frame; | |
143 struct msgb *msg; | |
144 int len; | |
145 | |
146 msg = msgb_alloc_c(g_ctx, 320, "TRAU-UL-frame"); | |
147 if (!msg) | |
148 return; | |
149 fr->type = OSMO_TRAU16_FT_EDATA; | |
150 fr->dir = OSMO_TRAU_DIR_UL; | |
151 fr->c_bits[5] = 0; | |
152 memset(fr->c_bits + 6, 1, 7); | |
153 fr->m_bits[0] = (filerec[1] & 2) >> 1; | |
154 fr->m_bits[1] = filerec[1] & 1; | |
155 osmo_pbit2ubit(fr->d_bits, filerec + 2, 288); | |
156 len = osmo_trau_frame_encode(msg->tail, msgb_tailroom(msg), fr); | |
157 if (len <= 0) { | |
158 msgb_free(msg); | |
159 return; | |
160 } | |
161 msgb_put(msg, len); | |
162 osmo_i460_mux_enqueue(at->schan, msg); | |
163 } | |
164 | |
139 static void handle_d144(int nr) | 165 static void handle_d144(int nr) |
140 { | 166 { |
141 struct ater_subslot *at = &subslots[nr]; | 167 struct ater_subslot *at = &subslots[nr]; |
142 struct msgb *msg; | 168 struct msgb *msg; |
143 | 169 |
170 if (at->play_buffer) { | |
171 d144_play_frame(at, at->play_buffer + at->play_buf_ptr * 38); | |
172 at->play_buf_ptr++; | |
173 if (at->play_buf_ptr < at->play_buf_total) | |
174 return; | |
175 free(at->play_buffer); | |
176 at->play_buffer = NULL; | |
177 printf("file play finished\n"); | |
178 return; | |
179 } | |
144 msg = msgb_alloc_c(g_ctx, 320, "TRAU-UL-frame"); | 180 msg = msgb_alloc_c(g_ctx, 320, "TRAU-UL-frame"); |
145 if (!msg) | 181 if (!msg) |
146 return; | 182 return; |
147 memcpy(msg->tail, at->d144_edata ? d144_idle_edata : d144_sync_frame, | 183 memcpy(msg->tail, at->d144_edata ? d144_idle_edata : d144_sync_frame, |
148 320); | 184 320); |