[asterisk-commits] dvossel: branch dvossel/hd_confbridge r310884 - in /team/dvossel/hd_confbridg...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Mar 16 11:20:11 CDT 2011
Author: dvossel
Date: Wed Mar 16 11:20:06 2011
New Revision: 310884
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=310884
Log:
Addition of the 'talk_detection' user profile option.
Modified:
team/dvossel/hd_confbridge/apps/app_confbridge.c
team/dvossel/hd_confbridge/apps/app_meetme.c
team/dvossel/hd_confbridge/apps/confbridge/conf_config_parser.c
team/dvossel/hd_confbridge/apps/confbridge/include/confbridge.h
team/dvossel/hd_confbridge/configs/confbridge.conf.sample
team/dvossel/hd_confbridge/include/asterisk/bridging_features.h
team/dvossel/hd_confbridge/main/bridging.c
Modified: team/dvossel/hd_confbridge/apps/app_confbridge.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/hd_confbridge/apps/app_confbridge.c?view=diff&rev=310884&r1=310883&r2=310884
==============================================================================
--- team/dvossel/hd_confbridge/apps/app_confbridge.c (original)
+++ team/dvossel/hd_confbridge/apps/app_confbridge.c Wed Mar 16 11:20:06 2011
@@ -50,6 +50,7 @@
#include "asterisk/astobj2.h"
#include "confbridge/include/confbridge.h"
#include "asterisk/paths.h"
+#include "asterisk/manager.h"
/*** DOCUMENTATION
<application name="ConfBridge" language="en_US">
@@ -714,6 +715,32 @@
return 0;
}
+static void conf_handle_talker_destructor(void *pvt_data)
+{
+ ast_free(pvt_data);
+}
+
+static void conf_handle_talker_cb(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel, void *pvt_data)
+{
+ char *conf_name = pvt_data;
+ int talking;
+ if (bridge_channel->state == AST_BRIDGE_CHANNEL_STATE_START_TALKING) {
+ talking = 1;
+ } else if (bridge_channel->state == AST_BRIDGE_CHANNEL_STATE_STOP_TALKING) {
+ talking = 0;
+ } else {
+ return; /* uhh this shouldn't happen, but bail if it does. */
+ }
+
+ /* notify AMI someone is has either started or stopped talking */
+ ast_manager_event(bridge_channel->chan, EVENT_FLAG_CALL, "ConfBridgeTalking",
+ "Channel: %s\r\n"
+ "Uniqueid: %s\r\n"
+ "ConfName: %s\r\n"
+ "TalkingStatus: %s\r\n",
+ bridge_channel->chan->name, bridge_channel->chan->uniqueid, conf_name, talking ? "on" : "off");
+}
+
static int conf_get_pin(struct ast_channel *chan, const char *pin)
{
char pin_guess[MAX_PIN] = { 0, };
@@ -844,6 +871,19 @@
ast_bridge_features_cleanup(&conference_bridge_user.features);
return -1;
}
+ }
+
+ /* Set a talker indicate call back if talking detection is requested */
+ if (ast_test_flag(&conference_bridge_user.u_profile, USER_OPT_TALKER_DETECT)) {
+ char *conf_name = ast_strdup(args.conf_name);
+ if (!(conf_name)) {
+ ast_bridge_features_cleanup(&conference_bridge_user.features);
+ return -1;
+ }
+ ast_bridge_features_set_talk_detector(&conference_bridge_user.features,
+ conf_handle_talker_cb,
+ conf_handle_talker_destructor,
+ conf_name);
}
/* Look for a conference bridge matching the provided name */
@@ -1167,7 +1207,6 @@
return res;
}
-
static char *complete_confbridge_name(const char *line, const char *word, int pos, int state)
{
int which = 0;
Modified: team/dvossel/hd_confbridge/apps/app_meetme.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/hd_confbridge/apps/app_meetme.c?view=diff&rev=310884&r1=310883&r2=310884
==============================================================================
--- team/dvossel/hd_confbridge/apps/app_meetme.c (original)
+++ team/dvossel/hd_confbridge/apps/app_meetme.c Wed Mar 16 11:20:06 2011
@@ -95,7 +95,6 @@
<para>Continue in dialplan when kicked out of conference.</para>
</option>
<option name="d">
- <para>Dynamically add conference.</para>
</option>
<option name="D">
<para>Dynamically add conference, prompting for a PIN.</para>
Modified: team/dvossel/hd_confbridge/apps/confbridge/conf_config_parser.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/hd_confbridge/apps/confbridge/conf_config_parser.c?view=diff&rev=310884&r1=310883&r2=310884
==============================================================================
--- team/dvossel/hd_confbridge/apps/confbridge/conf_config_parser.c (original)
+++ team/dvossel/hd_confbridge/apps/confbridge/conf_config_parser.c Wed Mar 16 11:20:06 2011
@@ -236,6 +236,10 @@
u_profile->flags = ast_true(var->value) ?
u_profile->flags | USER_OPT_ENDMARKED :
u_profile->flags & ~USER_OPT_ENDMARKED;
+ } else if (!strcasecmp(var->name, "talk_detection")) {
+ u_profile->flags = ast_true(var->value) ?
+ u_profile->flags | USER_OPT_TALKER_DETECT :
+ u_profile->flags & ~USER_OPT_TALKER_DETECT;
} else if (!strcasecmp(var->name, "announce_join_leave")) {
u_profile->flags = ast_true(var->value) ?
u_profile->flags | USER_OPT_ANNOUNCE_JOIN_LEAVE :
@@ -500,6 +504,9 @@
"enabled" : "disabled");
ast_cli(a->fd,"Announce join/leave: %s\n",
u_profile.flags & USER_OPT_ANNOUNCE_JOIN_LEAVE ?
+ "enabled" : "disabled");
+ ast_cli(a->fd,"Talker Detection: %s\n",
+ u_profile.flags & USER_OPT_TALKER_DETECT ?
"enabled" : "disabled");
ast_cli(a->fd,"PIN: %s\n",
ast_strlen_zero(u_profile.pin) ?
Modified: team/dvossel/hd_confbridge/apps/confbridge/include/confbridge.h
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/hd_confbridge/apps/confbridge/include/confbridge.h?view=diff&rev=310884&r1=310883&r2=310884
==============================================================================
--- team/dvossel/hd_confbridge/apps/confbridge/include/confbridge.h (original)
+++ team/dvossel/hd_confbridge/apps/confbridge/include/confbridge.h Wed Mar 16 11:20:06 2011
@@ -43,8 +43,8 @@
USER_OPT_ENDMARKED = (1 << 8), /*!< Set if the user should be kicked after the last Marked user exits */
USER_OPT_DENOISE = (1 << 9), /*!< Sets if denoise filter should be used on audio before mixing. */
USER_OPT_ANNOUNCE_JOIN_LEAVE = (1 << 10), /*!< Sets if the user's name should be recorded and announced on join and leave. */
-};
-
+ USER_OPT_TALKER_DETECT = (1 << 11), /*!< Sets if start and stop talking events should generated for this user over AMI. */
+};
enum bridge_profile_flags {
BRIDGE_OPT_RECORD_CONFERENCE = (1 << 0), /*!< Set if the conference should be recorded */
Modified: team/dvossel/hd_confbridge/configs/confbridge.conf.sample
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/hd_confbridge/configs/confbridge.conf.sample?view=diff&rev=310884&r1=310883&r2=310884
==============================================================================
--- team/dvossel/hd_confbridge/configs/confbridge.conf.sample (original)
+++ team/dvossel/hd_confbridge/configs/confbridge.conf.sample Wed Mar 16 11:20:06 2011
@@ -41,6 +41,9 @@
; name when entering the conference. After the name is
; recorded, it will be played as the user enters and exists
; the conference. This option is off by default.
+;talk_detection=yes ; This option sets whether or not notifications of when a user
+ ; begins and ends talking should be sent out as events over AMI.
+ ; By default this option is off.
; --- ConfBridge Bridge Profile Options ---
[default_bridge]
Modified: team/dvossel/hd_confbridge/include/asterisk/bridging_features.h
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/hd_confbridge/include/asterisk/bridging_features.h?view=diff&rev=310884&r1=310883&r2=310884
==============================================================================
--- team/dvossel/hd_confbridge/include/asterisk/bridging_features.h (original)
+++ team/dvossel/hd_confbridge/include/asterisk/bridging_features.h Wed Mar 16 11:20:06 2011
@@ -83,7 +83,10 @@
* \retval 0 success
* \retval -1 failure
*/
-typedef int (*ast_bridge_talking_indicate_callback)(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel);
+typedef void (*ast_bridge_talking_indicate_callback)(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel, void *pvt_data);
+
+
+typedef void (*ast_bridge_talking_indicate_destructor)(void *pvt_data);
/*!
* \brief Maximum length of a DTMF feature string
@@ -113,10 +116,14 @@
/*! Attached DTMF based feature hooks */
AST_LIST_HEAD_NOLOCK(, ast_bridge_features_hook) hooks;
/*! Callback to indicate when a bridge channel has started and stopped talking */
- ast_bridge_talking_indicate_callback talker;
+ ast_bridge_talking_indicate_callback talker_cb;
+ /*! Callback to destroy any pvt data stored for the talker. */
+ ast_bridge_talking_indicate_destructor talker_destructor_cb;
+ /*! Talker callback pvt data */
+ void *talker_pvt_data;
/*! Feature flags that are enabled */
struct ast_flags feature_flags;
- /*! Bit to indicate that this structure is useful and should be considered when looking for features */
+ /*! Bit to indicate that the hook list is useful and should be considered when looking for DTMF features */
unsigned int usable:1;
/*! Bit to indicate whether the channel/bridge is muted or not */
unsigned int mute:1;
@@ -213,6 +220,21 @@
void *hook_pvt,
ast_bridge_features_hook_pvt_destructor destructor);
+/*! \brief Set a callback on the features structure to receive talking notifications on.
+ *
+ * \param features Bridge features structure
+ * \param talker_cb, Callback function to execute when talking events occur in the bridge core.
+ * \param pvt_data Optional unique data that will be passed with the talking events.
+ * \param Optional destructor callback for pvt data.
+ *
+ * \retval 0, success
+ * \retval -1, failure
+ */
+int ast_bridge_features_set_talk_detector(struct ast_bridge_features *features,
+ ast_bridge_talking_indicate_callback talker_cb,
+ ast_bridge_talking_indicate_destructor talker_destructor,
+ void *pvt_data);
+
/*! \brief Enable a built in feature on a bridge features structure
*
* \param features Bridge features structure
Modified: team/dvossel/hd_confbridge/main/bridging.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/hd_confbridge/main/bridging.c?view=diff&rev=310884&r1=310883&r2=310884
==============================================================================
--- team/dvossel/hd_confbridge/main/bridging.c (original)
+++ team/dvossel/hd_confbridge/main/bridging.c Wed Mar 16 11:20:06 2011
@@ -866,8 +866,8 @@
{
struct ast_bridge_features *features = (bridge_channel->features ? bridge_channel->features : &bridge->features);
- if (features && features->talker) {
- features->talker(bridge, bridge_channel);
+ if (features && features->talker_cb) {
+ features->talker_cb(bridge, bridge_channel, features->talker_pvt_data);
}
ast_bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_WAIT);
}
@@ -970,7 +970,9 @@
break;
case AST_BRIDGE_CHANNEL_STATE_START_TALKING:
case AST_BRIDGE_CHANNEL_STATE_STOP_TALKING:
+ ao2_unlock(bridge_channel->bridge);
bridge_channel_talking(bridge_channel->bridge, bridge_channel);
+ ao2_lock(bridge_channel->bridge);
break;
default:
break;
@@ -1309,7 +1311,6 @@
return 0;
}
-
int ast_bridge_features_hook(struct ast_bridge_features *features,
const char *dtmf,
ast_bridge_features_hook_callback callback,
@@ -1333,6 +1334,17 @@
features->usable = 1;
+ return 0;
+}
+
+int ast_bridge_features_set_talk_detector(struct ast_bridge_features *features,
+ ast_bridge_talking_indicate_callback talker_cb,
+ ast_bridge_talking_indicate_destructor talker_destructor,
+ void *pvt_data)
+{
+ features->talker_cb = talker_cb;
+ features->talker_destructor_cb = talker_destructor;
+ features->talker_pvt_data = pvt_data;
return 0;
}
@@ -1385,6 +1397,10 @@
}
ast_free(hook);
}
+ if (features->talker_destructor_cb && features->talker_pvt_data) {
+ features->talker_destructor_cb(features->talker_pvt_data);
+ features->talker_pvt_data = NULL;
+ }
return 0;
}
More information about the asterisk-commits
mailing list