Common implementation-independent jitterbuffer stuff. More...
#include "asterisk.h"
#include "asterisk/frame.h"
#include "asterisk/channel.h"
#include "asterisk/term.h"
#include "asterisk/utils.h"
#include "asterisk/abstract_jb.h"
#include "fixedjitterbuf.h"
#include "jitterbuf.h"
Go to the source code of this file.
Data Structures | |
struct | ast_jb_impl |
Jitterbuffer implementation private struct. More... | |
Macros | |
#define | jb_framelog(...) |
Macros for the frame log files. More... | |
Typedefs | |
typedef void *(* | jb_create_impl )(struct ast_jb_conf *general_config, long resynch_threshold) |
Create. More... | |
typedef void(* | jb_destroy_impl )(void *jb) |
Destroy. More... | |
typedef void(* | jb_empty_and_reset_impl )(void *jb) |
Empty and reset jb. More... | |
typedef void(* | jb_force_resynch_impl )(void *jb) |
Force resynch. More... | |
typedef int(* | jb_get_impl )(void *jb, struct ast_frame **fout, long now, long interpl) |
Get frame for now. More... | |
typedef long(* | jb_next_impl )(void *jb) |
Get next. More... | |
typedef int(* | jb_put_first_impl )(void *jb, struct ast_frame *fin, long now) |
Put first frame. More... | |
typedef int(* | jb_put_impl )(void *jb, struct ast_frame *fin, long now) |
Put frame. More... | |
typedef int(* | jb_remove_impl )(void *jb, struct ast_frame **fout) |
Remove first frame. More... | |
Enumerations | |
enum | { JB_USE = (1 << 0), JB_TIMEBASE_INITIALIZED = (1 << 1), JB_CREATED = (1 << 2) } |
enum | { JB_IMPL_OK, JB_IMPL_DROP, JB_IMPL_INTERP, JB_IMPL_NOFRAME } |
Functions | |
void | ast_jb_configure (struct ast_channel *chan, const struct ast_jb_conf *conf) |
Configures a jitterbuffer on a channel. More... | |
void | ast_jb_destroy (struct ast_channel *chan) |
Destroys jitterbuffer on a channel. More... | |
int | ast_jb_do_usecheck (struct ast_channel *c0, struct ast_channel *c1) |
Checks the need of a jb use in a generic bridge. More... | |
void | ast_jb_empty_and_reset (struct ast_channel *c0, struct ast_channel *c1) |
drops all frames from a jitterbuffer and resets it More... | |
void | ast_jb_get_and_deliver (struct ast_channel *c0, struct ast_channel *c1) |
Deliver the queued frames that should be delivered now for both channels. More... | |
void | ast_jb_get_config (const struct ast_channel *chan, struct ast_jb_conf *conf) |
Copies a channel's jitterbuffer configuration. More... | |
int | ast_jb_get_when_to_wakeup (struct ast_channel *c0, struct ast_channel *c1, int time_left) |
Calculates the time, left to the closest delivery moment in a bridge. More... | |
int | ast_jb_put (struct ast_channel *chan, struct ast_frame *f) |
Puts a frame into a channel jitterbuffer. More... | |
int | ast_jb_read_conf (struct ast_jb_conf *conf, const char *varname, const char *value) |
Sets jitterbuffer configuration property. More... | |
static int | create_jb (struct ast_channel *chan, struct ast_frame *first_frame) |
static long | get_now (struct ast_jb *jb, struct timeval *tv) |
static void | jb_choose_impl (struct ast_channel *chan) |
static void * | jb_create_adaptive (struct ast_jb_conf *general_config, long resynch_threshold) |
static void * | jb_create_fixed (struct ast_jb_conf *general_config, long resynch_threshold) |
static void | jb_destroy_adaptive (void *jb) |
static void | jb_destroy_fixed (void *jb) |
static void | jb_empty_and_reset_adaptive (void *jb) |
static void | jb_empty_and_reset_fixed (void *jb) |
static void | jb_force_resynch_adaptive (void *jb) |
static void | jb_force_resynch_fixed (void *jb) |
static int | jb_get_adaptive (void *jb, struct ast_frame **fout, long now, long interpl) |
static void | jb_get_and_deliver (struct ast_channel *chan) |
static int | jb_get_fixed (void *jb, struct ast_frame **fout, long now, long interpl) |
static long | jb_next_adaptive (void *jb) |
static long | jb_next_fixed (void *jb) |
static int | jb_put_adaptive (void *jb, struct ast_frame *fin, long now) |
static int | jb_put_first_adaptive (void *jb, struct ast_frame *fin, long now) |
static int | jb_put_first_fixed (void *jb, struct ast_frame *fin, long now) |
static int | jb_put_fixed (void *jb, struct ast_frame *fin, long now) |
static int | jb_remove_adaptive (void *jb, struct ast_frame **fout) |
static int | jb_remove_fixed (void *jb, struct ast_frame **fout) |
Variables | |
static const int | adaptive_to_abstract_code [] |
static struct ast_jb_impl | avail_impl [] |
static int | default_impl = 0 |
static const int | fixed_to_abstract_code [] |
static const char *const | jb_get_actions [] = {"Delivered", "Dropped", "Interpolated", "No"} |
Common implementation-independent jitterbuffer stuff.
Definition in file abstract_jb.c.
#define jb_framelog | ( | ... | ) |
Macros for the frame log files.
Definition at line 165 of file abstract_jb.c.
Referenced by ast_jb_put(), create_jb(), and jb_get_and_deliver().
typedef void*(* jb_create_impl)(struct ast_jb_conf *general_config, long resynch_threshold) |
Create.
Definition at line 59 of file abstract_jb.c.
typedef void(* jb_destroy_impl)(void *jb) |
Destroy.
Definition at line 61 of file abstract_jb.c.
typedef void(* jb_empty_and_reset_impl)(void *jb) |
Empty and reset jb.
Definition at line 75 of file abstract_jb.c.
typedef void(* jb_force_resynch_impl)(void *jb) |
Force resynch.
Definition at line 73 of file abstract_jb.c.
typedef int(* jb_get_impl)(void *jb, struct ast_frame **fout, long now, long interpl) |
Get frame for now.
Definition at line 67 of file abstract_jb.c.
typedef long(* jb_next_impl)(void *jb) |
Get next.
Definition at line 69 of file abstract_jb.c.
typedef int(* jb_put_first_impl)(void *jb, struct ast_frame *fin, long now) |
Put first frame.
Definition at line 63 of file abstract_jb.c.
typedef int(* jb_put_impl)(void *jb, struct ast_frame *fin, long now) |
Put frame.
Definition at line 65 of file abstract_jb.c.
typedef int(* jb_remove_impl)(void *jb, struct ast_frame **fout) |
Remove first frame.
Definition at line 71 of file abstract_jb.c.
anonymous enum |
Internal jb flags
Enumerator | |
---|---|
JB_USE | |
JB_TIMEBASE_INITIALIZED | |
JB_CREATED |
Definition at line 50 of file abstract_jb.c.
anonymous enum |
Abstract return codes
Enumerator | |
---|---|
JB_IMPL_OK | |
JB_IMPL_DROP | |
JB_IMPL_INTERP | |
JB_IMPL_NOFRAME |
Definition at line 148 of file abstract_jb.c.
void ast_jb_configure | ( | struct ast_channel * | chan, |
const struct ast_jb_conf * | conf | ||
) |
Configures a jitterbuffer on a channel.
chan | channel to configure. |
conf | configuration to apply. |
Called from a channel driver when a channel is created and its jitterbuffer needs to be configured.
Definition at line 616 of file abstract_jb.c.
References ast_jb::conf, and ast_channel::jb.
Referenced by __oh323_rtp_create(), __oh323_update_info(), alsa_new(), console_new(), dahdi_new(), gtalk_new(), jingle_new(), local_new(), mgcp_new(), misdn_new(), oss_new(), sip_new(), skinny_new(), and unistim_new().
void ast_jb_destroy | ( | struct ast_channel * | chan | ) |
Destroys jitterbuffer on a channel.
chan | channel. |
Called from ast_channel_free() when a channel is destroyed.
Definition at line 536 of file abstract_jb.c.
References ast_clear_flag, ast_frfree, ast_test_flag, ast_verb, ast_jb_impl::destroy, f, ast_jb::impl, ast_channel::jb, JB_CREATED, JB_IMPL_OK, ast_jb::jbobj, ast_jb::logfile, ast_jb_impl::name, ast_channel::name, and ast_jb_impl::remove.
Referenced by ast_channel_destructor().
int ast_jb_do_usecheck | ( | struct ast_channel * | c0, |
struct ast_channel * | c1 | ||
) |
Checks the need of a jb use in a generic bridge.
c0 | first bridged channel. |
c1 | second bridged channel. |
Called from ast_generic_bridge() when two channels are entering in a bridge. The function checks the need of a jitterbuffer, depending on both channel's configuration and technology properties. As a result, this function sets appropriate internal jb flags to the channels, determining further behaviour of the bridged jitterbuffers.
zero | if there are no jitter buffers in use |
non-zero | if there are |
Definition at line 205 of file abstract_jb.c.
References AST_CHAN_TP_CREATESJITTER, AST_CHAN_TP_WANTSJITTER, AST_JB_ENABLED, AST_JB_FORCED, ast_set_flag, ast_test_flag, ast_jb::conf, ast_channel::jb, jb_choose_impl(), JB_CREATED, JB_TIMEBASE_INITIALIZED, JB_USE, ast_channel_tech::properties, ast_channel::tech, and ast_jb::timebase.
Referenced by ast_generic_bridge().
void ast_jb_empty_and_reset | ( | struct ast_channel * | c0, |
struct ast_channel * | c1 | ||
) |
drops all frames from a jitterbuffer and resets it
c0 | one channel of a bridge |
c1 | the other channel of the bridge |
Definition at line 627 of file abstract_jb.c.
References ast_test_flag, ast_jb_impl::empty_and_reset, ast_jb::impl, ast_channel::jb, JB_CREATED, JB_USE, and ast_jb::jbobj.
Referenced by ast_generic_bridge().
void ast_jb_get_and_deliver | ( | struct ast_channel * | c0, |
struct ast_channel * | c1 | ||
) |
Deliver the queued frames that should be delivered now for both channels.
c0 | first bridged channel. |
c1 | second bridged channel. |
Called from ast_generic_bridge() to deliver any frames, that should be delivered for the moment of invocation. Does nothing if neihter of the channels is using jb or has any frames currently queued in. The function delivers frames usig ast_write() each of the channels.
Definition at line 371 of file abstract_jb.c.
References ast_test_flag, ast_channel::jb, JB_CREATED, jb_get_and_deliver(), and JB_USE.
Referenced by ast_generic_bridge().
void ast_jb_get_config | ( | const struct ast_channel * | chan, |
struct ast_jb_conf * | conf | ||
) |
Copies a channel's jitterbuffer configuration.
chan | channel. |
conf | destination. |
Definition at line 622 of file abstract_jb.c.
References ast_jb::conf, and ast_channel::jb.
int ast_jb_get_when_to_wakeup | ( | struct ast_channel * | c0, |
struct ast_channel * | c1, | ||
int | time_left | ||
) |
Calculates the time, left to the closest delivery moment in a bridge.
c0 | first bridged channel. |
c1 | second bridged channel. |
time_left | bridge time limit, or -1 if not set. |
Called from ast_generic_bridge() to determine the maximum time to wait for activity in ast_waitfor_n() call. If neihter of the channels is using jb, this function returns the time limit passed.
Definition at line 266 of file abstract_jb.c.
References ast_test_flag, get_now(), ast_channel::jb, JB_CREATED, JB_USE, and ast_jb::next.
Referenced by ast_generic_bridge().
int ast_jb_put | ( | struct ast_channel * | chan, |
struct ast_frame * | f | ||
) |
Puts a frame into a channel jitterbuffer.
chan | channel. |
f | frame. |
Called from ast_generic_bridge() to put a frame into a channel's jitterbuffer. The function will successfuly enqueue a frame if and only if:
0 | if the frame was queued |
-1 | if not |
Definition at line 306 of file abstract_jb.c.
References ast_clear_flag, AST_FRAME_DTMF, AST_FRAME_VOICE, ast_frdup(), AST_FRFLAG_HAS_TIMING_INFO, ast_frfree, ast_log(), ast_set_flag, ast_test_flag, create_jb(), ast_jb_impl::force_resync, ast_frame::frametype, get_now(), ast_jb::impl, ast_channel::jb, JB_CREATED, jb_framelog, JB_IMPL_OK, JB_USE, ast_jb::jbobj, ast_frame::len, LOG_ERROR, LOG_WARNING, ast_channel::name, ast_jb_impl::next, ast_jb::next, ast_jb_impl::put, ast_frame::src, and ast_frame::ts.
Referenced by ast_generic_bridge().
int ast_jb_read_conf | ( | struct ast_jb_conf * | conf, |
const char * | varname, | ||
const char * | value | ||
) |
Sets jitterbuffer configuration property.
conf | configuration to store the property in. |
varname | property name. |
value | property value. |
Called from a channel driver to build a jitterbuffer configuration typically when reading a configuration file. It is not necessary for a channel driver to know each of the jb configuration property names. The jitterbuffer itself knows them. The channel driver can pass each config var it reads through this function. It will return 0 if the variable was consumed from the jb conf.
Definition at line 577 of file abstract_jb.c.
References AST_JB_CONF_ENABLE, AST_JB_CONF_FORCE, AST_JB_CONF_IMPL, AST_JB_CONF_LOG, AST_JB_CONF_MAX_SIZE, AST_JB_CONF_PREFIX, AST_JB_CONF_RESYNCH_THRESHOLD, AST_JB_CONF_TARGET_EXTRA, AST_JB_ENABLED, AST_JB_FORCED, AST_JB_LOG, ast_set2_flag, ast_strlen_zero(), ast_true(), ast_jb_conf::impl, ast_jb_conf::max_size, name, ast_jb_conf::resync_threshold, and ast_jb_conf::target_extra.
Referenced by _build_general_config(), config_parse_variables(), gtalk_load_config(), jingle_load_config(), load_module(), process_dahdi(), reload_config(), and store_config_core().
|
static |
Definition at line 449 of file abstract_jb.c.
References ast_assert, ast_bridged_channel(), AST_CHANNEL_NAME, ast_frfree, AST_JB_IMPL_NAME_SIZE, AST_JB_LOG, ast_log(), ast_test_flag, ast_verb, ast_frame_subclass::codec, ast_jb::conf, ast_jb_impl::create, errno, get_now(), ast_jb::impl, ast_channel::jb, jb_framelog, JB_IMPL_OK, ast_jb::jbobj, ast_jb::last_format, ast_frame::len, LOG_ERROR, LOG_WARNING, ast_jb::logfile, ast_jb_impl::name, ast_channel::name, ast_jb_impl::next, ast_jb::next, ast_jb_impl::put_first, ast_jb_conf::resync_threshold, ast_frame::subclass, and ast_frame::ts.
Referenced by ast_jb_put().
|
static |
Definition at line 564 of file abstract_jb.c.
References ast_tvdiff_ms(), and ast_jb::timebase.
Referenced by ast_jb_get_when_to_wakeup(), ast_jb_put(), create_jb(), and jb_get_and_deliver().
|
static |
Definition at line 183 of file abstract_jb.c.
References ARRAY_LEN, ast_strlen_zero(), ast_jb::conf, default_impl, ast_jb_conf::impl, ast_jb::impl, ast_channel::jb, and ast_jb_impl::name.
Referenced by ast_jb_do_usecheck().
|
static |
Definition at line 742 of file abstract_jb.c.
References jb_new(), jb_setconf(), jb_conf::max_contig_interp, jb_conf::max_jitterbuf, ast_jb_conf::max_size, ast_jb_conf::resync_threshold, jb_conf::resync_threshold, ast_jb_conf::target_extra, and jb_conf::target_extra.
|
static |
Definition at line 648 of file abstract_jb.c.
References fixed_jb_new(), fixed_jb_conf::jbsize, ast_jb_conf::max_size, and fixed_jb_conf::resync_threshold.
|
static |
|
static |
|
static |
Definition at line 828 of file abstract_jb.c.
References ast_frfree, jb_frame::data, f, jb_getall(), JB_OK, and jb_reset().
|
static |
Definition at line 730 of file abstract_jb.c.
References ast_frfree, fixed_jb_frame::data, FIXED_JB_OK, and fixed_jb_remove().
|
static |
Definition at line 824 of file abstract_jb.c.
|
static |
Definition at line 723 of file abstract_jb.c.
References fixed_jb_set_force_resynch().
|
static |
Definition at line 790 of file abstract_jb.c.
References jb_frame::data, and jb_get().
|
static |
Definition at line 388 of file abstract_jb.c.
References ast_assert, ast_codec_interp_len(), AST_FRAME_VOICE, ast_frfree, AST_FRIENDLY_OFFSET, ast_log(), ast_samp2tv(), ast_tvadd(), ast_write(), ast_frame_subclass::codec, ast_frame::delivery, f, ast_jb_impl::get, get_now(), ast_jb::impl, ast_channel::jb, jb_framelog, JB_IMPL_DROP, JB_IMPL_INTERP, JB_IMPL_NOFRAME, JB_IMPL_OK, ast_jb::jbobj, ast_jb::last_format, ast_frame::len, LOG_ERROR, LOG_WARNING, ast_jb_impl::name, ast_jb_impl::next, ast_jb::next, ast_frame::next, ast_frame::offset, ast_frame::samples, ast_frame::src, ast_frame::subclass, ast_jb::timebase, and ast_frame::ts.
Referenced by ast_jb_get_and_deliver().
|
static |
Definition at line 689 of file abstract_jb.c.
References fixed_jb_frame::data, and fixed_jb_get().
|
static |
Definition at line 803 of file abstract_jb.c.
References jb_next().
|
static |
|
static |
Definition at line 779 of file abstract_jb.c.
References jb_put(), JB_TYPE_VOICE, ast_frame::len, and ast_frame::ts.
Referenced by jb_put_first_adaptive().
|
static |
Definition at line 768 of file abstract_jb.c.
References jitterbuf::info, jb_put_adaptive(), jb_info::resync_offset, and ast_frame::ts.
|
static |
Definition at line 667 of file abstract_jb.c.
References fixed_jb_put_first(), ast_frame::len, and ast_frame::ts.
|
static |
Definition at line 678 of file abstract_jb.c.
References fixed_jb_put(), ast_frame::len, and ast_frame::ts.
|
static |
Definition at line 811 of file abstract_jb.c.
References jb_frame::data, and jb_getall().
|
static |
Definition at line 710 of file abstract_jb.c.
References fixed_jb_frame::data, and fixed_jb_remove().
|
static |
Definition at line 158 of file abstract_jb.c.
|
static |
Definition at line 117 of file abstract_jb.c.
|
static |
Definition at line 144 of file abstract_jb.c.
Referenced by jb_choose_impl().
|
static |
Definition at line 156 of file abstract_jb.c.
|
static |
Definition at line 162 of file abstract_jb.c.