libosmo-netif 1.5.1.31-6b3f
Osmocom network interface library
twjit_private.h
1/*
2 * Themyscira Wireless RTP jitter buffer implementation:
3 * internal definitions confined to twjit code inside libosmo-netif.
4 *
5 * This code was contributed to Osmocom Cellular Network Infrastructure
6 * project by Mother Mychaela N. Falconia of Themyscira Wireless.
7 * Mother Mychaela's contributions are NOT subject to copyright:
8 * no rights reserved, all rights relinquished.
9 */
10
11#pragma once
12
13#include <stdint.h>
14#include <stdbool.h>
15
16#include <osmocom/core/linuxlist.h>
17#include <osmocom/core/timer.h>
18
19#include <osmocom/netif/twjit.h>
20
21/*
22 * Each twjit instance has two sub-buffers; each subbuf is a queue of
23 * received RTP packets that have the same SSRC and whose timestamps
24 * increment in the expected cadence, with each ts delta being an
25 * integral multiple of the samples-per-quantum constant.
26 */
28 uint32_t ssrc;
29 uint32_t head_ts;
30 struct llist_head queue;
31 uint32_t depth;
32 uint32_t delta_ms; /* used only in starting state */
33 /* thinning mechanism */
34 uint16_t drop_int_count;
35 /* running config for this subbuf */
36 struct osmo_twjit_config conf;
37};
38
39/*
40 * Each twjit instance is in one of 4 fundamental states at any moment,
41 * as enumerated here.
42 */
43enum twjit_state {
44 TWJIT_STATE_EMPTY,
45 TWJIT_STATE_HUNT,
46 TWJIT_STATE_FLOWING,
47 TWJIT_STATE_HANDOVER,
48};
49
50/* Main structure for one instance of twjit */
51struct osmo_twjit {
52 /* pointer to config structure given to osmo_twjit_create(),
53 * memory must remain valid, but content can change at any time. */
54 const struct osmo_twjit_config *ext_config;
55 /* count of RTP timestamp units per quantum */
56 uint32_t ts_quantum;
57 /* quanta per second, used to scale max_future_sec */
58 uint16_t quanta_per_sec;
59 /* scaling factors for time delta conversions */
60 uint16_t ts_units_per_ms;
61 uint32_t ts_units_per_sec;
62 uint32_t ns_to_ts_units;
63 /* operational state */
64 enum twjit_state state;
65 struct twjit_subbuf sb[2];
66 uint8_t read_sb; /* 0 or 1 */
67 uint8_t write_sb; /* ditto */
68 /* info about the most recent Rx packet */
69 uint32_t last_ts;
70 uint16_t last_seq;
71 bool got_first_packet;
72 struct timespec last_arrival;
73 uint32_t last_arrival_delta;
74 /* analytics for RTCP RR, also remembers last SSRC */
75 struct osmo_twjit_rr_info rr_info;
76 /* stats over lifetime of this instance */
77 struct osmo_twjit_stats stats;
78};
Definition: twjit.h:26
Definition: twjit.h:74
Definition: twjit.h:42
Definition: twjit_private.h:51
Definition: twjit_private.h:27