FreeCalypso > hg > themwi-rtp-lib
comparison src/twjit_in.c @ 12:323957bebd53
twjit: smarter counting of underruns
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 06 Jul 2024 02:47:21 +0000 |
parents | 4f82b9c07ddb |
children | ec50018cc4ea |
comparison
equal
deleted
inserted
replaced
11:4f82b9c07ddb | 12:323957bebd53 |
---|---|
216 } | 216 } |
217 } | 217 } |
218 | 218 |
219 void twrtp_jibuf_input(struct twrtp_jibuf_inst *twjit, struct msgb *msg) | 219 void twrtp_jibuf_input(struct twrtp_jibuf_inst *twjit, struct msgb *msg) |
220 { | 220 { |
221 bool got_previous_input = twjit->got_first_packet; | |
221 struct rtp_basic_hdr *rtph; | 222 struct rtp_basic_hdr *rtph; |
222 uint32_t rx_ssrc, rx_ts; | 223 uint32_t rx_ssrc, rx_ts; |
223 uint16_t rx_seq; | 224 uint16_t rx_seq; |
224 struct timespec now; | 225 struct timespec now; |
225 enum input_decision id; | 226 enum input_decision id; |
234 goto inv_packet; | 235 goto inv_packet; |
235 rx_ssrc = ntohl(rtph->ssrc); | 236 rx_ssrc = ntohl(rtph->ssrc); |
236 rx_ts = ntohl(rtph->tstamp); | 237 rx_ts = ntohl(rtph->tstamp); |
237 rx_seq = ntohs(rtph->seq); | 238 rx_seq = ntohs(rtph->seq); |
238 osmo_clock_gettime(CLOCK_MONOTONIC, &now); | 239 osmo_clock_gettime(CLOCK_MONOTONIC, &now); |
239 if (!twjit->got_first_packet) { | 240 if (!got_previous_input) { |
240 analytics_init(twjit, rx_seq); | 241 analytics_init(twjit, rx_seq); |
241 twjit->got_first_packet = true; | 242 twjit->got_first_packet = true; |
242 } else if (rx_ssrc != twjit->last_ssrc) { | 243 } else if (rx_ssrc != twjit->last_ssrc) { |
243 twjit->stats.ssrc_changes++; | 244 twjit->stats.ssrc_changes++; |
244 analytics_init(twjit, rx_seq); | 245 analytics_init(twjit, rx_seq); |
252 msg->cb[0] = rx_ts; | 253 msg->cb[0] = rx_ts; |
253 | 254 |
254 switch (twjit->state) { | 255 switch (twjit->state) { |
255 case TWJIT_STATE_EMPTY: | 256 case TWJIT_STATE_EMPTY: |
256 /* first packet into totally empty buffer */ | 257 /* first packet into totally empty buffer */ |
258 if (got_previous_input) | |
259 twjit->stats.underruns++; | |
257 twjit->state = TWJIT_STATE_HUNT; | 260 twjit->state = TWJIT_STATE_HUNT; |
258 twjit->write_sb = 0; | 261 twjit->write_sb = 0; |
259 init_subbuf_first_packet(twjit, msg, rx_ssrc, rx_ts); | 262 init_subbuf_first_packet(twjit, msg, rx_ssrc, rx_ts); |
260 return; | 263 return; |
261 case TWJIT_STATE_HUNT: | 264 case TWJIT_STATE_HUNT: |