aboutsummaryrefslogtreecommitdiffstats
path: root/include/osmocom
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2017-04-12 19:36:47 +0200
committerPau Espin Pedrol <pespin@sysmocom.de>2018-04-13 15:51:43 +0200
commitce820763c1c527856e8f75719b958de77d8c74aa (patch)
tree3c4f88488e3c0da6a54119ba1d475bdd3c5d2a85 /include/osmocom
parent5c962c2f3eb1c4e1497edf0f540006c76deb06fd (diff)
jibuf: Add initial implementation of Jitter Buffer
Diffstat (limited to 'include/osmocom')
-rw-r--r--include/osmocom/netif/Makefile.am1
-rw-r--r--include/osmocom/netif/jibuf.h63
2 files changed, 64 insertions, 0 deletions
diff --git a/include/osmocom/netif/Makefile.am b/include/osmocom/netif/Makefile.am
index cbaff5c..0db78fb 100644
--- a/include/osmocom/netif/Makefile.am
+++ b/include/osmocom/netif/Makefile.am
@@ -3,6 +3,7 @@ SUBDIRS = channel
osmonetif_HEADERS = amr.h \
channel.h \
datagram.h \
+ jibuf.h \
osmux.h \
ipa.h \
ipa_unit.h \
diff --git a/include/osmocom/netif/jibuf.h b/include/osmocom/netif/jibuf.h
new file mode 100644
index 0000000..6273983
--- /dev/null
+++ b/include/osmocom/netif/jibuf.h
@@ -0,0 +1,63 @@
+#pragma once
+
+#include <stdint.h>
+#include <stdbool.h>
+#include <time.h>
+
+#include <osmocom/core/timer.h>
+
+/*! \defgroup jibuf Osmocom Jitter Buffer
+ * @{
+ */
+
+/*! \file jibuf.h
+ * \brief Osmocom Jitter Buffer helpers
+ */
+
+typedef void (*osmo_jibuf_dequeue_cb)(struct msgb *msg, void *data);
+
+/*! \brief A structure representing a single instance of a jitter buffer */
+struct osmo_jibuf {
+ void *talloc_ctx;
+ bool started;
+ struct osmo_timer_list timer;
+ struct llist_head msg_list; /* sorted by output ts */
+ uint32_t min_delay; /* in msec */
+ uint32_t max_delay; /* in msec */
+ uint32_t threshold_delay; /* in msec */
+
+ osmo_jibuf_dequeue_cb dequeue_cb;
+ void *dequeue_cb_data;
+
+ /* number of pkt drops since we last changed the buffer size */
+ uint32_t last_dropped;
+ uint32_t consecutive_drops;
+
+ uint32_t ref_rx_ts;
+ uint32_t ref_tx_ts;
+ uint16_t ref_tx_seq;
+
+ struct timeval last_enqueue_time;
+ struct timeval next_dequeue_time;
+
+ struct {
+ uint32_t total_enqueued;
+ uint64_t total_dropped;
+ } stats;
+};
+
+
+struct osmo_jibuf *osmo_jibuf_alloc(void *talloc_ctx);
+
+void osmo_jibuf_delete(struct osmo_jibuf *jb);
+
+int osmo_jibuf_enqueue(struct osmo_jibuf *jb, struct msgb *msg);
+
+bool osmo_jibuf_empty(struct osmo_jibuf *jb);
+
+void osmo_jibuf_set_min_delay(struct osmo_jibuf *jb, uint32_t min_delay);
+void osmo_jibuf_set_max_delay(struct osmo_jibuf *jb, uint32_t max_delay);
+
+void osmo_jibuf_set_dequeue_cb(struct osmo_jibuf *jb, osmo_jibuf_dequeue_cb dequeue_cb, void* cb_data);
+
+/*! @} */