Index: apps/app_meetme.c =================================================================== RCS file: /usr/cvsroot/asterisk/apps/app_meetme.c,v retrieving revision 1.70 diff -u -r1.70 app_meetme.c --- apps/app_meetme.c 14 Jan 2005 05:10:00 -0000 1.70 +++ apps/app_meetme.c 18 Jan 2005 10:45:27 -0000 @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -60,6 +61,7 @@ "The option string may contain zero or more of the following characters:\n" " 'm' -- set monitor only mode (Listen only, no talking)\n" " 't' -- set talk only mode. (Talk only, no listening)\n" +" 'T' -- set talker detection (sent to manager interface and meetme list)\n" " 'i' -- announce user join/leave\n" " 'p' -- allow user to exit the conference by pressing '#'\n" " 'X' -- allow user to exit the conference by entering a valid single\n" @@ -127,6 +129,7 @@ int userflags; /* Flags as set in the conference */ int adminflags; /* Flags set by the Admin */ struct ast_channel *chan; /* Connected channel */ + int talking; /* Is user talking */ char usrvalue[50]; /* Custom User Value */ char namerecloc[AST_MAX_EXTENSION]; /* Name Recorded file Location */ time_t jointime; /* Time the user joined the conference */ @@ -162,6 +165,7 @@ #define CONFFLAG_EXIT_CONTEXT (1 << 12) /* If set, the MeetMe will exit to the specified context */ #define CONFFLAG_MARKEDUSER (1 << 13) /* If set, the user will be marked */ #define CONFFLAG_INTROUSER (1 << 14) /* If set, user will be ask record name on entry of conference */ +#define CONFFLAG_MONITORTALKER (1 << 15) /* If set, the user will be monitored if the user is talking or not */ static int careful_write(int fd, unsigned char *data, int len) { @@ -394,7 +398,7 @@ /* Show all the users */ user = cnf->firstuser; while(user) { - ast_cli(fd, "User #: %i Channel: %s %s %s %s\n", user->user_no, user->chan->name, (user->userflags & CONFFLAG_ADMIN) ? "(Admin)" : "", (user->userflags & CONFFLAG_MONITOR) ? "(Listen only)" : "", (user->adminflags & ADMINFLAG_MUTED) ? "(Admn Muted)" : "" ); + ast_cli(fd, "User #: %i Channel: %s %s %s %s %d\n", user->user_no, user->chan->name, (user->userflags & CONFFLAG_ADMIN) ? "(Admin)" : "", (user->userflags & CONFFLAG_MONITOR) ? "(Listen only)" : "", (user->adminflags & ADMINFLAG_MUTED) ? "(Admn Muted)" : "", (user->talking == -1 ? -1 : user->talking)); user = user->nextuser; } return RESULT_SUCCESS; @@ -522,6 +526,7 @@ int menu_active = 0; int using_pseudo = 0; int duration=20; + struct ast_dsp *dsp=NULL; struct ast_app *app; char *agifile; @@ -580,6 +585,7 @@ user->chan = chan; user->userflags = confflags; user->adminflags = 0; + user->talking = -1; ast_mutex_unlock(&conflock); origquiet = confflags & CONFFLAG_QUIET; if (confflags & CONFFLAG_EXIT_CONTEXT) { @@ -774,6 +780,10 @@ x = 1; ast_channel_setoption(chan,AST_OPTION_TONE_VERIFY,&x,sizeof(char),0); } + if (confflags & CONFFLAG_MONITORTALKER && !(dsp = ast_dsp_new())) { + ast_log(LOG_WARNING, "Unable to allocate DSP!\n"); + res = -1; + } for(;;) { outfd = -1; ms = -1; @@ -852,7 +862,38 @@ f = ast_read(c); if (!f) break; - if ((f->frametype == AST_FRAME_DTMF) && (confflags & CONFFLAG_EXIT_CONTEXT)) { + if ((f->frametype == AST_FRAME_VOICE) && (f->subclass == AST_FORMAT_SLINEAR)) { + int totalsilence; + int ms; + if (confflags & CONFFLAG_MONITORTALKER) { + if (user->talking == -1) + user->talking = 0; + + res = ast_dsp_silence(dsp, f, &totalsilence); + if (totalsilence < 300 && !user->talking) { + user->talking = 1; + manager_event(EVENT_FLAG_CALL, "MeetmeTalking", + "Channel: %s\r\n" + "Uniqueid: %s\r\n" + "Meetme: %s\r\n" + "Usernum: %i\r\n", + chan->name, chan->uniqueid, conf->confno, user->user_no); + + user->talking = 1; + } + if (totalsilence > 1000 && user->talking) { + user->talking = 0; + manager_event(EVENT_FLAG_CALL, "MeetmeStopTalking", + "Channel: %s\r\n" + "Uniqueid: %s\r\n" + "Meetme: %s\r\n" + "Usernum: %i\r\n", + chan->name, chan->uniqueid, conf->confno, user->user_no); + + user->talking = 0; + } + } + } else if ((f->frametype == AST_FRAME_DTMF) && (confflags & CONFFLAG_EXIT_CONTEXT)) { char tmp[2]; tmp[0] = f->subclass; tmp[1] = '\0'; @@ -1043,6 +1084,9 @@ outrun: ast_mutex_lock(&conflock); + if (confflags & CONFFLAG_MONITORTALKER && dsp) + ast_dsp_free(dsp); + if (user->user_no) { /* Only cleanup users who really joined! */ manager_event(EVENT_FLAG_CALL, "MeetmeLeave", "Channel: %s\r\n" @@ -1263,6 +1307,8 @@ if (inflags) { if (strchr(inflags, 'a')) confflags |= CONFFLAG_ADMIN; + if (strchr(inflags, 'T')) + confflags |= CONFFLAG_MONITORTALKER; if (strchr(inflags, 'i')) confflags |= CONFFLAG_INTROUSER; if (strchr(inflags, 'm'))