Asterisk - The Open Source Telephony Project
21.4.1
|
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/pbx.h"
#include "asterisk/timing.h"
#include "asterisk/rtp_engine.h"
#include "asterisk/format_cache.h"
#include "asterisk/abstract_jb.h"
#include "fixedjitterbuf.h"
#include "jitterbuf.h"
Go to the source code of this file.
Data Structures | |
struct | jb_framedata |
struct | jb_stream_sync |
Macros | |
#define | DEFAULT_RESYNC 1000 |
#define | DEFAULT_SIZE 200 |
#define | DEFAULT_TARGET_EXTRA 40 |
#define | DEFAULT_TIMER_INTERVAL 20 |
#define | DEFAULT_TYPE AST_JB_FIXED |
#define | jb_framelog(...) |
Macros for the frame log files. | |
#define | MAXIMUM_EARLY_FRAME_COUNT 200 |
Enumerations | |
enum | { JB_USE = (1 << 0), JB_TIMEBASE_INITIALIZED = (1 << 1), JB_CREATED = (1 << 2) } |
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... | |
static int | create_jb (struct ast_channel *chan, struct ast_frame *first_frame) |
static void | datastore_destroy_cb (void *data) |
static long | get_now (struct ast_jb *jb, struct timeval *tv) |
static void | hook_destroy_cb (void *framedata) |
static struct ast_frame * | hook_event_cb (struct ast_channel *chan, struct ast_frame *frame, enum ast_framehook_event event, void *data) |
static void | jb_choose_impl (struct ast_channel *chan) |
static void * | jb_create_adaptive (struct ast_jb_conf *general_config) |
static void * | jb_create_fixed (struct ast_jb_conf *general_config) |
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 void | jb_framedata_destroy (struct jb_framedata *framedata) |
static int | jb_framedata_init (struct jb_framedata *framedata, struct ast_jb_conf *jb_conf) |
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 int | jb_is_late_adaptive (void *jb, long ts) |
static int | jb_is_late_fixed (void *jb, long ts) |
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) |
static struct timeval | jitterbuffer_frame_get_ntp_timestamp (const struct jb_stream_sync *stream_sync, const struct ast_frame *frame) |
Variables | |
static const int | adaptive_to_abstract_code [] |
static const struct ast_jb_impl | avail_impl [] |
static int | default_impl = 0 |
static const int | fixed_to_abstract_code [] |
static const struct ast_datastore_info | jb_datastore |
static const char *const | jb_get_actions [] = {"Delivered", "Dropped", "Interpolated", "No"} |
Common implementation-independent jitterbuffer stuff.
Definition in file abstract_jb.c.
#define MAXIMUM_EARLY_FRAME_COUNT 200 |
The maximum size we allow the early frame buffer to get
Definition at line 59 of file abstract_jb.c.
anonymous enum |
Internal jb flags
Definition at line 52 of file abstract_jb.c.
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_copy_string(), ast_jb_conf::impl, ast_jb_conf::max_size, ast_jb_conf::resync_threshold, and ast_jb_conf::target_extra.
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.
Referenced by ast_unreal_new_channels(), console_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_set_fd(), ast_datastore_free(), ast_framehook_attach(), ast_framehook_detach(), AST_JITTERBUFFER_FD, ast_datastore::data, ast_framehook_interface::data, ast_jb_conf::impl, and ast_framehook_interface::version.
Referenced by ast_jb_enable_for_channel().
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 ast_jb::impl, ast_jb::jbobj, ast_jb::last_format, and ast_jb::logfile.
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_jb::conf, 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_jb::impl, 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_jb_create_framehook(), and ast_jb::conf.
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.
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.
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_jb::next.
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_FRAME_VOICE, ast_frdup, AST_FRFLAG_HAS_TIMING_INFO, ast_frame::frametype, ast_jb::impl, jb_framelog, ast_jb::jbobj, ast_frame::len, ast_jb::next, 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_true(), ast_jb_conf::impl, ast_jb_conf::max_size, ast_jb_conf::resync_threshold, and ast_jb_conf::target_extra.
Referenced by store_config_core().
|
static |
Definition at line 123 of file abstract_jb.c.
|
static |
Definition at line 121 of file abstract_jb.c.
|
static |
Definition at line 904 of file abstract_jb.c.