48 static const char config[] =
"indications.conf";
51 8, 8, 9, 9, 10, 10, 11, 12, 12, 13,
52 14, 15, 16, 17, 18, 19, 20, 21, 23, 24,
53 25, 27, 29, 30, 32, 34, 36, 38, 41, 43,
54 46, 48, 51, 55, 58, 61, 65, 69, 73, 77,
55 82, 87, 92, 97, 103, 110, 116, 123, 130, 138,
56 146, 155, 164, 174, 184, 195, 207, 220, 233, 246,
57 261, 277, 293, 311, 329, 349, 369, 391, 415, 440,
58 466, 493, 523, 554, 587, 622, 659, 698, 739, 783,
59 830, 880, 932, 987, 1046, 1108, 1174, 1244, 1318, 1396,
60 1479, 1567, 1661, 1760, 1864, 1975, 2093, 2217, 2349, 2489,
61 2637, 2793, 2959, 3135, 3322, 3520, 3729, 3951, 4186, 4434,
62 4698, 4978, 5274, 5587, 5919, 6271, 6644, 7040, 7458, 7902,
63 8372, 8869, 9397, 9956, 10548, 11175, 11839, 12543
68 #define NUM_TONE_ZONE_BUCKETS 53 171 if (len >
sizeof(ps->
data) / 2 - 1) {
176 memset(&ps->
f, 0,
sizeof(ps->
f));
191 for (x = 0; x < samples; x++) {
201 p = ps->
v3_2 - 32768;
205 p = ((p * 9) / 10) + 1;
247 if (sscanf(s,
"%30u+%30u/%30u", &tone_data->
freq1, &tone_data->
freq2,
248 &tone_data->
time) == 3) {
250 }
else if (sscanf(s,
"%30u+%30u", &tone_data->
freq1, &tone_data->
freq2) == 2) {
253 }
else if (sscanf(s,
"%30u*%30u/%30u", &tone_data->
freq1, &tone_data->
freq2,
254 &tone_data->
time) == 3) {
257 }
else if (sscanf(s,
"%30u*%30u", &tone_data->
freq1, &tone_data->
freq2) == 2) {
261 }
else if (sscanf(s,
"%30u/%30u", &tone_data->
freq1, &tone_data->
time) == 2) {
263 tone_data->
freq2 = 0;
264 }
else if (sscanf(s,
"%30u", &tone_data->
freq1) == 1) {
266 tone_data->
freq2 = 0;
268 }
else if (sscanf(s,
"M%30u+M%30u/%30u", &tone_data->
freq1, &tone_data->
freq2,
269 &tone_data->
time) == 3) {
272 }
else if (sscanf(s,
"M%30u+M%30u", &tone_data->
freq1, &tone_data->
freq2) == 2) {
276 }
else if (sscanf(s,
"M%30u*M%30u/%30u", &tone_data->
freq1, &tone_data->
freq2,
277 &tone_data->
time) == 3) {
281 }
else if (sscanf(s,
"M%30u*M%30u", &tone_data->
freq1, &tone_data->
freq2) == 2) {
286 }
else if (sscanf(s,
"M%30u/%30u", &tone_data->
freq1, &tone_data->
time) == 2) {
288 tone_data->
freq2 = -1;
290 }
else if (sscanf(s,
"M%30u", &tone_data->
freq1) == 1) {
292 tone_data->
freq2 = -1;
308 static const float sample_rate = 8000.0;
309 static const float max_sample_val = 32768.0;
320 if (strchr(stringp,
'|')) {
335 }
else if (d.
reppos == -1) {
346 if (tone_data.
freq1 <= 127) {
352 if (tone_data.
freq2 <= 127) {
418 ast_verb(3,
"Setting default indication country to '%s'\n", country);
421 if (default_tone_zone) {
442 if (default_tone_zone) {
464 if (default_tone_zone) {
478 if (!strcasecmp(ts->
name, indication)) {
529 if (!default_tone_zone) {
558 if (default_tone_zone == tz) {
574 const char *tonelist)
583 if (!strcasecmp(indication, ts->
name)) {
616 if (!strcasecmp(indication, ts->
name)) {
641 wordlen = strlen(a->
word);
661 int created_country = 0;
668 "Usage: indication add <country> <indication> \"<tonelist>\"\n" 669 " Add the given indication to the country.\n";
710 if (created_country) {
739 wordlen = strlen(a->
word);
743 if (!strncasecmp(a->
word, ts->
name, wordlen)) {
763 e->
command =
"indication remove";
765 "Usage: indication remove <country> [indication]\n" 766 " Remove the given indication from the country.\n";
811 int found_country = 0;
816 e->
command =
"indication show";
818 "Usage: indication show [<country> ...]\n" 819 " Display either a condensed summary of all countries and indications, or a\n" 820 " more verbose list of indications for the specified countries.\n";
830 ast_cli(a->
fd,
"===========================\n");
844 for (i = 2; i < a->
argc; i++) {
857 if (!found_country) {
859 ast_cli(a->
fd,
"Country Indication PlayList\n");
860 ast_cli(a->
fd,
"=====================================\n");
881 if (!found_country) {
882 ast_cli(a->
fd,
"No countries matched your criteria.\n");
906 char *ring, *
c =
buf;
910 while ((ring =
strsep(&c,
","))) {
915 if (!isdigit(ring[0]) || (value = atoi(ring)) == -1) {
1048 const char *cxt =
NULL;
1070 if (!strcasecmp(cxt,
"general")) {
1075 goto return_cleanup;
1127 if (default_tone_zone) {
1129 default_tone_zone =
NULL;
1131 if (ast_tone_zones) {
1133 ast_tone_zones =
NULL;
1144 if (!ast_tone_zones) {
1169 .requires =
"extconfig",
struct ast_variable * next
Main Channel structure associated with a channel.
#define AST_CLI_DEFINE(fn, txt,...)
Asterisk locking-related definitions:
Asterisk main include file. File version handling, generic pbx functions.
#define ast_realloc(p, len)
A wrapper for realloc()
int ao2_container_count(struct ao2_container *c)
Returns the number of elements in a container.
char description[40]
Text description of the given country.
static char * handle_cli_indication_show(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static struct ast_tone_zone * ast_tone_zone_unref(struct ast_tone_zone *tz)
Release a reference to an ast_tone_zone.
static char * complete_country(struct ast_cli_args *a)
void *(* alloc)(struct ast_channel *chan, void *params)
int ast_cli_unregister_multiple(struct ast_cli_entry *e, int len)
Unregister multiple commands.
char country[MAX_TONEZONE_COUNTRY]
Country code that this set of tones is for.
static struct ast_tone_zone * default_tone_zone
static char * handle_cli_indication_add(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
struct ast_variable * ast_variable_browse(const struct ast_config *config, const char *category_name)
int ast_activate_generator(struct ast_channel *chan, struct ast_generator *gen, void *params)
#define ast_set_flag(p, flag)
descriptor for a cli entry.
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
#define ast_tone_zone_unlock(tz)
Unlock an ast_tone_zone.
static struct ao2_container * ast_tone_zones
#define ao2_callback(c, flags, cb_fn, arg)
#define CONFIG_STATUS_FILEINVALID
A description of a part of a tone.
int ast_tone_zone_part_parse(const char *s, struct ast_tone_zone_part *tone_data)
Parse a tone part.
static int reload_module(void)
Reload indications module.
struct ast_config * ast_config_load2(const char *filename, const char *who_asked, struct ast_flags flags)
Load a config file.
Structure for variables, used for configurations and for channel variables.
static int load_module(void)
Load indications module.
static int ast_tone_zone_cmp(void *obj, void *arg, int flags)
static int prune_tone_zone(void *obj, void *arg, int flags)
Prune tones no longer in the configuration, and have the tone zone unlinked if it is no longer in the...
int ast_str_append(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Append to a thread local dynamic string.
#define ast_cli_register_multiple(e, len)
Register multiple commands.
void ao2_iterator_destroy(struct ao2_iterator *iter)
Destroy a container iterator.
static char * complete_indications(struct ast_cli_args *a)
#define AST_LIST_EMPTY(head)
Checks whether the specified list contains any entries.
#define ao2_alloc_options(data_size, destructor_fn, options)
static int ast_unregister_indication(struct ast_tone_zone *zone, const char *indication)
remove an existing country's indication. Both country and indication must exist
#define ast_str_alloca(init_len)
#define ast_strdup(str)
A wrapper for strdup()
char * ast_category_browse(struct ast_config *config, const char *prev_name)
Browse categories.
#define CV_END
close a variable parsing block
static void reset_tone_zone(struct ast_tone_zone *zone)
void ast_cli(int fd, const char *fmt,...)
static struct ast_generator playtones
static int ast_register_indication(struct ast_tone_zone *zone, const char *indication, const char *tonelist)
#define CV_START(__in_var, __in_val)
the macro to open a block for variable parsing
#define AST_LIST_TRAVERSE_SAFE_END
Closes a safe loop traversal block.
#define ast_verb(level,...)
#define CV_STR(__x, __dst)
struct ast_frame_subclass subclass
#define ast_strlen_zero(foo)
static struct ast_tone_zone * ast_tone_zone_alloc(void)
static int tone_zone_mark(void *obj, void *arg, int flags)
Mark the zone and its tones before parsing configuration. We will use this to know what to remove aft...
int ast_str_set(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Set a dynamic string using variable arguments.
#define CV_F(__pattern, __body)
call a generic function if the name matches.
static int is_valid_tone_zone(struct ast_tone_zone *zone)
static int ast_register_indication_country(struct ast_tone_zone *zone)
add a new country, if country exists, it will be replaced.
General Asterisk PBX channel definitions.
#define AST_FRIENDLY_OFFSET
Offset into a frame's data buffer.
A set of tones for a given locale.
static int unload_module(void)
static void ast_tone_zone_destructor(void *obj)
deallocate the passed tone zone
struct playtones_item * items
char * ast_strip(char *s)
Strip leading/trailing whitespace from a string.
static struct ast_cli_entry cli_indications[]
CLI entries for commands provided by this module.
#define AST_LIST_REMOVE_CURRENT(field)
Removes the current entry from a list during a traversal.
Asterisk internal frame definitions.
#define ao2_ref(o, delta)
void ast_config_destroy(struct ast_config *config)
Destroys a config.
#define ast_strdupa(s)
duplicate a string in memory from the stack
static struct ast_tone_zone_sound * ast_tone_zone_sound_unref(struct ast_tone_zone_sound *ts)
Release a reference to an ast_tone_zone_sound.
A set of macros to manage forward-linked lists.
int ast_set_write_format(struct ast_channel *chan, struct ast_format *format)
Sets write format on channel chan.
#define AST_LIST_REMOVE_HEAD(head, field)
Removes and returns the head entry from a list.
void ast_playtones_stop(struct ast_channel *chan)
Stop playing tones on a channel.
int ast_playtones_start(struct ast_channel *chan, int vol, const char *playlst, int interruptible)
Start playing a list of tones on a channel.
static void store_config_tone_zone(struct ast_tone_zone *zone, const char *var, const char *value)
const char * name
Name of the tone. For example, "busy".
#define CONFIG_STATUS_FILEUNCHANGED
static int playtones_generator(struct ast_channel *chan, void *data, int len, int samples)
#define AST_LIST_INSERT_TAIL(head, elm, field)
Appends a list entry to the tail of a list.
#define ao2_container_alloc_hash(ao2_options, container_options, n_buckets, hash_fn, sort_fn, cmp_fn)
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
static struct ast_tone_zone_sound * ast_tone_zone_sound_ref(struct ast_tone_zone_sound *ts)
Increase the reference count on an ast_tone_zone_sound.
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
static struct ast_tone_zone * ast_tone_zone_ref(struct ast_tone_zone *tz)
Increase the reference count on an ast_tone_zone.
#define ao2_iterator_next(iter)
#define ao2_alloc(data_size, destructor_fn)
#define NUM_TONE_ZONE_BUCKETS
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
static void * playtones_alloc(struct ast_channel *chan, void *params)
struct ao2_iterator ast_tone_zone_iterator_init(void)
Get an iterator for the available tone zones.
#define ast_calloc(num, len)
A wrapper for calloc()
int ast_tone_zone_count(void)
Get the number of registered tone zones.
Module could not be loaded properly.
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.
Prototypes for public functions only of internal interest,.
struct playtones_item * items
#define ao2_find(container, arg, flags)
static int ast_tone_zone_hash(const void *obj, const int flags)
Structure used to handle boolean flags.
#define ast_clear_flag(p, flag)
AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS|AST_MODFLAG_LOAD_ORDER, "HTTP Phone Provisioning",.support_level=AST_MODULE_SUPPORT_EXTENDED,.load=load_module,.unload=unload_module,.reload=reload,.load_pri=AST_MODPRI_CHANNEL_DEPEND,.requires="http",)
int * ringcadence
Array of ring cadence parts.
struct ast_tone_zone * ast_get_indication_zone(const char *country)
locate ast_tone_zone, given the country. if country == NULL, use the default country ...
static int load_indications(int reload)
load indications module
#define CONFIG_STATUS_FILEMISSING
const char * ast_variable_retrieve(struct ast_config *config, const char *category, const char *variable)
void ast_deactivate_generator(struct ast_channel *chan)
static int parse_tone_zone(struct ast_config *cfg, const char *country)
char * strsep(char **str, const char *delims)
When we need to walk through a container, we use an ao2_iterator to keep track of the current positio...
static int ast_set_indication_country(const char *country)
Set global indication country If no country is specified or we are unable to find the zone...
Standard Command Line Interface.
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
unsigned int nrringcadence
Number of ring cadence elements in the ringcadence array.
const char * ast_channel_name(const struct ast_channel *chan)
struct ast_format * origwfmt
Data structure associated with a single frame of data.
static void ast_tone_zone_sound_destructor(void *obj)
static const char config[]
const char * data
Description of a tone.
#define ast_tone_zone_lock(tz)
Lock an ast_tone_zone.
union ast_frame::@263 data
#define AST_LIST_TRAVERSE_SAFE_BEGIN(head, var, field)
Loops safely over (traverses) the entries in a list.
enum ast_frame_type frametype
struct ast_flags * ast_channel_flags(struct ast_channel *chan)
struct ast_format * format
struct ast_tone_zone_sound * ast_get_indication_tone(const struct ast_tone_zone *_zone, const char *indication)
Locate a tone zone sound.
int ast_cli_completion_add(char *value)
Add a result to a request for completion options.
static void store_tone_zone_ring_cadence(struct ast_tone_zone *zone, const char *val)
#define ASTERISK_GPL_KEY
The text the key() function should return.
Asterisk module definitions.
struct ast_format * ast_channel_writeformat(struct ast_channel *chan)
static const int midi_tohz[128]
static void playtones_release(struct ast_channel *chan, void *params)
static char * handle_cli_indication_remove(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
struct ao2_iterator ao2_iterator_init(struct ao2_container *c, int flags) attribute_warn_unused_result
Create an iterator for a container.
static int ast_unregister_indication_country(const char *country)
remove an existing country and all its indications, country must exist.
static force_inline int attribute_pure ast_str_case_hash(const char *str)
Compute a hash value on a case-insensitive string.
struct ast_tone_zone::@271 tones
A list of tones for this locale.
#define ao2_link(container, obj)