Index: apps/app_meetme.c =================================================================== --- apps/app_meetme.c (revision 48388) +++ apps/app_meetme.c (working copy) @@ -5,7 +5,7 @@ * * Mark Spencer * - * See http://www.asterisk.org for more information about + * See http://www.asterisk.org for more information aboutwh * the Asterisk project. Please do not directly contact * any of the maintainers of this project for assistance; * the project provides a web site, mailing lists and IRC @@ -72,7 +72,8 @@ enum { ADMINFLAG_MUTED = (1 << 1), /*!< User is muted */ ADMINFLAG_SELFMUTED = (1 << 2), /*!< User muted self */ - ADMINFLAG_KICKME = (1 << 3) /*!< User has been kicked */ + ADMINFLAG_KICKME = (1 << 3), /*!< User has been kicked */ + ADMINFLAG_WHISPER = (1 << 4) /*!name, chan->uniqueid, conf->confno, user->user_no); - } - + } + + /* If whisper mode */ + if (user->adminflags & ADMINFLAG_WHISPER) { + user->adminflags ^= ADMINFLAG_WHISPER; + /* Separate user from conference audio stream temporarily */ + struct zt_confinfo ztc_curr; + memset(&ztc_curr, 0, sizeof(ztc_curr)); + if (!ioctl(fd, ZT_GETCONF, &ztc_curr)) { + ztc.confmode |= ZT_CONF_TALKER; + ztc.confmode ^= ZT_CONF_LISTENER; + if (ioctl(fd, ZT_SETCONF, &ztc)) { + ast_log(LOG_WARNING, "Error setting conference\n"); + } + + /* whisper the message */ + if (!ast_streamfile(user->chan, user->whisperfile, user->chan->language)) { + ast_waitstream(user->chan, AST_DIGIT_ANY); + } + + /* Restore user's audio stream from the conference */ + if (ioctl(fd, ZT_SETCONF, &ztc_curr)) { + ast_log(LOG_WARNING, "Error setting conference\n"); + } + + /* Restore musiconhold */ + if (((musiconhold) && (confflags & CONFFLAG_MOH)) && + (((confflags & CONFFLAG_WAITMARKED) && (currentmarked == 0)) + || (!(confflags & CONFFLAG_WAITMARKED) && (conf->users == 1))) ) { + ast_moh_start(user->chan, NULL, NULL); + } + } else { + ast_log(LOG_WARNING, "Error getting conference\n"); + } + } + /* If I have been kicked, exit the conference */ if (user->adminflags & ADMINFLAG_KICKME) { //You have been kicked. @@ -1550,6 +1590,18 @@ f = ast_read(c); if (!f) break; + + /* Send UserEvent to manager if CONFFLAG_DTMF is turned on, can be used to customize key functionality through manager interface */ + if((f->frametype == AST_FRAME_DTMF) && (confflags & CONFFLAG_DTMF)) { + manager_event(EVENT_FLAG_CALL, "DTMFEvent", + "Channel: %s\r\n" + "Uniqueid: %s\r\n" + "Meetme: %s\r\n" + "Usernum: %d\r\n" + "Status: %c\r\n", + chan->name, chan->uniqueid, conf->confno, user->user_no, f->subclass); + } + if ((f->frametype == AST_FRAME_VOICE) && (f->subclass == AST_FORMAT_SLINEAR)) { if (user->talk.actual) ast_frame_adjust_volume(f, user->talk.actual); @@ -2848,6 +2900,73 @@ return meetmemute(s, m, 0); } +static int action_meetmewhisper(struct mansession *s, struct message *m) +{ + struct ast_conference *conf; + struct ast_conf_user *user; + char *confid = astman_get_header(m, "Meetme"); + char *userid = astman_get_header(m, "Usernum"); + char *message = astman_get_header(m, "Message"); + int userno; + + if (!confid || ast_strlen_zero(confid)) { + astman_send_error(s, m, "Meetme conference not specified"); + return 0; + } + + if (!userid || ast_strlen_zero(userid)) { + astman_send_error(s, m, "Meetme user number not specified"); + return 0; + } + + if (!message || ast_strlen_zero(message)) { + astman_send_error(s, m, "Meetme whisper message not specified"); + return 0; + } + + userno = strtoul(userid, &userid, 10); + + if (*userid) { + astman_send_error(s, m, "Invalid user number"); + return 0; + } + + /* Look in the conference list */ + AST_LIST_LOCK(&confs); + AST_LIST_TRAVERSE(&confs, conf, list) { + if (!strcmp(confid, conf->confno)) + break; + } + + if (!conf) { + AST_LIST_UNLOCK(&confs); + astman_send_error(s, m, "Meetme conference does not exist"); + return 0; + } + + AST_LIST_TRAVERSE(&conf->userlist, user, list) + if (user->user_no == userno) + break; + + if (!user) { + AST_LIST_UNLOCK(&confs); + astman_send_error(s, m, "User number not found"); + return 0; + } + + user->whisperfile = realloc(user->whisperfile, strlen(message)); + strcpy(user->whisperfile, message); + + user->adminflags |= ADMINFLAG_WHISPER; /* request user whisper, disconnect from rest of conference stream to prevent mixing */ + AST_LIST_UNLOCK(&confs); + + ast_log(LOG_NOTICE, "Requested to whisper conf %s user %d userchan %s uniqueid %s\n", conf->confno, user->user_no, user->chan->name, user->chan->uniqueid); + + astman_send_ack(s, m, "Whispered user"); + return 0; +} + + static void *recordthread(void *args) { struct ast_conference *cnf = args; @@ -3096,6 +3215,7 @@ ast_cli_unregister_multiple(cli_meetme, sizeof(cli_meetme) / sizeof(struct ast_cli_entry)); res = ast_manager_unregister("MeetmeMute"); res |= ast_manager_unregister("MeetmeUnmute"); + res |= ast_manager_unregister("MeetmeWhisper"); res |= ast_unregister_application(app3); res |= ast_unregister_application(app2); res |= ast_unregister_application(app); @@ -3117,6 +3237,7 @@ ast_cli_register_multiple(cli_meetme, sizeof(cli_meetme) / sizeof(struct ast_cli_entry)); res = ast_manager_register("MeetmeMute", EVENT_FLAG_CALL, action_meetmemute, "Mute a Meetme user"); res |= ast_manager_register("MeetmeUnmute", EVENT_FLAG_CALL, action_meetmeunmute, "Unmute a Meetme user"); + res |= ast_manager_register("MeetmeWhisper", EVENT_FLAG_CALL, action_meetmewhisper, "Whisper a specific channel"); res |= ast_register_application(app3, admin_exec, synopsis3, descrip3); res |= ast_register_application(app2, count_exec, synopsis2, descrip2); res |= ast_register_application(app, conf_exec, synopsis, descrip);