37 #include <sys/types.h>
51 static int bridge_features_duration_callback(
struct ast_bridge_channel *bridge_channel,
void *hook_pvt)
60 AST_CAUSE_NORMAL_CLEARING);
63 ast_channel_name(bridge_channel->
chan));
69 if (!strcasecmp(file,
"timeleft")) {
78 if ((remaining / 60) > 1) {
89 ast_channel_language(bridge_channel->
chan), NULL);
94 ast_channel_language(bridge_channel->
chan), NULL);
106 const char *latest_musicclass;
108 ast_channel_lock(bridge_channel->
chan);
109 latest_musicclass =
ast_strdupa(ast_channel_latest_musicclass(bridge_channel->
chan));
110 ast_channel_unlock(bridge_channel->
chan);
115 static int bridge_features_connect_callback(
struct ast_bridge_channel *bridge_channel,
void *hook_pvt)
119 limits_interval_playback(bridge_channel, limits, limits->
connect_sound);
123 static int bridge_features_warning_callback(
struct ast_bridge_channel *bridge_channel,
void *hook_pvt)
127 limits_interval_playback(bridge_channel, limits, limits->
warning_sound);
140 static void bridge_features_limits_dtor(
void *vdoomed)
160 feature_limits = ao2_alloc_options(
sizeof(*feature_limits),
162 if (!feature_limits) {
169 bridge_features_limits_copy(feature_limits, limits);
176 feature_limits->duration,
177 bridge_features_duration_callback, feature_limits,
__ao2_cleanup, remove_flags)) {
178 ast_log(LOG_ERROR,
"Failed to schedule the duration limiter to the bridge channel.\n");
182 if (!ast_strlen_zero(feature_limits->connect_sound)) {
185 bridge_features_connect_callback, feature_limits,
__ao2_cleanup, remove_flags)) {
186 ast_log(LOG_WARNING,
"Failed to schedule connect sound to the bridge channel.\n");
190 if (feature_limits->warning && feature_limits->warning < feature_limits->duration) {
193 feature_limits->duration - feature_limits->warning,
194 bridge_features_warning_callback, feature_limits,
__ao2_cleanup, remove_flags)) {
195 ast_log(LOG_WARNING,
"Failed to schedule warning sound playback to the bridge channel.\n");
203 static int unload_module(
void)
209 static int load_module(
void)
212 bridge_builtin_set_limits);
215 AST_MODULE_INFO_STANDARD(
ASTERISK_GPL_KEY,
"Built in bridging interval features");
Asterisk main include file. File version handling, generic pbx functions.
Structure that contains features information.
const ast_string_field duration_sound
ast_bridge_hook_remove_flags
void __ao2_cleanup(void *obj)
int ast_bridge_interval_register(enum ast_bridge_builtin_interval interval, ast_bridge_builtin_set_limits_fn callback)
Register a handler for a built in interval feature.
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
int64_t ast_tvdiff_ms(struct timeval end, struct timeval start)
Computes the difference (in milliseconds) between two struct timeval instances.
Generic File Format Support. Should be included by clients of the file handling routines. File service providers should instead include mod_format.h.
struct timeval quitting_time
void ast_bridge_features_limits_destroy(struct ast_bridge_features_limits *limits)
Destructor function for ast_bridge_features_limits.
General Asterisk PBX channel definitions.
#define ast_strdupa(s)
duplicate a string in memory from the stack
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
struct timeval ast_samp2tv(unsigned int _nsamp, unsigned int _rate)
Returns a timeval corresponding to the duration of n samples at rate r. Useful to convert samples to ...
int ast_bridge_interval_hook(struct ast_bridge_features *features, enum ast_bridge_hook_timer_option flags, unsigned int interval, ast_bridge_hook_callback callback, void *hook_pvt, ast_bridge_hook_pvt_destructor destructor, enum ast_bridge_hook_remove_flags remove_flags)
Attach an interval hook to a bridge features structure.
#define ast_test_suite_event_notify(s, f,...)
#define ast_string_fields_copy(copy, orig)
Copy all string fields from one instance to another of the same structure.
int ast_bridge_features_limits_construct(struct ast_bridge_features_limits *limits)
Constructor function for ast_bridge_features_limits.
Structure that contains configuration information for the limits feature.
struct timeval ast_tvadd(struct timeval a, struct timeval b)
Returns the sum of two timevals a + b.
int ast_moh_start(struct ast_channel *chan, const char *mclass, const char *interpclass)
Turn on music on hold on a given channel.
#define ast_module_ref(mod)
Hold a reference to the module.
void ast_bridge_channel_leave_bridge(struct ast_bridge_channel *bridge_channel, enum bridge_channel_state new_state, int cause)
Set bridge channel state to leave bridge (if not leaving already).
const ast_string_field warning_sound
int ast_stream_and_wait(struct ast_channel *chan, const char *file, const char *digits)
stream file until digit If the file name is non-empty, try to play it.
const ast_string_field connect_sound
#define ast_module_unref(mod)
Release a reference to the module.
struct ast_channel * chan
Structure that contains information regarding a channel in a bridge.
int ast_say_number(struct ast_channel *chan, int num, const char *ints, const char *lang, const char *options)
says a number
Internal Asterisk hangup causes.
Say numbers and dates (maybe words one day too)
#define ASTERISK_GPL_KEY
The text the key() function should return.
Asterisk module definitions.
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
Application convenience functions, designed to give consistent look and feel to Asterisk apps...
int ast_bridge_interval_unregister(enum ast_bridge_builtin_interval interval)
Unregisters a handler for a built in interval feature.