40 #include "asterisk/stasis_channels.h"
73 .
type =
"hold_intercept",
77 static int remove_hold_intercept(
struct ast_channel *chan)
85 ast_log(AST_LOG_WARNING,
"Cannot remove HOLD_INTERCEPT from %s: HOLD_INTERCEPT not currently enabled\n",
86 ast_channel_name(chan));
89 data = datastore->
data;
92 ast_log(AST_LOG_WARNING,
"Failed to remove HOLD_INTERCEPT framehook from channel %s\n",
93 ast_channel_name(chan));
98 ast_log(AST_LOG_WARNING,
"Failed to remove HOLD_INTERCEPT datastore from channel %s\n",
99 ast_channel_name(chan));
144 static int set_hold_intercept(
struct ast_channel *chan)
149 .
version = AST_FRAMEHOOK_INTERFACE_VERSION,
152 .disable_inheritance = 1,
158 ast_log(AST_LOG_WARNING,
"HOLD_INTERCEPT already set on '%s'\n",
159 ast_channel_name(chan));
163 datastore = ast_datastore_alloc(&hold_intercept_datastore, NULL);
175 if (data->framehook_id < 0) {
176 ast_log(AST_LOG_WARNING,
"Failed to attach HOLD_INTERCEPT framehook to '%s'\n",
177 ast_channel_name(chan));
190 static int hold_intercept_fn_write(
struct ast_channel *chan,
const char *
function,
191 char *data,
const char *value)
199 if (ast_strlen_zero(data)) {
200 ast_log(AST_LOG_WARNING,
"HOLD_INTERCEPT requires an argument\n");
204 if (!strcasecmp(data,
"set")) {
205 res = set_hold_intercept(chan);
206 }
else if (!strcasecmp(data,
"remove")) {
207 res = remove_hold_intercept(chan);
209 ast_log(AST_LOG_WARNING,
"HOLD_INTERCEPT: unknown option %s\n", data);
218 .
name =
"HOLD_INTERCEPT",
219 .write = hold_intercept_fn_write,
223 static int unload_module(
void)
229 static int load_module(
void)
234 AST_MODULE_INFO_STANDARD(
ASTERISK_GPL_KEY,
"Hold interception dialplan function");
struct stasis_message_type * ast_channel_hold_type(void)
Message type for when a channel is placed on hold.
Main Channel structure associated with a channel.
Asterisk main include file. File version handling, generic pbx functions.
struct stasis_message_type * ast_channel_unhold_type(void)
Message type for when a channel is removed from hold.
static int hold_intercept_framehook_consume(void *data, enum ast_frame_type type)
Callback function which informs upstream if we are consuming a frame of a specific type...
void ast_channel_publish_cached_blob(struct ast_channel *chan, struct stasis_message_type *type, struct ast_json *blob)
Publish a channel blob message using the latest snapshot from the cache.
static struct ast_custom_function hold_intercept_function
Definition of the HOLD_INTERCEPT function.
Stasis Message Bus API. See Stasis Message Bus API for detailed documentation.
ast_framehook_event
These are the types of events that the framehook's event callback can receive.
int ast_framehook_detach(struct ast_channel *chan, int framehook_id)
Detach an framehook from a channel.
Structure for a data store type.
Structure for a data store object.
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.
int ast_custom_function_unregister(struct ast_custom_function *acf)
Unregister a custom function.
int ast_datastore_free(struct ast_datastore *datastore)
Free a data store object.
struct ast_frame_subclass subclass
int ast_framehook_attach(struct ast_channel *chan, struct ast_framehook_interface *i)
Attach an framehook onto a channel for frame interception.
#define SCOPED_CHANNELLOCK(varname, chan)
scoped lock specialization for channels.
General Asterisk PBX channel definitions.
Data structure associated with a custom dialplan function.
Asterisk internal frame definitions.
Core PBX routines and definitions.
ast_frame_type
Frame types.
static struct ast_frame * hold_intercept_framehook(struct ast_channel *chan, struct ast_frame *f, enum ast_framehook_event event, void *data)
Frame hook that is called to intercept hold/unhold.
#define ast_calloc(num, len)
A wrapper for calloc()
Module has failed to load, may be in an inconsistent state.
Private data structure used with the function's datastore.
static const struct ast_datastore_info hold_intercept_datastore
The channel datastore the function uses to store state.
struct ast_frame ast_null_frame
Data structure associated with a single frame of data.
enum ast_frame_type frametype
#define ASTERISK_GPL_KEY
The text the key() function should return.
Asterisk module definitions.
int ast_channel_datastore_add(struct ast_channel *chan, struct ast_datastore *datastore)
Add a datastore to a channel.
Application convenience functions, designed to give consistent look and feel to Asterisk apps...
int ast_channel_datastore_remove(struct ast_channel *chan, struct ast_datastore *datastore)
Remove a datastore from a channel.
#define ast_custom_function_register(acf)
Register a custom function.