whitepace cleanup and various minor fixes

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@7032 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Kevin P. Fleming
2005-11-08 21:32:51 +00:00
parent 15b01f246c
commit 9433b7157f

View File

@@ -200,7 +200,7 @@ static void *recordthread(void *args);
#define CONFFLAG_ADMIN (1 << 1) /* If set the user has admin access on the conference */ #define CONFFLAG_ADMIN (1 << 1) /* If set the user has admin access on the conference */
#define CONFFLAG_MONITOR (1 << 2) /* If set the user can only receive audio from the conference */ #define CONFFLAG_MONITOR (1 << 2) /* If set the user can only receive audio from the conference */
#define CONFFLAG_POUNDEXIT (1 << 3) /* If set asterisk will exit conference when '#' is pressed */ #define CONFFLAG_POUNDEXIT (1 << 3) /* If set asterisk will exit conference when '#' is pressed */
#define CONFFLAG_STARMENU (1 << 4) /* If set asterisk will provide a menu to the user what '*' is pressed */ #define CONFFLAG_STARMENU (1 << 4) /* If set asterisk will provide a menu to the user when '*' is pressed */
#define CONFFLAG_TALKER (1 << 5) /* If set the use can only send audio to the conference */ #define CONFFLAG_TALKER (1 << 5) /* If set the use can only send audio to the conference */
#define CONFFLAG_QUIET (1 << 6) /* If set there will be no enter or leave sounds */ #define CONFFLAG_QUIET (1 << 6) /* If set there will be no enter or leave sounds */
#define CONFFLAG_VIDEO (1 << 7) /* Set to enable video mode */ #define CONFFLAG_VIDEO (1 << 7) /* Set to enable video mode */
@@ -259,7 +259,8 @@ static int careful_write(int fd, unsigned char *data, int len)
{ {
int res; int res;
int x; int x;
while(len) {
while (len) {
x = ZT_IOMUX_WRITE | ZT_IOMUX_SIGEVENT; x = ZT_IOMUX_WRITE | ZT_IOMUX_SIGEVENT;
res = ioctl(fd, ZT_IOMUX, &x); res = ioctl(fd, ZT_IOMUX, &x);
if (res >= 0) if (res >= 0)
@@ -274,6 +275,7 @@ static int careful_write(int fd, unsigned char *data, int len)
len -= res; len -= res;
data += res; data += res;
} }
return 0; return 0;
} }
@@ -305,6 +307,7 @@ static int set_talk_volume(struct ast_conf_user *user, int volume)
if successful, don't adjust in the frame reading routine if successful, don't adjust in the frame reading routine
*/ */
gain_adjust = gain_map[volume + 5]; gain_adjust = gain_map[volume + 5];
return ast_channel_setoption(user->chan, AST_OPTION_RXGAIN, &gain_adjust, sizeof(gain_adjust), 0); return ast_channel_setoption(user->chan, AST_OPTION_RXGAIN, &gain_adjust, sizeof(gain_adjust), 0);
} }
@@ -316,6 +319,7 @@ static int set_listen_volume(struct ast_conf_user *user, int volume)
if successful, don't adjust in the frame reading routine if successful, don't adjust in the frame reading routine
*/ */
gain_adjust = gain_map[volume + 5]; gain_adjust = gain_map[volume + 5];
return ast_channel_setoption(user->chan, AST_OPTION_TXGAIN, &gain_adjust, sizeof(gain_adjust), 0); return ast_channel_setoption(user->chan, AST_OPTION_TXGAIN, &gain_adjust, sizeof(gain_adjust), 0);
} }
@@ -390,10 +394,13 @@ static void conf_play(struct ast_channel *chan, struct ast_conference *conf, int
{ {
unsigned char *data; unsigned char *data;
int len; int len;
int res=-1; int res = -1;
if (!chan->_softhangup) if (!chan->_softhangup)
res = ast_autoservice_start(chan); res = ast_autoservice_start(chan);
ast_mutex_lock(&conflock); ast_mutex_lock(&conflock);
switch(sound) { switch(sound) {
case ENTER: case ENTER:
data = enter; data = enter;
@@ -409,7 +416,9 @@ static void conf_play(struct ast_channel *chan, struct ast_conference *conf, int
} }
if (data) if (data)
careful_write(conf->fd, data, len); careful_write(conf->fd, data, len);
ast_mutex_unlock(&conflock); ast_mutex_unlock(&conflock);
if (!res) if (!res)
ast_autoservice_stop(chan); ast_autoservice_stop(chan);
} }
@@ -418,18 +427,18 @@ static struct ast_conference *build_conf(char *confno, char *pin, char *pinadmin
{ {
struct ast_conference *cnf; struct ast_conference *cnf;
struct zt_confinfo ztc; struct zt_confinfo ztc;
ast_mutex_lock(&conflock); ast_mutex_lock(&conflock);
cnf = confs;
while(cnf) { for (cnf = confs; cnf; cnf = cnf->next) {
if (!strcmp(confno, cnf->confno)) if (!strcmp(confno, cnf->confno))
break; break;
cnf = cnf->next;
} }
if (!cnf && (make || dynamic)) { if (!cnf && (make || dynamic)) {
cnf = malloc(sizeof(struct ast_conference));
if (cnf) {
/* Make a new one */ /* Make a new one */
memset(cnf, 0, sizeof(struct ast_conference)); cnf = calloc(1, sizeof(*cnf));
if (cnf) {
ast_copy_string(cnf->confno, confno, sizeof(cnf->confno)); ast_copy_string(cnf->confno, confno, sizeof(cnf->confno));
ast_copy_string(cnf->pin, pin, sizeof(cnf->pin)); ast_copy_string(cnf->pin, pin, sizeof(cnf->pin));
ast_copy_string(cnf->pinadmin, pinadmin, sizeof(cnf->pinadmin)); ast_copy_string(cnf->pinadmin, pinadmin, sizeof(cnf->pinadmin));
@@ -476,7 +485,7 @@ static struct ast_conference *build_conf(char *confno, char *pin, char *pinadmin
} else } else
ast_log(LOG_WARNING, "Out of memory\n"); ast_log(LOG_WARNING, "Out of memory\n");
} }
cnfout: cnfout:
ast_mutex_unlock(&conflock); ast_mutex_unlock(&conflock);
return cnf; return cnf;
} }
@@ -484,6 +493,7 @@ cnfout:
static int confs_show(int fd, int argc, char **argv) static int confs_show(int fd, int argc, char **argv)
{ {
ast_cli(fd, "Deprecated! Please use 'meetme' instead.\n"); ast_cli(fd, "Deprecated! Please use 'meetme' instead.\n");
return RESULT_SUCCESS; return RESULT_SUCCESS;
} }
@@ -599,22 +609,29 @@ static int conf_cmd(int fd, int argc, char **argv) {
} }
} }
/* Show all the users */ /* Show all the users */
user = cnf->firstuser; for (user = cnf->firstuser; user; user = user->nextuser)
while(user) { ast_cli(fd, "User #: %-2.2d %12.12s %-20.20s Channel: %s %s %s %s %s\n",
ast_cli(fd, "User #: %-2.2d %12.12s %-20.20s Channel: %s %s %s %s %s\n", user->user_no, user->chan->cid.cid_num ? user->chan->cid.cid_num : "<unknown>", user->chan->cid.cid_name ? user->chan->cid.cid_name : "<no name>", user->chan->name, (user->userflags & CONFFLAG_ADMIN) ? "(Admin)" : "", (user->userflags & CONFFLAG_MONITOR) ? "(Listen only)" : "", (user->adminflags & ADMINFLAG_MUTED) ? "(Admn Muted)" : "", istalking(user->talking)); user->user_no,
user = user->nextuser; user->chan->cid.cid_num ? user->chan->cid.cid_num : "<unknown>",
} user->chan->cid.cid_name ? user->chan->cid.cid_name : "<no name>",
user->chan->name,
user->userflags & CONFFLAG_ADMIN ? "(Admin)" : "",
user->userflags & CONFFLAG_MONITOR ? "(Listen only)" : "",
user->adminflags & ADMINFLAG_MUTED ? "(Admn Muted)" : "",
istalking(user->talking));
ast_cli(fd,"%d users in that conference.\n",cnf->users); ast_cli(fd,"%d users in that conference.\n",cnf->users);
return RESULT_SUCCESS; return RESULT_SUCCESS;
} else } else
return RESULT_SHOWUSAGE; return RESULT_SHOWUSAGE;
ast_log(LOG_DEBUG, "Cmdline: %s\n", cmdline); ast_log(LOG_DEBUG, "Cmdline: %s\n", cmdline);
admin_exec(NULL, cmdline); admin_exec(NULL, cmdline);
return 0; return 0;
} }
static char *complete_confcmd(char *line, char *word, int pos, int state) { static char *complete_confcmd(char *line, char *word, int pos, int state) {
#define CONF_COMMANDS 6 #define CONF_COMMANDS 6
int which = 0, x = 0; int which = 0, x = 0;
struct ast_conference *cnf = NULL; struct ast_conference *cnf = NULL;
struct ast_conf_user *usr = NULL; struct ast_conf_user *usr = NULL;
@@ -653,7 +670,6 @@ static char *complete_confcmd(char *line, char *word, int pos, int state) {
} }
which++; which++;
ast_mutex_lock(&conflock); ast_mutex_lock(&conflock);
cnf = confs;
/* TODO: Find the conf number from the cmdline (ignore spaces) <- test this and make it fail-safe! */ /* TODO: Find the conf number from the cmdline (ignore spaces) <- test this and make it fail-safe! */
myline = ast_strdupa(line); myline = ast_strdupa(line);
@@ -662,28 +678,26 @@ static char *complete_confcmd(char *line, char *word, int pos, int state) {
; ;
} }
while(cnf) { for (cnf = confs; cnf; cnf = cnf->next) {
if (strcmp(confno, cnf->confno) == 0) { if (!strcmp(confno, cnf->confno))
break; break;
} }
cnf = cnf->next;
}
if (cnf) { if (cnf) {
/* Search for the user */ /* Search for the user */
usr = cnf->firstuser; for (usr = cnf->firstuser; usr; usr = usr->nextuser) {
while(usr) {
snprintf(usrno, sizeof(usrno), "%d", usr->user_no); snprintf(usrno, sizeof(usrno), "%d", usr->user_no);
if (!strncasecmp(word, usrno, strlen(word))) { if (!strncasecmp(word, usrno, strlen(word))) {
if (++which > state) if (++which > state)
break; break;
} }
usr = usr->nextuser;
} }
} }
ast_mutex_unlock(&conflock); ast_mutex_unlock(&conflock);
return usr ? strdup(usrno) : NULL; return usr ? strdup(usrno) : NULL;
} }
} }
return NULL; return NULL;
} }
@@ -698,6 +712,7 @@ static struct ast_cli_entry cli_conf = {
static void conf_flush(int fd) static void conf_flush(int fd)
{ {
int x; int x;
x = ZT_FLUSH_ALL; x = ZT_FLUSH_ALL;
if (ioctl(fd, ZT_FLUSH, &x)) if (ioctl(fd, ZT_FLUSH, &x))
ast_log(LOG_WARNING, "Error flushing channel\n"); ast_log(LOG_WARNING, "Error flushing channel\n");
@@ -709,7 +724,7 @@ static int conf_free(struct ast_conference *conf)
{ {
struct ast_conference *prev = NULL, *cur = confs; struct ast_conference *prev = NULL, *cur = confs;
while(cur) { while (cur) {
if (cur == conf) { if (cur == conf) {
if (prev) if (prev)
prev->next = conf->next; prev->next = conf->next;
@@ -747,7 +762,7 @@ static int conf_free(struct ast_conference *conf)
static int conf_run(struct ast_channel *chan, struct ast_conference *conf, int confflags) static int conf_run(struct ast_channel *chan, struct ast_conference *conf, int confflags)
{ {
struct ast_conf_user *user = malloc(sizeof(struct ast_conf_user)); struct ast_conf_user *user = calloc(1, sizeof(*user));
struct ast_conf_user *usr = NULL; struct ast_conf_user *usr = NULL;
int fd; int fd;
struct zt_confinfo ztc, ztc_empty; struct zt_confinfo ztc, ztc_empty;
@@ -763,7 +778,6 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, int c
int origfd; int origfd;
int musiconhold = 0; int musiconhold = 0;
int firstpass = 0; int firstpass = 0;
int origquiet;
int lastmarked = 0; int lastmarked = 0;
int currentmarked = 0; int currentmarked = 0;
int ret = -1; int ret = -1;
@@ -772,7 +786,6 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, int c
int using_pseudo = 0; int using_pseudo = 0;
int duration=20; int duration=20;
struct ast_dsp *dsp=NULL; struct ast_dsp *dsp=NULL;
struct ast_app *app; struct ast_app *app;
char *agifile; char *agifile;
char *agifiledefault = "conf-background.agi"; char *agifiledefault = "conf-background.agi";
@@ -780,36 +793,33 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, int c
char exitcontext[AST_MAX_CONTEXT] = ""; char exitcontext[AST_MAX_CONTEXT] = "";
char recordingtmp[AST_MAX_EXTENSION] = ""; char recordingtmp[AST_MAX_EXTENSION] = "";
int dtmf; int dtmf;
ZT_BUFFERINFO bi; ZT_BUFFERINFO bi;
char __buf[CONF_SIZE + AST_FRIENDLY_OFFSET]; char __buf[CONF_SIZE + AST_FRIENDLY_OFFSET];
char *buf = __buf + AST_FRIENDLY_OFFSET; char *buf = __buf + AST_FRIENDLY_OFFSET;
if (!user) { if (!user) {
ast_log(LOG_ERROR, "Out of memory\n"); ast_log(LOG_ERROR, "Out of memory\n");
return(ret); return ret;
} }
memset(user, 0, sizeof(struct ast_conf_user));
if (confflags & CONFFLAG_RECORDCONF && conf->recording !=MEETME_RECORD_ACTIVE) { if (confflags & CONFFLAG_RECORDCONF && conf->recording !=MEETME_RECORD_ACTIVE) {
conf->recordingfilename = pbx_builtin_getvar_helper(chan,"MEETME_RECORDINGFILE"); conf->recordingfilename = pbx_builtin_getvar_helper(chan, "MEETME_RECORDINGFILE");
if (!conf->recordingfilename) { if (!conf->recordingfilename) {
snprintf(recordingtmp,sizeof(recordingtmp),"meetme-conf-rec-%s-%s",conf->confno,chan->uniqueid); snprintf(recordingtmp, sizeof(recordingtmp), "meetme-conf-rec-%s-%s", conf->confno, chan->uniqueid);
conf->recordingfilename = ast_strdupa(recordingtmp); conf->recordingfilename = ast_strdupa(recordingtmp);
} }
conf->recordingformat = pbx_builtin_getvar_helper(chan, "MEETME_RECORDINGFORMAT"); conf->recordingformat = pbx_builtin_getvar_helper(chan, "MEETME_RECORDINGFORMAT");
if (!conf->recordingformat) { if (!conf->recordingformat) {
snprintf(recordingtmp,sizeof(recordingtmp), "wav"); snprintf(recordingtmp, sizeof(recordingtmp), "wav");
conf->recordingformat = ast_strdupa(recordingtmp); conf->recordingformat = ast_strdupa(recordingtmp);
} }
pthread_attr_init(&conf->attr); pthread_attr_init(&conf->attr);
pthread_attr_setdetachstate(&conf->attr, PTHREAD_CREATE_DETACHED); pthread_attr_setdetachstate(&conf->attr, PTHREAD_CREATE_DETACHED);
ast_verbose(VERBOSE_PREFIX_4 "Starting recording of MeetMe Conference %s into file %s.%s.\n", conf->confno, conf->recordingfilename, conf->recordingformat); ast_verbose(VERBOSE_PREFIX_4 "Starting recording of MeetMe Conference %s into file %s.%s.\n",
conf->confno, conf->recordingfilename, conf->recordingformat);
ast_pthread_create(&conf->recordthread, &conf->attr, recordthread, conf); ast_pthread_create(&conf->recordthread, &conf->attr, recordthread, conf);
} }
user->user_no = 0; /* User number 0 means starting up user! (dead - not in the list!) */
time(&user->jointime); time(&user->jointime);
if (conf->locked) { if (conf->locked) {
@@ -823,19 +833,16 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, int c
conf->markedusers++; conf->markedusers++;
ast_mutex_lock(&conflock); ast_mutex_lock(&conflock);
if (conf->firstuser == NULL) { if (!conf->firstuser) {
/* Fill the first new User struct */ /* Fill the first new User struct */
user->user_no = 1; user->user_no = 1;
user->nextuser = NULL;
user->prevuser = NULL;
conf->firstuser = user; conf->firstuser = user;
conf->lastuser = user; conf->lastuser = user;
} else { } else {
/* Fill the new user struct */ /* Fill the new user struct */
user->user_no = conf->lastuser->user_no + 1; user->user_no = conf->lastuser->user_no + 1;
user->prevuser = conf->lastuser; user->prevuser = conf->lastuser;
user->nextuser = NULL; if (conf->lastuser->nextuser) {
if (conf->lastuser->nextuser != NULL) {
ast_log(LOG_WARNING, "Error in User Management!\n"); ast_log(LOG_WARNING, "Error in User Management!\n");
ast_mutex_unlock(&conflock); ast_mutex_unlock(&conflock);
goto outrun; goto outrun;
@@ -844,12 +851,14 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, int c
conf->lastuser = user; conf->lastuser = user;
} }
} }
user->chan = chan; user->chan = chan;
user->userflags = confflags; user->userflags = confflags;
user->adminflags = 0; user->adminflags = 0;
user->talking = -1; user->talking = -1;
conf->users++;
ast_mutex_unlock(&conflock); ast_mutex_unlock(&conflock);
origquiet = confflags & CONFFLAG_QUIET;
if (confflags & CONFFLAG_EXIT_CONTEXT) { if (confflags & CONFFLAG_EXIT_CONTEXT) {
if ((agifile = pbx_builtin_getvar_helper(chan, "MEETME_EXIT_CONTEXT"))) if ((agifile = pbx_builtin_getvar_helper(chan, "MEETME_EXIT_CONTEXT")))
ast_copy_string(exitcontext, agifile, sizeof(exitcontext)); ast_copy_string(exitcontext, agifile, sizeof(exitcontext));
@@ -860,12 +869,12 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, int c
} }
if (!(confflags & CONFFLAG_QUIET) && (confflags & CONFFLAG_INTROUSER)) { if (!(confflags & CONFFLAG_QUIET) && (confflags & CONFFLAG_INTROUSER)) {
snprintf(user->namerecloc,sizeof(user->namerecloc),"%s/meetme/meetme-username-%s-%d",ast_config_AST_SPOOL_DIR,conf->confno,user->user_no); snprintf(user->namerecloc, sizeof(user->namerecloc),
ast_record_review(chan,"vm-rec-name",user->namerecloc, 10,"sln", &duration, NULL); "%s/meetme/meetme-username-%s-%d", ast_config_AST_SPOOL_DIR,
conf->confno, user->user_no);
ast_record_review(chan, "vm-rec-name", user->namerecloc, 10, "sln", &duration, NULL);
} }
conf->users++;
if (!(confflags & CONFFLAG_QUIET)) { if (!(confflags & CONFFLAG_QUIET)) {
if (conf->users == 1 && !(confflags & CONFFLAG_WAITMARKED)) if (conf->users == 1 && !(confflags & CONFFLAG_WAITMARKED))
if (!ast_streamfile(chan, "conf-onlyperson", chan->language)) if (!ast_streamfile(chan, "conf-onlyperson", chan->language))
@@ -876,7 +885,7 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, int c
} }
if (!(confflags & CONFFLAG_QUIET) && (confflags & CONFFLAG_ANNOUNCEUSERCOUNT) && conf->users > 1) { if (!(confflags & CONFFLAG_QUIET) && (confflags & CONFFLAG_ANNOUNCEUSERCOUNT) && conf->users > 1) {
int keepplaying=1; int keepplaying = 1;
if (conf->users == 2) { if (conf->users == 2) {
if (!ast_streamfile(chan,"conf-onlyone",chan->language)) { if (!ast_streamfile(chan,"conf-onlyone",chan->language)) {
@@ -911,21 +920,21 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, int c
} }
} }
/* Set it into linear mode (write) */
if (ast_set_write_format(chan, AST_FORMAT_SLINEAR) < 0) { if (ast_set_write_format(chan, AST_FORMAT_SLINEAR) < 0) {
ast_log(LOG_WARNING, "Unable to set '%s' to write linear mode\n", chan->name); ast_log(LOG_WARNING, "Unable to set '%s' to write linear mode\n", chan->name);
goto outrun; goto outrun;
} }
/* Set it into linear mode (read) */
if (ast_set_read_format(chan, AST_FORMAT_SLINEAR) < 0) { if (ast_set_read_format(chan, AST_FORMAT_SLINEAR) < 0) {
ast_log(LOG_WARNING, "Unable to set '%s' to read linear mode\n", chan->name); ast_log(LOG_WARNING, "Unable to set '%s' to read linear mode\n", chan->name);
goto outrun; goto outrun;
} }
ast_indicate(chan, -1); ast_indicate(chan, -1);
retryzap = strcasecmp(chan->type, "Zap"); retryzap = strcasecmp(chan->type, "Zap");
user->zapchannel = !retryzap; user->zapchannel = !retryzap;
zapretry:
zapretry:
origfd = chan->fds[0]; origfd = chan->fds[0];
if (retryzap) { if (retryzap) {
fd = open("/dev/zap/pseudo", O_RDWR); fd = open("/dev/zap/pseudo", O_RDWR);
@@ -990,7 +999,9 @@ zapretry:
/* Add us to the conference */ /* Add us to the conference */
ztc.chan = 0; ztc.chan = 0;
ztc.confno = conf->zapconf; ztc.confno = conf->zapconf;
ast_mutex_lock(&conflock); ast_mutex_lock(&conflock);
if (!(confflags & CONFFLAG_QUIET) && (confflags & CONFFLAG_INTROUSER) && conf->users > 1) { if (!(confflags & CONFFLAG_QUIET) && (confflags & CONFFLAG_INTROUSER) && conf->users > 1) {
if (conf->chan && ast_fileexists(user->namerecloc, NULL, NULL)) { if (conf->chan && ast_fileexists(user->namerecloc, NULL, NULL)) {
if (!ast_streamfile(conf->chan, user->namerecloc, chan->language)) if (!ast_streamfile(conf->chan, user->namerecloc, chan->language))
@@ -1028,21 +1039,23 @@ zapretry:
if (!(confflags & CONFFLAG_WAITMARKED) || (conf->markedusers >= 1)) if (!(confflags & CONFFLAG_WAITMARKED) || (conf->markedusers >= 1))
conf_play(chan, conf, ENTER); conf_play(chan, conf, ENTER);
} }
conf_flush(fd);
ast_mutex_unlock(&conflock);
if (confflags & CONFFLAG_AGI) {
ast_mutex_unlock(&conflock);
conf_flush(fd);
if (confflags & CONFFLAG_AGI) {
/* Get name of AGI file to run from $(MEETME_AGI_BACKGROUND) /* Get name of AGI file to run from $(MEETME_AGI_BACKGROUND)
or use default filename of conf-background.agi */ or use default filename of conf-background.agi */
agifile = pbx_builtin_getvar_helper(chan,"MEETME_AGI_BACKGROUND"); agifile = pbx_builtin_getvar_helper(chan, "MEETME_AGI_BACKGROUND");
if (!agifile) if (!agifile)
agifile = agifiledefault; agifile = agifiledefault;
if (user->zapchannel) { if (user->zapchannel) {
/* Set CONFMUTE mode on Zap channel to mute DTMF tones */ /* Set CONFMUTE mode on Zap channel to mute DTMF tones */
x = 1; x = 1;
ast_channel_setoption(chan,AST_OPTION_TONE_VERIFY,&x,sizeof(char),0); ast_channel_setoption(chan, AST_OPTION_TONE_VERIFY, &x, sizeof(char), 0);
} }
/* Find a pointer to the agi app and execute the script */ /* Find a pointer to the agi app and execute the script */
app = pbx_findapp("agi"); app = pbx_findapp("agi");
@@ -1055,13 +1068,13 @@ zapretry:
if (user->zapchannel) { if (user->zapchannel) {
/* Remove CONFMUTE mode on Zap channel */ /* Remove CONFMUTE mode on Zap channel */
x = 0; x = 0;
ast_channel_setoption(chan,AST_OPTION_TONE_VERIFY,&x,sizeof(char),0); ast_channel_setoption(chan, AST_OPTION_TONE_VERIFY, &x, sizeof(char), 0);
} }
} else { } else {
if (user->zapchannel && (confflags & CONFFLAG_STARMENU)) { if (user->zapchannel && (confflags & CONFFLAG_STARMENU)) {
/* Set CONFMUTE mode on Zap channel to mute DTMF tones when the menu is enabled */ /* Set CONFMUTE mode on Zap channel to mute DTMF tones when the menu is enabled */
x = 1; x = 1;
ast_channel_setoption(chan,AST_OPTION_TONE_VERIFY,&x,sizeof(char),0); ast_channel_setoption(chan, AST_OPTION_TONE_VERIFY, &x, sizeof(char), 0);
} }
if (confflags & CONFFLAG_MONITORTALKER && !(dsp = ast_dsp_new())) { if (confflags & CONFFLAG_MONITORTALKER && !(dsp = ast_dsp_new())) {
ast_log(LOG_WARNING, "Unable to allocate DSP!\n"); ast_log(LOG_WARNING, "Unable to allocate DSP!\n");
@@ -1082,7 +1095,10 @@ zapretry:
menu_was_active = menu_active; menu_was_active = menu_active;
currentmarked = conf->markedusers; currentmarked = conf->markedusers;
if (!(confflags & CONFFLAG_QUIET) && (confflags & CONFFLAG_MARKEDUSER) && (confflags & CONFFLAG_WAITMARKED) && lastmarked == 0) { if (!(confflags & CONFFLAG_QUIET) &&
(confflags & CONFFLAG_MARKEDUSER) &&
(confflags & CONFFLAG_WAITMARKED) &&
lastmarked == 0) {
if (currentmarked == 1 && conf->users > 1) { if (currentmarked == 1 && conf->users > 1) {
ast_say_number(chan, conf->users - 1, AST_DIGIT_ANY, chan->language, (char *) NULL); ast_say_number(chan, conf->users - 1, AST_DIGIT_ANY, chan->language, (char *) NULL);
if (conf->users - 1 == 1) { if (conf->users - 1 == 1) {
@@ -1232,6 +1248,7 @@ zapretry:
if (confflags & CONFFLAG_MONITORTALKER) { if (confflags & CONFFLAG_MONITORTALKER) {
int totalsilence; int totalsilence;
if (user->talking == -1) if (user->talking == -1)
user->talking = 0; user->talking = 0;
@@ -1261,6 +1278,7 @@ zapretry:
} }
} else if ((f->frametype == AST_FRAME_DTMF) && (confflags & CONFFLAG_EXIT_CONTEXT)) { } else if ((f->frametype == AST_FRAME_DTMF) && (confflags & CONFFLAG_EXIT_CONTEXT)) {
char tmp[2]; char tmp[2];
tmp[0] = f->subclass; tmp[0] = f->subclass;
tmp[1] = '\0'; tmp[1] = '\0';
if (ast_goto_if_exists(chan, exitcontext, tmp, 1)) { if (ast_goto_if_exists(chan, exitcontext, tmp, 1)) {
@@ -1275,7 +1293,6 @@ zapretry:
if (ioctl(fd, ZT_SETCONF, &ztc_empty)) { if (ioctl(fd, ZT_SETCONF, &ztc_empty)) {
ast_log(LOG_WARNING, "Error setting conference\n"); ast_log(LOG_WARNING, "Error setting conference\n");
close(fd); close(fd);
ast_mutex_unlock(&conflock);
goto outrun; goto outrun;
} }
@@ -1345,27 +1362,21 @@ zapretry:
usr->adminflags |= ADMINFLAG_KICKME; usr->adminflags |= ADMINFLAG_KICKME;
ast_stopstream(chan); ast_stopstream(chan);
break; break;
case '4': case '4':
tweak_listen_volume(user, VOL_DOWN); tweak_listen_volume(user, VOL_DOWN);
break; break;
case '6': case '6':
tweak_listen_volume(user, VOL_UP); tweak_listen_volume(user, VOL_UP);
break; break;
case '7': case '7':
tweak_talk_volume(user, VOL_DOWN); tweak_talk_volume(user, VOL_DOWN);
break; break;
case '8': case '8':
menu_active = 0; menu_active = 0;
break; break;
case '9': case '9':
tweak_talk_volume(user, VOL_UP); tweak_talk_volume(user, VOL_UP);
break; break;
default: default:
menu_active = 0; menu_active = 0;
/* Play an error message! */ /* Play an error message! */
@@ -1378,7 +1389,6 @@ zapretry:
/* User menu */ /* User menu */
if (!menu_active) { if (!menu_active) {
menu_active = 1; menu_active = 1;
/* Record this sound! */
if (!ast_streamfile(chan, "conf-usermenu", chan->language)) if (!ast_streamfile(chan, "conf-usermenu", chan->language))
dtmf = ast_waitstream(chan, AST_DIGIT_ANY); dtmf = ast_waitstream(chan, AST_DIGIT_ANY);
else else
@@ -1412,35 +1422,28 @@ zapretry:
case '4': case '4':
tweak_listen_volume(user, VOL_DOWN); tweak_listen_volume(user, VOL_DOWN);
break; break;
case '6': case '6':
tweak_listen_volume(user, VOL_UP); tweak_listen_volume(user, VOL_UP);
break; break;
case '7': case '7':
tweak_talk_volume(user, VOL_DOWN); tweak_talk_volume(user, VOL_DOWN);
break; break;
case '8': case '8':
menu_active = 0; menu_active = 0;
break; break;
case '9': case '9':
tweak_talk_volume(user, VOL_UP); tweak_talk_volume(user, VOL_UP);
break; break;
default: default:
menu_active = 0; menu_active = 0;
/* Play an error message! */
if (!ast_streamfile(chan, "conf-errormenu", chan->language)) if (!ast_streamfile(chan, "conf-errormenu", chan->language))
ast_waitstream(chan, ""); ast_waitstream(chan, "");
break; break;
} }
} }
} }
if (musiconhold) { if (musiconhold)
ast_moh_start(chan, NULL); ast_moh_start(chan, NULL);
}
if (ioctl(fd, ZT_SETCONF, &ztc)) { if (ioctl(fd, ZT_SETCONF, &ztc)) {
ast_log(LOG_WARNING, "Error setting conference\n"); ast_log(LOG_WARNING, "Error setting conference\n");
@@ -1450,7 +1453,9 @@ zapretry:
} }
conf_flush(fd); conf_flush(fd);
} else if (option_debug) { } else if (option_debug) {
ast_log(LOG_DEBUG, "Got unrecognized frame on channel %s, f->frametype=%d,f->subclass=%d\n",chan->name,f->frametype,f->subclass); ast_log(LOG_DEBUG,
"Got unrecognized frame on channel %s, f->frametype=%d,f->subclass=%d\n",
chan->name, f->frametype, f->subclass);
} }
ast_frfree(f); ast_frfree(f);
} else if (outfd > -1) { } else if (outfd > -1) {
@@ -1467,7 +1472,6 @@ zapretry:
ast_frame_adjust_volume(&fr, user->listen.actual); ast_frame_adjust_volume(&fr, user->listen.actual);
if (ast_write(chan, &fr) < 0) { if (ast_write(chan, &fr) < 0) {
ast_log(LOG_WARNING, "Unable to write frame to channel: %s\n", strerror(errno)); ast_log(LOG_WARNING, "Unable to write frame to channel: %s\n", strerror(errno));
/* break; */
} }
} else } else
ast_log(LOG_WARNING, "Failed to read frame: %s\n", strerror(errno)); ast_log(LOG_WARNING, "Failed to read frame: %s\n", strerror(errno));
@@ -1506,9 +1510,9 @@ zapretry:
} }
ast_mutex_unlock(&conflock); ast_mutex_unlock(&conflock);
outrun:
outrun:
ast_mutex_lock(&conflock); ast_mutex_lock(&conflock);
if (confflags & CONFFLAG_MONITORTALKER && dsp) if (confflags & CONFFLAG_MONITORTALKER && dsp)
ast_dsp_free(dsp); ast_dsp_free(dsp);
@@ -1560,6 +1564,7 @@ outrun:
} }
free(user); free(user);
ast_mutex_unlock(&conflock); ast_mutex_unlock(&conflock);
return ret; return ret;
} }
@@ -1571,11 +1576,9 @@ static struct ast_conference *find_conf(struct ast_channel *chan, char *confno,
/* Check first in the conference list */ /* Check first in the conference list */
ast_mutex_lock(&conflock); ast_mutex_lock(&conflock);
cnf = confs; for (cnf = confs; cnf; cnf = cnf->next) {
while (cnf) {
if (!strcmp(confno, cnf->confno)) if (!strcmp(confno, cnf->confno))
break; break;
cnf = cnf->next;
} }
ast_mutex_unlock(&conflock); ast_mutex_unlock(&conflock);
@@ -1600,7 +1603,7 @@ static struct ast_conference *find_conf(struct ast_channel *chan, char *confno,
return NULL; return NULL;
} }
var = ast_variable_browse(cfg, "rooms"); var = ast_variable_browse(cfg, "rooms");
while(var) { while (var) {
if (!strcasecmp(var->name, "conf")) { if (!strcasecmp(var->name, "conf")) {
/* Separate the PIN */ /* Separate the PIN */
char *pin, *pinadmin, *conf; char *pin, *pinadmin, *conf;
@@ -1638,6 +1641,7 @@ static struct ast_conference *find_conf(struct ast_channel *chan, char *confno,
if (dynamic_pin[0] == 'q') if (dynamic_pin[0] == 'q')
dynamic_pin[0] = '\0'; dynamic_pin[0] = '\0';
} }
return cnf; return cnf;
} }
@@ -1674,14 +1678,15 @@ static int count_exec(struct ast_channel *chan, void *data)
if (!ast_strlen_zero(localdata)){ if (!ast_strlen_zero(localdata)){
/* have var so load it and exit */ /* have var so load it and exit */
snprintf(val,sizeof(val), "%d",count); snprintf(val, sizeof(val), "%d",count);
pbx_builtin_setvar_helper(chan, localdata,val); pbx_builtin_setvar_helper(chan, localdata, val);
} else { } else {
if (chan->_state != AST_STATE_UP) if (chan->_state != AST_STATE_UP)
ast_answer(chan); ast_answer(chan);
res = ast_say_number(chan, count, "", chan->language, (char *) NULL); /* Needs gender */ res = ast_say_number(chan, count, "", chan->language, (char *) NULL); /* Needs gender */
} }
LOCAL_USER_REMOVE(u); LOCAL_USER_REMOVE(u);
return res; return res;
} }
@@ -1767,7 +1772,7 @@ static int conf_exec(struct ast_channel *chan, void *data)
cfg = ast_config_load("meetme.conf"); cfg = ast_config_load("meetme.conf");
if (cfg) { if (cfg) {
var = ast_variable_browse(cfg, "rooms"); var = ast_variable_browse(cfg, "rooms");
while(var) { while (var) {
if (!strcasecmp(var->name, "conf")) { if (!strcasecmp(var->name, "conf")) {
char *stringp = ast_strdupa(var->value); char *stringp = ast_strdupa(var->value);
if (stringp) { if (stringp) {
@@ -1780,7 +1785,7 @@ static int conf_exec(struct ast_channel *chan, void *data)
} }
} }
} }
if (! dynamic) { if (!dynamic) {
/* For static: run through the list and see if this conference is empty */ /* For static: run through the list and see if this conference is empty */
ast_mutex_lock(&conflock); ast_mutex_lock(&conflock);
cnf = confs; cnf = confs;
@@ -1863,13 +1868,16 @@ static int conf_exec(struct ast_channel *chan, void *data)
if (allowretry) if (allowretry)
confno[0] = '\0'; confno[0] = '\0';
} else { } else {
if ((!ast_strlen_zero(cnf->pin) && !ast_test_flag(&confflags, CONFFLAG_ADMIN)) || (!ast_strlen_zero(cnf->pinadmin) && ast_test_flag(&confflags, CONFFLAG_ADMIN))) { if ((!ast_strlen_zero(cnf->pin) &&
!ast_test_flag(&confflags, CONFFLAG_ADMIN)) ||
(!ast_strlen_zero(cnf->pinadmin) &&
ast_test_flag(&confflags, CONFFLAG_ADMIN))) {
char pin[AST_MAX_EXTENSION]=""; char pin[AST_MAX_EXTENSION]="";
int j; int j;
/* Allow the pin to be retried up to 3 times */ /* Allow the pin to be retried up to 3 times */
for (j=0; j<3; j++) { for (j = 0; j < 3; j++) {
if (*the_pin && (always_prompt==0)) { if (*the_pin && (always_prompt == 0)) {
ast_copy_string(pin, the_pin, sizeof(pin)); ast_copy_string(pin, the_pin, sizeof(pin));
res = 0; res = 0;
} else { } else {
@@ -1877,8 +1885,9 @@ static int conf_exec(struct ast_channel *chan, void *data)
res = ast_app_getdata(chan, "conf-getpin", pin + strlen(pin), sizeof(pin) - 1 - strlen(pin), 0); res = ast_app_getdata(chan, "conf-getpin", pin + strlen(pin), sizeof(pin) - 1 - strlen(pin), 0);
} }
if (res >= 0) { if (res >= 0) {
if (!strcasecmp(pin, cnf->pin) || (!ast_strlen_zero(cnf->pinadmin) && !strcasecmp(pin, cnf->pinadmin))) { if (!strcasecmp(pin, cnf->pin) ||
(!ast_strlen_zero(cnf->pinadmin) &&
!strcasecmp(pin, cnf->pinadmin))) {
/* Pin correct */ /* Pin correct */
allowretry = 0; allowretry = 0;
if (!ast_strlen_zero(cnf->pinadmin) && !strcasecmp(pin, cnf->pinadmin)) if (!ast_strlen_zero(cnf->pinadmin) && !strcasecmp(pin, cnf->pinadmin))
@@ -1936,9 +1945,10 @@ static int conf_exec(struct ast_channel *chan, void *data)
static struct ast_conf_user* find_user(struct ast_conference *conf, char *callerident) { static struct ast_conf_user* find_user(struct ast_conference *conf, char *callerident) {
struct ast_conf_user *user = NULL; struct ast_conf_user *user = NULL;
char usrno[1024] = ""; char usrno[1024] = "";
if (conf && callerident) { if (conf && callerident) {
user = conf->firstuser; user = conf->firstuser;
while(user) { while (user) {
snprintf(usrno, sizeof(usrno), "%d", user->user_no); snprintf(usrno, sizeof(usrno), "%d", user->user_no);
if (strcmp(usrno, callerident) == 0) if (strcmp(usrno, callerident) == 0)
return user; return user;
@@ -1972,11 +1982,9 @@ static int admin_exec(struct ast_channel *chan, void *data) {
LOCAL_USER_REMOVE(u); LOCAL_USER_REMOVE(u);
return -1; return -1;
} }
cnf = confs; for (cnf = confs; cnf; cnf = cnf->next) {
while (cnf) { if (!strcmp(cnf->confno, conf))
if (strcmp(cnf->confno, conf) == 0)
break; break;
cnf = cnf->next;
} }
if (caller) if (caller)
@@ -2069,14 +2077,13 @@ static int admin_exec(struct ast_channel *chan, void *data) {
static void *recordthread(void *args) static void *recordthread(void *args)
{ {
struct ast_conference *cnf; struct ast_conference *cnf = args;
struct ast_frame *f=NULL; struct ast_frame *f=NULL;
int flags; int flags;
struct ast_filestream *s; struct ast_filestream *s;
int res=0; int res=0;
cnf = (struct ast_conference *)args; if (!cnf || !cnf->chan) {
if( !cnf || !cnf->chan ) {
pthread_exit(0); pthread_exit(0);
} }
ast_stopstream(cnf->chan); ast_stopstream(cnf->chan);
@@ -2145,7 +2152,9 @@ char *description(void)
int usecount(void) int usecount(void)
{ {
int res; int res;
STANDARD_USECOUNT(res); STANDARD_USECOUNT(res);
return res; return res;
} }