FreeCalypso > hg > themwi-rtp-lib
annotate src/twjit_in.c @ 9:117fa99ff871
twjit: implement proper analytics
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Fri, 05 Jul 2024 23:49:37 +0000 |
parents | 95f6c8ce33b0 |
children | e60df79cbe9f |
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 |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 /* FIXME: this libosmo-netif dependency needs to be removed */ |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 #include <osmocom/netif/rtp.h> |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 #include <themwi/rtp/twjit.h> |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 |
9
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
20 /* raw analytics on the Rx packet stream */ |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
21 |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
22 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
|
23 { |
9
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
24 struct twrtp_jibuf_rr_info *rri = &twjit->rr_info; |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
25 |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
26 rri->rx_packets = 1; |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
27 rri->base_seq = rx_seq; |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
28 rri->max_seq_ext = rx_seq; |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
29 rri->expected_pkt = 1; |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
30 rri->jitter_accum = 0; |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
31 } |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
32 |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
33 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
|
34 uint32_t rx_ts, struct timespec *now) |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
35 { |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
36 struct twrtp_jibuf_rr_info *rri = &twjit->rr_info; |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
37 uint16_t seq_ext_lo = rri->max_seq_ext; |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
38 uint16_t seq_ext_hi = rri->max_seq_ext >> 16; |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
39 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
|
40 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
|
41 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
|
42 struct timespec time_delta; |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
43 uint32_t time_delta_tsu; |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
44 int32_t jitter_new, ts_delta_clamp; |
3
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 |
9
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
46 /* analytics for our own stats */ |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
47 if (seq_delta < 0) |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
48 twjit->stats.seq_backwards++; |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
49 else if (seq_delta == 0) |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
50 twjit->stats.seq_repeats++; |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
51 else if (seq_delta == 1) { |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
52 if (ts_delta != twjit->ts_quantum) { |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
53 if (ts_delta > 0 && (ts_delta % twjit->ts_quantum) == 0) |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
54 twjit->stats.intentional_gaps++; |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
55 else |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
56 twjit->stats.ts_resets++; |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
57 } |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
58 } else |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
59 twjit->stats.seq_skips++; |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
60 |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
61 /* analytics for RTCP RR: packet counts */ |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
62 rri->rx_packets++; |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
63 if (seq_delta2 > 0) { |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
64 if (rx_seq < seq_ext_lo) |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
65 seq_ext_hi++; |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
66 seq_ext_lo = rx_seq; |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
67 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
|
68 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
|
69 } |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
70 |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
71 /* time-of-arrival analytics */ |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
72 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
|
73 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
|
74 if (time_delta.tv_nsec < 0) { |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
75 time_delta.tv_sec--; |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
76 time_delta.tv_nsec += 1000000000; |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
77 } |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
78 /* to avoid overflows in downstream math, clamp to 1 hour */ |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
79 if (time_delta.tv_sec >= 3600) { |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
80 time_delta.tv_sec = 3600; |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
81 time_delta.tv_nsec = 0; |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
82 } |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
83 /* convert to RTP timestamp units */ |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
84 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
|
85 time_delta.tv_nsec / twjit->ns_to_ts_units; |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
86 twjit->last_arrival_delta = time_delta_tsu; |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
87 /* jitter calculation for RTCP RR */ |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
88 ts_delta_clamp = twjit->ts_units_per_sec * 3600; |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
89 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 else if (ts_delta < -ts_delta_clamp) |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
92 ts_delta = -ts_delta_clamp; |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
93 jitter_new = time_delta_tsu - ts_delta; |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
94 if (jitter_new < 0) |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
95 jitter_new = -jitter_new; |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
96 rri->jitter_accum += jitter_new - ((rri->jitter_accum + 8) >> 4); |
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 { |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
214 struct rtp_hdr *rtph; |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
215 uint32_t rx_ssrc, rx_ts; |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
216 uint16_t rx_seq; |
9
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
217 struct timespec now; |
3
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
218 enum input_decision id; |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
219 |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
220 rtph = osmo_rtp_get_hdr(msg); |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
221 if (!rtph) { |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
222 /* invalid packet, couldn't even get header from it */ |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
223 twjit->stats.bad_packets++; |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
224 msgb_free(msg); |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
225 return; |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
226 } |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
227 rx_ssrc = ntohl(rtph->ssrc); |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
228 rx_ts = ntohl(rtph->timestamp); |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
229 rx_seq = ntohs(rtph->sequence); |
9
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
230 osmo_clock_gettime(CLOCK_MONOTONIC, &now); |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
231 if (!twjit->got_first_packet) { |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
232 analytics_init(twjit, rx_seq); |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
233 twjit->got_first_packet = true; |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
234 } else if (rx_ssrc != twjit->last_ssrc) { |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
235 twjit->stats.ssrc_changes++; |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
236 analytics_init(twjit, rx_seq); |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
237 } else |
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
238 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
|
239 twjit->last_ssrc = rx_ssrc; |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
240 twjit->last_seq = rx_seq; |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
241 twjit->last_ts = rx_ts; |
9
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
242 memcpy(&twjit->last_arrival, &now, sizeof(struct timespec)); |
3
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
243 msg->cb[0] = rx_ts; |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
244 |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
245 switch (twjit->state) { |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
246 case TWJIT_STATE_EMPTY: |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
247 /* first packet into totally empty buffer */ |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
248 twjit->state = TWJIT_STATE_HUNT; |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
249 twjit->write_sb = 0; |
9
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
250 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
|
251 return; |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
252 case TWJIT_STATE_HUNT: |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
253 case TWJIT_STATE_HANDOVER: |
9
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
254 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
|
255 if (id == INPUT_TOO_OLD) { |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
256 msgb_free(msg); |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
257 return; |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
258 } |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
259 if (id == INPUT_RESET) { |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
260 toss_write_queue(twjit); |
9
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
261 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
|
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 insert_pkt_write_sb(twjit, msg, rx_ts); |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
265 trim_starting_sb(twjit); |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
266 return; |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
267 case TWJIT_STATE_FLOWING: |
9
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
268 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
|
269 if (id == INPUT_TOO_OLD) { |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
270 twjit->stats.too_old++; |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
271 msgb_free(msg); |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
272 return; |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
273 } |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
274 if (id == INPUT_RESET) { |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
275 twjit->state = TWJIT_STATE_HANDOVER; |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
276 twjit->write_sb = !twjit->write_sb; |
9
117fa99ff871
twjit: implement proper analytics
Mychaela Falconia <falcon@freecalypso.org>
parents:
8
diff
changeset
|
277 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
|
278 twjit->stats.handovers++; |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
279 return; |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
280 } |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
281 insert_pkt_write_sb(twjit, msg, rx_ts); |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
282 return; |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
283 default: |
d10ea5dc61b3
twjit: initial import from previous work repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
284 OSMO_ASSERT(0); |
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 } |