--- asterisk-1.2.5.org/apps/app_meetme.c	2006-03-06 11:19:23.000000000 +0100
+++ asterisk-1.2.5/apps/app_meetme.c	2006-03-06 15:18:51.000000000 +0100
@@ -84,6 +84,10 @@
 "      'e' -- select an empty conference\n"
 "      'E' -- select an empty pinless conference\n"
 "      'i' -- announce user join/leave\n"
+"             Setting ${MEETME_PRERECINTROUSER} to an existing sound file (.sln)"
+"             containing a pre-recorded intro for the user will make meetme use it\n"
+"             instead of asking the user to record his intro when logging in to\n"
+"             the conference\n"
 "      'm' -- set monitor only mode (Listen only, no talking)\n"
 "      'M' -- enable music on hold when the conference has a single caller\n"
 "      'p' -- allow user to exit the conference by pressing '#'\n"
@@ -95,6 +99,10 @@
 "      's' -- Present menu (user or admin) when '*' is received ('send' to menu)\n"
 "      't' -- set talk only mode. (Talk only, no listening)\n"
 "      'T' -- set talker detection (sent to manager interface and meetme list)\n"
+"      'o' -- set talker optimization - treats talkers who aren't speaking as\n"
+"             being muted, meaning (a) No encode is done on transmission and\n"
+"             (b) Received audio that is not registered as talking is omitted\n"
+"             causing no buildup in background noise\n"
 "      'v' -- video mode\n"
 "      'w' -- wait until the marked user enters the conference\n"
 "      'x' -- close the conference when last marked user exits\n"
@@ -227,12 +235,14 @@
 #define CONFFLAG_EMPTYNOPIN (1 << 20)
 #define CONFFLAG_ALWAYSPROMPT (1 << 21)
 #define CONFFLAG_ANNOUNCEUSERCOUNT (1 << 22)	/* If set, when user joins the conference, they will be told the number of users that are already in */
+#define CONFFLAG_OPTIMIZETALKER (1 << 23)      /* If set, treats talking users as muted users */
 
 
 AST_APP_OPTIONS(meetme_opts, {
 	AST_APP_OPTION('a', CONFFLAG_ADMIN ),
 	AST_APP_OPTION('c', CONFFLAG_ANNOUNCEUSERCOUNT ),
 	AST_APP_OPTION('T', CONFFLAG_MONITORTALKER ),
+	AST_APP_OPTION('o', CONFFLAG_OPTIMIZETALKER ),
 	AST_APP_OPTION('i', CONFFLAG_INTROUSER ),
 	AST_APP_OPTION('m', CONFFLAG_MONITOR ),
 	AST_APP_OPTION('p', CONFFLAG_POUNDEXIT ),
@@ -821,6 +831,7 @@
 	char meetmesecs[30] = "";
 	char exitcontext[AST_MAX_CONTEXT] = "";
 	char recordingtmp[AST_MAX_EXTENSION] = "";
+	char *preintrousertmp;
 	int dtmf;
 	ZT_BUFFERINFO bi;
 	char __buf[CONF_SIZE + AST_FRIENDLY_OFFSET];
@@ -901,7 +912,16 @@
 		snprintf(user->namerecloc, sizeof(user->namerecloc),
 			 "%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);
+		/* checking pre-recorded user intro */
+		if ((preintrousertmp = pbx_builtin_getvar_helper(chan, "MEETME_PRERECINTROUSER")) && (ast_fileexists(preintrousertmp, "sln", NULL) > 0)) {
+			if (option_verbose > 1)
+				ast_verbose(VERBOSE_PREFIX_2 "Pre-recorded user intro is: '%s'\n", preintrousertmp);
+			ast_filecopy(preintrousertmp, user->namerecloc, "sln");
+		} else {
+			if (option_verbose > 1)
+				ast_verbose(VERBOSE_PREFIX_2 "Pre-recorded user intro not present: recording new intro\n");
+			ast_record_review(chan, "vm-rec-name", user->namerecloc, 10, "sln", &duration, NULL);
+		}
 	}
 
 	if (!(confflags & CONFFLAG_QUIET)) {
@@ -1106,7 +1126,7 @@
 			x = 1;
 			ast_channel_setoption(chan, AST_OPTION_TONE_VERIFY, &x, sizeof(char), 0);
 		}	
-		if (confflags & CONFFLAG_MONITORTALKER && !(dsp = ast_dsp_new())) {
+		if (confflags & (CONFFLAG_MONITORTALKER | CONFFLAG_OPTIMIZETALKER) && !(dsp = ast_dsp_new())) {
 			ast_log(LOG_WARNING, "Unable to allocate DSP!\n");
 			res = -1;
 		}
@@ -1276,7 +1296,7 @@
 					if (user->talk.actual)
 						ast_frame_adjust_volume(f, user->talk.actual);
 
-					if (confflags &  CONFFLAG_MONITORTALKER) {
+					if (confflags & (CONFFLAG_MONITORTALKER | CONFFLAG_OPTIMIZETALKER)) {
 						int totalsilence;
 
 						if (user->talking == -1)
@@ -1315,7 +1335,8 @@
 						   don't want to block, but we do want to at least *try*
 						   to write out all the samples.
 						 */
-						careful_write(fd, f->data, f->datalen, 0);
+						if (user->talking || !(confflags & CONFFLAG_OPTIMIZETALKER))
+							careful_write(fd, f->data, f->datalen, 0);
 					}
 				} else if ((f->frametype == AST_FRAME_DTMF) && (confflags & CONFFLAG_EXIT_CONTEXT)) {
 					char tmp[2];
@@ -1561,7 +1582,7 @@
  outrun:
 	ast_mutex_lock(&conflock);
 
-	if (confflags & CONFFLAG_MONITORTALKER && dsp)
+	if (dsp)
 		ast_dsp_free(dsp);
 	
 	if (user->user_no) { /* Only cleanup users who really joined! */
