[Asterisk-cvs] asterisk/apps app_meetme.c,1.46,1.47

markster at lists.digium.com markster at lists.digium.com
Wed Jun 23 01:09:09 CDT 2004


Update of /usr/cvsroot/asterisk/apps
In directory mongoose.digium.com:/tmp/cvs-serv26233/apps

Modified Files:
	app_meetme.c 
Log Message:
Add 'w' option to meetme which causes us to wait for a "marked" user to enter the bridge


Index: app_meetme.c
===================================================================
RCS file: /usr/cvsroot/asterisk/apps/app_meetme.c,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -d -r1.46 -r1.47
--- app_meetme.c	22 Jun 2004 19:32:52 -0000	1.46
+++ app_meetme.c	23 Jun 2004 04:55:04 -0000	1.47
@@ -67,6 +67,7 @@
 "      'q' -- quiet mode (don't play enter/leave sounds)\n"
 "      'M' -- enable music on hold when the conference has a single caller\n"
 "      'x' -- exit the conference if the last marked user left\n"
+"      'w' -- wait until a marked user has entered the conference\n"
 "      'b' -- run AGI script specified in ${MEETME_AGI_BACKGROUND}\n"
 "         Default: conf-background.agi\n"
 "        (Note: This does not work with non-Zap channels in the same conference)\n"
@@ -146,6 +147,7 @@
 #define CONFFLAG_AGI (1 << 8)		/* Set to run AGI Script in Background */
 #define CONFFLAG_MOH (1 << 9)		/* Set to have music on hold when user is alone in conference */
 #define CONFFLAG_ADMINEXIT (1 << 10)    /* If set the MeetMe will return if all marked with this flag left */
+#define CONFFLAG_WAITMARKED (1 << 11)		/* If set, the MeetMe will wait until a marked user enters */
 
 
 static int careful_write(int fd, unsigned char *data, int len)
@@ -464,6 +466,16 @@
 	{ "meetme", NULL, NULL }, conf_cmd,
 	"Execute a command on a conference or conferee", conf_usage, complete_confcmd };
 
+static int confnonzero(void *ptr)
+{
+	struct ast_conference *conf = ptr;
+	int res;
+	ast_mutex_lock(&conflock);
+	res = (conf->markedusers < 0);
+	ast_mutex_unlock(&conflock);
+	return res;
+}
+
 static int conf_run(struct ast_channel *chan, struct ast_conference *conf, int confflags)
 {
 	struct ast_conference *prev=NULL, *cur;
@@ -482,6 +494,7 @@
 	int origfd;
 	int musiconhold = 0;
 	int firstpass = 0;
+	int origquiet;
 	int ret = -1;
 	int x;
 	int menu_active = 0;
@@ -504,7 +517,6 @@
 			ast_waitstream(chan, "");
 		goto outrun;
 	}
-	
 	conf->users++;
 	if (confflags & CONFFLAG_ADMINEXIT) {
 		if (conf->markedusers == -1) {
@@ -540,10 +552,36 @@
 	user->userflags = confflags;
 	user->adminflags = 0;
 	ast_mutex_unlock(&conflock);
+	origquiet = confflags & CONFFLAG_QUIET;
+	while((confflags & CONFFLAG_WAITMARKED) && (conf->markedusers < 0)) {
+		confflags &= ~CONFFLAG_QUIET;
+		confflags |= origquiet;
+		/* XXX Announce that we're waiting on the conference lead to join */
+		if (!(confflags & CONFFLAG_QUIET)) {
+			res = ast_streamfile(chan, "vm-dialout", chan->language);
+			if (!res)
+				res = ast_waitstream(chan, "");
+		} else
+			res = 0;
+		/* If we're waiting with hold music, set to silent mode */
+		if (!res) {
+			confflags |= CONFFLAG_QUIET;
+			ast_moh_start(chan, NULL);
+			res = ast_safe_sleep_conditional(chan, 60000, confnonzero, conf);
+			ast_moh_stop(chan);
+		}
+		if (res < 0) {
+			ast_log(LOG_DEBUG, "Got hangup on '%s' already\n", chan->name);
+			goto outrun;
+		}
+	}
 	
 	if (!(confflags & CONFFLAG_QUIET) && conf->users == 1) {
-		if (!ast_streamfile(chan, "conf-onlyperson", chan->language))
-			ast_waitstream(chan, "");
+		if (!ast_streamfile(chan, "conf-onlyperson", chan->language)) {
+			if (ast_waitstream(chan, "") < 0)
+				goto outrun;
+		} else
+			goto outrun;
 	}
 
 	/* Set it into linear mode (write) */
@@ -1137,6 +1175,8 @@
 			confflags |= CONFFLAG_ADMINEXIT;
 		if (strchr(inflags, 'b'))
 			confflags |= CONFFLAG_AGI;
+		if (strchr(inflags, 'w'))
+			confflags |= CONFFLAG_WAITMARKED;
 		if (strchr(inflags, 'd'))
 			dynamic = 1;
 		if (strchr(inflags, 'D')) {




More information about the svn-commits mailing list