libosmo-netif 1.5.1.5-89a1
Osmocom network interface library
jibuf.c File Reference

Osmocom Jitter Buffer helpers. More...

#include <stdio.h>
#include <string.h>
#include <inttypes.h>
#include <osmocom/core/msgb.h>
#include <osmocom/core/timer.h>
#include <osmocom/core/talloc.h>
#include <osmocom/core/logging.h>
#include <osmocom/core/utils.h>
#include <osmocom/netif/amr.h>
#include <osmocom/netif/rtp.h>
#include <osmocom/netif/jibuf.h>
#include <arpa/inet.h>

Macros

#define SAMPLES_PER_PKT   160
 
#define SAMPLE_RATE   8000
 
#define JIBUF_DEFAULT_MIN_DELAY_MS   60
 
#define JIBUF_DEFAULT_MAX_DELAY_MS   200
 
#define JIBUF_REFERENCE_TS_FREQ   60
 
#define JIBUF_BUFFER_RECALC_FREQ   40
 
#define JIBUF_ALLOWED_PKT_DROP   3
 
#define JIBUF_ALLOWED_PKT_CONSECUTIVE_DROP   1
 
#define JIBUF_BUFFER_INC_STEP   20
 
#define JIBUF_BUFFER_DEC_STEP   5
 
#define JIBUF_SKEW_WEIGHT   ((double)1/32)
 
#define JIBUF_MSGB_CB(__msgb)   ((struct osmo_jibuf_msgb_cb *)&((__msgb)->cb[0]))
 

Functions

struct osmo_jibufosmo_jibuf_alloc (void *talloc_ctx)
 Allocate a new jitter buffer instance. More...
 
void osmo_jibuf_delete (struct osmo_jibuf *jb)
 Destroy a previously allocated jitter buffer instance. More...
 
int osmo_jibuf_enqueue (struct osmo_jibuf *jb, struct msgb *msg)
 Try to enqueue a packet into the jitter buffer. More...
 
bool osmo_jibuf_empty (struct osmo_jibuf *jb)
 Check whether the jitter buffer instance has packets queued or not. More...
 
void osmo_jibuf_set_min_delay (struct osmo_jibuf *jb, uint32_t min_delay)
 Set minimum buffer size for the jitter buffer. More...
 
void osmo_jibuf_set_max_delay (struct osmo_jibuf *jb, uint32_t max_delay)
 Set maximum buffer size for the jitter buffer. More...
 
void osmo_jibuf_enable_skew_compensation (struct osmo_jibuf *jb, bool enable)
 Toggle use of skew detection and compensation mechanism. More...
 
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. More...
 

Detailed Description

Osmocom Jitter Buffer helpers.