[asterisk-commits] file: branch file/bridging r107346 - /team/file/bridging/apps/app_confbridge.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Mar 10 20:43:15 CDT 2008


Author: file
Date: Mon Mar 10 20:43:14 2008
New Revision: 107346

URL: http://svn.digium.com/view/asterisk?view=rev&rev=107346
Log:
Add option to announce the number of users in the conference bridge upon joining.

Modified:
    team/file/bridging/apps/app_confbridge.c

Modified: team/file/bridging/apps/app_confbridge.c
URL: http://svn.digium.com/view/asterisk/team/file/bridging/apps/app_confbridge.c?view=diff&rev=107346&r1=107345&r2=107346
==============================================================================
--- team/file/bridging/apps/app_confbridge.c (original)
+++ team/file/bridging/apps/app_confbridge.c Mon Mar 10 20:43:14 2008
@@ -45,6 +45,7 @@
 #include "asterisk/app.h"
 #include "asterisk/bridging.h"
 #include "asterisk/musiconhold.h"
+#include "asterisk/say.h"
 
 static char *app = "ConfBridge";
 static char *synopsis = 
@@ -53,16 +54,18 @@
  " It shows you the basic structure to create your own Asterisk applications.\n";
 
 enum {
-	OPTION_DYNAMIC = (1 << 0),      /*!< Set if the conference is to be dynamically generated */
-	OPTION_ADMIN = (1 << 1),        /*!< Set if the caller is an administrator */
-	OPTION_MENU = (1 << 2),         /*!< Set if the caller should have access to the conference bridge IVR menu */
-	OPTION_MUSICONHOLD = (1 << 3),  /*!< Set if music on hold should be played if nobody else is in the conference bridge */
-	OPTION_NOONLYPERSON = (1 << 4), /*!< Set if the "you are currently the only person in this conference" sound file should not be played */
-	OPTION_STARTMUTED = (1 << 5),   /*!< Set if the caller should be initially set muted */
+	OPTION_DYNAMIC = (1 << 0),           /*!< Set if the conference is to be dynamically generated */
+	OPTION_ADMIN = (1 << 1),             /*!< Set if the caller is an administrator */
+	OPTION_MENU = (1 << 2),              /*!< Set if the caller should have access to the conference bridge IVR menu */
+	OPTION_MUSICONHOLD = (1 << 3),       /*!< Set if music on hold should be played if nobody else is in the conference bridge */
+	OPTION_NOONLYPERSON = (1 << 4),      /*!< Set if the "you are currently the only person in this conference" sound file should not be played */
+	OPTION_STARTMUTED = (1 << 5),        /*!< Set if the caller should be initially set muted */
+	OPTION_ANNOUNCEUSERCOUNT = (1 << 6), /*!< Set if the number of users should be announced to the caller */
 } option_flags;
 
 AST_APP_OPTIONS(app_opts,{
 	AST_APP_OPTION('a', OPTION_ADMIN),
+	AST_APP_OPTION('c', OPTION_ANNOUNCEUSERCOUNT),
 	AST_APP_OPTION('d', OPTION_DYNAMIC),
 	AST_APP_OPTION('m', OPTION_MENU),
 	AST_APP_OPTION('M', OPTION_MUSICONHOLD),
@@ -97,6 +100,40 @@
 static AST_LIST_HEAD_STATIC(conference_bridges, conference_bridge);
 
 /*!
+ * \brief Announce number of users in the conference bridge to the caller
+ *
+ * \param conference_bridge Conference bridge to peek at
+ * \param conference_bridge_user Caller
+ *
+ * \return Returns nothing
+ */
+static void announce_user_count(struct conference_bridge *conference_bridge, struct conference_bridge_user *conference_bridge_user)
+{
+	if (conference_bridge->users == 1) {
+		/* Awww we are the only person in the conference bridge */
+		return;
+	} else if (conference_bridge->users == 2) {
+		/* Eep, there is one other person */
+		if (ast_stream_and_wait(conference_bridge_user->chan, "conf-onlyone", "")) {
+			return;
+		}
+	} else {
+		/* Alas multiple others in here */
+		if (ast_stream_and_wait(conference_bridge_user->chan, "conf-thereare", "")) {
+			return;
+		}
+		if (ast_say_number(conference_bridge_user->chan, conference_bridge->users - 1, "", conference_bridge_user->chan->language, (char*)NULL)) {
+			return;
+		}
+		if (ast_stream_and_wait(conference_bridge_user->chan, "conf-otherinparty", "")) {
+			return;
+		}
+	}
+	
+	return;
+}
+
+/*!
  * \brief Join a conference bridge
  *
  * \param name The conference name
@@ -171,6 +208,13 @@
 		}
 	} else if (previous_participants == 1) {
 		struct conference_bridge_user *first_participant = AST_LIST_FIRST(&conference_bridge->users_list);
+
+		/* Announce number of users if need be */
+		if (ast_test_flag(&conference_bridge_user->flags, OPTION_ANNOUNCEUSERCOUNT)) {
+			AST_LIST_UNLOCK(&conference_bridges);
+			announce_user_count(conference_bridge, conference_bridge_user);
+			AST_LIST_LOCK(&conference_bridges);
+		}
 
 		/* Temporarily suspend the above participant from the bridge so we have control to stop MOH if needed */
 		if (ast_test_flag(&first_participant->flags, OPTION_MUSICONHOLD) && !ast_bridge_suspend(conference_bridge->bridge, first_participant->chan)) {




More information about the asterisk-commits mailing list