[asterisk-commits] dvossel: trunk r314598 - in /trunk: ./ apps/ apps/confbridge/ apps/confbridge...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Apr 21 13:11:48 CDT 2011
Author: dvossel
Date: Thu Apr 21 13:11:40 2011
New Revision: 314598
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=314598
Log:
New HD ConfBridge conferencing application.
Includes a new highly optimized and customizable
ConfBridge application capable of mixing audio at
sample rates ranging from 8khz-192khz.
Review: https://reviewboard.asterisk.org/r/1147/
Added:
trunk/apps/confbridge/
trunk/apps/confbridge/conf_config_parser.c (with props)
trunk/apps/confbridge/include/
trunk/apps/confbridge/include/confbridge.h (with props)
trunk/configs/confbridge.conf.sample (with props)
Modified:
trunk/CHANGES
trunk/UPGRADE.txt
trunk/apps/Makefile
trunk/apps/app_confbridge.c
trunk/bridges/bridge_builtin_features.c
trunk/bridges/bridge_softmix.c
trunk/include/asterisk/bridging.h
trunk/include/asterisk/bridging_features.h
trunk/include/asterisk/bridging_technology.h
trunk/include/asterisk/channel.h
trunk/include/asterisk/dsp.h
trunk/main/bridging.c
trunk/main/channel.c
trunk/main/dsp.c
trunk/res/res_musiconhold.c
Modified: trunk/CHANGES
URL: http://svnview.digium.com/svn/asterisk/trunk/CHANGES?view=diff&rev=314598&r1=314597&r2=314598
==============================================================================
--- trunk/CHANGES (original)
+++ trunk/CHANGES Thu Apr 21 13:11:40 2011
@@ -57,6 +57,13 @@
--------------------------
* Ability to define custom SILK formats in codecs.conf.
* Addition of speex32 audio format with translation.
+
+ConfBridge
+--------------------------
+ * New highly optimized and customizable ConfBridge application capable of
+ mixing audio at sample rates ranging from 8khz-96khz.
+ * CONFBRIDGE dialplan function capable of creating dynamic ConfBridge user
+ and bridge profiles on a channel.
Dialplan Variables
------------------
Modified: trunk/UPGRADE.txt
URL: http://svnview.digium.com/svn/asterisk/trunk/UPGRADE.txt?view=diff&rev=314598&r1=314597&r2=314598
==============================================================================
--- trunk/UPGRADE.txt (original)
+++ trunk/UPGRADE.txt Thu Apr 21 13:11:40 2011
@@ -21,6 +21,10 @@
From 1.8 to 1.10:
+ConfBridge
+ - ConfBridge's dialplan arguments have changed and are not
+ backwards compatible.
+
HTTP:
- A bindaddr must be specified in order for the HTTP server
to run. Previous versions would default to 0.0.0.0 if no
Modified: trunk/apps/Makefile
URL: http://svnview.digium.com/svn/asterisk/trunk/apps/Makefile?view=diff&rev=314598&r1=314597&r2=314598
==============================================================================
--- trunk/apps/Makefile (original)
+++ trunk/apps/Makefile Thu Apr 21 13:11:40 2011
@@ -27,6 +27,12 @@
include $(ASTTOPDIR)/Makefile.moddir_rules
+clean::
+ rm -f confbridge/*.o confbridge/*.i
+
+$(if $(filter app_confbridge,$(EMBEDDED_MODS)),modules.link,app_confbridge.so): $(subst .c,.o,$(wildcard confbridge/*.c))
+$(subst .c,.o,$(wildcard confbridge/*.c)): _ASTCFLAGS+=$(call MOD_ASTCFLAGS,app_confbridge)
+
ifneq ($(findstring $(OSARCH), mingw32 cygwin ),)
LIBS+= -lres_features.so -lres_ael_share.so -lres_monitor.so -lres_speech.so
LIBS+= -lres_smdi.so
Modified: trunk/apps/app_confbridge.c
URL: http://svnview.digium.com/svn/asterisk/trunk/apps/app_confbridge.c?view=diff&rev=314598&r1=314597&r2=314598
==============================================================================
--- trunk/apps/app_confbridge.c (original)
+++ trunk/apps/app_confbridge.c Thu Apr 21 13:11:40 2011
@@ -4,6 +4,7 @@
* Copyright (C) 2007-2008, Digium, Inc.
*
* Joshua Colp <jcolp at digium.com>
+ * David Vossel <dvossel at digium.com>
*
* See http://www.asterisk.org for more information about
* the Asterisk project. Please do not directly contact
@@ -21,6 +22,7 @@
* \brief Conference Bridge application
*
* \author\verbatim Joshua Colp <jcolp at digium.com> \endverbatim
+ * \author\verbatim David Vossel <dvossel at digium.com> \endverbatim
*
* This is a conference bridge application utilizing the bridging core.
* \ingroup applications
@@ -38,69 +40,183 @@
#include "asterisk/cli.h"
#include "asterisk/file.h"
-#include "asterisk/logger.h"
#include "asterisk/channel.h"
+#include "asterisk/pbx.h"
#include "asterisk/pbx.h"
#include "asterisk/module.h"
#include "asterisk/lock.h"
-#include "asterisk/app.h"
#include "asterisk/bridging.h"
#include "asterisk/musiconhold.h"
#include "asterisk/say.h"
#include "asterisk/audiohook.h"
#include "asterisk/astobj2.h"
+#include "confbridge/include/confbridge.h"
+#include "asterisk/paths.h"
+#include "asterisk/manager.h"
/*** DOCUMENTATION
- <application name="ConfBridge" language="en_US">
- <synopsis>
- Conference bridge application.
- </synopsis>
- <syntax>
- <parameter name="confno">
- <para>The conference number</para>
- </parameter>
- <parameter name="options">
- <optionlist>
- <option name="a">
- <para>Set admin mode.</para>
- </option>
- <option name="A">
- <para>Set marked mode.</para>
- </option>
- <option name="c">
- <para>Announce user(s) count on joining a conference.</para>
- </option>
- <option name="m">
- <para>Set initially muted.</para>
- </option>
- <option name="M" hasparams="optional">
- <para>Enable music on hold when the conference has a single caller. Optionally,
- specify a musiconhold class to use. If one is not provided, it will use the
- channel's currently set music class, or <literal>default</literal>.</para>
- <argument name="class" required="true" />
- </option>
- <option name="1">
- <para>Do not play message when first person enters</para>
- </option>
- <option name="s">
- <para>Present menu (user or admin) when <literal>*</literal> is received
- (send to menu).</para>
- </option>
- <option name="w">
- <para>Wait until the marked user enters the conference.</para>
- </option>
- <option name="q">
- <para>Quiet mode (don't play enter/leave sounds).</para>
- </option>
- </optionlist>
- </parameter>
- </syntax>
- <description>
- <para>Enters the user into a specified conference bridge. The user can exit the conference by hangup only.</para>
- <para>The join sound can be set using the <literal>CONFBRIDGE_JOIN_SOUND</literal> variable and the leave sound can be set using the <literal>CONFBRIDGE_LEAVE_SOUND</literal> variable. These can be unique to the caller.</para>
- <note><para>This application will not automatically answer the channel.</para></note>
- </description>
- </application>
+ <application name="ConfBridge" language="en_US">
+ <synopsis>
+ Conference bridge application.
+ </synopsis>
+ <syntax>
+ <parameter name="confno">
+ <para>The conference number</para>
+ </parameter>
+ <parameter name="bridge_profile">
+ <para>The bridge profile name from confbridge.conf. When left blank, a dynamically built bridge profile created by the CONFBRIDGE dialplan function is searched for on the channel and used. If no dynamic profile is present, the 'default_bridge' profile found in confbridge.conf is used. </para>
+ <para>It is important to note that while user profiles may be unique for each participant, mixing bridge profiles on a single conference is _NOT_ recommended and will produce undefined results.</para>
+ </parameter>
+ <parameter name="user_profile">
+ <para>The user profile name from confbridge.conf. When left blank, a dynamically built user profile created by the CONFBRIDGE dialplan function is searched for on the channel and used. If no dynamic profile is present, the 'default_user' profile found in confbridge.conf is used.</para>
+ </parameter>
+ <parameter name="menu">
+ <para>The name of the DTMF menu in confbridge.conf to be applied to this channel. No menu is applied by default if this option is left blank.</para>
+ </parameter>
+ </syntax>
+ <description>
+ <para>Enters the user into a specified conference bridge. The user can exit the conference by hangup or DTMF menu option.</para>
+ </description>
+ </application>
+ <function name="CONFBRIDGE" language="en_US">
+ <synopsis>
+ Set a custom dynamic bridge and user profile on a channel for the ConfBridge application using the same options defined in confbridge.conf.
+ </synopsis>
+ <syntax>
+ <parameter name="type" required="true">
+ <para>Type refers to which type of profile the option belongs too. Type can be <literal>bridge</literal> or <literal>user</literal>.</para>
+ </parameter>
+ <parameter name="option" required="true">
+ <para>Option refers to <filename>confbridge.conf</filename> option that is being set dynamically on this channel.</para>
+ </parameter>
+ </syntax>
+ <description>
+ <para>---- Example 1 ----</para>
+ <para>In this example the custom set user profile on this channel will automatically be used by the ConfBridge app.</para>
+ <para>exten => 1,1,Answer() </para>
+ <para>exten => 1,n,Set(CONFBRIDGE(user,announce_join_leave)=yes)</para>
+ <para>exten => 1,n,Set(CONFBRIDGE(user,startmuted)=yes)</para>
+ <para>exten => 1,n,ConfBridge(1) </para>
+ <para>---- Example 2 ----</para>
+ <para>This example shows how to use a predefined user or bridge profile in confbridge.conf as a template for a dynamic profile. Here we make a admin/marked user out of the default_user profile that is already defined in confbridge.conf.</para>
+ <para>exten => 1,1,Answer() </para>
+ <para>exten => 1,n,Set(CONFBRIDGE(user,template)=default_user)</para>
+ <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>
+ <manager name="ConfbridgeList" language="en_US">
+ <synopsis>
+ List participants in a conference.
+ </synopsis>
+ <syntax>
+ <xi:include xpointer="xpointer(/docs/manager[@name='Login']/syntax/parameter[@name='ActionID'])" />
+ <parameter name="Conference" required="false">
+ <para>Conference number.</para>
+ </parameter>
+ </syntax>
+ <description>
+ <para>Lists all users in a particular ConfBridge conference.
+ ConfbridgeList will follow as separate events, followed by a final event called
+ ConfbridgeListComplete.</para>
+ </description>
+ </manager>
+ <manager name="ConfbridgeListRooms" language="en_US">
+ <synopsis>
+ List active conferences.
+ </synopsis>
+ <syntax>
+ <xi:include xpointer="xpointer(/docs/manager[@name='Login']/syntax/parameter[@name='ActionID'])" />
+ </syntax>
+ <description>
+ <para>Lists data about all active conferences.
+ ConfbridgeListRooms will follow as separate events, followed by a final event called
+ ConfbridgeListRoomsComplete.</para>
+ </description>
+ </manager>
+ <manager name="ConfbridgeMute" language="en_US">
+ <synopsis>
+ Mute a Confbridge user.
+ </synopsis>
+ <syntax>
+ <xi:include xpointer="xpointer(/docs/manager[@name='Login']/syntax/parameter[@name='ActionID'])" />
+ <parameter name="Conference" required="true" />
+ <parameter name="Channel" required="true" />
+ </syntax>
+ <description>
+ </description>
+ </manager>
+ <manager name="ConfbridgeUnmute" language="en_US">
+ <synopsis>
+ Unmute a Confbridge user.
+ </synopsis>
+ <syntax>
+ <xi:include xpointer="xpointer(/docs/manager[@name='Login']/syntax/parameter[@name='ActionID'])" />
+ <parameter name="Conference" required="true" />
+ <parameter name="Channel" required="true" />
+ </syntax>
+ <description>
+ </description>
+ </manager>
+ <manager name="ConfbridgeKick" language="en_US">
+ <synopsis>
+ Kick a Confbridge user.
+ </synopsis>
+ <syntax>
+ <xi:include xpointer="xpointer(/docs/manager[@name='Login']/syntax/parameter[@name='ActionID'])" />
+ <parameter name="Conference" required="true" />
+ <parameter name="Channel" required="true" />
+ </syntax>
+ <description>
+ </description>
+ </manager>
+ <manager name="ConfbridgeLock" language="en_US">
+ <synopsis>
+ Lock a Confbridge conference.
+ </synopsis>
+ <syntax>
+ <xi:include xpointer="xpointer(/docs/manager[@name='Login']/syntax/parameter[@name='ActionID'])" />
+ <parameter name="Conference" required="true" />
+ </syntax>
+ <description>
+ </description>
+ </manager>
+ <manager name="ConfbridgeUnlock" language="en_US">
+ <synopsis>
+ Unlock a Confbridge conference.
+ </synopsis>
+ <syntax>
+ <xi:include xpointer="xpointer(/docs/manager[@name='Login']/syntax/parameter[@name='ActionID'])" />
+ <parameter name="Conference" required="true" />
+ </syntax>
+ <description>
+ </description>
+ </manager>
+ <manager name="ConfbridgeStartRecord" language="en_US">
+ <synopsis>
+ Start recording a Confbridge conference.
+ </synopsis>
+ <syntax>
+ <xi:include xpointer="xpointer(/docs/manager[@name='Login']/syntax/parameter[@name='ActionID'])" />
+ <parameter name="Conference" required="true" />
+ <parameter name="RecordFile" required="false" />
+ </syntax>
+ <description>
+ <para>Start recording a conference. If recording is already present an error will be returned. If RecordFile is not provided, the default record file specified in the conference's bridge profile will be used, if that is not present either a file will automatically be generated in the monitor directory.</para>
+ </description>
+ </manager>
+ <manager name="ConfbridgeStopRecord" language="en_US">
+ <synopsis>
+ Stop recording a Confbridge conference.
+ </synopsis>
+ <syntax>
+ <xi:include xpointer="xpointer(/docs/manager[@name='Login']/syntax/parameter[@name='ActionID'])" />
+ <parameter name="Conference" required="true" />
+ </syntax>
+ <description>
+ </description>
+ </manager>
***/
/*!
@@ -115,69 +231,19 @@
static const char app[] = "ConfBridge";
-enum {
- OPTION_ADMIN = (1 << 0), /*!< Set if the caller is an administrator */
- OPTION_MENU = (1 << 1), /*!< Set if the caller should have access to the conference bridge IVR menu */
- OPTION_MUSICONHOLD = (1 << 2), /*!< Set if music on hold should be played if nobody else is in the conference bridge */
- OPTION_NOONLYPERSON = (1 << 3), /*!< Set if the "you are currently the only person in this conference" sound file should not be played */
- OPTION_STARTMUTED = (1 << 4), /*!< Set if the caller should be initially set muted */
- OPTION_ANNOUNCEUSERCOUNT = (1 << 5), /*!< Set if the number of users should be announced to the caller */
- OPTION_MARKEDUSER = (1 << 6), /*!< Set if the caller is a marked user */
- OPTION_WAITMARKED = (1 << 7), /*!< Set if the conference must wait for a marked user before starting */
- OPTION_QUIET = (1 << 8), /*!< Set if no audio prompts should be played */
-};
-
-enum {
- OPTION_MUSICONHOLD_CLASS, /*!< If the 'M' option is set, the music on hold class to play */
- /*This must be the last element */
- OPTION_ARRAY_SIZE,
-};
-
-AST_APP_OPTIONS(app_opts,{
- AST_APP_OPTION('A', OPTION_MARKEDUSER),
- AST_APP_OPTION('a', OPTION_ADMIN),
- AST_APP_OPTION('c', OPTION_ANNOUNCEUSERCOUNT),
- AST_APP_OPTION('m', OPTION_STARTMUTED),
- AST_APP_OPTION_ARG('M', OPTION_MUSICONHOLD, OPTION_MUSICONHOLD_CLASS),
- AST_APP_OPTION('1', OPTION_NOONLYPERSON),
- AST_APP_OPTION('s', OPTION_MENU),
- AST_APP_OPTION('w', OPTION_WAITMARKED),
- AST_APP_OPTION('q', OPTION_QUIET),
-});
-
-/* Maximum length of a conference bridge name */
-#define MAX_CONF_NAME 32
-
/* Number of buckets our conference bridges container can have */
#define CONFERENCE_BRIDGE_BUCKETS 53
-/*! \brief The structure that represents a conference bridge */
-struct conference_bridge {
- char name[MAX_CONF_NAME]; /*!< Name of the conference bridge */
- struct ast_bridge *bridge; /*!< Bridge structure doing the mixing */
- unsigned int users; /*!< Number of users present */
- unsigned int markedusers; /*!< Number of marked users present */
- unsigned int locked:1; /*!< Is this conference bridge locked? */
- AST_LIST_HEAD_NOLOCK(, conference_bridge_user) users_list; /*!< List of users participating in the conference bridge */
- struct ast_channel *playback_chan; /*!< Channel used for playback into the conference bridge */
- ast_mutex_t playback_lock; /*!< Lock used for playback channel */
-};
-
-/*! \brief The structure that represents a conference bridge user */
-struct conference_bridge_user {
- struct conference_bridge *conference_bridge; /*!< Conference bridge they are participating in */
- struct ast_channel *chan; /*!< Asterisk channel participating */
- struct ast_flags flags; /*!< Flags passed in when the application was called */
- char *opt_args[OPTION_ARRAY_SIZE]; /*!< Arguments to options passed when application was called */
- struct ast_bridge_features features; /*!< Bridge features structure */
- unsigned int kicked:1; /*!< User has been kicked from the conference */
- AST_LIST_ENTRY(conference_bridge_user) list; /*!< Linked list information */
-};
-
/*! \brief Container to hold all conference bridges in progress */
static struct ao2_container *conference_bridges;
static int play_sound_file(struct conference_bridge *conference_bridge, const char *filename);
+static int play_sound_number(struct conference_bridge *conference_bridge, int say_number);
+static int execute_menu_entry(struct conference_bridge *conference_bridge,
+ struct conference_bridge_user *conference_bridge_user,
+ struct ast_bridge_channel *bridge_channel,
+ struct conf_menu_entry *menu_entry,
+ struct conf_menu *menu);
/*! \brief Hashing function used for conference bridges container */
static int conference_bridge_hash_cb(const void *obj, const int flags)
@@ -193,34 +259,320 @@
return (!strcasecmp(conference_bridge0->name, conference_bridge1->name) ? CMP_MATCH | CMP_STOP : 0);
}
+const char *conf_get_sound(enum conf_sounds sound, struct bridge_profile_sounds *custom_sounds)
+{
+ switch (sound) {
+ case CONF_SOUND_HAS_JOINED:
+ return S_OR(custom_sounds->hasjoin, "conf-hasjoin");
+ case CONF_SOUND_HAS_LEFT:
+ return S_OR(custom_sounds->hasleft, "conf-hasleft");
+ case CONF_SOUND_KICKED:
+ return S_OR(custom_sounds->kicked, "conf-kicked");
+ case CONF_SOUND_MUTED:
+ return S_OR(custom_sounds->muted, "conf-muted");
+ case CONF_SOUND_UNMUTED:
+ return S_OR(custom_sounds->unmuted, "conf-unmuted");
+ case CONF_SOUND_ONLY_ONE:
+ return S_OR(custom_sounds->onlyone, "conf-onlyone");
+ case CONF_SOUND_THERE_ARE:
+ return S_OR(custom_sounds->thereare, "conf-thereare");
+ case CONF_SOUND_OTHER_IN_PARTY:
+ return S_OR(custom_sounds->otherinparty, "conf-otherinparty");
+ case CONF_SOUND_PLACE_IN_CONF:
+ return S_OR(custom_sounds->placeintoconf, "conf-placeintoconf");
+ case CONF_SOUND_WAIT_FOR_LEADER:
+ return S_OR(custom_sounds->waitforleader, "conf-waitforleader");
+ case CONF_SOUND_LEADER_HAS_LEFT:
+ return S_OR(custom_sounds->leaderhasleft, "conf-leaderhasleft");
+ case CONF_SOUND_GET_PIN:
+ return S_OR(custom_sounds->getpin, "conf-getpin");
+ case CONF_SOUND_INVALID_PIN:
+ return S_OR(custom_sounds->invalidpin, "conf-invalidpin");
+ case CONF_SOUND_ONLY_PERSON:
+ return S_OR(custom_sounds->onlyperson, "conf-onlyperson");
+ case CONF_SOUND_LOCKED:
+ return S_OR(custom_sounds->locked, "conf-locked");
+ case CONF_SOUND_LOCKED_NOW:
+ return S_OR(custom_sounds->lockednow, "conf-lockednow");
+ case CONF_SOUND_UNLOCKED_NOW:
+ return S_OR(custom_sounds->unlockednow, "conf-unlockednow");
+ case CONF_SOUND_ERROR_MENU:
+ return S_OR(custom_sounds->errormenu, "conf-errormenu");
+ case CONF_SOUND_JOIN:
+ return S_OR(custom_sounds->join, "beep");
+ case CONF_SOUND_LEAVE:
+ return S_OR(custom_sounds->leave, "beeperr");
+ }
+
+ return "";
+}
+
+static struct ast_frame *rec_read(struct ast_channel *ast)
+{
+ return &ast_null_frame;
+}
+static int rec_write(struct ast_channel *ast, struct ast_frame *f)
+{
+ return 0;
+}
+static struct ast_channel *rec_request(const char *type, struct ast_format_cap *cap, const struct ast_channel *requestor, void *data, int *cause);
+static struct ast_channel_tech record_tech = {
+ .type = "ConfBridgeRec",
+ .description = "Conference Bridge Recording Channel",
+ .requester = rec_request,
+ .read = rec_read,
+ .write = rec_write,
+};
+static struct ast_channel *rec_request(const char *type, struct ast_format_cap *cap, const struct ast_channel *requestor, void *data, int *cause)
+{
+ struct ast_channel *tmp;
+ struct ast_format fmt;
+ const char *conf_name = data;
+ if (!(tmp = ast_channel_alloc(1, AST_STATE_UP, 0, 0, "", "", "", NULL, 0,
+ "ConfBridgeRecorder/conf-%s-uid-%d",
+ conf_name,
+ (int) ast_random()))) {
+ return NULL;
+ }
+ ast_format_set(&fmt, AST_FORMAT_SLINEAR, 0);
+ tmp->tech = &record_tech;
+ ast_format_cap_add_all(tmp->nativeformats);
+ ast_format_copy(&tmp->writeformat, &fmt);
+ ast_format_copy(&tmp->rawwriteformat, &fmt);
+ ast_format_copy(&tmp->readformat, &fmt);
+ ast_format_copy(&tmp->rawreadformat, &fmt);
+ return tmp;
+}
+
+static void *record_thread(void *obj)
+{
+ struct conference_bridge *conference_bridge = obj;
+ struct ast_app *mixmonapp = pbx_findapp("MixMonitor");
+ struct ast_channel *chan;
+ struct ast_str *filename = ast_str_alloca(PATH_MAX);
+
+ if (!mixmonapp) {
+ ao2_ref(conference_bridge, -1);
+ return NULL;
+ }
+
+ ao2_lock(conference_bridge);
+ if (!(conference_bridge->record_chan)) {
+ conference_bridge->record_thread = AST_PTHREADT_NULL;
+ ao2_unlock(conference_bridge);
+ ao2_ref(conference_bridge, -1);
+ return NULL;
+ }
+ chan = ast_channel_ref(conference_bridge->record_chan);
+
+ if (!(ast_strlen_zero(conference_bridge->b_profile.rec_file))) {
+ ast_str_append(&filename, 0, "%s", conference_bridge->b_profile.rec_file);
+ } else {
+ time_t now;
+ time(&now);
+ ast_str_append(&filename, 0, "confbridge-%s-%u.wav",
+ conference_bridge->name,
+ (unsigned int) now);
+ }
+ ao2_unlock(conference_bridge);
+
+ ast_answer(chan);
+ pbx_exec(chan, mixmonapp, ast_str_buffer(filename));
+ ast_bridge_join(conference_bridge->bridge, chan, NULL, NULL, NULL);
+
+ ao2_lock(conference_bridge);
+ conference_bridge->record_thread = AST_PTHREADT_NULL;
+ ao2_unlock(conference_bridge);
+
+ ast_hangup(chan); /* This will eat this threads reference to the channel as well */
+ ao2_ref(conference_bridge, -1);
+ return NULL;
+}
+
+/*!
+ * \internal
+ * \brief Returns whether or not conference is being recorded.
+ * \retval 1, conference is recording.
+ * \retval 0, conference is NOT recording.
+ */
+static int conf_is_recording(struct conference_bridge *conference_bridge)
+{
+ int res = 0;
+ ao2_lock(conference_bridge);
+ if (conference_bridge->record_chan || conference_bridge->record_thread != AST_PTHREADT_NULL) {
+ res = 1;
+ }
+ ao2_unlock(conference_bridge);
+ return res;
+}
+
+/*!
+ * \internal
+ * \brief Stops the confbridge recording thread.
+ *
+ * \note do not call this function with any locks
+ */
+static int conf_stop_record(struct conference_bridge *conference_bridge)
+{
+ ao2_lock(conference_bridge);
+
+ if (conference_bridge->record_thread != AST_PTHREADT_NULL) {
+ struct ast_channel *chan = ast_channel_ref(conference_bridge->record_chan);
+ pthread_t thread = conference_bridge->record_thread;
+ ao2_unlock(conference_bridge);
+
+ ast_bridge_remove(conference_bridge->bridge, chan);
+ ast_queue_frame(chan, &ast_null_frame);
+
+ chan = ast_channel_unref(chan);
+ pthread_join(thread, NULL);
+
+ ao2_lock(conference_bridge);
+ }
+
+ /* this is the reference given to the channel during the channel alloc */
+ if (conference_bridge->record_chan) {
+ conference_bridge->record_chan = ast_channel_unref(conference_bridge->record_chan);
+ }
+
+ ao2_unlock(conference_bridge);
+ return 0;
+}
+
+static int conf_start_record(struct conference_bridge *conference_bridge)
+{
+ struct ast_format_cap *cap = ast_format_cap_alloc_nolock();
+ struct ast_format tmpfmt;
+ int cause;
+
+ ao2_lock(conference_bridge);
+ if (conference_bridge->record_chan || conference_bridge->record_thread != AST_PTHREADT_NULL) {
+ ao2_unlock(conference_bridge);
+ return -1; /* already recording */
+ }
+ if (!cap) {
+ ao2_unlock(conference_bridge);
+ return -1;
+ }
+ if (!pbx_findapp("MixMonitor")) {
+ ast_log(LOG_WARNING, "Can not record ConfBridge, MixMonitor app is not installed\n");
+ cap = ast_format_cap_destroy(cap);
+ ao2_unlock(conference_bridge);
+ return -1;
+ }
+ ast_format_cap_add(cap, ast_format_set(&tmpfmt, AST_FORMAT_SLINEAR, 0));
+ if (!(conference_bridge->record_chan = ast_request("ConfBridgeRec", cap, NULL, conference_bridge->name, &cause))) {
+ cap = ast_format_cap_destroy(cap);
+ ao2_unlock(conference_bridge);
+ return -1;
+ }
+
+ cap = ast_format_cap_destroy(cap);
+ ao2_ref(conference_bridge, +1); /* give the record thread a ref */
+
+ if (ast_pthread_create_background(&conference_bridge->record_thread, NULL, record_thread, conference_bridge)) {
+ ast_log(LOG_WARNING, "Failed to create recording channel for conference %s\n", conference_bridge->name);
+
+ ao2_unlock(conference_bridge);
+ ao2_ref(conference_bridge, -1); /* error so remove ref */
+ return -1;
+ }
+
+ ao2_unlock(conference_bridge);
+ return 0;
+}
+
+static void send_conf_start_event(const char *conf_name)
+{
+ manager_event(EVENT_FLAG_CALL, "ConfbridgeStart", "Conference: %s\r\n", conf_name);
+}
+
+static void send_conf_end_event(const char *conf_name)
+{
+ manager_event(EVENT_FLAG_CALL, "ConfbridgeEnd", "Conference: %s\r\n", conf_name);
+}
+
+static void send_join_event(struct ast_channel *chan, const char *conf_name)
+{
+ ast_manager_event(chan, EVENT_FLAG_CALL, "ConfbridgeJoin",
+ "Channel: %s\r\n"
+ "Uniqueid: %s\r\n"
+ "Conference: %s\r\n"
+ "CallerIDnum: %s\r\n"
+ "CallerIDname: %s\r\n",
+ chan->name,
+ chan->uniqueid,
+ conf_name,
+ S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, "<unknown>"),
+ S_COR(chan->caller.id.name.valid, chan->caller.id.name.str, "<unknown>")
+ );
+}
+
+static void send_leave_event(struct ast_channel *chan, const char *conf_name)
+{
+ ast_manager_event(chan, EVENT_FLAG_CALL, "ConfbridgeLeave",
+ "Channel: %s\r\n"
+ "Uniqueid: %s\r\n"
+ "Conference: %s\r\n"
+ "CallerIDnum: %s\r\n"
+ "CallerIDname: %s\r\n",
+ chan->name,
+ chan->uniqueid,
+ conf_name,
+ S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, "<unknown>"),
+ S_COR(chan->caller.id.name.valid, chan->caller.id.name.str, "<unknown>")
+ );
+}
+
/*!
* \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
- *
+ * \param (OPTIONAL) conference_bridge_user Caller
+ *
+ * \note if caller is NULL, the announcment will be sent to all participants in the conference.
* \return Returns nothing
*/
static void announce_user_count(struct conference_bridge *conference_bridge, struct conference_bridge_user *conference_bridge_user)
{
+ const char *other_in_party = conf_get_sound(CONF_SOUND_OTHER_IN_PARTY, conference_bridge->b_profile.sounds);
+ const char *only_one = conf_get_sound(CONF_SOUND_ONLY_ONE, conference_bridge->b_profile.sounds);
+ const char *there_are = conf_get_sound(CONF_SOUND_THERE_ARE, conference_bridge->b_profile.sounds);
+
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;
+ if (conference_bridge_user) {
+ /* Eep, there is one other person */
+ if (ast_stream_and_wait(conference_bridge_user->chan,
+ only_one,
+ "")) {
+ return;
+ }
+ } else {
+ play_sound_file(conference_bridge, only_one);
}
} 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, NULL)) {
- return;
- }
- if (ast_stream_and_wait(conference_bridge_user->chan, "conf-otherinparty", "")) {
- return;
+ if (conference_bridge_user) {
+ if (ast_stream_and_wait(conference_bridge_user->chan,
+ there_are,
+ "")) {
+ return;
+ }
+ if (ast_say_number(conference_bridge_user->chan, conference_bridge->users - 1, "", conference_bridge_user->chan->language, NULL)) {
+ return;
+ }
+ if (ast_stream_and_wait(conference_bridge_user->chan,
+ other_in_party,
+ "")) {
+ return;
+ }
+ } else {
+ play_sound_file(conference_bridge, there_are);
+ play_sound_number(conference_bridge, conference_bridge->users - 1);
+ play_sound_file(conference_bridge, other_in_party);
}
}
}
@@ -253,7 +605,7 @@
*/
static void post_join_marked(struct conference_bridge *conference_bridge, struct conference_bridge_user *conference_bridge_user)
{
- if (ast_test_flag(&conference_bridge_user->flags, OPTION_MARKEDUSER)) {
+ if (ast_test_flag(&conference_bridge_user->u_profile, USER_OPT_MARKEDUSER)) {
struct conference_bridge_user *other_conference_bridge_user = NULL;
/* If we are not the first marked user to join just bail out now */
@@ -266,17 +618,18 @@
if (other_conference_bridge_user == conference_bridge_user) {
continue;
}
- if (ast_test_flag(&other_conference_bridge_user->flags, OPTION_MUSICONHOLD) && !ast_bridge_suspend(conference_bridge->bridge, other_conference_bridge_user->chan)) {
+ if (ast_test_flag(&other_conference_bridge_user->u_profile, USER_OPT_MUSICONHOLD) && !ast_bridge_suspend(conference_bridge->bridge, other_conference_bridge_user->chan)) {
ast_moh_stop(other_conference_bridge_user->chan);
ast_bridge_unsuspend(conference_bridge->bridge, other_conference_bridge_user->chan);
}
}
/* Next play the audio file stating they are going to be placed into the conference */
- if (!ast_test_flag(&conference_bridge_user->flags, OPTION_QUIET)) {
+ if (!ast_test_flag(&conference_bridge_user->u_profile, USER_OPT_QUIET)) {
ao2_unlock(conference_bridge);
ast_autoservice_start(conference_bridge_user->chan);
- play_sound_file(conference_bridge, "conf-placeintoconf");
+ play_sound_file(conference_bridge,
+ conf_get_sound(CONF_SOUND_PLACE_IN_CONF, conference_bridge_user->b_profile.sounds));
ast_autoservice_stop(conference_bridge_user->chan);
ao2_lock(conference_bridge);
}
@@ -286,7 +639,10 @@
if (other_conference_bridge_user == conference_bridge_user) {
continue;
}
- other_conference_bridge_user->features.mute = 0;
+ /* only unmute them if they are not supposed to start muted */
+ if (!ast_test_flag(&other_conference_bridge_user->u_profile, USER_OPT_STARTMUTED)) {
+ other_conference_bridge_user->features.mute = 0;
+ }
}
} else {
@@ -297,15 +653,17 @@
/* Be sure we are muted so we can't talk to anybody else waiting */
conference_bridge_user->features.mute = 1;
/* If we have not been quieted play back that they are waiting for the leader */
- if (!ast_test_flag(&conference_bridge_user->flags, OPTION_QUIET)) {
- play_prompt_to_channel(conference_bridge, conference_bridge_user->chan, "conf-waitforleader");
+ if (!ast_test_flag(&conference_bridge_user->u_profile, USER_OPT_QUIET)) {
+ play_prompt_to_channel(conference_bridge,
+ conference_bridge_user->chan,
+ conf_get_sound(CONF_SOUND_WAIT_FOR_LEADER, conference_bridge_user->b_profile.sounds));
}
/* Start music on hold if needed */
/* We need to recheck the markedusers value here. play_prompt_to_channel unlocks the conference bridge, potentially
* allowing a marked user to enter while the prompt was playing
*/
- if (!conference_bridge->markedusers && ast_test_flag(&conference_bridge_user->flags, OPTION_MUSICONHOLD)) {
- ast_moh_start(conference_bridge_user->chan, conference_bridge_user->opt_args[OPTION_MUSICONHOLD_CLASS], NULL);
+ if (!conference_bridge->markedusers && ast_test_flag(&conference_bridge_user->u_profile, USER_OPT_MUSICONHOLD)) {
+ ast_moh_start(conference_bridge_user->chan, conference_bridge_user->u_profile.moh_class, NULL);
}
}
}
@@ -323,21 +681,23 @@
/* Play back audio prompt and start MOH if need be if we are the first participant */
if (conference_bridge->users == 1) {
/* If audio prompts have not been quieted or this prompt quieted play it on out */
- if (!ast_test_flag(&conference_bridge_user->flags, OPTION_QUIET | OPTION_NOONLYPERSON)) {
- play_prompt_to_channel(conference_bridge, conference_bridge_user->chan, "conf-onlyperson");
+ if (!ast_test_flag(&conference_bridge_user->u_profile, USER_OPT_QUIET | USER_OPT_NOONLYPERSON)) {
+ play_prompt_to_channel(conference_bridge,
+ conference_bridge_user->chan,
+ conf_get_sound(CONF_SOUND_ONLY_PERSON, conference_bridge_user->b_profile.sounds));
}
/* If we need to start music on hold on the channel do so now */
/* We need to re-check the number of users in the conference bridge here because another conference bridge
* participant could have joined while the above prompt was playing for the first user.
*/
- if (conference_bridge->users == 1 && ast_test_flag(&conference_bridge_user->flags, OPTION_MUSICONHOLD)) {
- ast_moh_start(conference_bridge_user->chan, conference_bridge_user->opt_args[OPTION_MUSICONHOLD_CLASS], NULL);
+ if (conference_bridge->users == 1 && ast_test_flag(&conference_bridge_user->u_profile, USER_OPT_MUSICONHOLD)) {
+ ast_moh_start(conference_bridge_user->chan, conference_bridge_user->u_profile.moh_class, NULL);
}
return;
}
/* Announce number of users if need be */
- if (ast_test_flag(&conference_bridge_user->flags, OPTION_ANNOUNCEUSERCOUNT)) {
+ if (ast_test_flag(&conference_bridge_user->u_profile, USER_OPT_ANNOUNCEUSERCOUNT)) {
ao2_unlock(conference_bridge);
announce_user_count(conference_bridge, conference_bridge_user);
ao2_lock(conference_bridge);
@@ -348,10 +708,17 @@
struct conference_bridge_user *first_participant = AST_LIST_FIRST(&conference_bridge->users_list);
/* 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)) {
+ if (ast_test_flag(&first_participant->u_profile, USER_OPT_MUSICONHOLD) && !ast_bridge_suspend(conference_bridge->bridge, first_participant->chan)) {
ast_moh_stop(first_participant->chan);
ast_bridge_unsuspend(conference_bridge->bridge, first_participant->chan);
}
+ }
+
+ if (ast_test_flag(&conference_bridge_user->u_profile, USER_OPT_ANNOUNCEUSERCOUNTALL) &&
+ (conference_bridge->users > conference_bridge_user->u_profile.announce_user_count_all_after)) {
+ ao2_unlock(conference_bridge);
+ announce_user_count(conference_bridge, NULL);
+ ao2_lock(conference_bridge);
}
}
@@ -382,6 +749,7 @@
ast_bridge_destroy(conference_bridge->bridge);
conference_bridge->bridge = NULL;
}
+ conf_bridge_profile_destroy(&conference_bridge->b_profile);
}
/*!
@@ -396,6 +764,8 @@
{
struct conference_bridge *conference_bridge = NULL;
struct conference_bridge tmp;
+ int start_record = 0;
+ int max_members_reached = 0;
ast_copy_string(tmp.name, name, sizeof(tmp.name));
@@ -407,12 +777,18 @@
/* Attempt to find an existing conference bridge */
conference_bridge = ao2_find(conference_bridges, &tmp, OBJ_POINTER);
+ if (conference_bridge && conference_bridge->b_profile.max_members) {
+ max_members_reached = conference_bridge->b_profile.max_members > conference_bridge->users ? 0 : 1;
+ }
+
/* When finding a conference bridge that already exists make sure that it is not locked, and if so that we are not an admin */
- if (conference_bridge && conference_bridge->locked && !ast_test_flag(&conference_bridge_user->flags, OPTION_ADMIN)) {
+ if (conference_bridge && (max_members_reached || conference_bridge->locked) && !ast_test_flag(&conference_bridge_user->u_profile, USER_OPT_ADMIN)) {
ao2_unlock(conference_bridges);
ao2_ref(conference_bridge, -1);
ast_debug(1, "Conference bridge '%s' is locked and caller is not an admin\n", name);
- ast_stream_and_wait(conference_bridge_user->chan, "conf-locked", "");
+ ast_stream_and_wait(conference_bridge_user->chan,
+ conf_get_sound(CONF_SOUND_LOCKED, conference_bridge_user->b_profile.sounds),
+ "");
return NULL;
}
@@ -426,10 +802,12 @@
}
/* Setup conference bridge parameters */
+ conference_bridge->record_thread = AST_PTHREADT_NULL;
ast_copy_string(conference_bridge->name, name, sizeof(conference_bridge->name));
+ conf_bridge_profile_copy(&conference_bridge->b_profile, &conference_bridge_user->b_profile);
/* Create an actual bridge that will do the audio mixing */
- if (!(conference_bridge->bridge = ast_bridge_new(AST_BRIDGE_CAPABILITY_1TO1MIX, AST_BRIDGE_FLAG_SMART))) {
+ if (!(conference_bridge->bridge = ast_bridge_new(AST_BRIDGE_CAPABILITY_MULTIMIX, 0))) {
ao2_ref(conference_bridge, -1);
conference_bridge = NULL;
ao2_unlock(conference_bridges);
@@ -437,12 +815,19 @@
return NULL;
}
+ /* Set the internal sample rate on the bridge from the bridge profile */
+ ast_bridge_set_internal_sample_rate(conference_bridge->bridge, conference_bridge->b_profile.internal_sample_rate);
+ /* Set the internal mixing interval on the bridge from the bridge profile */
+ ast_bridge_set_mixing_interval(conference_bridge->bridge, conference_bridge->b_profile.mix_interval);
+
/* Setup lock for playback channel */
ast_mutex_init(&conference_bridge->playback_lock);
[... 6188 lines stripped ...]
More information about the asterisk-commits
mailing list