#include "asterisk.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include "asterisk/lock.h"
#include "asterisk/file.h"
#include "asterisk/logger.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/options.h"
#include "asterisk/cli.h"
#include "asterisk/say.h"
#include "asterisk/utils.h"
#include "asterisk/translate.h"
#include "asterisk/ulaw.h"
#include "asterisk/astobj.h"
#include "asterisk/astobj2.h"
#include "asterisk/devicestate.h"
#include "asterisk/dial.h"
#include "asterisk/causes.h"
#include "asterisk/dahdi_compat.h"
#include "enter.h"
#include "leave.h"

Go to the source code of this file.
Data Structures | |
| struct | announce_listitem |
| struct | ast_conf_user |
| struct | ast_conference |
| The MeetMe Conference object. More... | |
| struct | confs |
| 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_stations |
| struct | sla_trunk |
| struct | sla_trunk_ref |
| struct | sla_trunks |
| struct | volume |
Defines | |
| #define | AST_FRAME_BITS 32 |
| #define | CONF_SIZE 320 |
| #define | CONFIG_FILE_NAME "meetme.conf" |
| #define | DEFAULT_AUDIO_BUFFERS 32 |
| #define | MAX_CONFNUM 80 |
| #define | MAX_PIN 80 |
| #define | MEETME_DELAYDETECTENDTALK 1000 |
| #define | MEETME_DELAYDETECTTALK 300 |
| #define | S(e) case e: return # e; |
| #define | SLA_CONFIG_FILE "sla.conf" |
Enumerations | |
| enum | { ADMINFLAG_MUTED = (1 << 1), ADMINFLAG_SELFMUTED = (1 << 2), ADMINFLAG_KICKME = (1 << 3) } |
| enum | { CONFFLAG_ADMIN = (1 << 0), CONFFLAG_MONITOR = (1 << 1), CONFFLAG_POUNDEXIT = (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_NO_AUDIO_UNTIL_UP = (1 << 28) } |
| enum | { OPT_ARG_WAITMARKED = 0, 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 } |
| 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 void | __reg_module (void) |
| static void | __unreg_module (void) |
| 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, void *data) |
| The MeetMeadmin application. | |
| static void * | announce_thread (void *data) |
| static void | answer_trunk_chan (struct ast_channel *chan) |
| static struct ast_conference * | build_conf (char *confno, char *pin, char *pinadmin, int make, int dynamic, int refcount) |
| Find or create a conference. | |
| static int | can_write (struct ast_channel *chan, int confflags) |
| static int | careful_write (int fd, unsigned char *data, int len, int block) |
| static char * | complete_meetmecmd (const char *line, const char *word, int pos, int state) |
| static int | conf_exec (struct ast_channel *chan, void *data) |
| The meetme() application. | |
| static void | conf_flush (int fd, struct ast_channel *chan) |
| static int | conf_free (struct ast_conference *conf) |
| 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, int confflags, char *optargs[]) |
| static int | count_exec (struct ast_channel *chan, void *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) |
| 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_flags *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_flags *confflags) |
| static struct ast_conf_user * | find_user (struct ast_conference *conf, char *callerident) |
| static const char * | get_announce_filename (enum announcetypes type) |
| static char * | istalking (int x) |
| static int | load_config (int reload) |
| static void | load_config_meetme (void) |
| static int | load_module (void) |
| static int | meetme_cmd (int fd, int argc, char **argv) |
| static int | meetmemute (struct mansession *s, const struct message *m, int mute) |
| static int | 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 void * | run_station (void *data) |
| 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 | 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 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 remove) |
| 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 (void) |
| 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 int | sla_show_stations (int fd, int argc, char **argv) |
| static int | sla_show_trunks (int fd, int argc, char **argv) |
| static int | sla_state (const char *data) |
| static int | sla_station_exec (struct ast_channel *chan, void *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, void *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) |
Variables | |
| static struct ast_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT | AST_MODFLAG_BUILDSUM, .description = "MeetMe conference bridge" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, .reload = reload, } |
| static const char * | app = "MeetMe" |
| static const char * | app2 = "MeetMeCount" |
| static const char * | app3 = "MeetMeAdmin" |
| static const struct ast_module_info * | ast_module_info = &__mod_info |
| static int | audio_buffers |
| static struct ast_cli_entry | cli_meetme [] |
| static unsigned int | conf_map [1024] = {0, } |
| static const char * | descrip |
| static const char * | descrip2 |
| static const char * | descrip3 |
| static char const | gain_map [] |
| static struct ast_app_option | meetme_opts [128] = { [ 'A' ] = { .flag = CONFFLAG_MARKEDUSER }, [ 'a' ] = { .flag = CONFFLAG_ADMIN }, [ 'b' ] = { .flag = CONFFLAG_AGI }, [ 'c' ] = { .flag = CONFFLAG_ANNOUNCEUSERCOUNT }, [ 'D' ] = { .flag = CONFFLAG_DYNAMICPIN }, [ 'd' ] = { .flag = CONFFLAG_DYNAMIC }, [ 'E' ] = { .flag = CONFFLAG_EMPTYNOPIN }, [ 'e' ] = { .flag = CONFFLAG_EMPTY }, [ 'F' ] = { .flag = CONFFLAG_PASS_DTMF }, [ 'i' ] = { .flag = CONFFLAG_INTROUSER }, [ 'I' ] = { .flag = CONFFLAG_INTROUSERNOREVIEW }, [ 'M' ] = { .flag = CONFFLAG_MOH }, [ 'm' ] = { .flag = CONFFLAG_STARTMUTED }, [ 'o' ] = { .flag = CONFFLAG_OPTIMIZETALKER }, [ 'P' ] = { .flag = CONFFLAG_ALWAYSPROMPT }, [ 'p' ] = { .flag = CONFFLAG_POUNDEXIT }, [ 'q' ] = { .flag = CONFFLAG_QUIET }, [ 'r' ] = { .flag = CONFFLAG_RECORDCONF }, [ 's' ] = { .flag = CONFFLAG_STARMENU }, [ 'T' ] = { .flag = CONFFLAG_MONITORTALKER }, [ 'l' ] = { .flag = CONFFLAG_MONITOR }, [ 't' ] = { .flag = CONFFLAG_TALKER }, [ 'w' ] = { .flag = CONFFLAG_WAITMARKED , .arg_index = OPT_ARG_WAITMARKED + 1 }, [ 'X' ] = { .flag = CONFFLAG_EXIT_CONTEXT }, [ 'x' ] = { .flag = CONFFLAG_MARKEDEXIT }, [ '1' ] = { .flag = CONFFLAG_NOONLYPERSON }, } |
| static char | meetme_usage [] |
| struct { | |
| unsigned int attempt_callerid:1 | |
| ast_cond_t cond | |
| struct { | |
| struct sla_event * first | |
| struct sla_event * last | |
| } event_q | |
| struct { | |
| struct sla_failed_station * first | |
| struct sla_failed_station * last | |
| } failed_stations | |
| ast_mutex_t lock | |
| struct { | |
| struct sla_ringing_station * first | |
| struct sla_ringing_station * last | |
| } ringing_stations | |
| struct { | |
| struct sla_ringing_trunk * first | |
| struct sla_ringing_trunk * last | |
| } ringing_trunks | |
| unsigned int stop:1 | |
| pthread_t thread | |
| } | sla |
| A structure for data used by the sla thread. | |
| static const char | sla_registrar [] = "SLA" |
| static const char | sla_show_stations_usage [] |
| static const char | sla_show_trunks_usage [] |
| static const char * | slastation_app = "SLAStation" |
| static const char * | slastation_desc |
| static const char * | slastation_synopsis = "Shared Line Appearance Station" |
| static const char * | slatrunk_app = "SLATrunk" |
| static const char * | slatrunk_desc |
| static const char * | slatrunk_synopsis = "Shared Line Appearance Trunk" |
| static const char * | synopsis = "MeetMe conference bridge" |
| static const char * | synopsis2 = "MeetMe participant count" |
| static const char * | synopsis3 = "MeetMe conference Administration" |
Definition in file app_meetme.c.
| #define AST_FRAME_BITS 32 |
Definition at line 92 of file app_meetme.c.
Referenced by conf_free(), conf_run(), and recordthread().
| #define CONF_SIZE 320 |
Definition at line 111 of file app_meetme.c.
| #define CONFIG_FILE_NAME "meetme.conf" |
Definition at line 77 of file app_meetme.c.
Referenced by conf_exec(), find_conf(), and load_config_meetme().
| #define DEFAULT_AUDIO_BUFFERS 32 |
each buffer is 20ms, so this is 640ms total
Definition at line 81 of file app_meetme.c.
Referenced by load_config_meetme().
| #define MAX_CONFNUM 80 |
Definition at line 319 of file app_meetme.c.
Referenced by conf_exec(), dial_trunk(), run_station(), sla_station_exec(), and sla_trunk_exec().
| #define MAX_PIN 80 |
| #define MEETME_DELAYDETECTENDTALK 1000 |
| #define MEETME_DELAYDETECTTALK 300 |
| #define S | ( | e | ) | case e: return # e; |
Referenced by sms_readfile(), and trunkstate2str().
| #define SLA_CONFIG_FILE "sla.conf" |
Definition at line 78 of file app_meetme.c.
Referenced by sla_build_station(), sla_build_trunk(), and sla_load_config().
| anonymous enum |
| ADMINFLAG_MUTED | User is muted |
| ADMINFLAG_SELFMUTED | User muted self |
| ADMINFLAG_KICKME | User has been kicked |
Definition at line 83 of file app_meetme.c.
00083 { 00084 ADMINFLAG_MUTED = (1 << 1), /*!< User is muted */ 00085 ADMINFLAG_SELFMUTED = (1 << 2), /*!< User muted self */ 00086 ADMINFLAG_KICKME = (1 << 3) /*!< User has been kicked */ 00087 };
| 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_POUNDEXIT | If set asterisk will exit conference when '#' 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 MeetMe will return if all marked with this flag left |
| 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 | If set, treats talking users as muted users |
| 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 | This is a SLA station. (Only for use by the SLA applications.) |
| CONFFLAG_SLA_TRUNK | This is a SLA trunk. (Only for use by the SLA applications.) |
| CONFFLAG_NO_AUDIO_UNTIL_UP | Do not write any audio to this channel until the state is up. |
Definition at line 113 of file app_meetme.c.
00113 { 00114 /*! user has admin access on the conference */ 00115 CONFFLAG_ADMIN = (1 << 0), 00116 /*! If set the user can only receive audio from the conference */ 00117 CONFFLAG_MONITOR = (1 << 1), 00118 /*! If set asterisk will exit conference when '#' is pressed */ 00119 CONFFLAG_POUNDEXIT = (1 << 2), 00120 /*! If set asterisk will provide a menu to the user when '*' is pressed */ 00121 CONFFLAG_STARMENU = (1 << 3), 00122 /*! If set the use can only send audio to the conference */ 00123 CONFFLAG_TALKER = (1 << 4), 00124 /*! If set there will be no enter or leave sounds */ 00125 CONFFLAG_QUIET = (1 << 5), 00126 /*! If set, when user joins the conference, they will be told the number 00127 * of users that are already in */ 00128 CONFFLAG_ANNOUNCEUSERCOUNT = (1 << 6), 00129 /*! Set to run AGI Script in Background */ 00130 CONFFLAG_AGI = (1 << 7), 00131 /*! Set to have music on hold when user is alone in conference */ 00132 CONFFLAG_MOH = (1 << 8), 00133 /*! If set the MeetMe will return if all marked with this flag left */ 00134 CONFFLAG_MARKEDEXIT = (1 << 9), 00135 /*! If set, the MeetMe will wait until a marked user enters */ 00136 CONFFLAG_WAITMARKED = (1 << 10), 00137 /*! If set, the MeetMe will exit to the specified context */ 00138 CONFFLAG_EXIT_CONTEXT = (1 << 11), 00139 /*! If set, the user will be marked */ 00140 CONFFLAG_MARKEDUSER = (1 << 12), 00141 /*! If set, user will be ask record name on entry of conference */ 00142 CONFFLAG_INTROUSER = (1 << 13), 00143 /*! If set, the MeetMe will be recorded */ 00144 CONFFLAG_RECORDCONF = (1<< 14), 00145 /*! If set, the user will be monitored if the user is talking or not */ 00146 CONFFLAG_MONITORTALKER = (1 << 15), 00147 CONFFLAG_DYNAMIC = (1 << 16), 00148 CONFFLAG_DYNAMICPIN = (1 << 17), 00149 CONFFLAG_EMPTY = (1 << 18), 00150 CONFFLAG_EMPTYNOPIN = (1 << 19), 00151 CONFFLAG_ALWAYSPROMPT = (1 << 20), 00152 /*! If set, treats talking users as muted users */ 00153 CONFFLAG_OPTIMIZETALKER = (1 << 21), 00154 /*! If set, won't speak the extra prompt when the first person 00155 * enters the conference */ 00156 CONFFLAG_NOONLYPERSON = (1 << 22), 00157 /*! If set, user will be asked to record name on entry of conference 00158 * without review */ 00159 CONFFLAG_INTROUSERNOREVIEW = (1 << 23), 00160 /*! If set, the user will be initially self-muted */ 00161 CONFFLAG_STARTMUTED = (1 << 24), 00162 /*! Pass DTMF through the conference */ 00163 CONFFLAG_PASS_DTMF = (1 << 25), 00164 /*! This is a SLA station. (Only for use by the SLA applications.) */ 00165 CONFFLAG_SLA_STATION = (1 << 26), 00166 /*! This is a SLA trunk. (Only for use by the SLA applications.) */ 00167 CONFFLAG_SLA_TRUNK = (1 << 27), 00168 /*! Do not write any audio to this channel until the state is up. */ 00169 CONFFLAG_NO_AUDIO_UNTIL_UP = (1 << 28), 00170 };
| anonymous enum |
Definition at line 172 of file app_meetme.c.
00172 { 00173 OPT_ARG_WAITMARKED = 0, 00174 OPT_ARG_ARRAY_SIZE = 1, 00175 };
| enum announcetypes |
Definition at line 322 of file app_meetme.c.
00322 { 00323 CONF_HASJOIN, 00324 CONF_HASLEFT 00325 };
| enum entrance_sound |
| enum recording_state |
Definition at line 104 of file app_meetme.c.
00104 { 00105 MEETME_RECORD_OFF, 00106 MEETME_RECORD_STARTED, 00107 MEETME_RECORD_ACTIVE, 00108 MEETME_RECORD_TERMINATE 00109 };
| 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 |
Definition at line 496 of file app_meetme.c.
00496 { 00497 /*! A station has put the call on hold */ 00498 SLA_EVENT_HOLD, 00499 /*! The state of a dial has changed */ 00500 SLA_EVENT_DIAL_STATE, 00501 /*! The state of a ringing trunk has changed */ 00502 SLA_EVENT_RINGING_TRUNK, 00503 };
| enum sla_hold_access |
Definition at line 410 of file app_meetme.c.
00410 { 00411 /*! This means that any station can put it on hold, and any station 00412 * can retrieve the call from hold. */ 00413 SLA_HOLD_OPEN, 00414 /*! This means that only the station that put the call on hold may 00415 * retrieve it from hold. */ 00416 SLA_HOLD_PRIVATE, 00417 };
| enum sla_station_hangup |
Definition at line 529 of file app_meetme.c.
00529 { 00530 SLA_STATION_HANGUP_NORMAL, 00531 SLA_STATION_HANGUP_TIMEOUT, 00532 };
| 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 402 of file app_meetme.c.
00402 { 00403 SLA_TRUNK_STATE_IDLE, 00404 SLA_TRUNK_STATE_RINGING, 00405 SLA_TRUNK_STATE_UP, 00406 SLA_TRUNK_STATE_ONHOLD, 00407 SLA_TRUNK_STATE_ONHOLD_BYME, 00408 };
| enum sla_which_trunk_refs |
Definition at line 397 of file app_meetme.c.
00397 { 00398 ALL_TRUNK_REFS, 00399 INACTIVE_TRUNK_REFS, 00400 };
| enum volume_action |
| static void __reg_module | ( | void | ) | [static] |
Definition at line 5044 of file app_meetme.c.
| static void __unreg_module | ( | void | ) | [static] |
Definition at line 5044 of file app_meetme.c.
| static int action_meetmemute | ( | struct mansession * | s, | |
| const struct message * | m | |||
| ) | [static] |
Definition at line 3157 of file app_meetme.c.
References meetmemute().
Referenced by load_module().
03158 { 03159 return meetmemute(s, m, 1); 03160 }
| static int action_meetmeunmute | ( | struct mansession * | s, | |
| const struct message * | m | |||
| ) | [static] |
Definition at line 3162 of file app_meetme.c.
References meetmemute().
Referenced by load_module().
03163 { 03164 return meetmemute(s, m, 0); 03165 }
| static int admin_exec | ( | struct ast_channel * | chan, | |
| void * | data | |||
| ) | [static] |
The MeetMeadmin application.
Definition at line 2943 of file app_meetme.c.
References ADMINFLAG_KICKME, ADMINFLAG_MUTED, ADMINFLAG_SELFMUTED, ast_conf_user::adminflags, AST_APP_ARG, ast_atomic_fetchadd_int(), AST_DECLARE_APP_ARGS, AST_LIST_LAST, AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, ast_log(), ast_module_user_add, ast_module_user_remove, AST_STANDARD_APP_ARGS, ast_strdupa, ast_strlen_zero(), CONFFLAG_ADMIN, ast_conference::confno, dispose_conf(), find_user(), ast_conference::locked, LOG_NOTICE, LOG_WARNING, ast_conference::refcount, reset_volumes(), tweak_listen_volume(), tweak_talk_volume(), ast_conf_user::userflags, ast_conference::userlist, VOL_DOWN, and VOL_UP.
Referenced by load_module(), meetme_cmd(), run_station(), sla_station_exec(), and sla_stop_ringing_trunk().
02943 { 02944 char *params; 02945 struct ast_conference *cnf; 02946 struct ast_conf_user *user = NULL; 02947 struct ast_module_user *u; 02948 AST_DECLARE_APP_ARGS(args, 02949 AST_APP_ARG(confno); 02950 AST_APP_ARG(command); 02951 AST_APP_ARG(user); 02952 ); 02953 02954 if (ast_strlen_zero(data)) { 02955 ast_log(LOG_WARNING, "MeetMeAdmin requires an argument!\n"); 02956 return -1; 02957 } 02958 02959 u = ast_module_user_add(chan); 02960 02961 AST_LIST_LOCK(&confs); 02962 02963 params = ast_strdupa(data); 02964 AST_STANDARD_APP_ARGS(args, params); 02965 02966 if (!args.command) { 02967 ast_log(LOG_WARNING, "MeetmeAdmin requires a command!\n"); 02968 AST_LIST_UNLOCK(&confs); 02969 ast_module_user_remove(u); 02970 return -1; 02971 } 02972 AST_LIST_TRAVERSE(&confs, cnf, list) { 02973 if (!strcmp(cnf->confno, args.confno)) 02974 break; 02975 } 02976 02977 if (!cnf) { 02978 ast_log(LOG_WARNING, "Conference number '%s' not found!\n", args.confno); 02979 AST_LIST_UNLOCK(&confs); 02980 ast_module_user_remove(u); 02981 return 0; 02982 } 02983 02984 ast_atomic_fetchadd_int(&cnf->refcount, 1); 02985 02986 if (args.user) 02987 user = find_user(cnf, args.user); 02988 02989 switch (*args.command) { 02990 case 76: /* L: Lock */ 02991 cnf->locked = 1; 02992 break; 02993 case 108: /* l: Unlock */ 02994 cnf->locked = 0; 02995 break; 02996 case 75: /* K: kick all users */ 02997 AST_LIST_TRAVERSE(&cnf->userlist, user, list) 02998 user->adminflags |= ADMINFLAG_KICKME; 02999 break; 03000 case 101: /* e: Eject last user*/ 03001 user = AST_LIST_LAST(&cnf->userlist); 03002 if (!(user->userflags & CONFFLAG_ADMIN)) 03003 user->adminflags |= ADMINFLAG_KICKME; 03004 else 03005 ast_log(LOG_NOTICE, "Not kicking last user, is an Admin!\n"); 03006 break; 03007 case 77: /* M: Mute */ 03008 if (user) { 03009 user->adminflags |= ADMINFLAG_MUTED; 03010 } else 03011 ast_log(LOG_NOTICE, "Specified User not found!\n"); 03012 break; 03013 case 78: /* N: Mute all (non-admin) users */ 03014 AST_LIST_TRAVERSE(&cnf->userlist, user, list) { 03015 if (!(user->userflags & CONFFLAG_ADMIN)) 03016 user->adminflags |= ADMINFLAG_MUTED; 03017 } 03018 break; 03019 case 109: /* m: Unmute */ 03020 if (user) { 03021 user->adminflags &= ~(ADMINFLAG_MUTED | ADMINFLAG_SELFMUTED); 03022 } else 03023 ast_log(LOG_NOTICE, "Specified User not found!\n"); 03024 break; 03025 case 110: /* n: Unmute all users */ 03026 AST_LIST_TRAVERSE(&cnf->userlist, user, list) 03027 user->adminflags &= ~(ADMINFLAG_MUTED | ADMINFLAG_SELFMUTED); 03028 break; 03029 case 107: /* k: Kick user */ 03030 if (user) 03031 user->adminflags |= ADMINFLAG_KICKME; 03032 else 03033 ast_log(LOG_NOTICE, "Specified User not found!\n"); 03034 break; 03035 case 118: /* v: Lower all users listen volume */ 03036 AST_LIST_TRAVERSE(&cnf->userlist, user, list) 03037 tweak_listen_volume(user, VOL_DOWN); 03038 break; 03039 case 86: /* V: Raise all users listen volume */ 03040 AST_LIST_TRAVERSE(&cnf->userlist, user, list) 03041 tweak_listen_volume(user, VOL_UP); 03042 break; 03043 case 115: /* s: Lower all users speaking volume */ 03044 AST_LIST_TRAVERSE(&cnf->userlist, user, list) 03045 tweak_talk_volume(user, VOL_DOWN); 03046 break; 03047 case 83: /* S: Raise all users speaking volume */ 03048 AST_LIST_TRAVERSE(&cnf->userlist, user, list) 03049 tweak_talk_volume(user, VOL_UP); 03050 break; 03051 case 82: /* R: Reset all volume levels */ 03052 AST_LIST_TRAVERSE(&cnf->userlist, user, list) 03053 reset_volumes(user); 03054 break; 03055 case 114: /* r: Reset user's volume level */ 03056 if (user) 03057 reset_volumes(user); 03058 else 03059 ast_log(LOG_NOTICE, "Specified User not found!\n"); 03060 break; 03061 case 85: /* U: Raise user's listen volume */ 03062 if (user) 03063 tweak_listen_volume(user, VOL_UP); 03064 else 03065 ast_log(LOG_NOTICE, "Specified User not found!\n"); 03066 break; 03067 case 117: /* u: Lower user's listen volume */ 03068 if (user) 03069 tweak_listen_volume(user, VOL_DOWN); 03070 else 03071 ast_log(LOG_NOTICE, "Specified User not found!\n"); 03072 break; 03073 case 84: /* T: Raise user's talk volume */ 03074 if (user) 03075 tweak_talk_volume(user, VOL_UP); 03076 else 03077 ast_log(LOG_NOTICE, "Specified User not found!\n"); 03078 break; 03079 case 116: /* t: Lower user's talk volume */ 03080 if (user) 03081 tweak_talk_volume(user, VOL_DOWN); 03082 else 03083 ast_log(LOG_NOTICE, "Specified User not found!\n"); 03084 break; 03085 } 03086 03087 AST_LIST_UNLOCK(&confs); 03088 03089 dispose_conf(cnf); 03090 03091 ast_module_user_remove(u); 03092 03093 return 0; 03094 }
| static void* announce_thread | ( | void * | data | ) | [static] |
Definition at line 1434 of file app_meetme.c.
References ast_conference::announcelist, ast_conference::announcelist_addition, ast_conference::announcelistlock, ast_conference::announcethread_stop, announce_listitem::announcetype, 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, announce_listitem::confchan, announce_listitem::confusers, get_announce_filename(), announce_listitem::language, LOG_DEBUG, and announce_listitem::namerecloc.
Referenced by conf_run().
01435 { 01436 struct announce_listitem *current; 01437 struct ast_conference *conf = data; 01438 int res; 01439 char filename[PATH_MAX] = ""; 01440 AST_LIST_HEAD_NOLOCK(, announce_listitem) local_list; 01441 AST_LIST_HEAD_INIT_NOLOCK(&local_list); 01442 01443 while (!conf->announcethread_stop) { 01444 ast_mutex_lock(&conf->announcelistlock); 01445 if (conf->announcethread_stop) { 01446 ast_mutex_unlock(&conf->announcelistlock); 01447 break; 01448 } 01449 if (AST_LIST_EMPTY(&conf->announcelist)) 01450 ast_cond_wait(&conf->announcelist_addition, &conf->announcelistlock); 01451 01452 AST_LIST_APPEND_LIST(&local_list, &conf->announcelist, entry); 01453 AST_LIST_HEAD_INIT_NOLOCK(&conf->announcelist); 01454 01455 ast_mutex_unlock(&conf->announcelistlock); 01456 if (conf->announcethread_stop) { 01457 break; 01458 } 01459 01460 for (res = 1; !conf->announcethread_stop && (current = AST_LIST_REMOVE_HEAD(&local_list, entry)); ao2_ref(current, -1)) { 01461 ast_log(LOG_DEBUG, "About to play %s\n", current->namerecloc); 01462 if (!ast_fileexists(current->namerecloc, NULL, NULL)) 01463 continue; 01464 if ((current->confchan) && (current->confusers > 1) && !ast_check_hangup(current->confchan)) { 01465 if (!ast_streamfile(current->confchan, current->namerecloc, current->language)) 01466 res = ast_waitstream(current->confchan, ""); 01467 if (!res) { 01468 ast_copy_string(filename, get_announce_filename(current->announcetype), sizeof(filename)); 01469 if (!ast_streamfile(current->confchan, filename, current->language)) 01470 ast_waitstream(current->confchan, ""); 01471 } 01472 } 01473 if (current->announcetype == CONF_HASLEFT) { 01474 ast_filedelete(current->namerecloc, NULL); 01475 } 01476 } 01477 } 01478 01479 /* thread marked to stop, clean up */ 01480 while ((current = AST_LIST_REMOVE_HEAD(&local_list, entry))) { 01481 ast_filedelete(current->namerecloc, NULL); 01482 ao2_ref(current, -1); 01483 } 01484 return NULL; 01485 }
| static void answer_trunk_chan | ( | struct ast_channel * | chan | ) | [static] |
Definition at line 3413 of file app_meetme.c.
References ast_answer(), and ast_indicate().
Referenced by run_station(), sla_handle_dial_state_event(), and sla_station_exec().
03414 { 03415 ast_answer(chan); 03416 ast_indicate(chan, -1); 03417 }
| static struct ast_conference* build_conf | ( | char * | confno, | |
| char * | pin, | |||
| char * | pinadmin, | |||
| int | make, | |||
| int | dynamic, | |||
| int | refcount | |||
| ) | [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 |
Definition at line 765 of file app_meetme.c.
References ast_conference::announcethread, ast_conference::announcethreadlock, ast_atomic_fetchadd_int(), ast_calloc, ast_copy_string(), AST_FORMAT_SLINEAR, ast_hangup(), AST_LIST_INSERT_HEAD, AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, ast_log(), ast_mutex_init(), AST_PTHREADT_NULL, ast_request(), ast_set_read_format(), ast_set_write_format(), ast_verbose(), ast_conference::chan, conf_map, ast_conference::confno, dahdi_chan_name, ast_conference::fd, ast_channel::fds, free, ast_conference::isdynamic, ast_conference::listenlock, LOG_WARNING, option_verbose, ast_conference::pin, ast_conference::pinadmin, ast_conference::playlock, ast_conference::recordthread, ast_conference::recordthreadlock, ast_conference::refcount, ast_conference::start, VERBOSE_PREFIX_3, and ast_conference::zapconf.
Referenced by dial_trunk(), find_conf(), find_conf_realtime(), run_station(), sla_station_exec(), and sla_trunk_exec().
00766 { 00767 struct ast_conference *cnf; 00768 struct dahdi_confinfo ztc = { 0, }; 00769 int confno_int = 0; 00770 00771 AST_LIST_LOCK(&confs); 00772 00773 AST_LIST_TRAVERSE(&confs, cnf, list) { 00774 if (!strcmp(confno, cnf->confno)) 00775 break; 00776 } 00777 00778 if (cnf || (!make && !dynamic)) 00779 goto cnfout; 00780 00781 /* Make a new one */ 00782 if (!(cnf = ast_calloc(1, sizeof(*cnf)))) 00783 goto cnfout; 00784 00785 ast_mutex_init(&cnf->playlock); 00786 ast_mutex_init(&cnf->listenlock); 00787 cnf->recordthread = AST_PTHREADT_NULL; 00788 ast_mutex_init(&cnf->recordthreadlock); 00789 cnf->announcethread = AST_PTHREADT_NULL; 00790 ast_mutex_init(&cnf->announcethreadlock); 00791 ast_copy_string(cnf->confno, confno, sizeof(cnf->confno)); 00792 ast_copy_string(cnf->pin, pin, sizeof(cnf->pin)); 00793 ast_copy_string(cnf->pinadmin, pinadmin, sizeof(cnf->pinadmin)); 00794 00795 /* Setup a new zap conference */ 00796 ztc.confno = -1; 00797 ztc.confmode = DAHDI_CONF_CONFANN | DAHDI_CONF_CONFANNMON; 00798 #ifdef HAVE_ZAPTEL 00799 cnf->fd = open("/dev/zap/pseudo", O_RDWR); 00800 #else 00801 cnf->fd = open("/dev/dahdi/pseudo", O_RDWR); 00802 #endif 00803 if (cnf->fd < 0 || ioctl(cnf->fd, DAHDI_SETCONF, &ztc)) { 00804 ast_log(LOG_WARNING, "Unable to open pseudo device\n"); 00805 if (cnf->fd >= 0) 00806 close(cnf->fd); 00807 free(cnf); 00808 cnf = NULL; 00809 goto cnfout; 00810 } 00811 00812 cnf->zapconf = ztc.confno; 00813 00814 /* Setup a new channel for playback of audio files */ 00815 cnf->chan = ast_request(dahdi_chan_name, AST_FORMAT_SLINEAR, "pseudo", NULL); 00816 if (cnf->chan) { 00817 ast_set_read_format(cnf->chan, AST_FORMAT_SLINEAR); 00818 ast_set_write_format(cnf->chan, AST_FORMAT_SLINEAR); 00819 ztc.chan = 0; 00820 ztc.confno = cnf->zapconf; 00821 ztc.confmode = DAHDI_CONF_CONFANN | DAHDI_CONF_CONFANNMON; 00822 if (ioctl(cnf->chan->fds[0], DAHDI_SETCONF, &ztc)) { 00823 ast_log(LOG_WARNING, "Error setting conference\n"); 00824 if (cnf->chan) 00825 ast_hangup(cnf->chan); 00826 else 00827 close(cnf->fd); 00828 free(cnf); 00829 cnf = NULL; 00830 goto cnfout; 00831 } 00832 } 00833 00834 /* Fill the conference struct */ 00835 cnf->start = time(NULL); 00836 cnf->isdynamic = dynamic ? 1 : 0; 00837 if (option_verbose > 2) 00838 ast_verbose(VERBOSE_PREFIX_3 "Created MeetMe conference %d for conference '%s'\n", cnf->zapconf, cnf->confno); 00839 AST_LIST_INSERT_HEAD(&confs, cnf, list); 00840 00841 /* Reserve conference number in map */ 00842 if ((sscanf(cnf->confno, "%d", &confno_int) == 1) && (confno_int >= 0 && confno_int < 1024)) 00843 conf_map[confno_int] = 1; 00844 00845 cnfout: 00846 if (cnf) 00847 ast_atomic_fetchadd_int(&cnf->refcount, refcount); 00848 00849 AST_LIST_UNLOCK(&confs); 00850 00851 return cnf; 00852 }
| static int can_write | ( | struct ast_channel * | chan, | |
| int | confflags | |||
| ) | [static] |
Definition at line 1487 of file app_meetme.c.
References ast_channel::_state, AST_STATE_UP, and CONFFLAG_NO_AUDIO_UNTIL_UP.
Referenced by conf_run().
01488 { 01489 if (!(confflags & CONFFLAG_NO_AUDIO_UNTIL_UP)) { 01490 return 1; 01491 } 01492 01493 return (chan->_state == AST_STATE_UP); 01494 }
| static int careful_write | ( | int | fd, | |
| unsigned char * | data, | |||
| int | len, | |||
| int | block | |||
| ) | [static] |
Definition at line 600 of file app_meetme.c.
References ast_log(), errno, and LOG_WARNING.
Referenced by conf_play(), and conf_run().
00601 { 00602 int res; 00603 int x; 00604 00605 while (len) { 00606 if (block) { 00607 x = DAHDI_IOMUX_WRITE | DAHDI_IOMUX_SIGEVENT; 00608 res = ioctl(fd, DAHDI_IOMUX, &x); 00609 } else 00610 res = 0; 00611 if (res >= 0) 00612 res = write(fd, data, len); 00613 if (res < 1) { 00614 if (errno != EAGAIN) { 00615 ast_log(LOG_WARNING, "Failed to write audio data to conference: %s\n", strerror(errno)); 00616 return -1; 00617 } else 00618 return 0; 00619 } 00620 len -= res; 00621 data += res; 00622 } 00623 00624 return 0; 00625 }
| static char* complete_meetmecmd | ( | const char * | line, | |
| const char * | word, | |||
| int | pos, | |||
| int | state | |||
| ) | [static] |
Definition at line 1002 of file app_meetme.c.
References ast_cli_complete(), AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, ast_strdup, ast_strdupa, ast_conference::confno, len(), ast_conf_user::list, strdup, ast_conf_user::user_no, and ast_conference::userlist.
01003 { 01004 static char *cmds[] = {"lock", "unlock", "mute", "unmute", "kick", "list", NULL}; 01005 01006 int len = strlen(word); 01007 int which = 0; 01008 struct ast_conference *cnf = NULL; 01009 struct ast_conf_user *usr = NULL; 01010 char *confno = NULL; 01011 char usrno[50] = ""; 01012 char *myline, *ret = NULL; 01013 01014 if (pos == 1) { /* Command */ 01015 return ast_cli_complete(word, cmds, state); 01016 } else if (pos == 2) { /* Conference Number */ 01017 AST_LIST_LOCK(&confs); 01018 AST_LIST_TRAVERSE(&confs, cnf, list) { 01019 if (!strncasecmp(word, cnf->confno, len) && ++which > state) { 01020 ret = cnf->confno; 01021 break; 01022 } 01023 } 01024 ret = ast_strdup(ret); /* dup before releasing the lock */ 01025 AST_LIST_UNLOCK(&confs); 01026 return ret; 01027 } else if (pos == 3) { 01028 /* User Number || Conf Command option*/ 01029 if (strstr(line, "mute") || strstr(line, "kick")) { 01030 if (state == 0 && (strstr(line, "kick") || strstr(line,"mute")) && !strncasecmp(word, "all", len)) 01031 return strdup("all"); 01032 which++; 01033 AST_LIST_LOCK(&confs); 01034 01035 /* TODO: Find the conf number from the cmdline (ignore spaces) <- test this and make it fail-safe! */ 01036 myline = ast_strdupa(line); 01037 if (strsep(&myline, " ") && strsep(&myline, " ") && !confno) { 01038 while((confno = strsep(&myline, " ")) && (strcmp(confno, " ") == 0)) 01039 ; 01040 } 01041 01042 AST_LIST_TRAVERSE(&confs, cnf, list) { 01043 if (!strcmp(confno, cnf->confno)) 01044 break; 01045 } 01046 01047 if (cnf) { 01048 /* Search for the user */ 01049 AST_LIST_TRAVERSE(&cnf->userlist, usr, list) { 01050 snprintf(usrno, sizeof(usrno), "%d", usr->user_no); 01051 if (!strncasecmp(word, usrno, len) && ++which > state) 01052 break; 01053 } 01054 } 01055 AST_LIST_UNLOCK(&confs); 01056 return usr ? strdup(usrno) : NULL; 01057 } else if ( strstr(line, "list") && ( 0 == state ) ) 01058 return strdup("concise"); 01059 } 01060 01061 return NULL; 01062 }
| static int conf_exec | ( | struct ast_channel * | chan, | |
| void * | data | |||
| ) | [static] |
The meetme() application.
Definition at line 2680 of file app_meetme.c.
References ast_channel::_state, ast_answer(), AST_APP_ARG, ast_app_getdata(), ast_app_parse_options(), 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_log(), ast_module_user_add, ast_module_user_remove, ast_say_digits(), ast_set_flag, AST_STANDARD_APP_ARGS, AST_STATE_UP, ast_stopstream(), ast_strdupa, ast_streamfile(), ast_strlen_zero(), ast_test_flag, ast_variable_browse(), ast_waitstream(), conf_map, conf_run(), CONFFLAG_ADMIN, CONFFLAG_ALWAYSPROMPT, CONFFLAG_DYNAMIC, CONFFLAG_DYNAMICPIN, CONFFLAG_EMPTY, CONFFLAG_EMPTYNOPIN, CONFIG_FILE_NAME, ast_conference::confno, dispose_conf(), find_conf(), find_conf_realtime(), ast_flags::flags, ast_channel::language, LOG_ERROR, LOG_WARNING, MAX_CONFNUM, MAX_PIN, meetme_opts, ast_variable::name, ast_variable::next, OPT_ARG_ARRAY_SIZE, ast_conference::pin, ast_conference::pinadmin, ast_variable::value, and var.
Referenced by load_module().
02681 { 02682 int res=-1; 02683 struct ast_module_user *u; 02684 char confno[MAX_CONFNUM] = ""; 02685 int allowretry = 0; 02686 int retrycnt = 0; 02687 struct ast_conference *cnf = NULL; 02688 struct ast_flags confflags = {0}; 02689 int dynamic = 0; 02690 int empty = 0, empty_no_pin = 0; 02691 int always_prompt = 0; 02692 char *notdata, *info, the_pin[MAX_PIN] = ""; 02693 AST_DECLARE_APP_ARGS(args, 02694 AST_APP_ARG(confno); 02695 AST_APP_ARG(options); 02696 AST_APP_ARG(pin); 02697 ); 02698 char *optargs[OPT_ARG_ARRAY_SIZE] = { NULL, }; 02699 02700 u = ast_module_user_add(chan); 02701 02702 if (ast_strlen_zero(data)) { 02703 allowretry = 1; 02704 notdata = ""; 02705 } else { 02706 notdata = data; 02707 } 02708 02709 if (chan->_state != AST_STATE_UP) 02710 ast_answer(chan); 02711 02712 info = ast_strdupa(notdata); 02713 02714 AST_STANDARD_APP_ARGS(args, info); 02715 02716 if (args.confno) { 02717 ast_copy_string(confno, args.confno, sizeof(confno)); 02718 if (ast_strlen_zero(confno)) { 02719 allowretry = 1; 02720 } 02721 } 02722 02723 if (args.pin) 02724 ast_copy_string(the_pin, args.pin, sizeof(the_pin)); 02725 02726 if (args.options) { 02727 ast_app_parse_options(meetme_opts, &confflags, optargs, args.options); 02728 dynamic = ast_test_flag(&confflags, CONFFLAG_DYNAMIC | CONFFLAG_DYNAMICPIN); 02729 if (ast_test_flag(&confflags, CONFFLAG_DYNAMICPIN) && ast_strlen_zero(args.pin)) 02730 strcpy(the_pin, "q"); 02731 02732 empty = ast_test_flag(&confflags, CONFFLAG_EMPTY | CONFFLAG_EMPTYNOPIN); 02733 empty_no_pin = ast_test_flag(&confflags, CONFFLAG_EMPTYNOPIN); 02734 always_prompt = ast_test_flag(&confflags, CONFFLAG_ALWAYSPROMPT); 02735 } 02736 02737 do { 02738 if (retrycnt > 3) 02739 allowretry = 0; 02740 if (empty) { 02741 int i; 02742 struct ast_config *cfg; 02743 struct ast_variable *var; 02744 int confno_int; 02745 02746 /* We only need to load the config file for static and empty_no_pin (otherwise we don't care) */ 02747 if ((empty_no_pin) || (!dynamic)) { 02748 cfg = ast_config_load(CONFIG_FILE_NAME); 02749 if (cfg) { 02750 var = ast_variable_browse(cfg, "rooms"); 02751 while (var) { 02752 if (!strcasecmp(var->name, "conf")) { 02753 char *stringp = ast_strdupa(var->value); 02754 if (stringp) { 02755 char *confno_tmp = strsep(&stringp, "|,"); 02756 int found = 0; 02757 if (!dynamic) { 02758 /* For static: run through the list and see if this conference is empty */ 02759 AST_LIST_LOCK(&confs); 02760 AST_LIST_TRAVERSE(&confs, cnf, list) { 02761 if (!strcmp(confno_tmp, cnf->confno)) { 02762 /* The conference exists, therefore it's not empty */ 02763 found = 1; 02764 break; 02765 } 02766 } 02767 AST_LIST_UNLOCK(&confs); 02768 if (!found) { 02769 /* At this point, we have a confno_tmp (static conference) that is empty */ 02770 if ((empty_no_pin && ast_strlen_zero(stringp)) || (!empty_no_pin)) { 02771 /* Case 1: empty_no_pin and pin is nonexistent (NULL) 02772 * Case 2: empty_no_pin and pin is blank (but not NULL) 02773 * Case 3: not empty_no_pin 02774 */ 02775 ast_copy_string(confno, confno_tmp, sizeof(confno)); 02776 break; 02777 /* XXX the map is not complete (but we do have a confno) */ 02778 } 02779 } 02780 } 02781 } 02782 } 02783 var = var->next; 02784 } 02785 ast_config_destroy(cfg); 02786 } 02787 } 02788 02789 /* Select first conference number not in use */ 02790 if (ast_strlen_zero(confno) && dynamic) { 02791 AST_LIST_LOCK(&confs); 02792 for (i = 0; i < sizeof(conf_map) / sizeof(conf_map[0]); i++) { 02793 if (!conf_map[i]) { 02794 snprintf(confno, sizeof(confno), "%d", i); 02795 conf_map[i] = 1; 02796 break; 02797 } 02798 } 02799 AST_LIST_UNLOCK(&confs); 02800 } 02801 02802 /* Not found? */ 02803 if (ast_strlen_zero(confno)) { 02804 res = ast_streamfile(chan, "conf-noempty", chan->language); 02805 if (!res) 02806 ast_waitstream(chan, ""); 02807 } else { 02808 if (sscanf(confno, "%d", &confno_int) == 1) { 02809 res = ast_streamfile(chan, "conf-enteringno", chan->language); 02810 if (!res) { 02811 ast_waitstream(chan, ""); 02812 res = ast_say_digits(chan, confno_int, "", chan->language); 02813 } 02814 } else { 02815 ast_log(LOG_ERROR, "Could not scan confno '%s'\n", confno); 02816 } 02817 } 02818 } 02819 02820 while (allowretry && (ast_strlen_zero(confno)) && (++retrycnt < 4)) { 02821 /* Prompt user for conference number */ 02822 res = ast_app_getdata(chan, "conf-getconfno", confno, sizeof(confno) - 1, 0); 02823 if (res < 0) { 02824 /* Don't try to validate when we catch an error */ 02825 confno[0] = '\0'; 02826 allowretry = 0; 02827 break; 02828 } 02829 } 02830 if (!ast_strlen_zero(confno)) { 02831 /* Check the validity of the conference */ 02832 cnf = find_conf(chan, confno, 1, dynamic, the_pin, 02833 sizeof(the_pin), 1, &confflags); 02834 if (!cnf) { 02835 cnf = find_conf_realtime(chan, confno, 1, dynamic, 02836 the_pin, sizeof(the_pin), 1, &confflags); 02837 } 02838 02839 if (!cnf) { 02840 res = ast_streamfile(chan, "conf-invalid", chan->language); 02841 if (!res) 02842 ast_waitstream(chan, ""); 02843 res = -1; 02844 if (allowretry) 02845 confno[0] = '\0'; 02846 } else { 02847 if ((!ast_strlen_zero(cnf->pin) && 02848 !ast_test_flag(&confflags, CONFFLAG_ADMIN)) || 02849 (!ast_strlen_zero(cnf->pinadmin) && 02850 ast_test_flag(&confflags, CONFFLAG_ADMIN))) { 02851 char pin[MAX_PIN] = ""; 02852 int j; 02853 02854 /* Allow the pin to be retried up to 3 times */ 02855 for (j = 0; j < 3; j++) { 02856 if (*the_pin && (always_prompt == 0)) { 02857 ast_copy_string(pin, the_pin, sizeof(pin)); 02858 res = 0; 02859 } else { 02860 /* Prompt user for pin if pin is required */ 02861 res = ast_app_getdata(chan, "conf-getpin", pin + strlen(pin), sizeof(pin) - 1 - strlen(pin), 0); 02862 } 02863 if (res >= 0) { 02864 if (!strcasecmp(pin, cnf->pin) || 02865 (!ast_strlen_zero(cnf->pinadmin) && 02866 !strcasecmp(pin, cnf->pinadmin))) { 02867 /* Pin correct */ 02868 allowretry = 0; 02869 if (!ast_strlen_zero(cnf->pinadmin) && !strcasecmp(pin, cnf->pinadmin)) 02870 ast_set_flag(&confflags, CONFFLAG_ADMIN); 02871 /* Run the conference */ 02872 res = conf_run(chan, cnf, confflags.flags, optargs); 02873 break; 02874 } else { 02875 /* Pin invalid */ 02876 if (!ast_streamfile(chan, "conf-invalidpin", chan->language)) { 02877 res = ast_waitstream(chan, AST_DIGIT_ANY); 02878 ast_stopstream(chan); 02879 } 02880 else { 02881 ast_log(LOG_WARNING, "Couldn't play invalid pin msg!\n"); 02882 break; 02883 } 02884 if (res < 0) 02885 break; 02886 pin[0] = res; 02887 pin[1] = '\0'; 02888 res = -1; 02889 if (allowretry) 02890 confno[0] = '\0'; 02891 } 02892 } else { 02893 /* failed when getting the pin */ 02894 res = -1; 02895 allowretry = 0; 02896 /* see if we need to get rid of the conference */ 02897 break; 02898 } 02899 02900 /* Don't retry pin with a static pin */ 02901 if (*the_pin && (always_prompt==0)) { 02902 break; 02903 } 02904 } 02905 } else { 02906 /* No pin required */ 02907 allowretry = 0; 02908 02909 /* Run the conference */ 02910 res = conf_run(chan, cnf, confflags.flags, optargs); 02911 } 02912 dispose_conf(cnf); 02913 cnf = NULL; 02914 } 02915 } 02916 } while (allowretry); 02917 02918 if (cnf) 02919 dispose_conf(cnf); 02920 02921 ast_module_user_remove(u); 02922 02923 return res; 02924 }
| static void conf_flush | ( | int | fd, | |
| struct ast_channel * | chan | |||
| ) | [static] |
Definition at line 1228 of file app_meetme.c.
References ast_frfree, ast_log(), ast_read(), ast_waitfor(), f, and LOG_WARNING.
Referenced by conf_run().
01229 { 01230 int x; 01231 01232 /* read any frames that may be waiting on the channel 01233 and throw them away 01234 */ 01235 if (chan) { 01236 struct ast_frame *f; 01237 01238 /* when no frames are available, this will wait 01239 for 1 millisecond maximum 01240 */ 01241 while (ast_waitfor(chan, 1)) { 01242 f = ast_read(chan); 01243 if (f) 01244 ast_frfree(f); 01245 else /* channel was hung up or something else happened */ 01246 break; 01247 } 01248 } 01249 01250 /* flush any data sitting in the pseudo channel */ 01251 x = DAHDI_FLUSH_ALL; 01252 if (ioctl(fd, DAHDI_FLUSH, &x)) 01253 ast_log(LOG_WARNING, "Error flushing channel\n"); 01254 01255 }
| static int conf_free | ( | struct ast_conference * | conf | ) | [static] |
Definition at line 1259 of file app_meetme.c.
References ast_conference::announcelist, ast_conference::announcelist_addition, ast_conference::announcelistlock, ast_conference::announcethread, ast_conference::announcethread_stop, ast_conference::announcethreadlock, ao2_ref(), ast_cond_signal(), ast_filedelete(), AST_FRAME_BITS, 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::fd, free, ast_conference::lchan, ast_conference::listenlock, MEETME_RECORD_ACTIVE, MEETME_RECORD_OFF, MEETME_RECORD_TERMINATE, announce_listitem::namerecloc, ast_conference::origframe, ast_conference::playlock, ast_conference::recordthreadlock, ast_conference::transframe, and ast_conference::transpath.
Referenced by dispose_conf().
01260 { 01261 int x; 01262 struct announce_listitem *item; 01263 01264 AST_LIST_REMOVE(&confs, conf, list); 01265 01266 if (conf->recording == MEETME_RECORD_ACTIVE) { 01267 conf->recording = MEETME_RECORD_TERMINATE; 01268 AST_LIST_UNLOCK(&confs); 01269 while (1) { 01270 usleep(1); 01271 AST_LIST_LOCK(&confs); 01272 if (conf->recording == MEETME_RECORD_OFF) 01273 break; 01274 AST_LIST_UNLOCK(&confs); 01275 } 01276 } 01277 01278 for (x=0;x<AST_FRAME_BITS;x++) { 01279 if (conf->transframe[x]) 01280 ast_frfree(conf->transframe[x]); 01281 if (conf->transpath[x]) 01282 ast_translator_free_path(conf->transpath[x]); 01283 } 01284 if (conf->announcethread != AST_PTHREADT_NULL) { 01285 ast_mutex_lock(&conf->announcelistlock); 01286 conf->announcethread_stop = 1; 01287 ast_softhangup(conf->chan, AST_SOFTHANGUP_EXPLICIT); 01288 ast_cond_signal(&conf->announcelist_addition); 01289 ast_mutex_unlock(&conf->announcelistlock); 01290 pthread_join(conf->announcethread, NULL); 01291 01292 while ((item = AST_LIST_REMOVE_HEAD(&conf->announcelist, entry))) { 01293 ast_filedelete(item->namerecloc, NULL); 01294 ao2_ref(item, -1); 01295 } 01296 ast_mutex_destroy(&conf->announcelistlock); 01297 } 01298 if (conf->origframe) 01299 ast_frfree(conf->origframe); 01300 if (conf->lchan) 01301 ast_hangup(conf->lchan); 01302 if (conf->chan) 01303 ast_hangup(conf->chan); 01304 if (conf->fd >= 0) 01305 close(conf->fd); 01306 01307 ast_mutex_destroy(&conf->playlock); 01308 ast_mutex_destroy(&conf->listenlock); 01309 ast_mutex_destroy(&conf->recordthreadlock); 01310 ast_mutex_destroy(&conf->announcethreadlock); 01311 01312 free(conf); 01313 01314 return 0; 01315 }
| static void conf_play | ( | struct ast_channel * | chan, | |
| struct ast_conference * | conf, | |||
| enum entrance_sound | sound | |||
| ) | [static] |
Definition at line 718 of file app_meetme.c.
References ast_channel::_softhangup, ast_autoservice_start(), ast_autoservice_stop(), AST_LIST_LOCK, AST_LIST_UNLOCK, careful_write(), enter, ENTER, ast_conference::fd, leave, LEAVE, and len().
Referenced by conf_run().
00719 { 00720 unsigned char *data; 00721 int len; 00722 int res = -1; 00723 00724 if (!chan->_softhangup) 00725 res = ast_autoservice_start(chan); 00726 00727 AST_LIST_LOCK(&confs); 00728 00729 switch(sound) { 00730 case ENTER: 00731 data = enter; 00732 len = sizeof(enter); 00733 break; 00734 case LEAVE: 00735 data = leave; 00736 len = sizeof(leave); 00737 break; 00738 default: 00739 data = NULL; 00740 len = 0; 00741 } 00742 if (data) { 00743 careful_write(conf->fd, data, len, 1); 00744 } 00745 00746 AST_LIST_UNLOCK(&confs); 00747 00748 if (!res) 00749 ast_autoservice_stop(chan); 00750 }
| static void conf_queue_dtmf | ( | const struct ast_conference * | conf, | |
| const struct ast_conf_user * | sender, | |||
| struct ast_frame * | f | |||
| ) | [static] |
Definition at line 1317 of file app_meetme.c.
References AST_LIST_TRAVERSE, ast_log(), ast_write(), ast_conf_user::chan, ast_conf_user::list, LOG_WARNING, ast_channel::name, and ast_conference::userlist.
Referenced by conf_run().
01319 { 01320 struct ast_conf_user *user; 01321 01322 AST_LIST_TRAVERSE(&conf->userlist, user, list) { 01323 if (user == sender) 01324 continue; 01325 if (ast_write(user->chan, f) < 0) 01326 ast_log(LOG_WARNING, "Error writing frame to channel %s\n", user->chan->name); 01327 } 01328 }
| static int conf_run | ( | struct ast_channel * | chan, | |
| struct ast_conference * | conf, | |||
| int | confflags, | |||
| char * | optargs[] | |||
| ) | [static] |
Definition at line 1496 of file app_meetme.c.
References volume::actual, ADMINFLAG_KICKME, ADMINFLAG_MUTED, ADMINFLAG_SELFMUTED, ast_conf_user::adminflags, announce_thread(), ast_conference::announcelist, ast_conference::announcelist_addition, ast_conference::announcelistlock, ast_conference::announcethread, ast_conference::announcethreadlock, announce_listitem::announcetype, ao2_alloc(), ao2_ref(), ast_calloc, ast_channel_setoption(), ast_check_hangup(), ast_cond_signal(), ast_config_AST_SPOOL_DIR, AST_CONTROL_HOLD, ast_copy_string(), ast_device_state_changed(), AST_DIGIT_ANY, ast_dsp_free(), ast_dsp_new(), ast_dsp_silence(), ast_exists_extension(), ast_filedelete(), 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_frfree, AST_FRIENDLY_OFFSET, ast_goto_if_exists(), ast_hangup(), ast_indicate(), AST_LIST_EMPTY, AST_LIST_HEAD_INIT_NOLOCK, AST_LIST_INSERT_TAIL, AST_LIST_LAST, AST_LIST_LOCK, AST_LIST_REMOVE, AST_LIST_UNLOCK, ast_log(), AST_MAX_CONTEXT, AST_MAX_EXTENSION, ast_moh_start(), 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_PTHREADT_NULL, ast_read(), ast_read_noaudio(), ast_record_review(), ast_request(), ast_safe_sleep(), ast_say_number(), ast_set_read_format(), ast_set_write_format(), ast_stopstream(), ast_strdupa, ast_streamfile(), ast_strlen_zero(), ast_translate(), ast_translator_build_path(), ast_update_realtime(), ast_verbose(), ast_waitfor_nandfds(), ast_waitstream(), ast_write(), ast_conference::attr, ast_channel::audiohooks, can_write(), careful_write(), ast_conference::chan, ast_conf_user::chan, ast_channel::cid, ast_callerid::cid_name, ast_callerid::cid_num, conf_flush(), CONF_HASJOIN, CONF_HASLEFT, conf_play(), conf_queue_dtmf(), CONF_SIZE, announce_listitem::confchan, CONFFLAG_ADMIN, CONFFLAG_AGI, CONFFLAG_ANNOUNCEUSERCOUNT, CONFFLAG_EXIT_CONTEXT, CONFFLAG_INTROUSER, CONFFLAG_INTROUSERNOREVIEW, CONFFLAG_MARKEDEXIT, CONFFLAG_MARKEDUSER, CONFFLAG_MOH, CONFFLAG_MONITOR, CONFFLAG_MONITORTALKER, CONFFLAG_NO_AUDIO_UNTIL_UP, CONFFLAG_NOONLYPERSON, CONFFLAG_OPTIMIZETALKER, CONFFLAG_PASS_DTMF, CONFFLAG_POUNDEXIT, CONFFLAG_QUIET, CONFFLAG_RECORDCONF, CONFFLAG_SLA_STATION, CONFFLAG_STARMENU, CONFFLAG_STARTMUTED, CONFFLAG_TALKER, CONFFLAG_WAITMARKED, ast_conference::confno, announce_listitem::confusers, ast_channel::context, dahdi_chan_name, ast_frame::data, ast_frame::datalen, volume::desired, ENTER, errno, EVENT_FLAG_CALL, exitcontext, f, ast_channel::fds, ast_frame::flags, ast_frame::frametype, free, ast_conf_user::jointime, announce_listitem::language, ast_channel::language, ast_conference::lchan, LEAVE, ast_conf_user::listen, ast_conference::listenlock, ast_conference::locked, LOG_DEBUG, LOG_WARNING, ast_channel::macrocontext, manager_event(), ast_conference::markedusers, MEETME_DELAYDETECTENDTALK, MEETME_DELAYDETECTTALK, ast_channel::monitor, ast_channel::name, announce_listitem::namerecloc, ast_conf_user::namerecloc, ast_frame::offset, OPT_ARG_WAITMARKED, option_debug, ast_conference::origframe, pbx_builtin_getvar_helper(), pbx_builtin_setvar_helper(), pbx_exec(), pbx_findapp(), ast_conference::playlock, ast_channel::rawwriteformat, ast_conference::recordingfilename, ast_conference::recordingformat, ast_conference::recordthread, ast_conference::recordthreadlock, reset_volumes(), s, S_OR, ast_frame::samples, set_talk_volume(), SLA_EVENT_HOLD, sla_queue_event_conf(), ast_frame::subclass, ast_conf_user::talk, ast_conf_user::talking, ast_channel::tech, timeout, ast_conference::transframe, ast_conference::transpath, tweak_listen_volume(), tweak_talk_volume(), ast_channel_tech::type, ast_channel::uniqueid, ast_conf_user::user_no, ast_conf_user::userflags, ast_conference::userlist, ast_conference::users, VERBOSE_PREFIX_4, VOL_DOWN, VOL_UP, ast_conf_user::zapchannel, and ast_conference::zapconf.
Referenced by conf_exec(), dial_trunk(), run_station(), sla_station_exec(), and sla_trunk_exec().
01497 { 01498 struct ast_conf_user *user = NULL; 01499 struct ast_conf_user *usr = NULL; 01500 int fd; 01501 struct dahdi_confinfo ztc, ztc_empty; 01502 struct ast_frame *f; 01503 struct ast_channel *c; 01504 struct ast_frame fr; 01505 int outfd; 01506 int ms; 01507 int nfds; 01508 int res; 01509 int flags; 01510 int retryzap; 01511 int origfd; 01512 int musiconhold = 0; 01513 int firstpass = 0; 01514 int lastmarked = 0; 01515 int currentmarked = 0; 01516 int ret = -1; 01517 int x; 01518 int menu_active = 0; 01519 int using_pseudo = 0; 01520 int duration=20; 01521 int hr, min, sec; 01522 int sent_event = 0; 01523 time_t now; 01524 struct ast_dsp *dsp=NULL; 01525 struct ast_app *app; 01526 const char *agifile; 01527 const char *agifiledefault = "conf-background.agi"; 01528 char meetmesecs[30] = ""; 01529 char exitcontext[AST_MAX_CONTEXT] = ""; 01530 char recordingtmp[AST_MAX_EXTENSION] = ""; 01531 char members[10] = ""; 01532 int dtmf, opt_waitmarked_timeout = 0; 01533 time_t timeout = 0; 01534 struct dahdi_bufferinfo bi; 01535 char __buf[CONF_SIZE + AST_FRIENDLY_OFFSET]; 01536 char *buf = __buf + AST_FRIENDLY_OFFSET; 01537 int setusercount = 0; 01538 01539 if (!(user = ast_calloc(1, sizeof(*user)))) 01540 return ret; 01541 01542 /* Possible timeout waiting for marked user */ 01543 if ((confflags & CONFFLAG_WAITMARKED) && 01544 !ast_strlen_zero(optargs[OPT_ARG_WAITMARKED]) && 01545 (sscanf(optargs[OPT_ARG_WAITMARKED], "%d", &opt_waitmarked_timeout) == 1) && 01546 (opt_waitmarked_timeout > 0)) { 01547 timeout = time(NULL) + opt_waitmarked_timeout; 01548 } 01549 01550 if (confflags & CONFFLAG_RECORDCONF) { 01551 if (!conf->recordingfilename) { 01552 conf->recordingfilename = pbx_builtin_getvar_helper(chan, "MEETME_RECORDINGFILE"); 01553 if (!conf->recordingfilename) { 01554 snprintf(recordingtmp, sizeof(recordingtmp), "meetme-conf-rec-%s-%s", conf->confno, chan->uniqueid); 01555 conf->recordingfilename = ast_strdupa(recordingtmp); 01556 } 01557 conf->recordingformat = pbx_builtin_getvar_helper(chan, "MEETME_RECORDINGFORMAT"); 01558 if (!conf->recordingformat) { 01559 snprintf(recordingtmp, sizeof(recordingtmp), "wav"); 01560 conf->recordingformat = ast_strdupa(recordingtmp); 01561 } 01562 ast_verbose(VERBOSE_PREFIX_4 "Starting recording of MeetMe Conference %s into file %s.%s.\n", 01563 conf->confno, conf->recordingfilename, conf->recordingformat); 01564 } 01565 } 01566 01567 ast_mutex_lock(&conf->recordthreadlock); 01568 if ((conf->recordthread == AST_PTHREADT_NULL) && (confflags & CONFFLAG_RECORDCONF) && ((conf->lchan = ast_request(dahdi_chan_name, AST_FORMAT_SLINEAR, "pseudo", NULL)))) { 01569 ast_set_read_format(conf->lchan, AST_FORMAT_SLINEAR); 01570 ast_set_write_format(conf->lchan, AST_FORMAT_SLINEAR); 01571 ztc.chan = 0; 01572 ztc.confno = conf->zapconf; 01573 ztc.confmode = DAHDI_CONF_CONFANN | DAHDI_CONF_CONFANNMON; 01574 if (ioctl(conf->lchan->fds[0], DAHDI_SETCONF, &ztc)) { 01575 ast_log(LOG_WARNING, "Error starting listen channel\n"); 01576 ast_hangup(conf->lchan); 01577 conf->lchan = NULL; 01578 } else { 01579 pthread_attr_init(&conf->attr); 01580 pthread_attr_setdetachstate(&conf->attr, PTHREAD_CREATE_DETACHED); 01581 ast_pthread_create_background(&conf->recordthread, &conf->attr, recordthread, conf); 01582 pthread_attr_destroy(&conf->attr); 01583 } 01584 } 01585 ast_mutex_unlock(&conf->recordthreadlock); 01586 01587 ast_mutex_lock(&conf->announcethreadlock); 01588 if ((conf->announcethread == AST_PTHREADT_NULL) && !(confflags & CONFFLAG_QUIET) && ((confflags & CONFFLAG_INTROUSER) || (confflags & CONFFLAG_INTROUSERNOREVIEW))) { 01589 ast_mutex_init(&conf->announcelistlock); 01590 AST_LIST_HEAD_INIT_NOLOCK(&conf->announcelist); 01591 ast_pthread_create_background(&conf->announcethread, NULL, announce_thread, conf); 01592 } 01593 ast_mutex_unlock(&conf->announcethreadlock); 01594 01595 time(&user->jointime); 01596 01597 if (conf->locked && (!(confflags & CONFFLAG_ADMIN))) { 01598 /* Sorry, but this confernce is locked! */ 01599 if (!ast_streamfile(chan, "conf-locked", chan->language)) 01600 ast_waitstream(chan, ""); 01601 goto outrun; 01602 } 01603 01604 ast_mutex_lock(&conf->playlock); 01605 01606 if (AST_LIST_EMPTY(&conf->userlist)) 01607 user->user_no = 1; 01608 else 01609 user->user_no = AST_LIST_LAST(&conf->userlist)->user_no + 1; 01610 01611 AST_LIST_INSERT_TAIL(&conf->userlist, user, list); 01612 01613 user->chan = chan; 01614 user->userflags = confflags; 01615 user->adminflags = (confflags & CONFFLAG_STARTMUTED) ? ADMINFLAG_SELFMUTED : 0; 01616 user->talking = -1; 01617 01618 ast_mutex_unlock(&conf->playlock); 01619 01620 if (!(confflags & CONFFLAG_QUIET) && ((confflags & CONFFLAG_INTROUSER) || (confflags & CONFFLAG_INTROUSERNOREVIEW))) { 01621 char destdir[PATH_MAX]; 01622 01623 snprintf(destdir, sizeof(destdir), "%s/meetme", ast_config_AST_SPOOL_DIR); 01624 01625 if (mkdir(destdir, 0777) && errno != EEXIST) { 01626 ast_log(LOG_WARNING, "mkdir '%s' failed: %s\n", destdir, strerror(errno)); 01627 goto outrun; 01628 } 01629 01630 snprintf(user->namerecloc, sizeof(user->namerecloc), 01631 "%s/meetme-username-%s-%d", destdir, 01632 conf->confno, user->user_no); 01633 if (confflags & CONFFLAG_INTROUSERNOREVIEW) 01634 res = ast_play_and_record(chan, "vm-rec-name", user->namerecloc, 10, "sln", &duration, 128, 0, NULL); 01635 else 01636 res = ast_record_review(chan, "vm-rec-name", user->namerecloc, 10, "sln", &duration, NULL); 01637 if (res == -1) 01638 goto outrun; 01639 } 01640 01641 ast_mutex_lock(&conf->playlock); 01642 01643 if (confflags & CONFFLAG_MARKEDUSER) 01644 conf->markedusers++; 01645 conf->users++; 01646 /* Update table */ 01647 snprintf(members, sizeof(members), "%d", conf->users); 01648 ast_update_realtime("meetme", "confno", conf->confno, "members", members , NULL); 01649 setusercount = 1; 01650 01651 /* This device changed state now - if this is the first user */ 01652 if (conf->users == 1) 01653 ast_device_state_changed("meetme:%s", conf->confno); 01654 01655 ast_mutex_unlock(&conf->playlock); 01656 01657 if (confflags & CONFFLAG_EXIT_CONTEXT) { 01658 if ((agifile = pbx_builtin_getvar_helper(chan, "MEETME_EXIT_CONTEXT"))) 01659 ast_copy_string(exitcontext, agifile, sizeof(exitcontext)); 01660 else if (!ast_strlen_zero(chan->macrocontext)) 01661 ast_copy_string(exitcontext, chan->macrocontext, sizeof(exitcontext)); 01662 else 01663 ast_copy_string(exitcontext, chan->context, sizeof(exitcontext)); 01664 } 01665 01666 if ( !(confflags & (CONFFLAG_QUIET | CONFFLAG_NOONLYPERSON)) ) { 01667 if (conf->users == 1 && !(confflags & CONFFLAG_WAITMARKED)) 01668 if (!ast_streamfile(chan, "conf-onlyperson", chan->language)) 01669 ast_waitstream(chan, ""); 01670 if ((confflags & CONFFLAG_WAITMARKED) && conf->markedusers == 0) 01671 if (!ast_streamfile(chan, "conf-waitforleader", chan->language)) 01672 ast_waitstream(chan, ""); 01673 } 01674 01675 if (!(confflags & CONFFLAG_QUIET) && (confflags & CONFFLAG_ANNOUNCEUSERCOUNT) && conf->users > 1) { 01676 int keepplaying = 1; 01677 01678 if (conf->users == 2) { 01679 if (!ast_streamfile(chan,"conf-onlyone",chan->language)) { 01680 res = ast_waitstream(chan, AST_DIGIT_ANY); 01681 ast_stopstream(chan); 01682 if (res > 0) 01683 keepplaying=0; 01684 else if (res == -1) 01685 goto outrun; 01686 } 01687 } else { 01688 if (!ast_streamfile(chan, "conf-thereare", chan->language)) { 01689 res = ast_waitstream(chan, AST_DIGIT_ANY); 01690 ast_stopstream(chan); 01691 if (res > 0) 01692 keepplaying=0; 01693 else if (res == -1) 01694 goto outrun; 01695 } 01696 if (keepplaying) { 01697 res = ast_say_number(chan, conf->users - 1, AST_DIGIT_ANY, chan->language, (char *) NULL); 01698 if (res > 0) 01699 keepplaying=0; 01700 else if (res == -1) 01701 goto outrun; 01702 } 01703 if (keepplaying && !ast_streamfile(chan, "conf-otherinparty", chan->language)) { 01704 res = ast_waitstream(chan, AST_DIGIT_ANY); 01705 ast_stopstream(chan); 01706 if (res > 0) 01707 keepplaying=0; 01708 else if (res == -1) 01709 goto outrun; 01710 } 01711 } 01712 } 01713 01714 if (!(confflags & CONFFLAG_NO_AUDIO_UNTIL_UP)) { 01715 /* We're leaving this alone until the state gets changed to up */ 01716 ast_indicate(chan, -1); 01717 } 01718 01719 if (ast_set_write_format(chan, AST_FORMAT_SLINEAR) < 0) { 01720 ast_log(LOG_WARNING, "Unable to set '%s' to write linear mode\n", chan->name); 01721 goto outrun; 01722 } 01723 01724 if (ast_set_read_format(chan, AST_FORMAT_SLINEAR) < 0) { 01725 ast_log(LOG_WARNING, "Unable to set '%s' to read linear mode\n", chan->name); 01726 goto outrun; 01727 } 01728 01729 retryzap = (strcasecmp(chan->tech->type, dahdi_chan_name) || (chan->audiohooks || chan->monitor) ? 1 : 0); 01730 user->zapchannel = !retryzap; 01731 01732 zapretry: 01733 origfd = chan->fds[0]; 01734 if (retryzap) { 01735 #ifdef HAVE_ZAPTEL 01736 fd = open("/dev/zap/pseudo", O_RDWR); 01737 #else 01738 fd = open("/dev/dahdi/pseudo", O_RDWR); 01739 #endif 01740 if (fd < 0) { 01741 ast_log(LOG_WARNING, "Unable to open pseudo channel: %s\n", strerror(errno)); 01742 goto outrun; 01743 } 01744 using_pseudo = 1; 01745 /* Make non-blocking */ 01746 flags = fcntl(fd, F_GETFL); 01747 if (flags < 0) { 01748 ast_log(LOG_WARNING, "Unable to get flags: %s\n", strerror(errno)); 01749 close(fd); 01750 goto outrun; 01751 } 01752 if (fcntl(fd, F_SETFL, flags | O_NONBLOCK)) { 01753 ast_log(LOG_WARNING, "Unable to set flags: %s\n", strerror(errno)); 01754 close(fd); 01755 goto outrun; 01756 } 01757 /* Setup buffering information */ 01758 memset(&bi, 0, sizeof(bi)); 01759 bi.bufsize = CONF_SIZE/2; 01760 bi.txbufpolicy = DAHDI_POLICY_IMMEDIATE; 01761 bi.rxbufpolicy = DAHDI_POLICY_IMMEDIATE; 01762 bi.numbufs = audio_buffers; 01763 if (ioctl(fd, DAHDI_SET_BUFINFO, &bi)) { 01764 ast_log(LOG_WARNING, "Unable to set buffering information: %s\n", strerror(errno)); 01765 close(fd); 01766 goto outrun; 01767 } 01768 x = 1; 01769 if (ioctl(fd, DAHDI_SETLINEAR, &x)) { 01770 ast_log(LOG_WARNING, "Unable to set linear mode: %s\n", strerror(errno)); 01771 close(fd); 01772 goto outrun; 01773 } 01774 nfds = 1; 01775 } else { 01776 /* XXX Make sure we're not running on a pseudo channel XXX */ 01777 fd = chan->fds[0]; 01778 nfds = 0; 01779 } 01780 memset(&ztc, 0, sizeof(ztc)); 01781 memset(&ztc_empty, 0, sizeof(ztc_empty)); 01782 /* Check to see if we're in a conference... */ 01783 ztc.chan = 0; 01784 if (ioctl(fd, DAHDI_GETCONF, &ztc)) { 01785 ast_log(LOG_WARNING, "Error getting conference\n"); 01786 close(fd); 01787 goto outrun; 01788 } 01789 if (ztc.confmode) { 01790 /* Whoa, already in a conference... Retry... */ 01791 if (!retryzap) { 01792 ast_log(LOG_DEBUG, "%s channel is in a conference already, retrying with pseudo\n", dahdi_chan_name); 01793 retryzap = 1; 01794 goto zapretry; 01795 } 01796 } 01797 memset(&ztc, 0, sizeof(ztc)); 01798 /* Add us to the conference */ 01799 ztc.chan = 0; 01800 ztc.confno = conf->zapconf; 01801 01802 if (!(confflags & CONFFLAG_QUIET) && ((confflags & CONFFLAG_INTROUSER) || (confflags & CONFFLAG_INTROUSERNOREVIEW)) && conf->users > 1) { 01803 struct announce_listitem *item; 01804 if (!(item = ao2_alloc(sizeof(*item), NULL))) 01805 return -1; 01806 ast_copy_string(item->namerecloc, user->namerecloc, sizeof(item->namerecloc)); 01807 ast_copy_string(item->language, chan->language, sizeof(item->language)); 01808 item->confchan = conf->chan; 01809 item->confusers = conf->users; 01810 item->announcetype = CONF_HASJOIN; 01811 ast_mutex_lock(&conf->announcelistlock); 01812 ao2_ref(item, +1); /* add one more so we can determine when announce_thread is done playing it */ 01813 AST_LIST_INSERT_TAIL(&conf->announcelist, item, entry); 01814 ast_cond_signal(&conf->announcelist_addition); 01815 ast_mutex_unlock(&conf->announcelistlock); 01816 01817 while (!ast_check_hangup(conf->chan) && ao2_ref(item, 0) == 2 && !ast_safe_sleep(chan, 1000)) { 01818 ; 01819 } 01820 ao2_ref(item, -1); 01821 } 01822 01823 if (confflags & CONFFLAG_WAITMARKED && !conf->markedusers) 01824 ztc.confmode = DAHDI_CONF_CONF; 01825 else if (confflags & CONFFLAG_MONITOR) 01826 ztc.confmode = DAHDI_CONF_CONFMON | DAHDI_CONF_LISTENER; 01827 else if (confflags & CONFFLAG_TALKER) 01828 ztc.confmode = DAHDI_CONF_CONF | DAHDI_CONF_TALKER; 01829 else 01830 ztc.confmode = DAHDI_CONF_CONF | DAHDI_CONF_TALKER | DAHDI_CONF_LISTENER; 01831 01832 if (ioctl(fd, DAHDI_SETCONF, &ztc)) { 01833 ast_log(LOG_WARNING, "Error setting conference\n"); 01834 close(fd); 01835 goto outrun; 01836 } 01837 ast_log(LOG_DEBUG, "Placed channel %s in %s conf %d\n", chan->name, dahdi_chan_name, conf->zapconf); 01838 01839 if (!sent_event) { 01840 manager_event(EVENT_FLAG_CALL, "MeetmeJoin", 01841 "Channel: %s\r\n" 01842 "Uniqueid: %s\r\n" 01843 "Meetme: %s\r\n" 01844 "Usernum: %d\r\n", 01845 chan->name, chan->uniqueid, conf->confno, user->user_no); 01846 sent_event = 1; 01847 } 01848 01849 if (!firstpass && !(confflags & CONFFLAG_MONITOR) && !(confflags & CONFFLAG_ADMIN)) { 01850 firstpass = 1; 01851 if (!(confflags & CONFFLAG_QUIET)) 01852 if (!(confflags & CONFFLAG_WAITMARKED) || ((confflags & CONFFLAG_MARKEDUSER) && (conf->markedusers >= 1))) 01853 conf_play(chan, conf, ENTER); 01854 } 01855 01856 conf_flush(fd, chan); 01857 01858 if (confflags & CONFFLAG_AGI) { 01859 /* Get name of AGI file to run from $(MEETME_AGI_BACKGROUND) 01860 or use default filename of conf-background.agi */ 01861 01862 agifile = pbx_builtin_getvar_helper(chan, "MEETME_AGI_BACKGROUND"); 01863 if (!agifile) 01864 agifile = agifiledefault; 01865 01866 if (user->zapchannel) { 01867 /* Set CONFMUTE mode on Zap channel to mute DTMF tones */ 01868 x = 1; 01869 ast_channel_setoption(chan, AST_OPTION_TONE_VERIFY, &x, sizeof(char), 0); 01870 } 01871 /* Find a pointer to the agi app and execute the script */ 01872 app = pbx_findapp("agi"); 01873 if (app) { 01874 char *s = ast_strdupa(agifile); 01875 ret = pbx_exec(chan, app, s); 01876 } else { 01877 ast_log(LOG_WARNING, "Could not find application (agi)\n"); 01878 ret = -2; 01879 } 01880 if (user->zapchannel) { 01881 /* Remove CONFMUTE mode on Zap channel */ 01882 x = 0; 01883 ast_channel_setoption(chan, AST_OPTION_TONE_VERIFY, &x, sizeof(char), 0); 01884 } 01885 } else { 01886 if (user->zapchannel && (confflags & CONFFLAG_STARMENU)) { 01887 /* Set CONFMUTE mode on Zap channel to mute DTMF tones when the menu is enabled */ 01888 x = 1; 01889 ast_channel_setoption(chan, AST_OPTION_TONE_VERIFY, &x, sizeof(char), 0); 01890 } 01891 if (confflags & (CONFFLAG_MONITORTALKER | CONFFLAG_OPTIMIZETALKER) && !(dsp = ast_dsp_new())) { 01892 ast_log(LOG_WARNING, "Unable to allocate DSP!\n"); 01893 res = -1; 01894 } 01895 for(;;) { 01896 int menu_was_active = 0; 01897 01898 outfd = -1; 01899 ms = -1; 01900 01901 if (timeout && time(NULL) >= timeout) 01902 break; 01903 01904 /* if we have just exited from the menu, and the user had a channel-driver 01905 volume adjustment, restore it 01906 */ 01907 if (!menu_active && menu_was_active && user->listen.desired && !user->listen.actual) 01908 set_talk_volume(user, user->listen.desired); 01909 01910 menu_was_active = menu_active; 01911 01912 currentmarked = conf->markedusers; 01913 if (!(confflags & CONFFLAG_QUIET) && 01914 (confflags & CONFFLAG_MARKEDUSER) && 01915 (confflags & CONFFLAG_WAITMARKED) && 01916 lastmarked == 0) { 01917 if (currentmarked == 1 && conf->users > 1) { 01918 ast_say_number(chan, conf->users - 1, AST_DIGIT_ANY, chan->language, (char *) NULL); 01919 if (conf->users - 1 == 1) { 01920 if (!ast_streamfile(chan, "conf-userwilljoin", chan->language)) 01921 ast_waitstream(chan, ""); 01922 } else { 01923 if (!ast_streamfile(chan, "conf-userswilljoin", chan->language)) 01924 ast_waitstream(chan, ""); 01925 } 01926 } 01927 if (conf->users == 1 && ! (confflags & CONFFLAG_MARKEDUSER)) 01928 if (!ast_streamfile(chan, "conf-onlyperson", chan->language)) 01929 ast_waitstream(chan, ""); 01930 } 01931 01932 c = ast_waitfor_nandfds(&chan, 1, &fd, nfds, NULL, &outfd, &ms); 01933 01934 01935 /* Update the struct with the actual confflags */ 01936 user->userflags = confflags; 01937 01938 if (confflags & CONFFLAG_WAITMARKED) { 01939 if(currentmarked == 0) { 01940 if (lastmarked != 0) { 01941 if (!(confflags & CONFFLAG_QUIET)) 01942 if (!ast_streamfile(chan, "conf-leaderhasleft", chan->language)) 01943 ast_waitstream(chan, ""); 01944 if(confflags & CONFFLAG_MARKEDEXIT) 01945 break; 01946 else { 01947 ztc.confmode = DAHDI_CONF_CONF; 01948 if (ioctl(fd, DAHDI_SETCONF, &ztc)) { 01949 ast_log(LOG_WARNING, "Error setting conference\n"); 01950 close(fd); 01951 goto outrun; 01952 } 01953 } 01954 } 01955 if (musiconhold == 0 && (confflags & CONFFLAG_MOH)) { 01956 ast_moh_start(chan, NULL, NULL); 01957 musiconhold = 1; 01958 } 01959 } else if(currentmarked >= 1 && lastmarked == 0) { 01960 /* Marked user entered, so cancel timeout */ 01961 timeout = 0; 01962 if (confflags & CONFFLAG_MONITOR) 01963 ztc.confmode = DAHDI_CONF_CONFMON | DAHDI_CONF_LISTENER; 01964 else if (confflags & CONFFLAG_TALKER) 01965 ztc.confmode = DAHDI_CONF_CONF | DAHDI_CONF_TALKER; 01966 else 01967 ztc.confmode = DAHDI_CONF_CONF | DAHDI_CONF_TALKER | DAHDI_CONF_LISTENER; 01968 if (ioctl(fd, DAHDI_SETCONF, &ztc)) { 01969 ast_log(LOG_WARNING, "Error setting conference\n"); 01970 close(fd); 01971 goto outrun; 01972 } 01973 if (musiconhold && (confflags & CONFFLAG_MOH)) { 01974 ast_moh_stop(chan); 01975 musiconhold = 0; 01976 } 01977 if ( !(confflags & CONFFLAG_QUIET) && !(confflags & CONFFLAG_MARKEDUSER)) { 01978 if (!ast_streamfile(chan, "conf-placeintoconf", chan->language)) 01979 ast_waitstream(chan, ""); 01980 conf_play(chan, conf, ENTER); 01981 } 01982 } 01983 } 01984 01985 /* trying to add moh for single person conf */ 01986 if ((confflags & CONFFLAG_MOH) && !(confflags & CONFFLAG_WAITMARKED)) { 01987 if (conf->users == 1) { 01988 if (musiconhold == 0) { 01989 ast_moh_start(chan, NULL, NULL); 01990 musiconhold = 1; 01991 } 01992 } else { 01993 if (musiconhold) { 01994 ast_moh_stop(chan); 01995 musiconhold = 0; 01996 } 01997 } 01998 } 01999 02000 /* Leave if the last marked user left */ 02001 if (currentmarked == 0 && lastmarked != 0 && (confflags & CONFFLAG_MARKEDEXIT)) { 02002 ret = -1; 02003 break; 02004 } 02005 02006 /* Check if my modes have changed */ 02007 02008 /* If I should be muted but am still talker, mute me */ 02009 if ((user->adminflags & (ADMINFLAG_MUTED | ADMINFLAG_SELFMUTED)) && (ztc.confmode & DAHDI_CONF_TALKER)) { 02010 ztc.confmode ^= DAHDI_CONF_TALKER; 02011 if (ioctl(fd, DAHDI_SETCONF, &ztc)) { 02012 ast_log(LOG_WARNING, "Error setting conference - Un/Mute \n"); 02013 ret = -1; 02014 break; 02015 } 02016 02017 manager_event(EVENT_FLAG_CALL, "MeetmeMute", 02018 "Channel: %s\r\n" 02019 "Uniqueid: %s\r\n" 02020 "Meetme: %s\r\n" 02021 "Usernum: %i\r\n" 02022 "Status: on\r\n", 02023 chan->name, chan->uniqueid, conf->confno, user->user_no); 02024 } 02025 02026 /* If I should be un-muted but am not talker, un-mute me */ 02027 if (!(user->adminflags & (ADMINFLAG_MUTED | ADMINFLAG_SELFMUTED)) && !(confflags & CONFFLAG_MONITOR) && !(ztc.confmode & DAHDI_CONF_TALKER)) { 02028 ztc.confmode |= DAHDI_CONF_TALKER; 02029 if (ioctl(fd, DAHDI_SETCONF, &ztc)) { 02030 ast_log(LOG_WARNING, "Error setting conference - Un/Mute \n"); 02031 ret = -1; 02032 break; 02033 } 02034 02035 manager_event(EVENT_FLAG_CALL, "MeetmeMute", 02036 "Channel: %s\r\n" 02037 "Uniqueid: %s\r\n" 02038 "Meetme: %s\r\n" 02039 "Usernum: %i\r\n" 02040 "Status: off\r\n", 02041 chan->name, chan->uniqueid, conf->confno, user->user_no); 02042 } 02043 02044 /* If I have been kicked, exit the conference */ 02045 if (user->adminflags & ADMINFLAG_KICKME) { 02046 //You have been kicked. 02047 if (!(confflags & CONFFLAG_QUIET) && 02048 !ast_streamfile(chan, "conf-kicked", chan->language)) { 02049 ast_waitstream(chan, ""); 02050 } 02051 ret = 0; 02052 break; 02053 } 02054 02055 /* Perform an extra hangup check just in case */ 02056 if (ast_check_hangup(chan)) 02057 break; 02058 02059 if (c) { 02060 char dtmfstr[2] = ""; 02061 02062 if (c->fds[0] != origfd || (user->zapchannel && (c->audiohooks || c->monitor))) { 02063 if (using_pseudo) { 02064 /* Kill old pseudo */ 02065 close(fd); 02066 using_pseudo = 0; 02067 } 02068 ast_log(LOG_DEBUG, "Ooh, something swapped out under us, starting over\n"); 02069 retryzap = (strcasecmp(c->tech->type, dahdi_chan_name) || (c->audiohooks || c->monitor) ? 1 : 0); 02070 user->zapchannel = !retryzap; 02071 goto zapretry; 02072 } 02073 if ((confflags & CONFFLAG_MONITOR) || (user->adminflags & (ADMINFLAG_MUTED | ADMINFLAG_SELFMUTED))) 02074 f = ast_read_noaudio(c); 02075 else 02076 f = ast_read(c); 02077 if (!f) 02078 break; 02079 if (f->frametype == AST_FRAME_DTMF) { 02080 dtmfstr[0] = f->subclass; 02081 dtmfstr[1] = '\0'; 02082 } 02083 02084 if ((f->frametype == AST_FRAME_VOICE) && (f->subclass == AST_FORMAT_SLINEAR)) { 02085 if (user->talk.actual) 02086 ast_frame_adjust_volume(f, user->talk.actual); 02087 02088 if (confflags & (CONFFLAG_MONITORTALKER | CONFFLAG_OPTIMIZETALKER)) { 02089 int totalsilence; 02090 02091 if (user->talking == -1) 02092 user->talking = 0; 02093 02094 res = ast_dsp_silence(dsp, f, &totalsilence); 02095 if (!user->talking && totalsilence < MEETME_DELAYDETECTTALK) { 02096 user->talking = 1; 02097 if (confflags & CONFFLAG_MONITORTALKER) 02098 manager_event(EVENT_FLAG_CALL, "MeetmeTalking", 02099 "Channel: %s\r\n" 02100 "Uniqueid: %s\r\n" 02101 "Meetme: %s\r\n" 02102 "Usernum: %d\r\n" 02103 "Status: on\r\n", 02104 chan->name, chan->uniqueid, conf->confno, user->user_no); 02105 } 02106 if (user->talking && totalsilence > MEETME_DELAYDETECTENDTALK) { 02107 user->talking = 0; 02108 if (confflags & CONFFLAG_MONITORTALKER) 02109 manager_event(EVENT_FLAG_CALL, "MeetmeTalking", 02110 "Channel: %s\r\n" 02111 "Uniqueid: %s\r\n" 02112 "Meetme: %s\r\n" 02113 "Usernum: %d\r\n" 02114 "Status: off\r\n", 02115 chan->name, chan->uniqueid, conf->confno, user->user_no); 02116 } 02117 } 02118 if (using_pseudo) { 02119 /* Absolutely do _not_ use careful_write here... 02120 it is important that we read data from the channel 02121 as fast as it arrives, and feed it into the conference. 02122 The buffering in the pseudo channel will take care of any 02123 timing differences, unless they are so drastic as to lose 02124 audio frames (in which case carefully writing would only 02125 have delayed the audio even further). 02126 */ 02127 /* As it turns out, we do want to use careful write. We just 02128 don't want to block, but we do want to at least *try* 02129 to write out all the samples. 02130 */ 02131 if (user->talking || !(confflags & CONFFLAG_OPTIMIZETALKER)) 02132 careful_write(fd, f->data, f->datalen, 0); 02133 } 02134 } else if ((f->frametype == AST_FRAME_DTMF) && (f->subclass == '#') && (confflags & CONFFLAG_POUNDEXIT)) { 02135 if (confflags & CONFFLAG_PASS_DTMF) 02136 conf_queue_dtmf(conf, user, f); 02137 ret = 0; 02138 ast_frfree(f); 02139 break; 02140 } else if (((f->frametype == AST_FRAME_DTMF) && (f->subclass == '*') && (confflags & CONFFLAG_STARMENU)) || ((f->frametype == AST_FRAME_DTMF) && menu_active)) { 02141 if (confflags & CONFFLAG_PASS_DTMF) 02142 conf_queue_dtmf(conf, user, f); 02143 if (ioctl(fd, DAHDI_SETCONF, &ztc_empty)) { 02144 ast_log(LOG_WARNING, "Error setting conference\n"); 02145 close(fd); 02146 ast_frfree(f); 02147 goto outrun; 02148 } 02149 02150 /* if we are entering the menu, and the user has a channel-driver 02151 volume adjustment, clear it 02152 */ 02153 if (!menu_active && user->talk.desired && !user->talk.actual) 02154 set_talk_volume(user, 0); 02155 02156 if (musiconhold) { 02157 ast_moh_stop(chan); 02158 } 02159 if ((confflags & CONFFLAG_ADMIN)) { 02160 /* Admin menu */ 02161 if (!menu_active) { 02162 menu_active = 1; 02163 /* Record this sound! */ 02164 if (!ast_streamfile(chan, "conf-adminmenu", chan->language)) { 02165 dtmf = ast_waitstream(chan, AST_DIGIT_ANY); 02166 ast_stopstream(chan); 02167 } else 02168 dtmf = 0; 02169 } else 02170 dtmf = f->subclass; 02171 if (dtmf) { 02172 switch(dtmf) { 02173 case '1': /* Un/Mute */ 02174 menu_active = 0; 02175 02176 /* for admin, change both admin and use flags */ 02177 if (user->adminflags & (ADMINFLAG_MUTED | ADMINFLAG_SELFMUTED)) 02178 user->adminflags &= ~(ADMINFLAG_MUTED | ADMINFLAG_SELFMUTED); 02179 else 02180 user->adminflags |= (ADMINFLAG_MUTED | ADMINFLAG_SELFMUTED); 02181 02182 if ((confflags & CONFFLAG_MONITOR) || (user->adminflags & (ADMINFLAG_MUTED | ADMINFLAG_SELFMUTED))) { 02183 if (!ast_streamfile(chan, "conf-muted", chan->language)) 02184 ast_waitstream(chan, ""); 02185 } else { 02186 if (!ast_streamfile(chan, "conf-unmuted", chan->language)) 02187 ast_waitstream(chan, ""); 02188 } 02189 break; 02190 case '2': /* Un/Lock the Conference */ 02191 menu_active = 0; 02192 if (conf->locked) { 02193 conf->locked = 0; 02194 if (!ast_streamfile(chan, "conf-unlockednow", chan->language)) 02195 ast_waitstream(chan, ""); 02196 } else { 02197 conf->locked = 1; 02198 if (!ast_streamfile(chan, "conf-lockednow", chan->language)) 02199 ast_waitstream(chan, ""); 02200 } 02201 break; 02202 case '3': /* Eject last user */ 02203 menu_active = 0; 02204 usr = AST_LIST_LAST(&conf->userlist); 02205 if ((usr->chan->name == chan->name)||(usr->userflags & CONFFLAG_ADMIN)) { 02206 if(!ast_streamfile(chan, "conf-errormenu", chan->language)) 02207 ast_waitstream(chan, ""); 02208 } else 02209 usr->adminflags |= ADMINFLAG_KICKME; 02210 ast_stopstream(chan); 02211 break; 02212 case '4': 02213 tweak_listen_volume(user, VOL_DOWN); 02214 break; 02215 case '6': 02216 tweak_listen_volume(user, VOL_UP); 02217 break; 02218 case '7': 02219 tweak_talk_volume(user, VOL_DOWN); 02220 break; 02221 case '8': 02222 menu_active = 0; 02223 break; 02224 case '9': 02225 tweak_talk_volume(user, VOL_UP); 02226 break; 02227 default: 02228 menu_active = 0; 02229 /* Play an error message! */ 02230 if (!ast_streamfile(chan, "conf-errormenu", chan->language)) 02231 ast_waitstream(chan, ""); 02232 break; 02233 } 02234 } 02235 } else { 02236 /* User menu */ 02237 if (!menu_active) { 02238 menu_active = 1; 02239 if (!ast_streamfile(chan, "conf-usermenu", chan->language)) { 02240 dtmf = ast_waitstream(chan, AST_DIGIT_ANY); 02241 ast_stopstream(chan); 02242 } else 02243 dtmf = 0; 02244 } else 02245 dtmf = f->subclass; 02246 if (dtmf) { 02247 switch(dtmf) { 02248 case '1': /* Un/Mute */ 02249 menu_active = 0; 02250 02251 /* user can only toggle the self-muted state */ 02252 user->adminflags ^= ADMINFLAG_SELFMUTED; 02253 02254 /* they can't override the admin mute state */ 02255 if ((confflags & CONFFLAG_MONITOR) || (user->adminflags & (ADMINFLAG_MUTED | ADMINFLAG_SELFMUTED))) { 02256 if (!ast_streamfile(chan, "conf-muted", chan->language)) 02257 ast_waitstream(chan, ""); 02258 } else { 02259 if (!ast_streamfile(chan, "conf-unmuted", chan->language)) 02260 ast_waitstream(chan, ""); 02261 } 02262 break; 02263 case '4': 02264 tweak_listen_volume(user, VOL_DOWN); 02265 break; 02266 case '6': 02267 tweak_listen_volume(user, VOL_UP); 02268 break; 02269 case '7': 02270 tweak_talk_volume(user, VOL_DOWN); 02271 break; 02272 case '8': 02273 menu_active = 0; 02274 break; 02275 case '9': 02276 tweak_talk_volume(user, VOL_UP); 02277 break; 02278 default: 02279 menu_active = 0; 02280 if (!ast_streamfile(chan, "conf-errormenu", chan->language)) 02281 ast_waitstream(chan, ""); 02282 break; 02283 } 02284 } 02285 } 02286 if (musiconhold) 02287 ast_moh_start(chan, NULL, NULL); 02288 02289 if (ioctl(fd, DAHDI_SETCONF, &ztc)) { 02290 ast_log(LOG_WARNING, "Error setting conference\n"); 02291 close(fd); 02292 ast_frfree(f); 02293 goto outrun; 02294 } 02295 02296 conf_flush(fd, chan); 02297 /* Since this option could absorb dtmf for the previous, we have to check this one last */ 02298 } else if ((f->frametype == AST_FRAME_DTMF) && (confflags & CONFFLAG_EXIT_CONTEXT) && ast_exists_extension(chan, exitcontext, dtmfstr, 1, "")) { 02299 if (confflags & CONFFLAG_PASS_DTMF) 02300 conf_queue_dtmf(conf, user, f); 02301 02302 if (!ast_goto_if_exists(chan, exitcontext, dtmfstr, 1)) { 02303 ast_log(LOG_DEBUG, "Got DTMF %c, goto context %s\n", dtmfstr[0], exitcontext); 02304 ret = 0; 02305 ast_frfree(f); 02306 break; 02307 } else if (option_debug > 1) 02308 ast_log(LOG_DEBUG, "Exit by single digit did not work in meetme. Extension '%s' does not exist in context '%s'\n", dtmfstr, exitcontext); 02309 } else if ((f->frametype == AST_FRAME_DTMF_BEGIN || f->frametype == AST_FRAME_DTMF_END) 02310 && confflags & CONFFLAG_PASS_DTMF) { 02311 conf_queue_dtmf(conf, user, f); 02312 } else if ((confflags & CONFFLAG_SLA_STATION) && f->frametype == AST_FRAME_CONTROL) { 02313 switch (f->subclass) { 02314 case AST_CONTROL_HOLD: 02315 sla_queue_event_conf(SLA_EVENT_HOLD, chan, conf); 02316 break; 02317 default: 02318 break; 02319 } 02320 } else if (f->frametype == AST_FRAME_NULL) { 02321 /* Ignore NULL frames. It is perfectly normal to get these if the person is muted. */ 02322 } else if (option_debug) { 02323 ast_log(LOG_DEBUG, 02324 "Got unrecognized frame on channel %s, f->frametype=%d,f->subclass=%d\n", 02325 chan->name, f->frametype, f->subclass); 02326 } 02327 ast_frfree(f); 02328 } else if (outfd > -1) { 02329 res = read(outfd, buf, CONF_SIZE); 02330 if (res > 0) { 02331 memset(&fr, 0, sizeof(fr)); 02332 fr.frametype = AST_FRAME_VOICE; 02333 fr.subclass = AST_FORMAT_SLINEAR; 02334 fr.datalen = res; 02335 fr.samples = res/2; 02336 fr.data = buf; 02337 fr.offset = AST_FRIENDLY_OFFSET; 02338 if (!user->listen.actual && 02339 ((confflags & CONFFLAG_MONITOR) || 02340 (user->adminflags & (ADMINFLAG_MUTED | ADMINFLAG_SELFMUTED)) || 02341 (!user->talking && (confflags & CONFFLAG_OPTIMIZETALKER)) 02342 )) { 02343 int index; 02344 for (index=0;index<AST_FRAME_BITS;index++) 02345 if (chan->rawwriteformat & (1 << index)) 02346 break; 02347 if (index >= AST_FRAME_BITS) 02348 goto bailoutandtrynormal; 02349 ast_mutex_lock(&conf->listenlock); 02350 if (!conf->transframe[index]) { 02351 if (conf->origframe) { 02352 if (!conf->transpath[index]) 02353 conf->transpath[index] = ast_translator_build_path((1 << index), AST_FORMAT_SLINEAR); 02354 if (conf->transpath[index]) { 02355 conf->transframe[index] = ast_translate(conf->transpath[index], conf->origframe, 0); 02356 if (!conf->transframe[index]) 02357 conf->transframe[index] = &ast_null_frame; 02358 } 02359 } 02360 } 02361 if (conf->transframe[index]) { 02362 if (conf->transframe[index]->frametype != AST_FRAME_NULL) { 02363 if (can_write(chan, confflags) && ast_write(chan, conf->transframe[index])) 02364 ast_log(LOG_WARNING, "Unable to write frame to channel %s\n", chan->name); 02365 } 02366 } else { 02367 ast_mutex_unlock(&conf->listenlock); 02368 goto bailoutandtrynormal; 02369 } 02370 ast_mutex_unlock(&conf->listenlock); 02371 } else { 02372 bailoutandtrynormal: 02373 if (user->listen.actual) 02374 ast_frame_adjust_volume(&fr, user->listen.actual); 02375 if (can_write(chan, confflags) && ast_write(chan, &fr) < 0) { 02376 ast_log(LOG_WARNING, "Unable to write frame to channel %s\n", chan->name); 02377 } 02378 } 02379 } else 02380 ast_log(LOG_WARNING, "Failed to read frame: %s\n", strerror(errno)); 02381 } 02382 lastmarked = currentmarked; 02383 } 02384 } 02385 02386 if (musiconhold) 02387 ast_moh_stop(chan); 02388 02389 if (using_pseudo) 02390 close(fd); 02391 else { 02392 /* Take out of conference */ 02393 ztc.chan = 0; 02394 ztc.confno = 0; 02395 ztc.confmode = 0; 02396 if (ioctl(fd, DAHDI_SETCONF, &ztc)) { 02397 ast_log(LOG_WARNING, "Error setting conference\n"); 02398 } 02399 } 02400 02401 reset_volumes(user); 02402 02403 if (!(confflags & CONFFLAG_QUIET) && !(confflags & CONFFLAG_MONITOR) && !(confflags & CONFFLAG_ADMIN)) 02404 conf_play(chan, conf, LEAVE); 02405 02406 if (!(confflags & CONFFLAG_QUIET) && ((confflags & CONFFLAG_INTROUSER) || (confflags & CONFFLAG_INTROUSERNOREVIEW)) && conf->users > 1) { 02407 struct announce_listitem *item; 02408 if (!(item = ao2_alloc(sizeof(*item), NULL))) 02409 return -1; 02410 ast_copy_string(item->namerecloc, user->namerecloc, sizeof(item->namerecloc)); 02411 ast_copy_string(item->language, chan->language, sizeof(item->language)); 02412 item->confchan = conf->chan; 02413 item->confusers = conf->users; 02414 item->announcetype = CONF_HASLEFT; 02415 ast_mutex_lock(&conf->announcelistlock); 02416 AST_LIST_INSERT_TAIL(&conf->announcelist, item, entry); 02417 ast_cond_signal(&conf->announcelist_addition); 02418 ast_mutex_unlock(&conf->announcelistlock); 02419 } else if (!(confflags & CONFFLAG_QUIET) && ((confflags & CONFFLAG_INTROUSER) || (confflags & CONFFLAG_INTROUSERNOREVIEW)) && conf->users == 1) { 02420 /* Last person is leaving, so no reason to try and announce, but should delete the name recording */ 02421 ast_filedelete(user->namerecloc, NULL); 02422 } 02423 02424 outrun: 02425 AST_LIST_LOCK(&confs); 02426 02427 if (dsp) 02428 ast_dsp_free(dsp); 02429 02430 if (user->user_no) { /* Only cleanup users who really joined! */ 02431 now = time(NULL); 02432 hr = (now - user->jointime) / 3600; 02433 min = ((now - user->jointime) % 3600) / 60; 02434 sec = (now - user->jointime) % 60; 02435 02436 if (sent_event) { 02437 manager_event(EVENT_FLAG_CALL, "MeetmeLeave", 02438 "Channel: %s\r\n" 02439 "Uniqueid: %s\r\n" 02440 "Meetme: %s\r\n" 02441 "Usernum: %d\r\n" 02442 "CallerIDnum: %s\r\n" 02443 "CallerIDname: %s\r\n" 02444 "Duration: %ld\r\n", 02445 chan->name, chan->uniqueid, conf->confno, 02446 user->user_no, 02447 S_OR(user->chan->cid.cid_num, "<unknown>"), 02448 S_OR(user->chan->cid.cid_name, "<unknown>"), 02449 (long)(now - user->jointime)); 02450 } 02451 02452 if (setusercount) { 02453 conf->users--; 02454 /* Update table */ 02455 snprintf(members, sizeof(members), "%d", conf->users); 02456 ast_update_realtime("meetme", "confno", conf->confno, "members", members, NULL); 02457 if (confflags & CONFFLAG_MARKEDUSER) 02458 conf->markedusers--; 02459 } 02460 /* Remove ourselves from the list */ 02461 AST_LIST_REMOVE(&conf->userlist, user, list); 02462 02463 /* Change any states */ 02464 if (!conf->users) 02465 ast_device_state_changed("meetme:%s", conf->confno); 02466 02467 /* Return the number of seconds the user was in the conf */ 02468 snprintf(meetmesecs, sizeof(meetmesecs), "%d", (int) (time(NULL) - user->jointime)); 02469 pbx_builtin_setvar_helper(chan, "MEETMESECS", meetmesecs); 02470 } 02471 free(user); 02472 AST_LIST_UNLOCK(&confs); 02473 02474 return ret; 02475 }
| static int count_exec | ( | struct ast_channel * | chan, | |
| void * | data | |||
| ) | [static] |
The MeetmeCount application.
Definition at line 2629 of file app_meetme.c.
References ast_channel::_state, ast_answer(), AST_APP_ARG, AST_DECLARE_APP_ARGS, ast_log(), ast_module_user_add, ast_module_user_remove, ast_say_number(), AST_STANDARD_APP_ARGS, AST_STATE_UP, ast_strdupa, ast_strlen_zero(), dispose_conf(), find_conf(), ast_channel::language, LOG_WARNING, pbx_builtin_setvar_helper(), and ast_conference::users.
Referenced by load_module().
02630 { 02631 struct ast_module_user *u; 02632 int res = 0; 02633 struct ast_conference *conf; 02634 int count; 02635 char *localdata; 02636 char val[80] = "0"; 02637 AST_DECLARE_APP_ARGS(args, 02638 AST_APP_ARG(confno); 02639 AST_APP_ARG(varname); 02640 ); 02641 02642 if (ast_strlen_zero(data)) { 02643 ast_log(LOG_WARNING, "MeetMeCount requires an argument (conference number)\n"); 02644 return -1; 02645 } 02646 02647 u = ast_module_user_add(chan); 02648 02649 if (!(localdata = ast_strdupa(data))) { 02650 ast_module_user_remove(u); 02651 return -1; 02652 } 02653 02654 AST_STANDARD_APP_ARGS(args, localdata); 02655 02656 conf = find_conf(chan, args.confno, 0, 0, NULL, 0, 1, NULL); 02657 02658 if (conf) { 02659 count = conf->users; 02660 dispose_conf(conf); 02661 conf = NULL; 02662 } else 02663 count = 0; 02664 02665 if (!ast_strlen_zero(args.varname)){ 02666 /* have var so load it and exit */ 02667 snprintf(val, sizeof(val), "%d",count); 02668 pbx_builtin_setvar_helper(chan, args.varname, val); 02669 } else { 02670 if (chan->_state != AST_STATE_UP) 02671 ast_answer(chan); 02672 res = ast_say_number(chan, count, "", chan->language, (char *) NULL); /* Needs gender */ 02673 } 02674 ast_module_user_remove(u); 02675 02676 return res; 02677 }
| static struct sla_trunk_ref* create_trunk_ref | ( | struct sla_trunk * | trunk | ) | [static, read] |
Definition at line 4453 of file app_meetme.c.
References ast_calloc, and sla_trunk_ref::trunk.
Referenced by sla_add_trunk_to_station().
04454 { 04455 struct sla_trunk_ref *trunk_ref; 04456 04457 if (!(trunk_ref = ast_calloc(1, sizeof(*trunk_ref)))) 04458 return NULL; 04459 04460 trunk_ref->trunk = trunk; 04461 04462 return trunk_ref; 04463 }
| static void destroy_station | ( | struct sla_station * | station | ) | [static] |
Definition at line 4621 of file app_meetme.c.
References ast_context_remove_extension(), 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(), sla_station::autocontext, exten, free, sla_trunk::name, sla_station::name, PRIORITY_HINT, sla_registrar, sla_trunk_ref::trunk, and sla_station::trunks.
Referenced by sla_build_station(), and sla_destroy().
04622 { 04623 struct sla_trunk_ref *trunk_ref; 04624 04625 if (!ast_strlen_zero(station->autocontext)) { 04626 AST_RWLIST_RDLOCK(&sla_trunks); 04627 AST_LIST_TRAVERSE(&station->trunks, trunk_ref, entry) { 04628 char exten[AST_MAX_EXTENSION]; 04629 char hint[AST_MAX_APP]; 04630 snprintf(exten, sizeof(exten), "%s_%s", station->name, trunk_ref->trunk->name); 04631 snprintf(hint, sizeof(hint), "SLA:%s", exten); 04632 ast_context_remove_extension(station->autocontext, exten, 04633 1, sla_registrar); 04634 ast_context_remove_extension(station->autocontext, hint, 04635 PRIORITY_HINT, sla_registrar); 04636 } 04637 AST_RWLIST_UNLOCK(&sla_trunks); 04638 } 04639 04640 while ((trunk_ref = AST_LIST_REMOVE_HEAD(&station->trunks, entry))) 04641 free(trunk_ref); 04642 04643 ast_string_field_free_memory(station); 04644 free(station); 04645 }
| static void destroy_trunk | ( | struct sla_trunk * | trunk | ) | [static] |
Definition at line 4607 of file app_meetme.c.
References ast_context_remove_extension(), AST_LIST_REMOVE_HEAD, ast_string_field_free_memory, ast_strlen_zero(), sla_trunk::autocontext, free, sla_registrar, and sla_trunk::stations.
Referenced by sla_build_trunk(), and sla_destroy().
04608 { 04609 struct sla_station_ref *station_ref; 04610 04611 if (!ast_strlen_zero(trunk->autocontext)) 04612 ast_context_remove_extension(trunk->autocontext, "s", 1, sla_registrar); 04613 04614 while ((station_ref = AST_LIST_REMOVE_HEAD(&trunk->stations, entry))) 04615 free(station_ref); 04616 04617 ast_string_field_free_memory(trunk); 04618 free(trunk); 04619 }
| static void* dial_trunk | ( | void * | data | ) | [static] |
Definition at line 4172 of file app_meetme.c.
References ALL_TRUNK_REFS, 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_set_flag, ast_strdup, ast_strdupa, ast_strlen_zero(), build_conf(), sla_trunk::chan, sla_trunk_ref::chan, ast_channel::cid, ast_callerid::cid_name, cid_name, ast_callerid::cid_num, cid_num, dial_trunk_args::cond, dial_trunk_args::cond_lock, conf_run(), CONFFLAG_MARKEDEXIT, CONFFLAG_MARKEDUSER, CONFFLAG_PASS_DTMF, CONFFLAG_QUIET, CONFFLAG_SLA_TRUNK, sla_trunk::device, dispose_conf(), ast_flags::flags, free, MAX_CONFNUM, sla_trunk::name, sla_trunk::on_hold, sla, sla_change_trunk_state(), SLA_TRUNK_STATE_IDLE, sla_trunk_ref::trunk, and dial_trunk_args::trunk_ref.
Referenced by sla_station_exec().
04173 { 04174 struct dial_trunk_args *args = data; 04175 struct ast_dial *dial; 04176 char *tech, *tech_data; 04177 enum ast_dial_result dial_res; 04178 char conf_name[MAX_CONFNUM]; 04179 struct ast_conference *conf; 04180 struct ast_flags conf_flags = { 0 }; 04181 struct sla_trunk_ref *trunk_ref = args->trunk_ref; 04182 const char *cid_name = NULL, *cid_num = NULL; 04183 04184 if (!(dial = ast_dial_create())) { 04185 ast_mutex_lock(args->cond_lock); 04186 ast_cond_signal(args->cond); 04187 ast_mutex_unlock(args->cond_lock); 04188 return NULL; 04189 } 04190 04191 tech_data = ast_strdupa(trunk_ref->trunk->device); 04192 tech = strsep(&tech_data, "/"); 04193 if (ast_dial_append(dial, tech, tech_data) == -1) { 04194 ast_mutex_lock(args->cond_lock); 04195 ast_cond_signal(args->cond); 04196 ast_mutex_unlock(args->cond_lock); 04197 ast_dial_destroy(dial); 04198 return NULL; 04199 } 04200 04201 if (!sla.attempt_callerid && !ast_strlen_zero(trunk_ref->chan->cid.cid_name)) { 04202 cid_name = ast_strdupa(trunk_ref->chan->cid.cid_name); 04203 free(trunk_ref->chan->cid.cid_name); 04204 trunk_ref->chan->cid.cid_name = NULL; 04205 } 04206 if (!sla.attempt_callerid && !ast_strlen_zero(trunk_ref->chan->cid.cid_num)) { 04207 cid_num = ast_strdupa(trunk_ref->chan->cid.cid_num); 04208 free(trunk_ref->chan->cid.cid_num); 04209 trunk_ref->chan->cid.cid_num = NULL; 04210 } 04211 04212 dial_res = ast_dial_run(dial, trunk_ref->chan, 1); 04213 04214 if (cid_name) 04215 trunk_ref->chan->cid.cid_name = ast_strdup(cid_name); 04216 if (cid_num) 04217 trunk_ref->chan->cid.cid_num = ast_strdup(cid_num); 04218 04219 if (dial_res != AST_DIAL_RESULT_TRYING) { 04220 ast_mutex_lock(args->cond_lock); 04221 ast_cond_signal(args->cond); 04222 ast_mutex_unlock(args->cond_lock); 04223 ast_dial_destroy(dial); 04224 return NULL; 04225 } 04226 04227 for (;;) { 04228 unsigned int done = 0; 04229 switch ((dial_res = ast_dial_state(dial))) { 04230 case AST_DIAL_RESULT_ANSWERED: 04231 trunk_ref->trunk->chan = ast_dial_answered(dial); 04232 case AST_DIAL_RESULT_HANGUP: 04233 case AST_DIAL_RESULT_INVALID: 04234 case AST_DIAL_RESULT_FAILED: 04235 case AST_DIAL_RESULT_TIMEOUT: 04236 case AST_DIAL_RESULT_UNANSWERED: 04237 done = 1; 04238 case AST_DIAL_RESULT_TRYING: 04239 case AST_DIAL_RESULT_RINGING: 04240 case AST_DIAL_RESULT_PROGRESS: 04241 case AST_DIAL_RESULT_PROCEEDING: 04242 break; 04243 } 04244 if (done) 04245 break; 04246 } 04247 04248 if (!trunk_ref->trunk->chan) { 04249 ast_mutex_lock(args->cond_lock); 04250 ast_cond_signal(args->cond); 04251 ast_mutex_unlock(args->cond_lock); 04252 ast_dial_join(dial); 04253 ast_dial_destroy(dial); 04254 return NULL; 04255 } 04256 04257 snprintf(conf_name, sizeof(conf_name), "SLA_%s", trunk_ref->trunk->name); 04258 ast_set_flag(&conf_flags, 04259 CONFFLAG_QUIET | CONFFLAG_MARKEDEXIT | CONFFLAG_MARKEDUSER | 04260 CONFFLAG_PASS_DTMF | CONFFLAG_SLA_TRUNK); 04261 conf = build_conf(conf_name, "", "", 1, 1, 1); 04262 04263 ast_mutex_lock(args->cond_lock); 04264 ast_cond_signal(args->cond); 04265 ast_mutex_unlock(args->cond_lock); 04266 04267 if (conf) { 04268 conf_run(trunk_ref->trunk->chan, conf, conf_flags.flags, NULL); 04269 dispose_conf(conf); 04270 conf = NULL; 04271 } 04272 04273 /* If the trunk is going away, it is definitely now IDLE. */ 04274 sla_change_trunk_state(trunk_ref->trunk, SLA_TRUNK_STATE_IDLE, ALL_TRUNK_REFS, NULL); 04275 04276 trunk_ref->trunk->chan = NULL; 04277 trunk_ref->trunk->on_hold = 0; 04278 04279 ast_dial_join(dial); 04280 ast_dial_destroy(dial); 04281 04282 return NULL; 04283 }
| static int dispose_conf | ( | struct ast_conference * | conf | ) | [static] |
Definition at line 1402 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().
01403 { 01404 int res = 0; 01405 int confno_int = 0; 01406 01407 AST_LIST_LOCK(&confs); 01408 if (ast_atomic_dec_and_test(&conf->refcount)) { 01409 /* Take the conference room number out of an inuse state */ 01410 if ((sscanf(conf->confno, "%d", &confno_int) == 1) && (confno_int >= 0 && confno_int < 1024)) 01411 conf_map[confno_int] = 0; 01412 conf_free(conf); 01413 res = 1; 01414 } 01415 AST_LIST_UNLOCK(&confs); 01416 01417 return res; 01418 }
| 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_flags * | confflags | |||
| ) | [static, read] |
Definition at line 2535 of file app_meetme.c.
References AST_APP_ARG, ast_app_getdata(), ast_clear_flag, ast_config_destroy(), ast_config_load(), AST_DECLARE_APP_ARGS, AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, ast_log(), AST_NONSTANDARD_APP_ARGS, ast_strdupa, ast_test_flag, ast_variable_browse(), build_conf(), ast_conference::chan, CONFFLAG_INTROUSER, CONFFLAG_QUIET, CONFFLAG_RECORDCONF, CONFIG_FILE_NAME, ast_conference::confno, dahdi_chan_name, ast_conference::list, LOG_DEBUG, LOG_WARNING, ast_variable::name, ast_variable::next, parse(), ast_conference::refcount, S_OR, ast_variable::value, and var.
Referenced by conf_exec(), and count_exec().
02537 { 02538 struct ast_config *cfg; 02539 struct ast_variable *var; 02540 struct ast_conference *cnf; 02541 char *parse; 02542 AST_DECLARE_APP_ARGS(args, 02543 AST_APP_ARG(confno); 02544 AST_APP_ARG(pin); 02545 AST_APP_ARG(pinadmin); 02546 ); 02547 02548 /* Check first in the conference list */ 02549 AST_LIST_LOCK(&confs); 02550 AST_LIST_TRAVERSE(&confs, cnf, list) { 02551 if (!strcmp(confno, cnf->confno)) 02552 break; 02553 } 02554 if (cnf){ 02555 cnf->refcount += refcount; 02556 } 02557 AST_LIST_UNLOCK(&confs); 02558 02559 if (!cnf) { 02560 if (dynamic) { 02561 /* No need to parse meetme.conf */ 02562 ast_log(LOG_DEBUG, "Building dynamic conference '%s'\n", confno); 02563 if (dynamic_pin) { 02564 if (dynamic_pin[0] == 'q') { 02565 /* Query the user to enter a PIN */ 02566 if (ast_app_getdata(chan, "conf-getpin", dynamic_pin, pin_buf_len - 1, 0) < 0) 02567 return NULL; 02568 } 02569 cnf = build_conf(confno, dynamic_pin, "", make, dynamic, refcount); 02570 } else { 02571 cnf = build_conf(confno, "", "", make, dynamic, refcount); 02572 } 02573 } else { 02574 /* Check the config */ 02575 cfg = ast_config_load(CONFIG_FILE_NAME); 02576 if (!cfg) { 02577 ast_log(LOG_WARNING, "No %s file :(\n", CONFIG_FILE_NAME); 02578 return NULL; 02579 } 02580 for (var = ast_variable_browse(cfg, "rooms"); var; var = var->next) { 02581 if (strcasecmp(var->name, "conf")) 02582 continue; 02583 02584 if (!(parse = ast_strdupa(var->value))) 02585 return NULL; 02586 02587 AST_NONSTANDARD_APP_ARGS(args, parse, ','); 02588 if (!strcasecmp(args.confno, confno)) { 02589 /* Bingo it's a valid conference */ 02590 cnf = build_conf(args.confno, 02591 S_OR(args.pin, ""), 02592 S_OR(args.pinadmin, ""), 02593 make, dynamic, refcount); 02594 break; 02595 } 02596 } 02597 if (!var) { 02598 ast_log(LOG_DEBUG, "%s isn't a valid conference\n", confno); 02599 } 02600 ast_config_destroy(cfg); 02601 } 02602 } else if (dynamic_pin) { 02603 /* Correct for the user selecting 'D' instead of 'd' to have 02604 someone join into a conference that has already been created 02605 with a pin. */ 02606 if (dynamic_pin[0] == 'q') 02607 dynamic_pin[0] = '\0'; 02608 } 02609 02610 if (cnf) { 02611 if (confflags && !cnf->chan && 02612 !ast_test_flag(confflags, CONFFLAG_QUIET) && 02613 ast_test_flag(confflags, CONFFLAG_INTROUSER)) { 02614 ast_log(LOG_WARNING, "No %s channel available for conference, user introduction disabled\n", dahdi_chan_name); 02615 ast_clear_flag(confflags, CONFFLAG_INTROUSER); 02616 } 02617 02618 if (confflags && !cnf->chan && 02619 ast_test_flag(confflags, CONFFLAG_RECORDCONF)) { 02620 ast_log(LOG_WARNING, "No %s channel available for conference, conference recording disabled\n", dahdi_chan_name); 02621 ast_clear_flag(confflags, CONFFLAG_RECORDCONF); 02622 } 02623 } 02624 02625 return cnf; 02626 }
| 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_flags * | confflags | |||
| ) | [static, read] |
Definition at line 2477 of file app_meetme.c.
References ast_clear_flag, AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, ast_load_realtime(), ast_log(), ast_strdupa, ast_test_flag, ast_variables_destroy(), build_conf(), ast_conference::chan, CONFFLAG_INTROUSER, CONFFLAG_QUIET, CONFFLAG_RECORDCONF, ast_conference::confno, dahdi_chan_name, ast_conference::list, LOG_WARNING, ast_variable::name, ast_variable::next, ast_conference::refcount, ast_variable::value, and var.
Referenced by conf_exec().
02479 { 02480 struct ast_variable *var, *save; 02481 struct ast_conference *cnf; 02482 02483 /* Check first in the conference list */ 02484 AST_LIST_LOCK(&confs); 02485 AST_LIST_TRAVERSE(&confs, cnf, list) { 02486 if (!strcmp(confno, cnf->confno)) 02487 break; 02488 } 02489 if (cnf) { 02490 cnf->refcount += refcount; 02491 } 02492 AST_LIST_UNLOCK(&confs); 02493 02494 if (!cnf) { 02495 char *pin = NULL, *pinadmin = NULL; /* For temp use */ 02496 02497 var = ast_load_realtime("meetme", "confno", confno, NULL); 02498 02499 if (!var) 02500 return NULL; 02501 02502 save = var; 02503 while (var) { 02504 if (!strcasecmp(var->name, "pin")) { 02505 pin = ast_strdupa(var->value); 02506 } else if (!strcasecmp(var->name, "adminpin")) { 02507 pinadmin = ast_strdupa(var->value); 02508 } 02509 var = var->next; 02510 } 02511 ast_variables_destroy(save); 02512 02513 cnf = build_conf(confno, pin ? pin : "", pinadmin ? pinadmin : "", make, dynamic, refcount); 02514 } 02515 02516 if (cnf) { 02517 if (confflags && !cnf->chan && 02518 !ast_test_flag(confflags, CONFFLAG_QUIET) && 02519 ast_test_flag(confflags, CONFFLAG_INTROUSER)) { 02520 ast_log(LOG_WARNING, "No %s channel available for conference, user introduction disabled\n", dahdi_chan_name); 02521 ast_clear_flag(confflags, CONFFLAG_INTROUSER); 02522 } 02523 02524 if (confflags && !cnf->chan && 02525 ast_test_flag(confflags, CONFFLAG_RECORDCONF)) { 02526 ast_log(LOG_WARNING, "No %s channel available for conference, conference recording disabled\n", dahdi_chan_name); 02527 ast_clear_flag(confflags, CONFFLAG_RECORDCONF); 02528 } 02529 } 02530 02531 return cnf; 02532 }
| static struct ast_conf_user* find_user | ( | struct ast_conference * | conf, | |
| char * | callerident | |||
| ) | [static, read] |
Definition at line 2926 of file app_meetme.c.
References AST_LIST_TRAVERSE, ast_conf_user::list, ast_conf_user::user_no, and ast_conference::userlist.
02927 { 02928 struct ast_conf_user *user = NULL; 02929 int cid; 02930 02931 sscanf(callerident, "%i", &cid); 02932 if (conf && callerident) { 02933 AST_LIST_TRAVERSE(&conf->userlist, user, list) { 02934 if (cid == user->user_no) 02935 return user; 02936 } 02937 } 02938 return NULL; 02939 }
| static const char* get_announce_filename | ( | enum announcetypes | type | ) | [static] |
Definition at line 1420 of file app_meetme.c.
References CONF_HASJOIN, and CONF_HASLEFT.
Referenced by announce_thread().
01421 { 01422 switch (type) { 01423 case CONF_HASLEFT: 01424 return "conf-hasleft"; 01425 break; 01426 case CONF_HASJOIN: 01427 return "conf-hasjoin"; 01428 break; 01429 default: 01430 return ""; 01431 } 01432 }
| static char* istalking | ( | int | x | ) | [static] |
Definition at line 590 of file app_meetme.c.
Referenced by meetme_cmd().
00591 { 00592 if (x > 0) 00593 return "(talking)"; 00594 else if (x < 0) 00595 return "(unmonitored)"; 00596 else 00597 return "(not talking)"; 00598 }
| static int load_config | ( | int | reload | ) | [static] |
Definition at line 4976 of file app_meetme.c.
References load_config_meetme(), and sla_load_config().
Referenced by load_module(), and reload().
04977 { 04978 int res = 0; 04979 04980 load_config_meetme(); 04981 if (!reload) 04982 res = sla_load_config(); 04983 04984 return res; 04985 }
| static void load_config_meetme | ( | void | ) | [static] |
Definition at line 3254 of file app_meetme.c.
References ast_config_destroy(), ast_config_load(), ast_log(), ast_variable_retrieve(), CONFIG_FILE_NAME, DEFAULT_AUDIO_BUFFERS, LOG_NOTICE, and LOG_WARNING.
Referenced by load_config().
03255 { 03256 struct ast_config *cfg; 03257 const char *val; 03258 03259 audio_buffers = DEFAULT_AUDIO_BUFFERS; 03260 03261 if (!(cfg = ast_config_load(CONFIG_FILE_NAME))) 03262 return; 03263 03264 if ((val = ast_variable_retrieve(cfg, "general", "audiobuffers"))) { 03265 if ((sscanf(val, "%d", &audio_buffers) != 1)) { 03266 ast_log(LOG_WARNING, "audiobuffers setting must be a number, not '%s'\n", val); 03267 audio_buffers = DEFAULT_AUDIO_BUFFERS; 03268 } else if ((audio_buffers < DAHDI_DEFAULT_NUM_BUFS) || (audio_buffers > DAHDI_MAX_NUM_BUFS)) { 03269 ast_log(LOG_WARNING, "audiobuffers setting must be between %d and %d\n", 03270 DAHDI_DEFAULT_NUM_BUFS, DAHDI_MAX_NUM_BUFS); 03271 audio_buffers = DEFAULT_AUDIO_BUFFERS; 03272 } 03273 if (audio_buffers != DEFAULT_AUDIO_BUFFERS) 03274 ast_log(LOG_NOTICE, "Audio buffers per channel set to %d\n", audio_buffers); 03275 } 03276 03277 ast_config_destroy(cfg); 03278 }
| static int load_module | ( | void | ) | [static] |
Definition at line 5010 of file app_meetme.c.
References action_meetmemute(), action_meetmeunmute(), admin_exec(), ARRAY_LEN, ast_cli_register_multiple(), ast_devstate_prov_add(), ast_manager_register, ast_register_application(), conf_exec(), count_exec(), EVENT_FLAG_CALL, load_config(), meetmestate(), sla_state(), sla_station_exec(), and sla_trunk_exec().
05011 { 05012 int res = 0; 05013 05014 res |= load_config(0); 05015 05016 ast_cli_register_multiple(cli_meetme, ARRAY_LEN(cli_meetme)); 05017 res |= ast_manager_register("MeetmeMute", EVENT_FLAG_CALL, 05018 action_meetmemute, "Mute a Meetme user"); 05019 res |= ast_manager_register("MeetmeUnmute", EVENT_FLAG_CALL, 05020 action_meetmeunmute, "Unmute a Meetme user"); 05021 res |= ast_register_application(app3, admin_exec, synopsis3, descrip3); 05022 res |= ast_register_application(app2, count_exec, synopsis2, descrip2); 05023 res |= ast_register_application(app, conf_exec, synopsis, descrip); 05024 res |= ast_register_application(slastation_app, sla_station_exec, 05025 slastation_synopsis, slastation_desc); 05026 res |= ast_register_application(slatrunk_app, sla_trunk_exec, 05027 slatrunk_synopsis, slatrunk_desc); 05028 05029 res |= ast_devstate_prov_add("Meetme", meetmestate); 05030 res |= ast_devstate_prov_add("SLA", sla_state); 05031 05032 return res; 05033 }
| static int meetme_cmd | ( | int | fd, | |
| int | argc, | |||
| char ** | argv | |||
| ) | [static] |
Definition at line 854 of file app_meetme.c.
References admin_exec(), ADMINFLAG_MUTED, ADMINFLAG_SELFMUTED, ast_conf_user::adminflags, ast_cli(), ast_copy_string(), AST_LIST_EMPTY, AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, ast_log(), ast_conf_user::chan, ast_channel::cid, ast_callerid::cid_name, ast_callerid::cid_num, CONFFLAG_ADMIN, CONFFLAG_MONITOR, ast_conference::confno, ast_conference::isdynamic, istalking(), ast_conf_user::jointime, ast_conf_user::list, LOG_DEBUG, ast_conference::markedusers, ast_channel::name, RESULT_SHOWUSAGE, RESULT_SUCCESS, S_OR, ast_conference::start, ast_conf_user::talking, total, ast_conf_user::user_no, ast_conf_user::userflags, ast_conference::userlist, and ast_conference::users.
00855 { 00856 /* Process the command */ 00857 struct ast_conference *cnf; 00858 struct ast_conf_user *user; 00859 int hr, min, sec; 00860 int i = 0, total = 0; 00861 time_t now; 00862 char *header_format = "%-14s %-14s %-10s %-8s %-8s\n"; 00863 char *data_format = "%-12.12s %4.4d %4.4s %02d:%02d:%02d %-8s\n"; 00864 char cmdline[1024] = ""; 00865 00866 if (argc > 8) 00867 ast_cli(fd, "Invalid Arguments.\n"); 00868 /* Check for length so no buffer will overflow... */ 00869 for (i = 0; i < argc; i++) { 00870 if (strlen(argv[i]) > 100) 00871 ast_cli(fd, "Invalid Arguments.\n"); 00872 } 00873 if (argc == 1) { 00874 /* 'MeetMe': List all the conferences */ 00875 now = time(NULL); 00876 AST_LIST_LOCK(&confs); 00877 if (AST_LIST_EMPTY(&confs)) { 00878 ast_cli(fd, "No active MeetMe conferences.\n"); 00879 AST_LIST_UNLOCK(&confs); 00880 return RESULT_SUCCESS; 00881 } 00882 ast_cli(fd, header_format, "Conf Num", "Parties", "Marked", "Activity", "Creation"); 00883 AST_LIST_TRAVERSE(&confs, cnf, list) { 00884 if (cnf->markedusers == 0) 00885 strcpy(cmdline, "N/A "); 00886 else 00887 snprintf(cmdline, sizeof(cmdline), "%4.4d", cnf->markedusers); 00888 hr = (now - cnf->start) / 3600; 00889 min = ((now - cnf->start) % 3600) / 60; 00890 sec = (now - cnf->start) % 60; 00891 00892 ast_cli(fd, data_format, cnf->confno, cnf->users, cmdline, hr, min, sec, cnf->isdynamic ? "Dynamic" : "Static"); 00893 00894 total += cnf->users; 00895 } 00896 AST_LIST_UNLOCK(&confs); 00897 ast_cli(fd, "* Total number of MeetMe users: %d\n", total); 00898 return RESULT_SUCCESS; 00899 } 00900 if (argc < 3) 00901 return RESULT_SHOWUSAGE; 00902 ast_copy_string(cmdline, argv[2], sizeof(cmdline)); /* Argv 2: conference number */ 00903 if (strstr(argv[1], "lock")) { 00904 if (strcmp(argv[1], "lock") == 0) { 00905 /* Lock */ 00906 strncat(cmdline, "|L", sizeof(cmdline) - strlen(cmdline) - 1); 00907 } else { 00908 /* Unlock */ 00909 strncat(cmdline, "|l", sizeof(cmdline) - strlen(cmdline) - 1); 00910 } 00911 } else if (strstr(argv[1], "mute")) { 00912 if (argc < 4) 00913 return RESULT_SHOWUSAGE; 00914 if (strcmp(argv[1], "mute") == 0) { 00915 /* Mute */ 00916 if (strcmp(argv[3], "all") == 0) { 00917 strncat(cmdline, "|N", sizeof(cmdline) - strlen(cmdline) - 1); 00918 } else { 00919 strncat(cmdline, "|M|", sizeof(cmdline) - strlen(cmdline) - 1); 00920 strncat(cmdline, argv[3], sizeof(cmdline) - strlen(cmdline) - 1); 00921 } 00922 } else { 00923 /* Unmute */ 00924 if (strcmp(argv[3], "all") == 0) { 00925 strncat(cmdline, "|n", sizeof(cmdline) - strlen(cmdline) - 1); 00926 } else { 00927 strncat(cmdline, "|m|", sizeof(cmdline) - strlen(cmdline) - 1); 00928 strncat(cmdline, argv[3], sizeof(cmdline) - strlen(cmdline) - 1); 00929 } 00930 } 00931 } else if (strcmp(argv[1], "kick") == 0) { 00932 if (argc < 4) 00933 return RESULT_SHOWUSAGE; 00934 if (strcmp(argv[3], "all") == 0) { 00935 /* Kick all */ 00936 strncat(cmdline, "|K", sizeof(cmdline) - strlen(cmdline) - 1); 00937 } else { 00938 /* Kick a single user */ 00939 strncat(cmdline, "|k|", sizeof(cmdline) - strlen(cmdline) - 1); 00940 strncat(cmdline, argv[3], sizeof(cmdline) - strlen(cmdline) - 1); 00941 } 00942 } else if(strcmp(argv[1], "list") == 0) { 00943 int concise = ( 4 == argc && ( !strcasecmp(argv[3], "concise") ) ); 00944 /* List all the users in a conference */ 00945 if (AST_LIST_EMPTY(&confs)) { 00946 if ( !concise ) 00947 ast_cli(fd, "No active conferences.\n"); 00948 return RESULT_SUCCESS; 00949 } 00950 /* Find the right conference */ 00951 AST_LIST_LOCK(&confs); 00952 AST_LIST_TRAVERSE(&confs, cnf, list) { 00953 if (strcmp(cnf->confno, argv[2]) == 0) 00954 break; 00955 } 00956 if (!cnf) { 00957 if ( !concise ) 00958 ast_cli(fd, "No such conference: %s.\n",argv[2]); 00959 AST_LIST_UNLOCK(&confs); 00960 return RESULT_SUCCESS; 00961 } 00962 /* Show all the users */ 00963 time(&now); 00964 AST_LIST_TRAVERSE(&cnf->userlist, user, list) { 00965 hr = (now - user->jointime) / 3600; 00966 min = ((now - user->jointime) % 3600) / 60; 00967 sec = (now - user->jointime) % 60; 00968 if ( !concise ) 00969 ast_cli(fd, "User #: %-2.2d %12.12s %-20.20s Channel: %s %s %s %s %s %02d:%02d:%02d\n", 00970 user->user_no, 00971 S_OR(user->chan->cid.cid_num, "<unknown>"), 00972 S_OR(user->chan->cid.cid_name, "<no name>"), 00973 user->chan->name, 00974 user->userflags & CONFFLAG_ADMIN ? "(Admin)" : "", 00975 user->userflags & CONFFLAG_MONITOR ? "(Listen only)" : "", 00976 user->adminflags & ADMINFLAG_MUTED ? "(Admin Muted)" : user->adminflags & ADMINFLAG_SELFMUTED ? "(Muted)" : "", 00977 istalking(user->talking), hr, min, sec); 00978 else 00979 ast_cli(fd, "%d!%s!%s!%s!%s!%s!%s!%d!%02d:%02d:%02d\n", 00980 user->user_no, 00981 S_OR(user->chan->cid.cid_num, ""), 00982 S_OR(user->chan->cid.cid_name, ""), 00983 user->chan->name, 00984 user->userflags & CONFFLAG_ADMIN ? "1" : "", 00985 user->userflags & CONFFLAG_MONITOR ? "1" : "", 00986 user->adminflags & (ADMINFLAG_MUTED | ADMINFLAG_SELFMUTED) ? "1" : "", 00987 user->talking, hr, min, sec); 00988 00989 } 00990 if ( !concise ) 00991 ast_cli(fd,"%d users in that conference.\n",cnf->users); 00992 AST_LIST_UNLOCK(&confs); 00993 return RESULT_SUCCESS; 00994 } else 00995 return RESULT_SHOWUSAGE; 00996 ast_log(LOG_DEBUG, "Cmdline: %s\n", cmdline); 00997 admin_exec(NULL, cmdline); 00998 00999 return 0; 01000 }
| static int meetmemute | ( | struct mansession * | s, | |
| const struct message * | m, | |||
| int | mute | |||
| ) | [static] |
Definition at line 3096 of file app_meetme.c.
References ADMINFLAG_MUTED, ADMINFLAG_SELFMUTED, ast_conf_user::adminflags, 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, ast_conf_user::list, LOG_NOTICE, ast_channel::name, ast_channel::uniqueid, ast_conf_user::user_no, and ast_conference::userlist.
Referenced by action_meetmemute(), and action_meetmeunmute().
03097 { 03098 struct ast_conference *conf; 03099 struct ast_conf_user *user; 03100 const char *confid = astman_get_header(m, "Meetme"); 03101 char *userid = ast_strdupa(astman_get_header(m, "Usernum")); 03102 int userno; 03103 03104 if (ast_strlen_zero(confid)) { 03105 astman_send_error(s, m, "Meetme conference not specified"); 03106 return 0; 03107 } 03108 03109 if (ast_strlen_zero(userid)) { 03110 astman_send_error(s, m, "Meetme user number not specified"); 03111 return 0; 03112 } 03113 03114 userno = strtoul(userid, &userid, 10); 03115 03116 if (*userid) { 03117 astman_send_error(s, m, "Invalid user number"); 03118 return 0; 03119 } 03120 03121 /* Look in the conference list */ 03122 AST_LIST_LOCK(&confs); 03123 AST_LIST_TRAVERSE(&confs, conf, list) { 03124 if (!strcmp(confid, conf->confno)) 03125 break; 03126 } 03127 03128 if (!conf) { 03129 AST_LIST_UNLOCK(&confs); 03130 astman_send_error(s, m, "Meetme conference does not exist"); 03131 return 0; 03132 } 03133 03134 AST_LIST_TRAVERSE(&conf->userlist, user, list) 03135 if (user->user_no == userno) 03136 break; 03137 03138 if (!user) { 03139 AST_LIST_UNLOCK(&confs); 03140 astman_send_error(s, m, "User number not found"); 03141 return 0; 03142 } 03143 03144 if (mute) 03145 user->adminflags |= ADMINFLAG_MUTED; /* request user muting */ 03146 else 03147 user->adminflags &= ~(ADMINFLAG_MUTED | ADMINFLAG_SELFMUTED); /* request user unmuting */ 03148 03149 AST_LIST_UNLOCK(&confs); 03150 03151 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); 03152 03153 astman_send_ack(s, m, mute ? "User muted" : "User unmuted"); 03154 return 0; 03155 }
| static int meetmestate | ( | const char * | data | ) | [static] |
Callback for devicestate providers.
Definition at line 3232 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, ast_conference::list, and ast_conference::users.
Referenced by load_module().
03233 { 03234 struct ast_conference *conf; 03235 03236 /* Find conference */ 03237 AST_LIST_LOCK(&confs); 03238 AST_LIST_TRAVERSE(&confs, conf, list) { 03239 if (!strcmp(data, conf->confno)) 03240 break; 03241 } 03242 AST_LIST_UNLOCK(&confs); 03243 if (!conf) 03244 return AST_DEVICE_INVALID; 03245 03246 03247 /* SKREP to fill */ 03248 if (!conf->users) 03249 return AST_DEVICE_NOT_INUSE; 03250 03251 return AST_DEVICE_INUSE; 03252 }
| static struct sla_ringing_trunk* queue_ringing_trunk | ( | struct sla_trunk * | trunk | ) | [static, read] |
Definition at line 4465 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().
04466 { 04467 struct sla_ringing_trunk *ringing_trunk; 04468 04469 if (!(ringing_trunk = ast_calloc(1, sizeof(*ringing_trunk)))) 04470 return NULL; 04471 04472 ringing_trunk->trunk = trunk; 04473 ringing_trunk->ring_begin = ast_tvnow(); 04474 04475 sla_change_trunk_state(trunk, SLA_TRUNK_STATE_RINGING, ALL_TRUNK_REFS, NULL); 04476 04477 ast_mutex_lock(&sla.lock); 04478 AST_LIST_INSERT_HEAD(&sla.ringing_trunks, ringing_trunk, entry); 04479 ast_mutex_unlock(&sla.lock); 04480 04481 sla_queue_event(SLA_EVENT_RINGING_TRUNK); 04482 04483 return ringing_trunk; 04484 }
| static void * recordthread | ( | void * | args | ) | [static] |
Definition at line 3167 of file app_meetme.c.
References ast_closestream(), 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_waitfor(), ast_writefile(), ast_writestream(), f, 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, s, and ast_conference::transframe.
03168 { 03169 struct ast_conference *cnf = args; 03170 struct ast_frame *f=NULL; 03171 int flags; 03172 struct ast_filestream *s=NULL; 03173 int res=0; 03174 int x; 03175 const char *oldrecordingfilename = NULL; 03176 03177 if (!cnf || !cnf->lchan) { 03178 pthread_exit(0); 03179 } 03180 03181 ast_stopstream(cnf->lchan); 03182 flags = O_CREAT|O_TRUNC|O_WRONLY; 03183 03184 03185 cnf->recording = MEETME_RECORD_ACTIVE; 03186 while (ast_waitfor(cnf->lchan, -1) > -1) { 03187 if (cnf->recording == MEETME_RECORD_TERMINATE) { 03188 AST_LIST_LOCK(&confs); 03189 AST_LIST_UNLOCK(&confs); 03190 break; 03191 } 03192 if (!s && cnf->recordingfilename && (cnf->recordingfilename != oldrecordingfilename)) { 03193 s = ast_writefile(cnf->recordingfilename, cnf->recordingformat, NULL, flags, 0, 0644); 03194 oldrecordingfilename = cnf->recordingfilename; 03195 } 03196 03197 f = ast_read(cnf->lchan); 03198 if (!f) { 03199 res = -1; 03200 break; 03201 } 03202 if (f->frametype == AST_FRAME_VOICE) { 03203 ast_mutex_lock(&cnf->listenlock); 03204 for (x=0;x<AST_FRAME_BITS;x++) { 03205 /* Free any translations that have occured */ 03206 if (cnf->transframe[x]) { 03207 ast_frfree(cnf->transframe[x]); 03208 cnf->transframe[x] = NULL; 03209 } 03210 } 03211 if (cnf->origframe) 03212 ast_frfree(cnf->origframe); 03213 cnf->origframe = ast_frdup(f); 03214 ast_mutex_unlock(&cnf->listenlock); 03215 if (s) 03216 res = ast_writestream(s, f); 03217 if (res) { 03218 ast_frfree(f); 03219 break; 03220 } 03221 } 03222 ast_frfree(f); 03223 } 03224 cnf->recording = MEETME_RECORD_OFF; 03225 if (s) 03226 ast_closestream(s); 03227 03228 pthread_exit(0); 03229 }
| static int reload | ( | void | ) | [static] |
Definition at line 5035 of file app_meetme.c.
References load_config().
05036 { 05037 return load_config(1); 05038 }
| static void reset_volumes | ( | struct ast_conf_user * | user | ) | [static] |
Definition at line 710 of file app_meetme.c.
References ast_channel_setoption(), AST_OPTION_RXGAIN, AST_OPTION_TXGAIN, and ast_conf_user::chan.
Referenced by admin_exec(), and conf_run().
00711 { 00712 signed char zero_volume = 0; 00713 00714 ast_channel_setoption(user->chan, AST_OPTION_TXGAIN, &zero_volume, sizeof(zero_volume), 0); 00715 ast_channel_setoption(user->chan, AST_OPTION_RXGAIN, &zero_volume, sizeof(zero_volume), 0); 00716 }
| static void* run_station | ( | void * | data | ) | [static] |
Definition at line 3419 of file app_meetme.c.
References sla_trunk::active_stations, admin_exec(), ALL_TRUNK_REFS, answer_trunk_chan(), ast_atomic_dec_and_test(), ast_atomic_fetchadd_int(), ast_cond_signal(), ast_dial_destroy(), ast_dial_join(), ast_mutex_lock(), ast_mutex_unlock(), ast_set_flag, build_conf(), sla_trunk_ref::chan, run_station_args::cond, run_station_args::cond_lock, conf_run(), CONFFLAG_MARKEDEXIT, CONFFLAG_PASS_DTMF, CONFFLAG_QUIET, CONFFLAG_SLA_STATION, sla_station::dial, dispose_conf(), ast_flags::flags, sla_trunk::hold_stations, MAX_CONFNUM, sla_trunk::name, sla_change_trunk_state(), SLA_TRUNK_STATE_IDLE, SLA_TRUNK_STATE_ONHOLD_BYME, sla_trunk_ref::state, run_station_args::station, sla_trunk_ref::trunk, and run_station_args::trunk_ref.
Referenced by sla_handle_dial_state_event().
03420 { 03421 struct sla_station *station; 03422 struct sla_trunk_ref *trunk_ref; 03423 char conf_name[MAX_CONFNUM]; 03424 struct ast_flags conf_flags = { 0 }; 03425 struct ast_conference *conf; 03426 03427 { 03428 struct run_station_args *args = data; 03429 station = args->station; 03430 trunk_ref = args->trunk_ref; 03431 ast_mutex_lock(args->cond_lock); 03432 ast_cond_signal(args->cond); 03433 ast_mutex_unlock(args->cond_lock); 03434 /* args is no longer valid here. */ 03435 } 03436 03437 ast_atomic_fetchadd_int((int *) &trunk_ref->trunk->active_stations, 1); 03438 snprintf(conf_name, sizeof(conf_name), "SLA_%s", trunk_ref->trunk->name); 03439 ast_set_flag(&conf_flags, 03440 CONFFLAG_QUIET | CONFFLAG_MARKEDEXIT | CONFFLAG_PASS_DTMF | CONFFLAG_SLA_STATION); 03441 answer_trunk_chan(trunk_ref->chan); 03442 conf = build_conf(conf_name, "", "", 0, 0, 1); 03443 if (conf) { 03444 conf_run(trunk_ref->chan, conf, conf_flags.flags, NULL); 03445 dispose_conf(conf); 03446 conf = NULL; 03447 } 03448 trunk_ref->chan = NULL; 03449 if (ast_atomic_dec_and_test((int *) &trunk_ref->trunk->active_stations) && 03450 trunk_ref->state != SLA_TRUNK_STATE_ONHOLD_BYME) { 03451 strncat(conf_name, "|K", sizeof(conf_name) - strlen(conf_name) - 1); 03452 admin_exec(NULL, conf_name); 03453 trunk_ref->trunk->hold_stations = 0; 03454 sla_change_trunk_state(trunk_ref->trunk, SLA_TRUNK_STATE_IDLE, ALL_TRUNK_REFS, NULL); 03455 } 03456 03457 ast_dial_join(station->dial); 03458 ast_dial_destroy(station->dial); 03459 station->dial = NULL; 03460 03461 return NULL; 03462 }
| static int set_listen_volume | ( | struct ast_conf_user * | user, | |
| int | volume | |||
| ) | [static] |
Definition at line 639 of file app_meetme.c.
References ast_channel_setoption(), AST_OPTION_TXGAIN, and ast_conf_user::chan.
Referenced by tweak_listen_volume().
00640 { 00641 char gain_adjust; 00642 00643 /* attempt to make the adjustment in the channel driver; 00644 if successful, don't adjust in the frame reading routine 00645 */ 00646 gain_adjust = gain_map[volume + 5]; 00647 00648 return ast_channel_setoption(user->chan, AST_OPTION_TXGAIN, &gain_adjust, sizeof(gain_adjust), 0); 00649 }
| static int set_talk_volume | ( | struct ast_conf_user * | user, | |
| int | volume | |||
| ) | [static] |
Definition at line 627 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().
00628 { 00629 char gain_adjust; 00630 00631 /* attempt to make the adjustment in the channel driver; 00632 if successful, don't adjust in the frame reading routine 00633 */ 00634 gain_adjust = gain_map[volume + 5]; 00635 00636 return ast_channel_setoption(user->chan, AST_OPTION_RXGAIN, &gain_adjust, sizeof(gain_adjust), 0); 00637 }
| static void sla_add_trunk_to_station | ( | struct sla_station * | station, | |
| struct ast_variable * | var | |||
| ) | [static] |
Definition at line 4768 of file app_meetme.c.
References ast_atomic_fetchadd_int(), AST_LIST_INSERT_TAIL, ast_log(), AST_RWLIST_RDLOCK, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, ast_strdupa, create_trunk_ref(), free, LOG_ERROR, LOG_WARNING, sla_station::name, sla_trunk::name, sla_trunk::num_stations, sla_trunk_ref::ring_delay, sla_trunk_ref::ring_timeout, sla_create_station_ref(), SLA_TRUNK_STATE_IDLE, sla_trunk_ref::state, sla_trunk::stations, sla_station::trunks, and ast_variable::value.
Referenced by sla_build_station().
04769 { 04770 struct sla_trunk *trunk; 04771 struct sla_trunk_ref *trunk_ref; 04772 struct sla_station_ref *station_ref; 04773 char *trunk_name, *options, *cur; 04774 04775 options = ast_strdupa(var->value); 04776 trunk_name = strsep(&options, ","); 04777 04778 AST_RWLIST_RDLOCK(&sla_trunks); 04779 AST_RWLIST_TRAVERSE(&sla_trunks, trunk, entry) { 04780 if (!strcasecmp(trunk->name, trunk_name)) 04781 break; 04782 } 04783 04784 AST_RWLIST_UNLOCK(&sla_trunks); 04785 if (!trunk) { 04786 ast_log(LOG_ERROR, "Trunk '%s' not found!\n", var->value); 04787 return; 04788 } 04789 if (!(trunk_ref = create_trunk_ref(trunk))) 04790 return; 04791 trunk_ref->state = SLA_TRUNK_STATE_IDLE; 04792 04793 while ((cur = strsep(&options, ","))) { 04794 char *name, *value = cur; 04795 name = strsep(&value, "="); 04796 if (!strcasecmp(name, "ringtimeout")) { 04797 if (sscanf(value, "%u", &trunk_ref->ring_timeout) != 1) { 04798 ast_log(LOG_WARNING, "Invalid ringtimeout value '%s' for " 04799 "trunk '%s' on station '%s'\n", value, trunk->name, station->name); 04800 trunk_ref->ring_timeout = 0; 04801 } 04802 } else if (!strcasecmp(name, "ringdelay")) { 04803 if (sscanf(value, "%u", &trunk_ref->ring_delay) != 1) { 04804 ast_log(LOG_WARNING, "Invalid ringdelay value '%s' for " 04805 "trunk '%s' on station '%s'\n", value, trunk->name, station->name); 04806 trunk_ref->ring_delay = 0; 04807 } 04808 } else { 04809 ast_log(LOG_WARNING, "Invalid option '%s' for " 04810 "trunk '%s' on station '%s'\n", name, trunk->name, station->name); 04811 } 04812 } 04813 04814 if (!(station_ref = sla_create_station_ref(station))) { 04815 free(trunk_ref); 04816 return; 04817 } 04818 ast_atomic_fetchadd_int((int *) &trunk->num_stations, 1); 04819 AST_RWLIST_WRLOCK(&sla_trunks); 04820 AST_LIST_INSERT_TAIL(&trunk->stations, station_ref, entry); 04821 AST_RWLIST_UNLOCK(&sla_trunks); 04822 AST_LIST_INSERT_TAIL(&station->trunks, trunk_ref, entry); 04823 }
| static int sla_build_station | ( | struct ast_config * | cfg, | |
| const char * | cat | |||
| ) | [static] |
Definition at line 4825 of file app_meetme.c.
References ast_add_extension2(), ast_calloc, ast_context_find_or_create(), ast_free, 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_init, ast_string_field_set, ast_strlen_zero(), ast_variable_browse(), ast_variable_retrieve(), sla_station::autocontext, context, destroy_station(), exten, free, sla_station::hold_access, ast_variable::lineno, LOG_ERROR, LOG_WARNING, sla_trunk::name, sla_station::name, ast_variable::name, ast_variable::next, PRIORITY_HINT, sla_station::ring_delay, sla_station::ring_timeout, sla_add_trunk_to_station(), SLA_CONFIG_FILE, SLA_HOLD_OPEN, SLA_HOLD_PRIVATE, sla_registrar, sla_trunk_ref::trunk, sla_station::trunks, ast_variable::value, and var.
Referenced by sla_load_config().
04826 { 04827 struct sla_station *station; 04828 struct ast_variable *var; 04829 const char *dev; 04830 04831 if (!(dev = ast_variable_retrieve(cfg, cat, "device"))) { 04832 ast_log(LOG_ERROR, "SLA Station '%s' defined with no device!\n", cat); 04833 return -1; 04834 } 04835 04836 if (!(station = ast_calloc(1, sizeof(*station)))) 04837 return -1; 04838 if (ast_string_field_init(station, 32)) { 04839 free(station); 04840 return -1; 04841 } 04842 04843 ast_string_field_set(station, name, cat); 04844 ast_string_field_set(station, device, dev); 04845 04846 for (var = ast_variable_browse(cfg, cat); var; var = var->next) { 04847 if (!strcasecmp(var->name, "trunk")) 04848 sla_add_trunk_to_station(station, var); 04849 else if (!strcasecmp(var->name, "autocontext")) 04850 ast_string_field_set(station, autocontext, var->value); 04851 else if (!strcasecmp(var->name, "ringtimeout")) { 04852 if (sscanf(var->value, "%u", &station->ring_timeout) != 1) { 04853 ast_log(LOG_WARNING, "Invalid ringtimeout '%s' specified for station '%s'\n", 04854 var->value, station->name); 04855 station->ring_timeout = 0; 04856 } 04857 } else if (!strcasecmp(var->name, "ringdelay")) { 04858 if (sscanf(var->value, "%u", &station->ring_delay) != 1) { 04859 ast_log(LOG_WARNING, "Invalid ringdelay '%s' specified for station '%s'\n", 04860 var->value, station->name); 04861 station->ring_delay = 0; 04862 } 04863 } else if (!strcasecmp(var->name, "hold")) { 04864 if (!strcasecmp(var->value, "private")) 04865 station->hold_access = SLA_HOLD_PRIVATE; 04866 else if (!strcasecmp(var->value, "open")) 04867 station->hold_access = SLA_HOLD_OPEN; 04868 else { 04869 ast_log(LOG_WARNING, "Invalid value '%s' for hold on station %s\n", 04870 var->value, station->name); 04871 } 04872 04873 } else if (strcasecmp(var->name, "type") && strcasecmp(var->name, "device")) { 04874 ast_log(LOG_ERROR, "Invalid option '%s' specified at line %d of %s!\n", 04875 var->name, var->lineno, SLA_CONFIG_FILE); 04876 } 04877 } 04878 04879 if (!ast_strlen_zero(station->autocontext)) { 04880 struct ast_context *context; 04881 struct sla_trunk_ref *trunk_ref; 04882 context = ast_context_find_or_create(NULL, station->autocontext, sla_registrar); 04883 if (!context) { 04884 ast_log(LOG_ERROR, "Failed to automatically find or create " 04885 "context '%s' for SLA!\n", station->autocontext); 04886 destroy_station(station); 04887 return -1; 04888 } 04889 /* The extension for when the handset goes off-hook. 04890 * exten => station1,1,SLAStation(station1) */ 04891 if (ast_add_extension2(context, 0 /* don't replace */, station->name, 1, 04892 NULL, NULL, slastation_app, ast_strdup(station->name), ast_free, sla_registrar)) { 04893 ast_log(LOG_ERROR, "Failed to automatically create extension " 04894 "for trunk '%s'!\n", station->name); 04895 destroy_station(station); 04896 return -1; 04897 } 04898 AST_RWLIST_RDLOCK(&sla_trunks); 04899 AST_LIST_TRAVERSE(&station->trunks, trunk_ref, entry) { 04900 char exten[AST_MAX_EXTENSION]; 04901 char hint[AST_MAX_APP]; 04902 snprintf(exten, sizeof(exten), "%s_%s", station->name, trunk_ref->trunk->name); 04903 snprintf(hint, sizeof(hint), "SLA:%s", exten); 04904 /* Extension for this line button 04905 * exten => station1_line1,1,SLAStation(station1_line1) */ 04906 if (ast_add_extension2(context, 0 /* don't replace */, exten, 1, 04907 NULL, NULL, slastation_app, ast_strdup(exten), ast_free, sla_registrar)) { 04908 ast_log(LOG_ERROR, "Failed to automatically create extension " 04909 "for trunk '%s'!\n", station->name); 04910 destroy_station(station); 04911 return -1; 04912 } 04913 /* Hint for this line button 04914 * exten => station1_line1,hint,SLA:station1_line1 */ 04915 if (ast_add_extension2(context, 0 /* don't replace */, exten, PRIORITY_HINT, 04916 NULL, NULL, hint, NULL, NULL, sla_registrar)) { 04917 ast_log(LOG_ERROR, "Failed to automatically create hint " 04918 "for trunk '%s'!\n", station->name); 04919 destroy_station(station); 04920 return -1; 04921 } 04922 } 04923 AST_RWLIST_UNLOCK(&sla_trunks); 04924 } 04925 04926 AST_RWLIST_WRLOCK(&sla_stations); 04927 AST_RWLIST_INSERT_TAIL(&sla_stations, station, entry); 04928 AST_RWLIST_UNLOCK(&sla_stations); 04929 04930 return 0; 04931 }
| static int sla_build_trunk | ( | struct ast_config * | cfg, | |
| const char * | cat | |||
| ) | [static] |
Definition at line 4690 of file app_meetme.c.
References ast_add_extension2(), ast_calloc, ast_context_find_or_create(), ast_false(), ast_free, ast_log(), AST_RWLIST_INSERT_TAIL, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, ast_strdup, ast_string_field_init, ast_string_field_set, ast_strlen_zero(), ast_variable_browse(), ast_variable_retrieve(), sla_trunk::autocontext, sla_trunk::barge_disabled, context, destroy_trunk(), free, sla_trunk::hold_access, ast_variable::lineno, LOG_ERROR, LOG_WARNING, sla_trunk::name, ast_variable::name, ast_variable::next, sla_trunk::ring_timeout, sla_check_device(), SLA_CONFIG_FILE, SLA_HOLD_OPEN, SLA_HOLD_PRIVATE, sla_registrar, ast_variable::value, and var.
Referenced by sla_load_config().
04691 { 04692 struct sla_trunk *trunk; 04693 struct ast_variable *var; 04694 const char *dev; 04695 04696 if (!(dev = ast_variable_retrieve(cfg, cat, "device"))) { 04697 ast_log(LOG_ERROR, "SLA Trunk '%s' defined with no device!\n", cat); 04698 return -1; 04699 } 04700 04701 if (sla_check_device(dev)) { 04702 ast_log(LOG_ERROR, "SLA Trunk '%s' define with invalid device '%s'!\n", 04703 cat, dev); 04704 return -1; 04705 } 04706 04707 if (!(trunk = ast_calloc(1, sizeof(*trunk)))) 04708 return -1; 04709 if (ast_string_field_init(trunk, 32)) { 04710 free(trunk); 04711 return -1; 04712 } 04713 04714 ast_string_field_set(trunk, name, cat); 04715 ast_string_field_set(trunk, device, dev); 04716 04717 for (var = ast_variable_browse(cfg, cat); var; var = var->next) { 04718 if (!strcasecmp(var->name, "autocontext")) 04719 ast_string_field_set(trunk, autocontext, var->value); 04720 else if (!strcasecmp(var->name, "ringtimeout")) { 04721 if (sscanf(var->value, "%u", &trunk->ring_timeout) != 1) { 04722 ast_log(LOG_WARNING, "Invalid ringtimeout '%s' specified for trunk '%s'\n", 04723 var->value, trunk->name); 04724 trunk->ring_timeout = 0; 04725 } 04726 } else if (!strcasecmp(var->name, "barge")) 04727 trunk->barge_disabled = ast_false(var->value); 04728 else if (!strcasecmp(var->name, "hold")) { 04729 if (!strcasecmp(var->value, "private")) 04730 trunk->hold_access = SLA_HOLD_PRIVATE; 04731 else if (!strcasecmp(var->value, "open")) 04732 trunk->hold_access = SLA_HOLD_OPEN; 04733 else { 04734 ast_log(LOG_WARNING, "Invalid value '%s' for hold on trunk %s\n", 04735 var->value, trunk->name); 04736 } 04737 } else if (strcasecmp(var->name, "type") && strcasecmp(var->name, "device")) { 04738 ast_log(LOG_ERROR, "Invalid option '%s' specified at line %d of %s!\n", 04739 var->name, var->lineno, SLA_CONFIG_FILE); 04740 } 04741 } 04742 04743 if (!ast_strlen_zero(trunk->autocontext)) { 04744 struct ast_context *context; 04745 context = ast_context_find_or_create(NULL, trunk->autocontext, sla_registrar); 04746 if (!context) { 04747 ast_log(LOG_ERROR, "Failed to automatically find or create " 04748 "context '%s' for SLA!\n", trunk->autocontext); 04749 destroy_trunk(trunk); 04750 return -1; 04751 } 04752 if (ast_add_extension2(context, 0 /* don't replace */, "s", 1, 04753 NULL, NULL, slatrunk_app, ast_strdup(trunk->name), ast_free, sla_registrar)) { 04754 ast_log(LOG_ERROR, "Failed to automatically create extension " 04755 "for trunk '%s'!\n", trunk->name); 04756 destroy_trunk(trunk); 04757 return -1; 04758 } 04759 } 04760 04761 AST_RWLIST_WRLOCK(&sla_trunks); 04762 AST_RWLIST_INSERT_TAIL(&sla_trunks, trunk, entry); 04763 AST_RWLIST_UNLOCK(&sla_trunks); 04764 04765 return 0; 04766 }
| static int sla_calc_station_delays | ( | unsigned int * | timeout | ) | [static] |
Calculate the ring delay for a station.
Definition at line 4036 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().
04037 { 04038 struct sla_station *station; 04039 int res = 0; 04040 04041 AST_LIST_TRAVERSE(&sla_stations, station, entry) { 04042 struct sla_ringing_trunk *ringing_trunk; 04043 int time_left; 04044 04045 /* Ignore stations already ringing */ 04046 if (sla_check_ringing_station(station)) 04047 continue; 04048 04049 /* Ignore stations already on a call */ 04050 if (sla_check_inuse_station(station)) 04051 continue; 04052 04053 /* Ignore stations that don't have one of their trunks ringing */ 04054 if (!(ringing_trunk = sla_choose_ringing_trunk(station, NULL, 0))) 04055 continue; 04056 04057 if ((time_left = sla_check_station_delay(station, ringing_trunk)) == INT_MAX) 04058 continue; 04059 04060 /* If there is no time left, then the station needs to start ringing. 04061 * Return non-zero so that an event will be queued up an event to 04062 * make that happen. */ 04063 if (time_left <= 0) { 04064 res = 1; 04065 continue; 04066 } 04067 04068 if (time_left < *timeout) 04069 *timeout = time_left; 04070 } 04071 04072 return res; 04073 }
| static int sla_calc_station_timeouts | ( | unsigned int * | timeout | ) | [static] |
Process station ring timeouts.
Definition at line 3953 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_station::ring_timeout, sla_trunk_ref::ring_timeout, sla, SLA_STATION_HANGUP_TIMEOUT, sla_stop_ringing_station(), sla_station_ref::station, sla_ringing_station::station, sla_ringing_trunk::timed_out_stations, sla_trunk_ref::trunk, sla_ringing_trunk::trunk, and sla_station::trunks.
Referenced by sla_process_timers().
03954 { 03955 struct sla_ringing_trunk *ringing_trunk; 03956 struct sla_ringing_station *ringing_station; 03957 int res = 0; 03958 03959 AST_LIST_TRAVERSE_SAFE_BEGIN(&sla.ringing_stations, ringing_station, entry) { 03960 unsigned int ring_timeout = 0; 03961 int time_elapsed, time_left = INT_MAX, final_trunk_time_left = INT_MIN; 03962 struct sla_trunk_ref *trunk_ref; 03963 03964 /* If there are any ring timeouts specified for a specific trunk 03965 * on the station, then use the highest per-trunk ring timeout. 03966 * Otherwise, use the ring timeout set for the entire station. */ 03967 AST_LIST_TRAVERSE(&ringing_station->station->trunks, trunk_ref, entry) { 03968 struct sla_station_ref *station_ref; 03969 int trunk_time_elapsed, trunk_time_left; 03970 03971 AST_LIST_TRAVERSE(&sla.ringing_trunks, ringing_trunk, entry) { 03972 if (ringing_trunk->trunk == trunk_ref->trunk) 03973 break; 03974 } 03975 if (!ringing_trunk) 03976 continue; 03977 03978 /* If there is a trunk that is ringing without a timeout, then the 03979 * only timeout that could matter is a global station ring timeout. */ 03980 if (!trunk_ref->ring_timeout) 03981 break; 03982 03983 /* This trunk on this station is ringing and has a timeout. 03984 * However, make sure this trunk isn't still ringing from a 03985 * previous timeout. If so, don't consider it. */ 03986 AST_LIST_TRAVERSE(&ringing_trunk->timed_out_stations, station_ref, entry) { 03987 if (station_ref->station == ringing_station->station) 03988 break; 03989 } 03990 if (station_ref) 03991 continue; 03992 03993 trunk_time_elapsed = ast_tvdiff_ms(ast_tvnow(), ringing_trunk->ring_begin); 03994 trunk_time_left = (trunk_ref->ring_timeout * 1000) - trunk_time_elapsed; 03995 if (trunk_time_left > final_trunk_time_left) 03996 final_trunk_time_left = trunk_time_left; 03997 } 03998 03999 /* No timeout was found for ringing trunks, and no timeout for the entire station */ 04000 if (final_trunk_time_left == INT_MIN && !ringing_station->station->ring_timeout) 04001 continue; 04002 04003 /* Compute how much time is left for a global station timeout */ 04004 if (ringing_station->station->ring_timeout) { 04005 ring_timeout = ringing_station->station->ring_timeout; 04006 time_elapsed = ast_tvdiff_ms(ast_tvnow(), ringing_station->ring_begin); 04007 time_left = (ring_timeout * 1000) - time_elapsed; 04008 } 04009 04010 /* If the time left based on the per-trunk timeouts is smaller than the 04011 * global station ring timeout, use that. */ 04012 if (final_trunk_time_left > INT_MIN && final_trunk_time_left < time_left) 04013 time_left = final_trunk_time_left; 04014 04015 /* If there is no time left, the station needs to stop ringing */ 04016 if (time_left <= 0) { 04017 AST_LIST_REMOVE_CURRENT(&sla.ringing_stations, entry); 04018 sla_stop_ringing_station(ringing_station, SLA_STATION_HANGUP_TIMEOUT); 04019 res = 1; 04020 continue; 04021 } 04022 04023 /* There is still some time left for this station to ring, so save that 04024 * timeout if it is the first event scheduled to occur */ 04025 if (time_left < *timeout) 04026 *timeout = time_left; 04027 } 04028 AST_LIST_TRAVERSE_SAFE_END 04029 04030 return res; 04031 }
| static int sla_calc_trunk_timeouts | ( | unsigned int * | timeout | ) | [static] |
Process trunk ring timeouts.
Definition at line 3923 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(), sla_trunk::chan, pbx_builtin_setvar_helper(), sla_ringing_trunk::ring_begin, sla_trunk::ring_timeout, sla, sla_stop_ringing_trunk(), and sla_ringing_trunk::trunk.
Referenced by sla_process_timers().
03924 { 03925 struct sla_ringing_trunk *ringing_trunk; 03926 int res = 0; 03927 03928 AST_LIST_TRAVERSE_SAFE_BEGIN(&sla.ringing_trunks, ringing_trunk, entry) { 03929 int time_left, time_elapsed; 03930 if (!ringing_trunk->trunk->ring_timeout) 03931 continue; 03932 time_elapsed = ast_tvdiff_ms(ast_tvnow(), ringing_trunk->ring_begin); 03933 time_left = (ringing_trunk->trunk->ring_timeout * 1000) - time_elapsed; 03934 if (time_left <= 0) { 03935 pbx_builtin_setvar_helper(ringing_trunk->trunk->chan, "SLATRUNK_STATUS", "RINGTIMEOUT"); 03936 AST_LIST_REMOVE_CURRENT(&sla.ringing_trunks, entry); 03937 sla_stop_ringing_trunk(ringing_trunk); 03938 res = 1; 03939 continue; 03940 } 03941 if (time_left < *timeout) 03942 *timeout = time_left; 03943 } 03944 AST_LIST_TRAVERSE_SAFE_END 03945 03946 return res; 03947 }
| 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 3388 of file app_meetme.c.
References ast_device_state_changed(), AST_LIST_TRAVERSE, sla_trunk_ref::chan, sla_trunk::name, sla_station::name, sla_trunk_ref::state, sla_trunk_ref::trunk, and sla_station::trunks.
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().
03390 { 03391 struct sla_station *station; 03392 struct sla_trunk_ref *trunk_ref; 03393 03394 AST_LIST_TRAVERSE(&sla_stations, station, entry) { 03395 AST_LIST_TRAVERSE(&station->trunks, trunk_ref, entry) { 03396 if (trunk_ref->trunk != trunk || (inactive_only ? trunk_ref->chan : 0) 03397 || trunk_ref == exclude) 03398 continue; 03399 trunk_ref->state = state; 03400 ast_device_state_changed("SLA:%s_%s", station->name, trunk->name); 03401 break; 03402 } 03403 } 03404 }
| static int sla_check_device | ( | const char * | device | ) | [static] |
Definition at line 4677 of file app_meetme.c.
References ast_strdupa, and ast_strlen_zero().
Referenced by sla_build_trunk().
04678 { 04679 char *tech, *tech_data; 04680 04681 tech_data = ast_strdupa(device); 04682 tech = strsep(&tech_data, "/"); 04683 04684 if (ast_strlen_zero(tech) || ast_strlen_zero(tech_data)) 04685 return -1; 04686 04687 return 0; 04688 }
| 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 3671 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(), free, sla_failed_station::last_try, sla, and sla_failed_station::station.
Referenced by sla_ring_stations().
03672 { 03673 struct sla_failed_station *failed_station; 03674 int res = 0; 03675 03676 AST_LIST_TRAVERSE_SAFE_BEGIN(&sla.failed_stations, failed_station, entry) { 03677 if (station != failed_station->station) 03678 continue; 03679 if (ast_tvdiff_ms(ast_tvnow(), failed_station->last_try) > 1000) { 03680 AST_LIST_REMOVE_CURRENT(&sla.failed_stations, entry); 03681 free(failed_station); 03682 break; 03683 } 03684 res = 1; 03685 } 03686 AST_LIST_TRAVERSE_SAFE_END 03687 03688 return res; 03689 }
| static int sla_check_inuse_station | ( | const struct sla_station * | station | ) | [static] |
Check to see if a station is in use.
Definition at line 3757 of file app_meetme.c.
References AST_LIST_TRAVERSE, sla_trunk_ref::chan, and sla_station::trunks.
Referenced by sla_calc_station_delays(), and sla_ring_stations().
03758 { 03759 struct sla_trunk_ref *trunk_ref; 03760 03761 AST_LIST_TRAVERSE(&station->trunks, trunk_ref, entry) { 03762 if (trunk_ref->chan) 03763 return 1; 03764 } 03765 03766 return 0; 03767 }
| static int sla_check_ringing_station | ( | const struct sla_station * | station | ) | [static] |
Check to see if this station is already ringing.
Definition at line 3656 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().
03657 { 03658 struct sla_ringing_station *ringing_station; 03659 03660 AST_LIST_TRAVERSE(&sla.ringing_stations, ringing_station, entry) { 03661 if (station == ringing_station->station) 03662 return 1; 03663 } 03664 03665 return 0; 03666 }
| 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 | |
| trunk | the trunk. If NULL, the highest priority ringing trunk will be used |
Definition at line 3787 of file app_meetme.c.
References ast_tvdiff_ms(), ast_tvnow(), sla_ringing_trunk::ring_begin, sla_station::ring_delay, sla_trunk_ref::ring_delay, sla_choose_ringing_trunk(), sla_find_trunk_ref(), and sla_ringing_trunk::trunk.
Referenced by sla_calc_station_delays(), and sla_ring_stations().
03789 { 03790 struct sla_trunk_ref *trunk_ref; 03791 unsigned int delay = UINT_MAX; 03792 int time_left, time_elapsed; 03793 03794 if (!ringing_trunk) 03795 ringing_trunk = sla_choose_ringing_trunk(station, &trunk_ref, 0); 03796 else 03797 trunk_ref = sla_find_trunk_ref(station, ringing_trunk->trunk); 03798 03799 if (!ringing_trunk || !trunk_ref) 03800 return delay; 03801 03802 /* If this station has a ring delay specific to the highest priority 03803 * ringing trunk, use that. Otherwise, use the ring delay specified 03804 * globally for the station. */ 03805 delay = trunk_ref->ring_delay; 03806 if (!delay) 03807 delay = station->ring_delay; 03808 if (!delay) 03809 return INT_MAX; 03810 03811 time_elapsed = ast_tvdiff_ms(ast_tvnow(), ringing_trunk->ring_begin); 03812 time_left = (delay * 1000) - time_elapsed; 03813 03814 return time_left; 03815 }
| static int sla_check_station_hold_access | ( | const struct sla_trunk * | trunk, | |
| const struct sla_station * | station | |||
| ) | [static] |
Definition at line 3310 of file app_meetme.c.
References AST_LIST_TRAVERSE, sla_station::hold_access, SLA_HOLD_PRIVATE, SLA_TRUNK_STATE_ONHOLD_BYME, sla_trunk_ref::state, sla_station_ref::station, sla_trunk::stations, sla_trunk_ref::trunk, and sla_station::trunks.
Referenced by sla_find_trunk_ref_byname().
03312 { 03313 struct sla_station_ref *station_ref; 03314 struct sla_trunk_ref *trunk_ref; 03315 03316 /* For each station that has this call on hold, check for private hold. */ 03317 AST_LIST_TRAVERSE(&trunk->stations, station_ref, entry) { 03318 AST_LIST_TRAVERSE(&station_ref->station->trunks, trunk_ref, entry) { 03319 if (trunk_ref->trunk != trunk || station_ref->station == station) 03320 continue; 03321 if (trunk_ref->state == SLA_TRUNK_STATE_ONHOLD_BYME && 03322 station_ref->station->hold_access == SLA_HOLD_PRIVATE) 03323 return 1; 03324 return 0; 03325 } 03326 } 03327 03328 return 0; 03329 }
| 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 3522 of file app_meetme.c.
References AST_LIST_TRAVERSE, sla_station_ref::station, and sla_ringing_trunk::timed_out_stations.
Referenced by sla_choose_ringing_trunk(), and sla_ring_stations().
03524 { 03525 struct sla_station_ref *timed_out_station; 03526 03527 AST_LIST_TRAVERSE(&ringing_trunk->timed_out_stations, timed_out_station, entry) { 03528 if (station == timed_out_station->station) 03529 return 1; 03530 } 03531 03532 return 0; 03533 }
| 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 4287 of file app_meetme.c.
References AST_LIST_TRAVERSE, SLA_TRUNK_STATE_IDLE, sla_trunk_ref::state, and sla_station::trunks.
Referenced by sla_station_exec().
04288 { 04289 struct sla_trunk_ref *trunk_ref = NULL; 04290 04291 AST_LIST_TRAVERSE(&station->trunks, trunk_ref, entry) { 04292 if (trunk_ref->state == SLA_TRUNK_STATE_IDLE) 04293 break; 04294 } 04295 04296 return trunk_ref; 04297 }
| static struct sla_ringing_trunk* sla_choose_ringing_trunk | ( | struct sla_station * | station, | |
| struct sla_trunk_ref ** | trunk_ref, | |||
| int | remove | |||
| ) | [static, read] |
Choose the highest priority ringing trunk for a station.
| station | the station | |
| remove | 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 3543 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(), sla_ringing_trunk::trunk, sla_trunk_ref::trunk, and sla_station::trunks.
Referenced by sla_calc_station_delays(), sla_check_station_delay(), and sla_handle_dial_state_event().
03545 { 03546 struct sla_trunk_ref *s_trunk_ref; 03547 struct sla_ringing_trunk *ringing_trunk = NULL; 03548 03549 AST_LIST_TRAVERSE(&station->trunks, s_trunk_ref, entry) { 03550 AST_LIST_TRAVERSE_SAFE_BEGIN(&sla.ringing_trunks, ringing_trunk, entry) { 03551 /* Make sure this is the trunk we're looking for */ 03552 if (s_trunk_ref->trunk != ringing_trunk->trunk) 03553 continue; 03554 03555 /* This trunk on the station is ringing. But, make sure this station 03556 * didn't already time out while this trunk was ringing. */ 03557 if (sla_check_timed_out_station(ringing_trunk, station)) 03558 continue; 03559 03560 if (remove) 03561 AST_LIST_REMOVE_CURRENT(&sla.ringing_trunks, entry); 03562 03563 if (trunk_ref) 03564 *trunk_ref = s_trunk_ref; 03565 03566 break; 03567 } 03568 AST_LIST_TRAVERSE_SAFE_END 03569 03570 if (ringing_trunk) 03571 break; 03572 } 03573 03574 return ringing_trunk; 03575 }
| static struct sla_ringing_station* sla_create_ringing_station | ( | struct sla_station * | station | ) | [static, read] |
Definition at line 3375 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().
03376 { 03377 struct sla_ringing_station *ringing_station; 03378 03379 if (!(ringing_station = ast_calloc(1, sizeof(*ringing_station)))) 03380 return NULL; 03381 03382 ringing_station->station = station; 03383 ringing_station->ring_begin = ast_tvnow(); 03384 03385 return ringing_station; 03386 }
| static struct sla_station_ref* sla_create_station_ref | ( | struct sla_station * | station | ) | [static, read] |
Definition at line 3363 of file app_meetme.c.
References ast_calloc, and sla_station_ref::station.
Referenced by sla_add_trunk_to_station(), and sla_stop_ringing_station().
03364 { 03365 struct sla_station_ref *station_ref; 03366 03367 if (!(station_ref = ast_calloc(1, sizeof(*station_ref)))) 03368 return NULL; 03369 03370 station_ref->station = station; 03371 03372 return station_ref; 03373 }
| static void sla_destroy | ( | void | ) | [static] |
Definition at line 4647 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().
04648 { 04649 struct sla_trunk *trunk; 04650 struct sla_station *station; 04651 04652 AST_RWLIST_WRLOCK(&sla_trunks); 04653 while ((trunk = AST_RWLIST_REMOVE_HEAD(&sla_trunks, entry))) 04654 destroy_trunk(trunk); 04655 AST_RWLIST_UNLOCK(&sla_trunks); 04656 04657 AST_RWLIST_WRLOCK(&sla_stations); 04658 while ((station = AST_RWLIST_REMOVE_HEAD(&sla_stations, entry))) 04659 destroy_station(station); 04660 AST_RWLIST_UNLOCK(&sla_stations); 04661 04662 if (sla.thread != AST_PTHREADT_NULL) { 04663 ast_mutex_lock(&sla.lock); 04664 sla.stop = 1; 04665 ast_cond_signal(&sla.cond); 04666 ast_mutex_unlock(&sla.lock); 04667 pthread_join(sla.thread, NULL); 04668 } 04669 04670 /* Drop any created contexts from the dialplan */ 04671 ast_context_destroy(NULL, sla_registrar); 04672 04673 ast_mutex_destroy(&sla.lock); 04674 ast_cond_destroy(&sla.cond); 04675 }
| static void sla_dial_state_callback | ( | struct ast_dial * | dial | ) | [static] |
Definition at line 3514 of file app_meetme.c.
References SLA_EVENT_DIAL_STATE, and sla_queue_event().
Referenced by sla_ring_station().
03515 { 03516 sla_queue_event(SLA_EVENT_DIAL_STATE); 03517 }
| static struct sla_station* sla_find_station | ( | const char * | name | ) | [static, read] |
Find an SLA station by name.
Definition at line 3298 of file app_meetme.c.
References AST_RWLIST_TRAVERSE, and sla_station::name.
Referenced by sla_station_exec().
03299 { 03300 struct sla_station *station = NULL; 03301 03302 AST_RWLIST_TRAVERSE(&sla_stations, station, entry) { 03303 if (!strcasecmp(station->name, name)) 03304 break; 03305 } 03306 03307 return station; 03308 }
| static struct sla_trunk* sla_find_trunk | ( | const char * | name | ) | [static, read] |
Find an SLA trunk by name.
Definition at line 3283 of file app_meetme.c.
References AST_RWLIST_TRAVERSE, and sla_trunk::name.
Referenced by sla_trunk_exec().
03284 { 03285 struct sla_trunk *trunk = NULL; 03286 03287 AST_RWLIST_TRAVERSE(&sla_trunks, trunk, entry) { 03288 if (!strcasecmp(trunk->name, name)) 03289 break; 03290 } 03291 03292 return trunk; 03293 }
| static struct sla_trunk_ref* sla_find_trunk_ref | ( | const struct sla_station * | station, | |
| const struct sla_trunk * | trunk | |||
| ) | [static, read] |
Definition at line 3769 of file app_meetme.c.
References AST_LIST_TRAVERSE, sla_trunk_ref::trunk, and sla_station::trunks.
Referenced by sla_check_station_delay().
03771 { 03772 struct sla_trunk_ref *trunk_ref = NULL; 03773 03774 AST_LIST_TRAVERSE(&station->trunks, trunk_ref, entry) { 03775 if (trunk_ref->trunk == trunk) 03776 break; 03777 } 03778 03779 return trunk_ref; 03780 }
| 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 3338 of file app_meetme.c.
References AST_LIST_TRAVERSE, sla_trunk::barge_disabled, sla_trunk::hold_access, sla_trunk::hold_stations, sla_trunk::name, sla_check_station_hold_access(), SLA_HOLD_PRIVATE, SLA_TRUNK_STATE_ONHOLD_BYME, SLA_TRUNK_STATE_UP, sla_trunk_ref::state, sla_trunk_ref::trunk, and sla_station::trunks.
Referenced by sla_station_exec().
03340 { 03341 struct sla_trunk_ref *trunk_ref = NULL; 03342 03343 AST_LIST_TRAVERSE(&station->trunks, trunk_ref, entry) { 03344 if (strcasecmp(trunk_ref->trunk->name, name)) 03345 continue; 03346 03347 if ( (trunk_ref->trunk->barge_disabled 03348 && trunk_ref->state == SLA_TRUNK_STATE_UP) || 03349 (trunk_ref->trunk->hold_stations 03350 && trunk_ref->trunk->hold_access == SLA_HOLD_PRIVATE 03351 && trunk_ref->state != SLA_TRUNK_STATE_ONHOLD_BYME) || 03352 sla_check_station_hold_access(trunk_ref->trunk, station) ) 03353 { 03354 trunk_ref = NULL; 03355 } 03356 03357 break; 03358 } 03359 03360 return trunk_ref; 03361 }
| static void sla_handle_dial_state_event | ( | void | ) | [static] |
Definition at line 3577 of file app_meetme.c.
References ALL_TRUNK_REFS, answer_trunk_chan(), ast_cond_destroy(), ast_cond_init(), ast_cond_wait(), 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_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_background, sla_trunk::chan, sla_trunk_ref::chan, run_station_args::cond, run_station_args::cond_lock, sla_station::dial, free, LOG_DEBUG, sla_station::name, 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().
03578 { 03579 struct sla_ringing_station *ringing_station; 03580 03581 AST_LIST_TRAVERSE_SAFE_BEGIN(&sla.ringing_stations, ringing_station, entry) { 03582 struct sla_trunk_ref *s_trunk_ref = NULL; 03583 struct sla_ringing_trunk *ringing_trunk = NULL; 03584 struct run_station_args args; 03585 enum ast_dial_result dial_res; 03586 pthread_attr_t attr; 03587 pthread_t dont_care; 03588 ast_mutex_t cond_lock; 03589 ast_cond_t cond; 03590 03591 switch ((dial_res = ast_dial_state(ringing_station->station->dial))) { 03592 case AST_DIAL_RESULT_HANGUP: 03593 case AST_DIAL_RESULT_INVALID: 03594 case AST_DIAL_RESULT_FAILED: 03595 case AST_DIAL_RESULT_TIMEOUT: 03596 case AST_DIAL_RESULT_UNANSWERED: 03597 AST_LIST_REMOVE_CURRENT(&sla.ringing_stations, entry); 03598 sla_stop_ringing_station(ringing_station, SLA_STATION_HANGUP_NORMAL); 03599 break; 03600 case AST_DIAL_RESULT_ANSWERED: 03601 AST_LIST_REMOVE_CURRENT(&sla.ringing_stations, entry); 03602 /* Find the appropriate trunk to answer. */ 03603 ast_mutex_lock(&sla.lock); 03604 ringing_trunk = sla_choose_ringing_trunk(ringing_station->station, &s_trunk_ref, 1); 03605 ast_mutex_unlock(&sla.lock); 03606 if (!ringing_trunk) { 03607 ast_log(LOG_DEBUG, "Found no ringing trunk for station '%s' to answer!\n", 03608 ringing_station->station->name); 03609 break; 03610 } 03611 /* Track the channel that answered this trunk */ 03612 s_trunk_ref->chan = ast_dial_answered(ringing_station->station->dial); 03613 /* Actually answer the trunk */ 03614 answer_trunk_chan(ringing_trunk->trunk->chan); 03615 sla_change_trunk_state(ringing_trunk->trunk, SLA_TRUNK_STATE_UP, ALL_TRUNK_REFS, NULL); 03616 /* Now, start a thread that will connect this station to the trunk. The rest of 03617 * the code here sets up the thread and ensures that it is able to save the arguments 03618 * before they are no longer valid since they are allocated on the stack. */ 03619 args.trunk_ref = s_trunk_ref; 03620 args.station = ringing_station->station; 03621 args.cond = &cond; 03622 args.cond_lock = &cond_lock; 03623 free(ringing_trunk); 03624 free(ringing_station); 03625 ast_mutex_init(&cond_lock); 03626 ast_cond_init(&cond, NULL); 03627 pthread_attr_init(&attr); 03628 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); 03629 ast_mutex_lock(&cond_lock); 03630 ast_pthread_create_background(&dont_care, &attr, run_station, &args); 03631 ast_cond_wait(&cond, &cond_lock); 03632 ast_mutex_unlock(&cond_lock); 03633 ast_mutex_destroy(&cond_lock); 03634 ast_cond_destroy(&cond); 03635 pthread_attr_destroy(&attr); 03636 break; 03637 case AST_DIAL_RESULT_TRYING: 03638 case AST_DIAL_RESULT_RINGING: 03639 case AST_DIAL_RESULT_PROGRESS: 03640 case AST_DIAL_RESULT_PROCEEDING: 03641 break; 03642 } 03643 if (dial_res == AST_DIAL_RESULT_ANSWERED) { 03644 /* Queue up reprocessing ringing trunks, and then ringing stations again */ 03645 sla_queue_event(SLA_EVENT_RINGING_TRUNK); 03646 sla_queue_event(SLA_EVENT_DIAL_STATE); 03647 break; 03648 } 03649 } 03650 AST_LIST_TRAVERSE_SAFE_END 03651 }
| static void sla_handle_hold_event | ( | struct sla_event * | event | ) | [static] |
Definition at line 3899 of file app_meetme.c.
References sla_trunk::active_stations, ast_atomic_fetchadd_int(), AST_CAUSE_NORMAL, AST_CONTROL_HOLD, ast_device_state_changed(), ast_indicate(), ast_softhangup(), sla_trunk_ref::chan, sla_trunk::chan, sla_trunk::hold_stations, INACTIVE_TRUNK_REFS, sla_trunk::name, sla_station::name, sla_change_trunk_state(), SLA_TRUNK_STATE_ONHOLD, SLA_TRUNK_STATE_ONHOLD_BYME, sla_event::station, sla_trunk_ref::trunk, and sla_event::trunk_ref.
Referenced by sla_thread().
03900 { 03901 ast_atomic_fetchadd_int((int *) &event->trunk_ref->trunk->hold_stations, 1); 03902 event->trunk_ref->state = SLA_TRUNK_STATE_ONHOLD_BYME; 03903 ast_device_state_changed("SLA:%s_%s", 03904 event->station->name, event->trunk_ref->trunk->name); 03905 sla_change_trunk_state(event->trunk_ref->trunk, SLA_TRUNK_STATE_ONHOLD, 03906 INACTIVE_TRUNK_REFS, event->trunk_ref); 03907 03908 if (event->trunk_ref->trunk->active_stations == 1) { 03909 /* The station putting it on hold is the only one on the call, so start 03910 * Music on hold to the trunk. */ 03911 event->trunk_ref->trunk->on_hold = 1; 03912 ast_indicate(event->trunk_ref->trunk->chan, AST_CONTROL_HOLD); 03913 } 03914 03915 ast_softhangup(event->trunk_ref->chan, AST_CAUSE_NORMAL); 03916 event->trunk_ref->chan = NULL; 03917 }
| static void sla_handle_ringing_trunk_event | ( | void | ) | [static] |
Definition at line 3889 of file app_meetme.c.
References ast_mutex_lock(), ast_mutex_unlock(), sla, sla_hangup_stations(), and sla_ring_stations().
Referenced by sla_thread().
03890 { 03891 ast_mutex_lock(&sla.lock); 03892 sla_ring_stations(); 03893 ast_mutex_unlock(&sla.lock); 03894 03895 /* Find stations that shouldn't be ringing anymore. */ 03896 sla_hangup_stations(); 03897 }
| static void sla_hangup_stations | ( | void | ) | [static] |
Definition at line 3861 of file app_meetme.c.
References ast_dial_destroy(), ast_dial_join(), AST_LIST_REMOVE_CURRENT, AST_LIST_TRAVERSE, AST_LIST_TRAVERSE_SAFE_BEGIN, AST_LIST_TRAVERSE_SAFE_END, ast_mutex_lock(), ast_mutex_unlock(), sla_station::dial, free, sla, sla_ringing_station::station, sla_ringing_trunk::trunk, sla_trunk_ref::trunk, and sla_station::trunks.
Referenced by sla_handle_ringing_trunk_event().
03862 { 03863 struct sla_trunk_ref *trunk_ref; 03864 struct sla_ringing_station *ringing_station; 03865 03866 AST_LIST_TRAVERSE_SAFE_BEGIN(&sla.ringing_stations, ringing_station, entry) { 03867 AST_LIST_TRAVERSE(&ringing_station->station->trunks, trunk_ref, entry) { 03868 struct sla_ringing_trunk *ringing_trunk; 03869 ast_mutex_lock(&sla.lock); 03870 AST_LIST_TRAVERSE(&sla.ringing_trunks, ringing_trunk, entry) { 03871 if (trunk_ref->trunk == ringing_trunk->trunk) 03872 break; 03873 } 03874 ast_mutex_unlock(&sla.lock); 03875 if (ringing_trunk) 03876 break; 03877 } 03878 if (!trunk_ref) { 03879 AST_LIST_REMOVE_CURRENT(&sla.ringing_stations, entry); 03880 ast_dial_join(ringing_station->station->dial); 03881 ast_dial_destroy(ringing_station->station->dial); 03882 ringing_station->station->dial = NULL; 03883 free(ringing_station); 03884 } 03885 } 03886 AST_LIST_TRAVERSE_SAFE_END 03887 }
| static const char* sla_hold_str | ( | unsigned int | hold_access | ) | [static] |
Definition at line 1068 of file app_meetme.c.
References SLA_HOLD_OPEN, and SLA_HOLD_PRIVATE.
Referenced by sla_show_stations(), and sla_show_trunks().
01069 { 01070 const char *hold = "Unknown"; 01071 01072 switch (hold_access) { 01073 case SLA_HOLD_OPEN: 01074 hold = "Open"; 01075 break; 01076 case SLA_HOLD_PRIVATE: 01077 hold = "Private"; 01078 default: 01079 break; 01080 } 01081 01082 return hold; 01083 }
| static int sla_load_config | ( | void | ) | [static] |
Definition at line 4933 of file app_meetme.c.
References ast_category_browse(), ast_cond_init(), ast_config_destroy(), ast_config_load(), AST_LIST_EMPTY, ast_log(), ast_mutex_init(), ast_pthread_create, ast_true(), ast_variable_retrieve(), LOG_WARNING, sla, sla_build_station(), sla_build_trunk(), SLA_CONFIG_FILE, sla_thread(), and type.
Referenced by load_config().
04934 { 04935 struct ast_config *cfg; 04936 const char *cat = NULL; 04937 int res = 0; 04938 const char *val; 04939 04940 ast_mutex_init(&sla.lock); 04941 ast_cond_init(&sla.cond, NULL); 04942 04943 if (!(cfg = ast_config_load(SLA_CONFIG_FILE))) 04944 return 0; /* Treat no config as normal */ 04945 04946 if ((val = ast_variable_retrieve(cfg, "general", "attemptcallerid"))) 04947 sla.attempt_callerid = ast_true(val); 04948 04949 while ((cat = ast_category_browse(cfg, cat)) && !res) { 04950 const char *type; 04951 if (!strcasecmp(cat, "general")) 04952 continue; 04953 if (!(type = ast_variable_retrieve(cfg, cat, "type"))) { 04954 ast_log(LOG_WARNING, "Invalid entry in %s defined with no type!\n", 04955 SLA_CONFIG_FILE); 04956 continue; 04957 } 04958 if (!strcasecmp(type, "trunk")) 04959 res = sla_build_trunk(cfg, cat); 04960 else if (!strcasecmp(type, "station")) 04961 res = sla_build_station(cfg, cat); 04962 else { 04963 ast_log(LOG_WARNING, "Entry in %s defined with invalid type '%s'!\n", 04964 SLA_CONFIG_FILE, type); 04965 } 04966 } 04967 04968 ast_config_destroy(cfg); 04969 04970 if (!AST_LIST_EMPTY(&sla_stations) || !AST_LIST_EMPTY(&sla_stations)) 04971 ast_pthread_create(&sla.thread, NULL, sla_thread, NULL); 04972 04973 return res; 04974 }
| static int sla_process_timers | ( | struct timespec * | ts | ) | [static] |
Calculate the time until the next known event.
Definition at line 4077 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, sla_queue_event_nolock(), and timeout.
Referenced by sla_thread().
04078 { 04079 unsigned int timeout = UINT_MAX; 04080 struct timeval tv; 04081 unsigned int change_made = 0; 04082 04083 /* Check for ring timeouts on ringing trunks */ 04084 if (sla_calc_trunk_timeouts(&timeout)) 04085 change_made = 1; 04086 04087 /* Check for ring timeouts on ringing stations */ 04088 if (sla_calc_station_timeouts(&timeout)) 04089 change_made = 1; 04090 04091 /* Check for station ring delays */ 04092 if (sla_calc_station_delays(&timeout)) 04093 change_made = 1; 04094 04095 /* queue reprocessing of ringing trunks */ 04096 if (change_made) 04097 sla_queue_event_nolock(SLA_EVENT_RINGING_TRUNK); 04098 04099 /* No timeout */ 04100 if (timeout == UINT_MAX) 04101 return 0; 04102 04103 if (ts) { 04104 tv = ast_tvadd(ast_tvnow(), ast_samp2tv(timeout, 1000)); 04105 ts->tv_sec = tv.tv_sec; 04106 ts->tv_nsec = tv.tv_usec * 1000; 04107 } 04108 04109 return 1; 04110 }
| static void sla_queue_event | ( | enum sla_event_type | type | ) | [static] |
Definition at line 1362 of file app_meetme.c.
References sla_queue_event_full().
Referenced by queue_ringing_trunk(), sla_dial_state_callback(), sla_handle_dial_state_event(), sla_station_exec(), and sla_trunk_exec().
01363 { 01364 sla_queue_event_full(type, NULL, NULL, 1); 01365 }
| 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 1368 of file app_meetme.c.
References AST_LIST_TRAVERSE, ast_log(), AST_RWLIST_RDLOCK, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, ast_strdupa, ast_strlen_zero(), sla_trunk_ref::chan, ast_conference::confno, LOG_DEBUG, LOG_ERROR, sla_trunk::name, sla_queue_event_full(), sla_trunk_ref::trunk, and sla_station::trunks.
Referenced by conf_run().
01370 { 01371 struct sla_station *station; 01372 struct sla_trunk_ref *trunk_ref = NULL; 01373 char *trunk_name; 01374 01375 trunk_name = ast_strdupa(conf->confno); 01376 strsep(&trunk_name, "_"); 01377 if (ast_strlen_zero(trunk_name)) { 01378 ast_log(LOG_ERROR, "Invalid conference name for SLA - '%s'!\n", conf->confno); 01379 return; 01380 } 01381 01382 AST_RWLIST_RDLOCK(&sla_stations); 01383 AST_RWLIST_TRAVERSE(&sla_stations, station, entry) { 01384 AST_LIST_TRAVERSE(&station->trunks, trunk_ref, entry) { 01385 if (trunk_ref->chan == chan && !strcmp(trunk_ref->trunk->name, trunk_name)) 01386 break; 01387 } 01388 if (trunk_ref) 01389 break; 01390 } 01391 AST_RWLIST_UNLOCK(&sla_stations); 01392 01393 if (!trunk_ref) { 01394 ast_log(LOG_DEBUG, "Trunk not found for event!\n"); 01395 return; 01396 } 01397 01398 sla_queue_event_full(type, trunk_ref, station, 1); 01399 }
| 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 1330 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().
01332 { 01333 struct sla_event *event; 01334 01335 if (sla.thread == AST_PTHREADT_NULL) { 01336 return; 01337 } 01338 01339 if (!(event = ast_calloc(1, sizeof(*event)))) 01340 return; 01341 01342 event->type = type; 01343 event->trunk_ref = trunk_ref; 01344 event->station = station; 01345 01346 if (!lock) { 01347 AST_LIST_INSERT_TAIL(&sla.event_q, event, entry); 01348 return; 01349 } 01350 01351 ast_mutex_lock(&sla.lock); 01352 AST_LIST_INSERT_TAIL(&sla.event_q, event, entry); 01353 ast_cond_signal(&sla.cond); 01354 ast_mutex_unlock(&sla.lock); 01355 }
| static void sla_queue_event_nolock | ( | enum sla_event_type | type | ) | [static] |
Definition at line 1357 of file app_meetme.c.
References sla_queue_event_full().
Referenced by sla_process_timers().
01358 { 01359 sla_queue_event_full(type, NULL, NULL, 0); 01360 }
| static int sla_ring_station | ( | struct sla_ringing_trunk * | ringing_trunk, | |
| struct sla_station * | station | |||
| ) | [static] |
Ring a station.
Definition at line 3694 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_strdup, ast_strdupa, ast_strlen_zero(), ast_tvnow(), sla_trunk::chan, ast_channel::cid, ast_callerid::cid_name, cid_name, ast_callerid::cid_num, cid_num, sla_station::device, sla_station::dial, free, 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().
03695 { 03696 char *tech, *tech_data; 03697 struct ast_dial *dial; 03698 struct sla_ringing_station *ringing_station; 03699 const char *cid_name = NULL, *cid_num = NULL; 03700 enum ast_dial_result res; 03701 03702 if (!(dial = ast_dial_create())) 03703 return -1; 03704 03705 ast_dial_set_state_callback(dial, sla_dial_state_callback); 03706 tech_data = ast_strdupa(station->device); 03707 tech = strsep(&tech_data, "/"); 03708 03709 if (ast_dial_append(dial, tech, tech_data) == -1) { 03710 ast_dial_destroy(dial); 03711 return -1; 03712 } 03713 03714 if (!sla.attempt_callerid && !ast_strlen_zero(ringing_trunk->trunk->chan->cid.cid_name)) { 03715 cid_name = ast_strdupa(ringing_trunk->trunk->chan->cid.cid_name); 03716 free(ringing_trunk->trunk->chan->cid.cid_name); 03717 ringing_trunk->trunk->chan->cid.cid_name = NULL; 03718 } 03719 if (!sla.attempt_callerid && !ast_strlen_zero(ringing_trunk->trunk->chan->cid.cid_num)) { 03720 cid_num = ast_strdupa(ringing_trunk->trunk->chan->cid.cid_num); 03721 free(ringing_trunk->trunk->chan->cid.cid_num); 03722 ringing_trunk->trunk->chan->cid.cid_num = NULL; 03723 } 03724 03725 res = ast_dial_run(dial, ringing_trunk->trunk->chan, 1); 03726 03727 if (cid_name) 03728 ringing_trunk->trunk->chan->cid.cid_name = ast_strdup(cid_name); 03729 if (cid_num) 03730 ringing_trunk->trunk->chan->cid.cid_num = ast_strdup(cid_num); 03731 03732 if (res != AST_DIAL_RESULT_TRYING) { 03733 struct sla_failed_station *failed_station; 03734 ast_dial_destroy(dial); 03735 if (!(failed_station = ast_calloc(1, sizeof(*failed_station)))) 03736 return -1; 03737 failed_station->station = station; 03738 failed_station->last_try = ast_tvnow(); 03739 AST_LIST_INSERT_HEAD(&sla.failed_stations, failed_station, entry); 03740 return -1; 03741 } 03742 if (!(ringing_station = sla_create_ringing_station(station))) { 03743 ast_dial_join(dial); 03744 ast_dial_destroy(dial); 03745 return -1; 03746 } 03747 03748 station->dial = dial; 03749 03750 AST_LIST_INSERT_HEAD(&sla.ringing_stations, ringing_station, entry); 03751 03752 return 0; 03753 }
| static void sla_ring_stations | ( | void | ) | [static] |
Ring stations based on current set of ringing trunks.
Definition at line 3820 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(), sla_station_ref::station, sla_trunk::stations, and sla_ringing_trunk::trunk.
Referenced by sla_handle_ringing_trunk_event().
03821 { 03822 struct sla_station_ref *station_ref; 03823 struct sla_ringing_trunk *ringing_trunk; 03824 03825 /* Make sure that every station that uses at least one of the ringing 03826 * trunks, is ringing. */ 03827 AST_LIST_TRAVERSE(&sla.ringing_trunks, ringing_trunk, entry) { 03828 AST_LIST_TRAVERSE(&ringing_trunk->trunk->stations, station_ref, entry) { 03829 int time_left; 03830 03831 /* Is this station already ringing? */ 03832 if (sla_check_ringing_station(station_ref->station)) 03833 continue; 03834 03835 /* Is this station already in a call? */ 03836 if (sla_check_inuse_station(station_ref->station)) 03837 continue; 03838 03839 /* Did we fail to dial this station earlier? If so, has it been 03840 * a minute since we tried? */ 03841 if (sla_check_failed_station(station_ref->station)) 03842 continue; 03843 03844 /* If this station already timed out while this trunk was ringing, 03845 * do not dial it again for this ringing trunk. */ 03846 if (sla_check_timed_out_station(ringing_trunk, station_ref->station)) 03847 continue; 03848 03849 /* Check for a ring delay in progress */ 03850 time_left = sla_check_station_delay(station_ref->station, ringing_trunk); 03851 if (time_left != INT_MAX && time_left > 0) 03852 continue; 03853 03854 /* It is time to make this station begin to ring. Do it! */ 03855 sla_ring_station(ringing_trunk, station_ref->station); 03856 } 03857 } 03858 /* Now, all of the stations that should be ringing, are ringing. */ 03859 }
| static int sla_show_stations | ( | int | fd, | |
| int | argc, | |||
| char ** | argv | |||
| ) | [static] |
Definition at line 1145 of file app_meetme.c.
References ast_cli(), AST_LIST_TRAVERSE, AST_RWLIST_RDLOCK, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, sla_station::autocontext, sla_station::device, sla_station::hold_access, sla_trunk::name, sla_station::name, RESULT_SUCCESS, sla_trunk_ref::ring_delay, sla_station::ring_delay, sla_trunk_ref::ring_timeout, sla_station::ring_timeout, S_OR, sla_hold_str(), sla_trunk_ref::state, sla_trunk_ref::trunk, sla_station::trunks, and trunkstate2str().
01146 { 01147 const struct sla_station *station; 01148 01149 ast_cli(fd, "\n" 01150 "=============================================================\n" 01151 "=== Configured SLA Stations =================================\n" 01152 "=============================================================\n" 01153 "===\n"); 01154 AST_RWLIST_RDLOCK(&sla_stations); 01155 AST_RWLIST_TRAVERSE(&sla_stations, station, entry) { 01156 struct sla_trunk_ref *trunk_ref; 01157 char ring_timeout[16] = "(none)"; 01158 char ring_delay[16] = "(none)"; 01159 if (station->ring_timeout) { 01160 snprintf(ring_timeout, sizeof(ring_timeout), 01161 "%u", station->ring_timeout); 01162 } 01163 if (station->ring_delay) { 01164 snprintf(ring_delay, sizeof(ring_delay), 01165 "%u", station->ring_delay); 01166 } 01167 ast_cli(fd, "=== ---------------------------------------------------------\n" 01168 "=== Station Name: %s\n" 01169 "=== ==> Device: %s\n" 01170 "=== ==> AutoContext: %s\n" 01171 "=== ==> RingTimeout: %s\n" 01172 "=== ==> RingDelay: %s\n" 01173 "=== ==> HoldAccess: %s\n" 01174 "=== ==> Trunks ...\n", 01175 station->name, station->device, 01176 S_OR(station->autocontext, "(none)"), 01177 ring_timeout, ring_delay, 01178 sla_hold_str(station->hold_access)); 01179 AST_RWLIST_RDLOCK(&sla_trunks); 01180 AST_LIST_TRAVERSE(&station->trunks, trunk_ref, entry) { 01181 if (trunk_ref->ring_timeout) { 01182 snprintf(ring_timeout, sizeof(ring_timeout), 01183 "%u", trunk_ref->ring_timeout); 01184 } else 01185 strcpy(ring_timeout, "(none)"); 01186 if (trunk_ref->ring_delay) { 01187 snprintf(ring_delay, sizeof(ring_delay), 01188 "%u", trunk_ref->ring_delay); 01189 } else 01190 strcpy(ring_delay, "(none)"); 01191 ast_cli(fd, "=== ==> Trunk Name: %s\n" 01192 "=== ==> State: %s\n" 01193 "=== ==> RingTimeout: %s\n" 01194 "=== ==> RingDelay: %s\n", 01195 trunk_ref->trunk->name, 01196 trunkstate2str(trunk_ref->state), 01197 ring_timeout, ring_delay); 01198 } 01199 AST_RWLIST_UNLOCK(&sla_trunks); 01200 ast_cli(fd, "=== ---------------------------------------------------------\n" 01201 "===\n"); 01202 } 01203 AST_RWLIST_UNLOCK(&sla_stations); 01204 ast_cli(fd, "============================================================\n" 01205 "\n"); 01206 01207 return RESULT_SUCCESS; 01208 }
| static int sla_show_trunks | ( | int | fd, | |
| int | argc, | |||
| char ** | argv | |||
| ) | [static] |
Definition at line 1085 of file app_meetme.c.
References ast_cli(), AST_LIST_TRAVERSE, AST_RWLIST_RDLOCK, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, sla_trunk::autocontext, sla_trunk::barge_disabled, sla_trunk::device, sla_trunk::hold_access, sla_station::name, sla_trunk::name, RESULT_SUCCESS, sla_trunk::ring_timeout, S_OR, sla_hold_str(), sla_station_ref::station, and sla_trunk::stations.
01086 { 01087 const struct sla_trunk *trunk; 01088 01089 ast_cli(fd, "\n" 01090 "=============================================================\n" 01091 "=== Configured SLA Trunks ===================================\n" 01092 "=============================================================\n" 01093 "===\n"); 01094 AST_RWLIST_RDLOCK(&sla_trunks); 01095 AST_RWLIST_TRAVERSE(&sla_trunks, trunk, entry) { 01096 struct sla_station_ref *station_ref; 01097 char ring_timeout[16] = "(none)"; 01098 if (trunk->ring_timeout) 01099 snprintf(ring_timeout, sizeof(ring_timeout), "%u Seconds", trunk->ring_timeout); 01100 ast_cli(fd, "=== ---------------------------------------------------------\n" 01101 "=== Trunk Name: %s\n" 01102 "=== ==> Device: %s\n" 01103 "=== ==> AutoContext: %s\n" 01104 "=== ==> RingTimeout: %s\n" 01105 "=== ==> BargeAllowed: %s\n" 01106 "=== ==> HoldAccess: %s\n" 01107 "=== ==> Stations ...\n", 01108 trunk->name, trunk->device, 01109 S_OR(trunk->autocontext, "(none)"), 01110 ring_timeout, 01111 trunk->barge_disabled ? "No" : "Yes", 01112 sla_hold_str(trunk->hold_access)); 01113 AST_RWLIST_RDLOCK(&sla_stations); 01114 AST_LIST_TRAVERSE(&trunk->stations, station_ref, entry) 01115 ast_cli(fd, "=== ==> Station name: %s\n", station_ref->station->name); 01116 AST_RWLIST_UNLOCK(&sla_stations); 01117 ast_cli(fd, "=== ---------------------------------------------------------\n" 01118 "===\n"); 01119 } 01120 AST_RWLIST_UNLOCK(&sla_trunks); 01121 ast_cli(fd, "=============================================================\n" 01122 "\n"); 01123 01124 return RESULT_SUCCESS; 01125 }
| static int sla_state | ( | const char * | data | ) | [static] |
Definition at line 4557 of file app_meetme.c.
References AST_DEVICE_INUSE, AST_DEVICE_INVALID, AST_DEVICE_NOT_INUSE, AST_DEVICE_ONHOLD, AST_DEVICE_RINGING, AST_LIST_TRAVERSE, ast_log(), AST_RWLIST_RDLOCK, AST_RWLIST_UNLOCK, ast_strdupa, LOG_ERROR, sla_trunk::name, sla_station::name, SLA_TRUNK_STATE_IDLE, SLA_TRUNK_STATE_ONHOLD, SLA_TRUNK_STATE_ONHOLD_BYME, SLA_TRUNK_STATE_RINGING, SLA_TRUNK_STATE_UP, sla_trunk_ref::state, sla_trunk_ref::trunk, and sla_station::trunks.
Referenced by load_module().
04558 { 04559 char *buf, *station_name, *trunk_name; 04560 struct sla_station *station; 04561 struct sla_trunk_ref *trunk_ref; 04562 int res = AST_DEVICE_INVALID; 04563 04564 trunk_name = buf = ast_strdupa(data); 04565 station_name = strsep(&trunk_name, "_"); 04566 04567 AST_RWLIST_RDLOCK(&sla_stations); 04568 AST_LIST_TRAVERSE(&sla_stations, station, entry) { 04569 if (strcasecmp(station_name, station->name)) 04570 continue; 04571 AST_RWLIST_RDLOCK(&sla_trunks); 04572 AST_LIST_TRAVERSE(&station->trunks, trunk_ref, entry) { 04573 if (!strcasecmp(trunk_name, trunk_ref->trunk->name)) 04574 break; 04575 } 04576 if (!trunk_ref) { 04577 AST_RWLIST_UNLOCK(&sla_trunks); 04578 break; 04579 } 04580 switch (trunk_ref->state) { 04581 case SLA_TRUNK_STATE_IDLE: 04582 res = AST_DEVICE_NOT_INUSE; 04583 break; 04584 case SLA_TRUNK_STATE_RINGING: 04585 res = AST_DEVICE_RINGING; 04586 break; 04587 case SLA_TRUNK_STATE_UP: 04588 res = AST_DEVICE_INUSE; 04589 break; 04590 case SLA_TRUNK_STATE_ONHOLD: 04591 case SLA_TRUNK_STATE_ONHOLD_BYME: 04592 res = AST_DEVICE_ONHOLD; 04593 break; 04594 } 04595 AST_RWLIST_UNLOCK(&sla_trunks); 04596 } 04597 AST_RWLIST_UNLOCK(&sla_stations); 04598 04599 if (res == AST_DEVICE_INVALID) { 04600 ast_log(LOG_ERROR, "Could not determine state for trunk %s on station %s!\n", 04601 trunk_name, station_name); 04602 } 04603 04604 return res; 04605 }
| static int sla_station_exec | ( | struct ast_channel * | chan, | |
| void * | data | |||
| ) | [static] |
Definition at line 4299 of file app_meetme.c.
References sla_trunk::active_stations, 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_device_state_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_background, AST_RWLIST_RDLOCK, AST_RWLIST_UNLOCK, ast_set_flag, ast_strdupa, ast_strlen_zero(), build_conf(), sla_trunk_ref::chan, sla_trunk::chan, conf_run(), CONFFLAG_MARKEDEXIT, CONFFLAG_PASS_DTMF, CONFFLAG_QUIET, CONFFLAG_SLA_STATION, dial_trunk(), dispose_conf(), ast_flags::flags, free, sla_trunk::hold_stations, LOG_DEBUG, LOG_NOTICE, LOG_WARNING, MAX_CONFNUM, sla_trunk::name, sla_station::name, sla_trunk::on_hold, pbx_builtin_setvar_helper(), sla, sla_change_trunk_state(), sla_choose_idle_trunk(), 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_trunk_ref::state, sla_ringing_trunk::trunk, sla_trunk_ref::trunk, and dial_trunk_args::trunk_ref.
Referenced by load_module().
04300 { 04301 char *station_name, *trunk_name; 04302 struct sla_station *station; 04303 struct sla_trunk_ref *trunk_ref = NULL; 04304 char conf_name[MAX_CONFNUM]; 04305 struct ast_flags conf_flags = { 0 }; 04306 struct ast_conference *conf; 04307 04308 if (ast_strlen_zero(data)) { 04309 ast_log(LOG_WARNING, "Invalid Arguments to SLAStation!\n"); 04310 pbx_builtin_setvar_helper(chan, "SLASTATION_STATUS", "FAILURE"); 04311 return 0; 04312 } 04313 04314 trunk_name = ast_strdupa(data); 04315 station_name = strsep(&trunk_name, "_"); 04316 04317 if (ast_strlen_zero(station_name)) { 04318 ast_log(LOG_WARNING, "Invalid Arguments to SLAStation!\n"); 04319 pbx_builtin_setvar_helper(chan, "SLASTATION_STATUS", "FAILURE"); 04320 return 0; 04321 } 04322 04323 AST_RWLIST_RDLOCK(&sla_stations); 04324 station = sla_find_station(station_name); 04325 AST_RWLIST_UNLOCK(&sla_stations); 04326 04327 if (!station) { 04328 ast_log(LOG_WARNING, "Station '%s' not found!\n", station_name); 04329 pbx_builtin_setvar_helper(chan, "SLASTATION_STATUS", "FAILURE"); 04330 return 0; 04331 } 04332 04333 AST_RWLIST_RDLOCK(&sla_trunks); 04334 if (!ast_strlen_zero(trunk_name)) { 04335 trunk_ref = sla_find_trunk_ref_byname(station, trunk_name); 04336 } else 04337 trunk_ref = sla_choose_idle_trunk(station); 04338 AST_RWLIST_UNLOCK(&sla_trunks); 04339 04340 if (!trunk_ref) { 04341 if (ast_strlen_zero(trunk_name)) 04342 ast_log(LOG_NOTICE, "No trunks available for call.\n"); 04343 else { 04344 ast_log(LOG_NOTICE, "Can't join existing call on trunk " 04345 "'%s' due to access controls.\n", trunk_name); 04346 } 04347 pbx_builtin_setvar_helper(chan, "SLASTATION_STATUS", "CONGESTION"); 04348 return 0; 04349 } 04350 04351 if (trunk_ref->state == SLA_TRUNK_STATE_ONHOLD_BYME) { 04352 if (ast_atomic_dec_and_test((int *) &trunk_ref->trunk->hold_stations) == 1) 04353 sla_change_trunk_state(trunk_ref->trunk, SLA_TRUNK_STATE_UP, ALL_TRUNK_REFS, NULL); 04354 else { 04355 trunk_ref->state = SLA_TRUNK_STATE_UP; 04356 ast_device_state_changed("SLA:%s_%s", station->name, trunk_ref->trunk->name); 04357 } 04358 } else if (trunk_ref->state == SLA_TRUNK_STATE_RINGING) { 04359 struct sla_ringing_trunk *ringing_trunk; 04360 04361 ast_mutex_lock(&sla.lock); 04362 AST_LIST_TRAVERSE_SAFE_BEGIN(&sla.ringing_trunks, ringing_trunk, entry) { 04363 if (ringing_trunk->trunk == trunk_ref->trunk) { 04364 AST_LIST_REMOVE_CURRENT(&sla.ringing_trunks, entry); 04365 break; 04366 } 04367 } 04368 AST_LIST_TRAVERSE_SAFE_END 04369 ast_mutex_unlock(&sla.lock); 04370 04371 if (ringing_trunk) { 04372 answer_trunk_chan(ringing_trunk->trunk->chan); 04373 sla_change_trunk_state(ringing_trunk->trunk, SLA_TRUNK_STATE_UP, ALL_TRUNK_REFS, NULL); 04374 04375 free(ringing_trunk); 04376 04377 /* Queue up reprocessing ringing trunks, and then ringing stations again */ 04378 sla_queue_event(SLA_EVENT_RINGING_TRUNK); 04379 sla_queue_event(SLA_EVENT_DIAL_STATE); 04380 } 04381 } 04382 04383 trunk_ref->chan = chan; 04384 04385 if (!trunk_ref->trunk->chan) { 04386 ast_mutex_t cond_lock; 04387 ast_cond_t cond; 04388 pthread_t dont_care; 04389 pthread_attr_t attr; 04390 struct dial_trunk_args args = { 04391 .trunk_ref = trunk_ref, 04392 .station = station, 04393 .cond_lock = &cond_lock, 04394 .cond = &cond, 04395 }; 04396 sla_change_trunk_state(trunk_ref->trunk, SLA_TRUNK_STATE_UP, ALL_TRUNK_REFS, NULL); 04397 /* Create a thread to dial the trunk and dump it into the conference. 04398 * However, we want to wait until the trunk has been dialed and the 04399 * conference is created before continuing on here. */ 04400 ast_autoservice_start(chan); 04401 ast_mutex_init(&cond_lock); 04402 ast_cond_init(&cond, NULL); 04403 pthread_attr_init(&attr); 04404 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); 04405 ast_mutex_lock(&cond_lock); 04406 ast_pthread_create_background(&dont_care, &attr, dial_trunk, &args); 04407 ast_cond_wait(&cond, &cond_lock); 04408 ast_mutex_unlock(&cond_lock); 04409 ast_mutex_destroy(&cond_lock); 04410 ast_cond_destroy(&cond); 04411 pthread_attr_destroy(&attr); 04412 ast_autoservice_stop(chan); 04413 if (!trunk_ref->trunk->chan) { 04414 ast_log(LOG_DEBUG, "Trunk didn't get created. chan: %lx\n", (long) trunk_ref->trunk->chan); 04415 pbx_builtin_setvar_helper(chan, "SLASTATION_STATUS", "CONGESTION"); 04416 sla_change_trunk_state(trunk_ref->trunk, SLA_TRUNK_STATE_IDLE, ALL_TRUNK_REFS, NULL); 04417 trunk_ref->chan = NULL; 04418 return 0; 04419 } 04420 } 04421 04422 if (ast_atomic_fetchadd_int((int *) &trunk_ref->trunk->active_stations, 1) == 0 && 04423 trunk_ref->trunk->on_hold) { 04424 trunk_ref->trunk->on_hold = 0; 04425 ast_indicate(trunk_ref->trunk->chan, AST_CONTROL_UNHOLD); 04426 sla_change_trunk_state(trunk_ref->trunk, SLA_TRUNK_STATE_UP, ALL_TRUNK_REFS, NULL); 04427 } 04428 04429 snprintf(conf_name, sizeof(conf_name), "SLA_%s", trunk_ref->trunk->name); 04430 ast_set_flag(&conf_flags, 04431 CONFFLAG_QUIET | CONFFLAG_MARKEDEXIT | CONFFLAG_PASS_DTMF | CONFFLAG_SLA_STATION); 04432 ast_answer(chan); 04433 conf = build_conf(conf_name, "", "", 0, 0, 1); 04434 if (conf) { 04435 conf_run(chan, conf, conf_flags.flags, NULL); 04436 dispose_conf(conf); 04437 conf = NULL; 04438 } 04439 trunk_ref->chan = NULL; 04440 if (ast_atomic_dec_and_test((int *) &trunk_ref->trunk->active_stations) && 04441 trunk_ref->state != SLA_TRUNK_STATE_ONHOLD_BYME) { 04442 strncat(conf_name, "|K", sizeof(conf_name) - strlen(conf_name) - 1); 04443 admin_exec(NULL, conf_name); 04444 trunk_ref->trunk->hold_stations = 0; 04445 sla_change_trunk_state(trunk_ref->trunk, SLA_TRUNK_STATE_IDLE, ALL_TRUNK_REFS, NULL); 04446 } 04447 04448 pbx_builtin_setvar_helper(chan, "SLASTATION_STATUS", "SUCCESS"); 04449 04450 return 0; 04451 }
| static void sla_stop_ringing_station | ( | struct sla_ringing_station * | ringing_station, | |
| enum sla_station_hangup | hangup | |||
| ) | [static] |
Definition at line 3479 of file app_meetme.c.
References ast_dial_destroy(), ast_dial_join(), AST_LIST_INSERT_TAIL, AST_LIST_TRAVERSE, sla_station::dial, free, sla, sla_create_station_ref(), SLA_STATION_HANGUP_NORMAL, sla_ringing_station::station, sla_ringing_trunk::timed_out_stations, sla_trunk_ref::trunk, sla_ringing_trunk::trunk, and sla_station::trunks.
Referenced by sla_calc_station_timeouts(), and sla_handle_dial_state_event().
03481 { 03482 struct sla_ringing_trunk *ringing_trunk; 03483 struct sla_trunk_ref *trunk_ref; 03484 struct sla_station_ref *station_ref; 03485 03486 ast_dial_join(ringing_station->station->dial); 03487 ast_dial_destroy(ringing_station->station->dial); 03488 ringing_station->station->dial = NULL; 03489 03490 if (hangup == SLA_STATION_HANGUP_NORMAL) 03491 goto done; 03492 03493 /* If the station is being hung up because of a timeout, then add it to the 03494 * list of timed out stations on each of the ringing trunks. This is so 03495 * that when doing further processing to figure out which stations should be 03496 * ringing, which trunk to answer, determining timeouts, etc., we know which 03497 * ringing trunks we should ignore. */ 03498 AST_LIST_TRAVERSE(&sla.ringing_trunks, ringing_trunk, entry) { 03499 AST_LIST_TRAVERSE(&ringing_station->station->trunks, trunk_ref, entry) { 03500 if (ringing_trunk->trunk == trunk_ref->trunk) 03501 break; 03502 } 03503 if (!trunk_ref) 03504 continue; 03505 if (!(station_ref = sla_create_station_ref(ringing_station->station))) 03506 continue; 03507 AST_LIST_INSERT_TAIL(&ringing_trunk->timed_out_stations, station_ref, entry); 03508 } 03509 03510 done: 03511 free(ringing_station); 03512 }
| static void sla_stop_ringing_trunk | ( | struct sla_ringing_trunk * | ringing_trunk | ) | [static] |
Definition at line 3464 of file app_meetme.c.
References admin_exec(), ALL_TRUNK_REFS, AST_LIST_REMOVE_HEAD, free, sla_trunk::name, sla_change_trunk_state(), SLA_TRUNK_STATE_IDLE, sla_ringing_trunk::timed_out_stations, and sla_ringing_trunk::trunk.
Referenced by sla_calc_trunk_timeouts().
03465 { 03466 char buf[80]; 03467 struct sla_station_ref *station_ref; 03468 03469 snprintf(buf, sizeof(buf), "SLA_%s|K", ringing_trunk->trunk->name); 03470 admin_exec(NULL, buf); 03471 sla_change_trunk_state(ringing_trunk->trunk, SLA_TRUNK_STATE_IDLE, ALL_TRUNK_REFS, NULL); 03472 03473 while ((station_ref = AST_LIST_REMOVE_HEAD(&ringing_trunk->timed_out_stations, entry))) 03474 free(station_ref); 03475 03476 free(ringing_trunk); 03477 }
| static void* sla_thread | ( | void * | data | ) | [static] |
Definition at line 4112 of file app_meetme.c.
References ast_cond_timedwait(), ast_cond_wait(), AST_LIST_EMPTY, AST_LIST_REMOVE_HEAD, ast_mutex_lock(), ast_mutex_unlock(), free, sla, SLA_EVENT_DIAL_STATE, SLA_EVENT_HOLD, 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().
04113 { 04114 struct sla_failed_station *failed_station; 04115 struct sla_ringing_station *ringing_station; 04116 04117 ast_mutex_lock(&sla.lock); 04118 04119 while (!sla.stop) { 04120 struct sla_event *event; 04121 struct timespec ts = { 0, }; 04122 unsigned int have_timeout = 0; 04123 04124 if (AST_LIST_EMPTY(&sla.event_q)) { 04125 if ((have_timeout = sla_process_timers(&ts))) 04126 ast_cond_timedwait(&sla.cond, &sla.lock, &ts); 04127 else 04128 ast_cond_wait(&sla.cond, &sla.lock); 04129 if (sla.stop) 04130 break; 04131 } 04132 04133 if (have_timeout) 04134 sla_process_timers(NULL); 04135 04136 while ((event = AST_LIST_REMOVE_HEAD(&sla.event_q, entry))) { 04137 ast_mutex_unlock(&sla.lock); 04138 switch (event->type) { 04139 case SLA_EVENT_HOLD: 04140 sla_handle_hold_event(event); 04141 break; 04142 case SLA_EVENT_DIAL_STATE: 04143 sla_handle_dial_state_event(); 04144 break; 04145 case SLA_EVENT_RINGING_TRUNK: 04146 sla_handle_ringing_trunk_event(); 04147 break; 04148 } 04149 free(event); 04150 ast_mutex_lock(&sla.lock); 04151 } 04152 } 04153 04154 ast_mutex_unlock(&sla.lock); 04155 04156 while ((ringing_station = AST_LIST_REMOVE_HEAD(&sla.ringing_stations, entry))) 04157 free(ringing_station); 04158 04159 while ((failed_station = AST_LIST_REMOVE_HEAD(&sla.failed_stations, entry))) 04160 free(failed_station); 04161 04162 return NULL; 04163 }
| static int sla_trunk_exec | ( | struct ast_channel * | chan, | |
| void * | data | |||
| ) | [static] |
Definition at line 4486 of file app_meetme.c.
References ALL_TRUNK_REFS, AST_CONTROL_RINGING, 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_flag, build_conf(), sla_trunk::chan, conf_run(), CONFFLAG_MARKEDEXIT, CONFFLAG_MARKEDUSER, CONFFLAG_NO_AUDIO_UNTIL_UP, CONFFLAG_PASS_DTMF, CONFFLAG_QUIET, dispose_conf(), ast_flags::flags, free, LOG_ERROR, MAX_CONFNUM, sla_trunk::on_hold, pbx_builtin_getvar_helper(), pbx_builtin_setvar_helper(), queue_ringing_trunk(), sla, sla_change_trunk_state(), SLA_EVENT_RINGING_TRUNK, sla_find_trunk(), sla_queue_event(), SLA_TRUNK_STATE_IDLE, and sla_ringing_trunk::trunk.
Referenced by load_module().
04487 { 04488 const char *trunk_name = data; 04489 char conf_name[MAX_CONFNUM]; 04490 struct ast_conference *conf; 04491 struct ast_flags conf_flags = { 0 }; 04492 struct sla_trunk *trunk; 04493 struct sla_ringing_trunk *ringing_trunk; 04494 04495 AST_RWLIST_RDLOCK(&sla_trunks); 04496 trunk = sla_find_trunk(trunk_name); 04497 AST_RWLIST_UNLOCK(&sla_trunks); 04498 if (!trunk) { 04499 ast_log(LOG_ERROR, "SLA Trunk '%s' not found!\n", trunk_name); 04500 pbx_builtin_setvar_helper(chan, "SLATRUNK_STATUS", "FAILURE"); 04501 return 0; 04502 } 04503 if (trunk->chan) { 04504 ast_log(LOG_ERROR, "Call came in on %s, but the trunk is already in use!\n", 04505 trunk_name); 04506 pbx_builtin_setvar_helper(chan, "SLATRUNK_STATUS", "FAILURE"); 04507 return 0; 04508 } 04509 trunk->chan = chan; 04510 04511 if (!(ringing_trunk = queue_ringing_trunk(trunk))) { 04512 pbx_builtin_setvar_helper(chan, "SLATRUNK_STATUS", "FAILURE"); 04513 return 0; 04514 } 04515 04516 snprintf(conf_name, sizeof(conf_name), "SLA_%s", trunk_name); 04517 conf = build_conf(conf_name, "", "", 1, 1, 1); 04518 if (!conf) { 04519 pbx_builtin_setvar_helper(chan, "SLATRUNK_STATUS", "FAILURE"); 04520 return 0; 04521 } 04522 ast_set_flag(&conf_flags, 04523 CONFFLAG_QUIET | CONFFLAG_MARKEDEXIT | CONFFLAG_MARKEDUSER | CONFFLAG_PASS_DTMF | CONFFLAG_NO_AUDIO_UNTIL_UP); 04524 ast_indicate(chan, AST_CONTROL_RINGING); 04525 conf_run(chan, conf, conf_flags.flags, NULL); 04526 dispose_conf(conf); 04527 conf = NULL; 04528 trunk->chan = NULL; 04529 trunk->on_hold = 0; 04530 04531 sla_change_trunk_state(trunk, SLA_TRUNK_STATE_IDLE, ALL_TRUNK_REFS, NULL); 04532 04533 if (!pbx_builtin_getvar_helper(chan, "SLATRUNK_STATUS")) 04534 pbx_builtin_setvar_helper(chan, "SLATRUNK_STATUS", "SUCCESS"); 04535 04536 /* Remove the entry from the list of ringing trunks if it is still there. */ 04537 ast_mutex_lock(&sla.lock); 04538 AST_LIST_TRAVERSE_SAFE_BEGIN(&sla.ringing_trunks, ringing_trunk, entry) { 04539 if (ringing_trunk->trunk == trunk) { 04540 AST_LIST_REMOVE_CURRENT(&sla.ringing_trunks, entry); 04541 break; 04542 } 04543 } 04544 AST_LIST_TRAVERSE_SAFE_END 04545 ast_mutex_unlock(&sla.lock); 04546 if (ringing_trunk) { 04547 free(ringing_trunk); 04548 pbx_builtin_setvar_helper(chan, "SLATRUNK_STATUS", "UNANSWERED"); 04549 /* Queue reprocessing of ringing trunks to make stations stop ringing 04550 * that shouldn't be ringing after this trunk stopped. */ 04551 sla_queue_event(SLA_EVENT_RINGING_TRUNK); 04552 } 04553 04554 return 0; 04555 }
| static const char* trunkstate2str | ( | enum sla_trunk_state | state | ) | [static] |
Definition at line 1127 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().
01128 { 01129 #define S(e) case e: return # e; 01130 switch (state) { 01131 S(SLA_TRUNK_STATE_IDLE) 01132 S(SLA_TRUNK_STATE_RINGING) 01133 S(SLA_TRUNK_STATE_UP) 01134 S(SLA_TRUNK_STATE_ONHOLD) 01135 S(SLA_TRUNK_STATE_ONHOLD_BYME) 01136 } 01137 return "Uknown State"; 01138 #undef S 01139 }
| static void tweak_listen_volume | ( | struct ast_conf_user * | user, | |
| enum volume_action | action | |||
| ) | [static] |
Definition at line 698 of file app_meetme.c.
References volume::actual, volume::desired, ast_conf_user::listen, set_listen_volume(), and tweak_volume().
Referenced by admin_exec(), and conf_run().
00699 { 00700 tweak_volume(&user->listen, action); 00701 /* attempt to make the adjustment in the channel driver; 00702 if successful, don't adjust in the frame reading routine 00703 */ 00704 if (!set_listen_volume(user, user->listen.desired)) 00705 user->listen.actual = 0; 00706 else 00707 user->listen.actual = user->listen.desired; 00708 }
| static void tweak_talk_volume | ( | struct ast_conf_user * | user, | |
| enum volume_action | action | |||
| ) | [static] |
Definition at line 686 of file app_meetme.c.
References volume::actual, volume::desired, set_talk_volume(), ast_conf_user::talk, and tweak_volume().
Referenced by admin_exec(), and conf_run().
00687 { 00688 tweak_volume(&user->talk, action); 00689 /* attempt to make the adjustment in the channel driver; 00690 if successful, don't adjust in the frame reading routine 00691 */ 00692 if (!set_talk_volume(user, user->talk.desired)) 00693 user->talk.actual = 0; 00694 else 00695 user->talk.actual = user->talk.desired; 00696 }
| static void tweak_volume | ( | struct volume * | vol, | |
| enum volume_action | action | |||
| ) | [static] |
Definition at line 651 of file app_meetme.c.
References volume::desired, VOL_DOWN, and VOL_UP.
Referenced by tweak_listen_volume(), and tweak_talk_volume().
00652 { 00653 switch (action) { 00654 case VOL_UP: 00655 switch (vol->desired) { 00656 case 5: 00657 break; 00658 case 0: 00659 vol->desired = 2; 00660 break; 00661 case -2: 00662 vol->desired = 0; 00663 break; 00664 default: 00665 vol->desired++; 00666 break; 00667 } 00668 break; 00669 case VOL_DOWN: 00670 switch (vol->desired) { 00671 case -5: 00672 break; 00673 case 2: 00674 vol->desired = 0; 00675 break; 00676 case 0: 00677 vol->desired = -2; 00678 break; 00679 default: 00680 vol->desired--; 00681 break; 00682 } 00683 } 00684 }
| static int unload_module | ( | void | ) | [static] |
Definition at line 4987 of file app_meetme.c.
References ARRAY_LEN, ast_cli_unregister_multiple(), ast_devstate_prov_del(), ast_manager_unregister(), ast_module_user_hangup_all, ast_unregister_application(), and sla_destroy().
04988 { 04989 int res = 0; 04990 04991 ast_cli_unregister_multiple(cli_meetme, ARRAY_LEN(cli_meetme)); 04992 res = ast_manager_unregister("MeetmeMute"); 04993 res |= ast_manager_unregister("MeetmeUnmute"); 04994 res |= ast_unregister_application(app3); 04995 res |= ast_unregister_application(app2); 04996 res |= ast_unregister_application(app); 04997 res |= ast_unregister_application(slastation_app); 04998 res |= ast_unregister_application(slatrunk_app); 04999 05000 ast_devstate_prov_del("Meetme"); 05001 ast_devstate_prov_del("SLA"); 05002 05003 ast_module_user_hangup_all(); 05004 05005 sla_destroy(); 05006 05007 return res; 05008 }
struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT | AST_MODFLAG_BUILDSUM, .description = "MeetMe conference bridge" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, .reload = reload, } [static] |
Definition at line 5044 of file app_meetme.c.
const char* app = "MeetMe" [static] |
Definition at line 206 of file app_meetme.c.
const char* app2 = "MeetMeCount" [static] |
Definition at line 207 of file app_meetme.c.
const char* app3 = "MeetMeAdmin" [static] |
Definition at line 208 of file app_meetme.c.
const struct ast_module_info* ast_module_info = &__mod_info [static] |
Definition at line 5044 of file app_meetme.c.
| unsigned int attempt_callerid |
Attempt to handle CallerID, even though it is known not to work properly in some situations.
Definition at line 557 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 564 of file app_meetme.c.
struct ast_cli_entry cli_meetme[] [static] |
Definition at line 1214 of file app_meetme.c.
Definition at line 548 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 375 of file app_meetme.c.
Referenced by build_conf(), conf_exec(), and dispose_conf().
const char* descrip [static] |
Definition at line 218 of file app_meetme.c.
const char* descrip2 [static] |
Definition at line 266 of file app_meetme.c.
const char* descrip3 [static] |
Definition at line 273 of file app_meetme.c.
| struct { ... } event_q |
| struct { ... } failed_stations |
Definition at line 550 of file app_meetme.c.
Referenced by ast_print_group(), ast_rtp_new_with_bindaddr(), check_goto(), get_goto_target(), and misdn_lib_init().
char const gain_map[] [static] |
Map 'volume' levels from -5 through +5 into decibel (dB) settings for channel drivers Note: these are not a straight linear-to-dB conversion... the numbers have been modified to give the user a better level of adjustability
Definition at line 572 of file app_meetme.c.
Definition at line 550 of file app_meetme.c.
Referenced by __verboser(), add_extensions(), aji_handle_presence(), ao2_callback(), apply_outgoing(), ast_config_engine_deregister(), ast_db_freetree(), ast_db_gettree(), config_mysql(), config_odbc(), config_pgsql(), crypto_load(), directory_exec(), do_monitor(), gtalk_free_candidates(), load_password(), node_lookup(), scan_thread(), and try_firmware().
Definition at line 549 of file app_meetme.c.
struct ast_app_option meetme_opts[128] = { [ 'A' ] = { .flag = CONFFLAG_MARKEDUSER }, [ 'a' ] = { .flag = CONFFLAG_ADMIN }, [ 'b' ] = { .flag = CONFFLAG_AGI }, [ 'c' ] = { .flag = CONFFLAG_ANNOUNCEUSERCOUNT }, [ 'D' ] = { .flag = CONFFLAG_DYNAMICPIN }, [ 'd' ] = { .flag = CONFFLAG_DYNAMIC }, [ 'E' ] = { .flag = CONFFLAG_EMPTYNOPIN }, [ 'e' ] = { .flag = CONFFLAG_EMPTY }, [ 'F' ] = { .flag = CONFFLAG_PASS_DTMF }, [ 'i' ] = { .flag = CONFFLAG_INTROUSER }, [ 'I' ] = { .flag = CONFFLAG_INTROUSERNOREVIEW }, [ 'M' ] = { .flag = CONFFLAG_MOH }, [ 'm' ] = { .flag = CONFFLAG_STARTMUTED }, [ 'o' ] = { .flag = CONFFLAG_OPTIMIZETALKER }, [ 'P' ] = { .flag = CONFFLAG_ALWAYSPROMPT }, [ 'p' ] = { .flag = CONFFLAG_POUNDEXIT }, [ 'q' ] = { .flag = CONFFLAG_QUIET }, [ 'r' ] = { .flag = CONFFLAG_RECORDCONF }, [ 's' ] = { .flag = CONFFLAG_STARMENU }, [ 'T' ] = { .flag = CONFFLAG_MONITORTALKER }, [ 'l' ] = { .flag = CONFFLAG_MONITOR }, [ 't' ] = { .flag = CONFFLAG_TALKER }, [ 'w' ] = { .flag = CONFFLAG_WAITMARKED , .arg_index = OPT_ARG_WAITMARKED + 1 }, [ 'X' ] = { .flag = CONFFLAG_EXIT_CONTEXT }, [ 'x' ] = { .flag = CONFFLAG_MARKEDEXIT }, [ '1' ] = { .flag = CONFFLAG_NOONLYPERSON }, } [static] |
char meetme_usage[] [static] |
Initial value:
"Usage: meetme (un)lock|(un)mute|kick|list [concise] <confno> <usernumber>\n" " Executes a command for the conference or on a conferee\n"
Definition at line 1064 of file app_meetme.c.
| struct { ... } ringing_stations |
| struct { ... } ringing_trunks |
struct { ... } sla [static] |
A structure for data used by the sla thread.
Referenced by dial_trunk(), queue_ringing_trunk(), sla_calc_station_timeouts(), sla_calc_trunk_timeouts(), sla_check_failed_station(), 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 493 of file app_meetme.c.
Referenced by destroy_station(), destroy_trunk(), sla_build_station(), sla_build_trunk(), and sla_destroy().
const char sla_show_stations_usage[] [static] |
Initial value:
"Usage: sla show stations\n" " This will list all stations defined in sla.conf\n"
Definition at line 1210 of file app_meetme.c.
const char sla_show_trunks_usage[] [static] |
Initial value:
"Usage: sla show trunks\n" " This will list all trunks defined in sla.conf\n"
Definition at line 1141 of file app_meetme.c.
const char* slastation_app = "SLAStation" [static] |
Definition at line 209 of file app_meetme.c.
const char* slastation_desc [static] |
Definition at line 296 of file app_meetme.c.
const char* slastation_synopsis = "Shared Line Appearance Station" [static] |
Definition at line 215 of file app_meetme.c.
const char* slatrunk_app = "SLATrunk" [static] |
Definition at line 210 of file app_meetme.c.
const char* slatrunk_desc [static] |
Definition at line 309 of file app_meetme.c.
const char* slatrunk_synopsis = "Shared Line Appearance Trunk" [static] |
Definition at line 216 of file app_meetme.c.
| unsigned int stop |
Definition at line 554 of file app_meetme.c.
Referenced by handle_controlstreamfile(), and queue_exec().
const char* synopsis = "MeetMe conference bridge" [static] |
Definition at line 212 of file app_meetme.c.
const char* synopsis2 = "MeetMe participant count" [static] |
Definition at line 213 of file app_meetme.c.
const char* synopsis3 = "MeetMe conference Administration" [static] |
Definition at line 214 of file app_meetme.c.
| pthread_t thread |
The SLA thread ID
Definition at line 547 of file app_meetme.c.
Referenced by __schedule_action(), __unload_module(), ast_bridge_call_thread_launch(), find_idle_thread(), iax2_process_thread(), iax2_process_thread_cleanup(), iax2_show_threads(), launch_monitor_thread(), load_module(), socket_read(), and start_network_thread().
1.5.9