37 #define _XOPEN_SOURCE 600
42 #include <sys/resource.h>
50 #pragma warning (disable:167)
70 #define fail() r = 255; goto end
73 int main(
int argc,
char *argv[])
79 char *file = NULL, *script = NULL;
81 const char *err = NULL;
83 int i = 0, c = 1, help = 0;
85 for(i = 1; i < argc; i++) {
86 if (!strstr(argv[i],
"-"))
break;
88 if (!strcmp(argv[i],
"-v")) {
92 if (!strcmp(argv[i],
"-s")) {
96 if (!strcmp(argv[i],
"-h")) {
100 if (!strncmp(argv[i],
"-R", 2)) {
101 char *p = argv[i] + 2;
112 if (argc - i != 2 || help) {
115 if (!help) printf(
"Invalid input!\n");
117 if ((app = strrchr(argv[0],
'/'))) {
124 printf(
"USAGE: %s [options] <file> <tones>\n", app);
125 printf(
"================================================================================\n");
129 "-R<rate>\tSet Rate (8000,16000,32000,48000) etc.\n"
130 "-v\t\tVerbose Logging\n"
131 "<file>\t\tAny file supported by libsndfile\n"
132 "<tones>\t\tA valid teletone script http://wiki.freeswitch.org/wiki/TGML"
142 printf(
"Cannot init core [%s]\n", err);
149 printf(
"Cannot init mod_sndfile [%s]\n", err);
154 printf(
"Cannot open file %s\n", file);
161 ts.
duration = 250 * (rate / 1000 / c);
162 ts.
wait = 50 * (rate / 1000 / c);
171 printf(
"File: %s generated...\n\nPlease support:\nFreeSWITCH http://www.freeswitch.org\nClueCon http://www.cluecon.com\n", file);
static int teletone_handler(teletone_generation_session_t *ts, teletone_tone_map_t *map)
switch_status_t switch_loadable_module_load_module(char *dir, char *fname, switch_bool_t runtime, const char **err)
Load a module.
An abstraction to store a tone mapping.
switch_status_t switch_core_init(_In_ switch_core_flag_t flags, _In_ switch_bool_t console, _Out_ const char **err)
Initilize the core.
teletone_audio_t * buffer
int teletone_mux_tones(teletone_generation_session_t *ts, teletone_tone_map_t *map)
Execute a single tone generation instruction.
switch_status_t switch_core_destroy(void)
Destroy the core.
int teletone_destroy_session(teletone_generation_session_t *ts)
Free the buffer allocated by a tone generation session.
int teletone_run(teletone_generation_session_t *ts, const char *cmd)
Execute a tone generation script and call callbacks after each instruction.
int teletone_init_session(teletone_generation_session_t *ts, int buflen, tone_handler handler, void *user_data)
Initilize a tone generation session.
switch_directories SWITCH_GLOBAL_dirs
An abstraction to store a tone generation session.
int main(int argc, char *argv[])
switch_status_t switch_loadable_module_init(switch_bool_t autoload)
Initilize the module backend and load all the modules.