[svn-commits] rmudgett: branch rmudgett/bridge_phase r395317 - in /team/rmudgett/bridge_pha...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Wed Jul 24 15:29:46 CDT 2013


Author: rmudgett
Date: Wed Jul 24 15:29:45 2013
New Revision: 395317

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=395317
Log:
* Refactor setup_bridge_features_builtin().

* Add an error message so you know when a feature is not available and you
tried to use it.  It usually means the module has not been loaded.
........

Merged revisions 395316 from http://svn.asterisk.org/svn/asterisk/trunk

Modified:
    team/rmudgett/bridge_phase/   (props changed)
    team/rmudgett/bridge_phase/main/features.c

Propchange: team/rmudgett/bridge_phase/
------------------------------------------------------------------------------
--- bridge_phase-integrated (original)
+++ bridge_phase-integrated Wed Jul 24 15:29:45 2013
@@ -1,1 +1,1 @@
-/trunk:1-395300
+/trunk:1-395316

Modified: team/rmudgett/bridge_phase/main/features.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/bridge_phase/main/features.c?view=diff&rev=395317&r1=395316&r2=395317
==============================================================================
--- team/rmudgett/bridge_phase/main/features.c (original)
+++ team/rmudgett/bridge_phase/main/features.c Wed Jul 24 15:29:45 2013
@@ -3163,6 +3163,42 @@
 
 /*!
  * \internal
+ * \brief Helper to add a builtin DTMF feature hook to the features struct.
+ * \since 12.0.0
+ *
+ * \param features Bridge features to setup.
+ * \param chan Get features from this channel.
+ * \param flags Feature flags on the channel.
+ * \param feature_flag Feature flag to test.
+ * \param feature_name features.conf name of feature.
+ * \param feature_bridge Bridge feature enum to get hook callback.
+ *
+ * \retval 0 on success.
+ * \retval -1 on error.
+ */
+static int builtin_features_helper(struct ast_bridge_features *features, struct ast_channel *chan,
+	struct ast_flags *flags, unsigned int feature_flag, const char *feature_name, enum ast_bridge_builtin_feature feature_bridge)
+{
+	char dtmf[AST_FEATURE_MAX_LEN];
+	int res;
+
+	res = 0;
+	if (ast_test_flag(flags, feature_flag)
+		&& !builtin_feature_get_exten(chan, feature_name, dtmf, sizeof(dtmf))
+		&& !ast_strlen_zero(dtmf)) {
+		res = ast_bridge_features_enable(features, feature_bridge, dtmf, NULL, NULL,
+			AST_BRIDGE_HOOK_REMOVE_ON_PULL | AST_BRIDGE_HOOK_REMOVE_ON_PERSONALITY_CHANGE);
+		if (res) {
+			ast_log(LOG_ERROR, "Channel %s: Requested DTMF feature %s not available.\n",
+				ast_channel_name(chan), feature_name);
+		}
+	}
+
+	return res;
+}
+
+/*!
+ * \internal
  * \brief Setup bridge builtin features.
  * \since 12.0.0
  *
@@ -3175,7 +3211,6 @@
 static int setup_bridge_features_builtin(struct ast_bridge_features *features, struct ast_channel *chan)
 {
 	struct ast_flags *flags;
-	char dtmf[AST_FEATURE_MAX_LEN];
 	int res;
 
 	ast_channel_lock(chan);
@@ -3186,43 +3221,12 @@
 	}
 
 	res = 0;
-	if (ast_test_flag(flags, AST_FEATURE_REDIRECT)) {
-		/* Add atxfer and blind transfer. */
-		if (!builtin_feature_get_exten(chan, "blindxfer", dtmf, sizeof(dtmf))
-				&& !ast_strlen_zero(dtmf)) {
-			res |= ast_bridge_features_enable(features, AST_BRIDGE_BUILTIN_BLINDTRANSFER, dtmf,
-					NULL, NULL, AST_BRIDGE_HOOK_REMOVE_ON_PULL | AST_BRIDGE_HOOK_REMOVE_ON_PERSONALITY_CHANGE);
-		}
-		if (!builtin_feature_get_exten(chan, "atxfer", dtmf, sizeof(dtmf)) &&
-				!ast_strlen_zero(dtmf)) {
-			res |= ast_bridge_features_enable(features, AST_BRIDGE_BUILTIN_ATTENDEDTRANSFER, dtmf,
-					NULL, NULL, AST_BRIDGE_HOOK_REMOVE_ON_PULL | AST_BRIDGE_HOOK_REMOVE_ON_PERSONALITY_CHANGE);
-		}
-	}
-	if (ast_test_flag(flags, AST_FEATURE_DISCONNECT) &&
-			!builtin_feature_get_exten(chan, "disconnect", dtmf, sizeof(dtmf)) &&
-			!ast_strlen_zero(dtmf)) {
-		res |= ast_bridge_features_enable(features, AST_BRIDGE_BUILTIN_HANGUP, dtmf,
-				NULL, NULL, AST_BRIDGE_HOOK_REMOVE_ON_PULL | AST_BRIDGE_HOOK_REMOVE_ON_PERSONALITY_CHANGE);
-	}
-	if (ast_test_flag(flags, AST_FEATURE_PARKCALL) &&
-			!builtin_feature_get_exten(chan, "parkcall", dtmf, sizeof(dtmf)) &&
-			!ast_strlen_zero(dtmf)) {
-		res |= ast_bridge_features_enable(features, AST_BRIDGE_BUILTIN_PARKCALL, dtmf,
-				NULL, NULL, AST_BRIDGE_HOOK_REMOVE_ON_PULL | AST_BRIDGE_HOOK_REMOVE_ON_PERSONALITY_CHANGE);
-	}
-	if (ast_test_flag(flags, AST_FEATURE_AUTOMON) &&
-			!builtin_feature_get_exten(chan, "automon", dtmf, sizeof(dtmf)) &&
-			!ast_strlen_zero(dtmf)) {
-		res |= ast_bridge_features_enable(features, AST_BRIDGE_BUILTIN_AUTOMON, dtmf,
-				NULL, NULL, AST_BRIDGE_HOOK_REMOVE_ON_PULL | AST_BRIDGE_HOOK_REMOVE_ON_PERSONALITY_CHANGE);
-	}
-	if (ast_test_flag(flags, AST_FEATURE_AUTOMIXMON) &&
-			!builtin_feature_get_exten(chan, "automixmon", dtmf, sizeof(dtmf)) &&
-			!ast_strlen_zero(dtmf)) {
-		res |= ast_bridge_features_enable(features, AST_BRIDGE_BUILTIN_AUTOMIXMON, dtmf,
-				NULL, NULL, AST_BRIDGE_HOOK_REMOVE_ON_PULL | AST_BRIDGE_HOOK_REMOVE_ON_PERSONALITY_CHANGE);
-	}
+	res |= builtin_features_helper(features, chan, flags, AST_FEATURE_REDIRECT, "blindxfer", AST_BRIDGE_BUILTIN_BLINDTRANSFER);
+	res |= builtin_features_helper(features, chan, flags, AST_FEATURE_REDIRECT, "atxfer", AST_BRIDGE_BUILTIN_ATTENDEDTRANSFER);
+	res |= builtin_features_helper(features, chan, flags, AST_FEATURE_DISCONNECT, "disconnect", AST_BRIDGE_BUILTIN_HANGUP);
+	res |= builtin_features_helper(features, chan, flags, AST_FEATURE_PARKCALL, "parkcall", AST_BRIDGE_BUILTIN_PARKCALL);
+	res |= builtin_features_helper(features, chan, flags, AST_FEATURE_AUTOMON, "automon", AST_BRIDGE_BUILTIN_AUTOMON);
+	res |= builtin_features_helper(features, chan, flags, AST_FEATURE_AUTOMIXMON, "automixmon", AST_BRIDGE_BUILTIN_AUTOMIXMON);
 
 	return res ? -1 : 0;
 }




More information about the svn-commits mailing list