FreeCalypso > hg > themwi-rtp-lib
annotate src/twjit_in.c @ 18:ec50018cc4ea
put struct rtp_basic_hdr into a header file
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 07 Jul 2024 00:15:00 +0000 |
parents | 323957bebd53 |
children |
rev | line source |
---|---|
3
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
5
1bb26347e253
twjit: split into separate base/in/out modules
Mychaela Falconia <falcon@freecalypso.org>
parents:
3
diff
changeset
|
2 * Themyscira Wireless jitter buffer implementation: RTP input processing. |
3
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 */ |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 #include <stdint.h> |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 #include <stdbool.h> |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 #include <string.h> |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 #include <arpa/inet.h> /* for network byte order functions */ |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 #include <osmocom/core/linuxlist.h> |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 #include <osmocom/core/msgb.h> |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 #include <osmocom/core/timer.h> |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 #include <osmocom/core/utils.h> |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 |
10
e60df79cbe9f
twjit: eliminate dependency on libosmo-netif
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
15 #include <themwi/rtp/twjit.h> |
18
ec50018cc4ea
put struct rtp_basic_hdr into a header file
Mychaela Falconia <falcon@freecalypso.org>
parents:
12
diff
changeset
|
16 #include <themwi/rtp/rtp_basic_hdr.h> |
3
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 |
9
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
18 /* raw analytics on the Rx packet stream */ |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
19 |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
20 static void analytics_init(struct twrtp_jibuf_inst *twjit, uint16_t rx_seq) |
3
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 { |
9
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
22 struct twrtp_jibuf_rr_info *rri = &twjit->rr_info; |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
23 |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
24 rri->rx_packets = 1; |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
25 rri->base_seq = rx_seq; |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
26 rri->max_seq_ext = rx_seq; |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
27 rri->expected_pkt = 1; |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
28 rri->jitter_accum = 0; |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
29 } |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
30 |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
31 static void analytics_cont(struct twrtp_jibuf_inst *twjit, uint16_t rx_seq, |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
32 uint32_t rx_ts, struct timespec *now) |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
33 { |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
34 struct twrtp_jibuf_rr_info *rri = &twjit->rr_info; |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
35 uint16_t seq_ext_lo = rri->max_seq_ext; |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
36 uint16_t seq_ext_hi = rri->max_seq_ext >> 16; |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
37 int16_t seq_delta = (int16_t)(rx_seq - twjit->last_seq); |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
38 int16_t seq_delta2 = (int16_t)(rx_seq - seq_ext_lo); |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
39 int32_t ts_delta = (int32_t)(rx_ts - twjit->last_ts); |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
40 struct timespec time_delta; |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
41 uint32_t time_delta_tsu; |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
42 int32_t jitter_new, ts_delta_clamp; |
3
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 |
9
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
44 /* analytics for our own stats */ |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
45 if (seq_delta < 0) |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
46 twjit->stats.seq_backwards++; |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
47 else if (seq_delta == 0) |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
48 twjit->stats.seq_repeats++; |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
49 else if (seq_delta == 1) { |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
50 if (ts_delta != twjit->ts_quantum) { |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
51 if (ts_delta > 0 && (ts_delta % twjit->ts_quantum) == 0) |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
52 twjit->stats.intentional_gaps++; |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
53 else |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
54 twjit->stats.ts_resets++; |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
55 } |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
56 } else |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
57 twjit->stats.seq_skips++; |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
58 |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
59 /* analytics for RTCP RR: packet counts */ |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
60 rri->rx_packets++; |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
61 if (seq_delta2 > 0) { |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
62 if (rx_seq < seq_ext_lo) |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
63 seq_ext_hi++; |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
64 seq_ext_lo = rx_seq; |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
65 rri->max_seq_ext = ((uint32_t) seq_ext_hi << 16) | seq_ext_lo; |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
66 rri->expected_pkt = rri->max_seq_ext - rri->base_seq + 1; |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
67 } |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
68 |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
69 /* time-of-arrival analytics */ |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
70 time_delta.tv_sec = now->tv_sec - twjit->last_arrival.tv_sec; |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
71 time_delta.tv_nsec = now->tv_nsec - twjit->last_arrival.tv_nsec; |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
72 if (time_delta.tv_nsec < 0) { |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
73 time_delta.tv_sec--; |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
74 time_delta.tv_nsec += 1000000000; |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
75 } |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
76 /* to avoid overflows in downstream math, clamp to 1 hour */ |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
77 if (time_delta.tv_sec >= 3600) { |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
78 time_delta.tv_sec = 3600; |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
79 time_delta.tv_nsec = 0; |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
80 } |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
81 /* convert to RTP timestamp units */ |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
82 time_delta_tsu = time_delta.tv_sec * twjit->ts_units_per_sec + |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
83 time_delta.tv_nsec / twjit->ns_to_ts_units; |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
84 twjit->last_arrival_delta = time_delta_tsu; |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
85 /* jitter calculation for RTCP RR */ |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
86 ts_delta_clamp = twjit->ts_units_per_sec * 3600; |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
87 if (ts_delta > ts_delta_clamp) |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
88 ts_delta = ts_delta_clamp; |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
89 else if (ts_delta < -ts_delta_clamp) |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
90 ts_delta = -ts_delta_clamp; |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
91 jitter_new = time_delta_tsu - ts_delta; |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
92 if (jitter_new < 0) |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
93 jitter_new = -jitter_new; |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
94 rri->jitter_accum += jitter_new - ((rri->jitter_accum + 8) >> 4); |
11
4f82b9c07ddb
twjit: update to stats
Mychaela Falconia <falcon@freecalypso.org>
parents:
10
diff
changeset
|
95 if (jitter_new > twjit->stats.jitter_max) |
4f82b9c07ddb
twjit: update to stats
Mychaela Falconia <falcon@freecalypso.org>
parents:
10
diff
changeset
|
96 twjit->stats.jitter_max = jitter_new; |
3
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
97 } |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
98 |
9
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
99 /* actual twjit input logic */ |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
100 |
3
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
101 static void |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
102 init_subbuf_first_packet(struct twrtp_jibuf_inst *twjit, struct msgb *msg, |
9
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
103 uint32_t rx_ssrc, uint32_t rx_ts) |
3
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
104 { |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
105 struct twrtp_jibuf_sub *sb = &twjit->sb[twjit->write_sb]; |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
106 |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
107 OSMO_ASSERT(llist_empty(&sb->queue)); |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
108 OSMO_ASSERT(sb->depth == 0); |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
109 /* all good, proceed */ |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
110 sb->ssrc = rx_ssrc; |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
111 sb->head_ts = rx_ts; |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
112 msgb_enqueue(&sb->queue, msg); |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
113 sb->depth = 1; |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
114 memcpy(&sb->conf, twjit->ext_config, sizeof(struct twrtp_jibuf_config)); |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
115 sb->drop_int_count = 0; |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
116 } |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
117 |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
118 enum input_decision { |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
119 INPUT_CONTINUE, |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
120 INPUT_TOO_OLD, |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
121 INPUT_RESET, |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
122 }; |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
123 |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
124 static enum input_decision |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
125 check_input_for_subbuf(struct twrtp_jibuf_inst *twjit, bool starting, |
9
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
126 uint32_t rx_ssrc, uint32_t rx_ts) |
3
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
127 { |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
128 struct twrtp_jibuf_sub *sb = &twjit->sb[twjit->write_sb]; |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
129 int32_t ts_delta; |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
130 |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
131 if (rx_ssrc != sb->ssrc) |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
132 return INPUT_RESET; |
9
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
133 sb->delta_ms = twjit->last_arrival_delta / twjit->ts_units_per_ms; |
3
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
134 ts_delta = (int32_t)(rx_ts - sb->head_ts); |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
135 if (ts_delta < 0) |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
136 return INPUT_TOO_OLD; |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
137 if (ts_delta % twjit->ts_quantum) |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
138 return INPUT_RESET; |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
139 if (starting) { |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
140 if (sb->conf.start_max_delta && |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
141 sb->delta_ms > sb->conf.start_max_delta) |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
142 return INPUT_RESET; |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
143 } else { |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
144 uint32_t fwd = ts_delta / twjit->ts_quantum; |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
145 |
8
95f6c8ce33b0
twjit: prep for rework of time delta handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
5
diff
changeset
|
146 if (fwd >= (uint32_t) sb->conf.max_future_sec * |
95f6c8ce33b0
twjit: prep for rework of time delta handling
Mychaela Falconia <falcon@freecalypso.org>
parents:
5
diff
changeset
|
147 twjit->quanta_per_sec) |
3
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
148 return INPUT_RESET; |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
149 } |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
150 return INPUT_CONTINUE; |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
151 } |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
152 |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
153 static void toss_write_queue(struct twrtp_jibuf_inst *twjit) |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
154 { |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
155 struct twrtp_jibuf_sub *sb = &twjit->sb[twjit->write_sb]; |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
156 |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
157 msgb_queue_free(&sb->queue); |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
158 sb->depth = 0; |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
159 } |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
160 |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
161 static void insert_pkt_write_sb(struct twrtp_jibuf_inst *twjit, |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
162 struct msgb *new_msg, uint32_t rx_ts) |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
163 { |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
164 struct twrtp_jibuf_sub *sb = &twjit->sb[twjit->write_sb]; |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
165 uint32_t ts_delta = rx_ts - sb->head_ts; |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
166 uint32_t ins_depth = ts_delta / twjit->ts_quantum; |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
167 struct msgb *old_msg; |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
168 uint32_t old_ts_delta; |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
169 |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
170 /* are we increasing total depth, and can we do simple tail append? */ |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
171 if (ins_depth >= sb->depth) { |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
172 msgb_enqueue(&sb->queue, new_msg); |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
173 sb->depth = ins_depth + 1; |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
174 return; |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
175 } |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
176 /* nope - do it the hard way */ |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
177 llist_for_each_entry(old_msg, &sb->queue, list) { |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
178 old_ts_delta = old_msg->cb[0] - sb->head_ts; |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
179 if (old_ts_delta == ts_delta) { |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
180 /* two packets with the same timestamp! */ |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
181 twjit->stats.duplicate_ts++; |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
182 msgb_free(new_msg); |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
183 return; |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
184 } |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
185 if (old_ts_delta > ts_delta) |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
186 break; |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
187 } |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
188 llist_add_tail(&new_msg->list, &old_msg->list); |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
189 } |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
190 |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
191 static void trim_starting_sb(struct twrtp_jibuf_inst *twjit) |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
192 { |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
193 struct twrtp_jibuf_sub *sb = &twjit->sb[twjit->write_sb]; |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
194 struct msgb *msg; |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
195 uint32_t msg_ts, ts_adv, quantum_adv; |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
196 |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
197 while (sb->depth > sb->conf.bd_start) { |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
198 msg = msgb_dequeue(&sb->queue); |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
199 OSMO_ASSERT(msg); |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
200 msgb_free(msg); |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
201 OSMO_ASSERT(!llist_empty(&sb->queue)); |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
202 msg = llist_entry(sb->queue.next, struct msgb, list); |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
203 msg_ts = msg->cb[0]; |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
204 ts_adv = msg_ts - sb->head_ts; |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
205 quantum_adv = ts_adv / twjit->ts_quantum; |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
206 OSMO_ASSERT(sb->depth > quantum_adv); |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
207 sb->head_ts = msg_ts; |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
208 sb->depth -= quantum_adv; |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
209 } |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
210 } |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
211 |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
212 void twrtp_jibuf_input(struct twrtp_jibuf_inst *twjit, struct msgb *msg) |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
213 { |
12
323957bebd53
twjit: smarter counting of underruns
Mychaela Falconia <falcon@freecalypso.org>
parents:
11
diff
changeset
|
214 bool got_previous_input = twjit->got_first_packet; |
10
e60df79cbe9f
twjit: eliminate dependency on libosmo-netif
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
215 struct rtp_basic_hdr *rtph; |
3
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
216 uint32_t rx_ssrc, rx_ts; |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
217 uint16_t rx_seq; |
9
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
218 struct timespec now; |
3
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
219 enum input_decision id; |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
220 |
10
e60df79cbe9f
twjit: eliminate dependency on libosmo-netif
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
221 if (msg->len < sizeof(struct rtp_basic_hdr)) { |
e60df79cbe9f
twjit: eliminate dependency on libosmo-netif
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
222 inv_packet: twjit->stats.bad_packets++; |
3
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
223 msgb_free(msg); |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
224 return; |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
225 } |
10
e60df79cbe9f
twjit: eliminate dependency on libosmo-netif
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
226 rtph = (struct rtp_basic_hdr *)msg->data; |
e60df79cbe9f
twjit: eliminate dependency on libosmo-netif
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
227 if ((rtph->v_p_x_cc & 0xC0) != 0x80) /* version field */ |
e60df79cbe9f
twjit: eliminate dependency on libosmo-netif
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
228 goto inv_packet; |
3
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
229 rx_ssrc = ntohl(rtph->ssrc); |
10
e60df79cbe9f
twjit: eliminate dependency on libosmo-netif
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
230 rx_ts = ntohl(rtph->tstamp); |
e60df79cbe9f
twjit: eliminate dependency on libosmo-netif
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
231 rx_seq = ntohs(rtph->seq); |
9
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
232 osmo_clock_gettime(CLOCK_MONOTONIC, &now); |
12
323957bebd53
twjit: smarter counting of underruns
Mychaela Falconia <falcon@freecalypso.org>
parents:
11
diff
changeset
|
233 if (!got_previous_input) { |
9
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
234 analytics_init(twjit, rx_seq); |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
235 twjit->got_first_packet = true; |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
236 } else if (rx_ssrc != twjit->last_ssrc) { |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
237 twjit->stats.ssrc_changes++; |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
238 analytics_init(twjit, rx_seq); |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
239 } else |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
240 analytics_cont(twjit, rx_seq, rx_ts, &now); |
3
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
241 twjit->last_ssrc = rx_ssrc; |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
242 twjit->last_seq = rx_seq; |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
243 twjit->last_ts = rx_ts; |
9
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
244 memcpy(&twjit->last_arrival, &now, sizeof(struct timespec)); |
11
4f82b9c07ddb
twjit: update to stats
Mychaela Falconia <falcon@freecalypso.org>
parents:
10
diff
changeset
|
245 twjit->stats.rx_packets++; |
3
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
246 msg->cb[0] = rx_ts; |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
247 |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
248 switch (twjit->state) { |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
249 case TWJIT_STATE_EMPTY: |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
250 /* first packet into totally empty buffer */ |
12
323957bebd53
twjit: smarter counting of underruns
Mychaela Falconia <falcon@freecalypso.org>
parents:
11
diff
changeset
|
251 if (got_previous_input) |
323957bebd53
twjit: smarter counting of underruns
Mychaela Falconia <falcon@freecalypso.org>
parents:
11
diff
changeset
|
252 twjit->stats.underruns++; |
3
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
253 twjit->state = TWJIT_STATE_HUNT; |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
254 twjit->write_sb = 0; |
9
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
255 init_subbuf_first_packet(twjit, msg, rx_ssrc, rx_ts); |
3
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
256 return; |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
257 case TWJIT_STATE_HUNT: |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
258 case TWJIT_STATE_HANDOVER: |
9
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
259 id = check_input_for_subbuf(twjit, true, rx_ssrc, rx_ts); |
3
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
260 if (id == INPUT_TOO_OLD) { |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
261 msgb_free(msg); |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
262 return; |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
263 } |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
264 if (id == INPUT_RESET) { |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
265 toss_write_queue(twjit); |
9
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
266 init_subbuf_first_packet(twjit, msg, rx_ssrc, rx_ts); |
3
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
267 return; |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
268 } |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
269 insert_pkt_write_sb(twjit, msg, rx_ts); |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
270 trim_starting_sb(twjit); |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
271 return; |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
272 case TWJIT_STATE_FLOWING: |
9
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
273 id = check_input_for_subbuf(twjit, false, rx_ssrc, rx_ts); |
3
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
274 if (id == INPUT_TOO_OLD) { |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
275 twjit->stats.too_old++; |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
276 msgb_free(msg); |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
277 return; |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
278 } |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
279 if (id == INPUT_RESET) { |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
280 twjit->state = TWJIT_STATE_HANDOVER; |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
281 twjit->write_sb = !twjit->write_sb; |
9
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
282 init_subbuf_first_packet(twjit, msg, rx_ssrc, rx_ts); |
11
4f82b9c07ddb
twjit: update to stats
Mychaela Falconia <falcon@freecalypso.org>
parents:
10
diff
changeset
|
283 twjit->stats.handovers_in++; |
3
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
284 return; |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
285 } |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
286 insert_pkt_write_sb(twjit, msg, rx_ts); |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
287 return; |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
288 default: |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
289 OSMO_ASSERT(0); |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
290 } |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
291 } |