Newer
Older
Mark Michelson
committed
char *mailbox = NULL;
char *name_context = NULL;
Tilghman Lesher
committed
AST_DECLARE_APP_ARGS(args,
AST_APP_ARG(context);
AST_APP_ARG(options);
);
Tilghman Lesher
committed
AST_STANDARD_APP_ARGS(args, data);
if (!ast_strlen_zero(args.context) && (ptr = strchr(args.context, '@'))) {
exten = args.context;
*ptr++ = '\0';
args.context = ptr;
Tilghman Lesher
committed
if (ast_strlen_zero(args.context))
args.context = ast_strdupa(chan->context);
if (args.options) {
Tilghman Lesher
committed
ast_app_parse_options(spy_opts, &flags, opts, args.options);
if (ast_test_flag(&flags, OPTION_GROUP))
mygroup = opts[OPT_ARG_GROUP];
if (ast_test_flag(&flags, OPTION_RECORD) &&
if (ast_test_flag(&flags, OPTION_VOLUME) && opts[OPT_ARG_VOLUME]) {
int vol;
if ((sscanf(opts[OPT_ARG_VOLUME], "%d", &vol) != 1) || (vol > 4) || (vol < -4))
ast_log(LOG_NOTICE, "Volume factor must be a number between -4 and 4\n");
else
volfactor = vol;
}
if (ast_test_flag(&flags, OPTION_PRIVATE))
ast_set_flag(&flags, OPTION_WHISPER);
Mark Michelson
committed
if (ast_test_flag(&flags, OPTION_NAME)) {
if (!ast_strlen_zero(opts[OPT_ARG_NAME])) {
char *delimiter;
if ((delimiter = strchr(opts[OPT_ARG_NAME], '@'))) {
mailbox = opts[OPT_ARG_NAME];
*delimiter++ = '\0';
name_context = delimiter;
} else {
mailbox = opts[OPT_ARG_NAME];
}
}
}
} else
ast_clear_flag(&flags, AST_FLAGS_ALL);
oldwf = chan->writeformat;
if (ast_set_write_format(chan, AST_FORMAT_SLINEAR) < 0) {
ast_log(LOG_ERROR, "Could Not Set Write Format.\n");
return -1;
}
if (recbase) {
snprintf(filename, sizeof(filename), "%s/%s.%d.raw", ast_config_AST_MONITOR_DIR, recbase, (int) time(NULL));
if ((fd = open(filename, O_CREAT | O_WRONLY | O_TRUNC, AST_FILE_MODE)) <= 0) {
ast_log(LOG_WARNING, "Cannot open '%s' for recording\n", filename);
fd = 0;
}
}
Mark Michelson
committed
res = common_exec(chan, &flags, volfactor, fd, mygroup, NULL, NULL, exten, args.context, mailbox, name_context);
Anthony Minessale II
committed
close(fd);
if (oldwf && ast_set_write_format(chan, oldwf) < 0)
Anthony Minessale II
committed
ast_log(LOG_ERROR, "Could Not Set Write Format.\n");
static int unload_module(void)
Russell Bryant
committed
res |= ast_unregister_application(app_chan);
res |= ast_unregister_application(app_ext);
Russell Bryant
committed
return res;
static int load_module(void)
int res = 0;
res |= ast_register_application(app_chan, chanspy_exec, tdesc, desc_chan);
res |= ast_register_application(app_ext, extenspy_exec, tdesc, desc_ext);
return res;
AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Listen to the audio of an active channel");