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

FreeSWITCH SVN anthm at freeswitch.org
Thu Apr 23 10:53:51 PDT 2009


Author: anthm
Date: Thu Apr 23 12:53:51 2009
New Revision: 13135

Log:
add mute-detect flag to conference

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

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	Thu Apr 23 12:53:51 2009
@@ -143,7 +143,8 @@
 	MFLAG_HAS_AUDIO = (1 << 10),
 	MFLAG_TALKING = (1 << 11),
 	MFLAG_RESTART = (1 << 12),
-	MFLAG_MINTWO = (1 << 13)
+	MFLAG_MINTWO = (1 << 13),
+	MFLAG_MUTE_DETECT = (1 << 14)
 } member_flag_t;
 
 typedef enum {
@@ -191,7 +192,8 @@
 	EFLAG_UNLOCK = (1 << 22),
 	EFLAG_TRANSFER = (1 << 23),
 	EFLAG_BGDIAL_RESULT = (1 << 24),
-	EFLAG_FLOOR_CHANGE = (1 << 25)
+	EFLAG_FLOOR_CHANGE = (1 << 25),
+	EFLAG_MUTE_DETECT = (1 << 26)
 } event_type_t;
 
 typedef struct conference_file_node {
@@ -225,6 +227,7 @@
 	char *ack_sound;
 	char *nack_sound;
 	char *muted_sound;
+	char *mute_detect_sound;
 	char *unmuted_sound;
 	char *locked_sound;
 	char *is_locked_sound;
@@ -1642,7 +1645,7 @@
 
 		/* if the member can speak, compute the audio energy level and */
 		/* generate events when the level crosses the threshold        */
-		if (switch_test_flag(member, MFLAG_CAN_SPEAK) && energy_level) {
+		if ((switch_test_flag(member, MFLAG_CAN_SPEAK) || switch_test_flag(member, MFLAG_MUTE_DETECT)) && energy_level) {
 			uint32_t energy = 0, i = 0, samples = 0, j = 0;
 			int16_t *data;
 			int divisor = 0;
@@ -1698,6 +1701,22 @@
 							switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Action", "start-talking");
 							switch_event_fire(&event);
 						}
+						
+						if (switch_test_flag(member, MFLAG_MUTE_DETECT) && !switch_test_flag(member, MFLAG_CAN_SPEAK)) {
+
+							if (!switch_strlen_zero(member->conference->mute_detect_sound)) {
+								conference_member_play_file(member, member->conference->mute_detect_sound, 0);
+							}
+
+							if (test_eflag(member->conference, EFLAG_MUTE_DETECT) &&
+								switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
+								conference_add_event_member_data(member, event);
+								switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Action", "mute-detect");
+								switch_event_fire(&event);
+							}
+
+						}
+						
 					}
 				}
 			} else {
@@ -4390,25 +4409,36 @@
 static void set_mflags(char *flags, member_flag_t *f)
 {
 	if (flags) {
-		if (strstr(flags, "mute")) {
-			*f &= ~MFLAG_CAN_SPEAK;
-		}
+		char *dup = strdup(flags);
+		char *p;
+		char *argv[10] = { 0 };
+		int i, argc = 0;
 
-		if (strstr(flags, "deaf")) {
-			*f &= ~MFLAG_CAN_HEAR;
+		for(p = dup; p && *p; p++) {
+			if (*p == ',') {
+				*p = '|';
+			}
 		}
 
-		if (strstr(flags, "waste")) {
-			*f |= MFLAG_WASTE_BANDWIDTH;
-		}
+		argc = switch_separate_string(dup, '|', argv, (sizeof(argv) / sizeof(argv[0])));
 
-		if (strstr(flags, "endconf")) {
-			*f |= MFLAG_ENDCONF;
+		for(i = 0; i < argc; i++) {
+			if (!strcasecmp(argv[i], "mute")) {
+				*f &= ~MFLAG_CAN_SPEAK;
+			} else if (!strcasecmp(argv[i], "deaf")) {
+				*f &= ~MFLAG_CAN_HEAR;
+			} else if (!strcasecmp(argv[i], "waste")) {
+				*f |= MFLAG_WASTE_BANDWIDTH;
+			} else if (!strcasecmp(argv[i], "mute-detect")) {
+				*f |= MFLAG_MUTE_DETECT;
+			} else if (!strcasecmp(argv[i], "endconf")) {
+				*f |= MFLAG_ENDCONF;
+			} else if (!strcasecmp(argv[i], "mintwo")) {
+				*f |= MFLAG_MINTWO;
+			}
 		}
 
-		if (strstr(flags, "mintwo")) {
-			*f |= MFLAG_MINTWO;
-		}
+		free(dup);
 	}
 }
 
@@ -4443,6 +4473,8 @@
 				*f &= ~EFLAG_STOP_TALKING;
 			} else if (!strcmp(event, "start-talking")) {
 				*f &= ~EFLAG_START_TALKING;
+			} else if (!strcmp(event, "mute-detect")) {
+				*f &= ~EFLAG_MUTE_DETECT;
 			} else if (!strcmp(event, "mute-member")) {
 				*f &= ~EFLAG_MUTE_MEMBER;
 			} else if (!strcmp(event, "unmute-member")) {
@@ -5282,6 +5314,7 @@
 	char *ack_sound = NULL;
 	char *nack_sound = NULL;
 	char *muted_sound = NULL;
+	char *mute_detect_sound = NULL;
 	char *unmuted_sound = NULL;
 	char *locked_sound = NULL;
 	char *is_locked_sound = NULL;
@@ -5370,6 +5403,8 @@
 			nack_sound = val;
 		} else if (!strcasecmp(var, "muted-sound") && !switch_strlen_zero(val)) {
 			muted_sound = val;
+		} else if (!strcasecmp(var, "mute-detect-sound") && !switch_strlen_zero(val)) {
+			mute_detect_sound = val;
 		} else if (!strcasecmp(var, "unmuted-sound") && !switch_strlen_zero(val)) {
 			unmuted_sound = val;
 		} else if (!strcasecmp(var, "locked-sound") && !switch_strlen_zero(val)) {
@@ -5525,6 +5560,14 @@
 		conference->muted_sound = switch_core_strdup(conference->pool, muted_sound);
 	}
 
+	if (switch_strlen_zero(mute_detect_sound)) {
+		if (!switch_strlen_zero(muted_sound)) {
+			conference->mute_detect_sound = switch_core_strdup(conference->pool, muted_sound);
+		}
+	} else {
+		conference->mute_detect_sound = switch_core_strdup(conference->pool, mute_detect_sound);
+	}
+
 	if (!switch_strlen_zero(unmuted_sound)) {
 		conference->unmuted_sound = switch_core_strdup(conference->pool, unmuted_sound);
 	}



More information about the Freeswitch-svn mailing list