libosmo-netif 1.6.0.16-c51c Osmocom network interface library

Loading...
Searching...
No Matches
jibuf.h
Go to the documentation of this file.
1#pragma once
2
3#include <stdint.h>
4#include <stdbool.h>
5#include <time.h>
6
7#include <osmocom/core/timer.h>
8
17 typedef void (*osmo_jibuf_dequeue_cb)(struct msgb *msg, void *data);
18
20 struct osmo_jibuf {
21 void *talloc_ctx;
22 bool started;
23 struct osmo_timer_list timer;
24 struct llist_head msg_list; /* sorted by output ts */
25 uint32_t min_delay; /* in msec */
26 uint32_t max_delay; /* in msec */
27 uint32_t threshold_delay; /* in msec */
28
29 osmo_jibuf_dequeue_cb dequeue_cb;
30 void *dequeue_cb_data;
31
32 /* number of pkt drops since we last changed the buffer size */
33 uint32_t last_dropped;
34 uint32_t consecutive_drops;
35
36 uint32_t ref_rx_ts;
37 uint32_t ref_tx_ts;
38 uint16_t ref_tx_seq;
39
40 struct timeval last_enqueue_time;
41 struct timeval next_dequeue_time;
42
43 bool skew_enabled;
44 int32_t skew_us; /* src clock skew, in usec */
45
46 struct {
47 uint32_t total_enqueued;
48 uint64_t total_dropped;
49 } stats;
50};
51
52
53 struct osmo_jibuf *osmo_jibuf_alloc(void *talloc_ctx);
54
55 void osmo_jibuf_delete(struct osmo_jibuf *jb);
56
57 int osmo_jibuf_enqueue(struct osmo_jibuf *jb, struct msgb *msg);
58
59 bool osmo_jibuf_empty(struct osmo_jibuf *jb);
60
61 void osmo_jibuf_set_min_delay(struct osmo_jibuf *jb, uint32_t min_delay);
62 void osmo_jibuf_set_max_delay(struct osmo_jibuf *jb, uint32_t max_delay);
63
64 void osmo_jibuf_enable_skew_compensation(struct osmo_jibuf *jb, bool enable);
65
66 void osmo_jibuf_set_dequeue_cb(struct osmo_jibuf *jb, osmo_jibuf_dequeue_cb dequeue_cb, void* cb_data);
67
osmo_jibuf_enable_skew_compensation
void osmo_jibuf_enable_skew_compensation(struct osmo_jibuf *jb, bool enable)
Toggle use of skew detection and compensation mechanism.
Definition jibuf.c:451
osmo_jibuf_alloc
struct osmo_jibuf * osmo_jibuf_alloc(void *talloc_ctx)
Allocate a new jitter buffer instance.
Definition jibuf.c:299
osmo_jibuf_set_dequeue_cb
void osmo_jibuf_set_dequeue_cb(struct osmo_jibuf *jb, osmo_jibuf_dequeue_cb dequeue_cb, void *cb_data)
Set dequeue callback for the jitter buffer.
Definition jibuf.c:462
osmo_jibuf_enqueue
int osmo_jibuf_enqueue(struct osmo_jibuf *jb, struct msgb *msg)
Try to enqueue a packet into the jitter buffer.
Definition jibuf.c:343
osmo_jibuf_set_max_delay
void osmo_jibuf_set_max_delay(struct osmo_jibuf *jb, uint32_t max_delay)
Set maximum buffer size for the jitter buffer.
Definition jibuf.c:439
osmo_jibuf_set_min_delay
void osmo_jibuf_set_min_delay(struct osmo_jibuf *jb, uint32_t min_delay)
Set minimum buffer size for the jitter buffer.
Definition jibuf.c:429
osmo_jibuf_delete
void osmo_jibuf_delete(struct osmo_jibuf *jb)
Destroy a previously allocated jitter buffer instance.
Definition jibuf.c:321
osmo_jibuf_empty
bool osmo_jibuf_empty(struct osmo_jibuf *jb)
Check whether the jitter buffer instance has packets queued or not.
Definition jibuf.c:420
osmo_jibuf
A structure representing a single instance of a jitter buffer.
Definition jibuf.h:20