Meet me conference bridge and Shared Line Appearances. More...
#include "asterisk.h"#include <dahdi/user.h>#include "asterisk/lock.h"#include "asterisk/file.h"#include "asterisk/channel.h"#include "asterisk/pbx.h"#include "asterisk/module.h"#include "asterisk/config.h"#include "asterisk/app.h"#include "asterisk/dsp.h"#include "asterisk/musiconhold.h"#include "asterisk/manager.h"#include "asterisk/cli.h"#include "asterisk/say.h"#include "asterisk/utils.h"#include "asterisk/translate.h"#include "asterisk/ulaw.h"#include "asterisk/astobj2.h"#include "asterisk/devicestate.h"#include "asterisk/dial.h"#include "asterisk/causes.h"#include "asterisk/paths.h"#include "asterisk/data.h"#include "asterisk/test.h"#include "enter.h"#include "leave.h"
Go to the source code of this file.
Data Structures | |
| struct | announce_listitem |
| struct | ast_conf_user |
| The MeetMe User object. More... | |
| struct | ast_conference |
| The MeetMe Conference object. More... | |
| struct | dial_trunk_args |
| struct | run_station_args |
| struct | sla_event |
| struct | sla_failed_station |
| A station that failed to be dialed. More... | |
| struct | sla_ringing_station |
| A station that is ringing. More... | |
| struct | sla_ringing_trunk |
| A trunk that is ringing. More... | |
| struct | sla_station |
| struct | sla_station_ref |
| struct | sla_trunk |
| struct | sla_trunk_ref |
| struct | volume |
Defines | |
| #define | AST_FRAME_BITS 32 |
| #define | CONF_SIZE 320 |
| #define | CONFFLAG_INTROMSG (1ULL << 32) |
| #define | CONFFLAG_NO_AUDIO_UNTIL_UP (1ULL << 31) |
| #define | CONFIG_FILE_NAME "meetme.conf" |
| #define | DATE_FORMAT "%Y-%m-%d %H:%M:%S" |
| #define | DEFAULT_AUDIO_BUFFERS 32 |
| #define | MAX_CONFNUM 80 |
| #define | MAX_PIN 80 |
| #define | MAX_SETTINGS (MAX_CONFNUM + MAX_PIN + MAX_PIN + 3) |
| #define | MC_DATA_FORMAT "%-12.12s %4.4d %4.4s %02d:%02d:%02d %-8s %-6s\n" |
| #define | MC_HEADER_FORMAT "%-14s %-14s %-10s %-8s %-8s %-6s\n" |
| #define | MEETME_DATA_EXPORT(MEMBER) |
| #define | MEETME_DELAYDETECTENDTALK 1000 |
| #define | MEETME_DELAYDETECTTALK 300 |
| #define | MEETME_USER_DATA_EXPORT(MEMBER) |
| #define | OPTIONS_LEN 100 |
| #define | S(e) case e: return # e; |
| #define | SLA_CONFIG_FILE "sla.conf" |
| #define | STR_CONCISE "concise" |
Enumerations | |
| enum | { ADMINFLAG_MUTED = (1 << 1), ADMINFLAG_SELFMUTED = (1 << 2), ADMINFLAG_KICKME = (1 << 3), ADMINFLAG_T_REQUEST = (1 << 4) } |
| enum | { CONFFLAG_ADMIN = (1 << 0), CONFFLAG_MONITOR = (1 << 1), CONFFLAG_KEYEXIT = (1 << 2), CONFFLAG_STARMENU = (1 << 3), CONFFLAG_TALKER = (1 << 4), CONFFLAG_QUIET = (1 << 5), CONFFLAG_ANNOUNCEUSERCOUNT = (1 << 6), CONFFLAG_AGI = (1 << 7), CONFFLAG_MOH = (1 << 8), CONFFLAG_MARKEDEXIT = (1 << 9), CONFFLAG_WAITMARKED = (1 << 10), CONFFLAG_EXIT_CONTEXT = (1 << 11), CONFFLAG_MARKEDUSER = (1 << 12), CONFFLAG_INTROUSER = (1 << 13), CONFFLAG_RECORDCONF = (1<< 14), CONFFLAG_MONITORTALKER = (1 << 15), CONFFLAG_DYNAMIC = (1 << 16), CONFFLAG_DYNAMICPIN = (1 << 17), CONFFLAG_EMPTY = (1 << 18), CONFFLAG_EMPTYNOPIN = (1 << 19), CONFFLAG_ALWAYSPROMPT = (1 << 20), CONFFLAG_OPTIMIZETALKER = (1 << 21), CONFFLAG_NOONLYPERSON = (1 << 22), CONFFLAG_INTROUSERNOREVIEW = (1 << 23), CONFFLAG_STARTMUTED = (1 << 24), CONFFLAG_PASS_DTMF = (1 << 25), CONFFLAG_SLA_STATION = (1 << 26), CONFFLAG_SLA_TRUNK = (1 << 27), CONFFLAG_KICK_CONTINUE = (1 << 28), CONFFLAG_DURATION_STOP = (1 << 29), CONFFLAG_DURATION_LIMIT = (1 << 30) } |
| enum | { OPT_ARG_WAITMARKED = 0, OPT_ARG_EXITKEYS = 1, OPT_ARG_DURATION_STOP = 2, OPT_ARG_DURATION_LIMIT = 3, OPT_ARG_MOH_CLASS = 4, OPT_ARG_INTROMSG = 5, OPT_ARG_ARRAY_SIZE = 6 } |
| enum | { SLA_TRUNK_OPT_MOH = (1 << 0) } |
| enum | { SLA_TRUNK_OPT_ARG_MOH_CLASS = 0, SLA_TRUNK_OPT_ARG_ARRAY_SIZE = 1 } |
| enum | announcetypes { CONF_HASJOIN, CONF_HASLEFT } |
| enum | entrance_sound { ENTER, LEAVE } |
| enum | recording_state { MEETME_RECORD_OFF, MEETME_RECORD_STARTED, MEETME_RECORD_ACTIVE, MEETME_RECORD_TERMINATE } |
| enum | sla_event_type { SLA_EVENT_HOLD, SLA_EVENT_DIAL_STATE, SLA_EVENT_RINGING_TRUNK, SLA_EVENT_RELOAD, SLA_EVENT_CHECK_RELOAD } |
Event types that can be queued up for the SLA thread. More... | |
| enum | sla_hold_access { SLA_HOLD_OPEN, SLA_HOLD_PRIVATE } |
| enum | sla_station_hangup { SLA_STATION_HANGUP_NORMAL, SLA_STATION_HANGUP_TIMEOUT } |
| enum | sla_trunk_state { SLA_TRUNK_STATE_IDLE, SLA_TRUNK_STATE_RINGING, SLA_TRUNK_STATE_UP, SLA_TRUNK_STATE_ONHOLD, SLA_TRUNK_STATE_ONHOLD_BYME } |
| enum | sla_which_trunk_refs { ALL_TRUNK_REFS, INACTIVE_TRUNK_REFS } |
| enum | volume_action { VOL_UP, VOL_DOWN } |
Functions | |
| static int | acf_meetme_info (struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len) |
| static int | acf_meetme_info_eval (const char *keyword, const struct ast_conference *conf) |
| static int | action_meetmelist (struct mansession *s, const struct message *m) |
| static int | action_meetmemute (struct mansession *s, const struct message *m) |
| static int | action_meetmeunmute (struct mansession *s, const struct message *m) |
| static int | admin_exec (struct ast_channel *chan, const char *data) |
| The MeetMeadmin application. | |
| static void * | announce_thread (void *data) |
| static void | answer_trunk_chan (struct ast_channel *chan) |
| AST_APP_OPTIONS (sla_trunk_opts, BEGIN_OPTIONS AST_APP_OPTION_ARG('M', SLA_TRUNK_OPT_MOH, SLA_TRUNK_OPT_ARG_MOH_CLASS), END_OPTIONS) | |
| AST_APP_OPTIONS (meetme_opts, BEGIN_OPTIONS AST_APP_OPTION('A', CONFFLAG_MARKEDUSER), AST_APP_OPTION('a', CONFFLAG_ADMIN), AST_APP_OPTION('b', CONFFLAG_AGI), AST_APP_OPTION('c', CONFFLAG_ANNOUNCEUSERCOUNT), AST_APP_OPTION('C', CONFFLAG_KICK_CONTINUE), AST_APP_OPTION('D', CONFFLAG_DYNAMICPIN), AST_APP_OPTION('d', CONFFLAG_DYNAMIC), AST_APP_OPTION('E', CONFFLAG_EMPTYNOPIN), AST_APP_OPTION('e', CONFFLAG_EMPTY), AST_APP_OPTION('F', CONFFLAG_PASS_DTMF), AST_APP_OPTION_ARG('G', CONFFLAG_INTROMSG, OPT_ARG_INTROMSG), AST_APP_OPTION('i', CONFFLAG_INTROUSER), AST_APP_OPTION('I', CONFFLAG_INTROUSERNOREVIEW), AST_APP_OPTION_ARG('M', CONFFLAG_MOH, OPT_ARG_MOH_CLASS), AST_APP_OPTION('m', CONFFLAG_STARTMUTED), AST_APP_OPTION('o', CONFFLAG_OPTIMIZETALKER), AST_APP_OPTION('P', CONFFLAG_ALWAYSPROMPT), AST_APP_OPTION_ARG('p', CONFFLAG_KEYEXIT, OPT_ARG_EXITKEYS), AST_APP_OPTION('q', CONFFLAG_QUIET), AST_APP_OPTION('r', CONFFLAG_RECORDCONF), AST_APP_OPTION('s', CONFFLAG_STARMENU), AST_APP_OPTION('T', CONFFLAG_MONITORTALKER), AST_APP_OPTION('l', CONFFLAG_MONITOR), AST_APP_OPTION('t', CONFFLAG_TALKER), AST_APP_OPTION_ARG('w', CONFFLAG_WAITMARKED, OPT_ARG_WAITMARKED), AST_APP_OPTION('X', CONFFLAG_EXIT_CONTEXT), AST_APP_OPTION('x', CONFFLAG_MARKEDEXIT), AST_APP_OPTION('1', CONFFLAG_NOONLYPERSON), AST_APP_OPTION_ARG('S', CONFFLAG_DURATION_STOP, OPT_ARG_DURATION_STOP), AST_APP_OPTION_ARG('L', CONFFLAG_DURATION_LIMIT, OPT_ARG_DURATION_LIMIT), END_OPTIONS) | |
| AST_DATA_STRUCTURE (ast_conf_user, MEETME_USER_DATA_EXPORT) | |
| AST_DATA_STRUCTURE (ast_conference, MEETME_DATA_EXPORT) | |
| static | AST_LIST_HEAD_STATIC (confs, ast_conference) |
| AST_MODULE_INFO (ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER,"MeetMe conference bridge",.load=load_module,.unload=unload_module,.reload=reload,.load_pri=AST_MODPRI_DEVSTATE_PROVIDER,) | |
| static | AST_RWLIST_HEAD_STATIC (sla_trunks, sla_trunk) |
| static | AST_RWLIST_HEAD_STATIC (sla_stations, sla_station) |
| static struct ast_conference * | build_conf (const char *confno, const char *pin, const char *pinadmin, int make, int dynamic, int refcount, const struct ast_channel *chan, struct ast_test *test) |
| Find or create a conference. | |
| static int | can_write (struct ast_channel *chan, struct ast_flags64 *confflags) |
| static int | careful_write (int fd, unsigned char *data, int len, int block) |
| static int | channel_admin_exec (struct ast_channel *chan, const char *data) |
| The MeetMeChannelAdmin application MeetMeChannelAdmin(channel, command). | |
| static char * | complete_confno (const char *word, int state) |
| static char * | complete_meetmecmd_list (const char *line, const char *word, int pos, int state) |
| static char * | complete_meetmecmd_lock (const char *word, int pos, int state) |
| static char * | complete_meetmecmd_mute_kick (const char *line, const char *word, int pos, int state) |
| static char * | complete_userno (struct ast_conference *cnf, const char *word, int state) |
| static int | conf_exec (struct ast_channel *chan, const char *data) |
| The meetme() application. | |
| static void | conf_flush (int fd, struct ast_channel *chan) |
| static int | conf_free (struct ast_conference *conf) |
| Remove the conference from the list and free it. | |
| static void | conf_play (struct ast_channel *chan, struct ast_conference *conf, enum entrance_sound sound) |
| static void | conf_queue_dtmf (const struct ast_conference *conf, const struct ast_conf_user *sender, struct ast_frame *f) |
| static int | conf_run (struct ast_channel *chan, struct ast_conference *conf, struct ast_flags64 *confflags, char *optargs[]) |
| static void | conf_start_moh (struct ast_channel *chan, const char *musicclass) |
| static int | count_exec (struct ast_channel *chan, const char *data) |
| The MeetmeCount application. | |
| static struct sla_trunk_ref * | create_trunk_ref (struct sla_trunk *trunk) |
| static void | destroy_station (struct sla_station *station) |
| static void | destroy_trunk (struct sla_trunk *trunk) |
| static void * | dial_trunk (void *data) |
| static int | dispose_conf (struct ast_conference *conf) |
| Decrement reference counts, as incremented by find_conf(). | |
| static void | filename_parse (char *filename, char *buffer) |
| static struct ast_conference * | find_conf (struct ast_channel *chan, char *confno, int make, int dynamic, char *dynamic_pin, size_t pin_buf_len, int refcount, struct ast_flags64 *confflags) |
| static struct ast_conference * | find_conf_realtime (struct ast_channel *chan, char *confno, int make, int dynamic, char *dynamic_pin, size_t pin_buf_len, int refcount, struct ast_flags64 *confflags, int *too_early, char **optargs) |
| static struct ast_conf_user * | find_user (struct ast_conference *conf, const char *callerident) |
| static const char * | get_announce_filename (enum announcetypes type) |
| static const char * | istalking (int x) |
| static int | load_config (int reload) |
| static void | load_config_meetme (void) |
| static int | load_module (void) |
| static char * | meetme_cmd_helper (struct ast_cli_args *a) |
| static int | meetme_data_provider_get (const struct ast_data_search *search, struct ast_data *data_root) |
| static char * | meetme_kick_cmd (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
| static char * | meetme_lock_cmd (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
| static char * | meetme_mute_cmd (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
| static char * | meetme_show_cmd (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
| static int | meetmemute (struct mansession *s, const struct message *m, int mute) |
| static enum ast_device_state | meetmestate (const char *data) |
| Callback for devicestate providers. | |
| static struct sla_ringing_trunk * | queue_ringing_trunk (struct sla_trunk *trunk) |
| static void * | recordthread (void *args) |
| static int | reload (void) |
| static void | reset_volumes (struct ast_conf_user *user) |
| static int | rt_extend_conf (const char *confno) |
| static void * | run_station (void *data) |
| static void | send_talking_event (struct ast_channel *chan, struct ast_conference *conf, struct ast_conf_user *user, int talking) |
| static int | set_listen_volume (struct ast_conf_user *user, int volume) |
| static int | set_talk_volume (struct ast_conf_user *user, int volume) |
| static void | set_user_talking (struct ast_channel *chan, struct ast_conference *conf, struct ast_conf_user *user, int talking, int monitor) |
| static void | sla_add_trunk_to_station (struct sla_station *station, struct ast_variable *var) |
| static int | sla_build_station (struct ast_config *cfg, const char *cat) |
| static int | sla_build_trunk (struct ast_config *cfg, const char *cat) |
| static int | sla_calc_station_delays (unsigned int *timeout) |
| Calculate the ring delay for a station. | |
| static int | sla_calc_station_timeouts (unsigned int *timeout) |
| Process station ring timeouts. | |
| static int | sla_calc_trunk_timeouts (unsigned int *timeout) |
| Process trunk ring timeouts. | |
| static void | sla_change_trunk_state (const struct sla_trunk *trunk, enum sla_trunk_state state, enum sla_which_trunk_refs inactive_only, const struct sla_trunk_ref *exclude) |
| static int | sla_check_device (const char *device) |
| static int | sla_check_failed_station (const struct sla_station *station) |
| Check to see if this station has failed to be dialed in the past minute. | |
| static int | sla_check_inuse_station (const struct sla_station *station) |
| Check to see if a station is in use. | |
| static void | sla_check_reload (void) |
| Check if we can do a reload of SLA, and do it if we can. | |
| static int | sla_check_ringing_station (const struct sla_station *station) |
| Check to see if this station is already ringing. | |
| static int | sla_check_station_delay (struct sla_station *station, struct sla_ringing_trunk *ringing_trunk) |
| Calculate the ring delay for a given ringing trunk on a station. | |
| static int | sla_check_station_hold_access (const struct sla_trunk *trunk, const struct sla_station *station) |
| static int | sla_check_timed_out_station (const struct sla_ringing_trunk *ringing_trunk, const struct sla_station *station) |
| Check to see if dialing this station already timed out for this ringing trunk. | |
| static struct sla_trunk_ref * | sla_choose_idle_trunk (const struct sla_station *station) |
| For a given station, choose the highest priority idle trunk. | |
| static struct sla_ringing_trunk * | sla_choose_ringing_trunk (struct sla_station *station, struct sla_trunk_ref **trunk_ref, int rm) |
| Choose the highest priority ringing trunk for a station. | |
| static struct sla_ringing_station * | sla_create_ringing_station (struct sla_station *station) |
| static struct sla_station_ref * | sla_create_station_ref (struct sla_station *station) |
| static void | sla_destroy (void) |
| static void | sla_dial_state_callback (struct ast_dial *dial) |
| static struct sla_station * | sla_find_station (const char *name) |
| Find an SLA station by name. | |
| static struct sla_trunk * | sla_find_trunk (const char *name) |
| Find an SLA trunk by name. | |
| static struct sla_trunk_ref * | sla_find_trunk_ref (const struct sla_station *station, const struct sla_trunk *trunk) |
| static struct sla_trunk_ref * | sla_find_trunk_ref_byname (const struct sla_station *station, const char *name) |
| Find a trunk reference on a station by name. | |
| static void | sla_handle_dial_state_event (void) |
| static void | sla_handle_hold_event (struct sla_event *event) |
| static void | sla_handle_ringing_trunk_event (void) |
| static void | sla_hangup_stations (void) |
| static const char * | sla_hold_str (unsigned int hold_access) |
| static int | sla_load_config (int reload) |
| static int | sla_process_timers (struct timespec *ts) |
| Calculate the time until the next known event. | |
| static void | sla_queue_event (enum sla_event_type type) |
| static void | sla_queue_event_conf (enum sla_event_type type, struct ast_channel *chan, struct ast_conference *conf) |
| Queue a SLA event from the conference. | |
| static void | sla_queue_event_full (enum sla_event_type type, struct sla_trunk_ref *trunk_ref, struct sla_station *station, int lock) |
| static void | sla_queue_event_nolock (enum sla_event_type type) |
| static int | sla_ring_station (struct sla_ringing_trunk *ringing_trunk, struct sla_station *station) |
| Ring a station. | |
| static void | sla_ring_stations (void) |
| Ring stations based on current set of ringing trunks. | |
| static char * | sla_show_stations (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
| static char * | sla_show_trunks (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
| static enum ast_device_state | sla_state (const char *data) |
| static enum ast_device_state | sla_state_to_devstate (enum sla_trunk_state state) |
| static int | sla_station_exec (struct ast_channel *chan, const char *data) |
| static void | sla_stop_ringing_station (struct sla_ringing_station *ringing_station, enum sla_station_hangup hangup) |
| static void | sla_stop_ringing_trunk (struct sla_ringing_trunk *ringing_trunk) |
| static void * | sla_thread (void *data) |
| static int | sla_trunk_exec (struct ast_channel *chan, const char *data) |
| static const char * | trunkstate2str (enum sla_trunk_state state) |
| static void | tweak_listen_volume (struct ast_conf_user *user, enum volume_action action) |
| static void | tweak_talk_volume (struct ast_conf_user *user, enum volume_action action) |
| static void | tweak_volume (struct volume *vol, enum volume_action action) |
| static int | unload_module (void) |
| static int | user_add_provider_cb (void *obj, void *arg, int flags) |
| static int | user_chan_cb (void *obj, void *args, int flags) |
| static int | user_listen_voldown_cb (void *obj, void *unused, int flags) |
| static int | user_listen_volup_cb (void *obj, void *unused, int flags) |
| static int | user_max_cmp (void *obj, void *arg, int flags) |
| static int | user_no_cmp (void *obj, void *arg, int flags) |
| static int | user_reset_vol_cb (void *obj, void *unused, int flags) |
| static int | user_set_kickme_cb (void *obj, void *check_admin_arg, int flags) |
| static int | user_set_muted_cb (void *obj, void *check_admin_arg, int flags) |
| static int | user_set_unmuted_cb (void *obj, void *check_admin_arg, int flags) |
| static int | user_talk_voldown_cb (void *obj, void *unused, int flags) |
| static int | user_talk_volup_cb (void *obj, void *unused, int flags) |
Variables | |
| static const char *const | app = "MeetMe" |
| static const char *const | app2 = "MeetMeCount" |
| static const char *const | app3 = "MeetMeAdmin" |
| static const char *const | app4 = "MeetMeChannelAdmin" |
| static int | audio_buffers |
| The number of audio buffers to be allocated on pseudo channels when in a conference. | |
| static struct ast_cli_entry | cli_meetme [] |
| static unsigned int | conf_map [1024] = {0, } |
| static int | earlyalert |
| static int | endalert |
| static int | extendby |
| static int | fuzzystart |
| static const char | gain_map [] |
| Map 'volume' levels from -5 through +5 into decibel (dB) settings for channel drivers. | |
| static struct ast_data_handler | meetme_data_provider |
| static struct ast_data_entry | meetme_data_providers [] |
| static struct ast_custom_function | meetme_info_acf |
| static int | rt_log_members |
| static int | rt_schedule |
| struct { | |
| ast_cond_t cond | |
| ast_mutex_t lock | |
| pthread_t thread | |
| } | sla |
| A structure for data used by the sla thread. | |
| static const char | sla_registrar [] = "SLA" |
| static const char *const | slastation_app = "SLAStation" |
| static const char *const | slatrunk_app = "SLATrunk" |
Meet me conference bridge and Shared Line Appearances.
Definition in file app_meetme.c.
| #define AST_FRAME_BITS 32 |
Definition at line 537 of file app_meetme.c.
Referenced by conf_free(), conf_run(), and recordthread().
| #define CONF_SIZE 320 |
Definition at line 556 of file app_meetme.c.
| #define CONFFLAG_INTROMSG (1ULL << 32) |
If set play an intro announcement at start of conference
Definition at line 620 of file app_meetme.c.
Referenced by conf_run().
| #define CONFFLAG_NO_AUDIO_UNTIL_UP (1ULL << 31) |
Do not write any audio to this channel until the state is up.
Definition at line 618 of file app_meetme.c.
Referenced by can_write(), conf_run(), and sla_trunk_exec().
| #define CONFIG_FILE_NAME "meetme.conf" |
Definition at line 516 of file app_meetme.c.
Referenced by _dsp_init(), conf_exec(), find_conf(), and load_config_meetme().
| #define DATE_FORMAT "%Y-%m-%d %H:%M:%S" |
String format for scheduled conferences
Definition at line 524 of file app_meetme.c.
Referenced by append_date(), build_radius_record(), conf_run(), execute_cb(), find_conf_realtime(), format_date(), get_date(), manager_log(), pgsql_log(), and rt_extend_conf().
| #define DEFAULT_AUDIO_BUFFERS 32 |
each buffer is 20ms, so this is 640ms total
Definition at line 521 of file app_meetme.c.
Referenced by load_config_meetme().
| #define MAX_CONFNUM 80 |
Definition at line 682 of file app_meetme.c.
Referenced by conf_exec(), dial_trunk(), meetme_cmd_helper(), sla_station_exec(), and sla_trunk_exec().
| #define MAX_PIN 80 |
Definition at line 683 of file app_meetme.c.
Referenced by conf_exec().
| #define MAX_SETTINGS (MAX_CONFNUM + MAX_PIN + MAX_PIN + 3) |
Definition at line 687 of file app_meetme.c.
Referenced by conf_exec(), and find_conf().
| #define MC_DATA_FORMAT "%-12.12s %4.4d %4.4s %02d:%02d:%02d %-8s %-6s\n" |
Referenced by meetme_show_cmd().
| #define MC_HEADER_FORMAT "%-14s %-14s %-10s %-8s %-8s %-6s\n" |
Referenced by meetme_show_cmd().
| #define MEETME_DATA_EXPORT | ( | MEMBER | ) |
Definition at line 7090 of file app_meetme.c.
| #define MEETME_DELAYDETECTENDTALK 1000 |
Definition at line 535 of file app_meetme.c.
Referenced by conf_run().
| #define MEETME_DELAYDETECTTALK 300 |
Definition at line 534 of file app_meetme.c.
Referenced by conf_run().
| #define MEETME_USER_DATA_EXPORT | ( | MEMBER | ) |
Definition at line 7107 of file app_meetme.c.
| #define OPTIONS_LEN 100 |
Definition at line 684 of file app_meetme.c.
Referenced by find_conf_realtime().
| #define S | ( | e | ) | case e: return # e; |
Referenced by sms_readfile(), and trunkstate2str().
| #define SLA_CONFIG_FILE "sla.conf" |
Definition at line 517 of file app_meetme.c.
Referenced by sla_build_station(), sla_build_trunk(), and sla_load_config().
| #define STR_CONCISE "concise" |
Definition at line 518 of file app_meetme.c.
Referenced by complete_meetmecmd_list(), and meetme_show_cmd().
| anonymous enum |
| ADMINFLAG_MUTED |
User is muted |
| ADMINFLAG_SELFMUTED |
User muted self |
| ADMINFLAG_KICKME |
User has been kicked |
| ADMINFLAG_T_REQUEST |
User has requested to speak |
Definition at line 526 of file app_meetme.c.
00526 { 00527 ADMINFLAG_MUTED = (1 << 1), /*!< User is muted */ 00528 ADMINFLAG_SELFMUTED = (1 << 2), /*!< User muted self */ 00529 ADMINFLAG_KICKME = (1 << 3), /*!< User has been kicked */ 00530 /*! User has requested to speak */ 00531 ADMINFLAG_T_REQUEST = (1 << 4), 00532 };
| anonymous enum |
| CONFFLAG_ADMIN |
user has admin access on the conference |
| CONFFLAG_MONITOR |
If set the user can only receive audio from the conference |
| CONFFLAG_KEYEXIT |
If set asterisk will exit conference when key defined in p() option is pressed |
| CONFFLAG_STARMENU |
If set asterisk will provide a menu to the user when '*' is pressed |
| CONFFLAG_TALKER |
If set the use can only send audio to the conference |
| CONFFLAG_QUIET |
If set there will be no enter or leave sounds |
| CONFFLAG_ANNOUNCEUSERCOUNT |
If set, when user joins the conference, they will be told the number of users that are already in |
| CONFFLAG_AGI |
Set to run AGI Script in Background |
| CONFFLAG_MOH |
Set to have music on hold when user is alone in conference |
| CONFFLAG_MARKEDEXIT |
If set, the channel will leave the conference if all marked users leave |
| CONFFLAG_WAITMARKED |
If set, the MeetMe will wait until a marked user enters |
| CONFFLAG_EXIT_CONTEXT |
If set, the MeetMe will exit to the specified context |
| CONFFLAG_MARKEDUSER |
If set, the user will be marked |
| CONFFLAG_INTROUSER |
If set, user will be ask record name on entry of conference |
| CONFFLAG_RECORDCONF |
If set, the MeetMe will be recorded |
| CONFFLAG_MONITORTALKER |
If set, the user will be monitored if the user is talking or not |
| CONFFLAG_DYNAMIC | |
| CONFFLAG_DYNAMICPIN | |
| CONFFLAG_EMPTY | |
| CONFFLAG_EMPTYNOPIN | |
| CONFFLAG_ALWAYSPROMPT | |
| CONFFLAG_OPTIMIZETALKER | |
| CONFFLAG_NOONLYPERSON |
If set, won't speak the extra prompt when the first person enters the conference |
| CONFFLAG_INTROUSERNOREVIEW |
If set, user will be asked to record name on entry of conference without review |
| CONFFLAG_STARTMUTED |
If set, the user will be initially self-muted |
| CONFFLAG_PASS_DTMF |
Pass DTMF through the conference |
| CONFFLAG_SLA_STATION | |
| CONFFLAG_SLA_TRUNK | |
| CONFFLAG_KICK_CONTINUE |
If set, the user should continue in the dialplan if kicked out |
| CONFFLAG_DURATION_STOP | |
| CONFFLAG_DURATION_LIMIT |
Definition at line 558 of file app_meetme.c.
00558 { 00559 /*! user has admin access on the conference */ 00560 CONFFLAG_ADMIN = (1 << 0), 00561 /*! If set the user can only receive audio from the conference */ 00562 CONFFLAG_MONITOR = (1 << 1), 00563 /*! If set asterisk will exit conference when key defined in p() option is pressed */ 00564 CONFFLAG_KEYEXIT = (1 << 2), 00565 /*! If set asterisk will provide a menu to the user when '*' is pressed */ 00566 CONFFLAG_STARMENU = (1 << 3), 00567 /*! If set the use can only send audio to the conference */ 00568 CONFFLAG_TALKER = (1 << 4), 00569 /*! If set there will be no enter or leave sounds */ 00570 CONFFLAG_QUIET = (1 << 5), 00571 /*! If set, when user joins the conference, they will be told the number 00572 * of users that are already in */ 00573 CONFFLAG_ANNOUNCEUSERCOUNT = (1 << 6), 00574 /*! Set to run AGI Script in Background */ 00575 CONFFLAG_AGI = (1 << 7), 00576 /*! Set to have music on hold when user is alone in conference */ 00577 CONFFLAG_MOH = (1 << 8), 00578 /*! If set, the channel will leave the conference if all marked users leave */ 00579 CONFFLAG_MARKEDEXIT = (1 << 9), 00580 /*! If set, the MeetMe will wait until a marked user enters */ 00581 CONFFLAG_WAITMARKED = (1 << 10), 00582 /*! If set, the MeetMe will exit to the specified context */ 00583 CONFFLAG_EXIT_CONTEXT = (1 << 11), 00584 /*! If set, the user will be marked */ 00585 CONFFLAG_MARKEDUSER = (1 << 12), 00586 /*! If set, user will be ask record name on entry of conference */ 00587 CONFFLAG_INTROUSER = (1 << 13), 00588 /*! If set, the MeetMe will be recorded */ 00589 CONFFLAG_RECORDCONF = (1<< 14), 00590 /*! If set, the user will be monitored if the user is talking or not */ 00591 CONFFLAG_MONITORTALKER = (1 << 15), 00592 CONFFLAG_DYNAMIC = (1 << 16), 00593 CONFFLAG_DYNAMICPIN = (1 << 17), 00594 CONFFLAG_EMPTY = (1 << 18), 00595 CONFFLAG_EMPTYNOPIN = (1 << 19), 00596 CONFFLAG_ALWAYSPROMPT = (1 << 20), 00597 /*! If set, treat talking users as muted users */ 00598 CONFFLAG_OPTIMIZETALKER = (1 << 21), 00599 /*! If set, won't speak the extra prompt when the first person 00600 * enters the conference */ 00601 CONFFLAG_NOONLYPERSON = (1 << 22), 00602 /*! If set, user will be asked to record name on entry of conference 00603 * without review */ 00604 CONFFLAG_INTROUSERNOREVIEW = (1 << 23), 00605 /*! If set, the user will be initially self-muted */ 00606 CONFFLAG_STARTMUTED = (1 << 24), 00607 /*! Pass DTMF through the conference */ 00608 CONFFLAG_PASS_DTMF = (1 << 25), 00609 CONFFLAG_SLA_STATION = (1 << 26), 00610 CONFFLAG_SLA_TRUNK = (1 << 27), 00611 /*! If set, the user should continue in the dialplan if kicked out */ 00612 CONFFLAG_KICK_CONTINUE = (1 << 28), 00613 CONFFLAG_DURATION_STOP = (1 << 29), 00614 CONFFLAG_DURATION_LIMIT = (1 << 30), 00615 };
| anonymous enum |
| OPT_ARG_WAITMARKED | |
| OPT_ARG_EXITKEYS | |
| OPT_ARG_DURATION_STOP | |
| OPT_ARG_DURATION_LIMIT | |
| OPT_ARG_MOH_CLASS | |
| OPT_ARG_INTROMSG | |
| OPT_ARG_ARRAY_SIZE |
Definition at line 622 of file app_meetme.c.
00622 { 00623 OPT_ARG_WAITMARKED = 0, 00624 OPT_ARG_EXITKEYS = 1, 00625 OPT_ARG_DURATION_STOP = 2, 00626 OPT_ARG_DURATION_LIMIT = 3, 00627 OPT_ARG_MOH_CLASS = 4, 00628 OPT_ARG_INTROMSG = 5, 00629 OPT_ARG_ARRAY_SIZE = 6, 00630 };
| anonymous enum |
Definition at line 6447 of file app_meetme.c.
06447 { 06448 SLA_TRUNK_OPT_MOH = (1 << 0), 06449 };
| anonymous enum |
Definition at line 6451 of file app_meetme.c.
06451 { 06452 SLA_TRUNK_OPT_ARG_MOH_CLASS = 0, 06453 SLA_TRUNK_OPT_ARG_ARRAY_SIZE = 1, 06454 };
| enum announcetypes |
Definition at line 689 of file app_meetme.c.
00689 { 00690 CONF_HASJOIN, 00691 CONF_HASLEFT 00692 };
| enum entrance_sound |
Definition at line 544 of file app_meetme.c.
| enum recording_state |
Definition at line 549 of file app_meetme.c.
00549 { 00550 MEETME_RECORD_OFF, 00551 MEETME_RECORD_STARTED, 00552 MEETME_RECORD_ACTIVE, 00553 MEETME_RECORD_TERMINATE 00554 };
| enum sla_event_type |
Event types that can be queued up for the SLA thread.
| SLA_EVENT_HOLD |
A station has put the call on hold |
| SLA_EVENT_DIAL_STATE |
The state of a dial has changed |
| SLA_EVENT_RINGING_TRUNK |
The state of a ringing trunk has changed |
| SLA_EVENT_RELOAD |
A reload of configuration has been requested |
| SLA_EVENT_CHECK_RELOAD |
Poke the SLA thread so it can check if it can perform a reload |
Definition at line 883 of file app_meetme.c.
00883 { 00884 /*! A station has put the call on hold */ 00885 SLA_EVENT_HOLD, 00886 /*! The state of a dial has changed */ 00887 SLA_EVENT_DIAL_STATE, 00888 /*! The state of a ringing trunk has changed */ 00889 SLA_EVENT_RINGING_TRUNK, 00890 /*! A reload of configuration has been requested */ 00891 SLA_EVENT_RELOAD, 00892 /*! Poke the SLA thread so it can check if it can perform a reload */ 00893 SLA_EVENT_CHECK_RELOAD, 00894 };
| enum sla_hold_access |
Definition at line 793 of file app_meetme.c.
00793 { 00794 /*! This means that any station can put it on hold, and any station 00795 * can retrieve the call from hold. */ 00796 SLA_HOLD_OPEN, 00797 /*! This means that only the station that put the call on hold may 00798 * retrieve it from hold. */ 00799 SLA_HOLD_PRIVATE, 00800 };
| enum sla_station_hangup |
Definition at line 920 of file app_meetme.c.
00920 { 00921 SLA_STATION_HANGUP_NORMAL, 00922 SLA_STATION_HANGUP_TIMEOUT, 00923 };
| enum sla_trunk_state |
| SLA_TRUNK_STATE_IDLE | |
| SLA_TRUNK_STATE_RINGING | |
| SLA_TRUNK_STATE_UP | |
| SLA_TRUNK_STATE_ONHOLD | |
| SLA_TRUNK_STATE_ONHOLD_BYME |
Definition at line 785 of file app_meetme.c.
00785 { 00786 SLA_TRUNK_STATE_IDLE, 00787 SLA_TRUNK_STATE_RINGING, 00788 SLA_TRUNK_STATE_UP, 00789 SLA_TRUNK_STATE_ONHOLD, 00790 SLA_TRUNK_STATE_ONHOLD_BYME, 00791 };
| enum sla_which_trunk_refs |
Definition at line 780 of file app_meetme.c.
00780 { 00781 ALL_TRUNK_REFS, 00782 INACTIVE_TRUNK_REFS, 00783 };
| enum volume_action |
Definition at line 539 of file app_meetme.c.
| static int acf_meetme_info | ( | struct ast_channel * | chan, | |
| const char * | cmd, | |||
| char * | data, | |||
| char * | buf, | |||
| size_t | len | |||
| ) | [static] |
Definition at line 7019 of file app_meetme.c.
References acf_meetme_info_eval(), args, AST_APP_ARG, AST_DECLARE_APP_ARGS, AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, ast_log(), AST_STANDARD_APP_ARGS, ast_strdupa, ast_strlen_zero(), ast_conference::confno, LOG_ERROR, LOG_NOTICE, and parse().
07020 { 07021 struct ast_conference *conf; 07022 char *parse; 07023 int result = -2; /* only non-negative numbers valid, -1 is used elsewhere */ 07024 AST_DECLARE_APP_ARGS(args, 07025 AST_APP_ARG(keyword); 07026 AST_APP_ARG(confno); 07027 ); 07028 07029 if (ast_strlen_zero(data)) { 07030 ast_log(LOG_ERROR, "Syntax: MEETME_INFO() requires two arguments\n"); 07031 return -1; 07032 } 07033 07034 parse = ast_strdupa(data); 07035 AST_STANDARD_APP_ARGS(args, parse); 07036 07037 if (ast_strlen_zero(args.keyword)) { 07038 ast_log(LOG_ERROR, "Syntax: MEETME_INFO() requires a keyword\n"); 07039 return -1; 07040 } 07041 07042 if (ast_strlen_zero(args.confno)) { 07043 ast_log(LOG_ERROR, "Syntax: MEETME_INFO() requires a conference number\n"); 07044 return -1; 07045 } 07046 07047 AST_LIST_LOCK(&confs); 07048 AST_LIST_TRAVERSE(&confs, conf, list) { 07049 if (!strcmp(args.confno, conf->confno)) { 07050 result = acf_meetme_info_eval(args.keyword, conf); 07051 break; 07052 } 07053 } 07054 AST_LIST_UNLOCK(&confs); 07055 07056 if (result > -1) { 07057 snprintf(buf, len, "%d", result); 07058 } else if (result == -1) { 07059 ast_log(LOG_NOTICE, "Error: invalid keyword: '%s'\n", args.keyword); 07060 snprintf(buf, len, "0"); 07061 } else if (result == -2) { 07062 ast_log(LOG_NOTICE, "Error: conference (%s) not found\n", args.confno); 07063 snprintf(buf, len, "0"); 07064 } 07065 07066 return 0; 07067 }
| static int acf_meetme_info_eval | ( | const char * | keyword, | |
| const struct ast_conference * | conf | |||
| ) | [static] |
Definition at line 7001 of file app_meetme.c.
References ast_conference::isdynamic, ast_conference::locked, ast_conference::start, and ast_conference::users.
Referenced by acf_meetme_info().
07002 { 07003 if (!strcasecmp("lock", keyword)) { 07004 return conf->locked; 07005 } else if (!strcasecmp("parties", keyword)) { 07006 return conf->users; 07007 } else if (!strcasecmp("activity", keyword)) { 07008 time_t now; 07009 now = time(NULL); 07010 return (now - conf->start); 07011 } else if (!strcasecmp("dynamic", keyword)) { 07012 return conf->isdynamic; 07013 } else { 07014 return -1; 07015 } 07016 07017 }
| static int action_meetmelist | ( | struct mansession * | s, | |
| const struct message * | m | |||
| ) | [static] |
Definition at line 4908 of file app_meetme.c.
References ADMINFLAG_MUTED, ADMINFLAG_SELFMUTED, ast_conf_user::adminflags, ao2_iterator_destroy(), ao2_iterator_init(), ao2_iterator_next, ao2_ref, AST_LIST_EMPTY, AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, ast_strlen_zero(), ast_test_flag64, astman_append(), astman_get_header(), astman_send_error(), astman_send_listack(), ast_channel::caller, ast_conf_user::chan, CONFFLAG_ADMIN, CONFFLAG_MARKEDUSER, CONFFLAG_MONITOR, CONFFLAG_TALKER, ast_conference::confno, ast_channel::connected, ast_party_connected_line::id, ast_party_caller::id, ast_party_id::name, ast_party_id::number, S_COR, ast_party_name::str, ast_party_number::str, ast_conf_user::talking, total, ast_conf_user::user_no, ast_conference::usercontainer, ast_conf_user::userflags, ast_party_name::valid, and ast_party_number::valid.
Referenced by load_module().
04909 { 04910 const char *actionid = astman_get_header(m, "ActionID"); 04911 const char *conference = astman_get_header(m, "Conference"); 04912 char idText[80] = ""; 04913 struct ast_conference *cnf; 04914 struct ast_conf_user *user; 04915 struct ao2_iterator user_iter; 04916 int total = 0; 04917 04918 if (!ast_strlen_zero(actionid)) 04919 snprintf(idText, sizeof(idText), "ActionID: %s\r\n", actionid); 04920 04921 if (AST_LIST_EMPTY(&confs)) { 04922 astman_send_error(s, m, "No active conferences."); 04923 return 0; 04924 } 04925 04926 astman_send_listack(s, m, "Meetme user list will follow", "start"); 04927 04928 /* Find the right conference */ 04929 AST_LIST_LOCK(&confs); 04930 AST_LIST_TRAVERSE(&confs, cnf, list) { 04931 /* If we ask for one particular, and this isn't it, skip it */ 04932 if (!ast_strlen_zero(conference) && strcmp(cnf->confno, conference)) 04933 continue; 04934 04935 /* Show all the users */ 04936 user_iter = ao2_iterator_init(cnf->usercontainer, 0); 04937 while ((user = ao2_iterator_next(&user_iter))) { 04938 total++; 04939 astman_append(s, 04940 "Event: MeetmeList\r\n" 04941 "%s" 04942 "Conference: %s\r\n" 04943 "UserNumber: %d\r\n" 04944 "CallerIDNum: %s\r\n" 04945 "CallerIDName: %s\r\n" 04946 "ConnectedLineNum: %s\r\n" 04947 "ConnectedLineName: %s\r\n" 04948 "Channel: %s\r\n" 04949 "Admin: %s\r\n" 04950 "Role: %s\r\n" 04951 "MarkedUser: %s\r\n" 04952 "Muted: %s\r\n" 04953 "Talking: %s\r\n" 04954 "\r\n", 04955 idText, 04956 cnf->confno, 04957 user->user_no, 04958 S_COR(user->chan->caller.id.number.valid, user->chan->caller.id.number.str, "<unknown>"), 04959 S_COR(user->chan->caller.id.name.valid, user->chan->caller.id.name.str, "<no name>"), 04960 S_COR(user->chan->connected.id.number.valid, user->chan->connected.id.number.str, "<unknown>"), 04961 S_COR(user->chan->connected.id.name.valid, user->chan->connected.id.name.str, "<no name>"), 04962 user->chan->name, 04963 ast_test_flag64(&user->userflags, CONFFLAG_ADMIN) ? "Yes" : "No", 04964 ast_test_flag64(&user->userflags, CONFFLAG_MONITOR) ? "Listen only" : ast_test_flag64(&user->userflags, CONFFLAG_TALKER) ? "Talk only" : "Talk and listen", 04965 ast_test_flag64(&user->userflags, CONFFLAG_MARKEDUSER) ? "Yes" : "No", 04966 user->adminflags & ADMINFLAG_MUTED ? "By admin" : user->adminflags & ADMINFLAG_SELFMUTED ? "By self" : "No", 04967 user->talking > 0 ? "Yes" : user->talking == 0 ? "No" : "Not monitored"); 04968 ao2_ref(user, -1); 04969 } 04970 ao2_iterator_destroy(&user_iter); 04971 } 04972 AST_LIST_UNLOCK(&confs); 04973 /* Send final confirmation */ 04974 astman_append(s, 04975 "Event: MeetmeListComplete\r\n" 04976 "EventList: Complete\r\n" 04977 "ListItems: %d\r\n" 04978 "%s" 04979 "\r\n", total, idText); 04980 return 0; 04981 }
| static int action_meetmemute | ( | struct mansession * | s, | |
| const struct message * | m | |||
| ) | [static] |
Definition at line 4898 of file app_meetme.c.
References meetmemute().
Referenced by load_module().
04899 { 04900 return meetmemute(s, m, 1); 04901 }
| static int action_meetmeunmute | ( | struct mansession * | s, | |
| const struct message * | m | |||
| ) | [static] |
Definition at line 4903 of file app_meetme.c.
References meetmemute().
Referenced by load_module().
04904 { 04905 return meetmemute(s, m, 0); 04906 }
| static int admin_exec | ( | struct ast_channel * | chan, | |
| const char * | data | |||
| ) | [static] |
The MeetMeadmin application.
MeetMeAdmin(confno, command, caller)
Definition at line 4630 of file app_meetme.c.
References ADMINFLAG_KICKME, ADMINFLAG_MUTED, ADMINFLAG_SELFMUTED, ADMINFLAG_T_REQUEST, ast_conf_user::adminflags, ao2_callback, ao2_find, ao2_ref, args, AST_APP_ARG, ast_atomic_fetchadd_int(), AST_DECLARE_APP_ARGS, AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, ast_log(), AST_STANDARD_APP_ARGS, ast_strdupa, ast_strlen_zero(), ast_test_flag64, CONFFLAG_ADMIN, ast_conference::confno, dispose_conf(), find_user(), ast_conference::locked, LOG_NOTICE, LOG_WARNING, OBJ_NODATA, pbx_builtin_setvar_helper(), ast_conference::refcount, reset_volumes(), rt_extend_conf(), tweak_listen_volume(), tweak_talk_volume(), user_listen_voldown_cb(), user_listen_volup_cb(), user_max_cmp(), user_reset_vol_cb(), user_set_kickme_cb(), user_set_muted_cb(), user_set_unmuted_cb(), user_talk_voldown_cb(), user_talk_volup_cb(), ast_conference::usercontainer, ast_conf_user::userflags, VOL_DOWN, and VOL_UP.
Referenced by load_module(), meetme_cmd_helper(), run_station(), sla_station_exec(), and sla_stop_ringing_trunk().
04630 { 04631 char *params; 04632 struct ast_conference *cnf; 04633 struct ast_conf_user *user = NULL; 04634 AST_DECLARE_APP_ARGS(args, 04635 AST_APP_ARG(confno); 04636 AST_APP_ARG(command); 04637 AST_APP_ARG(user); 04638 ); 04639 int res = 0; 04640 04641 if (ast_strlen_zero(data)) { 04642 ast_log(LOG_WARNING, "MeetMeAdmin requires an argument!\n"); 04643 pbx_builtin_setvar_helper(chan, "MEETMEADMINSTATUS", "NOPARSE"); 04644 return -1; 04645 } 04646 04647 params = ast_strdupa(data); 04648 AST_STANDARD_APP_ARGS(args, params); 04649 04650 if (!args.command) { 04651 ast_log(LOG_WARNING, "MeetmeAdmin requires a command!\n"); 04652 pbx_builtin_setvar_helper(chan, "MEETMEADMINSTATUS", "NOPARSE"); 04653 return -1; 04654 } 04655 04656 AST_LIST_LOCK(&confs); 04657 AST_LIST_TRAVERSE(&confs, cnf, list) { 04658 if (!strcmp(cnf->confno, args.confno)) 04659 break; 04660 } 04661 04662 if (!cnf) { 04663 ast_log(LOG_WARNING, "Conference number '%s' not found!\n", args.confno); 04664 AST_LIST_UNLOCK(&confs); 04665 pbx_builtin_setvar_helper(chan, "MEETMEADMINSTATUS", "NOTFOUND"); 04666 return 0; 04667 } 04668 04669 ast_atomic_fetchadd_int(&cnf->refcount, 1); 04670 04671 if (args.user) { 04672 user = find_user(cnf, args.user); 04673 if (!user) { 04674 ast_log(LOG_NOTICE, "Specified User not found!\n"); 04675 res = -2; 04676 goto usernotfound; 04677 } 04678 } 04679 04680 switch (*args.command) { 04681 case 76: /* L: Lock */ 04682 cnf->locked = 1; 04683 break; 04684 case 108: /* l: Unlock */ 04685 cnf->locked = 0; 04686 break; 04687 case 75: /* K: kick all users */ 04688 ao2_callback(cnf->usercontainer, OBJ_NODATA, user_set_kickme_cb, NULL); 04689 break; 04690 case 101: /* e: Eject last user*/ 04691 { 04692 int max_no = 0; 04693 04694 /* If they passed in a user, disregard it */ 04695 if (user) { 04696 ao2_ref(user, -1); 04697 } 04698 04699 ao2_callback(cnf->usercontainer, OBJ_NODATA, user_max_cmp, &max_no); 04700 user = ao2_find(cnf->usercontainer, &max_no, 0); 04701 if (!ast_test_flag64(&user->userflags, CONFFLAG_ADMIN)) 04702 user->adminflags |= ADMINFLAG_KICKME; 04703 else { 04704 res = -1; 04705 ast_log(LOG_NOTICE, "Not kicking last user, is an Admin!\n"); 04706 } 04707 ao2_ref(user, -1); 04708 break; 04709 } 04710 case 77: /* M: Mute */ 04711 user->adminflags |= ADMINFLAG_MUTED; 04712 break; 04713 case 78: /* N: Mute all (non-admin) users */ 04714 ao2_callback(cnf->usercontainer, OBJ_NODATA, user_set_muted_cb, &cnf); 04715 break; 04716 case 109: /* m: Unmute */ 04717 user->adminflags &= ~(ADMINFLAG_MUTED | ADMINFLAG_SELFMUTED | ADMINFLAG_T_REQUEST); 04718 break; 04719 case 110: /* n: Unmute all users */ 04720 ao2_callback(cnf->usercontainer, OBJ_NODATA, user_set_unmuted_cb, NULL); 04721 break; 04722 case 107: /* k: Kick user */ 04723 user->adminflags |= ADMINFLAG_KICKME; 04724 break; 04725 case 118: /* v: Lower all users listen volume */ 04726 ao2_callback(cnf->usercontainer, OBJ_NODATA, user_listen_voldown_cb, NULL); 04727 break; 04728 case 86: /* V: Raise all users listen volume */ 04729 ao2_callback(cnf->usercontainer, OBJ_NODATA, user_listen_volup_cb, NULL); 04730 break; 04731 case 115: /* s: Lower all users speaking volume */ 04732 ao2_callback(cnf->usercontainer, OBJ_NODATA, user_talk_voldown_cb, NULL); 04733 break; 04734 case 83: /* S: Raise all users speaking volume */ 04735 ao2_callback(cnf->usercontainer, OBJ_NODATA, user_talk_volup_cb, NULL); 04736 break; 04737 case 82: /* R: Reset all volume levels */ 04738 ao2_callback(cnf->usercontainer, OBJ_NODATA, user_reset_vol_cb, NULL); 04739 break; 04740 case 114: /* r: Reset user's volume level */ 04741 reset_volumes(user); 04742 break; 04743 case 85: /* U: Raise user's listen volume */ 04744 tweak_listen_volume(user, VOL_UP); 04745 break; 04746 case 117: /* u: Lower user's listen volume */ 04747 tweak_listen_volume(user, VOL_DOWN); 04748 break; 04749 case 84: /* T: Raise user's talk volume */ 04750 tweak_talk_volume(user, VOL_UP); 04751 break; 04752 case 116: /* t: Lower user's talk volume */ 04753 tweak_talk_volume(user, VOL_DOWN); 04754 break; 04755 case 'E': /* E: Extend conference */ 04756 if (rt_extend_conf(args.confno)) { 04757 res = -1; 04758 } 04759 break; 04760 } 04761 04762 if (args.user) { 04763 /* decrement reference from find_user */ 04764 ao2_ref(user, -1); 04765 } 04766 usernotfound: 04767 AST_LIST_UNLOCK(&confs); 04768 04769 dispose_conf(cnf); 04770 pbx_builtin_setvar_helper(chan, "MEETMEADMINSTATUS", res == -2 ? "NOTFOUND" : res ? "FAILED" : "OK"); 04771 04772 return 0; 04773 }
| static void* announce_thread | ( | void * | data | ) | [static] |
Definition at line 2160 of file app_meetme.c.
References ao2_ref, ast_check_hangup(), ast_cond_wait, ast_copy_string(), ast_filedelete(), ast_fileexists(), AST_LIST_APPEND_LIST, AST_LIST_EMPTY, AST_LIST_HEAD_INIT_NOLOCK, AST_LIST_HEAD_NOLOCK, AST_LIST_REMOVE_HEAD, ast_log(), ast_mutex_lock, ast_mutex_unlock, ast_streamfile(), ast_waitstream(), CONF_HASLEFT, get_announce_filename(), and LOG_DEBUG.
Referenced by conf_run().
02161 { 02162 struct announce_listitem *current; 02163 struct ast_conference *conf = data; 02164 int res; 02165 char filename[PATH_MAX] = ""; 02166 AST_LIST_HEAD_NOLOCK(, announce_listitem) local_list; 02167 AST_LIST_HEAD_INIT_NOLOCK(&local_list); 02168 02169 while (!conf->announcethread_stop) { 02170 ast_mutex_lock(&conf->announcelistlock); 02171 if (conf->announcethread_stop) { 02172 ast_mutex_unlock(&conf->announcelistlock); 02173 break; 02174 } 02175 if (AST_LIST_EMPTY(&conf->announcelist)) 02176 ast_cond_wait(&conf->announcelist_addition, &conf->announcelistlock); 02177 02178 AST_LIST_APPEND_LIST(&local_list, &conf->announcelist, entry); 02179 AST_LIST_HEAD_INIT_NOLOCK(&conf->announcelist); 02180 02181 ast_mutex_unlock(&conf->announcelistlock); 02182 if (conf->announcethread_stop) { 02183 break; 02184 } 02185 02186 for (res = 1; !conf->announcethread_stop && (current = AST_LIST_REMOVE_HEAD(&local_list, entry)); ao2_ref(current, -1)) { 02187 ast_log(LOG_DEBUG, "About to play %s\n", current->namerecloc); 02188 if (!ast_fileexists(current->namerecloc, NULL, NULL)) 02189 continue; 02190 if ((current->confchan) && (current->confusers > 1) && !ast_check_hangup(current->confchan)) { 02191 if (!ast_streamfile(current->confchan, current->namerecloc, current->language)) 02192 res = ast_waitstream(current->confchan, ""); 02193 if (!res) { 02194 ast_copy_string(filename, get_announce_filename(current->announcetype), sizeof(filename)); 02195 if (!ast_streamfile(current->confchan, filename, current->language)) 02196 ast_waitstream(current->confchan, ""); 02197 } 02198 } 02199 if (current->announcetype == CONF_HASLEFT) { 02200 ast_filedelete(current->namerecloc, NULL); 02201 } 02202 } 02203 } 02204 02205 /* thread marked to stop, clean up */ 02206 while ((current = AST_LIST_REMOVE_HEAD(&local_list, entry))) { 02207 ast_filedelete(current->namerecloc, NULL); 02208 ao2_ref(current, -1); 02209 } 02210 return NULL; 02211 }
| static void answer_trunk_chan | ( | struct ast_channel * | chan | ) | [static] |
Definition at line 5320 of file app_meetme.c.
References ast_answer(), and ast_indicate().
Referenced by run_station(), sla_handle_dial_state_event(), and sla_station_exec().
05321 { 05322 ast_answer(chan); 05323 ast_indicate(chan, -1); 05324 }
| AST_APP_OPTIONS | ( | sla_trunk_opts | , | |
| BEGIN_OPTIONS | AST_APP_OPTION_ARG'M', SLA_TRUNK_OPT_MOH, SLA_TRUNK_OPT_ARG_MOH_CLASS, | |||
| END_OPTIONS | ||||
| ) |
| AST_APP_OPTIONS | ( | meetme_opts | , | |
| BEGIN_OPTIONS | AST_APP_OPTION'A', CONFFLAG_MARKEDUSER, | |||
| AST_APP_OPTION('a', CONFFLAG_ADMIN) | , | |||
| AST_APP_OPTION('b', CONFFLAG_AGI) | , | |||
| AST_APP_OPTION('c', CONFFLAG_ANNOUNCEUSERCOUNT) | , | |||
| AST_APP_OPTION('C', CONFFLAG_KICK_CONTINUE) | , | |||
| AST_APP_OPTION('D', CONFFLAG_DYNAMICPIN) | , | |||
| AST_APP_OPTION('d', CONFFLAG_DYNAMIC) | , | |||
| AST_APP_OPTION('E', CONFFLAG_EMPTYNOPIN) | , | |||
| AST_APP_OPTION('e', CONFFLAG_EMPTY) | , | |||
| AST_APP_OPTION('F', CONFFLAG_PASS_DTMF) | , | |||
| AST_APP_OPTION_ARG('G', CONFFLAG_INTROMSG, OPT_ARG_INTROMSG) | , | |||
| AST_APP_OPTION('i', CONFFLAG_INTROUSER) | , | |||
| AST_APP_OPTION('I', CONFFLAG_INTROUSERNOREVIEW) | , | |||
| AST_APP_OPTION_ARG('M', CONFFLAG_MOH, OPT_ARG_MOH_CLASS) | , | |||
| AST_APP_OPTION('m', CONFFLAG_STARTMUTED) | , | |||
| AST_APP_OPTION('o', CONFFLAG_OPTIMIZETALKER) | , | |||
| AST_APP_OPTION('P', CONFFLAG_ALWAYSPROMPT) | , | |||
| AST_APP_OPTION_ARG('p', CONFFLAG_KEYEXIT, OPT_ARG_EXITKEYS) | , | |||
| AST_APP_OPTION('q', CONFFLAG_QUIET) | , | |||
| AST_APP_OPTION('r', CONFFLAG_RECORDCONF) | , | |||
| AST_APP_OPTION('s', CONFFLAG_STARMENU) | , | |||
| AST_APP_OPTION('T', CONFFLAG_MONITORTALKER) | , | |||
| AST_APP_OPTION('l', CONFFLAG_MONITOR) | , | |||
| AST_APP_OPTION('t', CONFFLAG_TALKER) | , | |||
| AST_APP_OPTION_ARG('w', CONFFLAG_WAITMARKED, OPT_ARG_WAITMARKED) | , | |||
| AST_APP_OPTION('X', CONFFLAG_EXIT_CONTEXT) | , | |||
| AST_APP_OPTION('x', CONFFLAG_MARKEDEXIT) | , | |||
| AST_APP_OPTION('1', CONFFLAG_NOONLYPERSON) | , | |||
| AST_APP_OPTION_ARG('S', CONFFLAG_DURATION_STOP, OPT_ARG_DURATION_STOP) | , | |||
| AST_APP_OPTION_ARG('L', CONFFLAG_DURATION_LIMIT, OPT_ARG_DURATION_LIMIT) | , | |||
| END_OPTIONS | ||||
| ) |
| AST_DATA_STRUCTURE | ( | ast_conf_user | , | |
| MEETME_USER_DATA_EXPORT | ||||
| ) |
| AST_DATA_STRUCTURE | ( | ast_conference | , | |
| MEETME_DATA_EXPORT | ||||
| ) |
| static AST_LIST_HEAD_STATIC | ( | confs | , | |
| ast_conference | ||||
| ) | [static] |
| AST_MODULE_INFO | ( | ASTERISK_GPL_KEY | , | |
| AST_MODFLAG_LOAD_ORDER | , | |||
| "MeetMe conference bridge" | , | |||
| . | load = load_module, |
|||
| . | unload = unload_module, |
|||
| . | reload = reload, |
|||
| . | load_pri = AST_MODPRI_DEVSTATE_PROVIDER | |||
| ) |
| static AST_RWLIST_HEAD_STATIC | ( | sla_trunks | , | |
| sla_trunk | ||||
| ) | [static] |
| static AST_RWLIST_HEAD_STATIC | ( | sla_stations | , | |
| sla_station | ||||
| ) | [static] |
| static struct ast_conference* build_conf | ( | const char * | confno, | |
| const char * | pin, | |||
| const char * | pinadmin, | |||
| int | make, | |||
| int | dynamic, | |||
| int | refcount, | |||
| const struct ast_channel * | chan, | |||
| struct ast_test * | test | |||
| ) | [static, read] |
Find or create a conference.
| confno | The conference name/number | |
| pin | The regular user pin | |
| pinadmin | The admin pin | |
| make | Make the conf if it doesn't exist | |
| dynamic | Mark the newly created conference as dynamic | |
| refcount | How many references to mark on the conference | |
| chan | The asterisk channel |
Definition at line 1191 of file app_meetme.c.
References ao2_container_alloc, ao2_ref, ast_atomic_fetchadd_int(), ast_calloc, ast_copy_string(), AST_FORMAT_SLINEAR, ast_free, ast_hangup(), AST_LIST_INSERT_HEAD, AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, ast_log(), ast_mutex_destroy, ast_mutex_init, AST_PTHREADT_NULL, ast_request(), ast_set_read_format(), ast_set_write_format(), ast_test_status_update, ast_verb, ast_conference::chan, conf_map, ast_conference::confno, ast_conference::dahdiconf, ast_conference::fd, ast_channel::fds, ast_conference::isdynamic, ast_conference::listenlock, LOG_WARNING, ast_conference::maxusers, ast_conference::pin, ast_conference::pinadmin, ast_conference::playlock, ast_conference::recordthread, ast_conference::recordthreadlock, ast_conference::refcount, ast_conference::start, ast_conference::uniqueid, user_no_cmp(), and ast_conference::usercontainer.
Referenced by dial_trunk(), find_conf(), find_conf_realtime(), run_station(), sla_station_exec(), and sla_trunk_exec().
01194 { 01195 struct ast_conference *cnf; 01196 struct dahdi_confinfo dahdic = { 0, }; 01197 int confno_int = 0; 01198 01199 AST_LIST_LOCK(&confs); 01200 01201 AST_LIST_TRAVERSE(&confs, cnf, list) { 01202 if (!strcmp(confno, cnf->confno)) 01203 break; 01204 } 01205 01206 if (cnf || (!make && !dynamic)) 01207 goto cnfout; 01208 01209 /* Make a new one */ 01210 if (!(cnf = ast_calloc(1, sizeof(*cnf))) || 01211 !(cnf->usercontainer = ao2_container_alloc(1, NULL, user_no_cmp))) { 01212 goto cnfout; 01213 } 01214 01215 ast_mutex_init(&cnf->playlock); 01216 ast_mutex_init(&cnf->listenlock); 01217 cnf->recordthread = AST_PTHREADT_NULL; 01218 ast_mutex_init(&cnf->recordthreadlock); 01219 cnf->announcethread = AST_PTHREADT_NULL; 01220 ast_mutex_init(&cnf->announcethreadlock); 01221 ast_copy_string(cnf->confno, confno, sizeof(cnf->confno)); 01222 ast_copy_string(cnf->pin, pin, sizeof(cnf->pin)); 01223 ast_copy_string(cnf->pinadmin, pinadmin, sizeof(cnf->pinadmin)); 01224 ast_copy_string(cnf->uniqueid, chan->uniqueid, sizeof(cnf->uniqueid)); 01225 01226 /* Setup a new dahdi conference */ 01227 dahdic.confno = -1; 01228 dahdic.confmode = DAHDI_CONF_CONFANN | DAHDI_CONF_CONFANNMON; 01229 cnf->fd = open("/dev/dahdi/pseudo", O_RDWR); 01230 if (cnf->fd < 0 || ioctl(cnf->fd, DAHDI_SETCONF, &dahdic)) { 01231 if (test) { 01232 /* if we are creating a conference for a unit test, it is not neccesary 01233 * to open a pseudo channel, so, if we fail continue creating 01234 * the conference. */ 01235 ast_test_status_update(test, "Unable to open DAHDI pseudo device\n"); 01236 } else { 01237 ast_log(LOG_WARNING, "Unable to open DAHDI pseudo device\n"); 01238 if (cnf->fd >= 0) 01239 close(cnf->fd); 01240 ao2_ref(cnf->usercontainer, -1); 01241 ast_mutex_destroy(&cnf->playlock); 01242 ast_mutex_destroy(&cnf->listenlock); 01243 ast_mutex_destroy(&cnf->recordthreadlock); 01244 ast_mutex_destroy(&cnf->announcethreadlock); 01245 ast_free(cnf); 01246 cnf = NULL; 01247 goto cnfout; 01248 } 01249 } 01250 01251 cnf->dahdiconf = dahdic.confno; 01252 01253 /* Setup a new channel for playback of audio files */ 01254 cnf->chan = ast_request("DAHDI", AST_FORMAT_SLINEAR, chan, "pseudo", NULL); 01255 if (cnf->chan) { 01256 ast_set_read_format(cnf->chan, AST_FORMAT_SLINEAR); 01257 ast_set_write_format(cnf->chan, AST_FORMAT_SLINEAR); 01258 dahdic.chan = 0; 01259 dahdic.confno = cnf->dahdiconf; 01260 dahdic.confmode = DAHDI_CONF_CONFANN | DAHDI_CONF_CONFANNMON; 01261 if (ioctl(cnf->chan->fds[0], DAHDI_SETCONF, &dahdic)) { 01262 if (test) { 01263 ast_test_status_update(test, "Error setting conference on pseudo channel\n"); 01264 } 01265 ast_log(LOG_WARNING, "Error setting conference\n"); 01266 if (cnf->chan) 01267 ast_hangup(cnf->chan); 01268 else 01269 close(cnf->fd); 01270 ao2_ref(cnf->usercontainer, -1); 01271 ast_mutex_destroy(&cnf->playlock); 01272 ast_mutex_destroy(&cnf->listenlock); 01273 ast_mutex_destroy(&cnf->recordthreadlock); 01274 ast_mutex_destroy(&cnf->announcethreadlock); 01275 ast_free(cnf); 01276 cnf = NULL; 01277 goto cnfout; 01278 } 01279 } 01280 01281 /* Fill the conference struct */ 01282 cnf->start = time(NULL); 01283 cnf->maxusers = 0x7fffffff; 01284 cnf->isdynamic = dynamic ? 1 : 0; 01285 ast_verb(3, "Created MeetMe conference %d for conference '%s'\n", cnf->dahdiconf, cnf->confno); 01286 AST_LIST_INSERT_HEAD(&confs, cnf, list); 01287 01288 /* Reserve conference number in map */ 01289 if ((sscanf(cnf->confno, "%30d", &confno_int) == 1) && (confno_int >= 0 && confno_int < 1024)) 01290 conf_map[confno_int] = 1; 01291 01292 cnfout: 01293 if (cnf) 01294 ast_atomic_fetchadd_int(&cnf->refcount, refcount); 01295 01296 AST_LIST_UNLOCK(&confs); 01297 01298 return cnf; 01299 }
| static int can_write | ( | struct ast_channel * | chan, | |
| struct ast_flags64 * | confflags | |||
| ) | [static] |
Definition at line 2213 of file app_meetme.c.
References ast_channel::_state, AST_STATE_UP, ast_test_flag64, and CONFFLAG_NO_AUDIO_UNTIL_UP.
Referenced by conf_run().
02214 { 02215 if (!ast_test_flag64(confflags, CONFFLAG_NO_AUDIO_UNTIL_UP)) { 02216 return 1; 02217 } 02218 02219 return (chan->_state == AST_STATE_UP); 02220 }
| static int careful_write | ( | int | fd, | |
| unsigned char * | data, | |||
| int | len, | |||
| int | block | |||
| ) | [static] |
Definition at line 994 of file app_meetme.c.
References ast_log(), errno, and LOG_WARNING.
Referenced by conf_play(), and conf_run().
00995 { 00996 int res; 00997 int x; 00998 00999 while (len) { 01000 if (block) { 01001 x = DAHDI_IOMUX_WRITE | DAHDI_IOMUX_SIGEVENT; 01002 res = ioctl(fd, DAHDI_IOMUX, &x); 01003 } else 01004 res = 0; 01005 if (res >= 0) 01006 res = write(fd, data, len); 01007 if (res < 1) { 01008 if (errno != EAGAIN) { 01009 ast_log(LOG_WARNING, "Failed to write audio data to conference: %s\n", strerror(errno)); 01010 return -1; 01011 } else 01012 return 0; 01013 } 01014 len -= res; 01015 data += res; 01016 } 01017 01018 return 0; 01019 }
| static int channel_admin_exec | ( | struct ast_channel * | chan, | |
| const char * | data | |||
| ) | [static] |
The MeetMeChannelAdmin application MeetMeChannelAdmin(channel, command).
Definition at line 4777 of file app_meetme.c.
References ADMINFLAG_KICKME, ADMINFLAG_MUTED, ast_conf_user::adminflags, ao2_callback, ao2_ref, args, AST_APP_ARG, AST_DECLARE_APP_ARGS, AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, ast_log(), AST_STANDARD_APP_ARGS, ast_strdupa, ast_strlen_zero(), LOG_NOTICE, LOG_WARNING, user_chan_cb(), and ast_conference::usercontainer.
Referenced by load_module().
04777 { 04778 char *params; 04779 struct ast_conference *conf = NULL; 04780 struct ast_conf_user *user = NULL; 04781 AST_DECLARE_APP_ARGS(args, 04782 AST_APP_ARG(channel); 04783 AST_APP_ARG(command); 04784 ); 04785 04786 if (ast_strlen_zero(data)) { 04787 ast_log(LOG_WARNING, "MeetMeChannelAdmin requires two arguments!\n"); 04788 return -1; 04789 } 04790 04791 params = ast_strdupa(data); 04792 AST_STANDARD_APP_ARGS(args, params); 04793 04794 if (!args.channel) { 04795 ast_log(LOG_WARNING, "MeetMeChannelAdmin requires a channel name!\n"); 04796 return -1; 04797 } 04798 04799 if (!args.command) { 04800 ast_log(LOG_WARNING, "MeetMeChannelAdmin requires a command!\n"); 04801 return -1; 04802 } 04803 04804 AST_LIST_LOCK(&confs); 04805 AST_LIST_TRAVERSE(&confs, conf, list) { 04806 if ((user = ao2_callback(conf->usercontainer, 0, user_chan_cb, args.channel))) { 04807 break; 04808 } 04809 } 04810 04811 if (!user) { 04812 ast_log(LOG_NOTICE, "Specified user (%s) not found\n", args.channel); 04813 AST_LIST_UNLOCK(&confs); 04814 return 0; 04815 } 04816 04817 /* perform the specified action */ 04818 switch (*args.command) { 04819 case 77: /* M: Mute */ 04820 user->adminflags |= ADMINFLAG_MUTED; 04821 break; 04822 case 109: /* m: Unmute */ 04823 user->adminflags &= ~ADMINFLAG_MUTED; 04824 break; 04825 case 107: /* k: Kick user */ 04826 user->adminflags |= ADMINFLAG_KICKME; 04827 break; 04828 default: /* unknown command */ 04829 ast_log(LOG_WARNING, "Unknown MeetMeChannelAdmin command '%s'\n", args.command); 04830 break; 04831 } 04832 ao2_ref(user, -1); 04833 AST_LIST_UNLOCK(&confs); 04834 04835 return 0; 04836 }
| static char* complete_confno | ( | const char * | word, | |
| int | state | |||
| ) | [static] |
Definition at line 1301 of file app_meetme.c.
References AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, ast_strdup, ast_conference::confno, and len().
Referenced by complete_meetmecmd_list(), complete_meetmecmd_lock(), and complete_meetmecmd_mute_kick().
01302 { 01303 struct ast_conference *cnf; 01304 char *ret = NULL; 01305 int which = 0; 01306 int len = strlen(word); 01307 01308 AST_LIST_LOCK(&confs); 01309 AST_LIST_TRAVERSE(&confs, cnf, list) { 01310 if (!strncmp(word, cnf->confno, len) && ++which > state) { 01311 /* dup before releasing the lock */ 01312 ret = ast_strdup(cnf->confno); 01313 break; 01314 } 01315 } 01316 AST_LIST_UNLOCK(&confs); 01317 return ret; 01318 }
| static char* complete_meetmecmd_list | ( | const char * | line, | |
| const char * | word, | |||
| int | pos, | |||
| int | state | |||
| ) | [static] |
Definition at line 1390 of file app_meetme.c.
References ast_strdup, ast_strdupa, complete_confno(), ast_conference::confno, len(), and STR_CONCISE.
Referenced by meetme_show_cmd().
01391 { 01392 int len; 01393 01394 if (pos == 2) { 01395 len = strlen(word); 01396 if (!strncasecmp(word, STR_CONCISE, len)) { 01397 if (state == 0) { 01398 return ast_strdup(STR_CONCISE); 01399 } 01400 --state; 01401 } 01402 01403 return complete_confno(word, state); 01404 } 01405 if (pos == 3 && state == 0) { 01406 char *saved = NULL; 01407 char *myline; 01408 char *confno; 01409 01410 /* Extract the confno from the command line. */ 01411 myline = ast_strdupa(line); 01412 strtok_r(myline, " ", &saved); 01413 strtok_r(NULL, " ", &saved); 01414 confno = strtok_r(NULL, " ", &saved); 01415 01416 if (!strcasecmp(confno, STR_CONCISE)) { 01417 /* There is nothing valid in this position now. */ 01418 return NULL; 01419 } 01420 01421 len = strlen(word); 01422 if (!strncasecmp(word, STR_CONCISE, len)) { 01423 return ast_strdup(STR_CONCISE); 01424 } 01425 } 01426 return NULL; 01427 }
| static char* complete_meetmecmd_lock | ( | const char * | word, | |
| int | pos, | |||
| int | state | |||
| ) | [static] |
Definition at line 1382 of file app_meetme.c.
References complete_confno().
Referenced by meetme_lock_cmd().
01383 { 01384 if (pos == 2) { 01385 return complete_confno(word, state); 01386 } 01387 return NULL; 01388 }
| static char* complete_meetmecmd_mute_kick | ( | const char * | line, | |
| const char * | word, | |||
| int | pos, | |||
| int | state | |||
| ) | [static] |
Definition at line 1342 of file app_meetme.c.
References AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, ast_strdup, ast_strdupa, complete_confno(), complete_userno(), ast_conference::confno, and len().
Referenced by meetme_kick_cmd(), and meetme_mute_cmd().
01343 { 01344 if (pos == 2) { 01345 return complete_confno(word, state); 01346 } 01347 if (pos == 3) { 01348 int len = strlen(word); 01349 char *ret = NULL; 01350 char *saved = NULL; 01351 char *myline; 01352 char *confno; 01353 struct ast_conference *cnf; 01354 01355 if (!strncasecmp(word, "all", len)) { 01356 if (state == 0) { 01357 return ast_strdup("all"); 01358 } 01359 --state; 01360 } 01361 01362 /* Extract the confno from the command line. */ 01363 myline = ast_strdupa(line); 01364 strtok_r(myline, " ", &saved); 01365 strtok_r(NULL, " ", &saved); 01366 confno = strtok_r(NULL, " ", &saved); 01367 01368 AST_LIST_LOCK(&confs); 01369 AST_LIST_TRAVERSE(&confs, cnf, list) { 01370 if (!strcmp(confno, cnf->confno)) { 01371 ret = complete_userno(cnf, word, state); 01372 break; 01373 } 01374 } 01375 AST_LIST_UNLOCK(&confs); 01376 01377 return ret; 01378 } 01379 return NULL; 01380 }
| static char* complete_userno | ( | struct ast_conference * | cnf, | |
| const char * | word, | |||
| int | state | |||
| ) | [static] |
Definition at line 1320 of file app_meetme.c.
References ao2_iterator_destroy(), ao2_iterator_init(), ao2_iterator_next, ao2_ref, ast_strdup, len(), ast_conf_user::user_no, and ast_conference::usercontainer.
Referenced by complete_meetmecmd_mute_kick().
01321 { 01322 char usrno[50]; 01323 struct ao2_iterator iter; 01324 struct ast_conf_user *usr; 01325 char *ret = NULL; 01326 int which = 0; 01327 int len = strlen(word); 01328 01329 iter = ao2_iterator_init(cnf->usercontainer, 0); 01330 for (; (usr = ao2_iterator_next(&iter)); ao2_ref(usr, -1)) { 01331 snprintf(usrno, sizeof(usrno), "%d", usr->user_no); 01332 if (!strncmp(word, usrno, len) && ++which > state) { 01333 ao2_ref(usr, -1); 01334 ret = ast_strdup(usrno); 01335 break; 01336 } 01337 } 01338 ao2_iterator_destroy(&iter); 01339 return ret; 01340 }
| static int conf_exec | ( | struct ast_channel * | chan, | |
| const char * | data | |||
| ) | [static] |
The meetme() application.
Definition at line 4242 of file app_meetme.c.
References ast_channel::_state, ast_conference::adminopts, args, ARRAY_LEN, ast_answer(), AST_APP_ARG, ast_app_getdata(), ast_app_parse_options64(), ast_category_browse(), ast_config_destroy(), ast_config_load, ast_copy_string(), AST_DECLARE_APP_ARGS, AST_DIGIT_ANY, AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, ast_load_realtime_multientry(), ast_log(), ast_say_digits(), AST_STANDARD_APP_ARGS, AST_STATE_UP, ast_stopstream(), ast_strdupa, ast_streamfile(), ast_strlen_zero(), ast_test_flag64, ast_test_suite_event_notify, ast_variable_browse(), ast_variable_retrieve(), ast_verb, ast_waitstream(), conf_map, conf_run(), CONFFLAG_ADMIN, CONFFLAG_ALWAYSPROMPT, CONFFLAG_DYNAMIC, CONFFLAG_DYNAMICPIN, CONFFLAG_EMPTY, CONFFLAG_EMPTYNOPIN, CONFFLAG_QUIET, CONFIG_FILE_NAME, CONFIG_STATUS_FILEINVALID, ast_conference::confno, dispose_conf(), find_conf(), find_conf_realtime(), ast_conference::isdynamic, LOG_ERROR, LOG_WARNING, MAX_CONFNUM, MAX_PIN, MAX_SETTINGS, ast_variable::name, ast_variable::next, OPT_ARG_ARRAY_SIZE, parse(), ast_conference::pin, ast_conference::pinadmin, ast_conference::recordingfilename, ast_conference::recordingformat, SENTINEL, ast_conference::useropts, ast_conference::users, ast_variable::value, and var.
Referenced by load_module().
04243 { 04244 int res = -1; 04245 char confno[MAX_CONFNUM] = ""; 04246 int allowretry = 0; 04247 int retrycnt = 0; 04248 struct ast_conference *cnf = NULL; 04249 struct ast_flags64 confflags = {0}; 04250 struct ast_flags config_flags = { 0 }; 04251 int dynamic = 0; 04252 int empty = 0, empty_no_pin = 0; 04253 int always_prompt = 0; 04254 const char *notdata; 04255 char *info, the_pin[MAX_PIN] = ""; 04256 AST_DECLARE_APP_ARGS(args, 04257 AST_APP_ARG(confno); 04258 AST_APP_ARG(options); 04259 AST_APP_ARG(pin); 04260 ); 04261 char *optargs[OPT_ARG_ARRAY_SIZE] = { NULL, }; 04262 04263 if (ast_strlen_zero(data)) { 04264 allowretry = 1; 04265 notdata = ""; 04266 } else { 04267 notdata = data; 04268 } 04269 04270 if (chan->_state != AST_STATE_UP) 04271 ast_answer(chan); 04272 04273 info = ast_strdupa(notdata); 04274 04275 AST_STANDARD_APP_ARGS(args, info); 04276 04277 if (args.confno) { 04278 ast_copy_string(confno, args.confno, sizeof(confno)); 04279 if (ast_strlen_zero(confno)) { 04280 allowretry = 1; 04281 } 04282 } 04283 04284 if (args.pin) 04285 ast_copy_string(the_pin, args.pin, sizeof(the_pin)); 04286 04287 if (args.options) { 04288 ast_app_parse_options64(meetme_opts, &confflags, optargs, args.options); 04289 dynamic = ast_test_flag64(&confflags, CONFFLAG_DYNAMIC | CONFFLAG_DYNAMICPIN); 04290 if (ast_test_flag64(&confflags, CONFFLAG_DYNAMICPIN) && ast_strlen_zero(args.pin)) 04291 strcpy(the_pin, "q"); 04292 04293 empty = ast_test_flag64(&confflags, CONFFLAG_EMPTY | CONFFLAG_EMPTYNOPIN); 04294 empty_no_pin = ast_test_flag64(&confflags, CONFFLAG_EMPTYNOPIN); 04295 always_prompt = ast_test_flag64(&confflags, CONFFLAG_ALWAYSPROMPT | CONFFLAG_DYNAMICPIN); 04296 } 04297 04298 do { 04299 if (retrycnt > 3) 04300 allowretry = 0; 04301 if (empty) { 04302 int i; 04303 struct ast_config *cfg; 04304 struct ast_variable *var; 04305 int confno_int; 04306 04307 /* We only need to load the config file for static and empty_no_pin (otherwise we don't care) */ 04308 if ((empty_no_pin) || (!dynamic)) { 04309 cfg = ast_config_load(CONFIG_FILE_NAME, config_flags); 04310 if (cfg && cfg != CONFIG_STATUS_FILEINVALID) { 04311 var = ast_variable_browse(cfg, "rooms"); 04312 while (var) { 04313 char parse[MAX_SETTINGS], *stringp = parse, *confno_tmp; 04314 if (!strcasecmp(var->name, "conf")) { 04315 int found = 0; 04316 ast_copy_string(parse, var->value, sizeof(parse)); 04317 confno_tmp = strsep(&stringp, "|,"); 04318 if (!dynamic) { 04319 /* For static: run through the list and see if this conference is empty */ 04320 AST_LIST_LOCK(&confs); 04321 AST_LIST_TRAVERSE(&confs, cnf, list) { 04322 if (!strcmp(confno_tmp, cnf->confno)) { 04323 /* The conference exists, therefore it's not empty */ 04324 found = 1; 04325 break; 04326 } 04327 } 04328 AST_LIST_UNLOCK(&confs); 04329 cnf = NULL; 04330 if (!found) { 04331 /* At this point, we have a confno_tmp (static conference) that is empty */ 04332 if ((empty_no_pin && ast_strlen_zero(stringp)) || (!empty_no_pin)) { 04333 /* Case 1: empty_no_pin and pin is nonexistent (NULL) 04334 * Case 2: empty_no_pin and pin is blank (but not NULL) 04335 * Case 3: not empty_no_pin 04336 */ 04337 ast_copy_string(confno, confno_tmp, sizeof(confno)); 04338 break; 04339 } 04340 } 04341 } 04342 } 04343 var = var->next; 04344 } 04345 ast_config_destroy(cfg); 04346 } 04347 04348 if (ast_strlen_zero(confno) && (cfg = ast_load_realtime_multientry("meetme", "confno LIKE", "%", SENTINEL))) { 04349 const char *catg; 04350 for (catg = ast_category_browse(cfg, NULL); catg; catg = ast_category_browse(cfg, catg)) { 04351 const char *confno_tmp = ast_variable_retrieve(cfg, catg, "confno"); 04352 const char *pin_tmp = ast_variable_retrieve(cfg, catg, "pin"); 04353 if (ast_strlen_zero(confno_tmp)) { 04354 continue; 04355 } 04356 if (!dynamic) { 04357 int found = 0; 04358 /* For static: run through the list and see if this conference is empty */ 04359 AST_LIST_LOCK(&confs); 04360 AST_LIST_TRAVERSE(&confs, cnf, list) { 04361 if (!strcmp(confno_tmp, cnf->confno)) { 04362 /* The conference exists, therefore it's not empty */ 04363 found = 1; 04364 break; 04365 } 04366 } 04367 AST_LIST_UNLOCK(&confs); 04368 if (!found) { 04369 /* At this point, we have a confno_tmp (realtime conference) that is empty */ 04370 if ((empty_no_pin && ast_strlen_zero(pin_tmp)) || (!empty_no_pin)) { 04371 /* Case 1: empty_no_pin and pin is nonexistent (NULL) 04372 * Case 2: empty_no_pin and pin is blank (but not NULL) 04373 * Case 3: not empty_no_pin 04374 */ 04375 ast_copy_string(confno, confno_tmp, sizeof(confno)); 04376 break; 04377 } 04378 } 04379 } 04380 } 04381 ast_config_destroy(cfg); 04382 } 04383 } 04384 04385 /* Select first conference number not in use */ 04386 if (ast_strlen_zero(confno) && dynamic) { 04387 AST_LIST_LOCK(&confs); 04388 for (i = 0; i < ARRAY_LEN(conf_map); i++) { 04389 if (!conf_map[i]) { 04390 snprintf(confno, sizeof(confno), "%d", i); 04391 conf_map[i] = 1; 04392 break; 04393 } 04394 } 04395 AST_LIST_UNLOCK(&confs); 04396 } 04397 04398 /* Not found? */ 04399 if (ast_strlen_zero(confno)) { 04400 ast_test_suite_event_notify("PLAYBACK", "Message: conf-noempty"); 04401 res = ast_streamfile(chan, "conf-noempty", chan->language); 04402 if (!res) 04403 ast_waitstream(chan, ""); 04404 } else { 04405 if (sscanf(confno, "%30d", &confno_int) == 1) { 04406 if (!ast_test_flag64(&confflags, CONFFLAG_QUIET)) { 04407 res = ast_streamfile(chan, "conf-enteringno", chan->language); 04408 if (!res) { 04409 ast_waitstream(chan, ""); 04410 res = ast_say_digits(chan, confno_int, "", chan->language); 04411 } 04412 } 04413 } else { 04414 ast_log(LOG_ERROR, "Could not scan confno '%s'\n", confno); 04415 } 04416 } 04417 } 04418 04419 while (allowretry && (ast_strlen_zero(confno)) && (++retrycnt < 4)) { 04420 /* Prompt user for conference number */ 04421 res = ast_app_getdata(chan, "conf-getconfno", confno, sizeof(confno) - 1, 0); 04422 if (res < 0) { 04423 /* Don't try to validate when we catch an error */ 04424 confno[0] = '\0'; 04425 allowretry = 0; 04426 break; 04427 } 04428 } 04429 if (!ast_strlen_zero(confno)) { 04430 /* Check the validity of the conference */ 04431 cnf = find_conf(chan, confno, 1, dynamic, the_pin, 04432 sizeof(the_pin), 1, &confflags); 04433 if (!cnf) { 04434 int too_early = 0; 04435 04436 cnf = find_conf_realtime(chan, confno, 1, dynamic, 04437 the_pin, sizeof(the_pin), 1, &confflags, &too_early, optargs); 04438 if (rt_schedule && too_early) 04439 allowretry = 0; 04440 } 04441 04442 if (!cnf) { 04443 if (allowretry) { 04444 confno[0] = '\0'; 04445 res = ast_streamfile(chan, "conf-invalid", chan->language); 04446 if (!res) 04447 ast_waitstream(chan, ""); 04448 res = -1; 04449 } 04450 } else { 04451 /* Conference requires a pin for specified access level */ 04452 int req_pin = !ast_strlen_zero(cnf->pin) || 04453 (!ast_strlen_zero(cnf->pinadmin) && 04454 ast_test_flag64(&confflags, CONFFLAG_ADMIN)); 04455 /* The following logic was derived from a 04456 * 4 variable truth table and defines which 04457 * circumstances are not exempt from pin 04458 * checking. 04459 * If this needs to be modified, write the 04460 * truth table back out from the boolean 04461 * expression AB+A'D+C', change the erroneous 04462 * result, and rederive the expression. 04463 * Variables: 04464 * A: pin provided? 04465 * B: always prompt? 04466 * C: dynamic? 04467 * D: has users? */ 04468 int not_exempt = !cnf->isdynamic; 04469 not_exempt = not_exempt || (!ast_strlen_zero(args.pin) && ast_test_flag64(&confflags, CONFFLAG_ALWAYSPROMPT)); 04470 not_exempt = not_exempt || (ast_strlen_zero(args.pin) && cnf->users); 04471 if (req_pin && not_exempt) { 04472 char pin[MAX_PIN] = ""; 04473 int j; 04474 04475 /* Allow the pin to be retried up to 3 times */ 04476 for (j = 0; j < 3; j++) { 04477 if (*the_pin && (always_prompt == 0)) { 04478 ast_copy_string(pin, the_pin, sizeof(pin)); 04479 res = 0; 04480 } else { 04481 /* Prompt user for pin if pin is required */ 04482 ast_test_suite_event_notify("PLAYBACK", "Message: conf-getpin\r\n" 04483 "Channel: %s", 04484 chan->name); 04485 res = ast_app_getdata(chan, "conf-getpin", pin + strlen(pin), sizeof(pin) - 1 - strlen(pin), 0); 04486 } 04487 if (res >= 0) { 04488 if ((!strcasecmp(pin, cnf->pin) && 04489 (ast_strlen_zero(cnf->pinadmin) || 04490 !ast_test_flag64(&confflags, CONFFLAG_ADMIN))) || 04491 (!ast_strlen_zero(cnf->pinadmin) && 04492 !strcasecmp(pin, cnf->pinadmin))) { 04493 /* Pin correct */ 04494 allowretry = 0; 04495 if (!ast_strlen_zero(cnf->pinadmin) && !strcasecmp(pin, cnf->pinadmin)) { 04496 if (!ast_strlen_zero(cnf->adminopts)) { 04497 char *opts = ast_strdupa(cnf->adminopts); 04498 ast_app_parse_options64(meetme_opts, &confflags, optargs, opts); 04499 } 04500 } else { 04501 if (!ast_strlen_zero(cnf->useropts)) { 04502 char *opts = ast_strdupa(cnf->useropts); 04503 ast_app_parse_options64(meetme_opts, &confflags, optargs, opts); 04504 } 04505 } 04506 /* Run the conference */ 04507 ast_verb(4, "Starting recording of MeetMe Conference %s into file %s.%s.\n", cnf->confno, cnf->recordingfilename, cnf->recordingformat); 04508 res = conf_run(chan, cnf, &confflags, optargs); 04509 break; 04510 } else { 04511 /* Pin invalid */ 04512 if (!ast_streamfile(chan, "conf-invalidpin", chan->language)) { 04513 res = ast_waitstream(chan, AST_DIGIT_ANY); 04514 ast_stopstream(chan); 04515 } else { 04516 ast_log(LOG_WARNING, "Couldn't play invalid pin msg!\n"); 04517 break; 04518 } 04519 if (res < 0) 04520 break; 04521 pin[0] = res; 04522 pin[1] = '\0'; 04523 res = -1; 04524 if (allowretry) 04525 confno[0] = '\0'; 04526 } 04527 } else { 04528 /* failed when getting the pin */ 04529 res = -1; 04530 allowretry = 0; 04531 /* see if we need to get rid of the conference */ 04532 break; 04533 } 04534 04535 /* Don't retry pin with a static pin */ 04536 if (*the_pin && (always_prompt == 0)) { 04537 break; 04538 } 04539 } 04540 } else { 04541 /* No pin required */ 04542 allowretry = 0; 04543 04544 /* For RealTime conferences without a pin 04545 * should still support loading options 04546 */ 04547 if (!ast_strlen_zero(cnf->useropts)) { 04548 char *opts = ast_strdupa(cnf->useropts); 04549 ast_app_parse_options64(meetme_opts, &confflags, optargs, opts); 04550 } 04551 04552 /* Run the conference */ 04553 res = conf_run(chan, cnf, &confflags, optargs); 04554 } 04555 dispose_conf(cnf); 04556 cnf = NULL; 04557 } 04558 } 04559 } while (allowretry); 04560 04561 if (cnf) 04562 dispose_conf(cnf); 04563 04564 return res; 04565 }
| static void conf_flush | ( | int | fd, | |
| struct ast_channel * | chan | |||
| ) | [static] |
Definition at line 1859 of file app_meetme.c.
References ast_frfree, ast_log(), ast_read(), ast_waitfor(), f, and LOG_WARNING.
Referenced by conf_run().
01860 { 01861 int x; 01862 01863 /* read any frames that may be waiting on the channel 01864 and throw them away 01865 */ 01866 if (chan) { 01867 struct ast_frame *f; 01868 01869 /* when no frames are available, this will wait 01870 for 1 millisecond maximum 01871 */ 01872 while (ast_waitfor(chan, 1) > 0) { 01873 f = ast_read(chan); 01874 if (f) 01875 ast_frfree(f); 01876 else /* channel was hung up or something else happened */ 01877 break; 01878 } 01879 } 01880 01881 /* flush any data sitting in the pseudo channel */ 01882 x = DAHDI_FLUSH_ALL; 01883 if (ioctl(fd, DAHDI_FLUSH, &x)) 01884 ast_log(LOG_WARNING, "Error flushing channel\n"); 01885 01886 }
| static int conf_free | ( | struct ast_conference * | conf | ) | [static] |
Remove the conference from the list and free it.
We assume that this was called while holding conflock.
Definition at line 1891 of file app_meetme.c.
References ao2_ref, ast_cond_signal, ast_filedelete(), AST_FRAME_BITS, ast_free, ast_frfree, ast_hangup(), AST_LIST_LOCK, AST_LIST_REMOVE, AST_LIST_REMOVE_HEAD, AST_LIST_UNLOCK, ast_mutex_destroy, ast_mutex_lock, ast_mutex_unlock, AST_PTHREADT_NULL, ast_softhangup(), AST_SOFTHANGUP_EXPLICIT, ast_translator_free_path(), ast_conference::chan, ast_conference::confno, EVENT_FLAG_CALL, ast_conference::fd, ast_conference::lchan, ast_conference::listenlock, manager_event, MEETME_RECORD_ACTIVE, MEETME_RECORD_OFF, MEETME_RECORD_TERMINATE, ast_conference::origframe, ast_conference::playlock, ast_conference::recordingfilename, ast_conference::recordingformat, ast_conference::recordthreadlock, ast_conference::transframe, ast_conference::transpath, and ast_conference::usercontainer.
Referenced by dispose_conf().
01892 { 01893 int x; 01894 struct announce_listitem *item; 01895 01896 AST_LIST_REMOVE(&confs, conf, list); 01897 manager_event(EVENT_FLAG_CALL, "MeetmeEnd", "Meetme: %s\r\n", conf->confno); 01898 01899 if (conf->recording == MEETME_RECORD_ACTIVE) { 01900 conf->recording = MEETME_RECORD_TERMINATE; 01901 AST_LIST_UNLOCK(&confs); 01902 while (1) { 01903 usleep(1); 01904 AST_LIST_LOCK(&confs); 01905 if (conf->recording == MEETME_RECORD_OFF) 01906 break; 01907 AST_LIST_UNLOCK(&confs); 01908 } 01909 } 01910 01911 for (x = 0; x < AST_FRAME_BITS; x++) { 01912 if (conf->transframe[x]) 01913 ast_frfree(conf->transframe[x]); 01914 if (conf->transpath[x]) 01915 ast_translator_free_path(conf->transpath[x]); 01916 } 01917 if (conf->announcethread != AST_PTHREADT_NULL) { 01918 ast_mutex_lock(&conf->announcelistlock); 01919 conf->announcethread_stop = 1; 01920 ast_softhangup(conf->chan, AST_SOFTHANGUP_EXPLICIT); 01921 ast_cond_signal(&conf->announcelist_addition); 01922 ast_mutex_unlock(&conf->announcelistlock); 01923 pthread_join(conf->announcethread, NULL); 01924 01925 while ((item = AST_LIST_REMOVE_HEAD(&conf->announcelist, entry))) { 01926 ast_filedelete(item->namerecloc, NULL); 01927 ao2_ref(item, -1); 01928 } 01929 ast_mutex_destroy(&conf->announcelistlock); 01930 } 01931 01932 if (conf->origframe) 01933 ast_frfree(conf->origframe); 01934 if (conf->lchan) 01935 ast_hangup(conf->lchan); 01936 if (conf->chan) 01937 ast_hangup(conf->chan); 01938 if (conf->fd >= 0) 01939 close(conf->fd); 01940 if (conf->recordingfilename) { 01941 ast_free(conf->recordingfilename); 01942 } 01943 if (conf->usercontainer) { 01944 ao2_ref(conf->usercontainer, -1); 01945 } 01946 if (conf->recordingformat) { 01947 ast_free(conf->recordingformat); 01948 } 01949 ast_mutex_destroy(&conf->playlock); 01950 ast_mutex_destroy(&conf->listenlock); 01951 ast_mutex_destroy(&conf->recordthreadlock); 01952 ast_mutex_destroy(&conf->announcethreadlock); 01953 ast_free(conf); 01954 01955 return 0; 01956 }
| static void conf_play | ( | struct ast_channel * | chan, | |
| struct ast_conference * | conf, | |||
| enum entrance_sound | sound | |||
| ) | [static] |
Definition at line 1112 of file app_meetme.c.
References ast_autoservice_start(), ast_autoservice_stop(), ast_check_hangup(), AST_LIST_LOCK, AST_LIST_UNLOCK, ast_test_suite_event_notify, careful_write(), ast_conference::confno, enter, ENTER, ast_conference::fd, leave, LEAVE, len(), and ast_conference::markedusers.
Referenced by conf_run().
01113 { 01114 unsigned char *data; 01115 int len; 01116 int res = -1; 01117 01118 ast_test_suite_event_notify("CONFPLAY", "Channel: %s\r\n" 01119 "Conference: %s\r\n" 01120 "Marked: %d", 01121 chan->name, 01122 conf->confno, 01123 conf->markedusers); 01124 01125 if (!ast_check_hangup(chan)) 01126 res = ast_autoservice_start(chan); 01127 01128 AST_LIST_LOCK(&confs); 01129 01130 switch(sound) { 01131 case ENTER: 01132 data = enter; 01133 len = sizeof(enter); 01134 break; 01135 case LEAVE: 01136 data = leave; 01137 len = sizeof(leave); 01138 break; 01139 default: 01140 data = NULL; 01141 len = 0; 01142 } 01143 if (data) { 01144 careful_write(conf->fd, data, len, 1); 01145 } 01146 01147 AST_LIST_UNLOCK(&confs); 01148 01149 if (!res) 01150 ast_autoservice_stop(chan); 01151 }
| static void conf_queue_dtmf | ( | const struct ast_conference * | conf, | |
| const struct ast_conf_user * | sender, | |||
| struct ast_frame * | f | |||
| ) | [static] |
Definition at line 1958 of file app_meetme.c.
References ao2_iterator_destroy(), ao2_iterator_init(), ao2_iterator_next, ao2_ref, ast_log(), ast_write(), ast_conf_user::chan, LOG_WARNING, and ast_conference::usercontainer.
Referenced by conf_run().
01960 { 01961 struct ast_conf_user *user; 01962 struct ao2_iterator user_iter; 01963 01964 user_iter = ao2_iterator_init(conf->usercontainer, 0); 01965 while ((user = ao2_iterator_next(&user_iter))) { 01966 if (user == sender) { 01967 ao2_ref(user, -1); 01968 continue; 01969 } 01970 if (ast_write(user->chan, f) < 0) 01971 ast_log(LOG_WARNING, "Error writing frame to channel %s\n", user->chan->name); 01972 ao2_ref(user, -1); 01973 } 01974 ao2_iterator_destroy(&user_iter); 01975 }
| static int conf_run | ( | struct ast_channel * | chan, | |
| struct ast_conference * | conf, | |||
| struct ast_flags64 * | confflags, | |||
| char * | optargs[] | |||
| ) | [static] |
Definition at line 2284 of file app_meetme.c.
References volume::actual, ADMINFLAG_KICKME, ADMINFLAG_MUTED, ADMINFLAG_SELFMUTED, ADMINFLAG_T_REQUEST, ast_conf_user::adminflags, announce_thread(), ao2_alloc, ao2_callback, ao2_find, ao2_iterator_destroy(), ao2_iterator_init(), ao2_iterator_next, ao2_link, ao2_lock, ao2_ref, ao2_unlink, ao2_unlock, ast_channel_lock, ast_channel_setoption(), ast_channel_unlock, ast_check_hangup(), ast_cond_signal, ast_config_AST_SPOOL_DIR, AST_CONTROL_BUSY, AST_CONTROL_CONGESTION, AST_CONTROL_HOLD, ast_copy_string(), ast_debug, AST_DEVICE_INUSE, AST_DEVICE_NOT_INUSE, AST_DEVSTATE_CACHABLE, ast_devstate_changed(), AST_DEVSTATE_NOT_CACHABLE, AST_DIGIT_ANY, ast_dsp_free(), ast_dsp_get_threshold_from_settings(), ast_dsp_new(), ast_dsp_silence(), ast_exists_extension(), ast_filedelete(), ast_fileexists(), AST_FORMAT_SLINEAR, ast_frame_adjust_volume(), AST_FRAME_BITS, AST_FRAME_CONTROL, AST_FRAME_DTMF, AST_FRAME_DTMF_BEGIN, AST_FRAME_DTMF_END, AST_FRAME_NULL, AST_FRAME_VOICE, ast_free, ast_frfree, AST_FRIENDLY_OFFSET, ast_func_write(), ast_goto_if_exists(), ast_hangup(), ast_indicate(), AST_LIST_HEAD_INIT_NOLOCK, AST_LIST_INSERT_TAIL, AST_LIST_LOCK, AST_LIST_NEXT, AST_LIST_UNLOCK, ast_load_realtime(), ast_localtime(), ast_log(), ast_manager_event, AST_MAX_CONTEXT, AST_MAX_EXTENSION, ast_mkdir(), ast_mktime(), ast_module_helper(), ast_moh_stop(), ast_mutex_init, ast_mutex_lock, ast_mutex_unlock, ast_null_frame, AST_OPTION_TONE_VERIFY, ast_play_and_record(), ast_pthread_create_background, ast_pthread_create_detached_background, AST_PTHREADT_NULL, ast_read(), ast_read_noaudio(), ast_realtime_require_field(), ast_record_review(), ast_request(), ast_safe_sleep(), ast_samp2tv(), ast_say_digits(), ast_say_number(), ast_set_flag64, ast_set_read_format(), ast_set_write_format(), ast_stopstream(), ast_strdup, ast_strdupa, ast_streamfile(), ast_strftime(), ast_strlen_zero(), ast_strptime(), ast_test_flag64, ast_test_suite_event_notify, ast_translate(), ast_translator_build_path(), ast_tvadd(), ast_tvdiff_ms(), ast_tvnow(), ast_tvsub(), ast_tvzero(), ast_update_realtime(), ast_variables_destroy(), ast_verb, ast_verbose, ast_waitfor_nandfds(), ast_waitstream(), ast_write(), ast_channel::audiohooks, ast_conference::bookid, ast_channel::caller, can_write(), careful_write(), ast_conference::chan, ast_conf_user::chan, ast_frame_subclass::codec, conf_flush(), CONF_HASJOIN, CONF_HASLEFT, conf_play(), conf_queue_dtmf(), CONF_SIZE, conf_start_moh(), CONFFLAG_ADMIN, CONFFLAG_AGI, CONFFLAG_ANNOUNCEUSERCOUNT, CONFFLAG_DURATION_LIMIT, CONFFLAG_DURATION_STOP, CONFFLAG_EXIT_CONTEXT, CONFFLAG_INTROMSG, CONFFLAG_INTROUSER, CONFFLAG_INTROUSERNOREVIEW, CONFFLAG_KEYEXIT, CONFFLAG_KICK_CONTINUE, CONFFLAG_MARKEDEXIT, CONFFLAG_MARKEDUSER, CONFFLAG_MOH, CONFFLAG_MONITOR, CONFFLAG_MONITORTALKER, CONFFLAG_NO_AUDIO_UNTIL_UP, CONFFLAG_NOONLYPERSON, CONFFLAG_OPTIMIZETALKER, CONFFLAG_PASS_DTMF, CONFFLAG_QUIET, CONFFLAG_RECORDCONF, CONFFLAG_SLA_STATION, CONFFLAG_STARMENU, CONFFLAG_STARTMUTED, CONFFLAG_TALKER, CONFFLAG_WAITMARKED, ast_conference::confno, ast_channel::connected, ast_channel::context, ast_conf_user::dahdichannel, ast_conference::dahdiconf, ast_frame::data, ast_frame::datalen, DATE_FORMAT, volume::desired, dtmfstr, ast_conf_user::end_sound, ast_conference::endalert, ast_conference::endtime, ENTER, errno, EVENT_FLAG_CALL, exitcontext, f, ast_conference::fd, ast_channel::fds, ast_frame::frametype, ast_conference::gmuted, ast_party_connected_line::id, ast_party_caller::id, ast_frame_subclass::integer, ast_conference::isdynamic, ast_conf_user::jointime, ast_conf_user::kicktime, ast_conference::lchan, LEAVE, ast_conf_user::listen, ast_conference::listenlock, ast_conference::locked, LOG_WARNING, ast_channel::macrocontext, ast_conference::markedusers, ast_conference::maxusers, MEETME_DELAYDETECTENDTALK, MEETME_DELAYDETECTTALK, MEETME_RECORD_ACTIVE, ast_channel::monitor, ast_variable::name, ast_party_id::name, ast_conf_user::namerecloc, ast_variable::next, ast_party_id::number, OBJ_NODATA, ast_frame::offset, OPT_ARG_DURATION_LIMIT, OPT_ARG_DURATION_STOP, OPT_ARG_EXITKEYS, OPT_ARG_INTROMSG, OPT_ARG_MOH_CLASS, OPT_ARG_WAITMARKED, ast_conference::origframe, parse(), pbx_builtin_getvar_helper(), pbx_builtin_setvar_helper(), pbx_exec(), pbx_findapp(), ast_conf_user::play_warning, ast_conference::playlock, ast_frame::ptr, ast_channel::rawwriteformat, ast_conference::recordingfilename, ast_conference::recordingformat, ast_conference::recordthread, ast_conference::recordthreadlock, reset_volumes(), RQ_UINTEGER1, RQ_UINTEGER2, RQ_UINTEGER3, RQ_UINTEGER4, rt_extend_conf(), S_COR, ast_frame::samples, set_talk_volume(), set_user_talking(), SLA_EVENT_HOLD, sla_queue_event_conf(), ast_conf_user::start_time, ast_party_name::str, ast_party_number::str, ast_frame::subclass, ast_conf_user::talk, ast_conf_user::talking, ast_channel::tech, THRESHOLD_SILENCE, ast_conf_user::timelimit, ast_conference::transframe, ast_conference::transpath, tweak_listen_volume(), tweak_talk_volume(), ast_channel_tech::type, ast_conference::uniqueid, user_max_cmp(), ast_conf_user::user_no, user_set_kickme_cb(), user_set_muted_cb(), user_set_unmuted_cb(), ast_conference::usercontainer, ast_conf_user::userflags, ast_conference::users, ast_party_name::valid, ast_party_number::valid, ast_variable::value, var, VOL_DOWN, VOL_UP, ast_conf_user::warning_freq, and ast_conf_user::warning_sound.
Referenced by conf_exec(), dial_trunk(), run_station(), sla_station_exec(), and sla_trunk_exec().
02285 { 02286 struct ast_conf_user *user = NULL; 02287 int fd; 02288 struct dahdi_confinfo dahdic, dahdic_empty; 02289 struct ast_frame *f; 02290 struct ast_channel *c; 02291 struct ast_frame fr; 02292 int outfd; 02293 int ms; 02294 int nfds; 02295 int res; 02296 int retrydahdi; 02297 int origfd; 02298 int musiconhold = 0, mohtempstopped = 0; 02299 int firstpass = 0; 02300 int lastmarked = 0; 02301 int currentmarked = 0; 02302 int ret = -1; 02303 int x; 02304 int menu_active = 0; 02305 int menu8_active = 0; 02306 int talkreq_manager = 0; 02307 int using_pseudo = 0; 02308 int duration = 20; 02309 int sent_event = 0; 02310 int checked = 0; 02311 int announcement_played = 0; 02312 struct timeval now; 02313 struct ast_dsp *dsp = NULL; 02314 struct ast_app *agi_app; 02315 char *agifile, *mod_speex; 02316 const char *agifiledefault = "conf-background.agi", *tmpvar; 02317 char meetmesecs[30] = ""; 02318 char exitcontext[AST_MAX_CONTEXT] = ""; 02319 char recordingtmp[AST_MAX_EXTENSION] = ""; 02320 char members[10] = ""; 02321 int dtmf, opt_waitmarked_timeout = 0; 02322 time_t timeout = 0; 02323 struct dahdi_bufferinfo bi; 02324 char __buf[CONF_SIZE + AST_FRIENDLY_OFFSET]; 02325 char *buf = __buf + AST_FRIENDLY_OFFSET; 02326 char *exitkeys = NULL; 02327 unsigned int calldurationlimit = 0; 02328 long timelimit = 0; 02329 long play_warning = 0; 02330 long warning_freq = 0; 02331 const char *warning_sound = NULL; 02332 const char *end_sound = NULL; 02333 char *parse; 02334 long time_left_ms = 0; 02335 struct timeval nexteventts = { 0, }; 02336 int to; 02337 int setusercount = 0; 02338 int confsilence = 0, totalsilence = 0; 02339 02340 if (!(user = ao2_alloc(sizeof(*user), NULL))) { 02341 return ret; 02342 } 02343 02344 /* Possible timeout waiting for marked user */ 02345 if (ast_test_flag64(confflags, CONFFLAG_WAITMARKED) && 02346 !ast_strlen_zero(optargs[OPT_ARG_WAITMARKED]) && 02347 (sscanf(optargs[OPT_ARG_WAITMARKED], "%30d", &opt_waitmarked_timeout) == 1) && 02348 (opt_waitmarked_timeout > 0)) { 02349 timeout = time(NULL) + opt_waitmarked_timeout; 02350 } 02351 02352 if (ast_test_flag64(confflags, CONFFLAG_DURATION_STOP) && !ast_strlen_zero(optargs[OPT_ARG_DURATION_STOP])) { 02353 calldurationlimit = atoi(optargs[OPT_ARG_DURATION_STOP]); 02354 ast_verb(3, "Setting call duration limit to %d seconds.\n", calldurationlimit); 02355 } 02356 02357 if (ast_test_flag64(confflags, CONFFLAG_DURATION_LIMIT) && !ast_strlen_zero(optargs[OPT_ARG_DURATION_LIMIT])) { 02358 char *limit_str, *warning_str, *warnfreq_str; 02359 const char *var; 02360 02361 parse = optargs[OPT_ARG_DURATION_LIMIT]; 02362 limit_str = strsep(&parse, ":"); 02363 warning_str = strsep(&parse, ":"); 02364 warnfreq_str = parse; 02365 02366 timelimit = atol(limit_str); 02367 if (warning_str) 02368 play_warning = atol(warning_str); 02369 if (warnfreq_str) 02370 warning_freq = atol(warnfreq_str); 02371 02372 if (!timelimit) { 02373 timelimit = play_warning = warning_freq = 0; 02374 warning_sound = NULL; 02375 } else if (play_warning > timelimit) { 02376 if (!warning_freq) { 02377 play_warning = 0; 02378 } else { 02379 while (play_warning > timelimit) 02380 play_warning -= warning_freq; 02381 if (play_warning < 1) 02382 play_warning = warning_freq = 0; 02383 } 02384 } 02385 02386 ast_verb(3, "Setting conference duration limit to: %ldms.\n", timelimit); 02387 if (play_warning) { 02388 ast_verb(3, "Setting warning time to %ldms from the conference duration limit.\n", play_warning); 02389 } 02390 if (warning_freq) { 02391 ast_verb(3, "Setting warning frequency to %ldms.\n", warning_freq); 02392 } 02393 02394 ast_channel_lock(chan); 02395 if ((var = pbx_builtin_getvar_helper(chan, "CONF_LIMIT_WARNING_FILE"))) { 02396 var = ast_strdupa(var); 02397 } 02398 ast_channel_unlock(chan); 02399 02400 warning_sound = var ? var : "timeleft"; 02401 02402 ast_channel_lock(chan); 02403 if ((var = pbx_builtin_getvar_helper(chan, "CONF_LIMIT_TIMEOUT_FILE"))) { 02404 var = ast_strdupa(var); 02405 } 02406 ast_channel_unlock(chan); 02407 02408 end_sound = var ? var : NULL; 02409 02410 /* undo effect of S(x) in case they are both used */ 02411 calldurationlimit = 0; 02412 /* more efficient do it like S(x) does since no advanced opts */ 02413 if (!play_warning && !end_sound && timelimit) { 02414 calldurationlimit = timelimit / 1000; 02415 timelimit = play_warning = warning_freq = 0; 02416 } else { 02417 ast_debug(2, "Limit Data for this call:\n"); 02418 ast_debug(2, "- timelimit = %ld\n", timelimit); 02419 ast_debug(2, "- play_warning = %ld\n", play_warning); 02420 ast_debug(2, "- warning_freq = %ld\n", warning_freq); 02421 ast_debug(2, "- warning_sound = %s\n", warning_sound ? warning_sound : "UNDEF"); 02422 ast_debug(2, "- end_sound = %s\n", end_sound ? end_sound : "UNDEF"); 02423 } 02424 } 02425 02426 /* Get exit keys */ 02427 if (ast_test_flag64(confflags, CONFFLAG_KEYEXIT)) { 02428 if (!ast_strlen_zero(optargs[OPT_ARG_EXITKEYS])) 02429 exitkeys = ast_strdupa(optargs[OPT_ARG_EXITKEYS]); 02430 else 02431 exitkeys = ast_strdupa("#"); /* Default */ 02432 } 02433 02434 if (ast_test_flag64(confflags, CONFFLAG_RECORDCONF)) { 02435 if (!conf->recordingfilename) { 02436 const char *var; 02437 ast_channel_lock(chan); 02438 if ((var = pbx_builtin_getvar_helper(chan, "MEETME_RECORDINGFILE"))) { 02439 conf->recordingfilename = ast_strdup(var); 02440 } 02441 if ((var = pbx_builtin_getvar_helper(chan, "MEETME_RECORDINGFORMAT"))) { 02442 conf->recordingformat = ast_strdup(var); 02443 } 02444 ast_channel_unlock(chan); 02445 if (!conf->recordingfilename) { 02446 snprintf(recordingtmp, sizeof(recordingtmp), "meetme-conf-rec-%s-%s", conf->confno, chan->uniqueid); 02447 conf->recordingfilename = ast_strdup(recordingtmp); 02448 } 02449 if (!conf->recordingformat) { 02450 conf->recordingformat = ast_strdup("wav"); 02451 } 02452 ast_verb(4, "Starting recording of MeetMe Conference %s into file %s.%s.\n", 02453 conf->confno, conf->recordingfilename, conf->recordingformat); 02454 } 02455 } 02456 02457 ast_mutex_lock(&conf->recordthreadlock); 02458 if ((conf->recordthread == AST_PTHREADT_NULL) && ast_test_flag64(confflags, CONFFLAG_RECORDCONF) && 02459 ((conf->lchan = ast_request("DAHDI", AST_FORMAT_SLINEAR, chan, "pseudo", NULL)))) { 02460 ast_set_read_format(conf->lchan, AST_FORMAT_SLINEAR); 02461 ast_set_write_format(conf->lchan, AST_FORMAT_SLINEAR); 02462 dahdic.chan = 0; 02463 dahdic.confno = conf->dahdiconf; 02464 dahdic.confmode = DAHDI_CONF_CONFANN | DAHDI_CONF_CONFANNMON; 02465 if (ioctl(conf->lchan->fds[0], DAHDI_SETCONF, &dahdic)) { 02466 ast_log(LOG_WARNING, "Error starting listen channel\n"); 02467 ast_hangup(conf->lchan); 02468 conf->lchan = NULL; 02469 } else { 02470 ast_pthread_create_detached_background(&conf->recordthread, NULL, recordthread, conf); 02471 } 02472 } 02473 ast_mutex_unlock(&conf->recordthreadlock); 02474 02475 ast_mutex_lock(&conf->announcethreadlock); 02476 if ((conf->announcethread == AST_PTHREADT_NULL) && !ast_test_flag64(confflags, CONFFLAG_QUIET) && 02477 (ast_test_flag64(confflags, CONFFLAG_INTROUSER) || ast_test_flag64(confflags, CONFFLAG_INTROUSERNOREVIEW))) { 02478 ast_mutex_init(&conf->announcelistlock); 02479 AST_LIST_HEAD_INIT_NOLOCK(&conf->announcelist); 02480 ast_pthread_create_background(&conf->announcethread, NULL, announce_thread, conf); 02481 } 02482 ast_mutex_unlock(&conf->announcethreadlock); 02483 02484 time(&user->jointime); 02485 02486 user->timelimit = timelimit; 02487 user->play_warning = play_warning; 02488 user->warning_freq = warning_freq; 02489 user->warning_sound = warning_sound; 02490 user->end_sound = end_sound; 02491 02492 if (calldurationlimit > 0) { 02493 time(&user->kicktime); 02494 user->kicktime = user->kicktime + calldurationlimit; 02495 } 02496 02497 if (ast_tvzero(user->start_time)) 02498 user->start_time = ast_tvnow(); 02499 time_left_ms = user->timelimit; 02500 02501 if (user->timelimit) { 02502 nexteventts = ast_tvadd(user->start_time, ast_samp2tv(user->timelimit, 1000)); 02503 nexteventts = ast_tvsub(nexteventts, ast_samp2tv(user->play_warning, 1000)); 02504 } 02505 02506 if (conf->locked && (!ast_test_flag64(confflags, CONFFLAG_ADMIN))) { 02507 /* Sorry, but this conference is locked! */ 02508 if (!ast_streamfile(chan, "conf-locked", chan->language)) 02509 ast_waitstream(chan, ""); 02510 goto outrun; 02511 } 02512 02513 ast_mutex_lock(&conf->playlock); 02514 02515 if (rt_schedule && conf->maxusers) { 02516 if (conf->users >= conf->maxusers) { 02517 /* Sorry, but this confernce has reached the participant limit! */ 02518 if (!ast_streamfile(chan, "conf-full", chan->language)) 02519 ast_waitstream(chan, ""); 02520 ast_mutex_unlock(&conf->playlock); 02521 goto outrun; 02522 } 02523 } 02524 02525 ao2_lock(conf->usercontainer); 02526 ao2_callback(conf->usercontainer, OBJ_NODATA, user_max_cmp, &user->user_no); 02527 user->user_no++; 02528 ao2_link(conf->usercontainer, user); 02529 ao2_unlock(conf->usercontainer); 02530 02531 user->chan = chan; 02532 user->userflags = *confflags; 02533 user->adminflags = ast_test_flag64(confflags, CONFFLAG_STARTMUTED) ? ADMINFLAG_SELFMUTED : 0; 02534 user->adminflags |= (conf->gmuted) ? ADMINFLAG_MUTED : 0; 02535 user->talking = -1; 02536 02537 ast_mutex_unlock(&conf->playlock); 02538 02539 if (!ast_test_flag64(confflags, CONFFLAG_QUIET) && (ast_test_flag64(confflags, CONFFLAG_INTROUSER) || 02540 ast_test_flag64(confflags, CONFFLAG_INTROUSERNOREVIEW))) { 02541 char destdir[PATH_MAX]; 02542 02543 snprintf(destdir, sizeof(destdir), "%s/meetme", ast_config_AST_SPOOL_DIR); 02544 02545 if (ast_mkdir(destdir, 0777) != 0) { 02546 ast_log(LOG_WARNING, "mkdir '%s' failed: %s\n", destdir, strerror(errno)); 02547 goto outrun; 02548 } 02549 02550 snprintf(user->namerecloc, sizeof(user->namerecloc), 02551 "%s/meetme-username-%s-%d", destdir, 02552 conf->confno, user->user_no); 02553 if (ast_test_flag64(confflags, CONFFLAG_INTROUSERNOREVIEW)) 02554 res = ast_play_and_record(chan, "vm-rec-name", user->namerecloc, 10, "sln", &duration, NULL, ast_dsp_get_threshold_from_settings(THRESHOLD_SILENCE), 0, NULL); 02555 else 02556 res = ast_record_review(chan, "vm-rec-name", user->namerecloc, 10, "sln", &duration, NULL); 02557 if (res == -1) 02558 goto outrun; 02559 } 02560 02561 ast_mutex_lock(&conf->playlock); 02562 02563 if (ast_test_flag64(confflags, CONFFLAG_MARKEDUSER)) 02564 conf->markedusers++; 02565 conf->users++; 02566 if (rt_log_members) { 02567 /* Update table */ 02568 snprintf(members, sizeof(members), "%d", conf->users); 02569 ast_realtime_require_field("meetme", 02570 "confno", strlen(conf->confno) > 7 ? RQ_UINTEGER4 : strlen(conf->confno) > 4 ? RQ_UINTEGER3 : RQ_UINTEGER2, strlen(conf->confno), 02571 "members", RQ_UINTEGER1, strlen(members), 02572 NULL); 02573 ast_update_realtime("meetme", "confno", conf->confno, "members", members, NULL); 02574 } 02575 setusercount = 1; 02576 02577 /* This device changed state now - if this is the first user */ 02578 if (conf->users == 1) 02579 ast_devstate_changed(AST_DEVICE_INUSE, (conf->isdynamic ? AST_DEVSTATE_NOT_CACHABLE : AST_DEVSTATE_CACHABLE), "meetme:%s", conf->confno); 02580 02581 ast_mutex_unlock(&conf->playlock); 02582 02583 /* return the unique ID of the conference */ 02584 pbx_builtin_setvar_helper(chan, "MEETMEUNIQUEID", conf->uniqueid); 02585 02586 if (ast_test_flag64(confflags, CONFFLAG_EXIT_CONTEXT)) { 02587 ast_channel_lock(chan); 02588 if ((tmpvar = pbx_builtin_getvar_helper(chan, "MEETME_EXIT_CONTEXT"))) { 02589 ast_copy_string(exitcontext, tmpvar, sizeof(exitcontext)); 02590 } else if (!ast_strlen_zero(chan->macrocontext)) { 02591 ast_copy_string(exitcontext, chan->macrocontext, sizeof(exitcontext)); 02592 } else { 02593 ast_copy_string(exitcontext, chan->context, sizeof(exitcontext)); 02594 } 02595 ast_channel_unlock(chan); 02596 } 02597 02598 /* Play an arbitrary intro message */ 02599 if (ast_test_flag64(confflags, CONFFLAG_INTROMSG) && 02600 !ast_strlen_zero(optargs[OPT_ARG_INTROMSG])) { 02601 if (!ast_streamfile(chan, optargs[OPT_ARG_INTROMSG], chan->language)) { 02602 ast_waitstream(chan, ""); 02603 } 02604 } 02605 02606 if (!ast_test_flag64(confflags, (CONFFLAG_QUIET | CONFFLAG_NOONLYPERSON))) { 02607 if (conf->users == 1 && !ast_test_flag64(confflags, CONFFLAG_WAITMARKED)) 02608 if (!ast_streamfile(chan, "conf-onlyperson", chan->language)) 02609 ast_waitstream(chan, ""); 02610 if (ast_test_flag64(confflags, CONFFLAG_WAITMARKED) && conf->markedusers == 0) 02611 if (!ast_streamfile(chan, "conf-waitforleader", chan->language)) 02612 ast_waitstream(chan, ""); 02613 } 02614 02615 if (!ast_test_flag64(confflags, CONFFLAG_QUIET) && ast_test_flag64(confflags, CONFFLAG_ANNOUNCEUSERCOUNT) && 02616 conf->users > 1) { 02617 int keepplaying = 1; 02618 02619 if (conf->users == 2) { 02620 if (!ast_streamfile(chan, "conf-onlyone", chan->language)) { 02621 res = ast_waitstream(chan, AST_DIGIT_ANY); 02622 ast_stopstream(chan); 02623 if (res > 0) 02624 keepplaying = 0; 02625 else if (res == -1) 02626 goto outrun; 02627 } 02628 } else { 02629 if (!ast_streamfile(chan, "conf-thereare", chan->language)) { 02630 res = ast_waitstream(chan, AST_DIGIT_ANY); 02631 ast_stopstream(chan); 02632 if (res > 0) 02633 keepplaying = 0; 02634 else if (res == -1) 02635 goto outrun; 02636 } 02637 if (keepplaying) { 02638 res = ast_say_number(chan, conf->users - 1, AST_DIGIT_ANY, chan->language, (char *) NULL); 02639 if (res > 0) 02640 keepplaying = 0; 02641 else if (res == -1) 02642 goto outrun; 02643 } 02644 if (keepplaying && !ast_streamfile(chan, "conf-otherinparty", chan->language)) { 02645 res = ast_waitstream(chan, AST_DIGIT_ANY); 02646 ast_stopstream(chan); 02647 if (res > 0) 02648 keepplaying = 0; 02649 else if (res == -1) 02650 goto outrun; 02651 } 02652 } 02653 } 02654 02655 if (!ast_test_flag64(confflags, CONFFLAG_NO_AUDIO_UNTIL_UP)) { 02656 /* We're leaving this alone until the state gets changed to up */ 02657 ast_indicate(chan, -1); 02658 } 02659 02660 if (ast_set_write_format(chan, AST_FORMAT_SLINEAR) < 0) { 02661 ast_log(LOG_WARNING, "Unable to set '%s' to write linear mode\n", chan->name); 02662 goto outrun; 02663 } 02664 02665 if (ast_set_read_format(chan, AST_FORMAT_SLINEAR) < 0) { 02666 ast_log(LOG_WARNING, "Unable to set '%s' to read linear mode\n", chan->name); 02667 goto outrun; 02668 } 02669 02670 /* Reduce background noise from each participant */ 02671 if ((mod_speex = ast_module_helper("", "codec_speex", 0, 0, 0, 0))) { 02672 ast_free(mod_speex); 02673 ast_func_write(chan, "DENOISE(rx)", "on"); 02674 } 02675 02676 retrydahdi = (strcasecmp(chan->tech->type, "DAHDI") || (chan->audiohooks || chan->monitor) ? 1 : 0); 02677 user->dahdichannel = !retrydahdi; 02678 02679 dahdiretry: 02680 origfd = chan->fds[0]; 02681 if (retrydahdi) { 02682 /* open pseudo in non-blocking mode */ 02683 fd = open("/dev/dahdi/pseudo", O_RDWR | O_NONBLOCK); 02684 if (fd < 0) { 02685 ast_log(LOG_WARNING, "Unable to open DAHDI pseudo channel: %s\n", strerror(errno)); 02686 goto outrun; 02687 } 02688 using_pseudo = 1; 02689 /* Setup buffering information */ 02690 memset(&bi, 0, sizeof(bi)); 02691 bi.bufsize = CONF_SIZE / 2; 02692 bi.txbufpolicy = DAHDI_POLICY_IMMEDIATE; 02693 bi.rxbufpolicy = DAHDI_POLICY_IMMEDIATE; 02694 bi.numbufs = audio_buffers; 02695 if (ioctl(fd, DAHDI_SET_BUFINFO, &bi)) { 02696 ast_log(LOG_WARNING, "Unable to set buffering information: %s\n", strerror(errno)); 02697 close(fd); 02698 goto outrun; 02699 } 02700 x = 1; 02701 if (ioctl(fd, DAHDI_SETLINEAR, &x)) { 02702 ast_log(LOG_WARNING, "Unable to set linear mode: %s\n", strerror(errno)); 02703 close(fd); 02704 goto outrun; 02705 } 02706 nfds = 1; 02707 } else { 02708 /* XXX Make sure we're not running on a pseudo channel XXX */ 02709 fd = chan->fds[0]; 02710 nfds = 0; 02711 } 02712 memset(&dahdic, 0, sizeof(dahdic)); 02713 memset(&dahdic_empty, 0, sizeof(dahdic_empty)); 02714 /* Check to see if we're in a conference... */ 02715 dahdic.chan = 0; 02716 if (ioctl(fd, DAHDI_GETCONF, &dahdic)) { 02717 ast_log(LOG_WARNING, "Error getting conference\n"); 02718 close(fd); 02719 goto outrun; 02720 } 02721 if (dahdic.confmode) { 02722 /* Whoa, already in a conference... Retry... */ 02723 if (!retrydahdi) { 02724 ast_debug(1, "DAHDI channel is in a conference already, retrying with pseudo\n"); 02725 retrydahdi = 1; 02726 goto dahdiretry; 02727 } 02728 } 02729 memset(&dahdic, 0, sizeof(dahdic)); 02730 /* Add us to the conference */ 02731 dahdic.chan = 0; 02732 dahdic.confno = conf->dahdiconf; 02733 02734 if (!ast_test_flag64(confflags, CONFFLAG_QUIET) && (ast_test_flag64(confflags, CONFFLAG_INTROUSER) || 02735 ast_test_flag64(confflags, CONFFLAG_INTROUSERNOREVIEW)) && conf->users > 1) { 02736 struct announce_listitem *item; 02737 if (!(item = ao2_alloc(sizeof(*item), NULL))) 02738 goto outrun; 02739 ast_copy_string(item->namerecloc, user->namerecloc, sizeof(item->namerecloc)); 02740 ast_copy_string(item->language, chan->language, sizeof(item->language)); 02741 item->confchan = conf->chan; 02742 item->confusers = conf->users; 02743 item->announcetype = CONF_HASJOIN; 02744 ast_mutex_lock(&conf->announcelistlock); 02745 ao2_ref(item, +1); /* add one more so we can determine when announce_thread is done playing it */ 02746 AST_LIST_INSERT_TAIL(&conf->announcelist, item, entry); 02747 ast_cond_signal(&conf->announcelist_addition); 02748 ast_mutex_unlock(&conf->announcelistlock); 02749 02750 while (!ast_check_hangup(conf->chan) && ao2_ref(item, 0) == 2 && !ast_safe_sleep(chan, 1000)) { 02751 ; 02752 } 02753 ao2_ref(item, -1); 02754 } 02755 02756 if (ast_test_flag64(confflags, CONFFLAG_WAITMARKED) && !conf->markedusers) 02757 dahdic.confmode = DAHDI_CONF_CONF; 02758 else if (ast_test_flag64(confflags, CONFFLAG_MONITOR)) 02759 dahdic.confmode = DAHDI_CONF_CONFMON | DAHDI_CONF_LISTENER; 02760 else if (ast_test_flag64(confflags, CONFFLAG_TALKER)) 02761 dahdic.confmode = DAHDI_CONF_CONF | DAHDI_CONF_TALKER; 02762 else 02763 dahdic.confmode = DAHDI_CONF_CONF | DAHDI_CONF_TALKER | DAHDI_CONF_LISTENER; 02764 02765 if (ioctl(fd, DAHDI_SETCONF, &dahdic)) { 02766 ast_log(LOG_WARNING, "Error setting conference\n"); 02767 close(fd); 02768 goto outrun; 02769 } 02770 ast_debug(1, "Placed channel %s in DAHDI conf %d\n", chan->name, conf->dahdiconf); 02771 02772 if (!sent_event) { 02773 ast_manager_event(chan, EVENT_FLAG_CALL, "MeetmeJoin", 02774 "Channel: %s\r\n" 02775 "Uniqueid: %s\r\n" 02776 "Meetme: %s\r\n" 02777 "Usernum: %d\r\n" 02778 "CallerIDnum: %s\r\n" 02779 "CallerIDname: %s\r\n" 02780 "ConnectedLineNum: %s\r\n" 02781 "ConnectedLineName: %s\r\n", 02782 chan->name, chan->uniqueid, conf->confno, 02783 user->user_no, 02784 S_COR(user->chan->caller.id.number.valid, user->chan->caller.id.number.str, "<unknown>"), 02785 S_COR(user->chan->caller.id.name.valid, user->chan->caller.id.name.str, "<unknown>"), 02786 S_COR(user->chan->connected.id.number.valid, user->chan->connected.id.number.str, "<unknown>"), 02787 S_COR(user->chan->connected.id.name.valid, user->chan->connected.id.name.str, "<unknown>") 02788 ); 02789 sent_event = 1; 02790 } 02791 02792 if (!firstpass && !ast_test_flag64(confflags, CONFFLAG_MONITOR) && 02793 !ast_test_flag64(confflags, CONFFLAG_ADMIN)) { 02794 firstpass = 1; 02795 if (!ast_test_flag64(confflags, CONFFLAG_QUIET)) 02796 if (!ast_test_flag64(confflags, CONFFLAG_WAITMARKED) || (ast_test_flag64(confflags, CONFFLAG_MARKEDUSER) && 02797 (conf->markedusers >= 1))) { 02798 conf_play(chan, conf, ENTER); 02799 } 02800 } 02801 02802 conf_flush(fd, chan); 02803 02804 if (dsp) 02805 ast_dsp_free(dsp); 02806 02807 if (!(dsp = ast_dsp_new())) { 02808 ast_log(LOG_WARNING, "Unable to allocate DSP!\n"); 02809 res = -1; 02810 } 02811 02812 if (ast_test_flag64(confflags, CONFFLAG_AGI)) { 02813 /* Get name of AGI file to run from $(MEETME_AGI_BACKGROUND) 02814 or use default filename of conf-background.agi */ 02815 02816 ast_channel_lock(chan); 02817 if ((tmpvar = pbx_builtin_getvar_helper(chan, "MEETME_AGI_BACKGROUND"))) { 02818 agifile = ast_strdupa(tmpvar); 02819 } else { 02820 agifile = ast_strdupa(agifiledefault); 02821 } 02822 ast_channel_unlock(chan); 02823 02824 if (user->dahdichannel) { 02825 /* Set CONFMUTE mode on DAHDI channel to mute DTMF tones */ 02826 x = 1; 02827 ast_channel_setoption(chan, AST_OPTION_TONE_VERIFY, &x, sizeof(char), 0); 02828 } 02829 /* Find a pointer to the agi app and execute the script */ 02830 agi_app = pbx_findapp("agi"); 02831 if (agi_app) { 02832 ret = pbx_exec(chan, agi_app, agifile); 02833 } else { 02834 ast_log(LOG_WARNING, "Could not find application (agi)\n"); 02835 ret = -2; 02836 } 02837 if (user->dahdichannel) { 02838 /* Remove CONFMUTE mode on DAHDI channel */ 02839 x = 0; 02840 ast_channel_setoption(chan, AST_OPTION_TONE_VERIFY, &x, sizeof(char), 0); 02841 } 02842 } else { 02843 int lastusers = conf->users; 02844 if (user->dahdichannel && ast_test_flag64(confflags, CONFFLAG_STARMENU)) { 02845 /* Set CONFMUTE mode on DAHDI channel to mute DTMF tones when the menu is enabled */ 02846 x = 1; 02847 ast_channel_setoption(chan, AST_OPTION_TONE_VERIFY, &x, sizeof(char), 0); 02848 } 02849 for (;;) { 02850 int menu_was_active = 0; 02851 02852 outfd = -1; 02853 ms = -1; 02854 now = ast_tvnow(); 02855 02856 if (rt_schedule && conf->endtime) { 02857 char currenttime[32]; 02858 long localendtime = 0; 02859 int extended = 0; 02860 struct ast_tm tm; 02861 struct ast_variable *var, *origvar; 02862 struct timeval tmp; 02863 02864 if (now.tv_sec % 60 == 0) { 02865 if (!checked) { 02866 ast_localtime(&now, &tm, NULL); 02867 ast_strftime(currenttime, sizeof(currenttime), DATE_FORMAT, &tm); 02868 var = origvar = ast_load_realtime("meetme", "confno", 02869 conf->confno, "starttime <=", currenttime, 02870 "endtime >=", currenttime, NULL); 02871 02872 for ( ; var; var = var->next) { 02873 if (!strcasecmp(var->name, "endtime")) { 02874 struct ast_tm endtime_tm; 02875 ast_strptime(var->value, "%Y-%m-%d %H:%M:%S", &endtime_tm); 02876 tmp = ast_mktime(&endtime_tm, NULL); 02877 localendtime = tmp.tv_sec; 02878 } 02879 } 02880 ast_variables_destroy(origvar); 02881 02882 /* A conference can be extended from the 02883 Admin/User menu or by an external source */ 02884 if (localendtime > conf->endtime){ 02885 conf->endtime = localendtime; 02886 extended = 1; 02887 } 02888 02889 if (conf->endtime && (now.tv_sec >= conf->endtime)) { 02890 ast_verbose("Quitting time...\n"); 02891 goto outrun; 02892 } 02893 02894 if (!announcement_played && conf->endalert) { 02895 if (now.tv_sec + conf->endalert >= conf->endtime) { 02896 if (!ast_streamfile(chan, "conf-will-end-in", chan->language)) 02897 ast_waitstream(chan, ""); 02898 ast_say_digits(chan, (conf->endtime - now.tv_sec) / 60, "", chan->language); 02899 if (!ast_streamfile(chan, "minutes", chan->language)) 02900 ast_waitstream(chan, ""); 02901 if (musiconhold) { 02902 conf_start_moh(chan, optargs[OPT_ARG_MOH_CLASS]); 02903 } 02904 announcement_played = 1; 02905 } 02906 } 02907 02908 if (extended) { 02909 announcement_played = 0; 02910 } 02911 02912 checked = 1; 02913 } 02914 } else { 02915 checked = 0; 02916 } 02917 } 02918 02919 if (user->kicktime && (user->kicktime <= now.tv_sec)) { 02920 if (ast_test_flag64(confflags, CONFFLAG_KICK_CONTINUE)) { 02921 ret = 0; 02922 } else { 02923 ret = -1; 02924 } 02925 break; 02926 } 02927 02928 to = -1; 02929 if (user->timelimit) { 02930 int minutes = 0, seconds = 0, remain = 0; 02931 02932 to = ast_tvdiff_ms(nexteventts, now); 02933 if (to < 0) { 02934 to = 0; 02935 } 02936 time_left_ms = user->timelimit - ast_tvdiff_ms(now, user->start_time); 02937 if (time_left_ms < to) { 02938 to = time_left_ms; 02939 } 02940 02941 if (time_left_ms <= 0) { 02942 if (user->end_sound) { 02943 res = ast_streamfile(chan, user->end_sound, chan->language); 02944 res = ast_waitstream(chan, ""); 02945 } 02946 if (ast_test_flag64(confflags, CONFFLAG_KICK_CONTINUE)) { 02947 ret = 0; 02948 } else { 02949 ret = -1; 02950 } 02951 break; 02952 } 02953 02954 if (!to) { 02955 if (time_left_ms >= 5000) { 02956 02957 remain = (time_left_ms + 500) / 1000; 02958 if (remain / 60 >= 1) { 02959 minutes = remain / 60; 02960 seconds = remain % 60; 02961 } else { 02962 seconds = remain; 02963 } 02964 02965 /* force the time left to round up if appropriate */ 02966 if (user->warning_sound && user->play_warning) { 02967 if (!strcmp(user->warning_sound, "timeleft")) { 02968 02969 res = ast_streamfile(chan, "vm-youhave", chan->language); 02970 res = ast_waitstream(chan, ""); 02971 if (minutes) { 02972 res = ast_say_number(chan, minutes, AST_DIGIT_ANY, chan->language, (char *) NULL); 02973 res = ast_streamfile(chan, "queue-minutes", chan->language); 02974 res = ast_waitstream(chan, ""); 02975 } 02976 if (seconds) { 02977 res = ast_say_number(chan, seconds, AST_DIGIT_ANY, chan->language, (char *) NULL); 02978 res = ast_streamfile(chan, "queue-seconds", chan->language); 02979 res = ast_waitstream(chan, ""); 02980 } 02981 } else { 02982 res = ast_streamfile(chan, user->warning_sound, chan->language); 02983 res = ast_waitstream(chan, ""); 02984 } 02985 if (musiconhold) { 02986 conf_start_moh(chan, optargs[OPT_ARG_MOH_CLASS]); 02987 } 02988 } 02989 } 02990 if (user->warning_freq) { 02991 nexteventts = ast_tvadd(nexteventts, ast_samp2tv(user->warning_freq, 1000)); 02992 } else { 02993 nexteventts = ast_tvadd(user->start_time, ast_samp2tv(user->timelimit, 1000)); 02994 } 02995 } 02996 } 02997 02998 now = ast_tvnow(); 02999 if (timeout && now.tv_sec >= timeout) { 03000 if (ast_test_flag64(confflags, CONFFLAG_KICK_CONTINUE)) { 03001 ret = 0; 03002 } else { 03003 ret = -1; 03004 } 03005 break; 03006 } 03007 03008 /* if we have just exited from the menu, and the user had a channel-driver 03009 volume adjustment, restore it 03010 */ 03011 if (!menu_active && menu_was_active && user->listen.desired && !user->listen.actual) { 03012 set_talk_volume(user, user->listen.desired); 03013 } 03014 03015 menu_was_active = menu_active; 03016 03017 currentmarked = conf->markedusers; 03018 if (!ast_test_flag64(confflags, CONFFLAG_QUIET) && 03019 ast_test_flag64(confflags, CONFFLAG_MARKEDUSER) && 03020 ast_test_flag64(confflags, CONFFLAG_WAITMARKED) && 03021 lastmarked == 0) { 03022 if (currentmarked == 1 && conf->users > 1) { 03023 ast_say_number(chan, conf->users - 1, AST_DIGIT_ANY, chan->language, (char *) NULL); 03024 if (conf->users - 1 == 1) { 03025 if (!ast_streamfile(chan, "conf-userwilljoin", chan->language)) { 03026 ast_waitstream(chan, ""); 03027 } 03028 } else { 03029 if (!ast_streamfile(chan, "conf-userswilljoin", chan->language)) { 03030 ast_waitstream(chan, ""); 03031 } 03032 } 03033 } 03034 if (conf->users == 1 && !ast_test_flag64(confflags, CONFFLAG_MARKEDUSER)) { 03035 if (!ast_streamfile(chan, "conf-onlyperson", chan->language)) { 03036 ast_waitstream(chan, ""); 03037 } 03038 } 03039 } 03040 03041 /* Update the struct with the actual confflags */ 03042 user->userflags = *confflags; 03043 03044 if (ast_test_flag64(confflags, CONFFLAG_WAITMARKED)) { 03045 if (currentmarked == 0) { 03046 if (lastmarked != 0) { 03047 if (!ast_test_flag64(confflags, CONFFLAG_QUIET)) { 03048 if (!ast_streamfile(chan, "conf-leaderhasleft", chan->language)) { 03049 ast_waitstream(chan, ""); 03050 } 03051 } 03052 if (ast_test_flag64(confflags, CONFFLAG_MARKEDEXIT)) { 03053 if (ast_test_flag64(confflags, CONFFLAG_KICK_CONTINUE)) { 03054 ret = 0; 03055 } 03056 break; 03057 } else { 03058 dahdic.confmode = DAHDI_CONF_CONF; 03059 if (ioctl(fd, DAHDI_SETCONF, &dahdic)) { 03060 ast_log(LOG_WARNING, "Error setting conference\n"); 03061 close(fd); 03062 goto outrun; 03063 } 03064 } 03065 } 03066 if (!musiconhold && (ast_test_flag64(confflags, CONFFLAG_MOH))) { 03067 conf_start_moh(chan, optargs[OPT_ARG_MOH_CLASS]); 03068 musiconhold = 1; 03069 } 03070 } else if (currentmarked >= 1 && lastmarked == 0) { 03071 /* Marked user entered, so cancel timeout */ 03072 timeout = 0; 03073 if (ast_test_flag64(confflags, CONFFLAG_MONITOR)) { 03074 dahdic.confmode = DAHDI_CONF_CONFMON | DAHDI_CONF_LISTENER; 03075 } else if (ast_test_flag64(confflags, CONFFLAG_TALKER)) { 03076 dahdic.confmode = DAHDI_CONF_CONF | DAHDI_CONF_TALKER; 03077 } else { 03078 dahdic.confmode = DAHDI_CONF_CONF | DAHDI_CONF_TALKER | DAHDI_CONF_LISTENER; 03079 } 03080 if (ioctl(fd, DAHDI_SETCONF, &dahdic)) { 03081 ast_log(LOG_WARNING, "Error setting conference\n"); 03082 close(fd); 03083 goto outrun; 03084 } 03085 if (musiconhold && (ast_test_flag64(confflags, CONFFLAG_MOH))) { 03086 ast_moh_stop(chan); 03087 musiconhold = 0; 03088 } 03089 if (!ast_test_flag64(confflags, CONFFLAG_QUIET) && 03090 !ast_test_flag64(confflags, CONFFLAG_MARKEDUSER)) { 03091 if (!ast_streamfile(chan, "conf-placeintoconf", chan->language)) { 03092 ast_waitstream(chan, ""); 03093 } 03094 conf_play(chan, conf, ENTER); 03095 } 03096 } 03097 } 03098 03099 /* trying to add moh for single person conf */ 03100 if (ast_test_flag64(confflags, CONFFLAG_MOH) && !ast_test_flag64(confflags, CONFFLAG_WAITMARKED)) { 03101 if (conf->users == 1) { 03102 if (!musiconhold) { 03103 conf_start_moh(chan, optargs[OPT_ARG_MOH_CLASS]); 03104 musiconhold = 1; 03105 } 03106 } else { 03107 if (musiconhold) { 03108 ast_moh_stop(chan); 03109 musiconhold = 0; 03110 } 03111 } 03112 } 03113 03114 /* Leave if the last marked user left */ 03115 if (currentmarked == 0 && lastmarked != 0 && ast_test_flag64(confflags, CONFFLAG_MARKEDEXIT)) { 03116 if (ast_test_flag64(confflags, CONFFLAG_KICK_CONTINUE)) { 03117 ret = 0; 03118 } else { 03119 ret = -1; 03120 } 03121 break; 03122 } 03123 03124 /* Throw a TestEvent if a user exit did not cause this user to leave the conference */ 03125 if (conf->users != lastusers) { 03126 if (conf->users < lastusers) { 03127 ast_test_suite_event_notify("NOEXIT", "Message: CONFFLAG_MARKEDEXIT\r\nLastUsers: %d\r\nUsers: %d", lastusers, conf->users); 03128 } 03129 lastusers = conf->users; 03130 } 03131 03132 /* Check if my modes have changed */ 03133 03134 /* If I should be muted but am still talker, mute me */ 03135 if ((user->adminflags & (ADMINFLAG_MUTED | ADMINFLAG_SELFMUTED)) && (dahdic.confmode & DAHDI_CONF_TALKER)) { 03136 dahdic.confmode ^= DAHDI_CONF_TALKER; 03137 if (ioctl(fd, DAHDI_SETCONF, &dahdic)) { 03138 ast_log(LOG_WARNING, "Error setting conference - Un/Mute \n"); 03139 ret = -1; 03140 break; 03141 } 03142 03143 /* Indicate user is not talking anymore - change him to unmonitored state */ 03144 if (ast_test_flag64(confflags, (CONFFLAG_MONITORTALKER | CONFFLAG_OPTIMIZETALKER))) { 03145 set_user_talking(chan, conf, user, -1, ast_test_flag64(confflags, CONFFLAG_MONITORTALKER)); 03146 } 03147 03148 ast_manager_event(chan, EVENT_FLAG_CALL, "MeetmeMute", 03149 "Channel: %s\r\n" 03150 "Uniqueid: %s\r\n" 03151 "Meetme: %s\r\n" 03152 "Usernum: %d\r\n" 03153 "Status: on\r\n", 03154 chan->name, chan->uniqueid, conf->confno, user->user_no); 03155 } 03156 03157 /* If I should be un-muted but am not talker, un-mute me */ 03158 if (!(user->adminflags & (ADMINFLAG_MUTED | ADMINFLAG_SELFMUTED)) && !ast_test_flag64(confflags, CONFFLAG_MONITOR) && !(dahdic.confmode & DAHDI_CONF_TALKER)) { 03159 dahdic.confmode |= DAHDI_CONF_TALKER; 03160 if (ioctl(fd, DAHDI_SETCONF, &dahdic)) { 03161 ast_log(LOG_WARNING, "Error setting conference - Un/Mute \n"); 03162 ret = -1; 03163 break; 03164 } 03165 03166 ast_manager_event(chan, EVENT_FLAG_CALL, "MeetmeMute", 03167 "Channel: %s\r\n" 03168 "Uniqueid: %s\r\n" 03169 "Meetme: %s\r\n" 03170 "Usernum: %d\r\n" 03171 "Status: off\r\n", 03172 chan->name, chan->uniqueid, conf->confno, user->user_no); 03173 } 03174 03175 if ((user->adminflags & (ADMINFLAG_MUTED | ADMINFLAG_SELFMUTED)) && 03176 (user->adminflags & ADMINFLAG_T_REQUEST) && !(talkreq_manager)) { 03177 talkreq_manager = 1; 03178 03179 ast_manager_event(chan, EVENT_FLAG_CALL, "MeetmeTalkRequest", 03180 "Channel: %s\r\n" 03181 "Uniqueid: %s\r\n" 03182 "Meetme: %s\r\n" 03183 "Usernum: %d\r\n" 03184 "Status: on\r\n", 03185 chan->name, chan->uniqueid, conf->confno, user->user_no); 03186 } 03187 03188 03189 if (!(user->adminflags & (ADMINFLAG_MUTED | ADMINFLAG_SELFMUTED)) && 03190 !(user->adminflags & ADMINFLAG_T_REQUEST) && (talkreq_manager)) { 03191 talkreq_manager = 0; 03192 ast_manager_event(chan, EVENT_FLAG_CALL, "MeetmeTalkRequest", 03193 "Channel: %s\r\n" 03194 "Uniqueid: %s\r\n" 03195 "Meetme: %s\r\n" 03196 "Usernum: %d\r\n" 03197 "Status: off\r\n", 03198 chan->name, chan->uniqueid, conf->confno, user->user_no); 03199 } 03200 03201 /* If I have been kicked, exit the conference */ 03202 if (user->adminflags & ADMINFLAG_KICKME) { 03203 /* You have been kicked. */ 03204 if (!ast_test_flag64(confflags, CONFFLAG_QUIET) && 03205 !ast_streamfile(chan, "conf-kicked", chan->language)) { 03206 ast_waitstream(chan, ""); 03207 } 03208 ret = 0; 03209 break; 03210 } 03211 03212 /* Perform a hangup check here since ast_waitfor_nandfds will not always be able to get a channel after a hangup has occurred */ 03213 if (ast_check_hangup(chan)) { 03214 break; 03215 } 03216 03217 c = ast_waitfor_nandfds(&chan, 1, &fd, nfds, NULL, &outfd, &ms); 03218 03219 if (c) { 03220 char dtmfstr[2] = ""; 03221 03222 if (c->fds[0] != origfd || (user->dahdichannel && (c->audiohooks || c->monitor))) { 03223 if (using_pseudo) { 03224 /* Kill old pseudo */ 03225 close(fd); 03226 using_pseudo = 0; 03227 } 03228 ast_debug(1, "Ooh, something swapped out under us, starting over\n"); 03229 retrydahdi = (strcasecmp(c->tech->type, "DAHDI") || (c->audiohooks || c->monitor) ? 1 : 0); 03230 user->dahdichannel = !retrydahdi; 03231 goto dahdiretry; 03232 } 03233 if (ast_test_flag64(confflags, CONFFLAG_MONITOR) || (user->adminflags & (ADMINFLAG_MUTED | ADMINFLAG_SELFMUTED))) { 03234 f = ast_read_noaudio(c); 03235 } else { 03236 f = ast_read(c); 03237 } 03238 if (!f) { 03239 break; 03240 } 03241 if (f->frametype == AST_FRAME_DTMF) { 03242 dtmfstr[0] = f->subclass.integer; 03243 dtmfstr[1] = '\0'; 03244 } 03245 03246 if ((f->frametype == AST_FRAME_VOICE) && (f->subclass.codec == AST_FORMAT_SLINEAR)) { 03247 if (user->talk.actual) { 03248 ast_frame_adjust_volume(f, user->talk.actual); 03249 } 03250 03251 if (ast_test_flag64(confflags, (CONFFLAG_OPTIMIZETALKER | CONFFLAG_MONITORTALKER))) { 03252 if (user->talking == -1) { 03253 user->talking = 0; 03254 } 03255 03256 res = ast_dsp_silence(dsp, f, &totalsilence); 03257 if (!user->talking && totalsilence < MEETME_DELAYDETECTTALK) { 03258 set_user_talking(chan, conf, user, 1, ast_test_flag64(confflags, CONFFLAG_MONITORTALKER)); 03259 } 03260 03261 if (user->talking && totalsilence > MEETME_DELAYDETECTENDTALK) { 03262 set_user_talking(chan, conf, user, 0, ast_test_flag64(confflags, CONFFLAG_MONITORTALKER)); 03263 } 03264 } 03265 if (using_pseudo) { 03266 /* Absolutely do _not_ use careful_write here... 03267 it is important that we read data from the channel 03268 as fast as it arrives, and feed it into the conference. 03269 The buffering in the pseudo channel will take care of any 03270 timing differences, unless they are so drastic as to lose 03271 audio frames (in which case carefully writing would only 03272 have delayed the audio even further). 03273 */ 03274 /* As it turns out, we do want to use careful write. We just 03275 don't want to block, but we do want to at least *try* 03276 to write out all the samples. 03277 */ 03278 if (user->talking || !ast_test_flag64(confflags, CONFFLAG_OPTIMIZETALKER)) { 03279 careful_write(fd, f->data.ptr, f->datalen, 0); 03280 } 03281 } 03282 } else if (((f->frametype == AST_FRAME_DTMF) && (f->subclass.integer == '*') && ast_test_flag64(confflags, CONFFLAG_STARMENU)) || ((f->frametype == AST_FRAME_DTMF) && menu_active)) { 03283 if (ast_test_flag64(confflags, CONFFLAG_PASS_DTMF)) { 03284 conf_queue_dtmf(conf, user, f); 03285 } 03286 if (ioctl(fd, DAHDI_SETCONF, &dahdic_empty)) { 03287 ast_log(LOG_WARNING, "Error setting conference\n"); 03288 close(fd); 03289 ast_frfree(f); 03290 goto outrun; 03291 } 03292 03293 /* if we are entering the menu, and the user has a channel-driver 03294 volume adjustment, clear it 03295 */ 03296 if (!menu_active && user->talk.desired && !user->talk.actual) { 03297 set_talk_volume(user, 0); 03298 } 03299 03300 if (musiconhold) { 03301 ast_moh_stop(chan); 03302 } 03303 if (menu8_active) { 03304 /* *8 Submenu */ 03305 dtmf = f->subclass.integer; 03306 if (dtmf > 0) { 03307 int keepplaying; 03308 int playednamerec; 03309 struct ao2_iterator user_iter; 03310 struct ast_conf_user *usr = NULL; 03311 switch(dtmf) { 03312 case '1': /* *81 Roll call */ 03313 keepplaying = 1; 03314 playednamerec = 0; 03315 if (conf->users == 1) { 03316 if (keepplaying && !ast_streamfile(chan, "conf-onlyperson", chan->language)) { 03317 res = ast_waitstream(chan, AST_DIGIT_ANY); 03318 ast_stopstream(chan); 03319 if (res > 0) 03320 keepplaying = 0; 03321 } 03322 } else if (conf->users == 2) { 03323 if (keepplaying && !ast_streamfile(chan, "conf-onlyone", chan->language)) { 03324 res = ast_waitstream(chan, AST_DIGIT_ANY); 03325 ast_stopstream(chan); 03326 if (res > 0) 03327 keepplaying = 0; 03328 } 03329 } else { 03330 if (keepplaying && !ast_streamfile(chan, "conf-thereare", chan->language)) { 03331 res = ast_waitstream(chan, AST_DIGIT_ANY); 03332 ast_stopstream(chan); 03333 if (res > 0) 03334 keepplaying = 0; 03335 } 03336 if (keepplaying) { 03337 res = ast_say_number(chan, conf->users - 1, AST_DIGIT_ANY, chan->language, (char *) NULL); 03338 if (res > 0) 03339 keepplaying = 0; 03340 } 03341 if (keepplaying && !ast_streamfile(chan, "conf-otherinparty", chan->language)) { 03342 res = ast_waitstream(chan, AST_DIGIT_ANY); 03343 ast_stopstream(chan); 03344 if (res > 0) 03345 keepplaying = 0; 03346 } 03347 } 03348 user_iter = ao2_iterator_init(conf->usercontainer, 0); 03349 while((usr = ao2_iterator_next(&user_iter))) { 03350 if (ast_fileexists(usr->namerecloc, NULL, NULL)) { 03351 if (keepplaying && !ast_streamfile(chan, usr->namerecloc, chan->language)) { 03352 res = ast_waitstream(chan, AST_DIGIT_ANY); 03353 ast_stopstream(chan); 03354 if (res > 0) 03355 keepplaying = 0; 03356 } 03357 playednamerec = 1; 03358 } 03359 ao2_ref(usr, -1); 03360 } 03361 ao2_iterator_destroy(&user_iter); 03362 if (keepplaying && playednamerec && !ast_streamfile(chan, "conf-roll-callcomplete", chan->language)) { 03363 res = ast_waitstream(chan, AST_DIGIT_ANY); 03364 ast_stopstream(chan); 03365 if (res > 0) 03366 keepplaying = 0; 03367 } 03368 break; 03369 case '2': /* *82 Eject all non-admins */ 03370 if (conf->users == 1) { 03371 if(!ast_streamfile(chan, "conf-errormenu", chan->language)) 03372 ast_waitstream(chan, ""); 03373 } else { 03374 ao2_callback(conf->usercontainer, OBJ_NODATA, user_set_kickme_cb, &conf); 03375 } 03376 ast_stopstream(chan); 03377 break; 03378 case '3': /* *83 (Admin) mute/unmute all non-admins */ 03379 if(conf->gmuted) { 03380 conf->gmuted = 0; 03381 ao2_callback(conf->usercontainer, OBJ_NODATA, user_set_unmuted_cb, &conf); 03382 if (!ast_streamfile(chan, "conf-now-unmuted", chan->language)) 03383 ast_waitstream(chan, ""); 03384 } else { 03385 conf->gmuted = 1; 03386 ao2_callback(conf->usercontainer, OBJ_NODATA, user_set_muted_cb, &conf); 03387 if (!ast_streamfile(chan, "conf-now-muted", chan->language)) 03388 ast_waitstream(chan, ""); 03389 } 03390 ast_stopstream(chan); 03391 break; 03392 case '4': /* *84 Record conference */ 03393 if (conf->recording != MEETME_RECORD_ACTIVE) { 03394 ast_set_flag64(confflags, CONFFLAG_RECORDCONF); 03395 03396 if (!conf->recordingfilename) { 03397 const char *var; 03398 ast_channel_lock(chan); 03399 if ((var = pbx_builtin_getvar_helper(chan, "MEETME_RECORDINGFILE"))) { 03400 conf->recordingfilename = ast_strdup(var); 03401 } 03402 if ((var = pbx_builtin_getvar_helper(chan, "MEETME_RECORDINGFORMAT"))) { 03403 conf->recordingformat = ast_strdup(var); 03404 } 03405 ast_channel_unlock(chan); 03406 if (!conf->recordingfilename) { 03407 snprintf(recordingtmp, sizeof(recordingtmp), "meetme-conf-rec-%s-%s", conf->confno, chan->uniqueid); 03408 conf->recordingfilename = ast_strdup(recordingtmp); 03409 } 03410 if (!conf->recordingformat) { 03411 conf->recordingformat = ast_strdup("wav"); 03412 } 03413 ast_verb(4, "Starting recording of MeetMe Conference %s into file %s.%s.\n", 03414 conf->confno, conf->recordingfilename, conf->recordingformat); 03415 } 03416 03417 ast_mutex_lock(&conf->recordthreadlock); 03418 if ((conf->recordthread == AST_PTHREADT_NULL) && ast_test_flag64(confflags, CONFFLAG_RECORDCONF) && ((conf->lchan = ast_request("DAHDI", AST_FORMAT_SLINEAR, chan, "pseudo", NULL)))) { 03419 ast_set_read_format(conf->lchan, AST_FORMAT_SLINEAR); 03420 ast_set_write_format(conf->lchan, AST_FORMAT_SLINEAR); 03421 dahdic.chan = 0; 03422 dahdic.confno = conf->dahdiconf; 03423 dahdic.confmode = DAHDI_CONF_CONFANN | DAHDI_CONF_CONFANNMON; 03424 if (ioctl(conf->lchan->fds[0], DAHDI_SETCONF, &dahdic)) { 03425 ast_log(LOG_WARNING, "Error starting listen channel\n"); 03426 ast_hangup(conf->lchan); 03427 conf->lchan = NULL; 03428 } else { 03429 ast_pthread_create_detached_background(&conf->recordthread, NULL, recordthread, conf); 03430 } 03431 } 03432 ast_mutex_unlock(&conf->recordthreadlock); 03433 03434 if (!ast_streamfile(chan, "conf-now-recording", chan->language)) 03435 ast_waitstream(chan, ""); 03436 03437 } 03438 03439 ast_stopstream(chan); 03440 break; 03441 default: 03442 if (!ast_streamfile(chan, "conf-errormenu", chan->language)) 03443 ast_waitstream(chan, ""); 03444 ast_stopstream(chan); 03445 break; 03446 } 03447 } 03448 03449 menu8_active = 0; 03450 menu_active = 0; 03451 } else if (ast_test_flag64(confflags, CONFFLAG_ADMIN)) { 03452 /* Admin menu */ 03453 if (!menu_active) { 03454 menu_active = 1; 03455 /* Record this sound! */ 03456 if (!ast_streamfile(chan, "conf-adminmenu-162", chan->language)) { 03457 dtmf = ast_waitstream(chan, AST_DIGIT_ANY); 03458 ast_stopstream(chan); 03459 } else { 03460 dtmf = 0; 03461 } 03462 } else { 03463 dtmf = f->subclass.integer; 03464 } 03465 if (dtmf > 0) { 03466 switch(dtmf) { 03467 case '1': /* Un/Mute */ 03468 menu_active = 0; 03469 03470 /* for admin, change both admin and use flags */ 03471 if (user->adminflags & (ADMINFLAG_MUTED | ADMINFLAG_SELFMUTED)) { 03472 user->adminflags &= ~(ADMINFLAG_MUTED | ADMINFLAG_SELFMUTED); 03473 } else { 03474 user->adminflags |= (ADMINFLAG_MUTED | ADMINFLAG_SELFMUTED); 03475 } 03476 03477 if (ast_test_flag64(confflags, CONFFLAG_MONITOR) || (user->adminflags & (ADMINFLAG_MUTED | ADMINFLAG_SELFMUTED))) { 03478 if (!ast_streamfile(chan, "conf-muted", chan->language)) { 03479 ast_waitstream(chan, ""); 03480 } 03481 } else { 03482 if (!ast_streamfile(chan, "conf-unmuted", chan->language)) { 03483 ast_waitstream(chan, ""); 03484 } 03485 } 03486 break; 03487 case '2': /* Un/Lock the Conference */ 03488 menu_active = 0; 03489 if (conf->locked) { 03490 conf->locked = 0; 03491 if (!ast_streamfile(chan, "conf-unlockednow", chan->language)) { 03492 ast_waitstream(chan, ""); 03493 } 03494 } else { 03495 conf->locked = 1; 03496 if (!ast_streamfile(chan, "conf-lockednow", chan->language)) { 03497 ast_waitstream(chan, ""); 03498 } 03499 } 03500 break; 03501 case '3': /* Eject last user */ 03502 { 03503 struct ast_conf_user *usr = NULL; 03504 int max_no = 0; 03505 ao2_callback(conf->usercontainer, OBJ_NODATA, user_max_cmp, &max_no); 03506 menu_active = 0; 03507 usr = ao2_find(conf->usercontainer, &max_no, 0); 03508 if ((usr->chan->name == chan->name) || ast_test_flag64(&usr->userflags, CONFFLAG_ADMIN)) { 03509 if (!ast_streamfile(chan, "conf-errormenu", chan->language)) { 03510 ast_waitstream(chan, ""); 03511 } 03512 } else { 03513 usr->adminflags |= ADMINFLAG_KICKME; 03514 } 03515 ao2_ref(usr, -1); 03516 ast_stopstream(chan); 03517 break; 03518 } 03519 case '4': 03520 tweak_listen_volume(user, VOL_DOWN); 03521 break; 03522 case '5': 03523 /* Extend RT conference */ 03524 if (rt_schedule) { 03525 if (!rt_extend_conf(conf->confno)) { 03526 if (!ast_streamfile(chan, "conf-extended", chan->language)) { 03527 ast_waitstream(chan, ""); 03528 } 03529 } else { 03530 if (!ast_streamfile(chan, "conf-nonextended", chan->language)) { 03531 ast_waitstream(chan, ""); 03532 } 03533 } 03534 ast_stopstream(chan); 03535 } 03536 menu_active = 0; 03537 break; 03538 case '6': 03539 tweak_listen_volume(user, VOL_UP); 03540 break; 03541 case '7': 03542 tweak_talk_volume(user, VOL_DOWN); 03543 break; 03544 case '8': 03545 menu8_active = 1; 03546 break; 03547 case '9': 03548 tweak_talk_volume(user, VOL_UP); 03549 break; 03550 default: 03551 menu_active = 0; 03552 /* Play an error message! */ 03553 if (!ast_streamfile(chan, "conf-errormenu", chan->language)) { 03554 ast_waitstream(chan, ""); 03555 } 03556 break; 03557 } 03558 } 03559 } else { 03560 /* User menu */ 03561 if (!menu_active) { 03562 menu_active = 1; 03563 if (!ast_streamfile(chan, "conf-usermenu-162", chan->language)) { 03564 dtmf = ast_waitstream(chan, AST_DIGIT_ANY); 03565 ast_stopstream(chan); 03566 } else { 03567 dtmf = 0; 03568 } 03569 } else { 03570 dtmf = f->subclass.integer; 03571 } 03572 if (dtmf > 0) { 03573 switch (dtmf) { 03574 case '1': /* Un/Mute */ 03575 menu_active = 0; 03576 03577 /* user can only toggle the self-muted state */ 03578 user->adminflags ^= ADMINFLAG_SELFMUTED; 03579 03580 /* they can't override the admin mute state */ 03581 if (ast_test_flag64(confflags, CONFFLAG_MONITOR) || (user->adminflags & (ADMINFLAG_MUTED | ADMINFLAG_SELFMUTED))) { 03582 if (!ast_streamfile(chan, "conf-muted", chan->language)) { 03583 ast_waitstream(chan, ""); 03584 } 03585 } else { 03586 if (!ast_streamfile(chan, "conf-unmuted", chan->language)) { 03587 ast_waitstream(chan, ""); 03588 } 03589 } 03590 break; 03591 case '2': 03592 menu_active = 0; 03593 if (user->adminflags & (ADMINFLAG_MUTED | ADMINFLAG_SELFMUTED)) { 03594 user->adminflags |= ADMINFLAG_T_REQUEST; 03595 } 03596 03597 if (user->adminflags & ADMINFLAG_T_REQUEST) { 03598 if (!ast_streamfile(chan, "beep", chan->language)) { 03599 ast_waitstream(chan, ""); 03600 } 03601 } 03602 break; 03603 case '4': 03604 tweak_listen_volume(user, VOL_DOWN); 03605 break; 03606 case '5': 03607 /* Extend RT conference */ 03608 if (rt_schedule) { 03609 rt_extend_conf(conf->confno); 03610 } 03611 menu_active = 0; 03612 break; 03613 case '6': 03614 tweak_listen_volume(user, VOL_UP); 03615 break; 03616 case '7': 03617 tweak_talk_volume(user, VOL_DOWN); 03618 break; 03619 case '8': 03620 menu_active = 0; 03621 break; 03622 case '9': 03623 tweak_talk_volume(user, VOL_UP); 03624 break; 03625 default: 03626 menu_active = 0; 03627 if (!ast_streamfile(chan, "conf-errormenu", chan->language)) { 03628 ast_waitstream(chan, ""); 03629 } 03630 break; 03631 } 03632 } 03633 } 03634 if (musiconhold && !menu_active) { 03635 conf_start_moh(chan, optargs[OPT_ARG_MOH_CLASS]); 03636 } 03637 03638 if (ioctl(fd, DAHDI_SETCONF, &dahdic)) { 03639 ast_log(LOG_WARNING, "Error setting conference\n"); 03640 close(fd); 03641 ast_frfree(f); 03642 goto outrun; 03643 } 03644 03645 conf_flush(fd, chan); 03646 /* 03647 * Since options using DTMF could absorb DTMF meant for the 03648 * conference menu, we have to check them after the menu. 03649 */ 03650 } else if ((f->frametype == AST_FRAME_DTMF) && ast_test_flag64(confflags, CONFFLAG_EXIT_CONTEXT) && ast_exists_extension(chan, exitcontext, dtmfstr, 1, "")) { 03651 if (ast_test_flag64(confflags, CONFFLAG_PASS_DTMF)) { 03652 conf_queue_dtmf(conf, user, f); 03653 } 03654 03655 if (!ast_goto_if_exists(chan, exitcontext, dtmfstr, 1)) { 03656 ast_debug(1, "Got DTMF %c, goto context %s\n", dtmfstr[0], exitcontext); 03657 ret = 0; 03658 ast_frfree(f); 03659 break; 03660 } else { 03661 ast_debug(2, "Exit by single digit did not work in meetme. Extension %s does not exist in context %s\n", dtmfstr, exitcontext); 03662 } 03663 } else if ((f->frametype == AST_FRAME_DTMF) && ast_test_flag64(confflags, CONFFLAG_KEYEXIT) && 03664 (strchr(exitkeys, f->subclass.integer))) { 03665 pbx_builtin_setvar_helper(chan, "MEETME_EXIT_KEY", dtmfstr); 03666 03667 if (ast_test_flag64(confflags, CONFFLAG_PASS_DTMF)) { 03668 conf_queue_dtmf(conf, user, f); 03669 } 03670 ret = 0; 03671 ast_frfree(f); 03672 break; 03673 } else if ((f->frametype == AST_FRAME_DTMF_BEGIN || f->frametype == AST_FRAME_DTMF_END) 03674 && ast_test_flag64(confflags, CONFFLAG_PASS_DTMF)) { 03675 conf_queue_dtmf(conf, user, f); 03676 } else if (ast_test_flag64(confflags, CONFFLAG_SLA_STATION) && f->frametype == AST_FRAME_CONTROL) { 03677 switch (f->subclass.integer) { 03678 case AST_CONTROL_HOLD: 03679 sla_queue_event_conf(SLA_EVENT_HOLD, chan, conf); 03680 break; 03681 default: 03682 break; 03683 } 03684 } else if (f->frametype == AST_FRAME_NULL) { 03685 /* Ignore NULL frames. It is perfectly normal to get these if the person is muted. */ 03686 } else if (f->frametype == AST_FRAME_CONTROL) { 03687 switch (f->subclass.integer) { 03688 case AST_CONTROL_BUSY: 03689 case AST_CONTROL_CONGESTION: 03690 ast_frfree(f); 03691 goto outrun; 03692 break; 03693 default: 03694 ast_debug(1, 03695 "Got ignored control frame on channel %s, f->frametype=%d,f->subclass=%d\n", 03696 chan->name, f->frametype, f->subclass.integer); 03697 } 03698 } else { 03699 ast_debug(1, 03700 "Got unrecognized frame on channel %s, f->frametype=%d,f->subclass=%d\n", 03701 chan->name, f->frametype, f->subclass.integer); 03702 } 03703 ast_frfree(f); 03704 } else if (outfd > -1) { 03705 res = read(outfd, buf, CONF_SIZE); 03706 if (res > 0) { 03707 memset(&fr, 0, sizeof(fr)); 03708 fr.frametype = AST_FRAME_VOICE; 03709 fr.subclass.codec = AST_FORMAT_SLINEAR; 03710 fr.datalen = res; 03711 fr.samples = res / 2; 03712 fr.data.ptr = buf; 03713 fr.offset = AST_FRIENDLY_OFFSET; 03714 if (!user->listen.actual && 03715 (ast_test_flag64(confflags, CONFFLAG_MONITOR) || 03716 (user->adminflags & (ADMINFLAG_MUTED | ADMINFLAG_SELFMUTED)) || 03717 (!user->talking && ast_test_flag64(confflags, CONFFLAG_OPTIMIZETALKER)) 03718 )) { 03719 int idx; 03720 for (idx = 0; idx < AST_FRAME_BITS; idx++) { 03721 if (chan->rawwriteformat & (1 << idx)) { 03722 break; 03723 } 03724 } 03725 if (idx >= AST_FRAME_BITS) { 03726 goto bailoutandtrynormal; 03727 } 03728 ast_mutex_lock(&conf->listenlock); 03729 if (!conf->transframe[idx]) { 03730 if (conf->origframe) { 03731 if (musiconhold && !ast_dsp_silence(dsp, conf->origframe, &confsilence) && confsilence < MEETME_DELAYDETECTTALK) { 03732 ast_moh_stop(chan); 03733 mohtempstopped = 1; 03734 } 03735 if (!conf->transpath[idx]) { 03736 conf->transpath[idx] = ast_translator_build_path((1 << idx), AST_FORMAT_SLINEAR); 03737 } 03738 if (conf->transpath[idx]) { 03739 conf->transframe[idx] = ast_translate(conf->transpath[idx], conf->origframe, 0); 03740 if (!conf->transframe[idx]) { 03741 conf->transframe[idx] = &ast_null_frame; 03742 } 03743 } 03744 } 03745 } 03746 if (conf->transframe[idx]) { 03747 if ((conf->transframe[idx]->frametype != AST_FRAME_NULL) && 03748 can_write(chan, confflags)) { 03749 struct ast_frame *cur; 03750 /* the translator may have returned a list of frames, so 03751 write each one onto the channel 03752 */ 03753 for (cur = conf->transframe[idx]; cur; cur = AST_LIST_NEXT(cur, frame_list)) { 03754 if (ast_write(chan, cur)) { 03755 ast_log(LOG_WARNING, "Unable to write frame to channel %s\n", chan->name); 03756 break; 03757 } 03758 } 03759 if (musiconhold && mohtempstopped && confsilence > MEETME_DELAYDETECTENDTALK) { 03760 mohtempstopped = 0; 03761 conf_start_moh(chan, optargs[OPT_ARG_MOH_CLASS]); 03762 } 03763 } 03764 } else { 03765 ast_mutex_unlock(&conf->listenlock); 03766 goto bailoutandtrynormal; 03767 } 03768 ast_mutex_unlock(&conf->listenlock); 03769 } else { 03770 bailoutandtrynormal: 03771 if (musiconhold && !ast_dsp_silence(dsp, &fr, &confsilence) && confsilence < MEETME_DELAYDETECTTALK) { 03772 ast_moh_stop(chan); 03773 mohtempstopped = 1; 03774 } 03775 if (user->listen.actual) { 03776 ast_frame_adjust_volume(&fr, user->listen.actual); 03777 } 03778 if (can_write(chan, confflags) && ast_write(chan, &fr) < 0) { 03779 ast_log(LOG_WARNING, "Unable to write frame to channel %s\n", chan->name); 03780 } 03781 if (musiconhold && mohtempstopped && confsilence > MEETME_DELAYDETECTENDTALK) { 03782 mohtempstopped = 0; 03783 conf_start_moh(chan, optargs[OPT_ARG_MOH_CLASS]); 03784 } 03785 } 03786 } else { 03787 ast_log(LOG_WARNING, "Failed to read frame: %s\n", strerror(errno)); 03788 } 03789 } 03790 lastmarked = currentmarked; 03791 } 03792 } 03793 03794 if (musiconhold) { 03795 ast_moh_stop(chan); 03796 } 03797 03798 if (using_pseudo) { 03799 close(fd); 03800 } else { 03801 /* Take out of conference */ 03802 dahdic.chan = 0; 03803 dahdic.confno = 0; 03804 dahdic.confmode = 0; 03805 if (ioctl(fd, DAHDI_SETCONF, &dahdic)) { 03806 ast_log(LOG_WARNING, "Error setting conference\n"); 03807 } 03808 } 03809 03810 reset_volumes(user); 03811 03812 if (!ast_test_flag64(confflags, CONFFLAG_QUIET) && !ast_test_flag64(confflags, CONFFLAG_MONITOR) && 03813 !ast_test_flag64(confflags, CONFFLAG_ADMIN)) { 03814 conf_play(chan, conf, LEAVE); 03815 } 03816 03817 if (!ast_test_flag64(confflags, CONFFLAG_QUIET) && (ast_test_flag64(confflags, CONFFLAG_INTROUSER) || ast_test_flag64(confflags, CONFFLAG_INTROUSERNOREVIEW)) && conf->users > 1) { 03818 struct announce_listitem *item; 03819 if (!(item = ao2_alloc(sizeof(*item), NULL))) 03820 goto outrun; 03821 ast_copy_string(item->namerecloc, user->namerecloc, sizeof(item->namerecloc)); 03822 ast_copy_string(item->language, chan->language, sizeof(item->language)); 03823 item->confchan = conf->chan; 03824 item->confusers = conf->users; 03825 item->announcetype = CONF_HASLEFT; 03826 ast_mutex_lock(&conf->announcelistlock); 03827 AST_LIST_INSERT_TAIL(&conf->announcelist, item, entry); 03828 ast_cond_signal(&conf->announcelist_addition); 03829 ast_mutex_unlock(&conf->announcelistlock); 03830 } else if (!ast_test_flag64(confflags, CONFFLAG_QUIET) && (ast_test_flag64(confflags, CONFFLAG_INTROUSER) || 03831 ast_test_flag64(confflags, CONFFLAG_INTROUSERNOREVIEW)) && conf->users == 1) { 03832 /* Last person is leaving, so no reason to try and announce, but should delete the name recording */ 03833 ast_filedelete(user->namerecloc, NULL); 03834 } 03835 03836 outrun: 03837 AST_LIST_LOCK(&confs); 03838 03839 if (dsp) { 03840 ast_dsp_free(dsp); 03841 } 03842 03843 if (user->user_no) { 03844 /* Only cleanup users who really joined! */ 03845 now = ast_tvnow(); 03846 03847 if (sent_event) { 03848 ast_manager_event(chan, EVENT_FLAG_CALL, "MeetmeLeave", 03849 "Channel: %s\r\n" 03850 "Uniqueid: %s\r\n" 03851 "Meetme: %s\r\n" 03852 "Usernum: %d\r\n" 03853 "CallerIDNum: %s\r\n" 03854 "CallerIDName: %s\r\n" 03855 "ConnectedLineNum: %s\r\n" 03856 "ConnectedLineName: %s\r\n" 03857 "Duration: %ld\r\n", 03858 chan->name, chan->uniqueid, conf->confno, 03859 user->user_no, 03860 S_COR(user->chan->caller.id.number.valid, user->chan->caller.id.number.str, "<unknown>"), 03861 S_COR(user->chan->caller.id.name.valid, user->chan->caller.id.name.str, "<unknown>"), 03862 S_COR(user->chan->connected.id.number.valid, user->chan->connected.id.number.str, "<unknown>"), 03863 S_COR(user->chan->connected.id.name.valid, user->chan->connected.id.name.str, "<unknown>"), 03864 (long)(now.tv_sec - user->jointime)); 03865 } 03866 03867 if (setusercount) { 03868 conf->users--; 03869 if (rt_log_members) { 03870 /* Update table */ 03871 snprintf(members, sizeof(members), "%d", conf->users); 03872 ast_realtime_require_field("meetme", 03873 "confno", strlen(conf->confno) > 7 ? RQ_UINTEGER4 : strlen(conf->confno) > 4 ? RQ_UINTEGER3 : RQ_UINTEGER2, strlen(conf->confno), 03874 "members", RQ_UINTEGER1, strlen(members), 03875 NULL); 03876 ast_update_realtime("meetme", "confno", conf->confno, "members", members, NULL); 03877 } 03878 if (ast_test_flag64(confflags, CONFFLAG_MARKEDUSER)) { 03879 conf->markedusers--; 03880 } 03881 } 03882 /* Remove ourselves from the container */ 03883 ao2_unlink(conf->usercontainer, user); 03884 03885 /* Change any states */ 03886 if (!conf->users) { 03887 ast_devstate_changed(AST_DEVICE_NOT_INUSE, (conf->isdynamic ? AST_DEVSTATE_NOT_CACHABLE : AST_DEVSTATE_CACHABLE), "meetme:%s", conf->confno); 03888 } 03889 03890 /* Return the number of seconds the user was in the conf */ 03891 snprintf(meetmesecs, sizeof(meetmesecs), "%d", (int) (time(NULL) - user->jointime)); 03892 pbx_builtin_setvar_helper(chan, "MEETMESECS", meetmesecs); 03893 03894 /* Return the RealTime bookid for CDR linking */ 03895 if (rt_schedule) { 03896 pbx_builtin_setvar_helper(chan, "MEETMEBOOKID", conf->bookid); 03897 } 03898 } 03899 ao2_ref(user, -1); 03900 AST_LIST_UNLOCK(&confs); 03901 03902 return ret; 03903 }
| static void conf_start_moh | ( | struct ast_channel * | chan, | |
| const char * | musicclass | |||
| ) | [static] |
Definition at line 2130 of file app_meetme.c.
References ast_channel_lock, ast_channel_unlock, ast_moh_start(), ast_strdupa, and ast_string_field_set.
Referenced by conf_run().
02131 { 02132 char *original_moh; 02133 02134 ast_channel_lock(chan); 02135 original_moh = ast_strdupa(chan->musicclass); 02136 ast_string_field_set(chan, musicclass, musicclass); 02137 ast_channel_unlock(chan); 02138 02139 ast_moh_start(chan, original_moh, NULL); 02140 02141 ast_channel_lock(chan); 02142 ast_string_field_set(chan, musicclass, original_moh); 02143 ast_channel_unlock(chan); 02144 }
| static int count_exec | ( | struct ast_channel * | chan, | |
| const char * | data | |||
| ) | [static] |
The MeetmeCount application.
Definition at line 4197 of file app_meetme.c.
References ast_channel::_state, args, ast_answer(), AST_APP_ARG, AST_DECLARE_APP_ARGS, ast_log(), ast_say_number(), AST_STANDARD_APP_ARGS, AST_STATE_UP, ast_strdupa, ast_strlen_zero(), ast_conference::confno, dispose_conf(), find_conf(), LOG_WARNING, pbx_builtin_setvar_helper(), and ast_conference::users.
Referenced by load_module().
04198 { 04199 int res = 0; 04200 struct ast_conference *conf; 04201 int count; 04202 char *localdata; 04203 char val[80] = "0"; 04204 AST_DECLARE_APP_ARGS(args, 04205 AST_APP_ARG(confno); 04206 AST_APP_ARG(varname); 04207 ); 04208 04209 if (ast_strlen_zero(data)) { 04210 ast_log(LOG_WARNING, "MeetMeCount requires an argument (conference number)\n"); 04211 return -1; 04212 } 04213 04214 localdata = ast_strdupa(data); 04215 04216 AST_STANDARD_APP_ARGS(args, localdata); 04217 04218 conf = find_conf(chan, args.confno, 0, 0, NULL, 0, 1, NULL); 04219 04220 if (conf) { 04221 count = conf->users; 04222 dispose_conf(conf); 04223 conf = NULL; 04224 } else 04225 count = 0; 04226 04227 if (!ast_strlen_zero(args.varname)) { 04228 /* have var so load it and exit */ 04229 snprintf(val, sizeof(val), "%d", count); 04230 pbx_builtin_setvar_helper(chan, args.varname, val); 04231 } else { 04232 if (chan->_state != AST_STATE_UP) { 04233 ast_answer(chan); 04234 } 04235 res = ast_say_number(chan, count, "", chan->language, (char *) NULL); /* Needs gender */ 04236 } 04237 04238 return res; 04239 }
| static struct sla_trunk_ref* create_trunk_ref | ( | struct sla_trunk * | trunk | ) | [static, read] |
Definition at line 6414 of file app_meetme.c.
References ast_calloc.
Referenced by sla_add_trunk_to_station().
06415 { 06416 struct sla_trunk_ref *trunk_ref; 06417 06418 if (!(trunk_ref = ast_calloc(1, sizeof(*trunk_ref)))) 06419 return NULL; 06420 06421 trunk_ref->trunk = trunk; 06422 06423 return trunk_ref; 06424 }
| static void destroy_station | ( | struct sla_station * | station | ) | [static] |
Definition at line 6622 of file app_meetme.c.
References ast_context_remove_extension(), ast_free, AST_LIST_REMOVE_HEAD, AST_LIST_TRAVERSE, AST_MAX_APP, AST_MAX_EXTENSION, AST_RWLIST_RDLOCK, AST_RWLIST_UNLOCK, ast_string_field_free_memory, ast_strlen_zero(), exten, PRIORITY_HINT, and sla_registrar.
Referenced by sla_build_station(), and sla_destroy().
06623 { 06624 struct sla_trunk_ref *trunk_ref; 06625 06626 if (!ast_strlen_zero(station->autocontext)) { 06627 AST_RWLIST_RDLOCK(&sla_trunks); 06628 AST_LIST_TRAVERSE(&station->trunks, trunk_ref, entry) { 06629 char exten[AST_MAX_EXTENSION]; 06630 char hint[AST_MAX_APP]; 06631 snprintf(exten, sizeof(exten), "%s_%s", station->name, trunk_ref->trunk->name); 06632 snprintf(hint, sizeof(hint), "SLA:%s", exten); 06633 ast_context_remove_extension(station->autocontext, exten, 06634 1, sla_registrar); 06635 ast_context_remove_extension(station->autocontext, hint, 06636 PRIORITY_HINT, sla_registrar); 06637 } 06638 AST_RWLIST_UNLOCK(&sla_trunks); 06639 } 06640 06641 while ((trunk_ref = AST_LIST_REMOVE_HEAD(&station->trunks, entry))) 06642 ast_free(trunk_ref); 06643 06644 ast_string_field_free_memory(station); 06645 ast_free(station); 06646 }
| static void destroy_trunk | ( | struct sla_trunk * | trunk | ) | [static] |
Definition at line 6608 of file app_meetme.c.
References ast_context_remove_extension(), ast_free, AST_LIST_REMOVE_HEAD, ast_string_field_free_memory, ast_strlen_zero(), and sla_registrar.
Referenced by sla_build_trunk(), and sla_destroy().
06609 { 06610 struct sla_station_ref *station_ref; 06611 06612 if (!ast_strlen_zero(trunk->autocontext)) 06613 ast_context_remove_extension(trunk->autocontext, "s", 1, sla_registrar); 06614 06615 while ((station_ref = AST_LIST_REMOVE_HEAD(&trunk->stations, entry))) 06616 ast_free(station_ref); 06617 06618 ast_string_field_free_memory(trunk); 06619 ast_free(trunk); 06620 }
| static void* dial_trunk | ( | void * | data | ) | [static] |
Definition at line 6127 of file app_meetme.c.
References ALL_TRUNK_REFS, args, ast_cond_signal, ast_dial_answered(), ast_dial_append(), ast_dial_create(), ast_dial_destroy(), ast_dial_join(), AST_DIAL_RESULT_ANSWERED, AST_DIAL_RESULT_FAILED, AST_DIAL_RESULT_HANGUP, AST_DIAL_RESULT_INVALID, AST_DIAL_RESULT_PROCEEDING, AST_DIAL_RESULT_PROGRESS, AST_DIAL_RESULT_RINGING, AST_DIAL_RESULT_TIMEOUT, AST_DIAL_RESULT_TRYING, AST_DIAL_RESULT_UNANSWERED, ast_dial_run(), ast_dial_state(), ast_mutex_lock, ast_mutex_unlock, ast_party_caller_free(), ast_party_caller_init(), ast_set_flag64, ast_strdupa, build_conf(), dial_trunk_args::cond, dial_trunk_args::cond_lock, conf_run(), CONFFLAG_MARKEDEXIT, CONFFLAG_MARKEDUSER, CONFFLAG_PASS_DTMF, CONFFLAG_QUIET, CONFFLAG_SLA_TRUNK, dispose_conf(), MAX_CONFNUM, sla, sla_change_trunk_state(), SLA_TRUNK_STATE_IDLE, and dial_trunk_args::trunk_ref.
Referenced by sla_station_exec().
06128 { 06129 struct dial_trunk_args *args = data; 06130 struct ast_dial *dial; 06131 char *tech, *tech_data; 06132 enum ast_dial_result dial_res; 06133 char conf_name[MAX_CONFNUM]; 06134 struct ast_conference *conf; 06135 struct ast_flags64 conf_flags = { 0 }; 06136 struct sla_trunk_ref *trunk_ref = args->trunk_ref; 06137 int caller_is_saved; 06138 struct ast_party_caller caller; 06139 06140 if (!(dial = ast_dial_create())) { 06141 ast_mutex_lock(args->cond_lock); 06142 ast_cond_signal(args->cond); 06143 ast_mutex_unlock(args->cond_lock); 06144 return NULL; 06145 } 06146 06147 tech_data = ast_strdupa(trunk_ref->trunk->device); 06148 tech = strsep(&tech_data, "/"); 06149 if (ast_dial_append(dial, tech, tech_data) == -1) { 06150 ast_mutex_lock(args->cond_lock); 06151 ast_cond_signal(args->cond); 06152 ast_mutex_unlock(args->cond_lock); 06153 ast_dial_destroy(dial); 06154 return NULL; 06155 } 06156 06157 /* Do we need to save of the caller ID data? */ 06158 caller_is_saved = 0; 06159 if (!sla.attempt_callerid) { 06160 caller_is_saved = 1; 06161 caller = trunk_ref->chan->caller; 06162 ast_party_caller_init(&trunk_ref->chan->caller); 06163 } 06164 06165 dial_res = ast_dial_run(dial, trunk_ref->chan, 1); 06166 06167 /* Restore saved caller ID */ 06168 if (caller_is_saved) { 06169 ast_party_caller_free(&trunk_ref->chan->caller); 06170 trunk_ref->chan->caller = caller; 06171 } 06172 06173 if (dial_res != AST_DIAL_RESULT_TRYING) { 06174 ast_mutex_lock(args->cond_lock); 06175 ast_cond_signal(args->cond); 06176 ast_mutex_unlock(args->cond_lock); 06177 ast_dial_destroy(dial); 06178 return NULL; 06179 } 06180 06181 for (;;) { 06182 unsigned int done = 0; 06183 switch ((dial_res = ast_dial_state(dial))) { 06184 case AST_DIAL_RESULT_ANSWERED: 06185 trunk_ref->trunk->chan = ast_dial_answered(dial); 06186 case AST_DIAL_RESULT_HANGUP: 06187 case AST_DIAL_RESULT_INVALID: 06188 case AST_DIAL_RESULT_FAILED: 06189 case AST_DIAL_RESULT_TIMEOUT: 06190 case AST_DIAL_RESULT_UNANSWERED: 06191 done = 1; 06192 case AST_DIAL_RESULT_TRYING: 06193 case AST_DIAL_RESULT_RINGING: 06194 case AST_DIAL_RESULT_PROGRESS: 06195 case AST_DIAL_RESULT_PROCEEDING: 06196 break; 06197 } 06198 if (done) 06199 break; 06200 } 06201 06202 if (!trunk_ref->trunk->chan) { 06203 ast_mutex_lock(args->cond_lock); 06204 ast_cond_signal(args->cond); 06205 ast_mutex_unlock(args->cond_lock); 06206 ast_dial_join(dial); 06207 ast_dial_destroy(dial); 06208 return NULL; 06209 } 06210 06211 snprintf(conf_name, sizeof(conf_name), "SLA_%s", trunk_ref->trunk->name); 06212 ast_set_flag64(&conf_flags, 06213 CONFFLAG_QUIET | CONFFLAG_MARKEDEXIT | CONFFLAG_MARKEDUSER | 06214 CONFFLAG_PASS_DTMF | CONFFLAG_SLA_TRUNK); 06215 conf = build_conf(conf_name, "", "", 1, 1, 1, trunk_ref->trunk->chan, NULL); 06216 06217 ast_mutex_lock(args->cond_lock); 06218 ast_cond_signal(args->cond); 06219 ast_mutex_unlock(args->cond_lock); 06220 06221 if (conf) { 06222 conf_run(trunk_ref->trunk->chan, conf, &conf_flags, NULL); 06223 dispose_conf(conf); 06224 conf = NULL; 06225 } 06226 06227 /* If the trunk is going away, it is definitely now IDLE. */ 06228 sla_change_trunk_state(trunk_ref->trunk, SLA_TRUNK_STATE_IDLE, ALL_TRUNK_REFS, NULL); 06229 06230 trunk_ref->trunk->chan = NULL; 06231 trunk_ref->trunk->on_hold = 0; 06232 06233 ast_dial_join(dial); 06234 ast_dial_destroy(dial); 06235 06236 return NULL; 06237 }
| static int dispose_conf | ( | struct ast_conference * | conf | ) | [static] |
Decrement reference counts, as incremented by find_conf().
Definition at line 2049 of file app_meetme.c.
References ast_atomic_dec_and_test(), AST_LIST_LOCK, AST_LIST_UNLOCK, conf_free(), conf_map, ast_conference::confno, and ast_conference::refcount.
Referenced by admin_exec(), conf_exec(), count_exec(), dial_trunk(), run_station(), sla_station_exec(), and sla_trunk_exec().
02050 { 02051 int res = 0; 02052 int confno_int = 0; 02053 02054 AST_LIST_LOCK(&confs); 02055 if (ast_atomic_dec_and_test(&conf->refcount)) { 02056 /* Take the conference room number out of an inuse state */ 02057 if ((sscanf(conf->confno, "%4d", &confno_int) == 1) && (confno_int >= 0 && confno_int < 1024)) { 02058 conf_map[confno_int] = 0; 02059 } 02060 conf_free(conf); 02061 res = 1; 02062 } 02063 AST_LIST_UNLOCK(&confs); 02064 02065 return res; 02066 }
| static void filename_parse | ( | char * | filename, | |
| char * | buffer | |||
| ) | [static] |
Definition at line 4989 of file app_meetme.c.
References ast_config_AST_SPOOL_DIR, ast_copy_string(), ast_log(), ast_mkdir(), ast_strlen_zero(), and LOG_WARNING.
Referenced by recordthread().
04990 { 04991 char *slash; 04992 if (ast_strlen_zero(filename)) { 04993 ast_log(LOG_WARNING, "No file name was provided for a file save option.\n"); 04994 } else if (filename[0] != '/') { 04995 snprintf(buffer, PATH_MAX, "%s/meetme/%s", ast_config_AST_SPOOL_DIR, filename); 04996 } else { 04997 ast_copy_string(buffer, filename, PATH_MAX); 04998 } 04999 05000 slash = buffer; 05001 if ((slash = strrchr(slash, '/'))) { 05002 *slash = '\0'; 05003 ast_mkdir(buffer, 0777); 05004 *slash = '/'; 05005 } 05006 }
| static struct ast_conference* find_conf | ( | struct ast_channel * | chan, | |
| char * | confno, | |||
| int | make, | |||
| int | dynamic, | |||
| char * | dynamic_pin, | |||
| size_t | pin_buf_len, | |||
| int | refcount, | |||
| struct ast_flags64 * | confflags | |||
| ) | [static, read] |
Definition at line 4093 of file app_meetme.c.
References args, AST_APP_ARG, ast_app_getdata(), ast_clear_flag64, ast_config_destroy(), ast_config_load, ast_copy_string(), ast_debug, AST_DECLARE_APP_ARGS, AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, ast_log(), AST_STANDARD_APP_ARGS, ast_test_flag64, ast_variable_browse(), build_conf(), ast_conference::chan, CONFFLAG_INTROUSER, CONFFLAG_INTROUSERNOREVIEW, CONFFLAG_QUIET, CONFFLAG_RECORDCONF, CONFIG_FILE_NAME, CONFIG_STATUS_FILEINVALID, ast_conference::confno, LOG_ERROR, LOG_WARNING, MAX_SETTINGS, ast_variable::name, ast_variable::next, parse(), ast_conference::pin, ast_conference::pinadmin, ast_conference::refcount, S_OR, ast_variable::value, and var.
Referenced by conf_exec(), and count_exec().
04095 { 04096 struct ast_config *cfg; 04097 struct ast_variable *var; 04098 struct ast_flags config_flags = { 0 }; 04099 struct ast_conference *cnf; 04100 04101 AST_DECLARE_APP_ARGS(args, 04102 AST_APP_ARG(confno); 04103 AST_APP_ARG(pin); 04104 AST_APP_ARG(pinadmin); 04105 ); 04106 04107 /* Check first in the conference list */ 04108 ast_debug(1, "The requested confno is '%s'?\n", confno); 04109 AST_LIST_LOCK(&confs); 04110 AST_LIST_TRAVERSE(&confs, cnf, list) { 04111 ast_debug(3, "Does conf %s match %s?\n", confno, cnf->confno); 04112 if (!strcmp(confno, cnf->confno)) 04113 break; 04114 } 04115 if (cnf) { 04116 cnf->refcount += refcount; 04117 } 04118 AST_LIST_UNLOCK(&confs); 04119 04120 if (!cnf) { 04121 if (dynamic) { 04122 /* No need to parse meetme.conf */ 04123 ast_debug(1, "Building dynamic conference '%s'\n", confno); 04124 if (dynamic_pin) { 04125 if (dynamic_pin[0] == 'q') { 04126 /* Query the user to enter a PIN */ 04127 if (ast_app_getdata(chan, "conf-getpin", dynamic_pin, pin_buf_len - 1, 0) < 0) 04128 return NULL; 04129 } 04130 cnf = build_conf(confno, dynamic_pin, "", make, dynamic, refcount, chan, NULL); 04131 } else { 04132 cnf = build_conf(confno, "", "", make, dynamic, refcount, chan, NULL); 04133 } 04134 } else { 04135 /* Check the config */ 04136 cfg = ast_config_load(CONFIG_FILE_NAME, config_flags); 04137 if (!cfg) { 04138 ast_log(LOG_WARNING, "No %s file :(\n", CONFIG_FILE_NAME); 04139 return NULL; 04140 } else if (cfg == CONFIG_STATUS_FILEINVALID) { 04141 ast_log(LOG_ERROR, "Config file " CONFIG_FILE_NAME " is in an invalid format. Aborting.\n"); 04142 return NULL; 04143 } 04144 04145 for (var = ast_variable_browse(cfg, "rooms"); var; var = var->next) { 04146 char parse[MAX_SETTINGS]; 04147 04148 if (strcasecmp(var->name, "conf")) 04149 continue; 04150 04151 ast_copy_string(parse, var->value, sizeof(parse)); 04152 04153 AST_STANDARD_APP_ARGS(args, parse); 04154 ast_debug(3, "Will conf %s match %s?\n", confno, args.confno); 04155 if (!strcasecmp(args.confno, confno)) { 04156 /* Bingo it's a valid conference */ 04157 cnf = build_conf(args.confno, 04158 S_OR(args.pin, ""), 04159 S_OR(args.pinadmin, ""), 04160 make, dynamic, refcount, chan, NULL); 04161 break; 04162 } 04163 } 04164 if (!var) { 04165 ast_debug(1, "%s isn't a valid conference\n", confno); 04166 } 04167 ast_config_destroy(cfg); 04168 } 04169 } else if (dynamic_pin) { 04170 /* Correct for the user selecting 'D' instead of 'd' to have 04171 someone join into a conference that has already been created 04172 with a pin. */ 04173 if (dynamic_pin[0] == 'q') { 04174 dynamic_pin[0] = '\0'; 04175 } 04176 } 04177 04178 if (cnf) { 04179 if (confflags && !cnf->chan && 04180 !ast_test_flag64(confflags, CONFFLAG_QUIET) && 04181 ast_test_flag64(confflags, CONFFLAG_INTROUSER | CONFFLAG_INTROUSERNOREVIEW)) { 04182 ast_log(LOG_WARNING, "No DAHDI channel available for conference, user introduction disabled (is chan_dahdi loaded?)\n"); 04183 ast_clear_flag64(confflags, CONFFLAG_INTROUSER | CONFFLAG_INTROUSERNOREVIEW); 04184 } 04185 04186 if (confflags && !cnf->chan && 04187 ast_test_flag64(confflags, CONFFLAG_RECORDCONF)) { 04188 ast_log(LOG_WARNING, "No DAHDI channel available for conference, conference recording disabled (is chan_dahdi loaded?)\n"); 04189 ast_clear_flag64(confflags, CONFFLAG_RECORDCONF); 04190 } 04191 } 04192 04193 return cnf; 04194 }
| static struct ast_conference* find_conf_realtime | ( | struct ast_channel * | chan, | |
| char * | confno, | |||
| int | make, | |||
| int | dynamic, | |||
| char * | dynamic_pin, | |||
| size_t | pin_buf_len, | |||
| int | refcount, | |||
| struct ast_flags64 * | confflags, | |||
| int * | too_early, | |||
| char ** | optargs | |||
| ) | [static, read] |
Definition at line 3905 of file app_meetme.c.
References ast_conference::adminopts, ast_app_parse_options64(), ast_channel_lock, ast_channel_unlock, ast_clear_flag64, ast_copy_flags64, ast_copy_string(), ast_debug, ast_free, AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, ast_load_realtime(), ast_localtime(), ast_log(), AST_MAX_EXTENSION, ast_mktime(), ast_strdup, ast_strdupa, ast_streamfile(), ast_strftime(), ast_strlen_zero(), ast_strptime(), ast_test_flag64, ast_tvnow(), ast_variables_destroy(), ast_verb, ast_waitstream(), ast_conference::bookid, build_conf(), ast_conference::chan, CONFFLAG_INTROUSER, CONFFLAG_INTROUSERNOREVIEW, CONFFLAG_QUIET, CONFFLAG_RECORDCONF, ast_conference::confno, DATE_FORMAT, ast_conference::endalert, ast_conference::endtime, ast_flags64::flags, LOG_WARNING, ast_conference::maxusers, ast_variable::name, ast_variable::next, OPTIONS_LEN, pbx_builtin_getvar_helper(), ast_conference::pin, ast_conference::pinadmin, ast_conference::recordingfilename, ast_conference::recordingformat, ast_conference::refcount, ast_conference::useropts, ast_variable::value, and var.
Referenced by conf_exec().
03907 { 03908 struct ast_variable *var, *origvar; 03909 struct ast_conference *cnf; 03910 03911 *too_early = 0; 03912 03913 /* Check first in the conference list */ 03914 AST_LIST_LOCK(&confs); 03915 AST_LIST_TRAVERSE(&confs, cnf, list) { 03916 if (!strcmp(confno, cnf->confno)) { 03917 break; 03918 } 03919 } 03920 if (cnf) { 03921 cnf->refcount += refcount; 03922 } 03923 AST_LIST_UNLOCK(&confs); 03924 03925 if (!cnf) { 03926 char *pin = NULL, *pinadmin = NULL; /* For temp use */ 03927 int maxusers = 0; 03928 struct timeval now; 03929 char recordingfilename[256] = ""; 03930 char recordingformat[11] = ""; 03931 char currenttime[32] = ""; 03932 char eatime[32] = ""; 03933 char bookid[51] = ""; 03934 char recordingtmp[AST_MAX_EXTENSION] = ""; 03935 char useropts[OPTIONS_LEN + 1] = ""; /* Used for RealTime conferences */ 03936 char adminopts[OPTIONS_LEN + 1] = ""; 03937 struct ast_tm tm, etm; 03938 struct timeval endtime = { .tv_sec = 0 }; 03939 const char *var2; 03940 03941 if (rt_schedule) { 03942 now = ast_tvnow(); 03943 03944 ast_localtime(&now, &tm, NULL); 03945 ast_strftime(currenttime, sizeof(currenttime), DATE_FORMAT, &tm); 03946 03947 ast_debug(1, "Looking for conference %s that starts after %s\n", confno, currenttime); 03948 03949 var = ast_load_realtime("meetme", "confno", 03950 confno, "starttime <= ", currenttime, "endtime >= ", 03951 currenttime, NULL); 03952 03953 if (!var && fuzzystart) { 03954 now = ast_tvnow(); 03955 now.tv_sec += fuzzystart; 03956 03957 ast_localtime(&now, &tm, NULL); 03958 ast_strftime(currenttime, sizeof(currenttime), DATE_FORMAT, &tm); 03959 var = ast_load_realtime("meetme", "confno", 03960 confno, "starttime <= ", currenttime, "endtime >= ", 03961 currenttime, NULL); 03962 } 03963 03964 if (!var && earlyalert) { 03965 now = ast_tvnow(); 03966 now.tv_sec += earlyalert; 03967 ast_localtime(&now, &etm, NULL); 03968 ast_strftime(eatime, sizeof(eatime), DATE_FORMAT, &etm); 03969 var = ast_load_realtime("meetme", "confno", 03970 confno, "starttime <= ", eatime, "endtime >= ", 03971 currenttime, NULL); 03972 if (var) { 03973 *too_early = 1; 03974 } 03975 } 03976 03977 } else { 03978 var = ast_load_realtime("meetme", "confno", confno, NULL); 03979 } 03980 03981 if (!var) { 03982 return NULL; 03983 } 03984 03985 if (rt_schedule && *too_early) { 03986 /* Announce that the caller is early and exit */ 03987 if (!ast_streamfile(chan, "conf-has-not-started", chan->language)) { 03988 ast_waitstream(chan, ""); 03989 } 03990 ast_variables_destroy(var); 03991 return NULL; 03992 } 03993 03994 for (origvar = var; var; var = var->next) { 03995 if (!strcasecmp(var->name, "pin")) { 03996 pin = ast_strdupa(var->value); 03997 } else if (!strcasecmp(var->name, "adminpin")) { 03998 pinadmin = ast_strdupa(var->value); 03999 } else if (!strcasecmp(var->name, "bookId")) { 04000 ast_copy_string(bookid, var->value, sizeof(bookid)); 04001 } else if (!strcasecmp(var->name, "opts")) { 04002 ast_copy_string(useropts, var->value, sizeof(char[OPTIONS_LEN + 1])); 04003 } else if (!strcasecmp(var->name, "maxusers")) { 04004 maxusers = atoi(var->value); 04005 } else if (!strcasecmp(var->name, "adminopts")) { 04006 ast_copy_string(adminopts, var->value, sizeof(char[OPTIONS_LEN + 1])); 04007 } else if (!strcasecmp(var->name, "recordingfilename")) { 04008 ast_copy_string(recordingfilename, var->value, sizeof(recordingfilename)); 04009 } else if (!strcasecmp(var->name, "recordingformat")) { 04010 ast_copy_string(recordingformat, var->value, sizeof(recordingformat)); 04011 } else if (!strcasecmp(var->name, "endtime")) { 04012 struct ast_tm endtime_tm; 04013 ast_strptime(var->value, "%Y-%m-%d %H:%M:%S", &endtime_tm); 04014 endtime = ast_mktime(&endtime_tm, NULL); 04015 } 04016 } 04017 04018 ast_variables_destroy(origvar); 04019 04020 cnf = build_conf(confno, pin ? pin : "", pinadmin ? pinadmin : "", make, dynamic, refcount, chan, NULL); 04021 04022 if (cnf) { 04023 struct ast_flags64 tmp_flags; 04024 04025 cnf->maxusers = maxusers; 04026 cnf->endalert = endalert; 04027 cnf->endtime = endtime.tv_sec; 04028 cnf->useropts = ast_strdup(useropts); 04029 cnf->adminopts = ast_strdup(adminopts); 04030 cnf->bookid = ast_strdup(bookid); 04031 if (!ast_strlen_zero(recordingfilename)) { 04032 cnf->recordingfilename = ast_strdup(recordingfilename); 04033 } 04034 if (!ast_strlen_zero(recordingformat)) { 04035 cnf->recordingformat = ast_strdup(recordingformat); 04036 } 04037 04038 /* Parse the other options into confflags -- need to do this in two 04039 * steps, because the parse_options routine zeroes the buffer. */ 04040 ast_app_parse_options64(meetme_opts, &tmp_flags, optargs, useropts); 04041 ast_copy_flags64(confflags, &tmp_flags, tmp_flags.flags); 04042 04043 if (strchr(cnf->useropts, 'r')) { 04044 if (ast_strlen_zero(recordingfilename)) { /* If the recordingfilename in the database is empty, use the channel definition or use the default. */ 04045 ast_channel_lock(chan); 04046 if ((var2 = pbx_builtin_getvar_helper(chan, "MEETME_RECORDINGFILE"))) { 04047 ast_free(cnf->recordingfilename); 04048 cnf->recordingfilename = ast_strdup(var2); 04049 } 04050 ast_channel_unlock(chan); 04051 if (ast_strlen_zero(cnf->recordingfilename)) { 04052 snprintf(recordingtmp, sizeof(recordingtmp), "meetme-conf-rec-%s-%s", cnf->confno, chan->uniqueid); 04053 ast_free(cnf->recordingfilename); 04054 cnf->recordingfilename = ast_strdup(recordingtmp); 04055 } 04056 } 04057 if (ast_strlen_zero(cnf->recordingformat)) {/* If the recording format is empty, use the wav as default */ 04058 ast_channel_lock(chan); 04059 if ((var2 = pbx_builtin_getvar_helper(chan, "MEETME_RECORDINGFORMAT"))) { 04060 ast_free(cnf->recordingformat); 04061 cnf->recordingformat = ast_strdup(var2); 04062 } 04063 ast_channel_unlock(chan); 04064 if (ast_strlen_zero(cnf->recordingformat)) { 04065 ast_free(cnf->recordingformat); 04066 cnf->recordingformat = ast_strdup("wav"); 04067 } 04068 } 04069 ast_verb(4, "Starting recording of MeetMe Conference %s into file %s.%s.\n", cnf->confno, cnf->recordingfilename, cnf->recordingformat); 04070 } 04071 } 04072 } 04073 04074 if (cnf) { 04075 if (confflags->flags && !cnf->chan && 04076 !ast_test_flag64(confflags, CONFFLAG_QUIET) && 04077 ast_test_flag64(confflags, CONFFLAG_INTROUSER | CONFFLAG_INTROUSERNOREVIEW)) { 04078 ast_log(LOG_WARNING, "No DAHDI channel available for conference, user introduction disabled (is chan_dahdi loaded?)\n"); 04079 ast_clear_flag64(confflags, CONFFLAG_INTROUSER | CONFFLAG_INTROUSERNOREVIEW); 04080 } 04081 04082 if (confflags && !cnf->chan && 04083 ast_test_flag64(confflags, CONFFLAG_RECORDCONF)) { 04084 ast_log(LOG_WARNING, "No DAHDI channel available for conference, conference recording disabled (is chan_dahdi loaded?)\n"); 04085 ast_clear_flag64(confflags, CONFFLAG_RECORDCONF); 04086 } 04087 } 04088 04089 return cnf; 04090 }
| static struct ast_conf_user* find_user | ( | struct ast_conference * | conf, | |
| const char * | callerident | |||
| ) | [static, read] |
Definition at line 4567 of file app_meetme.c.
References ao2_find, and ast_conference::usercontainer.
Referenced by admin_exec().
04568 { 04569 struct ast_conf_user *user = NULL; 04570 int cid; 04571 04572 if (conf && callerident && sscanf(callerident, "%30d", &cid) == 1) { 04573 user = ao2_find(conf->usercontainer, &cid, 0); 04574 /* reference decremented later in admin_exec */ 04575 return user; 04576 } 04577 return NULL; 04578 }
| static const char* get_announce_filename | ( | enum announcetypes | type | ) | [static] |
Definition at line 2146 of file app_meetme.c.
References CONF_HASJOIN, and CONF_HASLEFT.
Referenced by announce_thread().
02147 { 02148 switch (type) { 02149 case CONF_HASLEFT: 02150 return "conf-hasleft"; 02151 break; 02152 case CONF_HASJOIN: 02153 return "conf-hasjoin"; 02154 break; 02155 default: 02156 return ""; 02157 } 02158 }
| static const char* istalking | ( | int | x | ) | [static] |
Definition at line 984 of file app_meetme.c.
Referenced by meetme_show_cmd().
| static int load_config | ( | int | reload | ) | [static] |
Definition at line 7076 of file app_meetme.c.
References ast_log(), AST_PTHREADT_NULL, load_config_meetme(), LOG_NOTICE, sla, SLA_EVENT_RELOAD, sla_load_config(), and sla_queue_event().
Referenced by load_module(), and reload().
07077 { 07078 load_config_meetme(); 07079 07080 if (reload && sla.thread != AST_PTHREADT_NULL) { 07081 sla_queue_event(SLA_EVENT_RELOAD); 07082 ast_log(LOG_NOTICE, "A reload of the SLA configuration has been requested " 07083 "and will be completed when the system is idle.\n"); 07084 return 0; 07085 } 07086 07087 return sla_load_config(0); 07088 }
| static void load_config_meetme | ( | void | ) | [static] |
Definition at line 5099 of file app_meetme.c.
References ast_config_destroy(), ast_config_load, ast_log(), ast_true(), ast_variable_retrieve(), CONFIG_FILE_NAME, CONFIG_STATUS_FILEINVALID, DEFAULT_AUDIO_BUFFERS, LOG_ERROR, LOG_NOTICE, and LOG_WARNING.
Referenced by load_config().
05100 { 05101 struct ast_config *cfg; 05102 struct ast_flags config_flags = { 0 }; 05103 const char *val; 05104 05105 if (!(cfg = ast_config_load(CONFIG_FILE_NAME, config_flags))) { 05106 return; 05107 } else if (cfg == CONFIG_STATUS_FILEINVALID) { 05108 ast_log(LOG_ERROR, "Config file " CONFIG_FILE_NAME " is in an invalid format. Aborting.\n"); 05109 return; 05110 } 05111 05112 audio_buffers = DEFAULT_AUDIO_BUFFERS; 05113 05114 /* Scheduling support is off by default */ 05115 rt_schedule = 0; 05116 fuzzystart = 0; 05117 earlyalert = 0; 05118 endalert = 0; 05119 extendby = 0; 05120 05121 /* Logging of participants defaults to ON for compatibility reasons */ 05122 rt_log_members = 1; 05123 05124 if ((val = ast_variable_retrieve(cfg, "general", "audiobuffers"))) { 05125 if ((sscanf(val, "%30d", &audio_buffers) != 1)) { 05126 ast_log(LOG_WARNING, "audiobuffers setting must be a number, not '%s'\n", val); 05127 audio_buffers = DEFAULT_AUDIO_BUFFERS; 05128 } else if ((audio_buffers < DAHDI_DEFAULT_NUM_BUFS) || (audio_buffers > DAHDI_MAX_NUM_BUFS)) { 05129 ast_log(LOG_WARNING, "audiobuffers setting must be between %d and %d\n", 05130 DAHDI_DEFAULT_NUM_BUFS, DAHDI_MAX_NUM_BUFS); 05131 audio_buffers = DEFAULT_AUDIO_BUFFERS; 05132 } 05133 if (audio_buffers != DEFAULT_AUDIO_BUFFERS) 05134 ast_log(LOG_NOTICE, "Audio buffers per channel set to %d\n", audio_buffers); 05135 } 05136 05137 if ((val = ast_variable_retrieve(cfg, "general", "schedule"))) 05138 rt_schedule = ast_true(val); 05139 if ((val = ast_variable_retrieve(cfg, "general", "logmembercount"))) 05140 rt_log_members = ast_true(val); 05141 if ((val = ast_variable_retrieve(cfg, "general", "fuzzystart"))) { 05142 if ((sscanf(val, "%30d", &fuzzystart) != 1)) { 05143 ast_log(LOG_WARNING, "fuzzystart must be a number, not '%s'\n", val); 05144 fuzzystart = 0; 05145 } 05146 } 05147 if ((val = ast_variable_retrieve(cfg, "general", "earlyalert"))) { 05148 if ((sscanf(val, "%30d", &earlyalert) != 1)) { 05149 ast_log(LOG_WARNING, "earlyalert must be a number, not '%s'\n", val); 05150 earlyalert = 0; 05151 } 05152 } 05153 if ((val = ast_variable_retrieve(cfg, "general", "endalert"))) { 05154 if ((sscanf(val, "%30d", &endalert) != 1)) { 05155 ast_log(LOG_WARNING, "endalert must be a number, not '%s'\n", val); 05156 endalert = 0; 05157 } 05158 } 05159 if ((val = ast_variable_retrieve(cfg, "general", "extendby"))) { 05160 if ((sscanf(val, "%30d", &extendby) != 1)) { 05161 ast_log(LOG_WARNING, "extendby must be a number, not '%s'\n", val); 05162 extendby = 0; 05163 } 05164 } 05165 05166 ast_config_destroy(cfg); 05167 }
| static int load_module | ( | void | ) | [static] |
Definition at line 7301 of file app_meetme.c.
References action_meetmelist(), action_meetmemute(), action_meetmeunmute(), admin_exec(), ARRAY_LEN, ast_cli_register_multiple(), ast_custom_function_register, ast_data_register_multiple, ast_devstate_prov_add(), ast_manager_register_xml, ast_realtime_require_field(), ast_register_application_xml, AST_TEST_REGISTER, channel_admin_exec(), conf_exec(), count_exec(), EVENT_FLAG_CALL, EVENT_FLAG_REPORTING, load_config(), meetmestate(), RQ_UINTEGER1, RQ_UINTEGER2, sla_state(), sla_station_exec(), and sla_trunk_exec().
07302 { 07303 int res = 0; 07304 07305 res |= load_config(0); 07306 07307 ast_cli_register_multiple(cli_meetme, ARRAY_LEN(cli_meetme)); 07308 res |= ast_manager_register_xml("MeetmeMute", EVENT_FLAG_CALL, action_meetmemute); 07309 res |= ast_manager_register_xml("MeetmeUnmute", EVENT_FLAG_CALL, action_meetmeunmute); 07310 res |= ast_manager_register_xml("MeetmeList", EVENT_FLAG_REPORTING, action_meetmelist); 07311 res |= ast_register_application_xml(app4, channel_admin_exec); 07312 res |= ast_register_application_xml(app3, admin_exec); 07313 res |= ast_register_application_xml(app2, count_exec); 07314 res |= ast_register_application_xml(app, conf_exec); 07315 res |= ast_register_application_xml(slastation_app, sla_station_exec); 07316 res |= ast_register_application_xml(slatrunk_app, sla_trunk_exec); 07317 07318 #ifdef TEST_FRAMEWORK 07319 AST_TEST_REGISTER(test_meetme_data_provider); 07320 #endif 07321 ast_data_register_multiple(meetme_data_providers, ARRAY_LEN(meetme_data_providers)); 07322 07323 res |= ast_devstate_prov_add("Meetme", meetmestate); 07324 res |= ast_devstate_prov_add("SLA", sla_state); 07325 07326 res |= ast_custom_function_register(&meetme_info_acf); 07327 ast_realtime_require_field("meetme", "confno", RQ_UINTEGER2, 3, "members", RQ_UINTEGER1, 3, NULL); 07328 07329 return res; 07330 }
| static char* meetme_cmd_helper | ( | struct ast_cli_args * | a | ) | [static] |
Definition at line 1572 of file app_meetme.c.
References admin_exec(), ast_cli_args::argv, ast_debug, ast_free, ast_str_append(), ast_str_buffer(), ast_str_create(), ast_str_set(), CLI_FAILURE, CLI_SHOWUSAGE, CLI_SUCCESS, and MAX_CONFNUM.
Referenced by meetme_kick_cmd(), meetme_lock_cmd(), and meetme_mute_cmd().
01573 { 01574 /* Process the command */ 01575 struct ast_str *cmdline; 01576 01577 /* Max confno length */ 01578 if (!(cmdline = ast_str_create(MAX_CONFNUM))) { 01579 return CLI_FAILURE; 01580 } 01581 01582 ast_str_set(&cmdline, 0, "%s", a->argv[2]); /* Argv 2: conference number */ 01583 if (strcasestr(a->argv[1], "lock")) { 01584 if (strcasecmp(a->argv[1], "lock") == 0) { 01585 /* Lock */ 01586 ast_str_append(&cmdline, 0, ",L"); 01587 } else { 01588 /* Unlock */ 01589 ast_str_append(&cmdline, 0, ",l"); 01590 } 01591 } else if (strcasestr(a->argv[1], "mute")) { 01592 if (strcasecmp(a->argv[1], "mute") == 0) { 01593 /* Mute */ 01594 if (strcasecmp(a->argv[3], "all") == 0) { 01595 ast_str_append(&cmdline, 0, ",N"); 01596 } else { 01597 ast_str_append(&cmdline, 0, ",M,%s", a->argv[3]); 01598 } 01599 } else { 01600 /* Unmute */ 01601 if (strcasecmp(a->argv[3], "all") == 0) { 01602 ast_str_append(&cmdline, 0, ",n"); 01603 } else { 01604 ast_str_append(&cmdline, 0, ",m,%s", a->argv[3]); 01605 } 01606 } 01607 } else if (strcasecmp(a->argv[1], "kick") == 0) { 01608 if (strcasecmp(a->argv[3], "all") == 0) { 01609 /* Kick all */ 01610 ast_str_append(&cmdline, 0, ",K"); 01611 } else { 01612 /* Kick a single user */ 01613 ast_str_append(&cmdline, 0, ",k,%s", a->argv[3]); 01614 } 01615 } else { 01616 /* 01617 * Should never get here because it is already filtered by the 01618 * callers. 01619 */ 01620 ast_free(cmdline); 01621 return CLI_SHOWUSAGE; 01622 } 01623 01624 ast_debug(1, "Cmdline: %s\n", ast_str_buffer(cmdline)); 01625 01626 admin_exec(NULL, ast_str_buffer(cmdline)); 01627 ast_free(cmdline); 01628 01629 return CLI_SUCCESS; 01630 }
| static int meetme_data_provider_get | ( | const struct ast_data_search * | search, | |
| struct ast_data * | data_root | |||
| ) | [static] |
Definition at line 7165 of file app_meetme.c.
References ao2_callback, ao2_container_count(), ast_data_add_node(), ast_data_add_structure, ast_data_remove_node(), ast_data_search_match(), AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, OBJ_NODATA, user_add_provider_cb(), and ast_conference::usercontainer.
07167 { 07168 struct ast_conference *cnf; 07169 struct ast_data *data_meetme, *data_meetme_users; 07170 07171 AST_LIST_LOCK(&confs); 07172 AST_LIST_TRAVERSE(&confs, cnf, list) { 07173 data_meetme = ast_data_add_node(data_root, "meetme"); 07174 if (!data_meetme) { 07175 continue; 07176 } 07177 07178 ast_data_add_structure(ast_conference, data_meetme, cnf); 07179 07180 if (ao2_container_count(cnf->usercontainer)) { 07181 data_meetme_users = ast_data_add_node(data_meetme, "users"); 07182 if (!data_meetme_users) { 07183 ast_data_remove_node(data_root, data_meetme); 07184 continue; 07185 } 07186 07187 ao2_callback(cnf->usercontainer, OBJ_NODATA, user_add_provider_cb, data_meetme_users); 07188 } 07189 07190 if (!ast_data_search_match(search, data_meetme)) { 07191 ast_data_remove_node(data_root, data_meetme); 07192 } 07193 } 07194 AST_LIST_UNLOCK(&confs); 07195 07196 return 0; 07197 }
| static char* meetme_kick_cmd | ( | struct ast_cli_entry * | e, | |
| int | cmd, | |||
| struct ast_cli_args * | a | |||
| ) | [static] |
Definition at line 1652 of file app_meetme.c.
References ast_cli_args::argc, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, ast_cli_entry::command, complete_meetmecmd_mute_kick(), ast_cli_args::line, meetme_cmd_helper(), ast_cli_args::n, ast_cli_args::pos, ast_cli_entry::usage, and ast_cli_args::word.
01653 { 01654 switch (cmd) { 01655 case CLI_INIT: 01656 e->command = "meetme kick"; 01657 e->usage = 01658 "Usage: meetme kick <confno> all|<userno>\n" 01659 " Kick a conference or a user in a conference.\n"; 01660 return NULL; 01661 case CLI_GENERATE: 01662 return complete_meetmecmd_mute_kick(a->line, a->word, a->pos, a->n); 01663 } 01664 01665 if (a->argc != 4) { 01666 return CLI_SHOWUSAGE; 01667 } 01668 01669 return meetme_cmd_helper(a); 01670 }
| static char* meetme_lock_cmd | ( | struct ast_cli_entry * | e, | |
| int | cmd, | |||
| struct ast_cli_args * | a | |||
| ) | [static] |
Definition at line 1632 of file app_meetme.c.
References ast_cli_args::argc, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, ast_cli_entry::command, complete_meetmecmd_lock(), meetme_cmd_helper(), ast_cli_args::n, ast_cli_args::pos, ast_cli_entry::usage, and ast_cli_args::word.
01633 { 01634 switch (cmd) { 01635 case CLI_INIT: 01636 e->command = "meetme {lock|unlock}"; 01637 e->usage = 01638 "Usage: meetme lock|unlock <confno>\n" 01639 " Lock or unlock a conference to new users.\n"; 01640 return NULL; 01641 case CLI_GENERATE: 01642 return complete_meetmecmd_lock(a->word, a->pos, a->n); 01643 } 01644 01645 if (a->argc != 3) { 01646 return CLI_SHOWUSAGE; 01647 } 01648 01649 return meetme_cmd_helper(a); 01650 }
| static char* meetme_mute_cmd | ( | struct ast_cli_entry * | e, | |
| int | cmd, | |||
| struct ast_cli_args * | a | |||
| ) | [static] |
Definition at line 1672 of file app_meetme.c.
References ast_cli_args::argc, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, ast_cli_entry::command, complete_meetmecmd_mute_kick(), ast_cli_args::line, meetme_cmd_helper(), ast_cli_args::n, ast_cli_args::pos, ast_cli_entry::usage, and ast_cli_args::word.
01673 { 01674 switch (cmd) { 01675 case CLI_INIT: 01676 e->command = "meetme {mute|unmute}"; 01677 e->usage = 01678 "Usage: meetme mute|unmute <confno> all|<userno>\n" 01679 " Mute or unmute a conference or a user in a conference.\n"; 01680 return NULL; 01681 case CLI_GENERATE: 01682 return complete_meetmecmd_mute_kick(a->line, a->word, a->pos, a->n); 01683 } 01684 01685 if (a->argc != 4) { 01686 return CLI_SHOWUSAGE; 01687 } 01688 01689 return meetme_cmd_helper(a); 01690 }
| static char* meetme_show_cmd | ( | struct ast_cli_entry * | e, | |
| int | cmd, | |||
| struct ast_cli_args * | a | |||
| ) | [static] |
Definition at line 1429 of file app_meetme.c.
References ADMINFLAG_MUTED, ADMINFLAG_SELFMUTED, ADMINFLAG_T_REQUEST, ast_conf_user::adminflags, ao2_iterator_destroy(), ao2_iterator_init(), ao2_iterator_next, ao2_ref, ast_cli_args::argc, ast_cli_args::argv, ast_cli(), ast_free, AST_LIST_EMPTY, AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, ast_str_buffer(), ast_str_create(), ast_str_set(), ast_test_flag64, ast_channel::caller, ast_conf_user::chan, CLI_FAILURE, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, complete_meetmecmd_list(), CONFFLAG_ADMIN, CONFFLAG_MONITOR, ast_conference::confno, ast_cli_args::fd, ast_party_caller::id, ast_conference::isdynamic, istalking(), ast_conf_user::jointime, ast_cli_args::line, ast_conference::locked, ast_conference::markedusers, MC_DATA_FORMAT, MC_HEADER_FORMAT, ast_cli_args::n, ast_party_id::name, ast_party_id::number, ast_cli_args::pos, S_COR, ast_conference::start, ast_party_name::str, ast_party_number::str, STR_CONCISE, ast_conf_user::talking, total, ast_cli_entry::usage, ast_conf_user::user_no, ast_conference::usercontainer, ast_conf_user::userflags, ast_conference::users, ast_party_name::valid, ast_party_number::valid, and ast_cli_args::word.
01430 { 01431 /* Process the command */ 01432 struct ast_conf_user *user; 01433 struct ast_conference *cnf; 01434 int hr, min, sec; 01435 int total = 0; 01436 time_t now; 01437 #define MC_HEADER_FORMAT "%-14s %-14s %-10s %-8s %-8s %-6s\n" 01438 #define MC_DATA_FORMAT "%-12.12s %4.4d %4.4s %02d:%02d:%02d %-8s %-6s\n" 01439 01440 switch (cmd) { 01441 case CLI_INIT: 01442 e->command = "meetme list"; 01443 e->usage = 01444 "Usage: meetme list [<confno>] [" STR_CONCISE "]\n" 01445 " List all conferences or a specific conference.\n"; 01446 return NULL; 01447 case CLI_GENERATE: 01448 return complete_meetmecmd_list(a->line, a->word, a->pos, a->n); 01449 } 01450 01451 if (a->argc == 2 || (a->argc == 3 && !strcasecmp(a->argv[2], STR_CONCISE))) { 01452 /* List all the conferences */ 01453 int concise = (a->argc == 3); 01454 struct ast_str *marked_users; 01455 01456 if (!(marked_users = ast_str_create(30))) { 01457 return CLI_FAILURE; 01458 } 01459 01460 now = time(NULL); 01461 AST_LIST_LOCK(&confs); 01462 if (AST_LIST_EMPTY(&confs)) { 01463 if (!concise) { 01464 ast_cli(a->fd, "No active MeetMe conferences.\n"); 01465 } 01466 AST_LIST_UNLOCK(&confs); 01467 ast_free(marked_users); 01468 return CLI_SUCCESS; 01469 } 01470 if (!concise) { 01471 ast_cli(a->fd, MC_HEADER_FORMAT, "Conf Num", "Parties", "Marked", "Activity", "Creation", "Locked"); 01472 } 01473 AST_LIST_TRAVERSE(&confs, cnf, list) { 01474 hr = (now - cnf->start) / 3600; 01475 min = ((now - cnf->start) % 3600) / 60; 01476 sec = (now - cnf->start) % 60; 01477 if (!concise) { 01478 if (cnf->markedusers == 0) { 01479 ast_str_set(&marked_users, 0, "N/A "); 01480 } else { 01481 ast_str_set(&marked_users, 0, "%4.4d", cnf->markedusers); 01482 } 01483 ast_cli(a->fd, MC_DATA_FORMAT, cnf->confno, cnf->users, 01484 ast_str_buffer(marked_users), hr, min, sec, 01485 cnf->isdynamic ? "Dynamic" : "Static", cnf->locked ? "Yes" : "No"); 01486 } else { 01487 ast_cli(a->fd, "%s!%d!%d!%02d:%02d:%02d!%d!%d\n", 01488 cnf->confno, 01489 cnf->users, 01490 cnf->markedusers, 01491 hr, min, sec, 01492 cnf->isdynamic, 01493 cnf->locked); 01494 } 01495 01496 total += cnf->users; 01497 } 01498 AST_LIST_UNLOCK(&confs); 01499 if (!concise) { 01500 ast_cli(a->fd, "* Total number of MeetMe users: %d\n", total); 01501 } 01502 ast_free(marked_users); 01503 return CLI_SUCCESS; 01504 } 01505 if (a->argc == 3 || (a->argc == 4 && !strcasecmp(a->argv[3], STR_CONCISE))) { 01506 struct ao2_iterator user_iter; 01507 int concise = (a->argc == 4); 01508 01509 /* List all the users in a conference */ 01510 if (AST_LIST_EMPTY(&confs)) { 01511 if (!concise) { 01512 ast_cli(a->fd, "No active MeetMe conferences.\n"); 01513 } 01514 return CLI_SUCCESS; 01515 } 01516 /* Find the right conference */ 01517 AST_LIST_LOCK(&confs); 01518 AST_LIST_TRAVERSE(&confs, cnf, list) { 01519 if (strcmp(cnf->confno, a->argv[2]) == 0) { 01520 break; 01521 } 01522 } 01523 if (!cnf) { 01524 if (!concise) 01525 ast_cli(a->fd, "No such conference: %s.\n", a->argv[2]); 01526 AST_LIST_UNLOCK(&confs); 01527 return CLI_SUCCESS; 01528 } 01529 /* Show all the users */ 01530 time(&now); 01531 user_iter = ao2_iterator_init(cnf->usercontainer, 0); 01532 while((user = ao2_iterator_next(&user_iter))) { 01533 hr = (now - user->jointime) / 3600; 01534 min = ((now - user->jointime) % 3600) / 60; 01535 sec = (now - user->jointime) % 60; 01536 if (!concise) { 01537 ast_cli(a->fd, "User #: %-2.2d %12.12s %-20.20s Channel: %s %s %s %s %s %s %02d:%02d:%02d\n", 01538 user->user_no, 01539 S_COR(user->chan->caller.id.number.valid, user->chan->caller.id.number.str, "<unknown>"), 01540 S_COR(user->chan->caller.id.name.valid, user->chan->caller.id.name.str, "<no name>"), 01541 user->chan->name, 01542 ast_test_flag64(&user->userflags, CONFFLAG_ADMIN) ? "(Admin)" : "", 01543 ast_test_flag64(&user->userflags, CONFFLAG_MONITOR) ? "(Listen only)" : "", 01544 user->adminflags & ADMINFLAG_MUTED ? "(Admin Muted)" : user->adminflags & ADMINFLAG_SELFMUTED ? "(Muted)" : "", 01545 user->adminflags & ADMINFLAG_T_REQUEST ? "(Request to Talk)" : "", 01546 istalking(user->talking), hr, min, sec); 01547 } else { 01548 ast_cli(a->fd, "%d!%s!%s!%s!%s!%s!%s!%s!%d!%02d:%02d:%02d\n", 01549 user->user_no, 01550 S_COR(user->chan->caller.id.number.valid, user->chan->caller.id.number.str, ""), 01551 S_COR(user->chan->caller.id.name.valid, user->chan->caller.id.name.str, ""), 01552 user->chan->name, 01553 ast_test_flag64(&user->userflags, CONFFLAG_ADMIN) ? "1" : "", 01554 ast_test_flag64(&user->userflags, CONFFLAG_MONITOR) ? "1" : "", 01555 user->adminflags & (ADMINFLAG_MUTED | ADMINFLAG_SELFMUTED) ? "1" : "", 01556 user->adminflags & ADMINFLAG_T_REQUEST ? "1" : "", 01557 user->talking, hr, min, sec); 01558 } 01559 ao2_ref(user, -1); 01560 } 01561 ao2_iterator_destroy(&user_iter); 01562 if (!concise) { 01563 ast_cli(a->fd, "%d users in that conference.\n", cnf->users); 01564 } 01565 AST_LIST_UNLOCK(&confs); 01566 return CLI_SUCCESS; 01567 } 01568 return CLI_SHOWUSAGE; 01569 }
| static int meetmemute | ( | struct mansession * | s, | |
| const struct message * | m, | |||
| int | mute | |||
| ) | [static] |
Definition at line 4838 of file app_meetme.c.
References ADMINFLAG_MUTED, ADMINFLAG_SELFMUTED, ADMINFLAG_T_REQUEST, ast_conf_user::adminflags, ao2_find, ao2_ref, AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, ast_log(), ast_strdupa, ast_strlen_zero(), astman_get_header(), astman_send_ack(), astman_send_error(), ast_conf_user::chan, ast_conference::confno, LOG_NOTICE, ast_conf_user::user_no, and ast_conference::usercontainer.
Referenced by action_meetmemute(), and action_meetmeunmute().
04839 { 04840 struct ast_conference *conf; 04841 struct ast_conf_user *user; 04842 const char *confid = astman_get_header(m, "Meetme"); 04843 char *userid = ast_strdupa(astman_get_header(m, "Usernum")); 04844 int userno; 04845 04846 if (ast_strlen_zero(confid)) { 04847 astman_send_error(s, m, "Meetme conference not specified"); 04848 return 0; 04849 } 04850 04851 if (ast_strlen_zero(userid)) { 04852 astman_send_error(s, m, "Meetme user number not specified"); 04853 return 0; 04854 } 04855 04856 userno = strtoul(userid, &userid, 10); 04857 04858 if (*userid) { 04859 astman_send_error(s, m, "Invalid user number"); 04860 return 0; 04861 } 04862 04863 /* Look in the conference list */ 04864 AST_LIST_LOCK(&confs); 04865 AST_LIST_TRAVERSE(&confs, conf, list) { 04866 if (!strcmp(confid, conf->confno)) 04867 break; 04868 } 04869 04870 if (!conf) { 04871 AST_LIST_UNLOCK(&confs); 04872 astman_send_error(s, m, "Meetme conference does not exist"); 04873 return 0; 04874 } 04875 04876 user = ao2_find(conf->usercontainer, &userno, 0); 04877 04878 if (!user) { 04879 AST_LIST_UNLOCK(&confs); 04880 astman_send_error(s, m, "User number not found"); 04881 return 0; 04882 } 04883 04884 if (mute) 04885 user->adminflags |= ADMINFLAG_MUTED; /* request user muting */ 04886 else 04887 user->adminflags &= ~(ADMINFLAG_MUTED | ADMINFLAG_SELFMUTED | ADMINFLAG_T_REQUEST); /* request user unmuting */ 04888 04889 AST_LIST_UNLOCK(&confs); 04890 04891 ast_log(LOG_NOTICE, "Requested to %smute conf %s user %d userchan %s uniqueid %s\n", mute ? "" : "un", conf->confno, user->user_no, user->chan->name, user->chan->uniqueid); 04892 04893 ao2_ref(user, -1); 04894 astman_send_ack(s, m, mute ? "User muted" : "User unmuted"); 04895 return 0; 04896 }
| static enum ast_device_state meetmestate | ( | const char * | data | ) | [static] |
Callback for devicestate providers.
Definition at line 5077 of file app_meetme.c.
References AST_DEVICE_INUSE, AST_DEVICE_INVALID, AST_DEVICE_NOT_INUSE, AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, ast_conference::confno, and ast_conference::users.
Referenced by load_module().
05078 { 05079 struct ast_conference *conf; 05080 05081 /* Find conference */ 05082 AST_LIST_LOCK(&confs); 05083 AST_LIST_TRAVERSE(&confs, conf, list) { 05084 if (!strcmp(data, conf->confno)) 05085 break; 05086 } 05087 AST_LIST_UNLOCK(&confs); 05088 if (!conf) 05089 return AST_DEVICE_INVALID; 05090 05091 05092 /* SKREP to fill */ 05093 if (!conf->users) 05094 return AST_DEVICE_NOT_INUSE; 05095 05096 return AST_DEVICE_INUSE; 05097 }
| static struct sla_ringing_trunk* queue_ringing_trunk | ( | struct sla_trunk * | trunk | ) | [static, read] |
Definition at line 6426 of file app_meetme.c.
References ALL_TRUNK_REFS, ast_calloc, AST_LIST_INSERT_HEAD, ast_mutex_lock, ast_mutex_unlock, ast_tvnow(), sla_ringing_trunk::ring_begin, sla, sla_change_trunk_state(), SLA_EVENT_RINGING_TRUNK, sla_queue_event(), SLA_TRUNK_STATE_RINGING, and sla_ringing_trunk::trunk.
Referenced by sla_trunk_exec().
06427 { 06428 struct sla_ringing_trunk *ringing_trunk; 06429 06430 if (!(ringing_trunk = ast_calloc(1, sizeof(*ringing_trunk)))) 06431 return NULL; 06432 06433 ringing_trunk->trunk = trunk; 06434 ringing_trunk->ring_begin = ast_tvnow(); 06435 06436 sla_change_trunk_state(trunk, SLA_TRUNK_STATE_RINGING, ALL_TRUNK_REFS, NULL); 06437 06438 ast_mutex_lock(&sla.lock); 06439 AST_LIST_INSERT_HEAD(&sla.ringing_trunks, ringing_trunk, entry); 06440 ast_mutex_unlock(&sla.lock); 06441 06442 sla_queue_event(SLA_EVENT_RINGING_TRUNK); 06443 06444 return ringing_trunk; 06445 }
| static void * recordthread | ( | void * | args | ) | [static] |
Definition at line 5008 of file app_meetme.c.
References ast_closestream(), AST_FILE_MODE, AST_FRAME_BITS, AST_FRAME_VOICE, ast_frdup(), ast_frfree, AST_LIST_LOCK, AST_LIST_UNLOCK, ast_mutex_lock, ast_mutex_unlock, ast_read(), ast_stopstream(), ast_strlen_zero(), ast_waitfor(), ast_writefile(), ast_writestream(), f, filename_parse(), ast_frame::flags, ast_frame::frametype, ast_conference::lchan, ast_conference::listenlock, MEETME_RECORD_ACTIVE, MEETME_RECORD_OFF, MEETME_RECORD_TERMINATE, ast_conference::origframe, ast_conference::recordingfilename, ast_conference::recordingformat, and ast_conference::transframe.
05009 { 05010 struct ast_conference *cnf = args; 05011 struct ast_frame *f = NULL; 05012 int flags; 05013 struct ast_filestream *s = NULL; 05014 int res = 0; 05015 int x; 05016 const char *oldrecordingfilename = NULL; 05017 char filename_buffer[PATH_MAX]; 05018 05019 if (!cnf || !cnf->lchan) { 05020 pthread_exit(0); 05021 } 05022 05023 filename_buffer[0] = '\0'; 05024 filename_parse(cnf->recordingfilename, filename_buffer); 05025 05026 ast_stopstream(cnf->lchan); 05027 flags = O_CREAT | O_TRUNC | O_WRONLY; 05028 05029 05030 cnf->recording = MEETME_RECORD_ACTIVE; 05031 while (ast_waitfor(cnf->lchan, -1) > -1) { 05032 if (cnf->recording == MEETME_RECORD_TERMINATE) { 05033 AST_LIST_LOCK(&confs); 05034 AST_LIST_UNLOCK(&confs); 05035 break; 05036 } 05037 if (!s && !(ast_strlen_zero(filename_buffer)) && (filename_buffer != oldrecordingfilename)) { 05038 s = ast_writefile(filename_buffer, cnf->recordingformat, NULL, flags, 0, AST_FILE_MODE); 05039 oldrecordingfilename = filename_buffer; 05040 } 05041 05042 f = ast_read(cnf->lchan); 05043 if (!f) { 05044 res = -1; 05045 break; 05046 } 05047 if (f->frametype == AST_FRAME_VOICE) { 05048 ast_mutex_lock(&cnf->listenlock); 05049 for (x = 0; x < AST_FRAME_BITS; x++) { 05050 /* Free any translations that have occured */ 05051 if (cnf->transframe[x]) { 05052 ast_frfree(cnf->transframe[x]); 05053 cnf->transframe[x] = NULL; 05054 } 05055 } 05056 if (cnf->origframe) 05057 ast_frfree(cnf->origframe); 05058 cnf->origframe = ast_frdup(f); 05059 ast_mutex_unlock(&cnf->listenlock); 05060 if (s) 05061 res = ast_writestream(s, f); 05062 if (res) { 05063 ast_frfree(f); 05064 break; 05065 } 05066 } 05067 ast_frfree(f); 05068 } 05069 cnf->recording = MEETME_RECORD_OFF; 05070 if (s) 05071 ast_closestream(s); 05072 05073 pthread_exit(0); 05074 }
| static int reload | ( | void | ) | [static] |
Definition at line 7332 of file app_meetme.c.
References ast_unload_realtime(), and load_config().
07333 { 07334 ast_unload_realtime("meetme"); 07335 return load_config(1); 07336 }
| static void reset_volumes | ( | struct ast_conf_user * | user | ) | [static] |
Definition at line 1104 of file app_meetme.c.
References ast_channel_setoption(), AST_OPTION_RXGAIN, AST_OPTION_TXGAIN, and ast_conf_user::chan.
Referenced by admin_exec(), conf_run(), and user_reset_vol_cb().
01105 { 01106 signed char zero_volume = 0; 01107 01108 ast_channel_setoption(user->chan, AST_OPTION_TXGAIN, &zero_volume, sizeof(zero_volume), 0); 01109 ast_channel_setoption(user->chan, AST_OPTION_RXGAIN, &zero_volume, sizeof(zero_volume), 0); 01110 }
| static int rt_extend_conf | ( | const char * | confno | ) | [static] |
Definition at line 2068 of file app_meetme.c.
References ast_copy_string(), ast_debug, ast_load_realtime(), ast_localtime(), ast_mktime(), ast_strftime(), ast_strptime(), ast_tvnow(), ast_update_realtime(), ast_variables_destroy(), ast_conference::bookid, DATE_FORMAT, ast_conference::endtime, ast_variable::name, ast_variable::next, ast_variable::value, and var.
Referenced by admin_exec(), and conf_run().
02069 { 02070 char currenttime[32]; 02071 char endtime[32]; 02072 struct timeval now; 02073 struct ast_tm tm; 02074 struct ast_variable *var, *orig_var; 02075 char bookid[51]; 02076 02077 if (!extendby) { 02078 return 0; 02079 } 02080 02081 now = ast_tvnow(); 02082 02083 ast_localtime(&now, &tm, NULL); 02084 ast_strftime(currenttime, sizeof(currenttime), DATE_FORMAT, &tm); 02085 02086 var = ast_load_realtime("meetme", "confno", 02087 confno, "startTime<= ", currenttime, 02088 "endtime>= ", currenttime, NULL); 02089 02090 orig_var = var; 02091 02092 /* Identify the specific RealTime conference */ 02093 while (var) { 02094 if (!strcasecmp(var->name, "bookid")) { 02095 ast_copy_string(bookid, var->value, sizeof(bookid)); 02096 } 02097 if (!strcasecmp(var->name, "endtime")) { 02098 ast_copy_string(endtime, var->value, sizeof(endtime)); 02099 } 02100 02101 var = var->next; 02102 } 02103 ast_variables_destroy(orig_var); 02104 02105 ast_strptime(endtime, DATE_FORMAT, &tm); 02106 now = ast_mktime(&tm, NULL); 02107 02108 now.tv_sec += extendby; 02109 02110 ast_localtime(&now, &tm, NULL); 02111 ast_strftime(currenttime, sizeof(currenttime), DATE_FORMAT, &tm); 02112 strcat(currenttime, "0"); /* Seconds needs to be 00 */ 02113 02114 var = ast_load_realtime("meetme", "confno", 02115 confno, "startTime<= ", currenttime, 02116 "endtime>= ", currenttime, NULL); 02117 02118 /* If there is no conflict with extending the conference, update the DB */ 02119 if (!var) { 02120 ast_debug(3, "Trying to update the endtime of Conference %s to %s\n", confno, currenttime); 02121 ast_update_realtime("meetme", "bookid", bookid, "endtime", currenttime, NULL); 02122 return 0; 02123 02124 } 02125 02126 ast_variables_destroy(var); 02127 return -1; 02128 }
| static void* run_station | ( | void * | data | ) | [static] |
Definition at line 5326 of file app_meetme.c.
References admin_exec(), ALL_TRUNK_REFS, answer_trunk_chan(), args, ast_atomic_dec_and_test(), ast_atomic_fetchadd_int(), ast_cond_signal, ast_dial_destroy(), ast_dial_join(), ast_free, ast_mutex_lock, ast_mutex_unlock, ast_set_flag64, ast_str_append(), ast_str_buffer(), ast_str_create(), ast_str_set(), build_conf(), run_station_args::cond, run_station_args::cond_lock, conf_run(), CONFFLAG_MARKEDEXIT, CONFFLAG_PASS_DTMF, CONFFLAG_QUIET, CONFFLAG_SLA_STATION, dispose_conf(), sla_change_trunk_state(), SLA_TRUNK_STATE_IDLE, SLA_TRUNK_STATE_ONHOLD_BYME, run_station_args::station, and run_station_args::trunk_ref.
Referenced by sla_handle_dial_state_event().
05327 { 05328 struct sla_station *station; 05329 struct sla_trunk_ref *trunk_ref; 05330 struct ast_str *conf_name = ast_str_create(16); 05331 struct ast_flags64 conf_flags = { 0 }; 05332 struct ast_conference *conf; 05333 05334 { 05335 struct run_station_args *args = data; 05336 station = args->station; 05337 trunk_ref = args->trunk_ref; 05338 ast_mutex_lock(args->cond_lock); 05339 ast_cond_signal(args->cond); 05340 ast_mutex_unlock(args->cond_lock); 05341 /* args is no longer valid here. */ 05342 } 05343 05344 ast_atomic_fetchadd_int((int *) &trunk_ref->trunk->active_stations, 1); 05345 ast_str_set(&conf_name, 0, "SLA_%s", trunk_ref->trunk->name); 05346 ast_set_flag64(&conf_flags, 05347 CONFFLAG_QUIET | CONFFLAG_MARKEDEXIT | CONFFLAG_PASS_DTMF | CONFFLAG_SLA_STATION); 05348 answer_trunk_chan(trunk_ref->chan); 05349 conf = build_conf(ast_str_buffer(conf_name), "", "", 0, 0, 1, trunk_ref->chan, NULL); 05350 if (conf) { 05351 conf_run(trunk_ref->chan, conf, &conf_flags, NULL); 05352 dispose_conf(conf); 05353 conf = NULL; 05354 } 05355 trunk_ref->chan = NULL; 05356 if (ast_atomic_dec_and_test((int *) &trunk_ref->trunk->active_stations) && 05357 trunk_ref->state != SLA_TRUNK_STATE_ONHOLD_BYME) { 05358 ast_str_append(&conf_name, 0, ",K"); 05359 admin_exec(NULL, ast_str_buffer(conf_name)); 05360 trunk_ref->trunk->hold_stations = 0; 05361 sla_change_trunk_state(trunk_ref->trunk, SLA_TRUNK_STATE_IDLE, ALL_TRUNK_REFS, NULL); 05362 } 05363 05364 ast_dial_join(station->dial); 05365 ast_dial_destroy(station->dial); 05366 station->dial = NULL; 05367 ast_free(conf_name); 05368 05369 return NULL; 05370 }
| static void send_talking_event | ( | struct ast_channel * | chan, | |
| struct ast_conference * | conf, | |||
| struct ast_conf_user * | user, | |||
| int | talking | |||
| ) | [static] |
Definition at line 2222 of file app_meetme.c.
References ast_manager_event, ast_conference::confno, EVENT_FLAG_CALL, and ast_conf_user::user_no.
Referenced by set_user_talking().
02223 { 02224 ast_manager_event(chan, EVENT_FLAG_CALL, "MeetmeTalking", 02225 "Channel: %s\r\n" 02226 "Uniqueid: %s\r\n" 02227 "Meetme: %s\r\n" 02228 "Usernum: %d\r\n" 02229 "Status: %s\r\n", 02230 chan->name, chan->uniqueid, conf->confno, user->user_no, talking ? "on" : "off"); 02231 }
| static int set_listen_volume | ( | struct ast_conf_user * | user, | |
| int | volume | |||
| ) | [static] |
Definition at line 1033 of file app_meetme.c.
References ast_channel_setoption(), AST_OPTION_TXGAIN, and ast_conf_user::chan.
Referenced by tweak_listen_volume().
01034 { 01035 char gain_adjust; 01036 01037 /* attempt to make the adjustment in the channel driver; 01038 if successful, don't adjust in the frame reading routine 01039 */ 01040 gain_adjust = gain_map[volume + 5]; 01041 01042 return ast_channel_setoption(user->chan, AST_OPTION_TXGAIN, &gain_adjust, sizeof(gain_adjust), 0); 01043 }
| static int set_talk_volume | ( | struct ast_conf_user * | user, | |
| int | volume | |||
| ) | [static] |
Definition at line 1021 of file app_meetme.c.
References ast_channel_setoption(), AST_OPTION_RXGAIN, and ast_conf_user::chan.
Referenced by conf_run(), and tweak_talk_volume().
01022 { 01023 char gain_adjust; 01024 01025 /* attempt to make the adjustment in the channel driver; 01026 if successful, don't adjust in the frame reading routine 01027 */ 01028 gain_adjust = gain_map[volume + 5]; 01029 01030 return ast_channel_setoption(user->chan, AST_OPTION_RXGAIN, &gain_adjust, sizeof(gain_adjust), 0); 01031 }
| static void set_user_talking | ( | struct ast_channel * | chan, | |
| struct ast_conference * | conf, | |||
| struct ast_conf_user * | user, | |||
| int | talking, | |||
| int | monitor | |||
| ) | [static] |
Definition at line 2233 of file app_meetme.c.
References send_talking_event(), and ast_conf_user::talking.
Referenced by conf_run().
02234 { 02235 int last_talking = user->talking; 02236 if (last_talking == talking) 02237 return; 02238 02239 user->talking = talking; 02240 02241 if (monitor) { 02242 /* Check if talking state changed. Take care of -1 which means unmonitored */ 02243 int was_talking = (last_talking > 0); 02244 int now_talking = (talking > 0); 02245 if (was_talking != now_talking) { 02246 send_talking_event(chan, conf, user, now_talking); 02247 } 02248 } 02249 }
| static void sla_add_trunk_to_station | ( | struct sla_station * | station, | |
| struct ast_variable * | var | |||
| ) | [static] |
Definition at line 6766 of file app_meetme.c.
References ast_atomic_fetchadd_int(), ast_free, AST_LIST_INSERT_TAIL, ast_log(), AST_RWLIST_RDLOCK, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, ast_strdupa, create_trunk_ref(), LOG_ERROR, LOG_WARNING, name, sla_create_station_ref(), SLA_TRUNK_STATE_IDLE, value, and ast_variable::value.
Referenced by sla_build_station().
06767 { 06768 struct sla_trunk *trunk; 06769 struct sla_trunk_ref *trunk_ref; 06770 struct sla_station_ref *station_ref; 06771 char *trunk_name, *options, *cur; 06772 06773 options = ast_strdupa(var->value); 06774 trunk_name = strsep(&options, ","); 06775 06776 AST_RWLIST_RDLOCK(&sla_trunks); 06777 AST_RWLIST_TRAVERSE(&sla_trunks, trunk, entry) { 06778 if (!strcasecmp(trunk->name, trunk_name)) 06779 break; 06780 } 06781 06782 AST_RWLIST_UNLOCK(&sla_trunks); 06783 if (!trunk) { 06784 ast_log(LOG_ERROR, "Trunk '%s' not found!\n", var->value); 06785 return; 06786 } 06787 if (!(trunk_ref = create_trunk_ref(trunk))) 06788 return; 06789 trunk_ref->state = SLA_TRUNK_STATE_IDLE; 06790 06791 while ((cur = strsep(&options, ","))) { 06792 char *name, *value = cur; 06793 name = strsep(&value, "="); 06794 if (!strcasecmp(name, "ringtimeout")) { 06795 if (sscanf(value, "%30u", &trunk_ref->ring_timeout) != 1) { 06796 ast_log(LOG_WARNING, "Invalid ringtimeout value '%s' for " 06797 "trunk '%s' on station '%s'\n", value, trunk->name, station->name); 06798 trunk_ref->ring_timeout = 0; 06799 } 06800 } else if (!strcasecmp(name, "ringdelay")) { 06801 if (sscanf(value, "%30u", &trunk_ref->ring_delay) != 1) { 06802 ast_log(LOG_WARNING, "Invalid ringdelay value '%s' for " 06803 "trunk '%s' on station '%s'\n", value, trunk->name, station->name); 06804 trunk_ref->ring_delay = 0; 06805 } 06806 } else { 06807 ast_log(LOG_WARNING, "Invalid option '%s' for " 06808 "trunk '%s' on station '%s'\n", name, trunk->name, station->name); 06809 } 06810 } 06811 06812 if (!(station_ref = sla_create_station_ref(station))) { 06813 ast_free(trunk_ref); 06814 return; 06815 } 06816 ast_atomic_fetchadd_int((int *) &trunk->num_stations, 1); 06817 AST_RWLIST_WRLOCK(&sla_trunks); 06818 AST_LIST_INSERT_TAIL(&trunk->stations, station_ref, entry); 06819 AST_RWLIST_UNLOCK(&sla_trunks); 06820 AST_LIST_INSERT_TAIL(&station->trunks, trunk_ref, entry); 06821 }
| static int sla_build_station | ( | struct ast_config * | cfg, | |
| const char * | cat | |||
| ) | [static] |
Definition at line 6823 of file app_meetme.c.
References ast_add_extension2(), ast_calloc_with_stringfields, ast_context_find_or_create(), ast_free_ptr(), AST_LIST_TRAVERSE, ast_log(), AST_MAX_APP, AST_MAX_EXTENSION, AST_RWLIST_INSERT_TAIL, AST_RWLIST_RDLOCK, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, ast_strdup, ast_string_field_set, ast_strlen_zero(), ast_variable_browse(), ast_variable_retrieve(), context, destroy_station(), exten, ast_variable::lineno, LOG_ERROR, LOG_WARNING, ast_variable::name, name, ast_variable::next, PRIORITY_HINT, sla_add_trunk_to_station(), SLA_CONFIG_FILE, SLA_HOLD_OPEN, SLA_HOLD_PRIVATE, sla_registrar, ast_variable::value, and var.
Referenced by sla_load_config().
06824 { 06825 struct sla_station *station; 06826 struct ast_variable *var; 06827 const char *dev; 06828 06829 if (!(dev = ast_variable_retrieve(cfg, cat, "device"))) { 06830 ast_log(LOG_ERROR, "SLA Station '%s' defined with no device!\n", cat); 06831 return -1; 06832 } 06833 06834 if (!(station = ast_calloc_with_stringfields(1, struct sla_station, 32))) { 06835 return -1; 06836 } 06837 06838 ast_string_field_set(station, name, cat); 06839 ast_string_field_set(station, device, dev); 06840 06841 for (var = ast_variable_browse(cfg, cat); var; var = var->next) { 06842 if (!strcasecmp(var->name, "trunk")) 06843 sla_add_trunk_to_station(station, var); 06844 else if (!strcasecmp(var->name, "autocontext")) 06845 ast_string_field_set(station, autocontext, var->value); 06846 else if (!strcasecmp(var->name, "ringtimeout")) { 06847 if (sscanf(var->value, "%30u", &station->ring_timeout) != 1) { 06848 ast_log(LOG_WARNING, "Invalid ringtimeout '%s' specified for station '%s'\n", 06849 var->value, station->name); 06850 station->ring_timeout = 0; 06851 } 06852 } else if (!strcasecmp(var->name, "ringdelay")) { 06853 if (sscanf(var->value, "%30u", &station->ring_delay) != 1) { 06854 ast_log(LOG_WARNING, "Invalid ringdelay '%s' specified for station '%s'\n", 06855 var->value, station->name); 06856 station->ring_delay = 0; 06857 } 06858 } else if (!strcasecmp(var->name, "hold")) { 06859 if (!strcasecmp(var->value, "private")) 06860 station->hold_access = SLA_HOLD_PRIVATE; 06861 else if (!strcasecmp(var->value, "open")) 06862 station->hold_access = SLA_HOLD_OPEN; 06863 else { 06864 ast_log(LOG_WARNING, "Invalid value '%s' for hold on station %s\n", 06865 var->value, station->name); 06866 } 06867 06868 } else if (strcasecmp(var->name, "type") && strcasecmp(var->name, "device")) { 06869 ast_log(LOG_ERROR, "Invalid option '%s' specified at line %d of %s!\n", 06870 var->name, var->lineno, SLA_CONFIG_FILE); 06871 } 06872 } 06873 06874 if (!ast_strlen_zero(station->autocontext)) { 06875 struct ast_context *context; 06876 struct sla_trunk_ref *trunk_ref; 06877 context = ast_context_find_or_create(NULL, NULL, station->autocontext, sla_registrar); 06878 if (!context) { 06879 ast_log(LOG_ERROR, "Failed to automatically find or create " 06880 "context '%s' for SLA!\n", station->autocontext); 06881 destroy_station(station); 06882 return -1; 06883 } 06884 /* The extension for when the handset goes off-hook. 06885 * exten => station1,1,SLAStation(station1) */ 06886 if (ast_add_extension2(context, 0 /* don't replace */, station->name, 1, 06887 NULL, NULL, slastation_app, ast_strdup(station->name), ast_free_ptr, sla_registrar)) { 06888 ast_log(LOG_ERROR, "Failed to automatically create extension " 06889 "for trunk '%s'!\n", station->name); 06890 destroy_station(station); 06891 return -1; 06892 } 06893 AST_RWLIST_RDLOCK(&sla_trunks); 06894 AST_LIST_TRAVERSE(&station->trunks, trunk_ref, entry) { 06895 char exten[AST_MAX_EXTENSION]; 06896 char hint[AST_MAX_APP]; 06897 snprintf(exten, sizeof(exten), "%s_%s", station->name, trunk_ref->trunk->name); 06898 snprintf(hint, sizeof(hint), "SLA:%s", exten); 06899 /* Extension for this line button 06900 * exten => station1_line1,1,SLAStation(station1_line1) */ 06901 if (ast_add_extension2(context, 0 /* don't replace */, exten, 1, 06902 NULL, NULL, slastation_app, ast_strdup(exten), ast_free_ptr, sla_registrar)) { 06903 ast_log(LOG_ERROR, "Failed to automatically create extension " 06904 "for trunk '%s'!\n", station->name); 06905 destroy_station(station); 06906 return -1; 06907 } 06908 /* Hint for this line button 06909 * exten => station1_line1,hint,SLA:station1_line1 */ 06910 if (ast_add_extension2(context, 0 /* don't replace */, exten, PRIORITY_HINT, 06911 NULL, NULL, hint, NULL, NULL, sla_registrar)) { 06912 ast_log(LOG_ERROR, "Failed to automatically create hint " 06913 "for trunk '%s'!\n", station->name); 06914 destroy_station(station); 06915 return -1; 06916 } 06917 } 06918 AST_RWLIST_UNLOCK(&sla_trunks); 06919 } 06920 06921 AST_RWLIST_WRLOCK(&sla_stations); 06922 AST_RWLIST_INSERT_TAIL(&sla_stations, station, entry); 06923 AST_RWLIST_UNLOCK(&sla_stations); 06924 06925 return 0; 06926 }
| static int sla_build_trunk | ( | struct ast_config * | cfg, | |
| const char * | cat | |||
| ) | [static] |
Definition at line 6691 of file app_meetme.c.
References ast_add_extension2(), ast_calloc_with_stringfields, ast_context_find_or_create(), ast_false(), ast_free_ptr(), ast_log(), AST_RWLIST_INSERT_TAIL, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, ast_strdup, ast_string_field_set, ast_strlen_zero(), ast_variable_browse(), ast_variable_retrieve(), context, destroy_trunk(), ast_variable::lineno, LOG_ERROR, LOG_WARNING, ast_variable::name, name, ast_variable::next, sla_check_device(), SLA_CONFIG_FILE, SLA_HOLD_OPEN, SLA_HOLD_PRIVATE, sla_registrar, ast_variable::value, and var.
Referenced by sla_load_config().
06692 { 06693 struct sla_trunk *trunk; 06694 struct ast_variable *var; 06695 const char *dev; 06696 06697 if (!(dev = ast_variable_retrieve(cfg, cat, "device"))) { 06698 ast_log(LOG_ERROR, "SLA Trunk '%s' defined with no device!\n", cat); 06699 return -1; 06700 } 06701 06702 if (sla_check_device(dev)) { 06703 ast_log(LOG_ERROR, "SLA Trunk '%s' define with invalid device '%s'!\n", 06704 cat, dev); 06705 return -1; 06706 } 06707 06708 if (!(trunk = ast_calloc_with_stringfields(1, struct sla_trunk, 32))) { 06709 return -1; 06710 } 06711 06712 ast_string_field_set(trunk, name, cat); 06713 ast_string_field_set(trunk, device, dev); 06714 06715 for (var = ast_variable_browse(cfg, cat); var; var = var->next) { 06716 if (!strcasecmp(var->name, "autocontext")) 06717 ast_string_field_set(trunk, autocontext, var->value); 06718 else if (!strcasecmp(var->name, "ringtimeout")) { 06719 if (sscanf(var->value, "%30u", &trunk->ring_timeout) != 1) { 06720 ast_log(LOG_WARNING, "Invalid ringtimeout '%s' specified for trunk '%s'\n", 06721 var->value, trunk->name); 06722 trunk->ring_timeout = 0; 06723 } 06724 } else if (!strcasecmp(var->name, "barge")) 06725 trunk->barge_disabled = ast_false(var->value); 06726 else if (!strcasecmp(var->name, "hold")) { 06727 if (!strcasecmp(var->value, "private")) 06728 trunk->hold_access = SLA_HOLD_PRIVATE; 06729 else if (!strcasecmp(var->value, "open")) 06730 trunk->hold_access = SLA_HOLD_OPEN; 06731 else { 06732 ast_log(LOG_WARNING, "Invalid value '%s' for hold on trunk %s\n", 06733 var->value, trunk->name); 06734 } 06735 } else if (strcasecmp(var->name, "type") && strcasecmp(var->name, "device")) { 06736 ast_log(LOG_ERROR, "Invalid option '%s' specified at line %d of %s!\n", 06737 var->name, var->lineno, SLA_CONFIG_FILE); 06738 } 06739 } 06740 06741 if (!ast_strlen_zero(trunk->autocontext)) { 06742 struct ast_context *context; 06743 context = ast_context_find_or_create(NULL, NULL, trunk->autocontext, sla_registrar); 06744 if (!context) { 06745 ast_log(LOG_ERROR, "Failed to automatically find or create " 06746 "context '%s' for SLA!\n", trunk->autocontext); 06747 destroy_trunk(trunk); 06748 return -1; 06749 } 06750 if (ast_add_extension2(context, 0 /* don't replace */, "s", 1, 06751 NULL, NULL, slatrunk_app, ast_strdup(trunk->name), ast_free_ptr, sla_registrar)) { 06752 ast_log(LOG_ERROR, "Failed to automatically create extension " 06753 "for trunk '%s'!\n", trunk->name); 06754 destroy_trunk(trunk); 06755 return -1; 06756 } 06757 } 06758 06759 AST_RWLIST_WRLOCK(&sla_trunks); 06760 AST_RWLIST_INSERT_TAIL(&sla_trunks, trunk, entry); 06761 AST_RWLIST_UNLOCK(&sla_trunks); 06762 06763 return 0; 06764 }
| static int sla_calc_station_delays | ( | unsigned int * | timeout | ) | [static] |
Calculate the ring delay for a station.
Definition at line 5938 of file app_meetme.c.
References AST_LIST_TRAVERSE, sla_check_inuse_station(), sla_check_ringing_station(), sla_check_station_delay(), and sla_choose_ringing_trunk().
Referenced by sla_process_timers().
05939 { 05940 struct sla_station *station; 05941 int res = 0; 05942 05943 AST_LIST_TRAVERSE(&sla_stations, station, entry) { 05944 struct sla_ringing_trunk *ringing_trunk; 05945 int time_left; 05946 05947 /* Ignore stations already ringing */ 05948 if (sla_check_ringing_station(station)) 05949 continue; 05950 05951 /* Ignore stations already on a call */ 05952 if (sla_check_inuse_station(station)) 05953 continue; 05954 05955 /* Ignore stations that don't have one of their trunks ringing */ 05956 if (!(ringing_trunk = sla_choose_ringing_trunk(station, NULL, 0))) 05957 continue; 05958 05959 if ((time_left = sla_check_station_delay(station, ringing_trunk)) == INT_MAX) 05960 continue; 05961 05962 /* If there is no time left, then the station needs to start ringing. 05963 * Return non-zero so that an event will be queued up an event to 05964 * make that happen. */ 05965 if (time_left <= 0) { 05966 res = 1; 05967 continue; 05968 } 05969 05970 if (time_left < *timeout) 05971 *timeout = time_left; 05972 } 05973 05974 return res; 05975 }
| static int sla_calc_station_timeouts | ( | unsigned int * | timeout | ) | [static] |
Process station ring timeouts.
Definition at line 5855 of file app_meetme.c.
References AST_LIST_REMOVE_CURRENT, AST_LIST_TRAVERSE, AST_LIST_TRAVERSE_SAFE_BEGIN, AST_LIST_TRAVERSE_SAFE_END, ast_tvdiff_ms(), ast_tvnow(), sla_ringing_station::ring_begin, sla_ringing_trunk::ring_begin, sla, SLA_STATION_HANGUP_TIMEOUT, sla_stop_ringing_station(), sla_ringing_station::station, and sla_ringing_trunk::trunk.
Referenced by sla_process_timers().
05856 { 05857 struct sla_ringing_trunk *ringing_trunk; 05858 struct sla_ringing_station *ringing_station; 05859 int res = 0; 05860 05861 AST_LIST_TRAVERSE_SAFE_BEGIN(&sla.ringing_stations, ringing_station, entry) { 05862 unsigned int ring_timeout = 0; 05863 int time_elapsed, time_left = INT_MAX, final_trunk_time_left = INT_MIN; 05864 struct sla_trunk_ref *trunk_ref; 05865 05866 /* If there are any ring timeouts specified for a specific trunk 05867 * on the station, then use the highest per-trunk ring timeout. 05868 * Otherwise, use the ring timeout set for the entire station. */ 05869 AST_LIST_TRAVERSE(&ringing_station->station->trunks, trunk_ref, entry) { 05870 struct sla_station_ref *station_ref; 05871 int trunk_time_elapsed, trunk_time_left; 05872 05873 AST_LIST_TRAVERSE(&sla.ringing_trunks, ringing_trunk, entry) { 05874 if (ringing_trunk->trunk == trunk_ref->trunk) 05875 break; 05876 } 05877 if (!ringing_trunk) 05878 continue; 05879 05880 /* If there is a trunk that is ringing without a timeout, then the 05881 * only timeout that could matter is a global station ring timeout. */ 05882 if (!trunk_ref->ring_timeout) 05883 break; 05884 05885 /* This trunk on this station is ringing and has a timeout. 05886 * However, make sure this trunk isn't still ringing from a 05887 * previous timeout. If so, don't consider it. */ 05888 AST_LIST_TRAVERSE(&ringing_trunk->timed_out_stations, station_ref, entry) { 05889 if (station_ref->station == ringing_station->station) 05890 break; 05891 } 05892 if (station_ref) 05893 continue; 05894 05895 trunk_time_elapsed = ast_tvdiff_ms(ast_tvnow(), ringing_trunk->ring_begin); 05896 trunk_time_left = (trunk_ref->ring_timeout * 1000) - trunk_time_elapsed; 05897 if (trunk_time_left > final_trunk_time_left) 05898 final_trunk_time_left = trunk_time_left; 05899 } 05900 05901 /* No timeout was found for ringing trunks, and no timeout for the entire station */ 05902 if (final_trunk_time_left == INT_MIN && !ringing_station->station->ring_timeout) 05903 continue; 05904 05905 /* Compute how much time is left for a global station timeout */ 05906 if (ringing_station->station->ring_timeout) { 05907 ring_timeout = ringing_station->station->ring_timeout; 05908 time_elapsed = ast_tvdiff_ms(ast_tvnow(), ringing_station->ring_begin); 05909 time_left = (ring_timeout * 1000) - time_elapsed; 05910 } 05911 05912 /* If the time left based on the per-trunk timeouts is smaller than the 05913 * global station ring timeout, use that. */ 05914 if (final_trunk_time_left > INT_MIN && final_trunk_time_left < time_left) 05915 time_left = final_trunk_time_left; 05916 05917 /* If there is no time left, the station needs to stop ringing */ 05918 if (time_left <= 0) { 05919 AST_LIST_REMOVE_CURRENT(entry); 05920 sla_stop_ringing_station(ringing_station, SLA_STATION_HANGUP_TIMEOUT); 05921 res = 1; 05922 continue; 05923 } 05924 05925 /* There is still some time left for this station to ring, so save that 05926 * timeout if it is the first event scheduled to occur */ 05927 if (time_left < *timeout) 05928 *timeout = time_left; 05929 } 05930 AST_LIST_TRAVERSE_SAFE_END; 05931 05932 return res; 05933 }
| static int sla_calc_trunk_timeouts | ( | unsigned int * | timeout | ) | [static] |
Process trunk ring timeouts.
Definition at line 5825 of file app_meetme.c.
References AST_LIST_REMOVE_CURRENT, AST_LIST_TRAVERSE_SAFE_BEGIN, AST_LIST_TRAVERSE_SAFE_END, ast_tvdiff_ms(), ast_tvnow(), pbx_builtin_setvar_helper(), sla_ringing_trunk::ring_begin, sla, sla_stop_ringing_trunk(), and sla_ringing_trunk::trunk.
Referenced by sla_process_timers().
05826 { 05827 struct sla_ringing_trunk *ringing_trunk; 05828 int res = 0; 05829 05830 AST_LIST_TRAVERSE_SAFE_BEGIN(&sla.ringing_trunks, ringing_trunk, entry) { 05831 int time_left, time_elapsed; 05832 if (!ringing_trunk->trunk->ring_timeout) 05833 continue; 05834 time_elapsed = ast_tvdiff_ms(ast_tvnow(), ringing_trunk->ring_begin); 05835 time_left = (ringing_trunk->trunk->ring_timeout * 1000) - time_elapsed; 05836 if (time_left <= 0) { 05837 pbx_builtin_setvar_helper(ringing_trunk->trunk->chan, "SLATRUNK_STATUS", "RINGTIMEOUT"); 05838 AST_LIST_REMOVE_CURRENT(entry); 05839 sla_stop_ringing_trunk(ringing_trunk); 05840 res = 1; 05841 continue; 05842 } 05843 if (time_left < *timeout) 05844 *timeout = time_left; 05845 } 05846 AST_LIST_TRAVERSE_SAFE_END; 05847 05848 return res; 05849 }
| static void sla_change_trunk_state | ( | const struct sla_trunk * | trunk, | |
| enum sla_trunk_state | state, | |||
| enum sla_which_trunk_refs | inactive_only, | |||
| const struct sla_trunk_ref * | exclude | |||
| ) | [static] |
Definition at line 5294 of file app_meetme.c.
References AST_DEVSTATE_CACHABLE, ast_devstate_changed(), AST_LIST_TRAVERSE, and sla_state_to_devstate().
Referenced by dial_trunk(), queue_ringing_trunk(), run_station(), sla_handle_dial_state_event(), sla_handle_hold_event(), sla_station_exec(), sla_stop_ringing_trunk(), and sla_trunk_exec().
05296 { 05297 struct sla_station *station; 05298 struct sla_trunk_ref *trunk_ref; 05299 05300 AST_LIST_TRAVERSE(&sla_stations, station, entry) { 05301 AST_LIST_TRAVERSE(&station->trunks, trunk_ref, entry) { 05302 if (trunk_ref->trunk != trunk || (inactive_only ? trunk_ref->chan : 0) 05303 || trunk_ref == exclude) 05304 continue; 05305 trunk_ref->state = state; 05306 ast_devstate_changed(sla_state_to_devstate(state), AST_DEVSTATE_CACHABLE, 05307 "SLA:%s_%s", station->name, trunk->name); 05308 break; 05309 } 05310 } 05311 }
| static int sla_check_device | ( | const char * | device | ) | [static] |
Definition at line 6678 of file app_meetme.c.
References ast_strdupa, and ast_strlen_zero().
Referenced by sla_build_trunk().
06679 { 06680 char *tech, *tech_data; 06681 06682 tech_data = ast_strdupa(device); 06683 tech = strsep(&tech_data, "/"); 06684 06685 if (ast_strlen_zero(tech) || ast_strlen_zero(tech_data)) 06686 return -1; 06687 06688 return 0; 06689 }
| static int sla_check_failed_station | ( | const struct sla_station * | station | ) | [static] |
Check to see if this station has failed to be dialed in the past minute.
Definition at line 5574 of file app_meetme.c.
References ast_free, AST_LIST_REMOVE_CURRENT, AST_LIST_TRAVERSE_SAFE_BEGIN, AST_LIST_TRAVERSE_SAFE_END, ast_tvdiff_ms(), ast_tvnow(), sla_failed_station::last_try, sla, and sla_failed_station::station.
Referenced by sla_ring_stations().
05575 { 05576 struct sla_failed_station *failed_station; 05577 int res = 0; 05578 05579 AST_LIST_TRAVERSE_SAFE_BEGIN(&sla.failed_stations, failed_station, entry) { 05580 if (station != failed_station->station) 05581 continue; 05582 if (ast_tvdiff_ms(ast_tvnow(), failed_station->last_try) > 1000) { 05583 AST_LIST_REMOVE_CURRENT(entry); 05584 ast_free(failed_station); 05585 break; 05586 } 05587 res = 1; 05588 } 05589 AST_LIST_TRAVERSE_SAFE_END 05590 05591 return res; 05592 }
| static int sla_check_inuse_station | ( | const struct sla_station * | station | ) | [static] |
Check to see if a station is in use.
Definition at line 5659 of file app_meetme.c.
References AST_LIST_TRAVERSE.
Referenced by sla_calc_station_delays(), and sla_ring_stations().
05660 { 05661 struct sla_trunk_ref *trunk_ref; 05662 05663 AST_LIST_TRAVERSE(&station->trunks, trunk_ref, entry) { 05664 if (trunk_ref->chan) 05665 return 1; 05666 } 05667 05668 return 0; 05669 }
| static void sla_check_reload | ( | void | ) | [static] |
Check if we can do a reload of SLA, and do it if we can.
Definition at line 6017 of file app_meetme.c.
References AST_LIST_EMPTY, ast_mutex_lock, ast_mutex_unlock, AST_RWLIST_RDLOCK, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, sla, and sla_load_config().
Referenced by sla_thread().
06018 { 06019 struct sla_station *station; 06020 struct sla_trunk *trunk; 06021 06022 ast_mutex_lock(&sla.lock); 06023 06024 if (!AST_LIST_EMPTY(&sla.event_q) || !AST_LIST_EMPTY(&sla.ringing_trunks) 06025 || !AST_LIST_EMPTY(&sla.ringing_stations)) { 06026 ast_mutex_unlock(&sla.lock); 06027 return; 06028 } 06029 06030 AST_RWLIST_RDLOCK(&sla_stations); 06031 AST_RWLIST_TRAVERSE(&sla_stations, station, entry) { 06032 if (station->ref_count) 06033 break; 06034 } 06035 AST_RWLIST_UNLOCK(&sla_stations); 06036 if (station) { 06037 ast_mutex_unlock(&sla.lock); 06038 return; 06039 } 06040 06041 AST_RWLIST_RDLOCK(&sla_trunks); 06042 AST_RWLIST_TRAVERSE(&sla_trunks, trunk, entry) { 06043 if (trunk->ref_count) 06044 break; 06045 } 06046 AST_RWLIST_UNLOCK(&sla_trunks); 06047 if (trunk) { 06048 ast_mutex_unlock(&sla.lock); 06049 return; 06050 } 06051 06052 /* yay */ 06053 sla_load_config(1); 06054 sla.reload = 0; 06055 06056 ast_mutex_unlock(&sla.lock); 06057 }
| static int sla_check_ringing_station | ( | const struct sla_station * | station | ) | [static] |
Check to see if this station is already ringing.
Definition at line 5559 of file app_meetme.c.
References AST_LIST_TRAVERSE, sla, and sla_ringing_station::station.
Referenced by sla_calc_station_delays(), and sla_ring_stations().
05560 { 05561 struct sla_ringing_station *ringing_station; 05562 05563 AST_LIST_TRAVERSE(&sla.ringing_stations, ringing_station, entry) { 05564 if (station == ringing_station->station) 05565 return 1; 05566 } 05567 05568 return 0; 05569 }
| static int sla_check_station_delay | ( | struct sla_station * | station, | |
| struct sla_ringing_trunk * | ringing_trunk | |||
| ) | [static] |
Calculate the ring delay for a given ringing trunk on a station.
| station | the station | |
| ringing_trunk | the trunk. If NULL, the highest priority ringing trunk will be used |
Definition at line 5689 of file app_meetme.c.
References ast_tvdiff_ms(), ast_tvnow(), sla_ringing_trunk::ring_begin, sla_choose_ringing_trunk(), sla_find_trunk_ref(), and sla_ringing_trunk::trunk.
Referenced by sla_calc_station_delays(), and sla_ring_stations().
05691 { 05692 struct sla_trunk_ref *trunk_ref; 05693 unsigned int delay = UINT_MAX; 05694 int time_left, time_elapsed; 05695 05696 if (!ringing_trunk) 05697 ringing_trunk = sla_choose_ringing_trunk(station, &trunk_ref, 0); 05698 else 05699 trunk_ref = sla_find_trunk_ref(station, ringing_trunk->trunk); 05700 05701 if (!ringing_trunk || !trunk_ref) 05702 return delay; 05703 05704 /* If this station has a ring delay specific to the highest priority 05705 * ringing trunk, use that. Otherwise, use the ring delay specified 05706 * globally for the station. */ 05707 delay = trunk_ref->ring_delay; 05708 if (!delay) 05709 delay = station->ring_delay; 05710 if (!delay) 05711 return INT_MAX; 05712 05713 time_elapsed = ast_tvdiff_ms(ast_tvnow(), ringing_trunk->ring_begin); 05714 time_left = (delay * 1000) - time_elapsed; 05715 05716 return time_left; 05717 }
| static int sla_check_station_hold_access | ( | const struct sla_trunk * | trunk, | |
| const struct sla_station * | station | |||
| ) | [static] |
Definition at line 5199 of file app_meetme.c.
References AST_LIST_TRAVERSE, SLA_HOLD_PRIVATE, and SLA_TRUNK_STATE_ONHOLD_BYME.
Referenced by sla_find_trunk_ref_byname().
05201 { 05202 struct sla_station_ref *station_ref; 05203 struct sla_trunk_ref *trunk_ref; 05204 05205 /* For each station that has this call on hold, check for private hold. */ 05206 AST_LIST_TRAVERSE(&trunk->stations, station_ref, entry) { 05207 AST_LIST_TRAVERSE(&station_ref->station->trunks, trunk_ref, entry) { 05208 if (trunk_ref->trunk != trunk || station_ref->station == station) 05209 continue; 05210 if (trunk_ref->state == SLA_TRUNK_STATE_ONHOLD_BYME && 05211 station_ref->station->hold_access == SLA_HOLD_PRIVATE) 05212 return 1; 05213 return 0; 05214 } 05215 } 05216 05217 return 0; 05218 }
| static int sla_check_timed_out_station | ( | const struct sla_ringing_trunk * | ringing_trunk, | |
| const struct sla_station * | station | |||
| ) | [static] |
Check to see if dialing this station already timed out for this ringing trunk.
Definition at line 5430 of file app_meetme.c.
References AST_LIST_TRAVERSE.
Referenced by sla_choose_ringing_trunk(), and sla_ring_stations().
05432 { 05433 struct sla_station_ref *timed_out_station; 05434 05435 AST_LIST_TRAVERSE(&ringing_trunk->timed_out_stations, timed_out_station, entry) { 05436 if (station == timed_out_station->station) 05437 return 1; 05438 } 05439 05440 return 0; 05441 }
| static struct sla_trunk_ref* sla_choose_idle_trunk | ( | const struct sla_station * | station | ) | [static, read] |
For a given station, choose the highest priority idle trunk.
Definition at line 6241 of file app_meetme.c.
References AST_LIST_TRAVERSE, and SLA_TRUNK_STATE_IDLE.
Referenced by sla_station_exec().
06242 { 06243 struct sla_trunk_ref *trunk_ref = NULL; 06244 06245 AST_LIST_TRAVERSE(&station->trunks, trunk_ref, entry) { 06246 if (trunk_ref->state == SLA_TRUNK_STATE_IDLE) 06247 break; 06248 } 06249 06250 return trunk_ref; 06251 }
| static struct sla_ringing_trunk* sla_choose_ringing_trunk | ( | struct sla_station * | station, | |
| struct sla_trunk_ref ** | trunk_ref, | |||
| int | rm | |||
| ) | [static, read] |
Choose the highest priority ringing trunk for a station.
| station | the station | |
| rm | remove the ringing trunk once selected | |
| trunk_ref | a place to store the pointer to this stations reference to the selected trunk |
Definition at line 5451 of file app_meetme.c.
References AST_LIST_REMOVE_CURRENT, AST_LIST_TRAVERSE, AST_LIST_TRAVERSE_SAFE_BEGIN, AST_LIST_TRAVERSE_SAFE_END, sla, sla_check_timed_out_station(), and sla_ringing_trunk::trunk.
Referenced by sla_calc_station_delays(), sla_check_station_delay(), and sla_handle_dial_state_event().
05453 { 05454 struct sla_trunk_ref *s_trunk_ref; 05455 struct sla_ringing_trunk *ringing_trunk = NULL; 05456 05457 AST_LIST_TRAVERSE(&station->trunks, s_trunk_ref, entry) { 05458 AST_LIST_TRAVERSE_SAFE_BEGIN(&sla.ringing_trunks, ringing_trunk, entry) { 05459 /* Make sure this is the trunk we're looking for */ 05460 if (s_trunk_ref->trunk != ringing_trunk->trunk) 05461 continue; 05462 05463 /* This trunk on the station is ringing. But, make sure this station 05464 * didn't already time out while this trunk was ringing. */ 05465 if (sla_check_timed_out_station(ringing_trunk, station)) 05466 continue; 05467 05468 if (rm) 05469 AST_LIST_REMOVE_CURRENT(entry); 05470 05471 if (trunk_ref) 05472 *trunk_ref = s_trunk_ref; 05473 05474 break; 05475 } 05476 AST_LIST_TRAVERSE_SAFE_END; 05477 05478 if (ringing_trunk) 05479 break; 05480 } 05481 05482 return ringing_trunk; 05483 }
| static struct sla_ringing_station* sla_create_ringing_station | ( | struct sla_station * | station | ) | [static, read] |
Definition at line 5264 of file app_meetme.c.
References ast_calloc, ast_tvnow(), sla_ringing_station::ring_begin, and sla_ringing_station::station.
Referenced by sla_ring_station().
05265 { 05266 struct sla_ringing_station *ringing_station; 05267 05268 if (!(ringing_station = ast_calloc(1, sizeof(*ringing_station)))) 05269 return NULL; 05270 05271 ringing_station->station = station; 05272 ringing_station->ring_begin = ast_tvnow(); 05273 05274 return ringing_station; 05275 }
| static struct sla_station_ref* sla_create_station_ref | ( | struct sla_station * | station | ) | [static, read] |
Definition at line 5252 of file app_meetme.c.
References ast_calloc.
Referenced by sla_add_trunk_to_station(), and sla_stop_ringing_station().
05253 { 05254 struct sla_station_ref *station_ref; 05255 05256 if (!(station_ref = ast_calloc(1, sizeof(*station_ref)))) 05257 return NULL; 05258 05259 station_ref->station = station; 05260 05261 return station_ref; 05262 }
| static void sla_destroy | ( | void | ) | [static] |
Definition at line 6648 of file app_meetme.c.
References ast_cond_destroy, ast_cond_signal, ast_context_destroy(), ast_mutex_destroy, ast_mutex_lock, ast_mutex_unlock, AST_PTHREADT_NULL, AST_RWLIST_REMOVE_HEAD, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, destroy_station(), destroy_trunk(), sla, and sla_registrar.
Referenced by unload_module().
06649 { 06650 struct sla_trunk *trunk; 06651 struct sla_station *station; 06652 06653 AST_RWLIST_WRLOCK(&sla_trunks); 06654 while ((trunk = AST_RWLIST_REMOVE_HEAD(&sla_trunks, entry))) 06655 destroy_trunk(trunk); 06656 AST_RWLIST_UNLOCK(&sla_trunks); 06657 06658 AST_RWLIST_WRLOCK(&sla_stations); 06659 while ((station = AST_RWLIST_REMOVE_HEAD(&sla_stations, entry))) 06660 destroy_station(station); 06661 AST_RWLIST_UNLOCK(&sla_stations); 06662 06663 if (sla.thread != AST_PTHREADT_NULL) { 06664 ast_mutex_lock(&sla.lock); 06665 sla.stop = 1; 06666 ast_cond_signal(&sla.cond); 06667 ast_mutex_unlock(&sla.lock); 06668 pthread_join(sla.thread, NULL); 06669 } 06670 06671 /* Drop any created contexts from the dialplan */ 06672 ast_context_destroy(NULL, sla_registrar); 06673 06674 ast_mutex_destroy(&sla.lock); 06675 ast_cond_destroy(&sla.cond); 06676 }
| static void sla_dial_state_callback | ( | struct ast_dial * | dial | ) | [static] |
Definition at line 5422 of file app_meetme.c.
References SLA_EVENT_DIAL_STATE, and sla_queue_event().
Referenced by sla_ring_station().
05423 { 05424 sla_queue_event(SLA_EVENT_DIAL_STATE); 05425 }
| static struct sla_station* sla_find_station | ( | const char * | name | ) | [static, read] |
Find an SLA station by name.
Definition at line 5187 of file app_meetme.c.
References AST_RWLIST_TRAVERSE.
Referenced by sla_station_exec().
05188 { 05189 struct sla_station *station = NULL; 05190 05191 AST_RWLIST_TRAVERSE(&sla_stations, station, entry) { 05192 if (!strcasecmp(station->name, name)) 05193 break; 05194 } 05195 05196 return station; 05197 }
| static struct sla_trunk* sla_find_trunk | ( | const char * | name | ) | [static, read] |
Find an SLA trunk by name.
Definition at line 5172 of file app_meetme.c.
References AST_RWLIST_TRAVERSE.
Referenced by sla_trunk_exec().
05173 { 05174 struct sla_trunk *trunk = NULL; 05175 05176 AST_RWLIST_TRAVERSE(&sla_trunks, trunk, entry) { 05177 if (!strcasecmp(trunk->name, name)) 05178 break; 05179 } 05180 05181 return trunk; 05182 }
| static struct sla_trunk_ref* sla_find_trunk_ref | ( | const struct sla_station * | station, | |
| const struct sla_trunk * | trunk | |||
| ) | [static, read] |
Definition at line 5671 of file app_meetme.c.
References AST_LIST_TRAVERSE.
Referenced by sla_check_station_delay().
05673 { 05674 struct sla_trunk_ref *trunk_ref = NULL; 05675 05676 AST_LIST_TRAVERSE(&station->trunks, trunk_ref, entry) { 05677 if (trunk_ref->trunk == trunk) 05678 break; 05679 } 05680 05681 return trunk_ref; 05682 }
| static struct sla_trunk_ref* sla_find_trunk_ref_byname | ( | const struct sla_station * | station, | |
| const char * | name | |||
| ) | [static, read] |
Find a trunk reference on a station by name.
| station | the station | |
| name | the trunk's name |
Definition at line 5227 of file app_meetme.c.
References AST_LIST_TRAVERSE, sla_check_station_hold_access(), SLA_HOLD_PRIVATE, SLA_TRUNK_STATE_ONHOLD_BYME, and SLA_TRUNK_STATE_UP.
Referenced by sla_station_exec().
05229 { 05230 struct sla_trunk_ref *trunk_ref = NULL; 05231 05232 AST_LIST_TRAVERSE(&station->trunks, trunk_ref, entry) { 05233 if (strcasecmp(trunk_ref->trunk->name, name)) 05234 continue; 05235 05236 if ( (trunk_ref->trunk->barge_disabled 05237 && trunk_ref->state == SLA_TRUNK_STATE_UP) || 05238 (trunk_ref->trunk->hold_stations 05239 && trunk_ref->trunk->hold_access == SLA_HOLD_PRIVATE 05240 && trunk_ref->state != SLA_TRUNK_STATE_ONHOLD_BYME) || 05241 sla_check_station_hold_access(trunk_ref->trunk, station) ) 05242 { 05243 trunk_ref = NULL; 05244 } 05245 05246 break; 05247 } 05248 05249 return trunk_ref; 05250 }
| static void sla_handle_dial_state_event | ( | void | ) | [static] |
Definition at line 5485 of file app_meetme.c.
References ALL_TRUNK_REFS, answer_trunk_chan(), ast_cond_destroy, ast_cond_init, ast_cond_wait, ast_debug, ast_dial_answered(), AST_DIAL_RESULT_ANSWERED, AST_DIAL_RESULT_FAILED, AST_DIAL_RESULT_HANGUP, AST_DIAL_RESULT_INVALID, AST_DIAL_RESULT_PROCEEDING, AST_DIAL_RESULT_PROGRESS, AST_DIAL_RESULT_RINGING, AST_DIAL_RESULT_TIMEOUT, AST_DIAL_RESULT_TRYING, AST_DIAL_RESULT_UNANSWERED, ast_dial_state(), ast_free, AST_LIST_REMOVE_CURRENT, AST_LIST_TRAVERSE_SAFE_BEGIN, AST_LIST_TRAVERSE_SAFE_END, ast_mutex_destroy, ast_mutex_init, ast_mutex_lock, ast_mutex_unlock, ast_pthread_create_detached_background, run_station_args::cond, run_station_args::cond_lock, run_station(), sla, sla_change_trunk_state(), sla_choose_ringing_trunk(), SLA_EVENT_DIAL_STATE, SLA_EVENT_RINGING_TRUNK, sla_queue_event(), SLA_STATION_HANGUP_NORMAL, sla_stop_ringing_station(), SLA_TRUNK_STATE_UP, run_station_args::station, sla_ringing_station::station, sla_ringing_trunk::trunk, and run_station_args::trunk_ref.
Referenced by sla_thread().
05486 { 05487 struct sla_ringing_station *ringing_station; 05488 05489 AST_LIST_TRAVERSE_SAFE_BEGIN(&sla.ringing_stations, ringing_station, entry) { 05490 struct sla_trunk_ref *s_trunk_ref = NULL; 05491 struct sla_ringing_trunk *ringing_trunk = NULL; 05492 struct run_station_args args; 05493 enum ast_dial_result dial_res; 05494 pthread_t dont_care; 05495 ast_mutex_t cond_lock; 05496 ast_cond_t cond; 05497 05498 switch ((dial_res = ast_dial_state(ringing_station->station->dial))) { 05499 case AST_DIAL_RESULT_HANGUP: 05500 case AST_DIAL_RESULT_INVALID: 05501 case AST_DIAL_RESULT_FAILED: 05502 case AST_DIAL_RESULT_TIMEOUT: 05503 case AST_DIAL_RESULT_UNANSWERED: 05504 AST_LIST_REMOVE_CURRENT(entry); 05505 sla_stop_ringing_station(ringing_station, SLA_STATION_HANGUP_NORMAL); 05506 break; 05507 case AST_DIAL_RESULT_ANSWERED: 05508 AST_LIST_REMOVE_CURRENT(entry); 05509 /* Find the appropriate trunk to answer. */ 05510 ast_mutex_lock(&sla.lock); 05511 ringing_trunk = sla_choose_ringing_trunk(ringing_station->station, &s_trunk_ref, 1); 05512 ast_mutex_unlock(&sla.lock); 05513 if (!ringing_trunk) { 05514 ast_debug(1, "Found no ringing trunk for station '%s' to answer!\n", ringing_station->station->name); 05515 break; 05516 } 05517 /* Track the channel that answered this trunk */ 05518 s_trunk_ref->chan = ast_dial_answered(ringing_station->station->dial); 05519 /* Actually answer the trunk */ 05520 answer_trunk_chan(ringing_trunk->trunk->chan); 05521 sla_change_trunk_state(ringing_trunk->trunk, SLA_TRUNK_STATE_UP, ALL_TRUNK_REFS, NULL); 05522 /* Now, start a thread that will connect this station to the trunk. The rest of 05523 * the code here sets up the thread and ensures that it is able to save the arguments 05524 * before they are no longer valid since they are allocated on the stack. */ 05525 args.trunk_ref = s_trunk_ref; 05526 args.station = ringing_station->station; 05527 args.cond = &cond; 05528 args.cond_lock = &cond_lock; 05529 ast_free(ringing_trunk); 05530 ast_free(ringing_station); 05531 ast_mutex_init(&cond_lock); 05532 ast_cond_init(&cond, NULL); 05533 ast_mutex_lock(&cond_lock); 05534 ast_pthread_create_detached_background(&dont_care, NULL, run_station, &args); 05535 ast_cond_wait(&cond, &cond_lock); 05536 ast_mutex_unlock(&cond_lock); 05537 ast_mutex_destroy(&cond_lock); 05538 ast_cond_destroy(&cond); 05539 break; 05540 case AST_DIAL_RESULT_TRYING: 05541 case AST_DIAL_RESULT_RINGING: 05542 case AST_DIAL_RESULT_PROGRESS: 05543 case AST_DIAL_RESULT_PROCEEDING: 05544 break; 05545 } 05546 if (dial_res == AST_DIAL_RESULT_ANSWERED) { 05547 /* Queue up reprocessing ringing trunks, and then ringing stations again */ 05548 sla_queue_event(SLA_EVENT_RINGING_TRUNK); 05549 sla_queue_event(SLA_EVENT_DIAL_STATE); 05550 break; 05551 } 05552 } 05553 AST_LIST_TRAVERSE_SAFE_END; 05554 }
| static void sla_handle_hold_event | ( | struct sla_event * | event | ) | [static] |
Definition at line 5801 of file app_meetme.c.
References ast_atomic_fetchadd_int(), AST_CONTROL_HOLD, AST_DEVICE_ONHOLD, AST_DEVSTATE_CACHABLE, ast_devstate_changed(), ast_indicate(), ast_softhangup(), AST_SOFTHANGUP_DEV, INACTIVE_TRUNK_REFS, sla_change_trunk_state(), SLA_TRUNK_STATE_ONHOLD, SLA_TRUNK_STATE_ONHOLD_BYME, sla_event::station, and sla_event::trunk_ref.
Referenced by sla_thread().
05802 { 05803 ast_atomic_fetchadd_int((int *) &event->trunk_ref->trunk->hold_stations, 1); 05804 event->trunk_ref->state = SLA_TRUNK_STATE_ONHOLD_BYME; 05805 ast_devstate_changed(AST_DEVICE_ONHOLD, AST_DEVSTATE_CACHABLE, "SLA:%s_%s", 05806 event->station->name, event->trunk_ref->trunk->name); 05807 sla_change_trunk_state(event->trunk_ref->trunk, SLA_TRUNK_STATE_ONHOLD, 05808 INACTIVE_TRUNK_REFS, event->trunk_ref); 05809 05810 if (event->trunk_ref->trunk->active_stations == 1) { 05811 /* The station putting it on hold is the only one on the call, so start 05812 * Music on hold to the trunk. */ 05813 event->trunk_ref->trunk->on_hold = 1; 05814 ast_indicate(event->trunk_ref->trunk->chan, AST_CONTROL_HOLD); 05815 } 05816 05817 ast_softhangup(event->trunk_ref->chan, AST_SOFTHANGUP_DEV); 05818 event->trunk_ref->chan = NULL; 05819 }
| static void sla_handle_ringing_trunk_event | ( | void | ) | [static] |
Definition at line 5791 of file app_meetme.c.
References ast_mutex_lock, ast_mutex_unlock, sla, sla_hangup_stations(), and sla_ring_stations().
Referenced by sla_thread().
05792 { 05793 ast_mutex_lock(&sla.lock); 05794 sla_ring_stations(); 05795 ast_mutex_unlock(&sla.lock); 05796 05797 /* Find stations that shouldn't be ringing anymore. */ 05798 sla_hangup_stations(); 05799 }
| static void sla_hangup_stations | ( | void | ) | [static] |
Definition at line 5763 of file app_meetme.c.
References ast_dial_destroy(), ast_dial_join(), ast_free, AST_LIST_REMOVE_CURRENT, AST_LIST_TRAVERSE, AST_LIST_TRAVERSE_SAFE_BEGIN, AST_LIST_TRAVERSE_SAFE_END, ast_mutex_lock, ast_mutex_unlock, sla, sla_ringing_station::station, and sla_ringing_trunk::trunk.
Referenced by sla_handle_ringing_trunk_event().
05764 { 05765 struct sla_trunk_ref *trunk_ref; 05766 struct sla_ringing_station *ringing_station; 05767 05768 AST_LIST_TRAVERSE_SAFE_BEGIN(&sla.ringing_stations, ringing_station, entry) { 05769 AST_LIST_TRAVERSE(&ringing_station->station->trunks, trunk_ref, entry) { 05770 struct sla_ringing_trunk *ringing_trunk; 05771 ast_mutex_lock(&sla.lock); 05772 AST_LIST_TRAVERSE(&sla.ringing_trunks, ringing_trunk, entry) { 05773 if (trunk_ref->trunk == ringing_trunk->trunk) 05774 break; 05775 } 05776 ast_mutex_unlock(&sla.lock); 05777 if (ringing_trunk) 05778 break; 05779 } 05780 if (!trunk_ref) { 05781 AST_LIST_REMOVE_CURRENT(entry); 05782 ast_dial_join(ringing_station->station->dial); 05783 ast_dial_destroy(ringing_station->station->dial); 05784 ringing_station->station->dial = NULL; 05785 ast_free(ringing_station); 05786 } 05787 } 05788 AST_LIST_TRAVERSE_SAFE_END 05789 }
| static const char* sla_hold_str | ( | unsigned int | hold_access | ) | [static] |
Definition at line 1692 of file app_meetme.c.
References SLA_HOLD_OPEN, and SLA_HOLD_PRIVATE.
Referenced by sla_show_stations(), and sla_show_trunks().
01693 { 01694 const char *hold = "Unknown"; 01695 01696 switch (hold_access) { 01697 case SLA_HOLD_OPEN: 01698 hold = "Open"; 01699 break; 01700 case SLA_HOLD_PRIVATE: 01701 hold = "Private"; 01702 default: 01703 break; 01704 } 01705 01706 return hold; 01707 }
| static int sla_load_config | ( | int | reload | ) | [static] |
Definition at line 6928 of file app_meetme.c.
References ast_category_browse(), ast_cond_init, ast_config_destroy(), ast_config_load, ast_free, AST_LIST_EMPTY, ast_log(), ast_mutex_init, ast_pthread_create, AST_PTHREADT_NULL, AST_RWLIST_REMOVE_CURRENT, AST_RWLIST_TRAVERSE_SAFE_BEGIN, AST_RWLIST_TRAVERSE_SAFE_END, ast_true(), ast_variable_retrieve(), CONFIG_FLAG_FILEUNCHANGED, CONFIG_STATUS_FILEINVALID, CONFIG_STATUS_FILEUNCHANGED, LOG_ERROR, LOG_WARNING, sla, sla_build_station(), sla_build_trunk(), SLA_CONFIG_FILE, sla_thread(), and type.
Referenced by load_config(), and sla_check_reload().
06929 { 06930 struct ast_config *cfg; 06931 struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 }; 06932 const char *cat = NULL; 06933 int res = 0; 06934 const char *val; 06935 06936 if (!reload) { 06937 ast_mutex_init(&sla.lock); 06938 ast_cond_init(&sla.cond, NULL); 06939 } 06940 06941 if (!(cfg = ast_config_load(SLA_CONFIG_FILE, config_flags))) { 06942 return 0; /* Treat no config as normal */ 06943 } else if (cfg == CONFIG_STATUS_FILEUNCHANGED) { 06944 return 0; 06945 } else if (cfg == CONFIG_STATUS_FILEINVALID) { 06946 ast_log(LOG_ERROR, "Config file " SLA_CONFIG_FILE " is in an invalid format. Aborting.\n"); 06947 return 0; 06948 } 06949 06950 if (reload) { 06951 struct sla_station *station; 06952 struct sla_trunk *trunk; 06953 06954 /* We need to actually delete the previous versions of trunks and stations now */ 06955 AST_RWLIST_TRAVERSE_SAFE_BEGIN(&sla_stations, station, entry) { 06956 AST_RWLIST_REMOVE_CURRENT(entry); 06957 ast_free(station); 06958 } 06959 AST_RWLIST_TRAVERSE_SAFE_END; 06960 06961 AST_RWLIST_TRAVERSE_SAFE_BEGIN(&sla_trunks, trunk, entry) { 06962 AST_RWLIST_REMOVE_CURRENT(entry); 06963 ast_free(trunk); 06964 } 06965 AST_RWLIST_TRAVERSE_SAFE_END; 06966 } 06967 06968 if ((val = ast_variable_retrieve(cfg, "general", "attemptcallerid"))) 06969 sla.attempt_callerid = ast_true(val); 06970 06971 while ((cat = ast_category_browse(cfg, cat)) && !res) { 06972 const char *type; 06973 if (!strcasecmp(cat, "general")) 06974 continue; 06975 if (!(type = ast_variable_retrieve(cfg, cat, "type"))) { 06976 ast_log(LOG_WARNING, "Invalid entry in %s defined with no type!\n", 06977 SLA_CONFIG_FILE); 06978 continue; 06979 } 06980 if (!strcasecmp(type, "trunk")) 06981 res = sla_build_trunk(cfg, cat); 06982 else if (!strcasecmp(type, "station")) 06983 res = sla_build_station(cfg, cat); 06984 else { 06985 ast_log(LOG_WARNING, "Entry in %s defined with invalid type '%s'!\n", 06986 SLA_CONFIG_FILE, type); 06987 } 06988 } 06989 06990 ast_config_destroy(cfg); 06991 06992 /* Even if we don't have any stations, we may after a reload and we need to 06993 * be able to process the SLA_EVENT_RELOAD event in that case */ 06994 if (sla.thread == AST_PTHREADT_NULL && (!AST_LIST_EMPTY(&sla_stations) || !AST_LIST_EMPTY(&sla_trunks))) { 06995 ast_pthread_create(&sla.thread, NULL, sla_thread, NULL); 06996 } 06997 06998 return res; 06999 }
| static int sla_process_timers | ( | struct timespec * | ts | ) | [static] |
Calculate the time until the next known event.
Definition at line 5979 of file app_meetme.c.
References ast_samp2tv(), ast_tvadd(), ast_tvnow(), sla_calc_station_delays(), sla_calc_station_timeouts(), sla_calc_trunk_timeouts(), SLA_EVENT_RINGING_TRUNK, and sla_queue_event_nolock().
Referenced by sla_thread().
05980 { 05981 unsigned int timeout = UINT_MAX; 05982 struct timeval wait; 05983 unsigned int change_made = 0; 05984 05985 /* Check for ring timeouts on ringing trunks */ 05986 if (sla_calc_trunk_timeouts(&timeout)) 05987 change_made = 1; 05988 05989 /* Check for ring timeouts on ringing stations */ 05990 if (sla_calc_station_timeouts(&timeout)) 05991 change_made = 1; 05992 05993 /* Check for station ring delays */ 05994 if (sla_calc_station_delays(&timeout)) 05995 change_made = 1; 05996 05997 /* queue reprocessing of ringing trunks */ 05998 if (change_made) 05999 sla_queue_event_nolock(SLA_EVENT_RINGING_TRUNK); 06000 06001 /* No timeout */ 06002 if (timeout == UINT_MAX) 06003 return 0; 06004 06005 if (ts) { 06006 wait = ast_tvadd(ast_tvnow(), ast_samp2tv(timeout, 1000)); 06007 ts->tv_sec = wait.tv_sec; 06008 ts->tv_nsec = wait.tv_usec * 1000; 06009 } 06010 06011 return 1; 06012 }
| static void sla_queue_event | ( | enum sla_event_type | type | ) | [static] |
Definition at line 2009 of file app_meetme.c.
References sla_queue_event_full().
Referenced by load_config(), queue_ringing_trunk(), sla_dial_state_callback(), sla_handle_dial_state_event(), sla_station_exec(), and sla_trunk_exec().
02010 { 02011 sla_queue_event_full(type, NULL, NULL, 1); 02012 }
| static void sla_queue_event_conf | ( | enum sla_event_type | type, | |
| struct ast_channel * | chan, | |||
| struct ast_conference * | conf | |||
| ) | [static] |
Queue a SLA event from the conference.
Definition at line 2015 of file app_meetme.c.
References ast_debug, AST_LIST_TRAVERSE, ast_log(), AST_RWLIST_RDLOCK, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, ast_strdupa, ast_strlen_zero(), ast_conference::confno, LOG_ERROR, and sla_queue_event_full().
Referenced by conf_run().
02017 { 02018 struct sla_station *station; 02019 struct sla_trunk_ref *trunk_ref = NULL; 02020 char *trunk_name; 02021 02022 trunk_name = ast_strdupa(conf->confno); 02023 strsep(&trunk_name, "_"); 02024 if (ast_strlen_zero(trunk_name)) { 02025 ast_log(LOG_ERROR, "Invalid conference name for SLA - '%s'!\n", conf->confno); 02026 return; 02027 } 02028 02029 AST_RWLIST_RDLOCK(&sla_stations); 02030 AST_RWLIST_TRAVERSE(&sla_stations, station, entry) { 02031 AST_LIST_TRAVERSE(&station->trunks, trunk_ref, entry) { 02032 if (trunk_ref->chan == chan && !strcmp(trunk_ref->trunk->name, trunk_name)) 02033 break; 02034 } 02035 if (trunk_ref) 02036 break; 02037 } 02038 AST_RWLIST_UNLOCK(&sla_stations); 02039 02040 if (!trunk_ref) { 02041 ast_debug(1, "Trunk not found for event!\n"); 02042 return; 02043 } 02044 02045 sla_queue_event_full(type, trunk_ref, station, 1); 02046 }
| static void sla_queue_event_full | ( | enum sla_event_type | type, | |
| struct sla_trunk_ref * | trunk_ref, | |||
| struct sla_station * | station, | |||
| int | lock | |||
| ) | [static] |
Definition at line 1977 of file app_meetme.c.
References ast_calloc, ast_cond_signal, AST_LIST_INSERT_TAIL, ast_mutex_lock, ast_mutex_unlock, AST_PTHREADT_NULL, and sla.
Referenced by sla_queue_event(), sla_queue_event_conf(), and sla_queue_event_nolock().
01979 { 01980 struct sla_event *event; 01981 01982 if (sla.thread == AST_PTHREADT_NULL) { 01983 return; 01984 } 01985 01986 if (!(event = ast_calloc(1, sizeof(*event)))) 01987 return; 01988 01989 event->type = type; 01990 event->trunk_ref = trunk_ref; 01991 event->station = station; 01992 01993 if (!lock) { 01994 AST_LIST_INSERT_TAIL(&sla.event_q, event, entry); 01995 return; 01996 } 01997 01998 ast_mutex_lock(&sla.lock); 01999 AST_LIST_INSERT_TAIL(&sla.event_q, event, entry); 02000 ast_cond_signal(&sla.cond); 02001 ast_mutex_unlock(&sla.lock); 02002 }
| static void sla_queue_event_nolock | ( | enum sla_event_type | type | ) | [static] |
Definition at line 2004 of file app_meetme.c.
References sla_queue_event_full().
Referenced by sla_process_timers().
02005 { 02006 sla_queue_event_full(type, NULL, NULL, 0); 02007 }
| static int sla_ring_station | ( | struct sla_ringing_trunk * | ringing_trunk, | |
| struct sla_station * | station | |||
| ) | [static] |
Ring a station.
Definition at line 5597 of file app_meetme.c.
References ast_calloc, ast_dial_append(), ast_dial_create(), ast_dial_destroy(), ast_dial_join(), AST_DIAL_RESULT_TRYING, ast_dial_run(), ast_dial_set_state_callback(), AST_LIST_INSERT_HEAD, ast_party_caller_free(), ast_party_caller_init(), ast_strdupa, ast_tvnow(), sla_failed_station::last_try, sla, sla_create_ringing_station(), sla_dial_state_callback(), sla_failed_station::station, and sla_ringing_trunk::trunk.
Referenced by sla_ring_stations().
05598 { 05599 char *tech, *tech_data; 05600 struct ast_dial *dial; 05601 struct sla_ringing_station *ringing_station; 05602 enum ast_dial_result res; 05603 int caller_is_saved; 05604 struct ast_party_caller caller; 05605 05606 if (!(dial = ast_dial_create())) 05607 return -1; 05608 05609 ast_dial_set_state_callback(dial, sla_dial_state_callback); 05610 tech_data = ast_strdupa(station->device); 05611 tech = strsep(&tech_data, "/"); 05612 05613 if (ast_dial_append(dial, tech, tech_data) == -1) { 05614 ast_dial_destroy(dial); 05615 return -1; 05616 } 05617 05618 /* Do we need to save off the caller ID data? */ 05619 caller_is_saved = 0; 05620 if (!sla.attempt_callerid) { 05621 caller_is_saved = 1; 05622 caller = ringing_trunk->trunk->chan->caller; 05623 ast_party_caller_init(&ringing_trunk->trunk->chan->caller); 05624 } 05625 05626 res = ast_dial_run(dial, ringing_trunk->trunk->chan, 1); 05627 05628 /* Restore saved caller ID */ 05629 if (caller_is_saved) { 05630 ast_party_caller_free(&ringing_trunk->trunk->chan->caller); 05631 ringing_trunk->trunk->chan->caller = caller; 05632 } 05633 05634 if (res != AST_DIAL_RESULT_TRYING) { 05635 struct sla_failed_station *failed_station; 05636 ast_dial_destroy(dial); 05637 if (!(failed_station = ast_calloc(1, sizeof(*failed_station)))) 05638 return -1; 05639 failed_station->station = station; 05640 failed_station->last_try = ast_tvnow(); 05641 AST_LIST_INSERT_HEAD(&sla.failed_stations, failed_station, entry); 05642 return -1; 05643 } 05644 if (!(ringing_station = sla_create_ringing_station(station))) { 05645 ast_dial_join(dial); 05646 ast_dial_destroy(dial); 05647 return -1; 05648 } 05649 05650 station->dial = dial; 05651 05652 AST_LIST_INSERT_HEAD(&sla.ringing_stations, ringing_station, entry); 05653 05654 return 0; 05655 }
| static void sla_ring_stations | ( | void | ) | [static] |
Ring stations based on current set of ringing trunks.
Definition at line 5722 of file app_meetme.c.
References AST_LIST_TRAVERSE, sla, sla_check_failed_station(), sla_check_inuse_station(), sla_check_ringing_station(), sla_check_station_delay(), sla_check_timed_out_station(), sla_ring_station(), and sla_ringing_trunk::trunk.
Referenced by sla_handle_ringing_trunk_event().
05723 { 05724 struct sla_station_ref *station_ref; 05725 struct sla_ringing_trunk *ringing_trunk; 05726 05727 /* Make sure that every station that uses at least one of the ringing 05728 * trunks, is ringing. */ 05729 AST_LIST_TRAVERSE(&sla.ringing_trunks, ringing_trunk, entry) { 05730 AST_LIST_TRAVERSE(&ringing_trunk->trunk->stations, station_ref, entry) { 05731 int time_left; 05732 05733 /* Is this station already ringing? */ 05734 if (sla_check_ringing_station(station_ref->station)) 05735 continue; 05736 05737 /* Is this station already in a call? */ 05738 if (sla_check_inuse_station(station_ref->station)) 05739 continue; 05740 05741 /* Did we fail to dial this station earlier? If so, has it been 05742 * a minute since we tried? */ 05743 if (sla_check_failed_station(station_ref->station)) 05744 continue; 05745 05746 /* If this station already timed out while this trunk was ringing, 05747 * do not dial it again for this ringing trunk. */ 05748 if (sla_check_timed_out_station(ringing_trunk, station_ref->station)) 05749 continue; 05750 05751 /* Check for a ring delay in progress */ 05752 time_left = sla_check_station_delay(station_ref->station, ringing_trunk); 05753 if (time_left != INT_MAX && time_left > 0) 05754 continue; 05755 05756 /* It is time to make this station begin to ring. Do it! */ 05757 sla_ring_station(ringing_trunk, station_ref->station); 05758 } 05759 } 05760 /* Now, all of the stations that should be ringing, are ringing. */ 05761 }
| static char* sla_show_stations | ( | struct ast_cli_entry * | e, | |
| int | cmd, | |||
| struct ast_cli_args * | a | |||
| ) | [static] |
Definition at line 1774 of file app_meetme.c.
References ast_cli(), AST_LIST_TRAVERSE, AST_RWLIST_RDLOCK, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, CLI_GENERATE, CLI_INIT, CLI_SUCCESS, ast_cli_entry::command, ast_cli_args::fd, S_OR, sla_hold_str(), trunkstate2str(), and ast_cli_entry::usage.
01775 { 01776 const struct sla_station *station; 01777 01778 switch (cmd) { 01779 case CLI_INIT: 01780 e->command = "sla show stations"; 01781 e->usage = 01782 "Usage: sla show stations\n" 01783 " This will list all stations defined in sla.conf\n"; 01784 return NULL; 01785 case CLI_GENERATE: 01786 return NULL; 01787 } 01788 01789 ast_cli(a->fd, "\n" 01790 "=============================================================\n" 01791 "=== Configured SLA Stations =================================\n" 01792 "=============================================================\n" 01793 "===\n"); 01794 AST_RWLIST_RDLOCK(&sla_stations); 01795 AST_RWLIST_TRAVERSE(&sla_stations, station, entry) { 01796 struct sla_trunk_ref *trunk_ref; 01797 char ring_timeout[16] = "(none)"; 01798 char ring_delay[16] = "(none)"; 01799 if (station->ring_timeout) { 01800 snprintf(ring_timeout, sizeof(ring_timeout), 01801 "%u", station->ring_timeout); 01802 } 01803 if (station->ring_delay) { 01804 snprintf(ring_delay, sizeof(ring_delay), 01805 "%u", station->ring_delay); 01806 } 01807 ast_cli(a->fd, "=== ---------------------------------------------------------\n" 01808 "=== Station Name: %s\n" 01809 "=== ==> Device: %s\n" 01810 "=== ==> AutoContext: %s\n" 01811 "=== ==> RingTimeout: %s\n" 01812 "=== ==> RingDelay: %s\n" 01813 "=== ==> HoldAccess: %s\n" 01814 "=== ==> Trunks ...\n", 01815 station->name, station->device, 01816 S_OR(station->autocontext, "(none)"), 01817 ring_timeout, ring_delay, 01818 sla_hold_str(station->hold_access)); 01819 AST_RWLIST_RDLOCK(&sla_trunks); 01820 AST_LIST_TRAVERSE(&station->trunks, trunk_ref, entry) { 01821 if (trunk_ref->ring_timeout) { 01822 snprintf(ring_timeout, sizeof(ring_timeout), 01823 "%u", trunk_ref->ring_timeout); 01824 } else 01825 strcpy(ring_timeout, "(none)"); 01826 if (trunk_ref->ring_delay) { 01827 snprintf(ring_delay, sizeof(ring_delay), 01828 "%u", trunk_ref->ring_delay); 01829 } else 01830 strcpy(ring_delay, "(none)"); 01831 ast_cli(a->fd, "=== ==> Trunk Name: %s\n" 01832 "=== ==> State: %s\n" 01833 "=== ==> RingTimeout: %s\n" 01834 "=== ==> RingDelay: %s\n", 01835 trunk_ref->trunk->name, 01836 trunkstate2str(trunk_ref->state), 01837 ring_timeout, ring_delay); 01838 } 01839 AST_RWLIST_UNLOCK(&sla_trunks); 01840 ast_cli(a->fd, "=== ---------------------------------------------------------\n" 01841 "===\n"); 01842 } 01843 AST_RWLIST_UNLOCK(&sla_stations); 01844 ast_cli(a->fd, "============================================================\n" 01845 "\n"); 01846 01847 return CLI_SUCCESS; 01848 }
| static char* sla_show_trunks | ( | struct ast_cli_entry * | e, | |
| int | cmd, | |||
| struct ast_cli_args * | a | |||
| ) | [static] |
Definition at line 1709 of file app_meetme.c.
References ast_cli(), AST_LIST_TRAVERSE, AST_RWLIST_RDLOCK, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, CLI_GENERATE, CLI_INIT, CLI_SUCCESS, ast_cli_entry::command, ast_cli_args::fd, S_OR, sla_hold_str(), and ast_cli_entry::usage.
01710 { 01711 const struct sla_trunk *trunk; 01712 01713 switch (cmd) { 01714 case CLI_INIT: 01715 e->command = "sla show trunks"; 01716 e->usage = 01717 "Usage: sla show trunks\n" 01718 " This will list all trunks defined in sla.conf\n"; 01719 return NULL; 01720 case CLI_GENERATE: 01721 return NULL; 01722 } 01723 01724 ast_cli(a->fd, "\n" 01725 "=============================================================\n" 01726 "=== Configured SLA Trunks ===================================\n" 01727 "=============================================================\n" 01728 "===\n"); 01729 AST_RWLIST_RDLOCK(&sla_trunks); 01730 AST_RWLIST_TRAVERSE(&sla_trunks, trunk, entry) { 01731 struct sla_station_ref *station_ref; 01732 char ring_timeout[16] = "(none)"; 01733 if (trunk->ring_timeout) 01734 snprintf(ring_timeout, sizeof(ring_timeout), "%u Seconds", trunk->ring_timeout); 01735 ast_cli(a->fd, "=== ---------------------------------------------------------\n" 01736 "=== Trunk Name: %s\n" 01737 "=== ==> Device: %s\n" 01738 "=== ==> AutoContext: %s\n" 01739 "=== ==> RingTimeout: %s\n" 01740 "=== ==> BargeAllowed: %s\n" 01741 "=== ==> HoldAccess: %s\n" 01742 "=== ==> Stations ...\n", 01743 trunk->name, trunk->device, 01744 S_OR(trunk->autocontext, "(none)"), 01745 ring_timeout, 01746 trunk->barge_disabled ? "No" : "Yes", 01747 sla_hold_str(trunk->hold_access)); 01748 AST_RWLIST_RDLOCK(&sla_stations); 01749 AST_LIST_TRAVERSE(&trunk->stations, station_ref, entry) 01750 ast_cli(a->fd, "=== ==> Station name: %s\n", station_ref->station->name); 01751 AST_RWLIST_UNLOCK(&sla_stations); 01752 ast_cli(a->fd, "=== ---------------------------------------------------------\n===\n"); 01753 } 01754 AST_RWLIST_UNLOCK(&sla_trunks); 01755 ast_cli(a->fd, "=============================================================\n\n"); 01756 01757 return CLI_SUCCESS; 01758 }
| static enum ast_device_state sla_state | ( | const char * | data | ) | [static] |
Definition at line 6572 of file app_meetme.c.
References AST_DEVICE_INVALID, AST_LIST_TRAVERSE, ast_log(), AST_RWLIST_RDLOCK, AST_RWLIST_UNLOCK, ast_strdupa, LOG_ERROR, and sla_state_to_devstate().
Referenced by load_module().
06573 { 06574 char *buf, *station_name, *trunk_name; 06575 struct sla_station *station; 06576 struct sla_trunk_ref *trunk_ref; 06577 enum ast_device_state res = AST_DEVICE_INVALID; 06578 06579 trunk_name = buf = ast_strdupa(data); 06580 station_name = strsep(&trunk_name, "_"); 06581 06582 AST_RWLIST_RDLOCK(&sla_stations); 06583 AST_LIST_TRAVERSE(&sla_stations, station, entry) { 06584 if (strcasecmp(station_name, station->name)) 06585 continue; 06586 AST_RWLIST_RDLOCK(&sla_trunks); 06587 AST_LIST_TRAVERSE(&station->trunks, trunk_ref, entry) { 06588 if (!strcasecmp(trunk_name, trunk_ref->trunk->name)) 06589 break; 06590 } 06591 if (!trunk_ref) { 06592 AST_RWLIST_UNLOCK(&sla_trunks); 06593 break; 06594 } 06595 res = sla_state_to_devstate(trunk_ref->state); 06596 AST_RWLIST_UNLOCK(&sla_trunks); 06597 } 06598 AST_RWLIST_UNLOCK(&sla_stations); 06599 06600 if (res == AST_DEVICE_INVALID) { 06601 ast_log(LOG_ERROR, "Could not determine state for trunk %s on station %s!\n", 06602 trunk_name, station_name); 06603 } 06604 06605 return res; 06606 }
| static enum ast_device_state sla_state_to_devstate | ( | enum sla_trunk_state | state | ) | [static] |
Definition at line 5277 of file app_meetme.c.
References AST_DEVICE_INUSE, AST_DEVICE_NOT_INUSE, AST_DEVICE_ONHOLD, AST_DEVICE_RINGING, AST_DEVICE_UNKNOWN, SLA_TRUNK_STATE_IDLE, SLA_TRUNK_STATE_ONHOLD, SLA_TRUNK_STATE_ONHOLD_BYME, SLA_TRUNK_STATE_RINGING, and SLA_TRUNK_STATE_UP.
Referenced by sla_change_trunk_state(), and sla_state().
05278 { 05279 switch (state) { 05280 case SLA_TRUNK_STATE_IDLE: 05281 return AST_DEVICE_NOT_INUSE; 05282 case SLA_TRUNK_STATE_RINGING: 05283 return AST_DEVICE_RINGING; 05284 case SLA_TRUNK_STATE_UP: 05285 return AST_DEVICE_INUSE; 05286 case SLA_TRUNK_STATE_ONHOLD: 05287 case SLA_TRUNK_STATE_ONHOLD_BYME: 05288 return AST_DEVICE_ONHOLD; 05289 } 05290 05291 return AST_DEVICE_UNKNOWN; 05292 }
| static int sla_station_exec | ( | struct ast_channel * | chan, | |
| const char * | data | |||
| ) | [static] |
Definition at line 6253 of file app_meetme.c.
References admin_exec(), ALL_TRUNK_REFS, answer_trunk_chan(), ast_answer(), ast_atomic_dec_and_test(), ast_atomic_fetchadd_int(), ast_autoservice_start(), ast_autoservice_stop(), ast_cond_destroy, ast_cond_init, ast_cond_wait, AST_CONTROL_UNHOLD, ast_debug, AST_DEVICE_INUSE, AST_DEVSTATE_CACHABLE, ast_devstate_changed(), ast_indicate(), AST_LIST_REMOVE_CURRENT, AST_LIST_TRAVERSE_SAFE_BEGIN, AST_LIST_TRAVERSE_SAFE_END, ast_log(), ast_mutex_destroy, ast_mutex_init, ast_mutex_lock, ast_mutex_unlock, ast_pthread_create_detached_background, AST_RWLIST_RDLOCK, AST_RWLIST_UNLOCK, ast_set_flag64, ast_strdupa, ast_strlen_zero(), build_conf(), conf_run(), CONFFLAG_MARKEDEXIT, CONFFLAG_PASS_DTMF, CONFFLAG_QUIET, CONFFLAG_SLA_STATION, dial_trunk(), dispose_conf(), free, LOG_NOTICE, LOG_WARNING, MAX_CONFNUM, pbx_builtin_setvar_helper(), sla, sla_change_trunk_state(), sla_choose_idle_trunk(), SLA_EVENT_CHECK_RELOAD, SLA_EVENT_DIAL_STATE, SLA_EVENT_RINGING_TRUNK, sla_find_station(), sla_find_trunk_ref_byname(), sla_queue_event(), SLA_TRUNK_STATE_IDLE, SLA_TRUNK_STATE_ONHOLD_BYME, SLA_TRUNK_STATE_RINGING, SLA_TRUNK_STATE_UP, sla_ringing_trunk::trunk, and dial_trunk_args::trunk_ref.
Referenced by load_module().
06254 { 06255 char *station_name, *trunk_name; 06256 struct sla_station *station; 06257 struct sla_trunk_ref *trunk_ref = NULL; 06258 char conf_name[MAX_CONFNUM]; 06259 struct ast_flags64 conf_flags = { 0 }; 06260 struct ast_conference *conf; 06261 06262 if (ast_strlen_zero(data)) { 06263 ast_log(LOG_WARNING, "Invalid Arguments to SLAStation!\n"); 06264 pbx_builtin_setvar_helper(chan, "SLASTATION_STATUS", "FAILURE"); 06265 return 0; 06266 } 06267 06268 trunk_name = ast_strdupa(data); 06269 station_name = strsep(&trunk_name, "_"); 06270 06271 if (ast_strlen_zero(station_name)) { 06272 ast_log(LOG_WARNING, "Invalid Arguments to SLAStation!\n"); 06273 pbx_builtin_setvar_helper(chan, "SLASTATION_STATUS", "FAILURE"); 06274 return 0; 06275 } 06276 06277 AST_RWLIST_RDLOCK(&sla_stations); 06278 station = sla_find_station(station_name); 06279 if (station) 06280 ast_atomic_fetchadd_int((int *) &station->ref_count, 1); 06281 AST_RWLIST_UNLOCK(&sla_stations); 06282 06283 if (!station) { 06284 ast_log(LOG_WARNING, "Station '%s' not found!\n", station_name); 06285 pbx_builtin_setvar_helper(chan, "SLASTATION_STATUS", "FAILURE"); 06286 sla_queue_event(SLA_EVENT_CHECK_RELOAD); 06287 return 0; 06288 } 06289 06290 AST_RWLIST_RDLOCK(&sla_trunks); 06291 if (!ast_strlen_zero(trunk_name)) { 06292 trunk_ref = sla_find_trunk_ref_byname(station, trunk_name); 06293 } else 06294 trunk_ref = sla_choose_idle_trunk(station); 06295 AST_RWLIST_UNLOCK(&sla_trunks); 06296 06297 if (!trunk_ref) { 06298 if (ast_strlen_zero(trunk_name)) 06299 ast_log(LOG_NOTICE, "No trunks available for call.\n"); 06300 else { 06301 ast_log(LOG_NOTICE, "Can't join existing call on trunk " 06302 "'%s' due to access controls.\n", trunk_name); 06303 } 06304 pbx_builtin_setvar_helper(chan, "SLASTATION_STATUS", "CONGESTION"); 06305 ast_atomic_fetchadd_int((int *) &station->ref_count, -1); 06306 sla_queue_event(SLA_EVENT_CHECK_RELOAD); 06307 return 0; 06308 } 06309 06310 if (trunk_ref->state == SLA_TRUNK_STATE_ONHOLD_BYME) { 06311 if (ast_atomic_dec_and_test((int *) &trunk_ref->trunk->hold_stations) == 1) 06312 sla_change_trunk_state(trunk_ref->trunk, SLA_TRUNK_STATE_UP, ALL_TRUNK_REFS, NULL); 06313 else { 06314 trunk_ref->state = SLA_TRUNK_STATE_UP; 06315 ast_devstate_changed(AST_DEVICE_INUSE, AST_DEVSTATE_CACHABLE, 06316 "SLA:%s_%s", station->name, trunk_ref->trunk->name); 06317 } 06318 } else if (trunk_ref->state == SLA_TRUNK_STATE_RINGING) { 06319 struct sla_ringing_trunk *ringing_trunk; 06320 06321 ast_mutex_lock(&sla.lock); 06322 AST_LIST_TRAVERSE_SAFE_BEGIN(&sla.ringing_trunks, ringing_trunk, entry) { 06323 if (ringing_trunk->trunk == trunk_ref->trunk) { 06324 AST_LIST_REMOVE_CURRENT(entry); 06325 break; 06326 } 06327 } 06328 AST_LIST_TRAVERSE_SAFE_END 06329 ast_mutex_unlock(&sla.lock); 06330 06331 if (ringing_trunk) { 06332 answer_trunk_chan(ringing_trunk->trunk->chan); 06333 sla_change_trunk_state(ringing_trunk->trunk, SLA_TRUNK_STATE_UP, ALL_TRUNK_REFS, NULL); 06334 06335 free(ringing_trunk); 06336 06337 /* Queue up reprocessing ringing trunks, and then ringing stations again */ 06338 sla_queue_event(SLA_EVENT_RINGING_TRUNK); 06339 sla_queue_event(SLA_EVENT_DIAL_STATE); 06340 } 06341 } 06342 06343 trunk_ref->chan = chan; 06344 06345 if (!trunk_ref->trunk->chan) { 06346 ast_mutex_t cond_lock; 06347 ast_cond_t cond; 06348 pthread_t dont_care; 06349 struct dial_trunk_args args = { 06350 .trunk_ref = trunk_ref, 06351 .station = station, 06352 .cond_lock = &cond_lock, 06353 .cond = &cond, 06354 }; 06355 sla_change_trunk_state(trunk_ref->trunk, SLA_TRUNK_STATE_UP, ALL_TRUNK_REFS, NULL); 06356 /* Create a thread to dial the trunk and dump it into the conference. 06357 * However, we want to wait until the trunk has been dialed and the 06358 * conference is created before continuing on here. */ 06359 ast_autoservice_start(chan); 06360 ast_mutex_init(&cond_lock); 06361 ast_cond_init(&cond, NULL); 06362 ast_mutex_lock(&cond_lock); 06363 ast_pthread_create_detached_background(&dont_care, NULL, dial_trunk, &args); 06364 ast_cond_wait(&cond, &cond_lock); 06365 ast_mutex_unlock(&cond_lock); 06366 ast_mutex_destroy(&cond_lock); 06367 ast_cond_destroy(&cond); 06368 ast_autoservice_stop(chan); 06369 if (!trunk_ref->trunk->chan) { 06370 ast_debug(1, "Trunk didn't get created. chan: %lx\n", (long) trunk_ref->trunk->chan); 06371 pbx_builtin_setvar_helper(chan, "SLASTATION_STATUS", "CONGESTION"); 06372 sla_change_trunk_state(trunk_ref->trunk, SLA_TRUNK_STATE_IDLE, ALL_TRUNK_REFS, NULL); 06373 trunk_ref->chan = NULL; 06374 ast_atomic_fetchadd_int((int *) &station->ref_count, -1); 06375 sla_queue_event(SLA_EVENT_CHECK_RELOAD); 06376 return 0; 06377 } 06378 } 06379 06380 if (ast_atomic_fetchadd_int((int *) &trunk_ref->trunk->active_stations, 1) == 0 && 06381 trunk_ref->trunk->on_hold) { 06382 trunk_ref->trunk->on_hold = 0; 06383 ast_indicate(trunk_ref->trunk->chan, AST_CONTROL_UNHOLD); 06384 sla_change_trunk_state(trunk_ref->trunk, SLA_TRUNK_STATE_UP, ALL_TRUNK_REFS, NULL); 06385 } 06386 06387 snprintf(conf_name, sizeof(conf_name), "SLA_%s", trunk_ref->trunk->name); 06388 ast_set_flag64(&conf_flags, 06389 CONFFLAG_QUIET | CONFFLAG_MARKEDEXIT | CONFFLAG_PASS_DTMF | CONFFLAG_SLA_STATION); 06390 ast_answer(chan); 06391 conf = build_conf(conf_name, "", "", 0, 0, 1, chan, NULL); 06392 if (conf) { 06393 conf_run(chan, conf, &conf_flags, NULL); 06394 dispose_conf(conf); 06395 conf = NULL; 06396 } 06397 trunk_ref->chan = NULL; 06398 if (ast_atomic_dec_and_test((int *) &trunk_ref->trunk->active_stations) && 06399 trunk_ref->state != SLA_TRUNK_STATE_ONHOLD_BYME) { 06400 strncat(conf_name, ",K", sizeof(conf_name) - strlen(conf_name) - 1); 06401 admin_exec(NULL, conf_name); 06402 trunk_ref->trunk->hold_stations = 0; 06403 sla_change_trunk_state(trunk_ref->trunk, SLA_TRUNK_STATE_IDLE, ALL_TRUNK_REFS, NULL); 06404 } 06405 06406 pbx_builtin_setvar_helper(chan, "SLASTATION_STATUS", "SUCCESS"); 06407 06408 ast_atomic_fetchadd_int((int *) &station->ref_count, -1); 06409 sla_queue_event(SLA_EVENT_CHECK_RELOAD); 06410 06411 return 0; 06412 }
| static void sla_stop_ringing_station | ( | struct sla_ringing_station * | ringing_station, | |
| enum sla_station_hangup | hangup | |||
| ) | [static] |
Definition at line 5387 of file app_meetme.c.
References ast_dial_destroy(), ast_dial_join(), ast_free, AST_LIST_INSERT_TAIL, AST_LIST_TRAVERSE, sla, sla_create_station_ref(), SLA_STATION_HANGUP_NORMAL, sla_ringing_station::station, and sla_ringing_trunk::trunk.
Referenced by sla_calc_station_timeouts(), and sla_handle_dial_state_event().
05389 { 05390 struct sla_ringing_trunk *ringing_trunk; 05391 struct sla_trunk_ref *trunk_ref; 05392 struct sla_station_ref *station_ref; 05393 05394 ast_dial_join(ringing_station->station->dial); 05395 ast_dial_destroy(ringing_station->station->dial); 05396 ringing_station->station->dial = NULL; 05397 05398 if (hangup == SLA_STATION_HANGUP_NORMAL) 05399 goto done; 05400 05401 /* If the station is being hung up because of a timeout, then add it to the 05402 * list of timed out stations on each of the ringing trunks. This is so 05403 * that when doing further processing to figure out which stations should be 05404 * ringing, which trunk to answer, determining timeouts, etc., we know which 05405 * ringing trunks we should ignore. */ 05406 AST_LIST_TRAVERSE(&sla.ringing_trunks, ringing_trunk, entry) { 05407 AST_LIST_TRAVERSE(&ringing_station->station->trunks, trunk_ref, entry) { 05408 if (ringing_trunk->trunk == trunk_ref->trunk) 05409 break; 05410 } 05411 if (!trunk_ref) 05412 continue; 05413 if (!(station_ref = sla_create_station_ref(ringing_station->station))) 05414 continue; 05415 AST_LIST_INSERT_TAIL(&ringing_trunk->timed_out_stations, station_ref, entry); 05416 } 05417 05418 done: 05419 ast_free(ringing_station); 05420 }
| static void sla_stop_ringing_trunk | ( | struct sla_ringing_trunk * | ringing_trunk | ) | [static] |
Definition at line 5372 of file app_meetme.c.
References admin_exec(), ALL_TRUNK_REFS, ast_free, AST_LIST_REMOVE_HEAD, sla_change_trunk_state(), SLA_TRUNK_STATE_IDLE, and sla_ringing_trunk::trunk.
Referenced by sla_calc_trunk_timeouts().
05373 { 05374 char buf[80]; 05375 struct sla_station_ref *station_ref; 05376 05377 snprintf(buf, sizeof(buf), "SLA_%s,K", ringing_trunk->trunk->name); 05378 admin_exec(NULL, buf); 05379 sla_change_trunk_state(ringing_trunk->trunk, SLA_TRUNK_STATE_IDLE, ALL_TRUNK_REFS, NULL); 05380 05381 while ((station_ref = AST_LIST_REMOVE_HEAD(&ringing_trunk->timed_out_stations, entry))) 05382 ast_free(station_ref); 05383 05384 ast_free(ringing_trunk); 05385 }
| static void* sla_thread | ( | void * | data | ) | [static] |
Definition at line 6059 of file app_meetme.c.
References ast_cond_timedwait, ast_cond_wait, ast_free, AST_LIST_EMPTY, AST_LIST_REMOVE_HEAD, ast_mutex_lock, ast_mutex_unlock, sla, sla_check_reload(), SLA_EVENT_CHECK_RELOAD, SLA_EVENT_DIAL_STATE, SLA_EVENT_HOLD, SLA_EVENT_RELOAD, SLA_EVENT_RINGING_TRUNK, sla_handle_dial_state_event(), sla_handle_hold_event(), sla_handle_ringing_trunk_event(), sla_process_timers(), and sla_event::type.
Referenced by sla_load_config().
06060 { 06061 struct sla_failed_station *failed_station; 06062 struct sla_ringing_station *ringing_station; 06063 06064 ast_mutex_lock(&sla.lock); 06065 06066 while (!sla.stop) { 06067 struct sla_event *event; 06068 struct timespec ts = { 0, }; 06069 unsigned int have_timeout = 0; 06070 06071 if (AST_LIST_EMPTY(&sla.event_q)) { 06072 if ((have_timeout = sla_process_timers(&ts))) 06073 ast_cond_timedwait(&sla.cond, &sla.lock, &ts); 06074 else 06075 ast_cond_wait(&sla.cond, &sla.lock); 06076 if (sla.stop) 06077 break; 06078 } 06079 06080 if (have_timeout) 06081 sla_process_timers(NULL); 06082 06083 while ((event = AST_LIST_REMOVE_HEAD(&sla.event_q, entry))) { 06084 ast_mutex_unlock(&sla.lock); 06085 switch (event->type) { 06086 case SLA_EVENT_HOLD: 06087 sla_handle_hold_event(event); 06088 break; 06089 case SLA_EVENT_DIAL_STATE: 06090 sla_handle_dial_state_event(); 06091 break; 06092 case SLA_EVENT_RINGING_TRUNK: 06093 sla_handle_ringing_trunk_event(); 06094 break; 06095 case SLA_EVENT_RELOAD: 06096 sla.reload = 1; 06097 case SLA_EVENT_CHECK_RELOAD: 06098 break; 06099 } 06100 ast_free(event); 06101 ast_mutex_lock(&sla.lock); 06102 } 06103 06104 if (sla.reload) { 06105 sla_check_reload(); 06106 } 06107 } 06108 06109 ast_mutex_unlock(&sla.lock); 06110 06111 while ((ringing_station = AST_LIST_REMOVE_HEAD(&sla.ringing_stations, entry))) 06112 ast_free(ringing_station); 06113 06114 while ((failed_station = AST_LIST_REMOVE_HEAD(&sla.failed_stations, entry))) 06115 ast_free(failed_station); 06116 06117 return NULL; 06118 }
| static int sla_trunk_exec | ( | struct ast_channel * | chan, | |
| const char * | data | |||
| ) | [static] |
Definition at line 6460 of file app_meetme.c.
References ALL_TRUNK_REFS, args, AST_APP_ARG, ast_app_parse_options(), ast_atomic_fetchadd_int(), AST_CONTROL_RINGING, AST_DECLARE_APP_ARGS, ast_free, ast_indicate(), AST_LIST_REMOVE_CURRENT, AST_LIST_TRAVERSE_SAFE_BEGIN, AST_LIST_TRAVERSE_SAFE_END, ast_log(), ast_mutex_lock, ast_mutex_unlock, AST_RWLIST_RDLOCK, AST_RWLIST_UNLOCK, ast_set_flag64, AST_STANDARD_APP_ARGS, ast_strdupa, ast_strlen_zero(), ast_test_flag, build_conf(), conf_run(), CONFFLAG_MARKEDEXIT, CONFFLAG_MARKEDUSER, CONFFLAG_MOH, CONFFLAG_NO_AUDIO_UNTIL_UP, CONFFLAG_PASS_DTMF, CONFFLAG_QUIET, dispose_conf(), LOG_ERROR, MAX_CONFNUM, parse(), pbx_builtin_getvar_helper(), pbx_builtin_setvar_helper(), queue_ringing_trunk(), sla, sla_change_trunk_state(), SLA_EVENT_CHECK_RELOAD, SLA_EVENT_RINGING_TRUNK, sla_find_trunk(), sla_queue_event(), SLA_TRUNK_OPT_ARG_ARRAY_SIZE, SLA_TRUNK_OPT_MOH, SLA_TRUNK_STATE_IDLE, and sla_ringing_trunk::trunk.
Referenced by load_module().
06461 { 06462 char conf_name[MAX_CONFNUM]; 06463 struct ast_conference *conf; 06464 struct ast_flags64 conf_flags = { 0 }; 06465 struct sla_trunk *trunk; 06466 struct sla_ringing_trunk *ringing_trunk; 06467 AST_DECLARE_APP_ARGS(args, 06468 AST_APP_ARG(trunk_name); 06469 AST_APP_ARG(options); 06470 ); 06471 char *opts[SLA_TRUNK_OPT_ARG_ARRAY_SIZE] = { NULL, }; 06472 struct ast_flags opt_flags = { 0 }; 06473 char *parse; 06474 06475 if (ast_strlen_zero(data)) { 06476 ast_log(LOG_ERROR, "The SLATrunk application requires an argument, the trunk name\n"); 06477 return -1; 06478 } 06479 06480 parse = ast_strdupa(data); 06481 AST_STANDARD_APP_ARGS(args, parse); 06482 if (args.argc == 2) { 06483 if (ast_app_parse_options(sla_trunk_opts, &opt_flags, opts, args.options)) { 06484 ast_log(LOG_ERROR, "Error parsing options for SLATrunk\n"); 06485 return -1; 06486 } 06487 } 06488 06489 AST_RWLIST_RDLOCK(&sla_trunks); 06490 trunk = sla_find_trunk(args.trunk_name); 06491 if (trunk) 06492 ast_atomic_fetchadd_int((int *) &trunk->ref_count, 1); 06493 AST_RWLIST_UNLOCK(&sla_trunks); 06494 06495 if (!trunk) { 06496 ast_log(LOG_ERROR, "SLA Trunk '%s' not found!\n", args.trunk_name); 06497 pbx_builtin_setvar_helper(chan, "SLATRUNK_STATUS", "FAILURE"); 06498 sla_queue_event(SLA_EVENT_CHECK_RELOAD); 06499 return 0; 06500 } 06501 06502 if (trunk->chan) { 06503 ast_log(LOG_ERROR, "Call came in on %s, but the trunk is already in use!\n", 06504 args.trunk_name); 06505 pbx_builtin_setvar_helper(chan, "SLATRUNK_STATUS", "FAILURE"); 06506 ast_atomic_fetchadd_int((int *) &trunk->ref_count, -1); 06507 sla_queue_event(SLA_EVENT_CHECK_RELOAD); 06508 return 0; 06509 } 06510 06511 trunk->chan = chan; 06512 06513 if (!(ringing_trunk = queue_ringing_trunk(trunk))) { 06514 pbx_builtin_setvar_helper(chan, "SLATRUNK_STATUS", "FAILURE"); 06515 ast_atomic_fetchadd_int((int *) &trunk->ref_count, -1); 06516 sla_queue_event(SLA_EVENT_CHECK_RELOAD); 06517 return 0; 06518 } 06519 06520 snprintf(conf_name, sizeof(conf_name), "SLA_%s", args.trunk_name); 06521 conf = build_conf(conf_name, "", "", 1, 1, 1, chan, NULL); 06522 if (!conf) { 06523 pbx_builtin_setvar_helper(chan, "SLATRUNK_STATUS", "FAILURE"); 06524 ast_atomic_fetchadd_int((int *) &trunk->ref_count, -1); 06525 sla_queue_event(SLA_EVENT_CHECK_RELOAD); 06526 return 0; 06527 } 06528 ast_set_flag64(&conf_flags, 06529 CONFFLAG_QUIET | CONFFLAG_MARKEDEXIT | CONFFLAG_MARKEDUSER | CONFFLAG_PASS_DTMF | CONFFLAG_NO_AUDIO_UNTIL_UP); 06530 06531 if (ast_test_flag(&opt_flags, SLA_TRUNK_OPT_MOH)) { 06532 ast_indicate(chan, -1); 06533 ast_set_flag64(&conf_flags, CONFFLAG_MOH); 06534 } else 06535 ast_indicate(chan, AST_CONTROL_RINGING); 06536 06537 conf_run(chan, conf, &conf_flags, opts); 06538 dispose_conf(conf); 06539 conf = NULL; 06540 trunk->chan = NULL; 06541 trunk->on_hold = 0; 06542 06543 sla_change_trunk_state(trunk, SLA_TRUNK_STATE_IDLE, ALL_TRUNK_REFS, NULL); 06544 06545 if (!pbx_builtin_getvar_helper(chan, "SLATRUNK_STATUS")) 06546 pbx_builtin_setvar_helper(chan, "SLATRUNK_STATUS", "SUCCESS"); 06547 06548 /* Remove the entry from the list of ringing trunks if it is still there. */ 06549 ast_mutex_lock(&sla.lock); 06550 AST_LIST_TRAVERSE_SAFE_BEGIN(&sla.ringing_trunks, ringing_trunk, entry) { 06551 if (ringing_trunk->trunk == trunk) { 06552 AST_LIST_REMOVE_CURRENT(entry); 06553 break; 06554 } 06555 } 06556 AST_LIST_TRAVERSE_SAFE_END; 06557 ast_mutex_unlock(&sla.lock); 06558 if (ringing_trunk) { 06559 ast_free(ringing_trunk); 06560 pbx_builtin_setvar_helper(chan, "SLATRUNK_STATUS", "UNANSWERED"); 06561 /* Queue reprocessing of ringing trunks to make stations stop ringing 06562 * that shouldn't be ringing after this trunk stopped. */ 06563 sla_queue_event(SLA_EVENT_RINGING_TRUNK); 06564 } 06565 06566 ast_atomic_fetchadd_int((int *) &trunk->ref_count, -1); 06567 sla_queue_event(SLA_EVENT_CHECK_RELOAD); 06568 06569 return 0; 06570 }
| static const char* trunkstate2str | ( | enum sla_trunk_state | state | ) | [static] |
Definition at line 1760 of file app_meetme.c.
References S, SLA_TRUNK_STATE_IDLE, SLA_TRUNK_STATE_ONHOLD, SLA_TRUNK_STATE_ONHOLD_BYME, SLA_TRUNK_STATE_RINGING, and SLA_TRUNK_STATE_UP.
Referenced by sla_show_stations().
01761 { 01762 #define S(e) case e: return # e; 01763 switch (state) { 01764 S(SLA_TRUNK_STATE_IDLE) 01765 S(SLA_TRUNK_STATE_RINGING) 01766 S(SLA_TRUNK_STATE_UP) 01767 S(SLA_TRUNK_STATE_ONHOLD) 01768 S(SLA_TRUNK_STATE_ONHOLD_BYME) 01769 } 01770 return "Uknown State"; 01771 #undef S 01772 }
| static void tweak_listen_volume | ( | struct ast_conf_user * | user, | |
| enum volume_action | action | |||
| ) | [static] |
Definition at line 1092 of file app_meetme.c.
References volume::actual, volume::desired, ast_conf_user::listen, set_listen_volume(), and tweak_volume().
Referenced by admin_exec(), conf_run(), user_listen_voldown_cb(), and user_listen_volup_cb().
01093 { 01094 tweak_volume(&user->listen, action); 01095 /* attempt to make the adjustment in the channel driver; 01096 if successful, don't adjust in the frame reading routine 01097 */ 01098 if (!set_listen_volume(user, user->listen.desired)) 01099 user->listen.actual = 0; 01100 else 01101 user->listen.actual = user->listen.desired; 01102 }
| static void tweak_talk_volume | ( | struct ast_conf_user * | user, | |
| enum volume_action | action | |||
| ) | [static] |
Definition at line 1080 of file app_meetme.c.
References volume::actual, volume::desired, set_talk_volume(), ast_conf_user::talk, and tweak_volume().
Referenced by admin_exec(), conf_run(), user_talk_voldown_cb(), and user_talk_volup_cb().
01081 { 01082 tweak_volume(&user->talk, action); 01083 /* attempt to make the adjustment in the channel driver; 01084 if successful, don't adjust in the frame reading routine 01085 */ 01086 if (!set_talk_volume(user, user->talk.desired)) 01087 user->talk.actual = 0; 01088 else 01089 user->talk.actual = user->talk.desired; 01090 }
| static void tweak_volume | ( | struct volume * | vol, | |
| enum volume_action | action | |||
| ) | [static] |
Definition at line 1045 of file app_meetme.c.
References volume::desired, VOL_DOWN, and VOL_UP.
Referenced by tweak_listen_volume(), and tweak_talk_volume().
01046 { 01047 switch (action) { 01048 case VOL_UP: 01049 switch (vol->desired) { 01050 case 5: 01051 break; 01052 case 0: 01053 vol->desired = 2; 01054 break; 01055 case -2: 01056 vol->desired = 0; 01057 break; 01058 default: 01059 vol->desired++; 01060 break; 01061 } 01062 break; 01063 case VOL_DOWN: 01064 switch (vol->desired) { 01065 case -5: 01066 break; 01067 case 2: 01068 vol->desired = 0; 01069 break; 01070 case 0: 01071 vol->desired = -2; 01072 break; 01073 default: 01074 vol->desired--; 01075 break; 01076 } 01077 } 01078 }
| static int unload_module | ( | void | ) | [static] |
Definition at line 7268 of file app_meetme.c.
References ARRAY_LEN, ast_cli_unregister_multiple(), ast_custom_function_unregister(), ast_data_unregister, ast_devstate_prov_del(), ast_manager_unregister(), AST_TEST_UNREGISTER, ast_unload_realtime(), ast_unregister_application(), and sla_destroy().
07269 { 07270 int res = 0; 07271 07272 ast_cli_unregister_multiple(cli_meetme, ARRAY_LEN(cli_meetme)); 07273 res = ast_manager_unregister("MeetmeMute"); 07274 res |= ast_manager_unregister("MeetmeUnmute"); 07275 res |= ast_manager_unregister("MeetmeList"); 07276 res |= ast_unregister_application(app4); 07277 res |= ast_unregister_application(app3); 07278 res |= ast_unregister_application(app2); 07279 res |= ast_unregister_application(app); 07280 res |= ast_unregister_application(slastation_app); 07281 res |= ast_unregister_application(slatrunk_app); 07282 07283 #ifdef TEST_FRAMEWORK 07284 AST_TEST_UNREGISTER(test_meetme_data_provider); 07285 #endif 07286 ast_data_unregister(NULL); 07287 07288 ast_devstate_prov_del("Meetme"); 07289 ast_devstate_prov_del("SLA"); 07290 07291 sla_destroy(); 07292 07293 res |= ast_custom_function_unregister(&meetme_info_acf); 07294 ast_unload_realtime("meetme"); 07295 07296 return res; 07297 }
| static int user_add_provider_cb | ( | void * | obj, | |
| void * | arg, | |||
| int | flags | |||
| ) | [static] |
Definition at line 7119 of file app_meetme.c.
References volume::actual, ast_channel_data_add_structure(), ast_data_add_int(), ast_data_add_node(), ast_data_add_structure, ast_conf_user::chan, volume::desired, ast_conf_user::listen, and ast_conf_user::talk.
Referenced by meetme_data_provider_get().
07120 { 07121 struct ast_data *data_meetme_user; 07122 struct ast_data *data_meetme_user_channel; 07123 struct ast_data *data_meetme_user_volume; 07124 07125 struct ast_conf_user *user = obj; 07126 struct ast_data *data_meetme_users = arg; 07127 07128 data_meetme_user = ast_data_add_node(data_meetme_users, "user"); 07129 if (!data_meetme_user) { 07130 return 0; 07131 } 07132 /* user structure */ 07133 ast_data_add_structure(ast_conf_user, data_meetme_user, user); 07134 07135 /* user's channel */ 07136 data_meetme_user_channel = ast_data_add_node(data_meetme_user, "channel"); 07137 if (!data_meetme_user_channel) { 07138 return 0; 07139 } 07140 07141 ast_channel_data_add_structure(data_meetme_user_channel, user->chan, 1); 07142 07143 /* volume structure */ 07144 data_meetme_user_volume = ast_data_add_node(data_meetme_user, "listen-volume"); 07145 if (!data_meetme_user_volume) { 07146 return 0; 07147 } 07148 ast_data_add_int(data_meetme_user_volume, "desired", user->listen.desired); 07149 ast_data_add_int(data_meetme_user_volume, "actual", user->listen.actual); 07150 07151 data_meetme_user_volume = ast_data_add_node(data_meetme_user, "talk-volume"); 07152 if (!data_meetme_user_volume) { 07153 return 0; 07154 } 07155 ast_data_add_int(data_meetme_user_volume, "desired", user->talk.desired); 07156 ast_data_add_int(data_meetme_user_volume, "actual", user->talk.actual); 07157 07158 return 0; 07159 }
| static int user_chan_cb | ( | void * | obj, | |
| void * | args, | |||
| int | flags | |||
| ) | [static] |
Definition at line 4615 of file app_meetme.c.
References ast_conf_user::chan, CMP_MATCH, and CMP_STOP.
Referenced by channel_admin_exec().
| static int user_listen_voldown_cb | ( | void * | obj, | |
| void * | unused, | |||
| int | flags | |||
| ) | [static] |
Definition at line 4587 of file app_meetme.c.
References tweak_listen_volume(), and VOL_DOWN.
Referenced by admin_exec().
04588 { 04589 struct ast_conf_user *user = obj; 04590 tweak_listen_volume(user, VOL_DOWN); 04591 return 0; 04592 }
| static int user_listen_volup_cb | ( | void * | obj, | |
| void * | unused, | |||
| int | flags | |||
| ) | [static] |
Definition at line 4580 of file app_meetme.c.
References tweak_listen_volume(), and VOL_UP.
Referenced by admin_exec().
04581 { 04582 struct ast_conf_user *user = obj; 04583 tweak_listen_volume(user, VOL_UP); 04584 return 0; 04585 }
| static int user_max_cmp | ( | void * | obj, | |
| void * | arg, | |||
| int | flags | |||
| ) | [static] |
Definition at line 1165 of file app_meetme.c.
References ast_conf_user::user_no.
Referenced by admin_exec(), and conf_run().
01166 { 01167 struct ast_conf_user *user = obj; 01168 int *max_no = arg; 01169 01170 if (user->user_no > *max_no) { 01171 *max_no = user->user_no; 01172 } 01173 01174 return 0; 01175 }
| static int user_no_cmp | ( | void * | obj, | |
| void * | arg, | |||
| int | flags | |||
| ) | [static] |
Definition at line 1153 of file app_meetme.c.
References CMP_MATCH, CMP_STOP, and ast_conf_user::user_no.
Referenced by build_conf().
| static int user_reset_vol_cb | ( | void * | obj, | |
| void * | unused, | |||
| int | flags | |||
| ) | [static] |
Definition at line 4608 of file app_meetme.c.
References reset_volumes().
Referenced by admin_exec().
04609 { 04610 struct ast_conf_user *user = obj; 04611 reset_volumes(user); 04612 return 0; 04613 }
| static int user_set_kickme_cb | ( | void * | obj, | |
| void * | check_admin_arg, | |||
| int | flags | |||
| ) | [static] |
Definition at line 2251 of file app_meetme.c.
References ADMINFLAG_KICKME, ast_conf_user::adminflags, ast_test_flag64, CONFFLAG_ADMIN, and ast_conf_user::userflags.
Referenced by admin_exec(), and conf_run().
02252 { 02253 struct ast_conf_user *user = obj; 02254 /* actual pointer contents of check_admin_arg is irrelevant */ 02255 02256 if (!check_admin_arg || (check_admin_arg && !ast_test_flag64(&user->userflags, CONFFLAG_ADMIN))) { 02257 user->adminflags |= ADMINFLAG_KICKME; 02258 } 02259 return 0; 02260 }
| static int user_set_muted_cb | ( | void * | obj, | |
| void * | check_admin_arg, | |||
| int | flags | |||
| ) | [static] |
Definition at line 2273 of file app_meetme.c.
References ADMINFLAG_MUTED, ast_conf_user::adminflags, ast_test_flag64, CONFFLAG_ADMIN, and ast_conf_user::userflags.
Referenced by admin_exec(), and conf_run().
02274 { 02275 struct ast_conf_user *user = obj; 02276 /* actual pointer contents of check_admin_arg is irrelevant */ 02277 02278 if (!check_admin_arg || !ast_test_flag64(&user->userflags, CONFFLAG_ADMIN)) { 02279 user->adminflags |= ADMINFLAG_MUTED; 02280 } 02281 return 0; 02282 }
| static int user_set_unmuted_cb | ( | void * | obj, | |
| void * | check_admin_arg, | |||
| int | flags | |||
| ) | [static] |
Definition at line 2262 of file app_meetme.c.
References ADMINFLAG_MUTED, ADMINFLAG_SELFMUTED, ADMINFLAG_T_REQUEST, ast_conf_user::adminflags, ast_test_flag64, CONFFLAG_ADMIN, and ast_conf_user::userflags.
Referenced by admin_exec(), and conf_run().
02263 { 02264 struct ast_conf_user *user = obj; 02265 /* actual pointer contents of check_admin_arg is irrelevant */ 02266 02267 if (!check_admin_arg || !ast_test_flag64(&user->userflags, CONFFLAG_ADMIN)) { 02268 user->adminflags &= ~(ADMINFLAG_MUTED | ADMINFLAG_SELFMUTED | ADMINFLAG_T_REQUEST); 02269 } 02270 return 0; 02271 }
| static int user_talk_voldown_cb | ( | void * | obj, | |
| void * | unused, | |||
| int | flags | |||
| ) | [static] |
Definition at line 4601 of file app_meetme.c.
References tweak_talk_volume(), and VOL_DOWN.
Referenced by admin_exec().
04602 { 04603 struct ast_conf_user *user = obj; 04604 tweak_talk_volume(user, VOL_DOWN); 04605 return 0; 04606 }
| static int user_talk_volup_cb | ( | void * | obj, | |
| void * | unused, | |||
| int | flags | |||
| ) | [static] |
Definition at line 4594 of file app_meetme.c.
References tweak_talk_volume(), and VOL_UP.
Referenced by admin_exec().
04595 { 04596 struct ast_conf_user *user = obj; 04597 tweak_talk_volume(user, VOL_UP); 04598 return 0; 04599 }
const char* const app = "MeetMe" [static] |
Definition at line 665 of file app_meetme.c.
const char* const app2 = "MeetMeCount" [static] |
Definition at line 666 of file app_meetme.c.
const char* const app3 = "MeetMeAdmin" [static] |
Definition at line 667 of file app_meetme.c.
const char* const app4 = "MeetMeChannelAdmin" [static] |
Definition at line 668 of file app_meetme.c.
int audio_buffers [static] |
The number of audio buffers to be allocated on pseudo channels when in a conference.
Definition at line 957 of file app_meetme.c.
struct ast_cli_entry cli_meetme[] [static] |
Definition at line 1850 of file app_meetme.c.
Definition at line 939 of file app_meetme.c.
Referenced by _macro_exec(), ast_safe_sleep_conditional(), gosubif_exec(), and smdi_message_wait().
unsigned int conf_map[1024] = {0, } [static] |
Definition at line 750 of file app_meetme.c.
Referenced by build_conf(), conf_exec(), and dispose_conf().
int earlyalert [static] |
Definition at line 675 of file app_meetme.c.
int endalert [static] |
Definition at line 676 of file app_meetme.c.
int extendby [static] |
Definition at line 677 of file app_meetme.c.
int fuzzystart [static] |
Definition at line 674 of file app_meetme.c.
const char gain_map[] [static] |
Map 'volume' levels from -5 through +5 into decibel (dB) settings for channel drivers.
Definition at line 966 of file app_meetme.c.
Definition at line 940 of file app_meetme.c.
Referenced by ast_localtime_wakeup_monitor(), reload(), smdi_message_wait(), and write_cdr().
struct ast_data_handler meetme_data_provider [static] |
{
.version = AST_DATA_HANDLER_VERSION,
.get = meetme_data_provider_get
}
Definition at line 7199 of file app_meetme.c.
struct ast_data_entry meetme_data_providers[] [static] |
{
AST_DATA_ENTRY("asterisk/application/meetme/list", &meetme_data_provider),
}
Definition at line 7204 of file app_meetme.c.
struct ast_custom_function meetme_info_acf [static] |
{
.name = "MEETME_INFO",
.read = acf_meetme_info,
}
Definition at line 7070 of file app_meetme.c.
int rt_log_members [static] |
Log participant count to the RealTime backend
Definition at line 680 of file app_meetme.c.
int rt_schedule [static] |
Definition at line 673 of file app_meetme.c.
struct { ... } sla [static] |
A structure for data used by the sla thread.
Referenced by dial_trunk(), load_config(), queue_ringing_trunk(), sla_calc_station_timeouts(), sla_calc_trunk_timeouts(), sla_check_failed_station(), sla_check_reload(), sla_check_ringing_station(), sla_choose_ringing_trunk(), sla_destroy(), sla_handle_dial_state_event(), sla_handle_ringing_trunk_event(), sla_hangup_stations(), sla_load_config(), sla_queue_event_full(), sla_ring_station(), sla_ring_stations(), sla_station_exec(), sla_stop_ringing_station(), sla_thread(), and sla_trunk_exec().
const char sla_registrar[] = "SLA" [static] |
Definition at line 880 of file app_meetme.c.
Referenced by destroy_station(), destroy_trunk(), sla_build_station(), sla_build_trunk(), and sla_destroy().
const char* const slastation_app = "SLAStation" [static] |
Definition at line 669 of file app_meetme.c.
const char* const slatrunk_app = "SLATrunk" [static] |
Definition at line 670 of file app_meetme.c.
| pthread_t thread |
The SLA thread ID
Definition at line 938 of file app_meetme.c.
Referenced by __schedule_action(), ast_bridge_depart(), ast_bridge_destroy(), bridge_call_thread_launch(), cleanup_thread_list(), find_idle_thread(), handle_cli_iax2_show_threads(), iax2_process_thread(), iax2_process_thread_cleanup(), launch_monitor_thread(), load_module(), multiplexed_add_or_remove(), socket_read(), start_network_thread(), and unload_module().
1.6.1