Asterisk - The Open Source Telephony Project
18.5.0
|
jitterbuf: an application-independent jitterbuffer More...
Go to the source code of this file.
Macros | |
#define | jb_dbg(...) (dbgf ? dbgf(__VA_ARGS__) : (void)0) |
#define | jb_dbg2(...) ((void)0) |
#define | jb_err(...) (errf ? errf(__VA_ARGS__) : (void)0) |
#define | JB_LONGMAX 2147483647L |
#define | JB_LONGMIN (-JB_LONGMAX - 1L) |
#define | jb_warn(...) (warnf ? warnf(__VA_ARGS__) : (void)0) |
Functions | |
static enum jb_return_code | _jb_get (jitterbuf *jb, jb_frame *frameout, long now, long interpl) |
static jb_frame * | _queue_get (jitterbuf *jb, long ts, int all) |
static int | check_resync (jitterbuf *jb, long ts, long now, long ms, const enum jb_frame_type type, long *delay) |
static void | decrement_losspct (jitterbuf *jb) |
static void | history_calc_maxbuf (jitterbuf *jb) |
static void | history_get (jitterbuf *jb) |
static int | history_put (jitterbuf *jb, long ts, long now, long ms, long delay) |
static void | increment_losspct (jitterbuf *jb) |
void | jb_destroy (jitterbuf *jb) |
destroy jitterbuf More... | |
enum jb_return_code | jb_get (jitterbuf *jb, jb_frame *frameout, long now, long interpl) |
get a frame for time now (receiver's time) return value is one of JB_OK: You've got frame! JB_DROP: Here's an audio frame you should just drop. Ask me again for this time.. JB_NOFRAME: There's no frame scheduled for this time. JB_INTERP: Please interpolate an interpl-length frame for this time (either we need to grow, or there was a lost frame) JB_EMPTY: The jb is empty. More... | |
enum jb_return_code | jb_getall (jitterbuf *jb, jb_frame *frameout) |
unconditionally get frames from jitterbuf until empty More... | |
enum jb_return_code | jb_getinfo (jitterbuf *jb, jb_info *stats) |
get jitterbuf info: only "statistics" may be valid More... | |
int | jb_is_late (jitterbuf *jb, long ts) |
Checks if the given time stamp is late. More... | |
jitterbuf * | jb_new () |
new jitterbuf More... | |
long | jb_next (jitterbuf *jb) |
when is the next frame due out, in receiver's time (0=EMPTY) This value may change as frames are added (esp non-audio frames) More... | |
enum jb_return_code | jb_put (jitterbuf *jb, void *data, const enum jb_frame_type type, long ms, long ts, long now) |
queue a frame More... | |
void | jb_reset (jitterbuf *jb) |
reset jitterbuf More... | |
enum jb_return_code | jb_setconf (jitterbuf *jb, jb_conf *conf) |
set jitterbuf conf More... | |
void | jb_setoutput (jb_output_function_t err, jb_output_function_t warn, jb_output_function_t dbg) |
static jb_frame * | queue_get (jitterbuf *jb, long ts) |
static jb_frame * | queue_getall (jitterbuf *jb) |
static long | queue_last (jitterbuf *jb) |
static long | queue_next (jitterbuf *jb) |
static int | queue_put (jitterbuf *jb, void *data, const enum jb_frame_type type, long ms, long ts) |
Variables | |
static jb_output_function_t | dbgf |
static jb_output_function_t | errf |
static jb_output_function_t | warnf |
jitterbuf: an application-independent jitterbuffer
Definition in file jitterbuf.c.
Definition at line 45 of file jitterbuf.c.
Referenced by _jb_get(), and queue_getall().
#define jb_dbg2 | ( | ... | ) | ((void)0) |
Definition at line 50 of file jitterbuf.c.
Referenced by jb_destroy(), jb_new(), and jb_put().
Definition at line 44 of file jitterbuf.c.
Referenced by queue_getall(), and queue_put().
#define JB_LONGMAX 2147483647L |
define these here, just for ancient compiler systems
Definition at line 40 of file jitterbuf.c.
Referenced by history_calc_maxbuf(), and jb_next().
#define JB_LONGMIN (-JB_LONGMAX - 1L) |
Definition at line 41 of file jitterbuf.c.
Referenced by history_calc_maxbuf().
Definition at line 43 of file jitterbuf.c.
Referenced by check_resync(), and jb_get().
|
static |
Definition at line 550 of file jitterbuf.c.
References jb_info::cnt_contig_interp, jb_info::conf, jb_info::current, decrement_losspct(), jb_info::frames_dropped, jb_info::frames_late, jb_info::frames_lost, jb_info::frames_out, history_get(), increment_losspct(), jitterbuf::info, sip_to_pjsip::info(), JB_ADJUST_DELAY, jb_dbg, JB_DROP, JB_INTERP, JB_NOFRAME, JB_OK, JB_TYPE_SILENCE, JB_TYPE_VOICE, jb_info::jitter, jb_info::last_adjustment, jb_info::last_voice_ms, jb_conf::max_contig_interp, jb_conf::max_jitterbuf, jb_info::min, jb_frame::ms, jb_info::next_voice_ts, queue_get(), queue_last(), queue_next(), jb_info::silence_begin_ts, jb_info::target, jb_conf::target_extra, jb_frame::ts, and jb_frame::type.
Referenced by jb_get().
Definition at line 414 of file jitterbuf.c.
References jitterbuf::frames, jb_info::frames_cur, jitterbuf::free, jitterbuf::info, jb_frame::next, NULL, jb_frame::prev, and jb_frame::ts.
Referenced by queue_get(), and queue_getall().
|
static |
Definition at line 116 of file jitterbuf.c.
References ast_debug, jb_info::cnt_delay_discont, jb_info::conf, jitterbuf::dropem, jitterbuf::frames, jb_info::frames_dropped, jitterbuf::hist_maxbuf_valid, jitterbuf::hist_ptr, jitterbuf::info, JB_TYPE_CONTROL, jb_warn, jb_info::jitter, jb_info::last_delay, jb_conf::max_jitterbuf, jb_frame::prev, jb_info::resync_offset, jb_conf::resync_threshold, and jb_frame::ts.
Referenced by jb_put().
|
static |
Definition at line 67 of file jitterbuf.c.
References jitterbuf::info, and jb_info::losspct.
Referenced by _jb_get().
|
static |
Definition at line 214 of file jitterbuf.c.
References jitterbuf::hist_maxbuf, jitterbuf::hist_maxbuf_valid, jitterbuf::hist_minbuf, jitterbuf::hist_ptr, jitterbuf::history, JB_HISTORY_MAXBUF_SZ, JB_HISTORY_SZ, JB_LONGMAX, and JB_LONGMIN.
Referenced by history_get().
|
static |
Definition at line 295 of file jitterbuf.c.
References jitterbuf::hist_maxbuf, jitterbuf::hist_maxbuf_valid, jitterbuf::hist_minbuf, jitterbuf::hist_ptr, history_calc_maxbuf(), if(), jitterbuf::info, JB_HISTORY_DROPPCT, JB_HISTORY_MAXBUF_SZ, JB_HISTORY_SZ, jb_info::jitter, max, jb_info::min, and min.
Referenced by _jb_get(), jb_getinfo(), and jb_next().
|
static |
Definition at line 163 of file jitterbuf.c.
References jitterbuf::hist_maxbuf, jitterbuf::hist_maxbuf_valid, jitterbuf::hist_ptr, jitterbuf::history, JB_HISTORY_MAXBUF_SZ, and JB_HISTORY_SZ.
Referenced by jb_put().
|
static |
Definition at line 62 of file jitterbuf.c.
References jitterbuf::info, and jb_info::losspct.
Referenced by _jb_get().
void jb_destroy | ( | jitterbuf * | jb | ) |
destroy jitterbuf
Definition at line 99 of file jitterbuf.c.
References ast_free, jitterbuf::free, jb_dbg2, jb_frame::next, and NULL.
Referenced by AST_TEST_DEFINE(), jb_destroy_adaptive(), and pvt_destructor().
enum jb_return_code jb_get | ( | jitterbuf * | jb, |
jb_frame * | frameout, | ||
long | now, | ||
long | interpl | ||
) |
get a frame for time now (receiver's time) return value is one of JB_OK: You've got frame! JB_DROP: Here's an audio frame you should just drop. Ask me again for this time.. JB_NOFRAME: There's no frame scheduled for this time. JB_INTERP: Please interpolate an interpl-length frame for this time (either we need to grow, or there was a lost frame) JB_EMPTY: The jb is empty.
Definition at line 785 of file jitterbuf.c.
References _jb_get(), jitterbuf::info, JB_DROP, JB_INTERP, JB_OK, jb_warn, jb_info::last_voice_ms, jb_frame::ms, and jb_frame::ts.
Referenced by __get_from_jb(), AST_TEST_DEFINE(), and jb_get_adaptive().
enum jb_return_code jb_getall | ( | jitterbuf * | jb, |
jb_frame * | frameout | ||
) |
unconditionally get frames from jitterbuf until empty
Definition at line 801 of file jitterbuf.c.
References JB_NOFRAME, JB_OK, and queue_getall().
Referenced by AST_TEST_DEFINE(), complete_transfer(), jb_empty_and_reset_adaptive(), jb_remove_adaptive(), and pvt_destructor().
enum jb_return_code jb_getinfo | ( | jitterbuf * | jb, |
jb_info * | stats | ||
) |
get jitterbuf info: only "statistics" may be valid
Definition at line 815 of file jitterbuf.c.
References history_get(), jitterbuf::info, and JB_OK.
Referenced by ast_cli_netstats(), AST_TEST_DEFINE(), construct_rr(), handle_cli_iax2_show_channels(), and log_jitterstats().
int jb_is_late | ( | jitterbuf * | jb, |
long | ts | ||
) |
Checks if the given time stamp is late.
Definition at line 846 of file jitterbuf.c.
References jb_info::current, jitterbuf::info, and jb_info::next_voice_ts.
Referenced by jb_is_late_adaptive().
jitterbuf* jb_new | ( | void | ) |
new jitterbuf
Definition at line 86 of file jitterbuf.c.
References ast_calloc, jb_dbg2, jb_reset(), and NULL.
Referenced by AST_TEST_DEFINE(), jb_create_adaptive(), and new_iax().
long jb_next | ( | jitterbuf * | jb | ) |
when is the next frame due out, in receiver's time (0=EMPTY) This value may change as frames are added (esp non-audio frames)
Definition at line 767 of file jitterbuf.c.
References jb_info::conf, jb_info::current, jitterbuf::frames, history_get(), jitterbuf::info, JB_LONGMAX, jb_info::last_adjustment, jb_info::next_voice_ts, queue_next(), jb_info::silence_begin_ts, jb_info::target, and jb_conf::target_extra.
Referenced by __get_from_jb(), AST_TEST_DEFINE(), jb_next_adaptive(), and update_jbsched().
enum jb_return_code jb_put | ( | jitterbuf * | jb, |
void * | data, | ||
const enum jb_frame_type | type, | ||
long | ms, | ||
long | ts, | ||
long | now | ||
) |
queue a frame
data=frame data, timings (in ms): ms=length of frame (for voice), ts=ts (sender's time) now=now (in receiver's time) return value is one of JB_OK: Frame added. Last call to jb_next() still valid JB_DROP: Drop this frame immediately JB_SCHED: Frame added. Call jb_next() to get a new time for the next frame
Definition at line 525 of file jitterbuf.c.
References check_resync(), jb_info::frames_in, history_put(), jitterbuf::info, jb_dbg2, JB_DROP, JB_OK, JB_SCHED, JB_TYPE_VOICE, queue_put(), and jb_info::resync_offset.
Referenced by jb_put_adaptive(), schedule_delivery(), test_jb_late_frame_insertion(), test_jb_lost_frame_insertion(), test_jb_nominal_frame_insertion(), test_jb_out_of_order_frame_insertion(), test_jb_overflow_frame_insertion(), and test_jb_resynch_frame_insertion().
void jb_reset | ( | jitterbuf * | jb | ) |
reset jitterbuf
Definition at line 72 of file jitterbuf.c.
References jb_info::conf, jb_info::current, jitterbuf::free, jitterbuf::info, JB_TARGET_EXTRA, jb_info::silence_begin_ts, jb_info::target, and jb_conf::target_extra.
Referenced by complete_transfer(), jb_empty_and_reset_adaptive(), and jb_new().
enum jb_return_code jb_setconf | ( | jitterbuf * | jb, |
jb_conf * | conf | ||
) |
set jitterbuf conf
Definition at line 825 of file jitterbuf.c.
References jb_info::conf, jb_info::current, jitterbuf::info, JB_OK, JB_TARGET_EXTRA, jb_conf::max_contig_interp, jb_conf::max_jitterbuf, jb_conf::resync_threshold, jb_info::target, and jb_conf::target_extra.
Referenced by AST_TEST_DEFINE(), jb_create_adaptive(), and new_iax().
void jb_setoutput | ( | jb_output_function_t | err, |
jb_output_function_t | warn, | ||
jb_output_function_t | dbg | ||
) |
Definition at line 55 of file jitterbuf.c.
References dbgf, errf, and warnf.
Referenced by handle_cli_iax2_set_debug_jb(), and load_module().
Definition at line 454 of file jitterbuf.c.
References _queue_get(), jb_info::current, dbgf, jitterbuf::frames, jb_info::frames_cur, jb_info::frames_dropped, jb_info::frames_in, jb_info::frames_late, jb_info::frames_lost, jb_info::frames_out, jitterbuf::info, jb_dbg, jb_err, jb_info::jitter, jb_info::last_voice_ms, jb_info::min, jb_frame::next, jb_info::next_voice_ts, NULL, queue_last(), queue_next(), jb_info::silence_begin_ts, jb_info::target, and jb_frame::ts.
Referenced by jb_getall().
|
static |
Definition at line 406 of file jitterbuf.c.
References jitterbuf::frames, jb_frame::prev, and jb_frame::ts.
Referenced by _jb_get(), and queue_getall().
|
static |
Definition at line 398 of file jitterbuf.c.
References jitterbuf::frames, and jb_frame::ts.
Referenced by _jb_get(), jb_next(), and queue_getall().
|
static |
Definition at line 337 of file jitterbuf.c.
References ast_malloc, jb_frame::data, frames, jitterbuf::frames, jb_info::frames_cur, jb_info::frames_ooo, jitterbuf::free, jitterbuf::info, jb_err, jb_frame::ms, jb_frame::next, jb_frame::prev, jb_info::resync_offset, jb_frame::ts, jb_frame::type, and type.
Referenced by jb_put().
|
static |
Definition at line 53 of file jitterbuf.c.
Referenced by jb_setoutput(), and queue_getall().
|
static |
Definition at line 53 of file jitterbuf.c.
Referenced by jb_setoutput().
|
static |
Definition at line 53 of file jitterbuf.c.
Referenced by jb_setoutput().