[asterisk-commits] kmoore: trunk r323517 - in /trunk: CHANGES apps/app_confbridge.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Jun 15 08:45:47 CDT 2011
Author: kmoore
Date: Wed Jun 15 08:45:41 2011
New Revision: 323517
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=323517
Log:
CONFBRIDGE_INFO function to get conference data
Added the CONFBRIDGE_INFO dialplan function to get information about a
conference bridge including locked status and number of parties, admins, and
marked users.
Review: https://reviewboard.asterisk.org/r/1271/
Modified:
trunk/CHANGES
trunk/apps/app_confbridge.c
Modified: trunk/CHANGES
URL: http://svnview.digium.com/svn/asterisk/trunk/CHANGES?view=diff&rev=323517&r1=323516&r2=323517
==============================================================================
--- trunk/CHANGES (original)
+++ trunk/CHANGES Wed Jun 15 08:45:41 2011
@@ -79,6 +79,9 @@
mixing audio at sample rates ranging from 8khz-96khz.
* CONFBRIDGE dialplan function capable of creating dynamic ConfBridge user
and bridge profiles on a channel.
+ * CONFBRIDGE_INFO dialplan function capable of retreiving information
+ about a conference such as locked status and number of parties, admins,
+ and marked users.
Dialplan Variables
------------------
Modified: trunk/apps/app_confbridge.c
URL: http://svnview.digium.com/svn/asterisk/trunk/apps/app_confbridge.c?view=diff&rev=323517&r1=323516&r2=323517
==============================================================================
--- trunk/apps/app_confbridge.c (original)
+++ trunk/apps/app_confbridge.c Wed Jun 15 08:45:41 2011
@@ -104,6 +104,22 @@
<para>exten => 1,n,Set(CONFBRIDGE(user,admin)=yes)</para>
<para>exten => 1,n,Set(CONFBRIDGE(user,marked)=yes)</para>
<para>exten => 1,n,ConfBridge(1)</para>
+ </description>
+ </function>
+ <function name="CONFBRIDGE_INFO" language="en_US">
+ <synopsis>
+ Get information about a ConfBridge conference.
+ </synopsis>
+ <syntax>
+ <parameter name="type" required="true">
+ <para>Type can be <literal>parties</literal>, <literal>admins</literal>, <literal>marked</literal>, or <literal>locked</literal>.</para>
+ </parameter>
+ <parameter name="conf" required="true">
+ <para>Conf refers to the name of the conference being referenced.</para>
+ </parameter>
+ </syntax>
+ <description>
+ <para>This function returns a non-negative integer for valid conference identifiers (0 or 1 for <literal>locked</literal>) and "" for invalid conference identifiers.</para>
</description>
</function>
<manager name="ConfbridgeList" language="en_US">
@@ -2079,6 +2095,12 @@
.write = func_confbridge_helper,
};
+static int func_confbridge_info(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len);
+static struct ast_custom_function confbridge_info_function = {
+ .name = "CONFBRIDGE_INFO",
+ .read = func_confbridge_info,
+};
+
static int action_confbridgelist(struct mansession *s, const struct message *m)
{
const char *actionid = astman_get_header(m, "ActionID");
@@ -2390,7 +2412,68 @@
return 0;
}
-
+static int func_confbridge_info(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
+{
+ char *parse = NULL;
+ struct conference_bridge *bridge = NULL;
+ struct conference_bridge_user *participant = NULL;
+ struct conference_bridge tmp;
+ int count = 0;
+ AST_DECLARE_APP_ARGS(args,
+ AST_APP_ARG(type);
+ AST_APP_ARG(confno);
+ );
+
+ /* parse all the required arguments and make sure they exist. */
+ if (ast_strlen_zero(data)) {
+ return -1;
+ }
+ parse = ast_strdupa(data);
+ AST_STANDARD_APP_ARGS(args, parse);
+ if (ast_strlen_zero(args.confno) || ast_strlen_zero(args.type)) {
+ return -1;
+ }
+ if (!ao2_container_count(conference_bridges)) {
+ ast_log(LOG_ERROR, "No active conferneces.\n");
+ return -1;
+ }
+ ast_copy_string(tmp.name, args.confno, sizeof(tmp.name));
+ bridge = ao2_find(conference_bridges, &tmp, OBJ_POINTER);
+ if (!bridge) {
+ ast_log(LOG_ERROR, "Confernece '%s' not found.\n", args.confno);
+ return -1;
+ }
+
+ /* get the correct count for the type requested */
+ ao2_lock(bridge);
+ if (!strncasecmp(args.type, "parties", 7)) {
+ AST_LIST_TRAVERSE(&bridge->users_list, participant, list) {
+ count++;
+ }
+ } else if (!strncasecmp(args.type, "admins", 6)) {
+ AST_LIST_TRAVERSE(&bridge->users_list, participant, list) {
+ if (ast_test_flag(&participant->u_profile, USER_OPT_ADMIN)) {
+ count++;
+ }
+ }
+ } else if (!strncasecmp(args.type, "marked", 6)) {
+ AST_LIST_TRAVERSE(&bridge->users_list, participant, list) {
+ if (ast_test_flag(&participant->u_profile, USER_OPT_MARKEDUSER)) {
+ count++;
+ }
+ }
+ } else if (!strncasecmp(args.type, "locked", 6)) {
+ count = bridge->locked;
+ } else {
+ ao2_unlock(bridge);
+ ao2_ref(bridge, -1);
+ return -1;
+ }
+ snprintf(buf, len, "%d", count);
+ ao2_unlock(bridge);
+ ao2_ref(bridge, -1);
+ return 0;
+}
/*! \brief Called when module is being unloaded */
static int unload_module(void)
@@ -2398,6 +2481,7 @@
int res = ast_unregister_application(app);
ast_custom_function_unregister(&confbridge_function);
+ ast_custom_function_unregister(&confbridge_info_function);
ast_cli_unregister_multiple(cli_confbridge, sizeof(cli_confbridge) / sizeof(struct ast_cli_entry));
@@ -2427,6 +2511,9 @@
{
int res = 0;
if ((ast_custom_function_register(&confbridge_function))) {
+ return AST_MODULE_LOAD_FAILURE;
+ }
+ if ((ast_custom_function_register(&confbridge_info_function))) {
return AST_MODULE_LOAD_FAILURE;
}
if (!(record_tech.capabilities = ast_format_cap_alloc())) {
More information about the asterisk-commits
mailing list