92 VOLUMEFLAG_CHANGE = (1 << 1),
133 vi = datastore->
data;
136 if (ast_test_flag(vi, VOLUMEFLAG_CHANGE)) {
137 if (frame->
frametype == AST_FRAME_DTMF) {
163 static int volume_write(
struct ast_channel *chan,
const char *cmd,
char *data,
const char *value)
177 ast_log(LOG_WARNING,
"No channel was provided to %s function.\n", cmd);
183 ast_channel_lock(chan);
185 ast_channel_unlock(chan);
187 if (!(datastore = ast_datastore_alloc(&volume_datastore, NULL)))
198 ast_channel_unlock(chan);
199 vi = datastore->
data;
203 if (ast_strlen_zero(args.direction)) {
204 ast_log(LOG_ERROR,
"Direction must be specified for VOLUME function\n");
208 if (!strcasecmp(args.direction,
"tx")) {
209 vi->tx_gain = atof(value);
210 }
else if (!strcasecmp(args.direction,
"rx")) {
211 vi->rx_gain = atof(value);
213 ast_log(LOG_ERROR,
"Direction must be either RX or TX\n");
217 datastore->
data = vi;
218 ast_channel_lock(chan);
220 ast_channel_unlock(chan);
226 if (!ast_strlen_zero(args.options)) {
229 vi->flags = flags.flags;
237 static int volume_read(
struct ast_channel *chan,
const char *cmd,
char *data,
char *buffer,
size_t buflen)
250 ast_log(LOG_WARNING,
"No channel was provided to %s function.\n", cmd);
256 ast_channel_lock(chan);
258 ast_channel_unlock(chan);
261 ast_channel_unlock(chan);
262 vi = datastore->
data;
266 if (ast_strlen_zero(args.direction)) {
267 ast_log(LOG_ERROR,
"Direction must be specified for VOLUME function\n");
271 if (!strcasecmp(args.direction,
"tx")) {
272 snprintf(buffer, buflen,
"%f", vi->tx_gain);
273 }
else if (!strcasecmp(args.direction,
"rx")) {
274 snprintf(buffer, buflen,
"%f", vi->rx_gain);
276 ast_log(LOG_ERROR,
"Direction must be either RX or TX\n");
284 .write = volume_write,
288 static int unload_module(
void)
293 static int load_module(
void)
298 AST_MODULE_INFO_STANDARD(
ASTERISK_GPL_KEY,
"Technology independent volume control");
Main Channel structure associated with a channel.
Asterisk main include file. File version handling, generic pbx functions.
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the 'standard' argument separation process for an application.
Structure for a data store type.
int ast_audiohook_attach(struct ast_channel *chan, struct ast_audiohook *audiohook)
Attach audiohook to channel.
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_audiohook_destroy(struct ast_audiohook *audiohook)
Destroys an audiohook structure.
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_frame_adjust_volume_float(struct ast_frame *f, float adjustment)
Adjusts the volume of the audio samples contained in a frame.
#define AST_APP_OPTIONS(holder, options...)
Declares an array of options for an application.
ast_audiohook_manipulate_callback manipulate_callback
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_unlock(ah)
Unlock an audiohook.
static const struct ast_datastore_info volume_datastore
Static structure for datastore information.
General Asterisk PBX channel definitions.
Data structure associated with a custom dialplan function.
int ast_app_parse_options(const struct ast_app_option *options, struct ast_flags *flags, char **args, char *optstr)
Parses a string containing application options and sets flags/arguments.
Core PBX routines and definitions.
int ast_audiohook_detach(struct ast_audiohook *audiohook)
Detach audiohook from channel.
static void destroy_callback(void *data)
Helper function used by datastores to destroy the speech structure upon hangup.
#define ast_calloc(num, len)
A wrapper for calloc()
Structure used to handle boolean flags.
Data structure associated with a single frame of data.
enum ast_audiohook_status status
enum ast_frame_type frametype
#define AST_APP_OPTION(option, flagno)
Declares an application option that does not accept an argument.
#define ASTERISK_GPL_KEY
The text the key() function should return.
#define ast_audiohook_lock(ah)
Lock an audiohook.
Asterisk module definitions.
int ast_channel_datastore_add(struct ast_channel *chan, struct ast_datastore *datastore)
Add a datastore to a channel.
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
Application convenience functions, designed to give consistent look and feel to Asterisk apps...
#define ast_custom_function_register(acf)
Register a custom function.
#define AST_APP_ARG(name)
Define an application argument.