#include "asterisk.h"
#include "asterisk/pbx.h"
#include "asterisk/app.h"
#include "asterisk/module.h"
Go to the source code of this file.
Enumerations | |
enum | { OPT_OFFSET = (1 << 1) } |
enum | { OPT_ARG_OFFSET = 0, OPT_ARG_ARRAY_LEN } |
Functions | |
static void | __reg_module (void) |
static void | __unreg_module (void) |
static int | controlplayback_exec (struct ast_channel *chan, void *data) |
static int | is_argument (const char *haystack, int needle) |
static int | is_on_phonepad (char key) |
static int | load_module (void) |
static int | unload_module (void) |
Variables | |
static struct ast_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .description = "Control Playback Application" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = "a9c98e5d177805051735cb5b0b16b0a0" , .load = load_module, .unload = unload_module, } |
static const char * | app = "ControlPlayback" |
static struct ast_module_info * | ast_module_info = &__mod_info |
static struct ast_app_option | cpb_opts [128] = { [ 'o' ] = { .flag = OPT_OFFSET , .arg_index = OPT_ARG_OFFSET + 1 }, } |
static const char * | descrip |
static const char * | synopsis = "Play a file with fast forward and rewind" |
Definition in file app_controlplayback.c.
anonymous enum |
anonymous enum |
Definition at line 66 of file app_controlplayback.c.
00066 { 00067 OPT_ARG_OFFSET = 0, 00068 /* must stay as the last entry ... */ 00069 OPT_ARG_ARRAY_LEN, 00070 };
static void __reg_module | ( | void | ) | [static] |
Definition at line 191 of file app_controlplayback.c.
static void __unreg_module | ( | void | ) | [static] |
Definition at line 191 of file app_controlplayback.c.
static int controlplayback_exec | ( | struct ast_channel * | chan, | |
void * | data | |||
) | [static] |
Definition at line 93 of file app_controlplayback.c.
References AST_APP_ARG, ast_app_parse_options(), ast_control_streamfile(), AST_DECLARE_APP_ARGS, ast_log(), AST_STANDARD_APP_ARGS, ast_strdupa, ast_strlen_zero(), ast_test_flag, chan, cpb_opts, is_argument(), is_on_phonepad(), LOG_WARNING, OPT_ARG_ARRAY_LEN, OPT_ARG_OFFSET, OPT_OFFSET, pbx_builtin_setvar_helper(), skipms, and stop.
Referenced by load_module().
00094 { 00095 int res = 0; 00096 int skipms = 0; 00097 long offsetms = 0; 00098 char offsetbuf[20]; 00099 char stopkeybuf[2]; 00100 char *tmp; 00101 struct ast_flags opts = { 0, }; 00102 char *opt_args[OPT_ARG_ARRAY_LEN]; 00103 AST_DECLARE_APP_ARGS(args, 00104 AST_APP_ARG(filename); 00105 AST_APP_ARG(skip); 00106 AST_APP_ARG(fwd); 00107 AST_APP_ARG(rev); 00108 AST_APP_ARG(stop); 00109 AST_APP_ARG(pause); 00110 AST_APP_ARG(restart); 00111 AST_APP_ARG(options); 00112 ); 00113 00114 if (ast_strlen_zero(data)) { 00115 ast_log(LOG_WARNING, "ControlPlayback requires an argument (filename)\n"); 00116 return -1; 00117 } 00118 00119 tmp = ast_strdupa(data); 00120 AST_STANDARD_APP_ARGS(args, tmp); 00121 00122 if (args.argc < 1) { 00123 ast_log(LOG_WARNING, "ControlPlayback requires an argument (filename)\n"); 00124 return -1; 00125 } 00126 00127 skipms = args.skip ? (atoi(args.skip) ? atoi(args.skip) : 3000) : 3000; 00128 00129 if (!args.fwd || !is_on_phonepad(*args.fwd)) { 00130 char *digit = "#"; 00131 if (!is_argument(args.rev, *digit) && !is_argument(args.stop, *digit) && !is_argument(args.pause, *digit) && !is_argument(args.restart, *digit)) 00132 args.fwd = digit; 00133 else 00134 args.fwd = NULL; 00135 } 00136 if (!args.rev || !is_on_phonepad(*args.rev)) { 00137 char *digit = "*"; 00138 if (!is_argument(args.fwd, *digit) && !is_argument(args.stop, *digit) && !is_argument(args.pause, *digit) && !is_argument(args.restart, *digit)) 00139 args.rev = digit; 00140 else 00141 args.rev = NULL; 00142 } 00143 ast_log(LOG_WARNING, "args.fwd = %s, args.rew = %s\n", args.fwd, args.rev); 00144 if (args.stop && !is_on_phonepad(*args.stop)) 00145 args.stop = NULL; 00146 if (args.pause && !is_on_phonepad(*args.pause)) 00147 args.pause = NULL; 00148 if (args.restart && !is_on_phonepad(*args.restart)) 00149 args.restart = NULL; 00150 00151 if (args.options) { 00152 ast_app_parse_options(cpb_opts, &opts, opt_args, args.options); 00153 if (ast_test_flag(&opts, OPT_OFFSET)) 00154 offsetms = atol(opt_args[OPT_ARG_OFFSET]); 00155 } 00156 00157 res = ast_control_streamfile(chan, args.filename, args.fwd, args.rev, args.stop, args.pause, args.restart, skipms, &offsetms); 00158 00159 /* If we stopped on one of our stop keys, return 0 */ 00160 if (res > 0 && args.stop && strchr(args.stop, res)) { 00161 pbx_builtin_setvar_helper(chan, "CPLAYBACKSTATUS", "USERSTOPPED"); 00162 snprintf(stopkeybuf, sizeof(stopkeybuf), "%c", res); 00163 pbx_builtin_setvar_helper(chan, "CPLAYBACKSTOPKEY", stopkeybuf); 00164 res = 0; 00165 } else { 00166 if (res < 0) { 00167 res = 0; 00168 pbx_builtin_setvar_helper(chan, "CPLAYBACKSTATUS", "ERROR"); 00169 } else 00170 pbx_builtin_setvar_helper(chan, "CPLAYBACKSTATUS", "SUCCESS"); 00171 } 00172 00173 snprintf(offsetbuf, sizeof(offsetbuf), "%ld", offsetms); 00174 pbx_builtin_setvar_helper(chan, "CPLAYBACKOFFSET", offsetbuf); 00175 00176 return res; 00177 }
static int is_argument | ( | const char * | haystack, | |
int | needle | |||
) | [static] |
Definition at line 82 of file app_controlplayback.c.
References ast_strlen_zero().
Referenced by controlplayback_exec().
00083 { 00084 if (ast_strlen_zero(haystack)) 00085 return 0; 00086 00087 if (strchr(haystack, needle)) 00088 return -1; 00089 00090 return 0; 00091 }
static int is_on_phonepad | ( | char | key | ) | [static] |
static int load_module | ( | void | ) | [static] |
Definition at line 186 of file app_controlplayback.c.
References ast_register_application, and controlplayback_exec().
00187 { 00188 return ast_register_application(app, controlplayback_exec, synopsis, descrip); 00189 }
static int unload_module | ( | void | ) | [static] |
Definition at line 179 of file app_controlplayback.c.
References ast_unregister_application().
00180 { 00181 int res; 00182 res = ast_unregister_application(app); 00183 return res; 00184 }
struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .description = "Control Playback Application" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = "a9c98e5d177805051735cb5b0b16b0a0" , .load = load_module, .unload = unload_module, } [static] |
Definition at line 191 of file app_controlplayback.c.
const char* app = "ControlPlayback" [static] |
Definition at line 36 of file app_controlplayback.c.
struct ast_module_info* ast_module_info = &__mod_info [static] |
Definition at line 191 of file app_controlplayback.c.
struct ast_app_option cpb_opts[128] = { [ 'o' ] = { .flag = OPT_OFFSET , .arg_index = OPT_ARG_OFFSET + 1 }, } [static] |
const char* descrip [static] |
Definition at line 40 of file app_controlplayback.c.
const char* synopsis = "Play a file with fast forward and rewind" [static] |
Definition at line 38 of file app_controlplayback.c.