[Freeswitch-svn] [commit] r1811 - freeswitch/trunk/src/mod/applications/mod_conference

Freeswitch SVN anthm at freeswitch.org
Mon Jul 10 12:28:55 EDT 2006


Author: anthm
Date: Mon Jul 10 12:28:54 2006
New Revision: 1811

Modified:
   freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c

Log:
add ability to set mute and deaf flag from the dialplan +flags{<mute>|<deaf>} 

Modified: freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c	(original)
+++ freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c	Mon Jul 10 12:28:54 2006
@@ -676,8 +676,6 @@
 		char *digit;
 		char msg[512];
 
-		switch_core_timer_next(&timer);
-
         if (switch_channel_has_dtmf(channel)) {
             switch_channel_dequeue_dtmf(channel, dtmf, sizeof(dtmf));
         }
@@ -863,28 +861,33 @@
 						switch_buffer_zero(member->mux_buffer);
 						switch_mutex_unlock(member->audio_out_mutex);
 					}
+					switch_core_timer_next(&timer);
 				}
 			}
 		} else {
-			/* Flush the output buffer and write all the data (presumably muxed) back to the channel */
-			switch_mutex_lock(member->audio_out_mutex);
-			write_frame.data = data;
-			while ((write_frame.datalen = (uint32_t)switch_buffer_read(member->mux_buffer, write_frame.data, bytes))) {
-				if (write_frame.datalen && switch_test_flag(member, MFLAG_CAN_HEAR)) {
-					write_frame.samples = write_frame.datalen / 2;
+			if (switch_buffer_inuse(member->mux_buffer)) {
+				/* Flush the output buffer and write all the data (presumably muxed) back to the channel */
+				switch_mutex_lock(member->audio_out_mutex);
+				write_frame.data = data;
+				while ((write_frame.datalen = (uint32_t)switch_buffer_read(member->mux_buffer, write_frame.data, bytes))) {
+					if (write_frame.datalen && switch_test_flag(member, MFLAG_CAN_HEAR)) {
+						write_frame.samples = write_frame.datalen / 2;
+						
+						/* Check for output volume adjustments */
+						if (member->volume_out_level) {
+							switch_change_sln_volume(write_frame.data, write_frame.samples, member->volume_out_level);
+						}
 
-					/* Check for output volume adjustments */
-					if (member->volume_out_level) {
-						switch_change_sln_volume(write_frame.data, write_frame.samples, member->volume_out_level);
+						switch_core_session_write_frame(member->session, &write_frame, -1, 0);
 					}
-
-					switch_core_session_write_frame(member->session, &write_frame, -1, 0);
 				}
+				switch_mutex_unlock(member->audio_out_mutex);
+			} else {
+				switch_core_timer_next(&timer);
 			}
-			switch_mutex_unlock(member->audio_out_mutex);
 		}
 	} /* Rinse ... Repeat */
-
+	
 	switch_clear_flag_locked(member, MFLAG_RUNNING);
 	switch_core_timer_destroy(&timer);
 
@@ -2076,10 +2079,13 @@
 	char *mydata = switch_core_session_strdup(session, data);
 	char *conf_name = NULL;
 	char *bridge_prefix = "bridge:";
+	char *flags_prefix = "+flags{";
 	char *bridgeto = NULL;
 	char *profile_name = NULL;
 	switch_xml_t cxml = NULL, cfg = NULL, profile = NULL, profiles = NULL;
-
+	char *flags_str;
+	member_flag_t uflags = MFLAG_CAN_SPEAK | MFLAG_CAN_HEAR;
+	
 	channel = switch_core_session_get_channel(session);
     assert(channel != NULL);
 
@@ -2094,6 +2100,23 @@
 		return;
 	}
 
+
+	if ((flags_str=strstr(mydata, flags_prefix))) {
+		char *p;
+
+		*flags_str = '\0';
+		flags_str += strlen(flags_prefix);
+		if ((p = strchr(flags_str, '}'))) {
+			*p = '\0';
+		}
+
+		if (strstr(flags_str, "mute")) {
+			uflags &= ~MFLAG_CAN_SPEAK;
+		} else if (strstr(flags_str, "deaf")) {
+			uflags &= ~MFLAG_CAN_HEAR;
+		}
+	}
+
 	if (!strncasecmp(mydata, bridge_prefix, strlen(bridge_prefix))) {
 		char *uuid = switch_core_session_get_uuid(session);
 		
@@ -2269,7 +2292,7 @@
 	if (conference_add_member(conference, &member) != SWITCH_STATUS_SUCCESS) {
 		goto codec_done1;
 	}
-	switch_set_flag_locked((&member), MFLAG_RUNNING | MFLAG_CAN_SPEAK | MFLAG_CAN_HEAR);
+	switch_set_flag_locked((&member), MFLAG_RUNNING | uflags);
 
 	/* Run the confernece loop */
 	conference_loop(&member);



More information about the Freeswitch-svn mailing list