[asterisk-commits] file: branch file/bridging r92615 - in /team/file/bridging: include/asterisk/...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Dec 12 15:05:46 CST 2007


Author: file
Date: Wed Dec 12 15:05:46 2007
New Revision: 92615

URL: http://svn.digium.com/view/asterisk?view=rev&rev=92615
Log:
Minor changes to the built in features code.

Modified:
    team/file/bridging/include/asterisk/bridging.h
    team/file/bridging/main/bridging.c

Modified: team/file/bridging/include/asterisk/bridging.h
URL: http://svn.digium.com/view/asterisk/team/file/bridging/include/asterisk/bridging.h?view=diff&rev=92615&r1=92614&r2=92615
==============================================================================
--- team/file/bridging/include/asterisk/bridging.h (original)
+++ team/file/bridging/include/asterisk/bridging.h Wed Dec 12 15:05:46 2007
@@ -72,6 +72,7 @@
 	AST_BRIDGE_BUILTIN_BLINDTRANSFER = 0, /*! Blind transfer */
 	AST_BRIDGE_BUILTIN_ATTENDEDTRANSFER,  /*! Attended transfer */
 	AST_BRIDGE_BUILTIN_HANGUP,            /*! Hangup on DTMF stream */
+	AST_BRIDGE_BUILTIN_END,               /*! End terminator for list of built in features */
 };
 
 struct ast_bridge;

Modified: team/file/bridging/main/bridging.c
URL: http://svn.digium.com/view/asterisk/team/file/bridging/main/bridging.c?view=diff&rev=92615&r1=92614&r2=92615
==============================================================================
--- team/file/bridging/main/bridging.c (original)
+++ team/file/bridging/main/bridging.c Wed Dec 12 15:05:46 2007
@@ -44,6 +44,9 @@
 #include "asterisk/bridging.h"
 
 static AST_RWLIST_HEAD_STATIC(bridge_technologies, ast_bridge_technology);
+
+/*! Default DTMF keys for built in features */
+static char builtin_features_dtmf[AST_BRIDGE_BUILTIN_END][8];
 
 /*! \brief Register a bridge technology for use
  * \param technology The bridge technology to register
@@ -1200,6 +1203,26 @@
 	return 0;
 }
 
+/*! \brief Internal built in feature for blind transfers */
+static int feature_blind_transfer(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel)
+{
+	return 0;
+}
+
+/*! \brief Internal built in feature for attended transfers */
+static int feature_attended_transfer(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel)
+{
+	return 0;
+}
+
+/*! \brief Internal built in feature for hangup */
+static int feature_hangup(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel)
+{
+	/* This is very simple, we basically change the state on the bridge channel to end and the core takes care of the rest */
+	bridge_channel->state = AST_BRIDGE_CHANNEL_STATE_END;
+	return 0;
+}
+
 /*! \brief Enable a built in feature on a bridge features structure
  * \param features Bridge features structure
  * \param feature Feature to enable
@@ -1210,28 +1233,25 @@
 {
 	ast_bridge_features_hook_callback callback = NULL;
 
-	/* Depending on each feature find the callback and either use the DTMF provided or use the default */
-	switch (feature) {
-	case AST_BRIDGE_BUILTIN_BLINDTRANSFER:
-		callback = NULL;
-		if (ast_strlen_zero(dtmf))
-			dtmf = "*1";
-		break;
-	case AST_BRIDGE_BUILTIN_ATTENDEDTRANSFER:
-		callback = NULL;
-		if (ast_strlen_zero(dtmf))
-			dtmf = "*2";
-		break;
-	case AST_BRIDGE_BUILTIN_HANGUP:
-		callback = NULL;
-		if (ast_strlen_zero(dtmf))
-			dtmf = "*3";
-		break;
-	default:
-		return -1;
-	}
-
-	/* The rest is basically pretty easy. We create another hook using the provided callback/DTMF, easy as pie */
+	/* If no alternate DTMF stream was provided use the default one */
+	if (ast_strlen_zero(dtmf)) {
+		dtmf = builtin_features_dtmf[feature];
+		/* If no DTMF is still available (ie: it has been disabled) then error out now */
+		if (ast_strlen_zero(dtmf)) {
+			ast_debug(1, "Failed to enable built in feature %d on %p, no DTMF string is available for it.\n", feature, features);
+			return -1;
+		}
+	}
+
+	/* Grab the callback for each feature */
+	if (feature == AST_BRIDGE_BUILTIN_BLINDTRANSFER)
+		callback = feature_blind_transfer;
+	else if (feature == AST_BRIDGE_BUILTIN_ATTENDEDTRANSFER)
+		callback = feature_attended_transfer;
+	else if (feature == AST_BRIDGE_BUILTIN_HANGUP)
+		callback = feature_hangup;
+
+	/* The rest is basically pretty easy. We create another hook using the built in feature's callback and DTMF, easy as pie. */
 	return ast_bridge_features_hook(features, dtmf, callback, NULL);
 }
 




More information about the asterisk-commits mailing list