164 static const char app[] =
"ControlPlayback";
167 OPT_OFFSET = (1 << 1),
181 static int is_on_phonepad(
char key)
183 return key == 35 || key == 42 || (key >= 48 && key <= 57);
186 static int is_argument(
const char *haystack,
int needle)
188 if (ast_strlen_zero(haystack))
191 if (strchr(haystack, needle))
197 static int controlplayback_exec(
struct ast_channel *
chan,
const char *data)
206 char *opt_args[OPT_ARG_ARRAY_LEN];
218 if (ast_strlen_zero(data)) {
219 ast_log(LOG_WARNING,
"ControlPlayback requires an argument (filename)\n");
227 ast_log(LOG_WARNING,
"ControlPlayback requires an argument (filename)\n");
231 skipms = args.skip ? (atoi(args.skip) ? atoi(args.skip) : 3000) : 3000;
233 if (!args.fwd || !is_on_phonepad(*args.fwd)) {
235 if (!is_argument(args.rev, *digit) && !is_argument(args.stop, *digit) && !is_argument(args.pause, *digit) && !is_argument(args.restart, *digit))
240 if (!args.rev || !is_on_phonepad(*args.rev)) {
242 if (!is_argument(args.fwd, *digit) && !is_argument(args.stop, *digit) && !is_argument(args.pause, *digit) && !is_argument(args.restart, *digit))
247 ast_debug(1,
"Forward key = %s, Rewind key = %s\n", args.fwd, args.rev);
248 if (args.stop && !is_on_phonepad(*args.stop))
250 if (args.pause && !is_on_phonepad(*args.pause))
252 if (args.restart && !is_on_phonepad(*args.restart))
257 if (ast_test_flag(&opts, OPT_OFFSET))
258 offsetms = atol(opt_args[OPT_ARG_OFFSET]);
261 res =
ast_control_streamfile(chan, args.filename, args.fwd, args.rev, args.stop, args.pause, args.restart, skipms, &offsetms);
264 if (res > 0 && args.stop && strchr(args.stop, res)) {
266 snprintf(stopkeybuf,
sizeof(stopkeybuf),
"%c", res);
280 snprintf(offsetbuf,
sizeof(offsetbuf),
"%ld", offsetms);
286 static int controlplayback_manager(
struct mansession *s,
const struct message *m)
292 if (ast_strlen_zero(channel_name)) {
297 if (ast_strlen_zero(control_type)) {
308 if (!strcasecmp(control_type,
"stop")) {
310 }
else if (!strcasecmp(control_type,
"forward")) {
312 }
else if (!strcasecmp(control_type,
"reverse")) {
314 }
else if (!strcasecmp(control_type,
"pause")) {
316 }
else if (!strcasecmp(control_type,
"restart")) {
329 static int unload_module(
void)
339 static int load_module(
void)
Main Channel structure associated with a channel.
Asterisk main include file. File version handling, generic pbx functions.
int ast_queue_control(struct ast_channel *chan, enum ast_control_frame_type control)
Queue a control frame without payload.
struct ast_channel * chan
#define ast_channel_unref(c)
Decrease channel reference count.
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the 'standard' argument separation process for an application.
void astman_send_ack(struct mansession *s, const struct message *m, char *msg)
Send ack in manager transaction.
int ast_control_streamfile(struct ast_channel *chan, const char *file, const char *fwd, const char *rev, const char *stop, const char *pause, const char *restart, int skipms, long *offsetms)
Stream a file with fast forward, pause, reverse, restart.
int ast_unregister_application(const char *app)
Unregister an application.
const char * astman_get_header(const struct message *m, char *var)
Get header from manager transaction.
#define AST_APP_OPTIONS(holder, options...)
Declares an array of options for an application.
#define ast_strdupa(s)
duplicate a string in memory from the stack
In case you didn't read that giant block of text above the mansession_session struct, the mansession is named this solely to keep the API the same in Asterisk. This structure really represents data that is different from Manager action to Manager action. The mansession_session pointer contained within points to session-specific data.
#define ast_debug(level,...)
Log a DEBUG message.
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_manager_unregister(const char *action)
Unregister a registered manager command.
The AMI - Asterisk Manager Interface - is a TCP protocol created to manage Asterisk with third-party ...
#define AST_APP_OPTION_ARG(option, flagno, argno)
Declares an application option that accepts an argument.
Structure used to handle boolean flags.
int pbx_builtin_setvar_helper(struct ast_channel *chan, const char *name, const char *value)
Add a variable to the channel variable stack, removing the most recently set value for the same name...
#define ast_manager_register_xml(action, authority, func)
Register a manager callback using XML documentation to describe the manager.
#define ASTERISK_GPL_KEY
The text the key() function should return.
struct ast_channel * ast_channel_get_by_name(const char *name)
Find a channel by name.
void astman_send_error(struct mansession *s, const struct message *m, char *error)
Send error in manager transaction.
Asterisk module definitions.
#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_register_application_xml(app, execute)
Register an application using XML documentation.
#define AST_APP_ARG(name)
Define an application argument.