libosmo-netif 1.6.0.16-c51c Osmocom network interface library

Loading...
Searching...
No Matches
Files | Data Structures | Typedefs | Functions
Osmocom Jitter Buffer

## Files
file | jibuf.h
| Osmocom Jitter Buffer helpers.

## Data Structures
struct | osmo_jibuf
| A structure representing a single instance of a jitter buffer. More...

## Typedefs
typedef void(* | osmo_jibuf_dequeue_cb) (struct msgb *msg, void *data)

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

## Detailed Description

## Function Documentation

## ◆ osmo_jibuf_alloc()

struct osmo_jibuf * osmo_jibuf_alloc | ( | void * | talloc_ctx | ) |

Allocate a new jitter buffer instance.

Returns
  the new allocated instance

## ◆ osmo_jibuf_delete()

void osmo_jibuf_delete | ( | struct osmo_jibuf * | jb | ) |

Destroy a previously allocated jitter buffer instance.

Parameters

  [in] | jb | Previously allocated (non-null) jitter buffer instance

All the queued packets are dequeued before deleting the instance.

## ◆ osmo_jibuf_empty()

bool osmo_jibuf_empty | ( | struct osmo_jibuf * | jb | ) |

Check whether the jitter buffer instance has packets queued or not.

Parameters

  [in] | jb | jitter buffer instance

Returns
  true if the queue is empty, false otherwise.

## ◆ 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.

Parameters

  [in] | jb | jitter buffer instance
  [in] | enable | Whether to enable or not (default) the skew estimation and compensation mechanism

When this function is called, the estimated skew is reset.

## ◆ osmo_jibuf_enqueue()

int osmo_jibuf_enqueue | ( | struct osmo_jibuf * | jb,
|  | struct msgb * | msg
| ) |  |

Try to enqueue a packet into the jitter buffer.

Parameters

  [in] | jb | jitter buffer instance
  [in] | msg | msgb to enqueue, containing an RTP packet

Returns
  <0 if the packet was dropped, 0 otherwise

This function calculates the delay for the enqueued packet. If the delay is bigger than the current buffer size, the function returns -1 and the caller owns the packet again and can free it if required. If the packet is enqueued, 0 is returned and the exact same packet (ownership transfer, no copy is made) will be available again through the dequeue_cb() when the queue timer for this packet expires.

## ◆ 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.

Parameters

  [in] | jb | jitter buffer instance
  [in] | dequeue_cb | function pointer to call back when the dequeue timer for a given packet expires
  [in] | cb_data | data pointer to be passed to dequeue_cb together with the msgb.

## ◆ 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.

Parameters

  [in] | jb | jitter buffer instance
  [in] | max_delay | Maximum buffer size, as in maximum delay in milliseconds

## ◆ 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.

Parameters

  [in] | jb | jitter buffer instance
  [in] | min_delay | Minimum buffer size, as in minimum delay in milliseconds