Asterisk - The Open Source Telephony Project GIT-master-0644429
|
Common implementation-independent jitterbuffer stuff. More...
Go to the source code of this file.
Data Structures | |
struct | ast_jb |
General jitterbuffer state. More... | |
struct | ast_jb_conf |
General jitterbuffer configuration. More... | |
struct | ast_jb_impl |
Jitterbuffer implementation struct. More... | |
Macros | |
#define | AST_JB_CONF_ENABLE "enable" |
#define | AST_JB_CONF_FORCE "force" |
#define | AST_JB_CONF_IMPL "impl" |
#define | AST_JB_CONF_LOG "log" |
#define | AST_JB_CONF_MAX_SIZE "maxsize" |
#define | AST_JB_CONF_PREFIX "jb" |
#define | AST_JB_CONF_RESYNCH_THRESHOLD "resyncthreshold" |
#define | AST_JB_CONF_SYNC_VIDEO "syncvideo" |
#define | AST_JB_CONF_TARGET_EXTRA "targetextra" |
#define | AST_JB_IMPL_NAME_SIZE 12 |
Typedefs | |
typedef void *(* | jb_create_impl) (struct ast_jb_conf *general_config) |
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 int(* | jb_is_late_impl) (void *jb, long ts) |
Check if late. 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 | { AST_JB_ENABLED = (1 << 0) , AST_JB_FORCED = (1 << 1) , AST_JB_LOG = (1 << 2) , AST_JB_SYNC_VIDEO = (1 << 3) } |
enum | { AST_JB_IMPL_OK , AST_JB_IMPL_DROP , AST_JB_IMPL_INTERP , AST_JB_IMPL_NOFRAME } |
enum | ast_jb_type { AST_JB_FIXED , AST_JB_ADAPTIVE } |
Functions | |
void | ast_jb_conf_default (struct ast_jb_conf *conf) |
Sets the contents of an ast_jb_conf struct to the default jitterbuffer settings. More... | |
void | ast_jb_configure (struct ast_channel *chan, const struct ast_jb_conf *conf) |
Configures a jitterbuffer on a channel. More... | |
void | ast_jb_create_framehook (struct ast_channel *chan, struct ast_jb_conf *jb_conf, int prefer_existing) |
Applies a jitterbuffer framehook to a channel based on a provided jitterbuffer config. 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_enable_for_channel (struct ast_channel *chan) |
Sets a jitterbuffer frame hook on the channel based on the channel's stored jitterbuffer configuration. 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... | |
const struct ast_jb_impl * | ast_jb_get_impl (enum ast_jb_type type) |
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... | |
Common implementation-independent jitterbuffer stuff.
Definition in file abstract_jb.h.
#define AST_JB_CONF_ENABLE "enable" |
Definition at line 86 of file abstract_jb.h.
#define AST_JB_CONF_FORCE "force" |
Definition at line 87 of file abstract_jb.h.
#define AST_JB_CONF_IMPL "impl" |
Definition at line 91 of file abstract_jb.h.
#define AST_JB_CONF_LOG "log" |
Definition at line 92 of file abstract_jb.h.
#define AST_JB_CONF_MAX_SIZE "maxsize" |
Definition at line 88 of file abstract_jb.h.
#define AST_JB_CONF_PREFIX "jb" |
Definition at line 85 of file abstract_jb.h.
#define AST_JB_CONF_RESYNCH_THRESHOLD "resyncthreshold" |
Definition at line 89 of file abstract_jb.h.
#define AST_JB_CONF_SYNC_VIDEO "syncvideo" |
Definition at line 93 of file abstract_jb.h.
#define AST_JB_CONF_TARGET_EXTRA "targetextra" |
Definition at line 90 of file abstract_jb.h.
#define AST_JB_IMPL_NAME_SIZE 12 |
Definition at line 64 of file abstract_jb.h.
typedef void *(* jb_create_impl) (struct ast_jb_conf *general_config) |
Create.
Definition at line 97 of file abstract_jb.h.
typedef void(* jb_destroy_impl) (void *jb) |
Destroy.
Definition at line 99 of file abstract_jb.h.
typedef void(* jb_empty_and_reset_impl) (void *jb) |
Empty and reset jb.
Definition at line 113 of file abstract_jb.h.
typedef void(* jb_force_resynch_impl) (void *jb) |
Force resynch.
Definition at line 111 of file abstract_jb.h.
typedef int(* jb_get_impl) (void *jb, struct ast_frame **fout, long now, long interpl) |
Get frame for now.
Definition at line 105 of file abstract_jb.h.
typedef int(* jb_is_late_impl) (void *jb, long ts) |
Check if late.
Definition at line 115 of file abstract_jb.h.
typedef long(* jb_next_impl) (void *jb) |
Get next.
Definition at line 107 of file abstract_jb.h.
typedef int(* jb_put_first_impl) (void *jb, struct ast_frame *fin, long now) |
Put first frame.
Definition at line 101 of file abstract_jb.h.
typedef int(* jb_put_impl) (void *jb, struct ast_frame *fin, long now) |
Put frame.
Definition at line 103 of file abstract_jb.h.
typedef int(* jb_remove_impl) (void *jb, struct ast_frame **fout) |
Remove first frame.
Definition at line 109 of file abstract_jb.h.
anonymous enum |
Enumerator | |
---|---|
AST_JB_ENABLED | |
AST_JB_FORCED | |
AST_JB_LOG | |
AST_JB_SYNC_VIDEO |
Definition at line 44 of file abstract_jb.h.
anonymous enum |
Abstract return codes
Enumerator | |
---|---|
AST_JB_IMPL_OK | |
AST_JB_IMPL_DROP | |
AST_JB_IMPL_INTERP | |
AST_JB_IMPL_NOFRAME |
Definition at line 57 of file abstract_jb.h.
enum ast_jb_type |
Enumerator | |
---|---|
AST_JB_FIXED | |
AST_JB_ADAPTIVE |
Definition at line 51 of file abstract_jb.h.
void ast_jb_conf_default | ( | struct ast_jb_conf * | conf | ) |
Sets the contents of an ast_jb_conf struct to the default jitterbuffer settings.
conf | Which jitterbuffer is being set |
Definition at line 890 of file abstract_jb.c.
References ast_clear_flag, ast_copy_string(), AST_FLAGS_ALL, DEFAULT_RESYNC, DEFAULT_SIZE, and DEFAULT_TARGET_EXTRA.
Referenced by jb_helper().
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 593 of file abstract_jb.c.
References ast_channel_jb().
Referenced by ast_unreal_new_channels(), console_new(), dahdi_new(), ooh323_new(), and unistim_new().
void ast_jb_create_framehook | ( | struct ast_channel * | chan, |
struct ast_jb_conf * | jb_conf, | ||
int | prefer_existing | ||
) |
Applies a jitterbuffer framehook to a channel based on a provided jitterbuffer config.
chan | Which channel the jitterbuffer is being set on |
jb_conf | Configuration to use for the jitterbuffer |
prefer_existing | If this is true and a jitterbuffer already exists for the channel, use the existing jitterbuffer |
Definition at line 1267 of file abstract_jb.c.
References ast_calloc, ast_channel_datastore_add(), ast_channel_datastore_find(), ast_channel_datastore_remove(), ast_channel_lock, ast_channel_set_fd(), ast_channel_unlock, ast_datastore_alloc, ast_datastore_free(), ast_framehook_attach(), ast_framehook_detach(), AST_FRAMEHOOK_INTERFACE_VERSION, AST_JITTERBUFFER_FD, ast_datastore::data, ast_framehook_interface::data, hook_destroy_cb(), hook_event_cb(), id, jb_datastore, jb_framedata_destroy(), jb_framedata_init(), NULL, jb_framedata::timer_fd, and ast_framehook_interface::version.
Referenced by ast_jb_enable_for_channel(), and jb_helper().
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 502 of file abstract_jb.c.
References ao2_cleanup, ast_channel_jb(), ast_channel_name(), ast_clear_flag, ast_frfree, AST_JB_IMPL_OK, ast_test_flag, ast_verb, ast_jb_impl::destroy, ast_jb::impl, JB_CREATED, ast_jb::jbobj, ast_jb::last_format, ast_jb::logfile, ast_jb_impl::name, NULL, 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 170 of file abstract_jb.c.
References AST_CHAN_TP_CREATESJITTER, AST_CHAN_TP_WANTSJITTER, ast_channel_jb(), ast_channel_tech(), AST_JB_ENABLED, AST_JB_FORCED, ast_set_flag, ast_test_flag, ast_jb::conf, jb_choose_impl(), JB_CREATED, JB_TIMEBASE_INITIALIZED, JB_USE, NULL, ast_channel_tech::properties, and ast_jb::timebase.
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 604 of file abstract_jb.c.
References ast_channel_jb(), ast_test_flag, ast_jb_impl::empty_and_reset, ast_jb::impl, JB_CREATED, JB_USE, and ast_jb::jbobj.
void ast_jb_enable_for_channel | ( | struct ast_channel * | chan | ) |
Sets a jitterbuffer frame hook on the channel based on the channel's stored jitterbuffer configuration.
chan | Which channel is being set up |
Definition at line 585 of file abstract_jb.c.
References ast_channel_jb(), ast_jb_create_framehook(), AST_JB_ENABLED, ast_test_flag, and ast_jb::conf.
Referenced by bridge_channel_internal_join().
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 using ast_write() each of the channels.
Definition at line 336 of file abstract_jb.c.
References ast_channel_jb(), ast_test_flag, JB_CREATED, jb_get_and_deliver(), and JB_USE.
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 599 of file abstract_jb.c.
References ast_channel_jb().
const struct ast_jb_impl * ast_jb_get_impl | ( | enum ast_jb_type | type | ) |
Definition at line 820 of file abstract_jb.c.
References ARRAY_LEN, avail_impl, NULL, and type.
Referenced by jb_framedata_init().
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 231 of file abstract_jb.c.
References ast_channel_jb(), ast_test_flag, get_now(), JB_CREATED, JB_USE, ast_jb::next, and NULL.
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 271 of file abstract_jb.c.
References ast_channel_jb(), ast_channel_name(), ast_clear_flag, AST_FRAME_DTMF, AST_FRAME_VOICE, ast_frdup, AST_FRFLAG_HAS_TIMING_INFO, ast_frfree, AST_JB_IMPL_OK, ast_log, ast_set_flag, ast_test_flag, create_jb(), ast_jb_impl::force_resync, ast_frame::frametype, get_now(), ast_jb::impl, JB_CREATED, jb_framelog, JB_USE, ast_jb::jbobj, ast_frame::len, LOG_ERROR, LOG_WARNING, ast_jb_impl::next, ast_jb::next, NULL, ast_jb_impl::put, ast_frame::src, and ast_frame::ts.
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 545 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_SYNC_VIDEO, AST_JB_CONF_TARGET_EXTRA, AST_JB_ENABLED, AST_JB_FORCED, AST_JB_LOG, AST_JB_SYNC_VIDEO, ast_set2_flag, ast_strlen_zero(), ast_true(), name, tmp(), and value.
Referenced by jb_helper(), process_dahdi(), reload_config(), and store_config_core().