93static const char context_name[] =
"__func_periodic_hook_context__";
177 .
name =
"HOOK_CHANNEL",
268 state->last_hook = now;
302 snprintf(
uid,
sizeof(
uid),
"%u", hook_id);
330 unsigned int interval;
335 sscanf(
args.interval,
"%30u", &interval) != 1 || interval == 0) {
345 ast_debug(1,
"hook to %s@%s enabled on %s with interval of %u seconds\n",
443 .
name =
"PERIODIC_HOOK",
469 "Set",
"EncodedChannel=${HOOK_CHANNEL}",
472 "Set",
"GROUP_NAME=${EncodedChannel}${HOOK_ID}",
475 "Set",
"GROUP(periodic-hook)=${GROUP_NAME}",
478 "$[${GROUP_COUNT(${GROUP_NAME}@periodic-hook)} > 1]?Hangup()",
481 "Set",
"ChannelToSpy=${URIDECODE(${EncodedChannel})}",
503 unsigned int interval,
char *beep_id,
size_t len)
507 snprintf(
args,
sizeof(
args),
"%s,%s,%u",
527 .
requires =
"app_chanspy,func_cut,func_groupcount,func_uri",
Asterisk main include file. File version handling, generic pbx functions.
#define ast_strdup(str)
A wrapper for strdup()
#define ast_strdupa(s)
duplicate a string in memory from the stack
#define ast_asprintf(ret, fmt,...)
A wrapper for asprintf()
#define ast_calloc(num, len)
A wrapper for calloc()
@ AST_AUDIOHOOK_MANIPULATE_ALL_RATES
int ast_audiohook_init(struct ast_audiohook *audiohook, enum ast_audiohook_type type, const char *source, enum ast_audiohook_init_flags flags)
Initialize an audiohook structure.
#define ast_audiohook_lock(ah)
Lock an audiohook.
int ast_audiohook_detach(struct ast_audiohook *audiohook)
Detach audiohook from channel.
int ast_audiohook_attach(struct ast_channel *chan, struct ast_audiohook *audiohook)
Attach audiohook to channel.
int ast_audiohook_destroy(struct ast_audiohook *audiohook)
Destroys an audiohook structure.
#define ast_audiohook_unlock(ah)
Unlock an audiohook.
@ AST_AUDIOHOOK_TYPE_MANIPULATE
@ AST_AUDIOHOOK_STATUS_DONE
Periodic beeps into the audio of a call.
General Asterisk PBX channel definitions.
const char * ast_channel_name(const struct ast_channel *chan)
int ast_channel_datastore_add(struct ast_channel *chan, struct ast_datastore *datastore)
Add a datastore to a channel.
#define ast_channel_lock(chan)
#define ast_channel_unlock(chan)
#define AST_MAX_EXTENSION
struct ast_datastore * ast_channel_datastore_find(struct ast_channel *chan, const struct ast_datastore_info *info, const char *uid)
Find a datastore on a channel.
#define ast_datastore_alloc(info, uid)
int ast_datastore_free(struct ast_datastore *datastore)
Free a data store object.
static void * hook_launch_thread(void *data)
static void hook_datastore_destroy_callback(void *data)
static int hook_re_enable(struct ast_channel *chan, const char *uid)
static void hook_thread_arg_destroy(struct hook_thread_arg *arg)
static const char exten_name[]
static int hook_off(struct ast_channel *chan, const char *hook_id)
static struct hook_state * hook_state_alloc(const char *context, const char *exten, unsigned int interval, unsigned int hook_id)
static unsigned int global_hook_id
Last used hook ID.
static int hook_callback(struct ast_audiohook *audiohook, struct ast_channel *chan, struct ast_frame *frame, enum ast_audiohook_direction direction)
static int hook_write(struct ast_channel *chan, const char *cmd, char *data, const char *value)
static int hook_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
static struct ast_custom_function hook_function
int AST_OPTIONAL_API_NAME() ast_beep_start(struct ast_channel *chan, unsigned int interval, char *beep_id, size_t len)
static const char full_exten_name[]
static int do_hook(struct ast_channel *chan, struct hook_state *state)
static const char context_name[]
static int load_module(void)
static int hook_on(struct ast_channel *chan, const char *data, unsigned int hook_id)
static struct hook_thread_arg * hook_thread_arg_alloc(struct ast_channel *chan, struct hook_state *state)
static int unload_module(void)
int AST_OPTIONAL_API_NAME() ast_beep_stop(struct ast_channel *chan, const char *beep_id)
static const struct ast_datastore_info hook_datastore
static const char beep_exten[]
static int init_hook(struct ast_channel *chan, const char *context, const char *exten, unsigned int interval, unsigned int hook_id)
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
Application convenience functions, designed to give consistent look and feel to Asterisk apps.
#define AST_APP_ARG(name)
Define an application argument.
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the 'standard' argument separation process for an application.
#define ast_debug(level,...)
Log a DEBUG message.
int ast_atomic_fetchadd_int(volatile int *p, int v)
Atomically add v to *p and return the previous value of *p.
Asterisk module definitions.
@ AST_MODFLAG_GLOBAL_SYMBOLS
#define AST_MODULE_INFO(keystr, flags_to_set, desc, fields...)
@ AST_MODULE_SUPPORT_CORE
#define ASTERISK_GPL_KEY
The text the key() function should return.
@ AST_MODULE_LOAD_SUCCESS
@ AST_MODULE_LOAD_DECLINE
Module has failed to load, may be in an inconsistent state.
#define AST_OPTIONAL_API_NAME(name)
Expands to the name of the implementation function.
Core PBX routines and definitions.
int ast_add_extension(const char *context, int replace, const char *extension, int priority, const char *label, const char *callerid, const char *application, void *data, void(*datad)(void *), const char *registrar)
Add and extension to an extension context.
struct ast_context * ast_context_find_or_create(struct ast_context **extcontexts, struct ast_hashtab *exttable, const char *name, const char *registrar)
Register a new context or find an existing one.
int ast_pbx_outgoing_exten(const char *type, struct ast_format_cap *cap, const char *addr, int timeout, const char *context, const char *exten, int priority, int *reason, int synchronous, const char *cid_num, const char *cid_name, struct ast_variable *vars, const char *account, struct ast_channel **locked_channel, int early_media, const struct ast_assigned_ids *assignedids)
Synchronously or asynchronously make an outbound call and send it to a particular extension.
#define ast_custom_function_register_escalating(acf, escalation)
Register a custom function which requires escalated privileges.
void ast_context_destroy(struct ast_context *con, const char *registrar)
Destroy a context (matches the specified context or ANY context if NULL)
int ast_custom_function_unregister(struct ast_custom_function *acf)
Unregister a custom function.
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one.
int attribute_pure ast_true(const char *val)
Make sure something is true. Determine if a string containing a boolean value is "true"....
static force_inline int attribute_pure ast_strlen_zero(const char *s)
int attribute_pure ast_false(const char *val)
Make sure something is false. Determine if a string containing a boolean value is "false"....
enum ast_audiohook_status status
Main Channel structure associated with a channel.
Data structure associated with a custom dialplan function.
Structure for a data store type.
Structure for a data store object.
Data structure associated with a single frame of data.
Structure for variables, used for configurations and for channel variables.
struct ast_audiohook audiohook
audiohook used as a callback into this module
#define ast_test_suite_event_notify(s, f,...)
int64_t ast_tvdiff_ms(struct timeval end, struct timeval start)
Computes the difference (in milliseconds) between two struct timeval instances.
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
#define ast_pthread_create_detached_background(a, b, c, d)