FreeCalypso > hg > themwi-rtp-lib
comparison src/twjit_in.c @ 10:e60df79cbe9f
twjit: eliminate dependency on libosmo-netif
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 06 Jul 2024 00:29:24 +0000 |
parents | 117fa99ff871 |
children | 4f82b9c07ddb |
comparison
equal
deleted
inserted
replaced
9:117fa99ff871 | 10:e60df79cbe9f |
---|---|
10 #include <osmocom/core/linuxlist.h> | 10 #include <osmocom/core/linuxlist.h> |
11 #include <osmocom/core/msgb.h> | 11 #include <osmocom/core/msgb.h> |
12 #include <osmocom/core/timer.h> | 12 #include <osmocom/core/timer.h> |
13 #include <osmocom/core/utils.h> | 13 #include <osmocom/core/utils.h> |
14 | 14 |
15 /* FIXME: this libosmo-netif dependency needs to be removed */ | |
16 #include <osmocom/netif/rtp.h> | |
17 | |
18 #include <themwi/rtp/twjit.h> | 15 #include <themwi/rtp/twjit.h> |
16 | |
17 struct rtp_basic_hdr { | |
18 uint8_t v_p_x_cc; | |
19 uint8_t m_pt; | |
20 uint16_t seq; | |
21 uint32_t tstamp; | |
22 uint32_t ssrc; | |
23 }; | |
19 | 24 |
20 /* raw analytics on the Rx packet stream */ | 25 /* raw analytics on the Rx packet stream */ |
21 | 26 |
22 static void analytics_init(struct twrtp_jibuf_inst *twjit, uint16_t rx_seq) | 27 static void analytics_init(struct twrtp_jibuf_inst *twjit, uint16_t rx_seq) |
23 { | 28 { |
209 } | 214 } |
210 } | 215 } |
211 | 216 |
212 void twrtp_jibuf_input(struct twrtp_jibuf_inst *twjit, struct msgb *msg) | 217 void twrtp_jibuf_input(struct twrtp_jibuf_inst *twjit, struct msgb *msg) |
213 { | 218 { |
214 struct rtp_hdr *rtph; | 219 struct rtp_basic_hdr *rtph; |
215 uint32_t rx_ssrc, rx_ts; | 220 uint32_t rx_ssrc, rx_ts; |
216 uint16_t rx_seq; | 221 uint16_t rx_seq; |
217 struct timespec now; | 222 struct timespec now; |
218 enum input_decision id; | 223 enum input_decision id; |
219 | 224 |
220 rtph = osmo_rtp_get_hdr(msg); | 225 if (msg->len < sizeof(struct rtp_basic_hdr)) { |
221 if (!rtph) { | 226 inv_packet: twjit->stats.bad_packets++; |
222 /* invalid packet, couldn't even get header from it */ | |
223 twjit->stats.bad_packets++; | |
224 msgb_free(msg); | 227 msgb_free(msg); |
225 return; | 228 return; |
226 } | 229 } |
230 rtph = (struct rtp_basic_hdr *)msg->data; | |
231 if ((rtph->v_p_x_cc & 0xC0) != 0x80) /* version field */ | |
232 goto inv_packet; | |
227 rx_ssrc = ntohl(rtph->ssrc); | 233 rx_ssrc = ntohl(rtph->ssrc); |
228 rx_ts = ntohl(rtph->timestamp); | 234 rx_ts = ntohl(rtph->tstamp); |
229 rx_seq = ntohs(rtph->sequence); | 235 rx_seq = ntohs(rtph->seq); |
230 osmo_clock_gettime(CLOCK_MONOTONIC, &now); | 236 osmo_clock_gettime(CLOCK_MONOTONIC, &now); |
231 if (!twjit->got_first_packet) { | 237 if (!twjit->got_first_packet) { |
232 analytics_init(twjit, rx_seq); | 238 analytics_init(twjit, rx_seq); |
233 twjit->got_first_packet = true; | 239 twjit->got_first_packet = true; |
234 } else if (rx_ssrc != twjit->last_ssrc) { | 240 } else if (rx_ssrc != twjit->last_ssrc) { |