72 static const char app[] =
"Milliwatt";
74 static const char digital_milliwatt[] = {0x1e,0x0b,0x0b,0x1e,0x9e,0x8b,0x8b,0x9e} ;
76 static void *milliwatt_alloc(
struct ast_channel *chan,
void *params)
87 static int milliwatt_generate(
struct ast_channel *chan,
void *
data,
int len,
int samples)
91 int i, *indexp = (
int *) data, res;
106 if (samples > maxsamples) {
107 ast_log(LOG_WARNING,
"Only doing %d samples (%d requested)\n", maxsamples, samples);
108 samples = maxsamples;
111 len = samples *
sizeof (buf[0]);
116 for (i = 0; i <
len; i++) {
117 buf[AST_FRIENDLY_OFFSET + i] = digital_milliwatt[(*indexp)++];
125 ast_log(LOG_WARNING,
"Failed to write frame to '%s': %s\n",ast_channel_name(chan),strerror(errno));
133 .alloc = milliwatt_alloc,
134 .release = milliwatt_release,
135 .generate = milliwatt_generate,
138 static int old_milliwatt_exec(
struct ast_channel *chan)
148 ast_log(LOG_WARNING,
"Failed to activate generator on '%s'\n",ast_channel_name(chan));
160 static int milliwatt_exec(
struct ast_channel *chan,
const char *data)
162 const char *options = data;
165 if (!ast_strlen_zero(options) && strchr(options,
'o')) {
166 return old_milliwatt_exec(chan);
168 if (!ast_strlen_zero(options) && strchr(options,
'm')) {
181 static int unload_module(
void)
186 static int load_module(
void)
191 AST_MODULE_INFO_STANDARD(
ASTERISK_GPL_KEY,
"Digital Milliwatt (mu-law) Test Application");
int ast_safe_sleep(struct ast_channel *chan, int ms)
Wait for a specified amount of time, looking for hangups.
Main Channel structure associated with a channel.
Asterisk main include file. File version handling, generic pbx functions.
int ast_activate_generator(struct ast_channel *chan, struct ast_generator *gen, void *params)
ast_channel_state
ast_channel states
int ast_unregister_application(const char *app)
Unregister an application.
struct ast_frame_subclass subclass
General Asterisk PBX channel definitions.
#define AST_FRIENDLY_OFFSET
Offset into a frame's data buffer.
int ast_set_read_format(struct ast_channel *chan, struct ast_format *format)
Sets read format on channel chan.
int ast_set_write_format(struct ast_channel *chan, struct ast_format *format)
Sets write format on channel chan.
Core PBX routines and definitions.
union ast_frame::@224 data
#define ast_calloc(num, len)
A wrapper for calloc()
int ast_write(struct ast_channel *chan, struct ast_frame *frame)
Write a frame to a channel This function writes the given frame to the indicated channel.
void ast_deactivate_generator(struct ast_channel *chan)
int ast_answer(struct ast_channel *chan)
Answer a channel.
Data structure associated with a single frame of data.
int ast_playtones_start(struct ast_channel *chan, int vol, const char *tonelist, int interruptible)
Start playing a list of tones on a channel.
enum ast_frame_type frametype
struct ast_format * format
#define ASTERISK_GPL_KEY
The text the key() function should return.
Asterisk module definitions.
#define ast_register_application_xml(app, execute)
Register an application using XML documentation.