Asterisk - The Open Source Telephony Project
18.5.0
|
Indication Tone Handling. More...
#include "asterisk.h"
#include <math.h>
#include "asterisk/lock.h"
#include "asterisk/linkedlists.h"
#include "asterisk/indications.h"
#include "asterisk/frame.h"
#include "asterisk/format_cache.h"
#include "asterisk/channel.h"
#include "asterisk/utils.h"
#include "asterisk/cli.h"
#include "asterisk/module.h"
#include "asterisk/astobj2.h"
#include "asterisk/_private.h"
Go to the source code of this file.
Data Structures | |
struct | playtones_def |
struct | playtones_item |
struct | playtones_state |
Macros | |
#define | NUM_TONE_ZONE_BUCKETS 53 |
Functions | |
static void | __reg_module (void) |
static void | __unreg_module (void) |
struct ast_tone_zone_sound * | ast_get_indication_tone (const struct ast_tone_zone *_zone, const char *indication) |
Locate a tone zone sound. More... | |
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 More... | |
struct ast_module * | AST_MODULE_SELF_SYM (void) |
int | ast_playtones_start (struct ast_channel *chan, int vol, const char *playlst, int interruptible) |
Start playing a list of tones on a channel. More... | |
void | ast_playtones_stop (struct ast_channel *chan) |
Stop playing tones on a channel. More... | |
static int | ast_register_indication (struct ast_tone_zone *zone, const char *indication, const char *tonelist) |
static int | ast_register_indication_country (struct ast_tone_zone *zone) |
add a new country, if country exists, it will be replaced. More... | |
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, then return not found. More... | |
static struct ast_tone_zone * | ast_tone_zone_alloc (void) |
static int | ast_tone_zone_cmp (void *obj, void *arg, int flags) |
int | ast_tone_zone_count (void) |
Get the number of registered tone zones. More... | |
static void | ast_tone_zone_destructor (void *obj) |
deallocate the passed tone zone More... | |
static int | ast_tone_zone_hash (const void *obj, const int flags) |
struct ao2_iterator | ast_tone_zone_iterator_init (void) |
Get an iterator for the available tone zones. More... | |
int | ast_tone_zone_part_parse (const char *s, struct ast_tone_zone_part *tone_data) |
Parse a tone part. More... | |
static void | ast_tone_zone_sound_destructor (void *obj) |
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 More... | |
static int | ast_unregister_indication_country (const char *country) |
remove an existing country and all its indications, country must exist. More... | |
static char * | complete_country (struct ast_cli_args *a) |
static char * | complete_indications (struct ast_cli_args *a) |
static char * | handle_cli_indication_add (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
static char * | handle_cli_indication_remove (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
static char * | handle_cli_indication_show (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
static int | is_valid_tone_zone (struct ast_tone_zone *zone) |
static int | load_indications (int reload) |
load indications module More... | |
static int | load_module (void) |
Load indications module. More... | |
static int | parse_tone_zone (struct ast_config *cfg, const char *country) |
static void * | playtones_alloc (struct ast_channel *chan, void *params) |
static int | playtones_generator (struct ast_channel *chan, void *data, int len, int samples) |
static void | playtones_release (struct ast_channel *chan, void *params) |
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 configuration at all. More... | |
static int | reload_module (void) |
Reload indications module. More... | |
static void | reset_tone_zone (struct ast_tone_zone *zone) |
static void | store_config_tone_zone (struct ast_tone_zone *zone, const char *var, const char *value) |
static void | store_tone_zone_ring_cadence (struct ast_tone_zone *zone, const char *val) |
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 after configuration is parsed. More... | |
static int | unload_module (void) |
Variables | |
static struct ast_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_ORDER , .description = "Indication Tone Handling" , .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 = "30ef0c93b36035ec78c9cfd712d36d9b" , .support_level = AST_MODULE_SUPPORT_CORE, .load = load_module, .unload = unload_module, .reload = reload_module, .load_pri = AST_MODPRI_CORE, .requires = "extconfig", } |
static const struct ast_module_info * | ast_module_info = &__mod_info |
static struct ao2_container * | ast_tone_zones |
static struct ast_cli_entry | cli_indications [] |
CLI entries for commands provided by this module. More... | |
static const char | config [] = "indications.conf" |
static struct ast_tone_zone * | default_tone_zone |
static const int | midi_tohz [128] |
static struct ast_generator | playtones |
Indication Tone Handling.
Definition in file indications.c.
#define NUM_TONE_ZONE_BUCKETS 53 |
Definition at line 68 of file indications.c.
Referenced by load_module().
|
static |
Definition at line 1170 of file indications.c.
|
static |
Definition at line 1170 of file indications.c.
struct ast_tone_zone_sound* ast_get_indication_tone | ( | const struct ast_tone_zone * | zone, |
const char * | indication | ||
) |
Locate a tone zone sound.
zone | Zone to look in for a sound, if NULL, the default will be used |
indication | Sound to look for, such as "busy" |
Definition at line 455 of file indications.c.
References ao2_lock, ao2_unlock, AST_LIST_TRAVERSE, ast_tone_zone_lock, ast_tone_zone_ref(), ast_tone_zone_sound_ref(), ast_tone_zone_unlock, ast_tone_zone_unref(), ast_tone_zone_sound::name, NULL, and ast_tone_zone::tones.
Referenced by ast_app_dtget(), ast_control_tone(), dial_handle_playtones(), dialtone_indicate(), handle_playtones(), in_band_indication(), indicate_data_internal(), pbx_builtin_waitexten(), play_dialtone(), read_exec(), readexten_exec(), and send_dial_tone().
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
locate ast_tone_zone
Definition at line 433 of file indications.c.
References ao2_find, ao2_lock, ao2_unlock, ast_copy_string(), ast_strlen_zero, ast_tone_zone_ref(), ast_tone_zone::country, ast_tone_zone::nrringcadence, NULL, OBJ_POINTER, and tz.
Referenced by ast_control_tone(), ast_set_indication_country(), ast_var_indications(), build_device(), build_peer(), chan_pjsip_new(), func_channel_write_real(), handle_cli_indication_add(), handle_cli_indication_remove(), reload_config(), and sip_new().
struct ast_module* AST_MODULE_SELF_SYM | ( | void | ) |
Definition at line 1170 of file indications.c.
int ast_playtones_start | ( | struct ast_channel * | chan, |
int | vol, | ||
const char * | tonelist, | ||
int | interruptible | ||
) |
Start playing a list of tones on a channel.
chan | the channel to play tones on |
vol | volume |
tonelist | the list of tones to play, comma separated |
interruptible | whether or not this tone can be interrupted |
0 | success |
non-zero | failure |
Definition at line 302 of file indications.c.
References ast_activate_generator(), ast_free, ast_log, ast_realloc, ast_strdupa, ast_strip(), ast_strlen_zero, ast_tone_zone_part_parse(), cos, playtones_item::duration, playtones_item::fac1, playtones_item::fac2, ast_tone_zone_part::freq1, ast_tone_zone_part::freq2, playtones_item::init_v2_1, playtones_item::init_v2_2, playtones_item::init_v3_1, playtones_item::init_v3_2, playtones_def::interruptible, playtones_def::items, LOG_ERROR, M_PI, midi_tohz, ast_tone_zone_part::midinote, playtones_item::modulate, ast_tone_zone_part::modulate, playtones_def::nitems, NULL, playtones_def::reppos, strsep(), ast_tone_zone_part::time, and playtones_def::vol.
Referenced by ast_app_dtget(), ast_control_tone(), ast_senddigit_begin(), ast_senddigit_mf_begin(), control_tone_frame_response(), dial_handle_playtones(), dialtone_indicate(), handle_playtones(), in_band_indication(), indicate_data_internal(), mf_stream(), milliwatt_exec(), pbx_builtin_waitexten(), play_dialtone(), playtone(), read_exec(), readexten_exec(), receivefax_t38_init(), send_digit_to_chan(), send_tone_burst(), and sendfax_t38_init().
void ast_playtones_stop | ( | struct ast_channel * | chan | ) |
Stop playing tones on a channel.
chan | the channel to stop tones on |
Definition at line 393 of file indications.c.
References ast_deactivate_generator().
Referenced by ast_app_dtget(), ast_senddigit_end(), ast_senddigit_mf_end(), control_tone_frame_response(), disa_exec(), handle_stopplaytones(), indicate_data_internal(), pbx_builtin_waitexten(), playtone(), read_exec(), readexten_exec(), receivefax_t38_init(), send_tone_burst(), sendfax_t38_init(), stop_indicate(), and unistim_indicate().
|
static |
Definition at line 573 of file indications.c.
References AO2_ALLOC_OPT_LOCK_NOLOCK, ao2_alloc_options, AST_LIST_INSERT_TAIL, AST_LIST_REMOVE_CURRENT, AST_LIST_TRAVERSE_SAFE_BEGIN, AST_LIST_TRAVERSE_SAFE_END, ast_strdup, ast_strlen_zero, ast_tone_zone_sound_destructor(), ast_tone_zone_sound_unref(), ast_tone_zone_sound::data, ast_tone_zone_sound::name, and ast_tone_zone::tones.
Referenced by handle_cli_indication_add(), and store_config_tone_zone().
|
static |
add a new country, if country exists, it will be replaced.
Definition at line 526 of file indications.c.
References ao2_link, ao2_lock, ao2_unlock, ast_tone_zone_ref(), ast_verb, and ast_tone_zone::country.
Referenced by handle_cli_indication_add(), and parse_tone_zone().
|
static |
Set global indication country If no country is specified or we are unable to find the zone, then return not found.
Definition at line 410 of file indications.c.
References ao2_lock, ao2_unlock, ast_get_indication_zone(), ast_strlen_zero, ast_tone_zone_ref(), ast_tone_zone_unref(), ast_verb, and NULL.
Referenced by load_indications().
|
static |
Definition at line 630 of file indications.c.
References ao2_alloc, and ast_tone_zone_destructor().
Referenced by handle_cli_indication_add(), and parse_tone_zone().
|
static |
Definition at line 1111 of file indications.c.
References CMP_MATCH, CMP_STOP, and ast_tone_zone::country.
Referenced by load_module().
int ast_tone_zone_count | ( | void | ) |
Get the number of registered tone zones.
Definition at line 398 of file indications.c.
References ao2_container_count().
|
static |
deallocate the passed tone zone
Definition at line 510 of file indications.c.
References ast_free, AST_LIST_REMOVE_HEAD, ast_tone_zone_sound_unref(), NULL, ast_tone_zone::ringcadence, and ast_tone_zone::tones.
Referenced by ast_tone_zone_alloc().
|
static |
Definition at line 1104 of file indications.c.
References ast_str_case_hash(), and ast_tone_zone::country.
Referenced by load_module().
struct ao2_iterator ast_tone_zone_iterator_init | ( | void | ) |
Get an iterator for the available tone zones.
Definition at line 403 of file indications.c.
References ao2_iterator_init().
Referenced by ast_var_indications(), ast_var_indications_table(), and handle_cli_indication_show().
int ast_tone_zone_part_parse | ( | const char * | s, |
struct ast_tone_zone_part * | tone_data | ||
) |
Parse a tone part.
s | The part of a tone to parse. This should be in the form described for the data part of ast_tone_zone_sound. '!' should be removed if present. |
tone_data | An output parameter that contains the result of the parsing. |
0 | success |
-1 | failure, and the contents of tone_data are undefined |
Definition at line 245 of file indications.c.
References ast_tone_zone_part::freq1, ast_tone_zone_part::freq2, ast_tone_zone_part::midinote, ast_tone_zone_part::modulate, and ast_tone_zone_part::time.
Referenced by ast_playtones_start(), and send_dial_tone().
|
static |
Definition at line 493 of file indications.c.
References ast_free, ast_tone_zone_sound::data, ast_tone_zone_sound::name, and NULL.
Referenced by ast_register_indication().
|
static |
remove an existing country's indication. Both country and indication must exist
Definition at line 608 of file indications.c.
References AST_LIST_REMOVE_CURRENT, AST_LIST_TRAVERSE_SAFE_BEGIN, AST_LIST_TRAVERSE_SAFE_END, ast_tone_zone_lock, ast_tone_zone_sound_unref(), ast_tone_zone_unlock, ast_tone_zone_sound::name, and ast_tone_zone::tones.
Referenced by handle_cli_indication_remove().
|
static |
remove an existing country and all its indications, country must exist.
Definition at line 542 of file indications.c.
References ao2_callback, ao2_find, ao2_lock, ao2_unlock, ast_copy_string(), ast_tone_zone_unref(), ast_tone_zone::country, ast_tone_zone::nrringcadence, NULL, OBJ_POINTER, OBJ_UNLINK, and tz.
Referenced by handle_cli_indication_add(), and handle_cli_indication_remove().
|
static |
Definition at line 635 of file indications.c.
References ao2_iterator_destroy(), ao2_iterator_init(), ao2_iterator_next, ast_cli_completion_add(), ast_strdup, ast_tone_zone_unref(), ast_tone_zone::country, NULL, tz, and ast_cli_args::word.
Referenced by handle_cli_indication_add(), handle_cli_indication_remove(), and handle_cli_indication_show().
|
static |
Definition at line 723 of file indications.c.
References ao2_find, ast_cli_args::argv, ast_cli_completion_add(), ast_copy_string(), AST_LIST_TRAVERSE, ast_strdup, ast_tone_zone_lock, ast_tone_zone_unlock, ast_tone_zone_unref(), ast_tone_zone::country, ast_tone_zone_sound::name, ast_tone_zone::nrringcadence, NULL, OBJ_POINTER, ast_cli_args::pos, ast_tone_zone::tones, tz, and ast_cli_args::word.
Referenced by handle_cli_indication_remove().
|
static |
Definition at line 658 of file indications.c.
References ast_cli_args::argc, ast_cli_args::argv, ast_copy_string(), ast_get_indication_zone(), ast_log, ast_register_indication(), ast_register_indication_country(), ast_strlen_zero, ast_tone_zone_alloc(), ast_tone_zone_lock, ast_tone_zone_unlock, ast_tone_zone_unref(), ast_unregister_indication_country(), CLI_FAILURE, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, complete_country(), ast_tone_zone::country, LOG_NOTICE, LOG_WARNING, NULL, ast_cli_args::pos, tz, and ast_cli_entry::usage.
|
static |
Definition at line 756 of file indications.c.
References ast_cli_args::argc, ast_cli_args::argv, ast_get_indication_zone(), ast_log, ast_tone_zone_unref(), ast_unregister_indication(), ast_unregister_indication_country(), CLI_FAILURE, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, complete_country(), complete_indications(), LOG_WARNING, NULL, ast_cli_args::pos, tz, and ast_cli_entry::usage.
|
static |
Definition at line 807 of file indications.c.
References ao2_find, ao2_iterator_destroy(), ao2_iterator_next, ast_cli_args::argc, ast_cli_args::argv, ast_cli(), ast_copy_string(), AST_LIST_TRAVERSE, ast_str_alloca, ast_str_append(), ast_str_buffer(), ast_str_set(), ast_tone_zone_iterator_init(), ast_tone_zone_lock, ast_tone_zone_unlock, ast_tone_zone_unref(), buf, CLI_GENERATE, CLI_INIT, CLI_SUCCESS, ast_cli_entry::command, complete_country(), ast_tone_zone::country, ast_tone_zone_sound::data, ast_tone_zone::description, ast_cli_args::fd, ast_tone_zone_sound::name, ast_tone_zone::nrringcadence, NULL, OBJ_POINTER, ast_tone_zone::ringcadence, ast_tone_zone::tones, tz, and ast_cli_entry::usage.
|
static |
Definition at line 888 of file indications.c.
References AST_LIST_EMPTY, ast_strlen_zero, ast_tone_zone_lock, ast_tone_zone_unlock, ast_tone_zone::description, and ast_tone_zone::tones.
Referenced by parse_tone_zone().
|
static |
load indications module
Definition at line 1045 of file indications.c.
References ao2_callback, ao2_lock, ao2_unlock, ast_category_browse(), ast_config_destroy(), ast_config_load2(), ast_log, ast_set_indication_country(), ast_strlen_zero, ast_variable_retrieve(), config, CONFIG_FLAG_FILEUNCHANGED, CONFIG_STATUS_FILEINVALID, CONFIG_STATUS_FILEMISSING, CONFIG_STATUS_FILEUNCHANGED, country, LOG_WARNING, NULL, OBJ_MULTIPLE, OBJ_NODATA, OBJ_UNLINK, parse_tone_zone(), prune_tone_zone(), and tone_zone_mark().
Referenced by load_module(), and reload_module().
|
static |
Load indications module.
Definition at line 1140 of file indications.c.
References AO2_ALLOC_OPT_LOCK_MUTEX, ao2_container_alloc_hash, ARRAY_LEN, ast_cli_register_multiple, AST_MODULE_LOAD_FAILURE, AST_MODULE_LOAD_SUCCESS, ast_tone_zone_cmp(), ast_tone_zone_hash(), load_indications(), NULL, and NUM_TONE_ZONE_BUCKETS.
Referenced by reload_module().
|
static |
Definition at line 958 of file indications.c.
References ao2_find, ast_copy_string(), ast_log, ast_register_indication_country(), ast_tone_zone_alloc(), ast_tone_zone_lock, ast_tone_zone_unlock, ast_tone_zone_unref(), ast_variable_browse(), ast_tone_zone::country, is_valid_tone_zone(), LOG_WARNING, ast_variable::name, ast_variable::next, ast_tone_zone::nrringcadence, OBJ_POINTER, reset_tone_zone(), store_config_tone_zone(), and ast_variable::value.
Referenced by load_indications().
|
static |
Definition at line 128 of file indications.c.
References ao2_bump, ast_calloc, ast_channel_flags(), ast_channel_name(), ast_channel_writeformat(), ast_clear_flag, AST_FLAG_WRITE_INT, ast_format_slin, ast_log, ast_set_flag, ast_set_write_format(), playtones_def::interruptible, playtones_def::items, playtones_state::items, LOG_WARNING, playtones_def::nitems, playtones_state::nitems, NULL, playtones_state::oldnpos, playtones_state::origwfmt, playtones_release(), playtones_def::reppos, playtones_state::reppos, playtones_def::vol, and playtones_state::vol.
|
static |
Definition at line 161 of file indications.c.
References ast_format_slin, AST_FRAME_VOICE, AST_FRIENDLY_OFFSET, ast_log, ast_write(), playtones_state::data, ast_frame::data, ast_frame::datalen, playtones_item::duration, playtones_state::f, playtones_item::fac1, playtones_item::fac2, ast_frame_subclass::format, ast_frame::frametype, playtones_item::init_v2_1, playtones_item::init_v2_2, playtones_item::init_v3_1, playtones_item::init_v3_2, playtones_state::items, len(), LOG_WARNING, playtones_item::modulate, playtones_state::nitems, playtones_state::npos, ast_frame::offset, playtones_state::oldnpos, playtones_state::pos, ast_frame::ptr, playtones_state::reppos, ast_frame::samples, ast_frame::subclass, playtones_state::v1_1, playtones_state::v1_2, playtones_state::v2_1, playtones_state::v2_2, playtones_state::v3_1, and playtones_state::v3_2.
|
static |
Definition at line 114 of file indications.c.
References ao2_cleanup, ast_free, ast_set_write_format(), playtones_state::items, and playtones_state::origwfmt.
Referenced by playtones_alloc().
|
static |
Prune tones no longer in the configuration, and have the tone zone unlinked if it is no longer in the configuration at all.
Definition at line 1024 of file indications.c.
References AST_LIST_REMOVE_CURRENT, AST_LIST_TRAVERSE_SAFE_BEGIN, AST_LIST_TRAVERSE_SAFE_END, ast_tone_zone_lock, ast_tone_zone_sound_unref(), ast_tone_zone_unlock, CMP_MATCH, ast_tone_zone_sound::killme, ast_tone_zone::killme, and ast_tone_zone::tones.
Referenced by load_indications().
|
static |
Reload indications module.
Definition at line 1158 of file indications.c.
References AST_MODFLAG_GLOBAL_SYMBOLS, AST_MODFLAG_LOAD_ORDER, AST_MODPRI_CORE, AST_MODULE_INFO(), AST_MODULE_SUPPORT_CORE, ASTERISK_GPL_KEY, load_indications(), load_module(), reload(), and unload_module().
|
static |
Definition at line 943 of file indications.c.
References ast_free, ast_tone_zone_lock, ast_tone_zone_unlock, ast_tone_zone::killme, ast_tone_zone::nrringcadence, NULL, and ast_tone_zone::ringcadence.
Referenced by parse_tone_zone().
|
static |
Definition at line 930 of file indications.c.
References ast_register_indication(), CV_END, CV_F, CV_START, CV_STR, ast_tone_zone::description, and store_tone_zone_ring_cadence().
Referenced by parse_tone_zone().
|
static |
Definition at line 903 of file indications.c.
References ast_copy_string(), ast_log, ast_realloc, ast_strip(), buf, c, LOG_WARNING, ast_tone_zone::nrringcadence, ast_tone_zone::ringcadence, strsep(), tmp(), and value.
Referenced by store_config_tone_zone().
|
static |
Mark the zone and its tones before parsing configuration. We will use this to know what to remove after configuration is parsed.
Definition at line 1002 of file indications.c.
References AST_LIST_TRAVERSE, ast_tone_zone_lock, ast_tone_zone_unlock, ast_tone_zone_sound::killme, ast_tone_zone::killme, and ast_tone_zone::tones.
Referenced by load_indications().
|
static |
Definition at line 1124 of file indications.c.
References ao2_ref, ARRAY_LEN, ast_cli_unregister_multiple(), ast_tone_zone_unref(), and NULL.
Referenced by reload_module().
|
static |
Definition at line 1170 of file indications.c.
|
static |
Definition at line 1170 of file indications.c.
|
static |
Definition at line 66 of file indications.c.
|
static |
CLI entries for commands provided by this module.
Definition at line 1098 of file indications.c.
|
static |
Definition at line 48 of file indications.c.
Referenced by load_indications().
|
static |
Definition at line 73 of file indications.c.
|
static |
Definition at line 50 of file indications.c.
Referenced by ast_playtones_start().
|
static |
Definition at line 239 of file indications.c.