[svn-commits] mmichelson: trunk r390510 - in /trunk: include/asterisk/ main/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Wed Jun 5 13:07:25 CDT 2013


Author: mmichelson
Date: Wed Jun  5 13:07:23 2013
New Revision: 390510

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=390510
Log:
Change the remove_on_pull flag on ast_bridge_hook to be a set of flags.

This change is used to make bridge hook removal more generic. This way,
depending on the circumstance, the appropriate bridge hooks may be
removed.


Modified:
    trunk/include/asterisk/bridging_features.h
    trunk/main/bridging.c

Modified: trunk/include/asterisk/bridging_features.h
URL: http://svnview.digium.com/svn/asterisk/trunk/include/asterisk/bridging_features.h?view=diff&rev=390510&r1=390509&r2=390510
==============================================================================
--- trunk/include/asterisk/bridging_features.h (original)
+++ trunk/include/asterisk/bridging_features.h Wed Jun  5 13:07:23 2013
@@ -180,6 +180,11 @@
 	unsigned int seqno;
 };
 
+enum ast_bridge_hook_remove_flags {
+	/*! The hook is removed when the channel is pulled from the bridge. */
+	AST_BRIDGE_HOOK_REMOVE_ON_PULL,
+};
+
 /* BUGBUG Need to be able to selectively remove DTMF, hangup, and interval hooks. */
 /*! \brief Structure that is the essence of a feature hook. */
 struct ast_bridge_hook {
@@ -191,8 +196,8 @@
 	ast_bridge_hook_pvt_destructor destructor;
 	/*! Unique data that was passed into us */
 	void *hook_pvt;
-	/*! TRUE if the hook is removed when the channel is pulled from the bridge. */
-	unsigned int remove_on_pull:1;
+	/*! Flags determining when hooks should be removed from a bridge channel */
+	struct ast_flags remove_flags;
 	/*! Extra hook parameters. */
 	union {
 		/*! Extra parameters for a DTMF feature hook. */

Modified: trunk/main/bridging.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/bridging.c?view=diff&rev=390510&r1=390509&r2=390510
==============================================================================
--- trunk/main/bridging.c (original)
+++ trunk/main/bridging.c Wed Jun  5 13:07:23 2013
@@ -75,7 +75,7 @@
 
 static void cleanup_video_mode(struct ast_bridge *bridge);
 static int bridge_make_compatible(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel);
-static void bridge_features_remove_on_pull(struct ast_bridge_features *features);
+static void bridge_features_remove(struct ast_bridge_features *features, enum ast_bridge_hook_remove_flags flags);
 
 /*! Default DTMF keys for built in features */
 static char builtin_features_dtmf[AST_BRIDGE_BUILTIN_END][MAXIMUM_DTMF_FEATURE_STRING];
@@ -1398,7 +1398,7 @@
  */
 static void bridge_base_pull(struct ast_bridge *self, struct ast_bridge_channel *bridge_channel)
 {
-	bridge_features_remove_on_pull(bridge_channel->features);
+	bridge_features_remove(bridge_channel->features, AST_BRIDGE_HOOK_REMOVE_ON_PULL);
 }
 
 /*!
@@ -4391,7 +4391,7 @@
 		hook->callback = callback;
 		hook->destructor = destructor;
 		hook->hook_pvt = hook_pvt;
-		hook->remove_on_pull = remove_on_pull;
+		ast_set_flag(&hook->remove_flags, AST_BRIDGE_HOOK_REMOVE_ON_PULL);
 	}
 
 	return hook;
@@ -4619,17 +4619,18 @@
  * \since 12.0.0
  *
  * \param obj Feature hook object.
- * \param arg Not used
- * \param flags Not used
- *
- * \retval CMP_MATCH if hook has remove_on_pull set.
+ * \param arg Removal flags
+ * \param unused Not used
+ *
+ * \retval CMP_MATCH if hook's remove_flags match the removal flags set.
  * \retval 0 if not match.
  */
-static int hook_remove_on_pull_match(void *obj, void *arg, int flags)
+static int hook_remove_match(void *obj, void *arg, int unused)
 {
 	struct ast_bridge_hook *hook = obj;
-
-	if (hook->remove_on_pull) {
+	enum ast_bridge_hook_remove_flags *flags = arg;
+
+	if (ast_test_flag(&hook->remove_flags, *flags)) {
 		return CMP_MATCH;
 	} else {
 		return 0;
@@ -4642,13 +4643,14 @@
  * \since 12.0.0
  *
  * \param hooks Hooks container to work on.
+ * \param flags Determinator for whether hook is removed
  *
  * \return Nothing
  */
-static void hooks_remove_on_pull_container(struct ao2_container *hooks)
+static void hooks_remove_container(struct ao2_container *hooks, enum ast_bridge_hook_remove_flags flags)
 {
 	ao2_callback(hooks, OBJ_UNLINK | OBJ_NODATA | OBJ_MULTIPLE,
-		hook_remove_on_pull_match, NULL);
+		hook_remove_match, &flags);
 }
 
 /*!
@@ -4657,10 +4659,11 @@
  * \since 12.0.0
  *
  * \param hooks Hooks heap to work on.
+ * \param flags Determinator for whether hook is removed
  *
  * \return Nothing
  */
-static void hooks_remove_on_pull_heap(struct ast_heap *hooks)
+static void hooks_remove_heap(struct ast_heap *hooks, enum ast_bridge_hook_remove_flags flags)
 {
 	struct ast_bridge_hook *hook;
 	int changed;
@@ -4672,7 +4675,7 @@
 		changed = 0;
 		for (idx = ast_heap_size(hooks); idx; --idx) {
 			hook = ast_heap_peek(hooks, idx);
-			if (hook->remove_on_pull) {
+			if (ast_test_flag(&hook->remove_flags, flags)) {
 				ast_heap_remove(hooks, hook);
 				ao2_ref(hook, -1);
 				changed = 1;
@@ -4687,17 +4690,18 @@
  * \brief Remove marked bridge channel feature hooks.
  * \since 12.0.0
  *
- * \param features Bridge featues structure
+ * \param features Bridge features structure
+ * \param flags Determinator for whether hook is removed.
  *
  * \return Nothing
  */
-static void bridge_features_remove_on_pull(struct ast_bridge_features *features)
-{
-	hooks_remove_on_pull_container(features->dtmf_hooks);
-	hooks_remove_on_pull_container(features->hangup_hooks);
-	hooks_remove_on_pull_container(features->join_hooks);
-	hooks_remove_on_pull_container(features->leave_hooks);
-	hooks_remove_on_pull_heap(features->interval_hooks);
+static void bridge_features_remove(struct ast_bridge_features *features, enum ast_bridge_hook_remove_flags flags)
+{
+	hooks_remove_container(features->dtmf_hooks, flags);
+	hooks_remove_container(features->hangup_hooks, flags);
+	hooks_remove_container(features->join_hooks, flags);
+	hooks_remove_container(features->leave_hooks, flags);
+	hooks_remove_heap(features->interval_hooks, flags);
 }
 
 static int interval_hook_time_cmp(void *a, void *b)




More information about the svn-commits mailing list