[asterisk-commits] rmudgett: branch rmudgett/bridge_tasks r388689 - in /team/rmudgett/bridge_tas...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue May 14 10:48:14 CDT 2013


Author: rmudgett
Date: Tue May 14 10:48:11 2013
New Revision: 388689

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=388689
Log:
Add bridge mute get/set routines.

The deadlock potential between the ast_bridge and the
confbridge_conference struct locks will go away when the
confbridge_conference struct becomes subclassed from ast_bridge.

Modified:
    team/rmudgett/bridge_tasks/apps/app_confbridge.c
    team/rmudgett/bridge_tasks/apps/confbridge/conf_state.c
    team/rmudgett/bridge_tasks/apps/confbridge/conf_state_multi_marked.c
    team/rmudgett/bridge_tasks/include/asterisk/bridging.h
    team/rmudgett/bridge_tasks/main/bridging.c

Modified: team/rmudgett/bridge_tasks/apps/app_confbridge.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/bridge_tasks/apps/app_confbridge.c?view=diff&rev=388689&r1=388688&r2=388689
==============================================================================
--- team/rmudgett/bridge_tasks/apps/app_confbridge.c (original)
+++ team/rmudgett/bridge_tasks/apps/app_confbridge.c Tue May 14 10:48:11 2013
@@ -1252,7 +1252,7 @@
 		conf_moh_stop(first_user);
 	}
 	if (!ast_test_flag(&first_user->u_profile, USER_OPT_STARTMUTED)) {
-		first_user->features.mute = 0;
+		ast_bridge_mute_set(conference->bridge, first_user->chan, 0);
 	}
 }
 
@@ -1906,17 +1906,25 @@
 	struct confbridge_user *user,
 	struct ast_channel *chan)
 {
+	int mute;
+
+	mute = ast_bridge_mute_get(conference->bridge, user->chan);
+	if (mute < 0) {
+		return -1;
+	}
+
 	/* Mute or unmute yourself, note we only allow manipulation if they aren't waiting for a marked user or if marked users exist */
 	if (!ast_test_flag(&user->u_profile, USER_OPT_WAITMARKED) || conference->markedusers) {
-		user->features.mute = (!user->features.mute ? 1 : 0);
-		ast_test_suite_event_notify("CONF_MUTE", "Message: participant %s %s\r\nConference: %s\r\nChannel: %s", ast_channel_name(chan), user->features.mute ? "muted" : "unmuted", user->b_profile.name, ast_channel_name(chan));
-		if (user->features.mute) {
+		mute = !mute;
+		ast_bridge_mute_set(conference->bridge, user->chan, mute);
+		ast_test_suite_event_notify("CONF_MUTE", "Message: participant %s %s\r\nConference: %s\r\nChannel: %s", ast_channel_name(chan), mute ? "muted" : "unmuted", user->b_profile.name, ast_channel_name(chan));
+		if (mute) {
 			send_mute_event(chan, conference->name);
 		} else { 
 			send_unmute_event(chan, conference->name);
 		}
 	}
-	return ast_stream_and_wait(chan, (user->features.mute ?
+	return ast_stream_and_wait(chan, (mute ?
 		conf_get_sound(CONF_SOUND_MUTED, user->b_profile.sounds) :
 		conf_get_sound(CONF_SOUND_UNMUTED, user->b_profile.sounds)),
 		"");
@@ -1930,13 +1938,13 @@
 	ao2_lock(conference);
 
 	/* If already muted, then unmute */
-	conference->muted = conference->muted ? 0 : 1;
+	conference->muted = !conference->muted;
 	sound_to_play = conf_get_sound((conference->muted ? CONF_SOUND_PARTICIPANTS_MUTED : CONF_SOUND_PARTICIPANTS_UNMUTED),
 		user->b_profile.sounds);
 
 	AST_LIST_TRAVERSE(&conference->active_list, cur_user, list) {
 		if (!ast_test_flag(&cur_user->u_profile, USER_OPT_ADMIN)) {
-			cur_user->features.mute = conference->muted;
+			ast_bridge_mute_set(conference->bridge, cur_user->chan, conference->muted);
 		}
 	}
 
@@ -2497,8 +2505,8 @@
 		}
 	}
 	if (user) {
-		user->features.mute = mute;
-		ast_test_suite_event_notify("CONF_MUTE", "Message: participant %s %s\r\nConference: %s\r\nChannel: %s", ast_channel_name(user->chan), user->features.mute ? "muted" : "unmuted", conference->b_profile.name, ast_channel_name(user->chan));
+		ast_bridge_mute_set(conference->bridge, user->chan, mute);
+		ast_test_suite_event_notify("CONF_MUTE", "Message: participant %s %s\r\nConference: %s\r\nChannel: %s", ast_channel_name(user->chan), mute ? "muted" : "unmuted", conference->b_profile.name, ast_channel_name(user->chan));
 	} else {
 		res = -2;;
 	}
@@ -3202,7 +3210,7 @@
 
 	/* Turn on MOH/mute if the single participant is set up for it */
 	if (ast_test_flag(&only_user->u_profile, USER_OPT_MUSICONHOLD)) {
-		only_user->features.mute = 1;
+		ast_bridge_mute_set(conference->bridge, only_user->chan, 1);
 		conf_moh_start(only_user);
 	}
 }

Modified: team/rmudgett/bridge_tasks/apps/confbridge/conf_state.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/bridge_tasks/apps/confbridge/conf_state.c?view=diff&rev=388689&r1=388688&r2=388689
==============================================================================
--- team/rmudgett/bridge_tasks/apps/confbridge/conf_state.c (original)
+++ team/rmudgett/bridge_tasks/apps/confbridge/conf_state.c Tue May 14 10:48:11 2013
@@ -58,7 +58,7 @@
 static void conf_mute_moh_inactive_waitmarked(struct confbridge_user *user)
 {
 	/* Be sure we are muted so we can't talk to anybody else waiting */
-	user->features.mute = 1;
+	ast_bridge_mute_set(user->conference->bridge, user->chan, 1);
 	/* Start music on hold if needed */
 	if (ast_test_flag(&user->u_profile, USER_OPT_MUSICONHOLD)) {
 		conf_moh_start(user);

Modified: team/rmudgett/bridge_tasks/apps/confbridge/conf_state_multi_marked.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/bridge_tasks/apps/confbridge/conf_state_multi_marked.c?view=diff&rev=388689&r1=388688&r2=388689
==============================================================================
--- team/rmudgett/bridge_tasks/apps/confbridge/conf_state_multi_marked.c (original)
+++ team/rmudgett/bridge_tasks/apps/confbridge/conf_state_multi_marked.c Tue May 14 10:48:11 2013
@@ -105,7 +105,7 @@
 				user_iter->conference->waitingusers++;
 				/* Handle muting/moh of user_iter if necessary */
 				if (ast_test_flag(&user_iter->u_profile, USER_OPT_MUSICONHOLD)) {
-					user_iter->features.mute = 1;
+					ast_bridge_mute_set(user_iter->conference->bridge, user_iter->chan, 1);
 					conf_moh_start(user_iter);
 				}
 			}
@@ -174,7 +174,7 @@
 		}
 		/* only unmute them if they are not supposed to start muted */
 		if (!ast_test_flag(&user_iter->u_profile, USER_OPT_STARTMUTED)) {
-			user_iter->features.mute = 0;
+			ast_bridge_mute_set(user_iter->conference->bridge, user_iter->chan, 0);
 		}
 	}
 	AST_LIST_TRAVERSE_SAFE_END;

Modified: team/rmudgett/bridge_tasks/include/asterisk/bridging.h
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/bridge_tasks/include/asterisk/bridging.h?view=diff&rev=388689&r1=388688&r2=388689
==============================================================================
--- team/rmudgett/bridge_tasks/include/asterisk/bridging.h (original)
+++ team/rmudgett/bridge_tasks/include/asterisk/bridging.h Tue May 14 10:48:11 2013
@@ -1535,6 +1535,32 @@
  */
 struct ast_channel *ast_bridge_peer(struct ast_bridge *bridge, struct ast_channel *chan);
 
+/*!
+ * \brief Set the mute setting of a channel in the bridge.
+ * \since 12.0.0
+ *
+ * \param brige Bridge channel is in.
+ * \param chan Channel to set mute.
+ * \param mute_setting TRUE to enable mute
+ *
+ * \retval 0 on success.
+ * \retval -1 on error.
+ */
+int ast_bridge_mute_set(struct ast_bridge *bridge, struct ast_channel *chan, int mute_setting);
+
+/*!
+ * \brief Get the mute setting of a channel in the bridge.
+ * \since 12.0.0
+ *
+ * \param brige Bridge channel is in.
+ * \param chan Channel to get mute.
+ *
+ * \retval 0 Channel is not muted.
+ * \retval 1 Channel is muted.
+ * \retval -1 on error.
+ */
+int ast_bridge_mute_get(struct ast_bridge *bridge, struct ast_channel *chan);
+
 #if defined(__cplusplus) || defined(c_plusplus)
 }
 #endif

Modified: team/rmudgett/bridge_tasks/main/bridging.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/bridge_tasks/main/bridging.c?view=diff&rev=388689&r1=388688&r2=388689
==============================================================================
--- team/rmudgett/bridge_tasks/main/bridging.c (original)
+++ team/rmudgett/bridge_tasks/main/bridging.c Tue May 14 10:48:11 2013
@@ -4957,6 +4957,33 @@
 	return peer;
 }
 
+int ast_bridge_mute_set(struct ast_bridge *bridge, struct ast_channel *chan, int mute_setting)
+{
+	struct ast_bridge_channel *bridge_channel;
+
+	ast_bridge_lock(bridge);
+	bridge_channel = find_bridge_channel(bridge, chan);
+	if (bridge_channel) {
+		bridge_channel->features->mute = mute_setting ? 1 : 0;
+	}
+	ast_bridge_unlock(bridge);
+	return bridge_channel ? 0 : -1;
+}
+
+int ast_bridge_mute_get(struct ast_bridge *bridge, struct ast_channel *chan)
+{
+	struct ast_bridge_channel *bridge_channel;
+	int mute = -1;
+
+	ast_bridge_lock(bridge);
+	bridge_channel = find_bridge_channel(bridge, chan);
+	if (bridge_channel) {
+		mute = bridge_channel->features->mute;
+	}
+	ast_bridge_unlock(bridge);
+	return mute;
+}
+
 /*!
  * \internal
  * \brief Transfer an entire bridge to a specific destination.




More information about the asterisk-commits mailing list