aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorPatrick McHardy <kaber@trash.net>2011-06-08 14:20:40 +0200
committerPatrick McHardy <kaber@trash.net>2011-06-08 14:20:40 +0200
commit84c94e92c153057470194aadf7ae22a2569f1bd4 (patch)
tree122c43bc5c85c2e2a81b2ab6cd7d59d9d71c4475 /apps
parent2ac6b3ac85972f5d4ec2b82eb299a7d85ff91c92 (diff)
parent70f4b1801b76660aed3487fa304e71f872daa077 (diff)
Merge 192.168.0.100:/repos/git/asterisk
Diffstat (limited to 'apps')
-rw-r--r--apps/Makefile6
-rw-r--r--apps/app_amd.c3
-rw-r--r--apps/app_chanspy.c5
-rw-r--r--apps/app_confbridge.c2125
-rw-r--r--apps/app_dial.c52
-rw-r--r--apps/app_directed_pickup.c212
-rw-r--r--apps/app_dumpchan.c155
-rw-r--r--apps/app_fax.c6
-rw-r--r--apps/app_festival.c8
-rw-r--r--apps/app_followme.c2
-rw-r--r--apps/app_ices.c3
-rw-r--r--apps/app_meetme.c51
-rw-r--r--apps/app_minivm.c26
-rw-r--r--apps/app_originate.c5
-rw-r--r--apps/app_privacy.c3
-rw-r--r--apps/app_queue.c51
-rw-r--r--apps/app_rpt.c8
-rw-r--r--apps/app_userevent.c7
-rw-r--r--apps/app_voicemail.c44
-rw-r--r--apps/confbridge/conf_config_parser.c1444
-rw-r--r--apps/confbridge/include/confbridge.h320
21 files changed, 3928 insertions, 608 deletions
diff --git a/apps/Makefile b/apps/Makefile
index 4343f3c30..7f8e7c9c2 100644
--- a/apps/Makefile
+++ b/apps/Makefile
@@ -27,6 +27,12 @@ all: _all
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
diff --git a/apps/app_amd.c b/apps/app_amd.c
index 60c13fd95..7c4e2a47a 100644
--- a/apps/app_amd.c
+++ b/apps/app_amd.c
@@ -157,7 +157,6 @@ static void isAnsweringMachine(struct ast_channel *chan, const char *data)
int iTotalTime = 0;
int iWordsCount = 0;
int currentState = STATE_IN_WORD;
- int previousState = STATE_IN_SILENCE;
int consecutiveVoiceDuration = 0;
char amdCause[256] = "", amdStatus[256] = "";
char *parse = ast_strdupa(data);
@@ -303,7 +302,6 @@ static void isAnsweringMachine(struct ast_channel *chan, const char *data)
if (silenceDuration >= betweenWordsSilence) {
if (currentState != STATE_IN_SILENCE ) {
- previousState = currentState;
ast_verb(3, "AMD: Channel [%s]. Changed state to STATE_IN_SILENCE\n", chan->name);
}
/* Find words less than word duration */
@@ -343,7 +341,6 @@ static void isAnsweringMachine(struct ast_channel *chan, const char *data)
if (consecutiveVoiceDuration >= minimumWordLength && currentState == STATE_IN_SILENCE) {
iWordsCount++;
ast_verb(3, "AMD: Channel [%s]. Word detected. iWordsCount:%d\n", chan->name, iWordsCount);
- previousState = currentState;
currentState = STATE_IN_WORD;
}
if (consecutiveVoiceDuration >= maximumWordLength){
diff --git a/apps/app_chanspy.c b/apps/app_chanspy.c
index 994a03a18..c90a7907a 100644
--- a/apps/app_chanspy.c
+++ b/apps/app_chanspy.c
@@ -404,6 +404,7 @@ struct chanspy_translation_helper {
struct ast_audiohook bridge_whisper_audiohook;
int fd;
int volfactor;
+ struct ast_flags flags;
};
struct spy_dtmf_options {
@@ -438,7 +439,7 @@ static int spy_generate(struct ast_channel *chan, void *data, int len, int sampl
return -1;
}
- if (ast_test_flag(&csth->spy_audiohook, OPTION_READONLY)) {
+ if (ast_test_flag(&csth->flags, OPTION_READONLY)) {
/* Option 'o' was set, so don't mix channel audio */
f = ast_audiohook_read_frame(&csth->spy_audiohook, samples, AST_AUDIOHOOK_DIRECTION_READ, &format_slin);
} else {
@@ -539,7 +540,7 @@ static int channel_spy(struct ast_channel *chan, struct ast_autochan *spyee_auto
spyer_name, name);
memset(&csth, 0, sizeof(csth));
- ast_copy_flags(&csth.spy_audiohook, flags, AST_FLAGS_ALL);
+ ast_copy_flags(&csth.flags, flags, AST_FLAGS_ALL);
ast_audiohook_init(&csth.spy_audiohook, AST_AUDIOHOOK_TYPE_SPY, "ChanSpy", 0);
diff --git a/apps/app_confbridge.c b/apps/app_confbridge.c
index e533c80e7..7cede133e 100644
--- a/apps/app_confbridge.c
+++ b/apps/app_confbridge.c
@@ -4,6 +4,7 @@
* Copyright (C) 2007-2008, Digium, Inc.
*
* Joshua Colp <jcolp@digium.com>
+ * David Vossel <dvossel@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@digium.com> \endverbatim
+ * \author\verbatim David Vossel <dvossel@digium.com> \endverbatim
*
* This is a conference bridge application utilizing the bridging core.
* \ingroup applications
@@ -38,69 +40,183 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#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 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
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 @@ static int conference_bridge_cmp_cb(void *obj, void *arg, int flags)
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, "confbridge-join");
+ case CONF_SOUND_LEAVE:
+ return S_OR(custom_sounds->leave, "confbridge-leave");
+ }
+
+ 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 play_prompt_to_channel(struct conference_bridge *conference_bridge,
*/
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 @@ static void post_join_marked(struct conference_bridge *conference_bridge, struct
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 @@ static void post_join_marked(struct conference_bridge *conference_bridge, struct
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 @@ static void post_join_marked(struct conference_bridge *conference_bridge, struct
/* 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 @@ static void post_join_unmarked(struct conference_bridge *conference_bridge, stru
/* 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,11 +708,18 @@ static void post_join_unmarked(struct conference_bridge *conference_bridge, stru
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 @@ static void destroy_conference_bridge(void *obj)
ast_bridge_destroy(conference_bridge->bridge);
conference_bridge->bridge = NULL;
}
+ conf_bridge_profile_destroy(&conference_bridge->b_profile);
}
/*!
@@ -396,6 +764,8 @@ static struct conference_bridge *join_conference_bridge(const char *name, struct
{
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 @@ static struct conference_bridge *join_conference_bridge(const char *name, struct
/* 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 @@ static struct conference_bridge *join_conference_bridge(const char *name, struct
}
/* 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 @@ static struct conference_bridge *join_conference_bridge(const char *name, struct
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);
/* Link it into the conference bridges container */
ao2_link(conference_bridges, conference_bridge);
+
+ send_conf_start_event(conference_bridge->name);
ast_debug(1, "Created conference bridge '%s' and linked to container '%p'\n", name, conference_bridges);
}
@@ -460,7 +845,7 @@ static struct conference_bridge *join_conference_bridge(const char *name, struct
conference_bridge->users++;
/* If the caller is a marked user bump up the count */
- if (ast_test_flag(&conference_bridge_user->flags, OPTION_MARKEDUSER)) {
+ if (ast_test_flag(&conference_bridge_user->u_profile, USER_OPT_MARKEDUSER)) {
conference_bridge->markedusers++;
}
@@ -470,14 +855,23 @@ static struct conference_bridge *join_conference_bridge(const char *name, struct
}
/* If the caller is a marked user or is waiting for a marked user to enter pass 'em off, otherwise pass them off to do regular joining stuff */
- if (ast_test_flag(&conference_bridge_user->flags, OPTION_MARKEDUSER | OPTION_WAITMARKED)) {
+ if (ast_test_flag(&conference_bridge_user->u_profile, USER_OPT_MARKEDUSER | USER_OPT_WAITMARKED)) {
post_join_marked(conference_bridge, conference_bridge_user);
} else {
post_join_unmarked(conference_bridge, conference_bridge_user);
}
+ /* check to see if recording needs to be started or not */
+ if (ast_test_flag(&conference_bridge->b_profile, BRIDGE_OPT_RECORD_CONFERENCE) && !conf_is_recording(conference_bridge)) {
+ start_record = 1;
+ }
+
ao2_unlock(conference_bridge);
+ if (start_record) {
+ conf_start_record(conference_bridge);
+ }
+
return conference_bridge;
}
@@ -488,12 +882,12 @@ static struct conference_bridge *join_conference_bridge(const char *name, struct
* \param conference_bridge_user The conference bridge user structure
*
*/
-static void leave_conference_bridge(struct conference_bridge *conference_bridge, struct conference_bridge_user *conference_bridge_user)
+static void leave_conference_bridge(struct conference_bridge *conference_bridge, struct conference_bridge_user *conference_bridge_user)
{
ao2_lock(conference_bridge);
/* If this caller is a marked user bump down the count */
- if (ast_test_flag(&conference_bridge_user->flags, OPTION_MARKEDUSER)) {
+ if (ast_test_flag(&conference_bridge_user->u_profile, USER_OPT_MARKEDUSER)) {
conference_bridge->markedusers--;
}
@@ -505,7 +899,7 @@ static void leave_conference_bridge(struct conference_bridge *conference_bridge
/* If there are still users in the conference bridge we may need to do things (such as start MOH on them) */
if (conference_bridge->users) {
- if (ast_test_flag(&conference_bridge_user->flags, OPTION_MARKEDUSER) && !conference_bridge->markedusers) {
+ if (ast_test_flag(&conference_bridge_user->u_profile, USER_OPT_MARKEDUSER) && !conference_bridge->markedusers) {
struct conference_bridge_user *other_participant = NULL;
/* Start out with muting everyone */
@@ -514,18 +908,22 @@ static void leave_conference_bridge(struct conference_bridge *conference_bridge
}
/* Play back the audio prompt saying the leader has left 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-leaderhasleft");
+ play_sound_file(conference_bridge,
+ conf_get_sound(CONF_SOUND_LEADER_HAS_LEFT, conference_bridge_user->b_profile.sounds));
ast_autoservice_stop(conference_bridge_user->chan);
ao2_lock(conference_bridge);
}
- /* Now on to starting MOH if needed */
+ /* Now on to starting MOH or kick if needed */
AST_LIST_TRAVERSE(&conference_bridge->users_list, other_participant, list) {
- if (ast_test_flag(&other_participant->flags, OPTION_MUSICONHOLD) && !ast_bridge_suspend(conference_bridge->bridge, other_participant->chan)) {
- ast_moh_start(other_participant->chan, other_participant->opt_args[OPTION_MUSICONHOLD_CLASS], NULL);
+ if (ast_test_flag(&other_participant->u_profile, USER_OPT_ENDMARKED)) {
+ other_participant->kicked = 1;
+ ast_bridge_remove(conference_bridge->bridge, other_participant->chan);
+ } else if (ast_test_flag(&other_participant->u_profile, USER_OPT_MUSICONHOLD) && !ast_bridge_suspend(conference_bridge->bridge, other_participant->chan)) {
+ ast_moh_start(other_participant->chan, other_participant->u_profile.moh_class, NULL);
ast_bridge_unsuspend(conference_bridge->bridge, other_participant->chan);
}
}
@@ -533,8 +931,8 @@ static void leave_conference_bridge(struct conference_bridge *conference_bridge
/* Of course if there is one other person in here we may need to start up MOH on them */
struct conference_bridge_user *first_participant = AST_LIST_FIRST(&conference_bridge->users_list);
- if (ast_test_flag(&first_participant->flags, OPTION_MUSICONHOLD) && !ast_bridge_suspend(conference_bridge->bridge, first_participant->chan)) {
- ast_moh_start(first_participant->chan, first_participant->opt_args[OPTION_MUSICONHOLD_CLASS], NULL);
+ if (ast_test_flag(&first_participant->u_profile, USER_OPT_MUSICONHOLD) && !ast_bridge_suspend(conference_bridge->bridge, first_participant->chan)) {
+ ast_moh_start(first_participant->chan, first_participant->u_profile.moh_class, NULL);
ast_bridge_unsuspend(conference_bridge->bridge, first_participant->chan);
}
}
@@ -543,55 +941,65 @@ static void leave_conference_bridge(struct conference_bridge *conference_bridge
ast_devstate_changed(AST_DEVICE_NOT_INUSE, "confbridge:%s", conference_bridge->name);
ao2_unlink(conference_bridges, conference_bridge);
+ send_conf_end_event(conference_bridge->name);
}
/* Done mucking with the conference bridge, huzzah */
ao2_unlock(conference_bridge);
+ if (!conference_bridge->users) {
+ conf_stop_record(conference_bridge);
+ }
+
ao2_ref(conference_bridge, -1);
}
/*!
- * \brief Play sound file into conference bridge
- *
- * \param conference_bridge The conference bridge to play sound file into
- * \param filename Sound file to play
- *
- * \retval 0 success
- * \retval -1 failure
+ * \internal
+ * \brief allocates playback chan on a channel
+ * \pre expects conference to be locked before calling this function
*/
-static int play_sound_file(struct conference_bridge *conference_bridge, const char *filename)
+static int alloc_playback_chan(struct conference_bridge *conference_bridge)
{
- struct ast_channel *underlying_channel;
-
- ast_mutex_lock(&conference_bridge->playback_lock);
+ int cause;
+ struct ast_format_cap *cap;
+ struct ast_format tmpfmt;
- if (!(conference_bridge->playback_chan)) {
- int cause;
- struct ast_format_cap *cap = ast_format_cap_alloc_nolock();
- struct ast_format tmpfmt;
- if (!cap) {
- return -1;
- }
- ast_format_cap_add(cap, ast_format_set(&tmpfmt, AST_FORMAT_SLINEAR, 0));
- if (!(conference_bridge->playback_chan = ast_request("Bridge", cap, NULL, "", &cause))) {
- ast_mutex_unlock(&conference_bridge->playback_lock);
- cap = ast_format_cap_destroy(cap);
- return -1;
- }
+ if (conference_bridge->playback_chan) {
+ return 0;
+ }
+ if (!(cap = ast_format_cap_alloc_nolock())) {
+ return -1;
+ }
+ ast_format_cap_add(cap, ast_format_set(&tmpfmt, AST_FORMAT_SLINEAR, 0));
+ if (!(conference_bridge->playback_chan = ast_request("Bridge", cap, NULL, "", &cause))) {
cap = ast_format_cap_destroy(cap);
+ return -1;
+ }
+ cap = ast_format_cap_destroy(cap);
+
+ conference_bridge->playback_chan->bridge = conference_bridge->bridge;
+
+ if (ast_call(conference_bridge->playback_chan, "", 0)) {
+ ast_hangup(conference_bridge->playback_chan);
+ conference_bridge->playback_chan = NULL;
+ return -1;
+ }
+
+ ast_debug(1, "Created a playback channel to conference bridge '%s'\n", conference_bridge->name);
+ return 0;
+}
- conference_bridge->playback_chan->bridge = conference_bridge->bridge;
+static int play_sound_helper(struct conference_bridge *conference_bridge, const char *filename, int say_number)
+{
+ struct ast_channel *underlying_channel;
- if (ast_call(conference_bridge->playback_chan, "", 0)) {
- ast_hangup(conference_bridge->playback_chan);
- conference_bridge->playback_chan = NULL;
+ ast_mutex_lock(&conference_bridge->playback_lock);
+ if (!(conference_bridge->playback_chan)) {
+ if (alloc_playback_chan(conference_bridge)) {
ast_mutex_unlock(&conference_bridge->playback_lock);
return -1;
}
-
- ast_debug(1, "Created a playback channel to conference bridge '%s'\n", conference_bridge->name);
-
underlying_channel = conference_bridge->playback_chan->tech->bridged_channel(conference_bridge->playback_chan, NULL);
} else {
/* Channel was already available so we just need to add it back into the bridge */
@@ -600,7 +1008,11 @@ static int play_sound_file(struct conference_bridge *conference_bridge, const ch
}
/* The channel is all under our control, in goes the prompt */
- ast_stream_and_wait(conference_bridge->playback_chan, filename, "");
+ if (!ast_strlen_zero(filename)) {
+ ast_stream_and_wait(conference_bridge->playback_chan, filename, "");
+ } else {
+ ast_say_number(conference_bridge->playback_chan, say_number, "", conference_bridge->playback_chan->language, NULL);
+ }
ast_debug(1, "Departing underlying channel '%s' from bridge '%p'\n", underlying_channel->name, conference_bridge->bridge);
ast_bridge_depart(conference_bridge->bridge, underlying_channel);
@@ -611,112 +1023,164 @@ static int play_sound_file(struct conference_bridge *conference_bridge, const ch
}
/*!
- * \brief DTMF Menu Callback
+ * \brief Play sound file into conference bridge
*
- * \param bridge Bridge this is involving
- * \param bridge_channel Bridged channel this is involving
- * \param hook_pvt User's conference bridge structure
+ * \param conference_bridge The conference bridge to play sound file into
+ * \param filename Sound file to play
*
* \retval 0 success
* \retval -1 failure
*/
-static int menu_callback(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel, void *hook_pvt)
+static int play_sound_file(struct conference_bridge *conference_bridge, const char *filename)
{
- struct conference_bridge_user *conference_bridge_user = hook_pvt;
- struct conference_bridge *conference_bridge = conference_bridge_user->conference_bridge;
- int digit, res = 0, isadmin = ast_test_flag(&conference_bridge_user->flags, OPTION_ADMIN);
+ return play_sound_helper(conference_bridge, filename, 0);
+}
- /* See if music on hold is playing */
- ao2_lock(conference_bridge);
- if (conference_bridge->users == 1 && ast_test_flag(&conference_bridge_user->flags, OPTION_MUSICONHOLD)) {
- /* Just us so MOH is probably indeed going, let's stop it */
- ast_moh_stop(bridge_channel->chan);
- }
- ao2_unlock(conference_bridge);
+/*!
+ * \brief Play number into the conference bridge
+ *
+ * \param conference_bridge The conference bridge to say the number into
+ * \param number to say
+ *
+ * \retval 0 success
+ * \retval -1 failure
+ */
+static int play_sound_number(struct conference_bridge *conference_bridge, int say_number)
+{
+ return play_sound_helper(conference_bridge, NULL, say_number);
+}
- /* Try to play back the user menu, if it fails pass this back up so the bridging core will act on it */
- if (ast_streamfile(bridge_channel->chan, (isadmin ? "conf-adminmenu" : "conf-usermenu"), bridge_channel->chan->language)) {
- res = -1;
- goto finished;
+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;
+
+ switch (bridge_channel->state) {
+ case AST_BRIDGE_CHANNEL_STATE_START_TALKING:
+ talking = 1;
+ break;
+ case AST_BRIDGE_CHANNEL_STATE_STOP_TALKING:
+ talking = 0;
+ break;
+ default:
+ return; /* uhh this shouldn't happen, but bail if it does. */
}
- /* Wait for them to enter a digit from the user menu options */
- digit = ast_waitstream(bridge_channel->chan, AST_DIGIT_ANY);
- ast_stopstream(bridge_channel->chan);
+ /* 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"
+ "Conference: %s\r\n"
+ "TalkingStatus: %s\r\n",
+ bridge_channel->chan->name, bridge_channel->chan->uniqueid, conf_name, talking ? "on" : "off");
+}
- if (digit == '1') {
- /* 1 - Mute or unmute yourself, note we only allow manipulation if they aren't waiting for a marked user or if marked users exist */
- if (!ast_test_flag(&conference_bridge_user->flags, OPTION_WAITMARKED) || conference_bridge->markedusers) {
- conference_bridge_user->features.mute = (!conference_bridge_user->features.mute ? 1 : 0);
+static int conf_get_pin(struct ast_channel *chan, struct conference_bridge_user *conference_bridge_user)
+{
+ char pin_guess[MAX_PIN+1] = { 0, };
+ const char *pin = conference_bridge_user->u_profile.pin;
+ char *tmp = pin_guess;
+ int i, res;
+ unsigned int len = MAX_PIN ;
+
+ /* give them three tries to get the pin right */
+ for (i = 0; i < 3; i++) {
+ if (ast_app_getdata(chan,
+ conf_get_sound(CONF_SOUND_GET_PIN, conference_bridge_user->b_profile.sounds),
+ tmp, len, 0) >= 0) {
+ if (!strcasecmp(pin, pin_guess)) {
+ return 0;
+ }
}
- res = ast_stream_and_wait(bridge_channel->chan, (conference_bridge_user->features.mute ? "conf-muted" : "conf-unmuted"), "");
- } else if (isadmin && digit == '2') {
- /* 2 - Unlock or lock conference */
- conference_bridge->locked = (!conference_bridge->locked ? 1 : 0);
- res = ast_stream_and_wait(bridge_channel->chan, (conference_bridge->locked ? "conf-lockednow" : "conf-unlockednow"), "");
- } else if (isadmin && digit == '3') {
- /* 3 - Eject last user */
- struct conference_bridge_user *last_participant = NULL;
-
- ao2_lock(conference_bridge);
- if (((last_participant = AST_LIST_LAST(&conference_bridge->users_list)) == conference_bridge_user) || (ast_test_flag(&last_participant->flags, OPTION_ADMIN))) {
- ao2_unlock(conference_bridge);
- res = ast_stream_and_wait(bridge_channel->chan, "conf-errormenu", "");
+ ast_streamfile(chan,
+ conf_get_sound(CONF_SOUND_INVALID_PIN, conference_bridge_user->b_profile.sounds),
+ chan->language);
+ res = ast_waitstream(chan, AST_DIGIT_ANY);
+ if (res > 0) {
+ /* Account for digit already read during ivalid pin playback
+ * resetting pin buf. */
+ pin_guess[0] = res;
+ pin_guess[1] = '\0';
+ tmp = pin_guess + 1;
+ len = MAX_PIN - 1;
} else {
- last_participant->kicked = 1;
- ast_bridge_remove(conference_bridge->bridge, last_participant->chan);
- ao2_unlock(conference_bridge);
+ /* reset pin buf as empty buffer. */
+ tmp = pin_guess;
+ len = MAX_PIN;
}
- } else if (digit == '4') {
- /* 4 - Decrease listening volume */
- ast_audiohook_volume_adjust(conference_bridge_user->chan, AST_AUDIOHOOK_DIRECTION_WRITE, -1);
- } else if (digit == '6') {
- /* 6 - Increase listening volume */
- ast_audiohook_volume_adjust(conference_bridge_user->chan, AST_AUDIOHOOK_DIRECTION_WRITE, 1);
- } else if (digit == '7') {
- /* 7 - Decrease talking volume */
- ast_audiohook_volume_adjust(conference_bridge_user->chan, AST_AUDIOHOOK_DIRECTION_READ, -1);
- } else if (digit == '8') {
- /* 8 - Exit the IVR */
- } else if (digit == '9') {
- /* 9 - Increase talking volume */
- ast_audiohook_volume_adjust(conference_bridge_user->chan, AST_AUDIOHOOK_DIRECTION_READ, 1);
- } else {
- /* No valid option was selected */
- res = ast_stream_and_wait(bridge_channel->chan, "conf-errormenu", "");
}
+ return -1;
+}
- finished:
- /* See if music on hold needs to be started back up again */
- ao2_lock(conference_bridge);
- if (conference_bridge->users == 1 && ast_test_flag(&conference_bridge_user->flags, OPTION_MUSICONHOLD)) {
- ast_moh_start(bridge_channel->chan, conference_bridge_user->opt_args[OPTION_MUSICONHOLD_CLASS], NULL);
- }
- ao2_unlock(conference_bridge);
+static int conf_rec_name(struct conference_bridge_user *user, const char *conf_name)
+{
+ char destdir[PATH_MAX];
+ int res;
+ int duration = 20;
- bridge_channel->state = AST_BRIDGE_CHANNEL_STATE_WAIT;
+ snprintf(destdir, sizeof(destdir), "%s/confbridge", ast_config_AST_SPOOL_DIR);
- return res;
+ if (ast_mkdir(destdir, 0777) != 0) {
+ ast_log(LOG_WARNING, "mkdir '%s' failed: %s\n", destdir, strerror(errno));
+ return -1;
+ }
+ snprintf(user->name_rec_location, sizeof(user->name_rec_location),
+ "%s/confbridge-name-%s-%s", destdir,
+ conf_name, user->chan->uniqueid);
+
+ res = ast_play_and_record(user->chan,
+ "vm-rec-name",
+ user->name_rec_location,
+ 10,
+ "sln",
+ &duration,
+ ast_dsp_get_threshold_from_settings(THRESHOLD_SILENCE),
+ 0,
+ NULL);
+
+ if (res == -1) {
+ user->name_rec_location[0] = '\0';
+ return -1;
+ }
+ return 0;
}
/*! \brief The ConfBridge application */
static int confbridge_exec(struct ast_channel *chan, const char *data)
{
int res = 0, volume_adjustments[2];
+ int quiet = 0;
char *parse;
+ const char *b_profile_name = DEFAULT_BRIDGE_PROFILE;
+ const char *u_profile_name = DEFAULT_USER_PROFILE;
struct conference_bridge *conference_bridge = NULL;
struct conference_bridge_user conference_bridge_user = {
.chan = chan,
+ .tech_args.talking_threshold = DEFAULT_TALKING_THRESHOLD,
+ .tech_args.silence_threshold = DEFAULT_SILENCE_THRESHOLD,
+ .tech_args.drop_silence = 0,
};
- const char *tmp, *join_sound = NULL, *leave_sound = NULL;
AST_DECLARE_APP_ARGS(args,
AST_APP_ARG(conf_name);
- AST_APP_ARG(options);
+ AST_APP_ARG(b_profile_name);
+ AST_APP_ARG(u_profile_name);
+ AST_APP_ARG(menu_name);
);
+ ast_bridge_features_init(&conference_bridge_user.features);
+
+ if (chan->_state != AST_STATE_UP) {
+ ast_answer(chan);
+ }
if (ast_strlen_zero(data)) {
ast_log(LOG_WARNING, "%s requires an argument (conference name[,options])\n", app);
- return -1;
+ res = -1; /* invalid PIN */
+ goto confbridge_cleanup;
}
/* We need to make a copy of the input string if we are going to modify it! */
@@ -724,54 +1188,146 @@ static int confbridge_exec(struct ast_channel *chan, const char *data)
AST_STANDARD_APP_ARGS(args, parse);
- if (args.argc == 2) {
- ast_app_parse_options(app_opts, &conference_bridge_user.flags, conference_bridge_user.opt_args, args.options);
+ /* bridge profile name */
+ if (args.argc > 1 && !ast_strlen_zero(args.b_profile_name)) {
+ b_profile_name = args.b_profile_name;
+ }
+ conf_find_bridge_profile(chan, b_profile_name, &conference_bridge_user.b_profile);
+
+ /* user profile name */
+ if (args.argc > 2 && !ast_strlen_zero(args.u_profile_name)) {
+ u_profile_name = args.u_profile_name;
+ }
+
+ conf_find_user_profile(chan, u_profile_name, &conference_bridge_user.u_profile);
+ quiet = ast_test_flag(&conference_bridge_user.u_profile, USER_OPT_QUIET);
+
+ /* ask for a PIN immediately after finding user profile. This has to be
+ * prompted for requardless of quiet setting. */
+ if (!ast_strlen_zero(conference_bridge_user.u_profile.pin)) {
+ if (conf_get_pin(chan, &conference_bridge_user)) {
+ res = -1; /* invalid PIN */
+ goto confbridge_cleanup;
+ }
+ }
+
+ /* See if we need them to record a intro name */
+ if (!quiet && ast_test_flag(&conference_bridge_user.u_profile, USER_OPT_ANNOUNCE_JOIN_LEAVE)) {
+ conf_rec_name(&conference_bridge_user, args.conf_name);
+ }
+
+ /* menu name */
+ if (args.argc > 3 && !ast_strlen_zero(args.menu_name)) {
+ ast_copy_string(conference_bridge_user.menu_name, args.menu_name, sizeof(conference_bridge_user.menu_name));
+ if (conf_set_menu_to_user(conference_bridge_user.menu_name, &conference_bridge_user)) {
+ ast_log(LOG_WARNING, "Conference menu %s does not exist and can not be applied to confbridge user.\n",
+ args.menu_name);
+ res = -1; /* invalid PIN */
+ goto confbridge_cleanup;
+ }
+ }
+
+ /* Set if DTMF should pass through for this user or not */
+ if (ast_test_flag(&conference_bridge_user.u_profile, USER_OPT_DTMF_PASS)) {
+ conference_bridge_user.features.dtmf_passthrough = 1;
+ }
+
+ /* Set dsp threshold values if present */
+ if (conference_bridge_user.u_profile.talking_threshold) {
+ conference_bridge_user.tech_args.talking_threshold = conference_bridge_user.u_profile.talking_threshold;
+ }
+ if (conference_bridge_user.u_profile.silence_threshold) {
+ conference_bridge_user.tech_args.silence_threshold = conference_bridge_user.u_profile.silence_threshold;
+ }
+
+ /* 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); /* this is freed during feature cleanup */
+ if (!(conf_name)) {
+ res = -1; /* invalid PIN */
+ goto confbridge_cleanup;
+ }
+ 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 */
if (!(conference_bridge = join_conference_bridge(args.conf_name, &conference_bridge_user))) {
- return -1;
+ res = -1; /* invalid PIN */
+ goto confbridge_cleanup;
}
/* Keep a copy of volume adjustments so we can restore them later if need be */
volume_adjustments[0] = ast_audiohook_volume_get(chan, AST_AUDIOHOOK_DIRECTION_READ);
volume_adjustments[1] = ast_audiohook_volume_get(chan, AST_AUDIOHOOK_DIRECTION_WRITE);
- /* Always initialize the features structure, we are in most cases always going to need it. */
- ast_bridge_features_init(&conference_bridge_user.features);
+ /* If the caller should be joined already muted, make it so */
+ if (ast_test_flag(&conference_bridge_user.u_profile, USER_OPT_STARTMUTED)) {
+ conference_bridge_user.features.mute = 1;
+ }
- /* If the menu option is enabled provide a user or admin menu as a custom feature hook */
- if (ast_test_flag(&conference_bridge_user.flags, OPTION_MENU)) {
- ast_bridge_features_hook(&conference_bridge_user.features, "#", menu_callback, &conference_bridge_user);
+ if (ast_test_flag(&conference_bridge_user.u_profile, USER_OPT_DROP_SILENCE)) {
+ conference_bridge_user.tech_args.drop_silence = 1;
}
- /* If the caller should be joined already muted, make it so */
- if (ast_test_flag(&conference_bridge_user.flags, OPTION_STARTMUTED)) {
- conference_bridge_user.features.mute = 1;
+ if (ast_test_flag(&conference_bridge_user.u_profile, USER_OPT_JITTERBUFFER)) {
+ char *func_jb;
+ if ((func_jb = ast_module_helper("", "func_jitterbuffer", 0, 0, 0, 0))) {
+ ast_free(func_jb);
+ ast_func_write(chan, "JITTERBUFFER(adaptive)", "default");
+ }
}
- /* Grab join/leave sounds from the channel */
- ast_channel_lock(chan);
- if ((tmp = pbx_builtin_getvar_helper(chan, "CONFBRIDGE_JOIN_SOUND"))) {
- join_sound = ast_strdupa(tmp);
+ if (ast_test_flag(&conference_bridge_user.u_profile, USER_OPT_DENOISE)) {
+ char *mod_speex;
+ /* Reduce background noise from each participant */
+ if ((mod_speex = ast_module_helper("", "codec_speex", 0, 0, 0, 0))) {
+ ast_free(mod_speex);
+ ast_func_write(chan, "DENOISE(rx)", "on");
+ }
}
- if ((tmp = pbx_builtin_getvar_helper(chan, "CONFBRIDGE_LEAVE_SOUND"))) {
- leave_sound = ast_strdupa(tmp);
+
+ /* if this user has a intro, play it before entering */
+ if (!ast_strlen_zero(conference_bridge_user.name_rec_location)) {
+ ast_autoservice_start(chan);
+ play_sound_file(conference_bridge, conference_bridge_user.name_rec_location);
+ play_sound_file(conference_bridge,
+ conf_get_sound(CONF_SOUND_HAS_JOINED, conference_bridge_user.b_profile.sounds));
+ ast_autoservice_stop(chan);
}
- ast_channel_unlock(chan);
- /* If there is 1 or more people already in the conference then play our join sound unless overridden */
- if (!ast_test_flag(&conference_bridge_user.flags, OPTION_QUIET) && !ast_strlen_zero(join_sound) && conference_bridge->users >= 2) {
+ /* Play the Join sound to both the conference and the user entering. */
+ if (!quiet) {
+ const char *join_sound = conf_get_sound(CONF_SOUND_JOIN, conference_bridge_user.b_profile.sounds);
+ ast_stream_and_wait(chan, join_sound, "");
ast_autoservice_start(chan);
play_sound_file(conference_bridge, join_sound);
ast_autoservice_stop(chan);
}
/* Join our conference bridge for real */
- ast_bridge_join(conference_bridge->bridge, chan, NULL, &conference_bridge_user.features);
+ send_join_event(conference_bridge_user.chan, conference_bridge->name);
+ ast_bridge_join(conference_bridge->bridge,
+ chan,
+ NULL,
+ &conference_bridge_user.features,
+ &conference_bridge_user.tech_args);
+ send_leave_event(conference_bridge_user.chan, conference_bridge->name);
+
+ /* if this user has a intro, play it when leaving */
+ if (!quiet && !ast_strlen_zero(conference_bridge_user.name_rec_location)) {
+ ast_autoservice_start(chan);
+ play_sound_file(conference_bridge, conference_bridge_user.name_rec_location);
+ play_sound_file(conference_bridge,
+ conf_get_sound(CONF_SOUND_HAS_LEFT, conference_bridge_user.b_profile.sounds));
+ ast_autoservice_stop(chan);
+ }
- /* If there is 1 or more people (not including us) already in the conference then play our leave sound unless overridden */
- if (!ast_test_flag(&conference_bridge_user.flags, OPTION_QUIET) && !ast_strlen_zero(leave_sound) && conference_bridge->users >= 2) {
+ /* play the leave sound */
+ if (!quiet) {
+ const char *leave_sound = conf_get_sound(CONF_SOUND_LEAVE, conference_bridge_user.b_profile.sounds);
ast_autoservice_start(chan);
play_sound_file(conference_bridge, leave_sound);
ast_autoservice_stop(chan);
@@ -785,8 +1341,10 @@ static int confbridge_exec(struct ast_channel *chan, const char *data)
ast_bridge_features_cleanup(&conference_bridge_user.features);
/* If the user was kicked from the conference play back the audio prompt for it */
- if (!ast_test_flag(&conference_bridge_user.flags, OPTION_QUIET) && conference_bridge_user.kicked) {
- res = ast_stream_and_wait(chan, "conf-kicked", "");
+ if (!quiet && conference_bridge_user.kicked) {
+ res = ast_stream_and_wait(chan,
+ conf_get_sound(CONF_SOUND_KICKED, conference_bridge_user.b_profile.sounds),
+ "");
}
/* Restore volume adjustments to previous values in case they were changed */
@@ -797,9 +1355,305 @@ static int confbridge_exec(struct ast_channel *chan, const char *data)
ast_audiohook_volume_set(chan, AST_AUDIOHOOK_DIRECTION_WRITE, volume_adjustments[1]);
}
+ if (!ast_strlen_zero(conference_bridge_user.name_rec_location)) {
+ ast_filedelete(conference_bridge_user.name_rec_location, NULL);
+ }
+
+confbridge_cleanup:
+ ast_bridge_features_cleanup(&conference_bridge_user.features);
+ conf_bridge_profile_destroy(&conference_bridge_user.b_profile);
+ return res;
+}
+
+static int action_toggle_mute(struct conference_bridge *conference_bridge,
+ struct conference_bridge_user *conference_bridge_user,
+ struct ast_channel *chan)
+{
+ /* Mute or unmute yourself, note we only allow manipulation if they aren't waiting for a marked user or if marked users exist */
+ if (!ast_test_flag(&conference_bridge_user->u_profile, USER_OPT_WAITMARKED) || conference_bridge->markedusers) {
+ conference_bridge_user->features.mute = (!conference_bridge_user->features.mute ? 1 : 0);
+ }
+ return ast_stream_and_wait(chan, (conference_bridge_user->features.mute ?
+ conf_get_sound(CONF_SOUND_MUTED, conference_bridge_user->b_profile.sounds) :
+ conf_get_sound(CONF_SOUND_UNMUTED, conference_bridge_user->b_profile.sounds)),
+ "");
+}
+
+static int action_playback(struct ast_bridge_channel *bridge_channel, const char *playback_file)
+{
+ char *file_copy = ast_strdupa(playback_file);
+ char *file = NULL;
+
+ while ((file = strsep(&file_copy, "&"))) {
+ if (ast_stream_and_wait(bridge_channel->chan, file, "")) {
+ ast_log(LOG_WARNING, "Failed to playback file %s to channel\n", file);
+ return -1;
+ }
+ }
+ return 0;
+}
+
+static int action_playback_and_continue(struct conference_bridge *conference_bridge,
+ struct conference_bridge_user *conference_bridge_user,
+ struct ast_bridge_channel *bridge_channel,
+ struct conf_menu *menu,
+ const char *playback_file,
+ const char *cur_dtmf,
+ int *stop_prompts)
+{
+ int i;
+ int digit = 0;
+ char dtmf[MAXIMUM_DTMF_FEATURE_STRING];
+ struct conf_menu_entry new_menu_entry = { { 0, }, };
+ char *file_copy = ast_strdupa(playback_file);
+ char *file = NULL;
+
+ while ((file = strsep(&file_copy, "&"))) {
+ if (ast_streamfile(bridge_channel->chan, file, bridge_channel->chan->language)) {
+ ast_log(LOG_WARNING, "Failed to playback file %s to channel\n", file);
+ return -1;
+ }
+
+ /* now wait for more digits. */
+ if (!(digit = ast_waitstream(bridge_channel->chan, AST_DIGIT_ANY))) {
+ /* streaming finished and no DTMF was entered */
+ continue;
+ } else if (digit == -1) {
+ /* error */
+ return -1;
+ } else {
+ break; /* dtmf was entered */
+ }
+ }
+ if (!digit) {
+ /* streaming finished on all files and no DTMF was entered */
+ return -1;
+ }
+ ast_stopstream(bridge_channel->chan);
+
+ /* If we get here, then DTMF has been entered, This means no
+ * additional prompts should be played for this menu entry */
+ *stop_prompts = 1;
+
+ /* If a digit was pressed during the payback, update
+ * the dtmf string and look for a new menu entry in the
+ * menu structure */
+ ast_copy_string(dtmf, cur_dtmf, sizeof(dtmf));
+ for (i = 0; i < (MAXIMUM_DTMF_FEATURE_STRING - 1); i++) {
+ dtmf[i] = cur_dtmf[i];
+ if (!dtmf[i]) {
+ dtmf[i] = (char) digit;
+ dtmf[i + 1] = '\0';
+ i = -1;
+ break;
+ }
+ }
+ /* If i is not -1 then the new dtmf digit was _NOT_ added to the string.
+ * If this is the case, no new DTMF sequence should be looked for. */
+ if (i != -1) {
+ return 0;
+ }
+
+ if (conf_find_menu_entry_by_sequence(dtmf, menu, &new_menu_entry)) {
+ execute_menu_entry(conference_bridge,
+ conference_bridge_user,
+ bridge_channel,
+ &new_menu_entry, menu);
+ conf_menu_entry_destroy(&new_menu_entry);
+ }
+ return 0;
+}
+
+static int action_kick_last(struct conference_bridge *conference_bridge,
+ struct ast_bridge_channel *bridge_channel,
+ struct conference_bridge_user *conference_bridge_user)
+{
+ struct conference_bridge_user *last_participant = NULL;
+ int isadmin = ast_test_flag(&conference_bridge_user->u_profile, USER_OPT_ADMIN);
+
+ if (!isadmin) {
+ ast_stream_and_wait(bridge_channel->chan,
+ conf_get_sound(CONF_SOUND_ERROR_MENU, conference_bridge_user->b_profile.sounds),
+ "");
+ ast_log(LOG_WARNING, "Only admin users can use the kick_last menu action. Channel %s of conf %s is not an admin.\n",
+ bridge_channel->chan->name,
+ conference_bridge->name);
+ return -1;
+ }
+
+ ao2_lock(conference_bridge);
+ if (((last_participant = AST_LIST_LAST(&conference_bridge->users_list)) == conference_bridge_user)
+ || (ast_test_flag(&last_participant->u_profile, USER_OPT_ADMIN))) {
+ ao2_unlock(conference_bridge);
+ ast_stream_and_wait(bridge_channel->chan,
+ conf_get_sound(CONF_SOUND_ERROR_MENU, conference_bridge_user->b_profile.sounds),
+ "");
+ } else if (last_participant) {
+ last_participant->kicked = 1;
+ ast_bridge_remove(conference_bridge->bridge, last_participant->chan);
+ ao2_unlock(conference_bridge);
+ }
+ return 0;
+}
+
+static int action_dialplan_exec(struct ast_bridge_channel *bridge_channel, struct conf_menu_action *menu_action)
+{
+ struct ast_pbx_args args;
+ struct ast_pbx *pbx;
+ char *exten;
+ char *context;
+ int priority;
+ int res;
+
+ memset(&args, 0, sizeof(args));
+ args.no_hangup_chan = 1;
+
+ ast_channel_lock(bridge_channel->chan);
+
+ /*save off*/
+ exten = ast_strdupa(bridge_channel->chan->exten);
+ context = ast_strdupa(bridge_channel->chan->context);
+ priority = bridge_channel->chan->priority;
+ pbx = bridge_channel->chan->pbx;
+ bridge_channel->chan->pbx = NULL;
+
+ /*set new*/
+ ast_copy_string(bridge_channel->chan->exten, menu_action->data.dialplan_args.exten, sizeof(bridge_channel->chan->exten));
+ ast_copy_string(bridge_channel->chan->context, menu_action->data.dialplan_args.context, sizeof(bridge_channel->chan->context));
+ bridge_channel->chan->priority = menu_action->data.dialplan_args.priority;
+
+ ast_channel_unlock(bridge_channel->chan);
+
+ /*execute*/
+ res = ast_pbx_run_args(bridge_channel->chan, &args);
+
+ /*restore*/
+ ast_channel_lock(bridge_channel->chan);
+
+ ast_copy_string(bridge_channel->chan->exten, exten, sizeof(bridge_channel->chan->exten));
+ ast_copy_string(bridge_channel->chan->context, context, sizeof(bridge_channel->chan->context));
+ bridge_channel->chan->priority = priority;
+ bridge_channel->chan->pbx = pbx;
+
+ ast_channel_unlock(bridge_channel->chan);
+
return res;
}
+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)
+{
+ struct conf_menu_action *menu_action;
+ int isadmin = ast_test_flag(&conference_bridge_user->u_profile, USER_OPT_ADMIN);
+ int stop_prompts = 0;
+ int res = 0;
+
+ AST_LIST_TRAVERSE(&menu_entry->actions, menu_action, action) {
+ switch (menu_action->id) {
+ case MENU_ACTION_TOGGLE_MUTE:
+ res |= action_toggle_mute(conference_bridge,
+ conference_bridge_user,
+ bridge_channel->chan);
+ break;
+ case MENU_ACTION_PLAYBACK:
+ if (!stop_prompts) {
+ res |= action_playback(bridge_channel, menu_action->data.playback_file);
+ }
+ break;
+ case MENU_ACTION_RESET_LISTENING:
+ ast_audiohook_volume_set(conference_bridge_user->chan, AST_AUDIOHOOK_DIRECTION_WRITE, 0);
+ break;
+ case MENU_ACTION_RESET_TALKING:
+ ast_audiohook_volume_set(conference_bridge_user->chan, AST_AUDIOHOOK_DIRECTION_READ, 0);
+ break;
+ case MENU_ACTION_INCREASE_LISTENING:
+ ast_audiohook_volume_adjust(conference_bridge_user->chan,
+ AST_AUDIOHOOK_DIRECTION_WRITE, 1);
+ break;
+ case MENU_ACTION_DECREASE_LISTENING:
+ ast_audiohook_volume_adjust(conference_bridge_user->chan,
+ AST_AUDIOHOOK_DIRECTION_WRITE, -1);
+ break;
+ case MENU_ACTION_INCREASE_TALKING:
+ ast_audiohook_volume_adjust(conference_bridge_user->chan,
+ AST_AUDIOHOOK_DIRECTION_READ, 1);
+ break;
+ case MENU_ACTION_DECREASE_TALKING:
+ ast_audiohook_volume_adjust(conference_bridge_user->chan,
+ AST_AUDIOHOOK_DIRECTION_READ, -1);
+ break;
+ case MENU_ACTION_PLAYBACK_AND_CONTINUE:
+ if (!(stop_prompts)) {
+ res |= action_playback_and_continue(conference_bridge,
+ conference_bridge_user,
+ bridge_channel,
+ menu,
+ menu_action->data.playback_file,
+ menu_entry->dtmf,
+ &stop_prompts);
+ }
+ break;
+ case MENU_ACTION_DIALPLAN_EXEC:
+ res |= action_dialplan_exec(bridge_channel, menu_action);
+ break;
+ case MENU_ACTION_ADMIN_TOGGLE_LOCK:
+ if (!isadmin) {
+ break;
+ }
+ conference_bridge->locked = (!conference_bridge->locked ? 1 : 0);
+ res |= ast_stream_and_wait(bridge_channel->chan,
+ (conference_bridge->locked ?
+ conf_get_sound(CONF_SOUND_LOCKED_NOW, conference_bridge_user->b_profile.sounds) :
+ conf_get_sound(CONF_SOUND_UNLOCKED_NOW, conference_bridge_user->b_profile.sounds)),
+ "");
+
+ break;
+ case MENU_ACTION_ADMIN_KICK_LAST:
+ res |= action_kick_last(conference_bridge, bridge_channel, conference_bridge_user);
+ break;
+ case MENU_ACTION_LEAVE:
+ ao2_lock(conference_bridge);
+ ast_bridge_remove(conference_bridge->bridge, bridge_channel->chan);
+ ao2_unlock(conference_bridge);
+ break;
+ case MENU_ACTION_NOOP:
+ break;
+ }
+ }
+ return res;
+}
+
+int conf_handle_dtmf(struct ast_bridge_channel *bridge_channel,
+ struct conference_bridge_user *conference_bridge_user,
+ struct conf_menu_entry *menu_entry,
+ struct conf_menu *menu)
+{
+ struct conference_bridge *conference_bridge = conference_bridge_user->conference_bridge;
+
+ /* See if music on hold is playing */
+ ao2_lock(conference_bridge);
+ if (conference_bridge->users == 1 && ast_test_flag(&conference_bridge_user->u_profile, USER_OPT_MUSICONHOLD)) {
+ /* Just us so MOH is probably indeed going, let's stop it */
+ ast_moh_stop(bridge_channel->chan);
+ }
+ ao2_unlock(conference_bridge);
+
+ /* execute the list of actions associated with this menu entry */
+ execute_menu_entry(conference_bridge, conference_bridge_user, bridge_channel, menu_entry, menu);
+
+ /* See if music on hold needs to be started back up again */
+ ao2_lock(conference_bridge);
+ if (conference_bridge->users == 1 && ast_test_flag(&conference_bridge_user->u_profile, USER_OPT_MUSICONHOLD)) {
+ ast_moh_start(bridge_channel->chan, conference_bridge_user->u_profile.moh_class, NULL);
+ }
+ ao2_unlock(conference_bridge);
+
+ return 0;
+}
+
static char *complete_confbridge_name(const char *line, const char *word, int pos, int state)
{
int which = 0;
@@ -824,19 +1678,18 @@ static char *complete_confbridge_name(const char *line, const char *word, int po
static char *handle_cli_confbridge_kick(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
-
struct conference_bridge *bridge = NULL;
struct conference_bridge tmp;
struct conference_bridge_user *participant = NULL;
- switch (cmd) {
- case CLI_INIT:
- e->command = "confbridge kick";
- e->usage =
- "Usage: confbridge kick <name> <channel>\n"
- " Kicks a channel out of the conference bridge.\n";
- return NULL;
- case CLI_GENERATE:
+ switch (cmd) {
+ case CLI_INIT:
+ e->command = "confbridge kick";
+ e->usage =
+ "Usage: confbridge kick <conference> <channel>\n"
+ " Kicks a channel out of the conference bridge.\n";
+ return NULL;
+ case CLI_GENERATE:
if (a->pos == 2) {
return complete_confbridge_name(a->line, a->word, a->pos, a->n);
}
@@ -845,8 +1698,8 @@ static char *handle_cli_confbridge_kick(struct ast_cli_entry *e, int cmd, struct
return complete_confbridge_channel(a->line, a->word, a->pos, a->n);
}
*/
- return NULL;
- }
+ return NULL;
+ }
if (a->argc != 4) {
return CLI_SHOWUSAGE;
@@ -881,19 +1734,19 @@ static char *handle_cli_confbridge_list(struct ast_cli_entry *e, int cmd, struct
struct conference_bridge tmp;
struct conference_bridge_user *participant = NULL;
- switch (cmd) {
- case CLI_INIT:
- e->command = "confbridge list";
- e->usage =
- "Usage: confbridge list [<name>]\n"
- " Lists all currently active conference bridges.\n";
- return NULL;
- case CLI_GENERATE:
+ switch (cmd) {
+ case CLI_INIT:
+ e->command = "confbridge list";
+ e->usage =
+ "Usage: confbridge list [<name>]\n"
+ " Lists all currently active conference bridges.\n";
+ return NULL;
+ case CLI_GENERATE:
if (a->pos == 2) {
return complete_confbridge_name(a->line, a->word, a->pos, a->n);
}
- return NULL;
- }
+ return NULL;
+ }
if (a->argc == 2) {
ast_cli(a->fd, "Conference Bridge Name Users Marked Locked?\n");
@@ -914,38 +1767,14 @@ static char *handle_cli_confbridge_list(struct ast_cli_entry *e, int cmd, struct
ast_cli(a->fd, "No conference bridge named '%s' found!\n", a->argv[2]);
return CLI_SUCCESS;
}
- ast_cli(a->fd, "Channel Flags\n");
- ast_cli(a->fd, "================================ ================\n");
+ ast_cli(a->fd, "Channel User Profile Bridge Profile Menu\n");
+ ast_cli(a->fd, "============================= ================ ================ ================\n");
ao2_lock(bridge);
AST_LIST_TRAVERSE(&bridge->users_list, participant, list) {
- ast_cli(a->fd, "%-32s ", participant->chan->name);
- if (ast_test_flag(&participant->flags, OPTION_MARKEDUSER)) {
- ast_cli(a->fd, "A");
- }
- if (ast_test_flag(&participant->flags, OPTION_ADMIN)) {
- ast_cli(a->fd, "a");
- }
- if (ast_test_flag(&participant->flags, OPTION_ANNOUNCEUSERCOUNT)) {
- ast_cli(a->fd, "c");
- }
- if (ast_test_flag(&participant->flags, OPTION_MENU)) {
- ast_cli(a->fd, "m");
- }
- if (ast_test_flag(&participant->flags, OPTION_MUSICONHOLD)) {
- ast_cli(a->fd, "M(%s)", participant->opt_args[OPTION_MUSICONHOLD_CLASS]);
- }
- if (ast_test_flag(&participant->flags, OPTION_NOONLYPERSON)) {
- ast_cli(a->fd, "1");
- }
- if (ast_test_flag(&participant->flags, OPTION_STARTMUTED)) {
- ast_cli(a->fd, "s");
- }
- if (ast_test_flag(&participant->flags, OPTION_WAITMARKED)) {
- ast_cli(a->fd, "w");
- }
- if (ast_test_flag(&participant->flags, OPTION_QUIET)) {
- ast_cli(a->fd, "q");
- }
+ ast_cli(a->fd, "%-29s ", participant->chan->name);
+ ast_cli(a->fd, "%-17s", participant->u_profile.name);
+ ast_cli(a->fd, "%-17s", participant->b_profile.name);
+ ast_cli(a->fd, "%-17s", participant->menu_name);
ast_cli(a->fd, "\n");
}
ao2_unlock(bridge);
@@ -956,44 +1785,670 @@ static char *handle_cli_confbridge_list(struct ast_cli_entry *e, int cmd, struct
return CLI_SHOWUSAGE;
}
+/* \internal
+ * \brief finds a conference by name and locks/unlocks.
+ *
+ * \retval 0 success
+ * \retval -1 conference not found
+ */
+static int generic_lock_unlock_helper(int lock, const char *conference)
+{
+ struct conference_bridge *bridge = NULL;
+ struct conference_bridge tmp;
+ int res = 0;
+
+ ast_copy_string(tmp.name, conference, sizeof(tmp.name));
+ bridge = ao2_find(conference_bridges, &tmp, OBJ_POINTER);
+ if (!bridge) {
+ return -1;
+ }
+ ao2_lock(bridge);
+ bridge->locked = lock;
+ ao2_unlock(bridge);
+ ao2_ref(bridge, -1);
+
+ return res;
+}
+
+/* \internal
+ * \brief finds a conference user by channel name and mutes/unmutes them.
+ *
+ * \retval 0 success
+ * \retval -1 conference not found
+ * \retval -2 user not found
+ */
+static int generic_mute_unmute_helper(int mute, const char *conference, const char *user)
+{
+ struct conference_bridge *bridge = NULL;
+ struct conference_bridge tmp;
+ struct conference_bridge_user *participant = NULL;
+ int res = 0;
+ ast_copy_string(tmp.name, conference, sizeof(tmp.name));
+ bridge = ao2_find(conference_bridges, &tmp, OBJ_POINTER);
+ if (!bridge) {
+ return -1;
+ }
+ ao2_lock(bridge);
+ AST_LIST_TRAVERSE(&bridge->users_list, participant, list) {
+ if (!strncmp(user, participant->chan->name, strlen(user))) {
+ break;
+ }
+ }
+ if (participant) {
+ participant->features.mute = mute;
+ } else {
+ res = -2;;
+ }
+ ao2_unlock(bridge);
+ ao2_ref(bridge, -1);
+
+ return res;
+}
+
+static int cli_mute_unmute_helper(int mute, struct ast_cli_args *a)
+{
+ int res = generic_mute_unmute_helper(mute, a->argv[2], a->argv[3]);
+
+ if (res == -1) {
+ ast_cli(a->fd, "No conference bridge named '%s' found!\n", a->argv[2]);
+ return -1;
+ } else if (res == -2) {
+ ast_cli(a->fd, "No channel named '%s' found in conference %s\n", a->argv[3], a->argv[2]);
+ return -1;
+ }
+ ast_cli(a->fd, "%s %s from confbridge %s\n", mute ? "Muting" : "Unmuting", a->argv[3], a->argv[2]);
+ return 0;
+}
+
+static char *handle_cli_confbridge_mute(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+{
+ switch (cmd) {
+ case CLI_INIT:
+ e->command = "confbridge mute";
+ e->usage =
+ "Usage: confbridge mute <conference> <channel>\n";
+ return NULL;
+ case CLI_GENERATE:
+ if (a->pos == 2) {
+ return complete_confbridge_name(a->line, a->word, a->pos, a->n);
+ }
+ return NULL;
+ }
+ if (a->argc != 4) {
+ return CLI_SHOWUSAGE;
+ }
+
+ cli_mute_unmute_helper(1, a);
+
+ return CLI_SUCCESS;
+}
+
+static char *handle_cli_confbridge_unmute(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+{
+ switch (cmd) {
+ case CLI_INIT:
+ e->command = "confbridge unmute";
+ e->usage =
+ "Usage: confbridge unmute <conference> <channel>\n";
+ return NULL;
+ case CLI_GENERATE:
+ if (a->pos == 2) {
+ return complete_confbridge_name(a->line, a->word, a->pos, a->n);
+ }
+ return NULL;
+ }
+ if (a->argc != 4) {
+ return CLI_SHOWUSAGE;
+ }
+
+ cli_mute_unmute_helper(0, a);
+
+ return CLI_SUCCESS;
+}
+
+static char *handle_cli_confbridge_lock(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+{
+ switch (cmd) {
+ case CLI_INIT:
+ e->command = "confbridge lock";
+ e->usage =
+ "Usage: confbridge lock <conference>\n";
+ return NULL;
+ case CLI_GENERATE:
+ if (a->pos == 2) {
+ return complete_confbridge_name(a->line, a->word, a->pos, a->n);
+ }
+ return NULL;
+ }
+ if (a->argc != 3) {
+ return CLI_SHOWUSAGE;
+ }
+ if (generic_lock_unlock_helper(1, a->argv[2])) {
+ ast_cli(a->fd, "Conference %s is not found\n", a->argv[2]);
+ } else {
+ ast_cli(a->fd, "Conference %s is locked.\n", a->argv[2]);
+ }
+ return CLI_SUCCESS;
+}
+
+static char *handle_cli_confbridge_unlock(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+{
+ switch (cmd) {
+ case CLI_INIT:
+ e->command = "confbridge unlock";
+ e->usage =
+ "Usage: confbridge unlock <conference>\n";
+ return NULL;
+ case CLI_GENERATE:
+ if (a->pos == 2) {
+ return complete_confbridge_name(a->line, a->word, a->pos, a->n);
+ }
+ return NULL;
+ }
+ if (a->argc != 3) {
+ return CLI_SHOWUSAGE;
+ }
+ if (generic_lock_unlock_helper(0, a->argv[2])) {
+ ast_cli(a->fd, "Conference %s is not found\n", a->argv[2]);
+ } else {
+ ast_cli(a->fd, "Conference %s is unlocked.\n", a->argv[2]);
+ }
+ return CLI_SUCCESS;
+}
+
+static char *handle_cli_confbridge_start_record(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+{
+ const char *rec_file = NULL;
+ struct conference_bridge *bridge = NULL;
+ struct conference_bridge tmp;
+
+ switch (cmd) {
+ case CLI_INIT:
+ e->command = "confbridge record start";
+ e->usage =
+ "Usage: confbridge record start <conference> <file>\n"
+ " <file> is optional, Otherwise the bridge profile\n"
+ " record file will be used. If the bridge profile\n"
+ " has no record file specified, a file will automatically\n"
+ " be generated in the monitor directory\n";
+ return NULL;
+ case CLI_GENERATE:
+ if (a->pos == 3) {
+ return complete_confbridge_name(a->line, a->word, a->pos, a->n);
+ }
+ return NULL;
+ }
+ if (a->argc < 4) {
+ return CLI_SHOWUSAGE;
+ }
+ if (a->argc == 5) {
+ rec_file = a->argv[4];
+ }
+
+ ast_copy_string(tmp.name, a->argv[3], sizeof(tmp.name));
+ bridge = ao2_find(conference_bridges, &tmp, OBJ_POINTER);
+ if (!bridge) {
+ ast_cli(a->fd, "Conference not found.\n");
+ return CLI_FAILURE;
+ }
+ if (conf_is_recording(bridge)) {
+ ast_cli(a->fd, "Conference is already being recorded.\n");
+ ao2_ref(bridge, -1);
+ return CLI_SUCCESS;
+ }
+ if (!ast_strlen_zero(rec_file)) {
+ ao2_lock(bridge);
+ ast_copy_string(bridge->b_profile.rec_file, rec_file, sizeof(bridge->b_profile.rec_file));
+ ao2_unlock(bridge);
+ }
+ if (conf_start_record(bridge)) {
+ ast_cli(a->fd, "Could not start recording due to internal error.\n");
+ ao2_ref(bridge, -1);
+ return CLI_FAILURE;
+ }
+ ast_cli(a->fd, "Recording started\n");
+ ao2_ref(bridge, -1);
+ return CLI_SUCCESS;
+}
+
+static char *handle_cli_confbridge_stop_record(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+{
+ struct conference_bridge *bridge = NULL;
+ struct conference_bridge tmp;
+
+ switch (cmd) {
+ case CLI_INIT:
+ e->command = "confbridge record stop";
+ e->usage =
+ "Usage: confbridge record stop <conference>\n";
+ return NULL;
+ case CLI_GENERATE:
+ if (a->pos == 3) {
+ return complete_confbridge_name(a->line, a->word, a->pos, a->n);
+ }
+ return NULL;
+ }
+ if (a->argc != 4) {
+ return CLI_SHOWUSAGE;
+ }
+
+ ast_copy_string(tmp.name, a->argv[3], sizeof(tmp.name));
+ bridge = ao2_find(conference_bridges, &tmp, OBJ_POINTER);
+ if (!bridge) {
+ ast_cli(a->fd, "Conference not found.\n");
+ return CLI_SUCCESS;
+ }
+ conf_stop_record(bridge);
+ ast_cli(a->fd, "Recording stopped.\n");
+ ao2_ref(bridge, -1);
+ return CLI_SUCCESS;
+}
+
static struct ast_cli_entry cli_confbridge[] = {
AST_CLI_DEFINE(handle_cli_confbridge_list, "List conference bridges and participants."),
- AST_CLI_DEFINE(handle_cli_confbridge_kick, "Kick participants out of conference bridges.")
+ AST_CLI_DEFINE(handle_cli_confbridge_kick, "Kick participants out of conference bridges."),
+ AST_CLI_DEFINE(handle_cli_confbridge_mute, "Mute a participant."),
+ AST_CLI_DEFINE(handle_cli_confbridge_unmute, "Mute a participant."),
+ AST_CLI_DEFINE(handle_cli_confbridge_lock, "Lock a conference."),
+ AST_CLI_DEFINE(handle_cli_confbridge_unlock, "Unlock a conference."),
+ AST_CLI_DEFINE(handle_cli_confbridge_start_record, "Start recording a conference"),
+ AST_CLI_DEFINE(handle_cli_confbridge_stop_record, "Stop recording a conference."),
};
+static struct ast_custom_function confbridge_function = {
+ .name = "CONFBRIDGE",
+ .write = func_confbridge_helper,
+};
+
+static int action_confbridgelist(struct mansession *s, const struct message *m)
+{
+ const char *actionid = astman_get_header(m, "ActionID");
+ const char *conference = astman_get_header(m, "Conference");
+ struct conference_bridge_user *participant = NULL;
+ struct conference_bridge *bridge = NULL;
+ struct conference_bridge tmp;
+ char id_text[80] = "";
+ int total = 0;
+
+ if (!ast_strlen_zero(actionid)) {
+ snprintf(id_text, sizeof(id_text), "ActionID: %s\r\n", actionid);
+ }
+ if (ast_strlen_zero(conference)) {
+ astman_send_error(s, m, "No Conference name provided.");
+ return 0;
+ }
+ if (!ao2_container_count(conference_bridges)) {
+ astman_send_error(s, m, "No active conferences.");
+ return 0;
+ }
+ ast_copy_string(tmp.name, conference, sizeof(tmp.name));
+ bridge = ao2_find(conference_bridges, &tmp, OBJ_POINTER);
+ if (!bridge) {
+ astman_send_error(s, m, "No Conference by that name found.");
+ return 0;
+ }
+
+ astman_send_listack(s, m, "Confbridge user list will follow", "start");
+
+ ao2_lock(bridge);
+ AST_LIST_TRAVERSE(&bridge->users_list, participant, list) {
+ total++;
+ astman_append(s,
+ "Event: ConfbridgeList\r\n"
+ "%s"
+ "Conference: %s\r\n"
+ "CallerIDNum: %s\r\n"
+ "CallerIDName: %s\r\n"
+ "Channel: %s\r\n"
+ "Admin: %s\r\n"
+ "MarkedUser: %s\r\n"
+ "\r\n",
+ id_text,
+ bridge->name,
+ S_COR(participant->chan->caller.id.number.valid, participant->chan->caller.id.number.str, "<unknown>"),
+ S_COR(participant->chan->caller.id.name.valid, participant->chan->caller.id.name.str, "<no name>"),
+ participant->chan->name,
+ ast_test_flag(&participant->u_profile, USER_OPT_ADMIN) ? "Yes" : "No",
+ ast_test_flag(&participant->u_profile, USER_OPT_MARKEDUSER) ? "Yes" : "No");
+ }
+ ao2_unlock(bridge);
+ ao2_ref(bridge, -1);
+
+ astman_append(s,
+ "Event: ConfbridgeListComplete\r\n"
+ "EventList: Complete\r\n"
+ "ListItems: %d\r\n"
+ "%s"
+ "\r\n", total, id_text);
+
+ return 0;
+}
+
+static int action_confbridgelistrooms(struct mansession *s, const struct message *m)
+{
+ const char *actionid = astman_get_header(m, "ActionID");
+ struct conference_bridge *bridge = NULL;
+ struct ao2_iterator i;
+ char id_text[512] = "";
+ int totalitems = 0;
+
+ if (!ast_strlen_zero(actionid)) {
+ snprintf(id_text, sizeof(id_text), "ActionID: %s\r\n", actionid);
+ }
+
+ if (!ao2_container_count(conference_bridges)) {
+ astman_send_error(s, m, "No active conferences.");
+ return 0;
+ }
+
+ astman_send_listack(s, m, "Confbridge conferences will follow", "start");
+
+ /* Traverse the conference list */
+ i = ao2_iterator_init(conference_bridges, 0);
+ while ((bridge = ao2_iterator_next(&i))) {
+ totalitems++;
+
+ ao2_lock(bridge);
+ astman_append(s,
+ "Event: ConfbridgeListRooms\r\n"
+ "%s"
+ "Conference: %s\r\n"
+ "Parties: %d\r\n"
+ "Marked: %d\r\n"
+ "Locked: %s\r\n"
+ "\r\n",
+ id_text,
+ bridge->name,
+ bridge->users,
+ bridge->markedusers,
+ bridge->locked ? "Yes" : "No");
+ ao2_unlock(bridge);
+
+ ao2_ref(bridge, -1);
+ }
+ ao2_iterator_destroy(&i);
+
+ /* Send final confirmation */
+ astman_append(s,
+ "Event: ConfbridgeListRoomsComplete\r\n"
+ "EventList: Complete\r\n"
+ "ListItems: %d\r\n"
+ "%s"
+ "\r\n", totalitems, id_text);
+ return 0;
+}
+
+static int action_mute_unmute_helper(struct mansession *s, const struct message *m, int mute)
+{
+ const char *conference = astman_get_header(m, "Conference");
+ const char *channel = astman_get_header(m, "Channel");
+ int res = 0;
+
+ if (ast_strlen_zero(conference)) {
+ astman_send_error(s, m, "No Conference name provided.");
+ return 0;
+ }
+ if (ast_strlen_zero(channel)) {
+ astman_send_error(s, m, "No channel name provided.");
+ return 0;
+ }
+ if (!ao2_container_count(conference_bridges)) {
+ astman_send_error(s, m, "No active conferences.");
+ return 0;
+ }
+
+ res = generic_mute_unmute_helper(mute, conference, channel);
+
+ if (res == -1) {
+ astman_send_error(s, m, "No Conference by that name found.");
+ return 0;
+ } else if (res == -2) {
+ astman_send_error(s, m, "No Channel by that name found in Conference.");
+ return 0;
+ }
+
+ astman_send_ack(s, m, mute ? "User muted" : "User unmuted");
+ return 0;
+}
+
+static int action_confbridgeunmute(struct mansession *s, const struct message *m)
+{
+ return action_mute_unmute_helper(s, m, 0);
+}
+static int action_confbridgemute(struct mansession *s, const struct message *m)
+{
+ return action_mute_unmute_helper(s, m, 1);
+}
+
+static int action_lock_unlock_helper(struct mansession *s, const struct message *m, int lock)
+{
+ const char *conference = astman_get_header(m, "Conference");
+ int res = 0;
+
+ if (ast_strlen_zero(conference)) {
+ astman_send_error(s, m, "No Conference name provided.");
+ return 0;
+ }
+ if (!ao2_container_count(conference_bridges)) {
+ astman_send_error(s, m, "No active conferences.");
+ return 0;
+ }
+ if ((res = generic_lock_unlock_helper(lock, conference))) {
+ astman_send_error(s, m, "No Conference by that name found.");
+ return 0;
+ }
+ astman_send_ack(s, m, lock ? "Conference locked" : "Conference unlocked");
+ return 0;
+}
+static int action_confbridgeunlock(struct mansession *s, const struct message *m)
+{
+ return action_lock_unlock_helper(s, m, 0);
+}
+static int action_confbridgelock(struct mansession *s, const struct message *m)
+{
+ return action_lock_unlock_helper(s, m, 1);
+}
+
+static int action_confbridgekick(struct mansession *s, const struct message *m)
+{
+ const char *conference = astman_get_header(m, "Conference");
+ const char *channel = astman_get_header(m, "Channel");
+ struct conference_bridge_user *participant = NULL;
+ struct conference_bridge *bridge = NULL;
+ struct conference_bridge tmp;
+ int found = 0;
+
+ if (ast_strlen_zero(conference)) {
+ astman_send_error(s, m, "No Conference name provided.");
+ return 0;
+ }
+ if (!ao2_container_count(conference_bridges)) {
+ astman_send_error(s, m, "No active conferences.");
+ return 0;
+ }
+ ast_copy_string(tmp.name, conference, sizeof(tmp.name));
+ bridge = ao2_find(conference_bridges, &tmp, OBJ_POINTER);
+ if (!bridge) {
+ astman_send_error(s, m, "No Conference by that name found.");
+ return 0;
+ }
+
+ ao2_lock(bridge);
+ AST_LIST_TRAVERSE(&bridge->users_list, participant, list) {
+ if (!strcasecmp(participant->chan->name, channel)) {
+ participant->kicked = 1;
+ ast_bridge_remove(bridge->bridge, participant->chan);
+ found = 1;
+ break;
+ }
+ }
+ ao2_unlock(bridge);
+ ao2_ref(bridge, -1);
+
+ if (found) {
+ astman_send_ack(s, m, "User kicked");
+ } else {
+ astman_send_error(s, m, "No Channel by that name found in Conference.");
+ }
+ return 0;
+}
+
+static int action_confbridgestartrecord(struct mansession *s, const struct message *m)
+{
+ const char *conference = astman_get_header(m, "Conference");
+ const char *recordfile = astman_get_header(m, "RecordFile");
+ struct conference_bridge *bridge = NULL;
+ struct conference_bridge tmp;
+
+ if (ast_strlen_zero(conference)) {
+ astman_send_error(s, m, "No Conference name provided.");
+ return 0;
+ }
+ if (!ao2_container_count(conference_bridges)) {
+ astman_send_error(s, m, "No active conferences.");
+ return 0;
+ }
+
+ ast_copy_string(tmp.name, conference, sizeof(tmp.name));
+ bridge = ao2_find(conference_bridges, &tmp, OBJ_POINTER);
+ if (!bridge) {
+ astman_send_error(s, m, "No Conference by that name found.");
+ return 0;
+ }
+
+ if (conf_is_recording(bridge)) {
+ astman_send_error(s, m, "Conference is already being recorded.");
+ ao2_ref(bridge, -1);
+ return 0;
+ }
+
+ if (!ast_strlen_zero(recordfile)) {
+ ao2_lock(bridge);
+ ast_copy_string(bridge->b_profile.rec_file, recordfile, sizeof(bridge->b_profile.rec_file));
+ ao2_unlock(bridge);
+ }
+
+ if (conf_start_record(bridge)) {
+ astman_send_error(s, m, "Internal error starting conference recording.");
+ ao2_ref(bridge, -1);
+ return 0;
+ }
+
+ ao2_ref(bridge, -1);
+ astman_send_ack(s, m, "Conference Recording Started.");
+ return 0;
+}
+static int action_confbridgestoprecord(struct mansession *s, const struct message *m)
+{
+ const char *conference = astman_get_header(m, "Conference");
+ struct conference_bridge *bridge = NULL;
+ struct conference_bridge tmp;
+
+ if (ast_strlen_zero(conference)) {
+ astman_send_error(s, m, "No Conference name provided.");
+ return 0;
+ }
+ if (!ao2_container_count(conference_bridges)) {
+ astman_send_error(s, m, "No active conferences.");
+ return 0;
+ }
+
+ ast_copy_string(tmp.name, conference, sizeof(tmp.name));
+ bridge = ao2_find(conference_bridges, &tmp, OBJ_POINTER);
+ if (!bridge) {
+ astman_send_error(s, m, "No Conference by that name found.");
+ return 0;
+ }
+
+ if (conf_stop_record(bridge)) {
+ astman_send_error(s, m, "Internal error while stopping recording.");
+ ao2_ref(bridge, -1);
+ return 0;
+ }
+
+ ao2_ref(bridge, -1);
+ astman_send_ack(s, m, "Conference Recording Stopped.");
+ return 0;
+}
+
+
/*! \brief Called when module is being unloaded */
static int unload_module(void)
{
int res = ast_unregister_application(app);
+ ast_custom_function_unregister(&confbridge_function);
+
ast_cli_unregister_multiple(cli_confbridge, sizeof(cli_confbridge) / sizeof(struct ast_cli_entry));
/* Get rid of the conference bridges container. Since we only allow dynamic ones none will be active. */
ao2_ref(conference_bridges, -1);
+ conf_destroy_config();
+
+ ast_channel_unregister(&record_tech);
+ record_tech.capabilities = ast_format_cap_destroy(record_tech.capabilities);
+
+ res |= ast_manager_unregister("ConfbridgeList");
+ res |= ast_manager_unregister("ConfbridgeListRooms");
+ res |= ast_manager_unregister("ConfbridgeMute");
+ res |= ast_manager_unregister("ConfbridgeUnmute");
+ res |= ast_manager_unregister("ConfbridgeKick");
+ res |= ast_manager_unregister("ConfbridgeUnlock");
+ res |= ast_manager_unregister("ConfbridgeLock");
+ res |= ast_manager_unregister("ConfbridgeStartRecord");
+ res |= ast_manager_unregister("ConfbridgeStopRecord");
+
return res;
}
/*! \brief Called when module is being loaded */
static int load_module(void)
{
+ int res = 0;
+ if ((ast_custom_function_register(&confbridge_function))) {
+ return AST_MODULE_LOAD_FAILURE;
+ }
+ if (!(record_tech.capabilities = ast_format_cap_alloc())) {
+ return AST_MODULE_LOAD_FAILURE;
+ }
+ ast_format_cap_add_all(record_tech.capabilities);
+ if (ast_channel_register(&record_tech)) {
+ ast_log(LOG_ERROR, "Unable to register ConfBridge recorder.\n");
+ return AST_MODULE_LOAD_FAILURE;
+ }
/* Create a container to hold the conference bridges */
if (!(conference_bridges = ao2_container_alloc(CONFERENCE_BRIDGE_BUCKETS, conference_bridge_hash_cb, conference_bridge_cmp_cb))) {
- return AST_MODULE_LOAD_DECLINE;
+ return AST_MODULE_LOAD_FAILURE;
}
-
if (ast_register_application_xml(app, confbridge_exec)) {
ao2_ref(conference_bridges, -1);
- return AST_MODULE_LOAD_DECLINE;
+ return AST_MODULE_LOAD_FAILURE;
}
- ast_cli_register_multiple(cli_confbridge, sizeof(cli_confbridge) / sizeof(struct ast_cli_entry));
+ res |= ast_cli_register_multiple(cli_confbridge, sizeof(cli_confbridge) / sizeof(struct ast_cli_entry));
+ res |= ast_manager_register_xml("ConfbridgeList", EVENT_FLAG_REPORTING, action_confbridgelist);
+ res |= ast_manager_register_xml("ConfbridgeListRooms", EVENT_FLAG_REPORTING, action_confbridgelistrooms);
+ res |= ast_manager_register_xml("ConfbridgeMute", EVENT_FLAG_CALL, action_confbridgemute);
+ res |= ast_manager_register_xml("ConfbridgeUnmute", EVENT_FLAG_CALL, action_confbridgeunmute);
+ res |= ast_manager_register_xml("ConfbridgeKick", EVENT_FLAG_CALL, action_confbridgekick);
+ res |= ast_manager_register_xml("ConfbridgeUnlock", EVENT_FLAG_CALL, action_confbridgeunlock);
+ res |= ast_manager_register_xml("ConfbridgeLock", EVENT_FLAG_CALL, action_confbridgelock);
+ res |= ast_manager_register_xml("ConfbridgeStartRecord", EVENT_FLAG_CALL, action_confbridgestartrecord);
+ res |= ast_manager_register_xml("ConfbridgeStopRecord", EVENT_FLAG_CALL, action_confbridgestoprecord);
+
+ conf_load_config(0);
+ return res;
+}
- return AST_MODULE_LOAD_SUCCESS;
+static int reload(void)
+{
+ return conf_load_config(1);
}
AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "Conference Bridge Application",
.load = load_module,
.unload = unload_module,
+ .reload = reload,
.load_pri = AST_MODPRI_DEVSTATE_PROVIDER,
);
diff --git a/apps/app_dial.c b/apps/app_dial.c
index 314b8e4e0..25172c743 100644
--- a/apps/app_dial.c
+++ b/apps/app_dial.c
@@ -768,12 +768,16 @@ static void senddialevent(struct ast_channel *src, struct ast_channel *dst, cons
"Destination: %s\r\n"
"CallerIDNum: %s\r\n"
"CallerIDName: %s\r\n"
+ "ConnectedLineNum: %s\r\n"
+ "ConnectedLineName: %s\r\n"
"UniqueID: %s\r\n"
"DestUniqueID: %s\r\n"
"Dialstring: %s\r\n",
src->name, dst->name,
S_COR(src->caller.id.number.valid, src->caller.id.number.str, "<unknown>"),
S_COR(src->caller.id.name.valid, src->caller.id.name.str, "<unknown>"),
+ S_COR(src->connected.id.number.valid, src->connected.id.number.str, "<unknown>"),
+ S_COR(src->connected.id.name.valid, src->connected.id.name.str, "<unknown>"),
src->uniqueid, dst->uniqueid,
dialstring ? dialstring : "");
}
@@ -1244,14 +1248,17 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in,
/* Setup early media if appropriate */
if (single && CAN_EARLY_BRIDGE(peerflags, in, c))
ast_channel_early_bridge(in, c);
- if (!ast_test_flag64(outgoing, OPT_RINGBACK))
+ if (!ast_test_flag64(outgoing, OPT_RINGBACK)) {
if (single || (!single && !pa->sentringing)) {
ast_indicate(in, AST_CONTROL_PROGRESS);
}
- if(!ast_strlen_zero(dtmf_progress)) {
- ast_verb(3, "Sending DTMF '%s' to the called party as result of receiving a PROGRESS message.\n", dtmf_progress);
- ast_dtmf_stream(c, in, dtmf_progress, 250, 0);
- }
+ }
+ if (!ast_strlen_zero(dtmf_progress)) {
+ ast_verb(3,
+ "Sending DTMF '%s' to the called party as result of receiving a PROGRESS message.\n",
+ dtmf_progress);
+ ast_dtmf_stream(c, in, dtmf_progress, 250, 0);
+ }
break;
case AST_CONTROL_VIDUPDATE:
ast_verb(3, "%s requested a video update, passing it to %s\n", c->name, in->name);
@@ -1418,12 +1425,17 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in,
}
}
- if (single) {
+ /* Send the frame from the in channel to all outgoing channels. */
+ for (o = outgoing; o; o = o->next) {
+ if (!o->chan || !ast_test_flag64(o, DIAL_STILLGOING)) {
+ /* This outgoing channel has died so don't send the frame to it. */
+ continue;
+ }
switch (f->frametype) {
case AST_FRAME_HTML:
/* Forward HTML stuff */
- if (!ast_test_flag64(outgoing, DIAL_NOFORWARDHTML)
- && ast_channel_sendhtml(outgoing->chan, f->subclass.integer, f->data.ptr, f->datalen) == -1) {
+ if (!ast_test_flag64(o, DIAL_NOFORWARDHTML)
+ && ast_channel_sendhtml(o->chan, f->subclass.integer, f->data.ptr, f->datalen) == -1) {
ast_log(LOG_WARNING, "Unable to send URL\n");
}
break;
@@ -1432,7 +1444,7 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in,
case AST_FRAME_TEXT:
case AST_FRAME_DTMF_BEGIN:
case AST_FRAME_DTMF_END:
- if (ast_write(outgoing->chan, f)) {
+ if (ast_write(o->chan, f)) {
ast_log(LOG_WARNING, "Unable to forward frametype: %d\n",
f->frametype);
}
@@ -1443,17 +1455,18 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in,
case AST_CONTROL_UNHOLD:
case AST_CONTROL_VIDUPDATE:
case AST_CONTROL_SRCUPDATE:
- ast_verb(3, "%s requested special control %d, passing it to %s\n", in->name, f->subclass.integer, outgoing->chan->name);
- ast_indicate_data(outgoing->chan, f->subclass.integer, f->data.ptr, f->datalen);
+ ast_verb(3, "%s requested special control %d, passing it to %s\n",
+ in->name, f->subclass.integer, o->chan->name);
+ ast_indicate_data(o->chan, f->subclass.integer, f->data.ptr, f->datalen);
break;
case AST_CONTROL_CONNECTED_LINE:
- if (ast_channel_connected_line_macro(in, outgoing->chan, f, 0, 1)) {
- ast_indicate_data(outgoing->chan, f->subclass.integer, f->data.ptr, f->datalen);
+ if (ast_channel_connected_line_macro(in, o->chan, f, 0, 1)) {
+ ast_indicate_data(o->chan, f->subclass.integer, f->data.ptr, f->datalen);
}
break;
case AST_CONTROL_REDIRECTING:
- if (ast_channel_redirecting_macro(in, outgoing->chan, f, 0, 1)) {
- ast_indicate_data(outgoing->chan, f->subclass.integer, f->data.ptr, f->datalen);
+ if (ast_channel_redirecting_macro(in, o->chan, f, 0, 1)) {
+ ast_indicate_data(o->chan, f->subclass.integer, f->data.ptr, f->datalen);
}
break;
default:
@@ -1939,7 +1952,7 @@ static int dial_exec_full(struct ast_channel *chan, const char *data, struct ast
pbx_builtin_setvar_helper(chan, "DIALSTATUS", pa.status);
goto done;
}
- ast_verb(3, "Setting call duration limit to %.3lf milliseconds.\n", calldurationlimit.tv_sec + calldurationlimit.tv_usec / 1000000.0);
+ ast_verb(3, "Setting call duration limit to %.3lf seconds.\n", calldurationlimit.tv_sec + calldurationlimit.tv_usec / 1000000.0);
}
if (ast_test_flag64(&opts, OPT_SENDDTMF) && !ast_strlen_zero(opt_args[OPT_ARG_SENDDTMF])) {
@@ -2234,6 +2247,7 @@ static int dial_exec_full(struct ast_channel *chan, const char *data, struct ast
* No hint name available. We have a connected name supplied by
* the dialplan we can use instead.
*/
+ caller.id.name.valid = 1;
caller.id.name = chan->connected.id.name;
}
ast_channel_set_caller_event(tc, &caller, NULL);
@@ -2247,6 +2261,7 @@ static int dial_exec_full(struct ast_channel *chan, const char *data, struct ast
* We have a connected name supplied by the dialplan we can
* use instead.
*/
+ caller.id.name.valid = 1;
caller.id.name = chan->connected.id.name;
ast_channel_set_caller_event(tc, &caller, NULL);
}
@@ -2390,8 +2405,11 @@ static int dial_exec_full(struct ast_channel *chan, const char *data, struct ast
* to which the datastore was moved hangs up, it will attempt to free this
* datastore again, causing a crash
*/
- if (!ast_channel_datastore_remove(chan, datastore))
+ ast_channel_lock(chan);
+ if (!ast_channel_datastore_remove(chan, datastore)) {
ast_datastore_free(datastore);
+ }
+ ast_channel_unlock(chan);
if (!peer) {
if (result) {
res = result;
diff --git a/apps/app_directed_pickup.c b/apps/app_directed_pickup.c
index 3914e0d8e..38f24effc 100644
--- a/apps/app_directed_pickup.c
+++ b/apps/app_directed_pickup.c
@@ -97,60 +97,17 @@ static const char app[] = "Pickup";
static const char app2[] = "PickupChan";
/*! \todo This application should return a result code, like PICKUPRESULT */
-/* Perform actual pickup between two channels */
-static int pickup_do(struct ast_channel *chan, struct ast_channel *target)
-{
- int res = 0;
- struct ast_party_connected_line connected_caller;
- struct ast_channel *chans[2] = { chan, target };
-
- ast_debug(1, "Call pickup on '%s' by '%s'\n", target->name, chan->name);
- ast_cel_report_event(target, AST_CEL_PICKUP, NULL, NULL, chan);
-
- ast_party_connected_line_init(&connected_caller);
- ast_party_connected_line_copy(&connected_caller, &target->connected);
- connected_caller.source = AST_CONNECTED_LINE_UPDATE_SOURCE_ANSWER;
- if (ast_channel_connected_line_macro(NULL, chan, &connected_caller, 0, 0)) {
- ast_channel_update_connected_line(chan, &connected_caller, NULL);
- }
- ast_party_connected_line_free(&connected_caller);
-
- ast_channel_lock(chan);
- ast_connected_line_copy_from_caller(&connected_caller, &chan->caller);
- ast_channel_unlock(chan);
- connected_caller.source = AST_CONNECTED_LINE_UPDATE_SOURCE_ANSWER;
- ast_channel_queue_connected_line_update(chan, &connected_caller, NULL);
- ast_party_connected_line_free(&connected_caller);
-
- if ((res = ast_answer(chan))) {
- ast_log(LOG_WARNING, "Unable to answer '%s'\n", chan->name);
- return -1;
- }
-
- if ((res = ast_queue_control(chan, AST_CONTROL_ANSWER))) {
- ast_log(LOG_WARNING, "Unable to queue answer on '%s'\n", chan->name);
- return -1;
- }
-
- if ((res = ast_channel_masquerade(target, chan))) {
- ast_log(LOG_WARNING, "Unable to masquerade '%s' into '%s'\n", chan->name, target->name);
- return -1;
- }
-
- /* If you want UniqueIDs, set channelvars in manager.conf to CHANNEL(uniqueid) */
- ast_manager_event_multichan(EVENT_FLAG_CALL, "Pickup", 2, chans,
- "Channel: %s\r\nTargetChannel: %s\r\n", chan->name, target->name);
-
- return res;
-}
-
/* Helper function that determines whether a channel is capable of being picked up */
static int can_pickup(struct ast_channel *chan)
{
- if (!chan->pbx && (chan->_state == AST_STATE_RINGING || chan->_state == AST_STATE_RING || chan->_state == AST_STATE_DOWN))
+ if (!chan->pbx && !chan->masq &&
+ !ast_test_flag(chan, AST_FLAG_ZOMBIE) &&
+ (chan->_state == AST_STATE_RINGING ||
+ chan->_state == AST_STATE_RING ||
+ chan->_state == AST_STATE_DOWN)) {
return 1;
- else
- return 0;
+ }
+ return 0;
}
struct pickup_by_name_args {
@@ -160,15 +117,15 @@ struct pickup_by_name_args {
static int pickup_by_name_cb(void *obj, void *arg, void *data, int flags)
{
- struct ast_channel *chan = obj;
+ struct ast_channel *target = obj;/*!< Potential pickup target */
struct pickup_by_name_args *args = data;
- ast_channel_lock(chan);
- if (!strncasecmp(chan->name, args->name, args->len) && can_pickup(chan)) {
+ ast_channel_lock(target);
+ if (!strncasecmp(target->name, args->name, args->len) && can_pickup(target)) {
/* Return with the channel still locked on purpose */
return CMP_MATCH | CMP_STOP;
}
- ast_channel_unlock(chan);
+ ast_channel_unlock(target);
return 0;
}
@@ -201,31 +158,29 @@ static struct ast_channel *my_ast_get_channel_by_name_locked(const char *channam
return ast_channel_callback(pickup_by_name_cb, NULL, &pickup_args, 0);
}
-/*! \brief Attempt to pick up specified channel named , does not use context */
+/*! \brief Attempt to pick up named channel, does not use context */
static int pickup_by_channel(struct ast_channel *chan, char *pickup)
{
- int res = 0;
- struct ast_channel *target;
-
- if (!(target = my_ast_get_channel_by_name_locked(pickup))) {
- return -1;
- }
+ int res = -1;
+ struct ast_channel *target;/*!< Potential pickup target */
- /* Just check that we are not picking up the SAME as target */
- if (chan != target) {
- res = pickup_do(chan, target);
+ target = my_ast_get_channel_by_name_locked(pickup);
+ if (target) {
+ /* Just check that we are not picking up the SAME as target. (i.e. ourself) */
+ if (chan != target) {
+ res = ast_do_pickup(chan, target);
+ }
+ ast_channel_unlock(target);
+ target = ast_channel_unref(target);
}
- ast_channel_unlock(target);
- target = ast_channel_unref(target);
-
return res;
}
/* Attempt to pick up specified extension with context */
static int pickup_by_exten(struct ast_channel *chan, const char *exten, const char *context)
{
- struct ast_channel *target = NULL;
+ struct ast_channel *target = NULL;/*!< Potential pickup target */
struct ast_channel_iterator *iter;
int res = -1;
@@ -236,6 +191,7 @@ static int pickup_by_exten(struct ast_channel *chan, const char *exten, const ch
while ((target = ast_channel_iterator_next(iter))) {
ast_channel_lock(target);
if ((chan != target) && can_pickup(target)) {
+ ast_log(LOG_NOTICE, "%s pickup by %s\n", target->name, chan->name);
break;
}
ast_channel_unlock(target);
@@ -245,7 +201,7 @@ static int pickup_by_exten(struct ast_channel *chan, const char *exten, const ch
ast_channel_iterator_destroy(iter);
if (target) {
- res = pickup_do(chan, target);
+ res = ast_do_pickup(chan, target);
ast_channel_unlock(target);
target = ast_channel_unref(target);
}
@@ -255,31 +211,63 @@ static int pickup_by_exten(struct ast_channel *chan, const char *exten, const ch
static int find_by_mark(void *obj, void *arg, void *data, int flags)
{
- struct ast_channel *c = obj;
+ struct ast_channel *target = obj;/*!< Potential pickup target */
const char *mark = data;
const char *tmp;
- int res;
-
- ast_channel_lock(c);
- res = (tmp = pbx_builtin_getvar_helper(c, PICKUPMARK)) &&
- !strcasecmp(tmp, mark) &&
- can_pickup(c);
-
- ast_channel_unlock(c);
+ ast_channel_lock(target);
+ tmp = pbx_builtin_getvar_helper(target, PICKUPMARK);
+ if (tmp && !strcasecmp(tmp, mark) && can_pickup(target)) {
+ /* Return with the channel still locked on purpose */
+ return CMP_MATCH | CMP_STOP;
+ }
+ ast_channel_unlock(target);
- return res ? CMP_MATCH | CMP_STOP : 0;
+ return 0;
}
/* Attempt to pick up specified mark */
static int pickup_by_mark(struct ast_channel *chan, const char *mark)
{
- struct ast_channel *target;
+ struct ast_channel *target;/*!< Potential pickup target */
int res = -1;
- if ((target = ast_channel_callback(find_by_mark, NULL, (char *) mark, 0))) {
- ast_channel_lock(target);
- res = pickup_do(chan, target);
+ /* The found channel is already locked. */
+ target = ast_channel_callback(find_by_mark, NULL, (char *) mark, 0);
+ if (target) {
+ res = ast_do_pickup(chan, target);
+ ast_channel_unlock(target);
+ target = ast_channel_unref(target);
+ }
+
+ return res;
+}
+
+static int find_channel_by_group(void *obj, void *arg, void *data, int flags)
+{
+ struct ast_channel *target = obj;/*!< Potential pickup target */
+ struct ast_channel *chan = data;/*!< Channel wanting to pickup call */
+
+ ast_channel_lock(target);
+ if (chan != target && (chan->pickupgroup & target->callgroup) && can_pickup(target)) {
+ /* Return with the channel still locked on purpose */
+ return CMP_MATCH | CMP_STOP;
+ }
+ ast_channel_unlock(target);
+
+ return 0;
+}
+
+static int pickup_by_group(struct ast_channel *chan)
+{
+ struct ast_channel *target;/*!< Potential pickup target */
+ int res = -1;
+
+ /* The found channel is already locked. */
+ target = ast_channel_callback(find_channel_by_group, NULL, chan, 0);
+ if (target) {
+ ast_log(LOG_NOTICE, "pickup %s attempt by %s\n", target->name, chan->name);
+ res = ast_do_pickup(chan, target);
ast_channel_unlock(target);
target = ast_channel_unref(target);
}
@@ -290,58 +278,63 @@ static int pickup_by_mark(struct ast_channel *chan, const char *mark)
/* application entry point for Pickup() */
static int pickup_exec(struct ast_channel *chan, const char *data)
{
- int res = 0;
char *tmp = ast_strdupa(data);
char *exten = NULL, *context = NULL;
if (ast_strlen_zero(data)) {
- res = ast_pickup_call(chan);
- return res;
+ return pickup_by_group(chan) ? 0 : -1;
}
-
+
/* Parse extension (and context if there) */
while (!ast_strlen_zero(tmp) && (exten = strsep(&tmp, "&"))) {
if ((context = strchr(exten, '@')))
*context++ = '\0';
if (!ast_strlen_zero(context) && !strcasecmp(context, PICKUPMARK)) {
- if (!pickup_by_mark(chan, exten))
- break;
+ if (!pickup_by_mark(chan, exten)) {
+ /* Pickup successful. Stop the dialplan this channel is a zombie. */
+ return -1;
+ }
} else {
- if (!pickup_by_exten(chan, exten, !ast_strlen_zero(context) ? context : chan->context))
- break;
+ if (!pickup_by_exten(chan, exten, !ast_strlen_zero(context) ? context : chan->context)) {
+ /* Pickup successful. Stop the dialplan this channel is a zombie. */
+ return -1;
+ }
}
ast_log(LOG_NOTICE, "No target channel found for %s.\n", exten);
}
- return res;
+ /* Pickup failed. Keep going in the dialplan. */
+ return 0;
}
/* Find channel for pick up specified by partial channel name */
static int find_by_part(void *obj, void *arg, void *data, int flags)
{
- struct ast_channel *c = obj;
+ struct ast_channel *target = obj;/*!< Potential pickup target */
const char *part = data;
- int res = 0;
int len = strlen(part);
- ast_channel_lock(c);
- if (len <= strlen(c->name)) {
- res = !(strncmp(c->name, part, len)) && (can_pickup(c));
+ ast_channel_lock(target);
+ if (len <= strlen(target->name) && !strncmp(target->name, part, len)
+ && can_pickup(target)) {
+ /* Return with the channel still locked on purpose */
+ return CMP_MATCH | CMP_STOP;
}
- ast_channel_unlock(c);
+ ast_channel_unlock(target);
- return res ? CMP_MATCH | CMP_STOP : 0;
+ return 0;
}
/* Attempt to pick up specified by partial channel name */
static int pickup_by_part(struct ast_channel *chan, const char *part)
{
- struct ast_channel *target;
+ struct ast_channel *target;/*!< Potential pickup target */
int res = -1;
- if ((target = ast_channel_callback(find_by_part, NULL, (char *) part, 0))) {
- ast_channel_lock(target);
- res = pickup_do(chan, target);
+ /* The found channel is already locked. */
+ target = ast_channel_callback(find_by_part, NULL, (char *) part, 0);
+ if (target) {
+ res = ast_do_pickup(chan, target);
ast_channel_unlock(target);
target = ast_channel_unref(target);
}
@@ -352,7 +345,6 @@ static int pickup_by_part(struct ast_channel *chan, const char *part)
/* application entry point for PickupChan() */
static int pickupchan_exec(struct ast_channel *chan, const char *data)
{
- int res = 0;
int partial_pickup = 0;
char *pickup = NULL;
char *parse = ast_strdupa(data);
@@ -364,7 +356,8 @@ static int pickupchan_exec(struct ast_channel *chan, const char *data)
if (ast_strlen_zero(args.channel)) {
ast_log(LOG_WARNING, "PickupChan requires an argument (channel)!\n");
- return -1;
+ /* Pickup failed. Keep going in the dialplan. */
+ return 0;
}
if (!ast_strlen_zero(args.options) && strchr(args.options, 'p')) {
@@ -378,16 +371,19 @@ static int pickupchan_exec(struct ast_channel *chan, const char *data)
} else {
if (partial_pickup) {
if (!pickup_by_part(chan, pickup)) {
- break;
+ /* Pickup successful. Stop the dialplan this channel is a zombie. */
+ return -1;
}
} else if (!pickup_by_channel(chan, pickup)) {
- break;
+ /* Pickup successful. Stop the dialplan this channel is a zombie. */
+ return -1;
}
ast_log(LOG_NOTICE, "No target channel found for %s.\n", pickup);
}
}
- return res;
+ /* Pickup failed. Keep going in the dialplan. */
+ return 0;
}
static int unload_module(void)
diff --git a/apps/app_dumpchan.c b/apps/app_dumpchan.c
index 47888935b..f9e657201 100644
--- a/apps/app_dumpchan.c
+++ b/apps/app_dumpchan.c
@@ -36,6 +36,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/module.h"
#include "asterisk/channel.h"
#include "asterisk/app.h"
+#include "asterisk/translate.h"
/*** DOCUMENTATION
<application name="DumpChan" language="en_US">
@@ -67,9 +68,11 @@ static int serialize_showchan(struct ast_channel *c, char *buf, size_t size)
struct timeval now;
long elapsed_seconds = 0;
int hour = 0, min = 0, sec = 0;
- char cgrp[BUFSIZ/2];
- char pgrp[BUFSIZ/2];
- char formatbuf[BUFSIZ/2];
+ char nf[256];
+ char cgrp[256];
+ char pgrp[256];
+ struct ast_str *write_transpath = ast_str_alloca(256);
+ struct ast_str *read_transpath = ast_str_alloca(256);
now = ast_tvnow();
memset(buf, 0, size);
@@ -84,65 +87,83 @@ static int serialize_showchan(struct ast_channel *c, char *buf, size_t size)
}
snprintf(buf,size,
- "Name= %s\n"
- "Type= %s\n"
- "UniqueID= %s\n"
- "CallerIDNum= %s\n"
- "CallerIDName= %s\n"
- "DNIDDigits= %s\n"
- "RDNIS= %s\n"
- "Parkinglot= %s\n"
- "Language= %s\n"
- "State= %s (%d)\n"
- "Rings= %d\n"
- "NativeFormat= %s\n"
- "WriteFormat= %s\n"
- "ReadFormat= %s\n"
- "RawWriteFormat= %s\n"
- "RawReadFormat= %s\n"
- "1stFileDescriptor= %d\n"
- "Framesin= %d %s\n"
- "Framesout= %d %s\n"
- "TimetoHangup= %ld\n"
- "ElapsedTime= %dh%dm%ds\n"
- "Context= %s\n"
- "Extension= %s\n"
- "Priority= %d\n"
- "CallGroup= %s\n"
- "PickupGroup= %s\n"
- "Application= %s\n"
- "Data= %s\n"
- "Blocking_in= %s\n",
- c->name,
- c->tech->type,
- c->uniqueid,
- S_COR(c->caller.id.number.valid, c->caller.id.number.str, "(N/A)"),
- S_COR(c->caller.id.name.valid, c->caller.id.name.str, "(N/A)"),
- S_OR(c->dialed.number.str, "(N/A)"),
- S_COR(c->redirecting.from.number.valid, c->redirecting.from.number.str, "(N/A)"),
- c->parkinglot,
- c->language,
- ast_state2str(c->_state),
- c->_state,
- c->rings,
- ast_getformatname_multiple(formatbuf, sizeof(formatbuf), c->nativeformats),
- ast_getformatname(&c->writeformat),
- ast_getformatname(&c->readformat),
- ast_getformatname(&c->rawwriteformat),
- ast_getformatname(&c->rawreadformat),
- c->fds[0], c->fin & ~DEBUGCHAN_FLAG, (c->fin & DEBUGCHAN_FLAG) ? " (DEBUGGED)" : "",
- c->fout & ~DEBUGCHAN_FLAG, (c->fout & DEBUGCHAN_FLAG) ? " (DEBUGGED)" : "", (long)c->whentohangup.tv_sec,
- hour,
- min,
- sec,
- c->context,
- c->exten,
- c->priority,
- ast_print_group(cgrp, sizeof(cgrp), c->callgroup),
- ast_print_group(pgrp, sizeof(pgrp), c->pickupgroup),
- ( c->appl ? c->appl : "(N/A)" ),
- ( c-> data ? S_OR(c->data, "(Empty)") : "(None)"),
- (ast_test_flag(c, AST_FLAG_BLOCKING) ? c->blockproc : "(Not Blocking)"));
+ "Name= %s\n"
+ "Type= %s\n"
+ "UniqueID= %s\n"
+ "LinkedID= %s\n"
+ "CallerIDNum= %s\n"
+ "CallerIDName= %s\n"
+ "ConnectedLineIDNum= %s\n"
+ "ConnectedLineIDName=%s\n"
+ "DNIDDigits= %s\n"
+ "RDNIS= %s\n"
+ "Parkinglot= %s\n"
+ "Language= %s\n"
+ "State= %s (%d)\n"
+ "Rings= %d\n"
+ "NativeFormat= %s\n"
+ "WriteFormat= %s\n"
+ "ReadFormat= %s\n"
+ "RawWriteFormat= %s\n"
+ "RawReadFormat= %s\n"
+ "WriteTranscode= %s %s\n"
+ "ReadTranscode= %s %s\n"
+ "1stFileDescriptor= %d\n"
+ "Framesin= %d %s\n"
+ "Framesout= %d %s\n"
+ "TimetoHangup= %ld\n"
+ "ElapsedTime= %dh%dm%ds\n"
+ "DirectBridge= %s\n"
+ "IndirectBridge= %s\n"
+ "Context= %s\n"
+ "Extension= %s\n"
+ "Priority= %d\n"
+ "CallGroup= %s\n"
+ "PickupGroup= %s\n"
+ "Application= %s\n"
+ "Data= %s\n"
+ "Blocking_in= %s\n",
+ c->name,
+ c->tech->type,
+ c->uniqueid,
+ c->linkedid,
+ S_COR(c->caller.id.number.valid, c->caller.id.number.str, "(N/A)"),
+ S_COR(c->caller.id.name.valid, c->caller.id.name.str, "(N/A)"),
+ S_COR(c->connected.id.number.valid, c->connected.id.number.str, "(N/A)"),
+ S_COR(c->connected.id.name.valid, c->connected.id.name.str, "(N/A)"),
+ S_OR(c->dialed.number.str, "(N/A)"),
+ S_COR(c->redirecting.from.number.valid, c->redirecting.from.number.str, "(N/A)"),
+ c->parkinglot,
+ c->language,
+ ast_state2str(c->_state),
+ c->_state,
+ c->rings,
+ ast_getformatname_multiple(nf, sizeof(nf), c->nativeformats),
+ ast_getformatname(&c->writeformat),
+ ast_getformatname(&c->readformat),
+ ast_getformatname(&c->rawwriteformat),
+ ast_getformatname(&c->rawreadformat),
+ c->writetrans ? "Yes" : "No",
+ ast_translate_path_to_str(c->writetrans, &write_transpath),
+ c->readtrans ? "Yes" : "No",
+ ast_translate_path_to_str(c->readtrans, &read_transpath),
+ c->fds[0],
+ c->fin & ~DEBUGCHAN_FLAG, (c->fin & DEBUGCHAN_FLAG) ? " (DEBUGGED)" : "",
+ c->fout & ~DEBUGCHAN_FLAG, (c->fout & DEBUGCHAN_FLAG) ? " (DEBUGGED)" : "",
+ (long)c->whentohangup.tv_sec,
+ hour,
+ min,
+ sec,
+ c->_bridge ? c->_bridge->name : "<none>",
+ ast_bridged_channel(c) ? ast_bridged_channel(c)->name : "<none>",
+ c->context,
+ c->exten,
+ c->priority,
+ ast_print_group(cgrp, sizeof(cgrp), c->callgroup),
+ ast_print_group(pgrp, sizeof(pgrp), c->pickupgroup),
+ c->appl ? c->appl : "(N/A)",
+ c->data ? S_OR(c->data, "(Empty)") : "(None)",
+ (ast_test_flag(c, AST_FLAG_BLOCKING) ? c->blockproc : "(Not Blocking)"));
return 0;
}
@@ -150,7 +171,7 @@ static int serialize_showchan(struct ast_channel *c, char *buf, size_t size)
static int dumpchan_exec(struct ast_channel *chan, const char *data)
{
struct ast_str *vars = ast_str_thread_get(&ast_str_thread_global_buf, 16);
- char info[1024];
+ char info[2048];
int level = 0;
static char *line = "================================================================================";
@@ -160,7 +181,13 @@ static int dumpchan_exec(struct ast_channel *chan, const char *data)
if (option_verbose >= level) {
serialize_showchan(chan, info, sizeof(info));
pbx_builtin_serialize_variables(chan, &vars);
- ast_verbose("\nDumping Info For Channel: %s:\n%s\nInfo:\n%s\nVariables:\n%s%s\n", chan->name, line, info, ast_str_buffer(vars), line);
+ ast_verbose("\n"
+ "Dumping Info For Channel: %s:\n"
+ "%s\n"
+ "Info:\n"
+ "%s\n"
+ "Variables:\n"
+ "%s%s\n", chan->name, line, info, ast_str_buffer(vars), line);
}
return 0;
diff --git a/apps/app_fax.c b/apps/app_fax.c
index 39c6ad1b6..0d59dfa3a 100644
--- a/apps/app_fax.c
+++ b/apps/app_fax.c
@@ -255,6 +255,9 @@ static void phase_e_handler(t30_state_t *f, void *user_data, int result)
"Channel: %s\r\n"
"Exten: %s\r\n"
"CallerID: %s\r\n"
+ "CallerIDName: %s\r\n"
+ "ConnectedLineNum: %s\r\n"
+ "ConnectedLineName: %s\r\n"
"RemoteStationID: %s\r\n"
"LocalStationID: %s\r\n"
"PagesTransferred: %d\r\n"
@@ -264,6 +267,9 @@ static void phase_e_handler(t30_state_t *f, void *user_data, int result)
s->chan->name,
s->chan->exten,
S_COR(s->chan->caller.id.number.valid, s->chan->caller.id.number.str, ""),
+ S_COR(s->chan->caller.id.name.valid, s->chan->caller.id.name.str, ""),
+ S_COR(s->chan->connected.id.number.valid, s->chan->connected.id.number.str, ""),
+ S_COR(s->chan->connected.id.name.valid, s->chan->connected.id.name.str, ""),
far_ident,
local_ident,
pages_transferred,
diff --git a/apps/app_festival.c b/apps/app_festival.c
index f6f3734ca..a30302fa7 100644
--- a/apps/app_festival.c
+++ b/apps/app_festival.c
@@ -163,7 +163,6 @@ static int send_waveform_to_channel(struct ast_channel *chan, char *waveform, in
{
int res = 0;
int fds[2];
- int pid = -1;
int needed = 0;
struct ast_format owriteformat;
struct ast_frame *f;
@@ -196,7 +195,6 @@ static int send_waveform_to_channel(struct ast_channel *chan, char *waveform, in
res = send_waveform_to_fd(waveform, length, fds[1]);
if (res >= 0) {
- pid = res;
/* Order is important -- there's almost always going to be mp3... we want to prioritize the
user */
for (;;) {
@@ -258,10 +256,6 @@ static int send_waveform_to_channel(struct ast_channel *chan, char *waveform, in
close(fds[0]);
close(fds[1]);
-#if 0
- if (pid > -1)
- kill(pid, SIGKILL);
-#endif
if (!res && owriteformat.id)
ast_set_write_format(chan, &owriteformat);
return res;
@@ -285,7 +279,6 @@ static int festival_exec(struct ast_channel *chan, const char *vdata)
char ack[4];
char *waveform;
int filesize;
- int wave;
char bigstring[MAXFESTLEN];
int i;
struct MD5Context md5ctx;
@@ -494,7 +487,6 @@ static int festival_exec(struct ast_channel *chan, const char *vdata)
/* Read back info from server */
/* This assumes only one waveform will come back, also LP is unlikely */
- wave = 0;
do {
int read_data;
for (n = 0; n < 3; ) {
diff --git a/apps/app_followme.c b/apps/app_followme.c
index c53264b14..7ed874928 100644
--- a/apps/app_followme.c
+++ b/apps/app_followme.c
@@ -804,7 +804,6 @@ static void findmeexec(struct fm_args *tpargs)
char *rest, *number;
struct findme_user *tmpuser;
struct findme_user *fmuser;
- struct findme_user *headuser;
struct findme_user_listptr *findme_user_list;
int status;
@@ -915,7 +914,6 @@ static void findmeexec(struct fm_args *tpargs)
fmuser = NULL;
tmpuser = NULL;
- headuser = NULL;
if (winner)
break;
diff --git a/apps/app_ices.c b/apps/app_ices.c
index b7eea944c..729375313 100644
--- a/apps/app_ices.c
+++ b/apps/app_ices.c
@@ -112,7 +112,6 @@ static int ices_exec(struct ast_channel *chan, const char *data)
int pid = -1;
int flags;
struct ast_format oreadformat;
- struct timeval last;
struct ast_frame *f;
char filename[256]="";
char *c;
@@ -123,8 +122,6 @@ static int ices_exec(struct ast_channel *chan, const char *data)
return -1;
}
- last = ast_tv(0, 0);
-
if (pipe(fds)) {
ast_log(LOG_WARNING, "Unable to create pipe\n");
return -1;
diff --git a/apps/app_meetme.c b/apps/app_meetme.c
index c9c491847..dad293b6e 100644
--- a/apps/app_meetme.c
+++ b/apps/app_meetme.c
@@ -626,8 +626,9 @@ enum {
CONFFLAG_NO_AUDIO_UNTIL_UP = (1 << 31),
};
-/* !If set play an intro announcement at start of conference */
-#define CONFFLAG_INTROMSG ((uint64_t)1 << 32)
+/* These flags are defined separately because we ran out of bits that an enum can be used to represent.
+ If you add new flags, be sure to do it in the same way that CONFFLAG_INTROMSG is. */
+#define CONFFLAG_INTROMSG ((uint64_t)1 << 32) /*!< If set play an intro announcement at start of conference */
#define CONFFLAG_INTROUSER_VMREC ((uint64_t)1 << 33)
enum {
@@ -779,13 +780,13 @@ struct ast_conf_user {
char usrvalue[50]; /*!< Custom User Value */
char namerecloc[PATH_MAX]; /*!< Name Recorded file Location */
time_t jointime; /*!< Time the user joined the conference */
- time_t kicktime; /*!< Time the user will be kicked from the conference */
- struct timeval start_time; /*!< Time the user entered into the conference */
- long timelimit; /*!< Time limit for the user to be in the conference L(x:y:z) */
- long play_warning; /*!< Play a warning when 'y' ms are left */
- long warning_freq; /*!< Repeat the warning every 'z' ms */
- const char *warning_sound; /*!< File to play as warning if 'y' is defined */
- const char *end_sound; /*!< File to play when time is up. */
+ time_t kicktime; /*!< Time the user will be kicked from the conference */
+ struct timeval start_time; /*!< Time the user entered into the conference */
+ long timelimit; /*!< Time limit for the user to be in the conference L(x:y:z) */
+ long play_warning; /*!< Play a warning when 'y' ms are left */
+ long warning_freq; /*!< Repeat the warning every 'z' ms */
+ const char *warning_sound; /*!< File to play as warning if 'y' is defined */
+ const char *end_sound; /*!< File to play when time is up. */
struct volume talk;
struct volume listen;
AST_LIST_ENTRY(ast_conf_user) list;
@@ -1370,6 +1371,7 @@ static char *complete_meetmecmd(const char *line, const char *word, int pos, int
AST_LIST_UNLOCK(&confs);
return usr ? ast_strdup(usrno) : NULL;
}
+ AST_LIST_UNLOCK(&confs);
}
}
@@ -2245,7 +2247,6 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, struc
int talkreq_manager = 0;
int using_pseudo = 0;
int duration = 20;
- int hr, min, sec;
int sent_event = 0;
int checked = 0;
int announcement_played = 0;
@@ -2732,7 +2733,7 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, struc
ao2_ref(item, -1);
}
- if (ast_test_flag64(confflags, CONFFLAG_WAITMARKED && !conf->markedusers))
+ if (ast_test_flag64(confflags, CONFFLAG_WAITMARKED) && !conf->markedusers)
dahdic.confmode = DAHDI_CONF_CONF;
else if (ast_test_flag64(confflags, CONFFLAG_MONITOR))
dahdic.confmode = DAHDI_CONF_CONFMON | DAHDI_CONF_LISTENER;
@@ -2755,11 +2756,15 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, struc
"Meetme: %s\r\n"
"Usernum: %d\r\n"
"CallerIDnum: %s\r\n"
- "CallerIDname: %s\r\n",
+ "CallerIDname: %s\r\n"
+ "ConnectedLineNum: %s\r\n"
+ "ConnectedLineName: %s\r\n",
chan->name, chan->uniqueid, conf->confno,
user->user_no,
S_COR(user->chan->caller.id.number.valid, user->chan->caller.id.number.str, "<unknown>"),
- S_COR(user->chan->caller.id.name.valid, user->chan->caller.id.name.str, "<unknown>")
+ S_COR(user->chan->caller.id.name.valid, user->chan->caller.id.name.str, "<unknown>"),
+ S_COR(user->chan->connected.id.number.valid, user->chan->connected.id.number.str, "<unknown>"),
+ S_COR(user->chan->connected.id.name.valid, user->chan->connected.id.name.str, "<unknown>")
);
sent_event = 1;
}
@@ -2917,6 +2922,11 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, struc
res = ast_streamfile(chan, user->end_sound, chan->language);
res = ast_waitstream(chan, "");
}
+ if (ast_test_flag64(confflags, CONFFLAG_KICK_CONTINUE)) {
+ ret = 0;
+ } else {
+ ret = -1;
+ }
break;
}
@@ -3802,9 +3812,6 @@ bailoutandtrynormal:
if (user->user_no) {
/* Only cleanup users who really joined! */
now = ast_tvnow();
- hr = (now.tv_sec - user->jointime) / 3600;
- min = ((now.tv_sec - user->jointime) % 3600) / 60;
- sec = (now.tv_sec - user->jointime) % 60;
if (sent_event) {
ast_manager_event(chan, EVENT_FLAG_CALL, "MeetmeLeave",
@@ -3814,11 +3821,15 @@ bailoutandtrynormal:
"Usernum: %d\r\n"
"CallerIDNum: %s\r\n"
"CallerIDName: %s\r\n"
+ "ConnectedLineNum: %s\r\n"
+ "ConnectedLineName: %s\r\n"
"Duration: %ld\r\n",
chan->name, chan->uniqueid, conf->confno,
user->user_no,
S_COR(user->chan->caller.id.number.valid, user->chan->caller.id.number.str, "<unknown>"),
S_COR(user->chan->caller.id.name.valid, user->chan->caller.id.name.str, "<unknown>"),
+ S_COR(user->chan->connected.id.number.valid, user->chan->connected.id.number.str, "<unknown>"),
+ S_COR(user->chan->connected.id.name.valid, user->chan->connected.id.name.str, "<unknown>"),
(long)(now.tv_sec - user->jointime));
}
@@ -3906,7 +3917,7 @@ static struct ast_conference *find_conf_realtime(struct ast_channel *chan, char
ast_localtime(&now, &tm, NULL);
ast_strftime(currenttime, sizeof(currenttime), DATE_FORMAT, &tm);
- ast_debug(1, "Looking for conference %s that starts after %s\n", confno, eatime);
+ ast_debug(1, "Looking for conference %s that starts after %s\n", confno, currenttime);
var = ast_load_realtime("meetme", "confno",
confno, "starttime <= ", currenttime, "endtime >= ",
@@ -4880,6 +4891,8 @@ static int action_meetmelist(struct mansession *s, const struct message *m)
"UserNumber: %d\r\n"
"CallerIDNum: %s\r\n"
"CallerIDName: %s\r\n"
+ "ConnectedLineNum: %s\r\n"
+ "ConnectedLineName: %s\r\n"
"Channel: %s\r\n"
"Admin: %s\r\n"
"Role: %s\r\n"
@@ -4892,6 +4905,8 @@ static int action_meetmelist(struct mansession *s, const struct message *m)
user->user_no,
S_COR(user->chan->caller.id.number.valid, user->chan->caller.id.number.str, "<unknown>"),
S_COR(user->chan->caller.id.name.valid, user->chan->caller.id.name.str, "<no name>"),
+ S_COR(user->chan->connected.id.number.valid, user->chan->connected.id.number.str, "<unknown>"),
+ S_COR(user->chan->connected.id.name.valid, user->chan->connected.id.name.str, "<no name>"),
user->chan->name,
ast_test_flag64(&user->userflags, CONFFLAG_ADMIN) ? "Yes" : "No",
ast_test_flag64(&user->userflags, CONFFLAG_MONITOR) ? "Listen only" : ast_test_flag64(&user->userflags, CONFFLAG_TALKER) ? "Talk only" : "Talk and listen",
@@ -6453,7 +6468,6 @@ static int sla_trunk_exec(struct ast_channel *chan, const char *data)
AST_APP_ARG(options);
);
char *opts[SLA_TRUNK_OPT_ARG_ARRAY_SIZE] = { NULL, };
- char *conf_opt_args[OPT_ARG_ARRAY_SIZE] = { NULL, };
struct ast_flags opt_flags = { 0 };
char *parse;
@@ -6516,7 +6530,6 @@ static int sla_trunk_exec(struct ast_channel *chan, const char *data)
if (ast_test_flag(&opt_flags, SLA_TRUNK_OPT_MOH)) {
ast_indicate(chan, -1);
ast_set_flag64(&conf_flags, CONFFLAG_MOH);
- conf_opt_args[OPT_ARG_MOH_CLASS] = opts[SLA_TRUNK_OPT_ARG_MOH_CLASS];
} else
ast_indicate(chan, AST_CONTROL_RINGING);
diff --git a/apps/app_minivm.c b/apps/app_minivm.c
index 55373698c..124a04d4f 100644
--- a/apps/app_minivm.c
+++ b/apps/app_minivm.c
@@ -1229,7 +1229,7 @@ static int sendmail(struct minivm_template *template, struct minivm_account *vmu
struct ast_tm tm;
struct minivm_zone *the_zone = NULL;
struct ast_channel *ast;
- char *finalfilename;
+ char *finalfilename = "";
struct ast_str *str1 = ast_str_create(16), *str2 = ast_str_create(16);
char *fromaddress;
char *fromemail;
@@ -1266,13 +1266,22 @@ static int sendmail(struct minivm_template *template, struct minivm_account *vmu
char tmpcmd[PATH_MAX];
int tmpfd;
+ /**
+ * XXX
+ * /bug tmpfd is a leaked fd. The file is also never unlinked.
+ * See app_voicemail.c for how the code works there that
+ * doesn't have this bug.
+ */
+
ast_copy_string(newtmp, "/tmp/XXXXXX", sizeof(newtmp));
ast_debug(3, "newtmp: %s\n", newtmp);
tmpfd = mkstemp(newtmp);
- snprintf(tmpcmd, sizeof(tmpcmd), "sox -v %.4f %s.%s %s.%s", vmu->volgain, filename, format, newtmp, format);
- ast_safe_system(tmpcmd);
- finalfilename = newtmp;
- ast_debug(3, "VOLGAIN: Stored at: %s.%s - Level: %.4f - Mailbox: %s\n", filename, format, vmu->volgain, vmu->username);
+ if (tmpfd > -1) {
+ snprintf(tmpcmd, sizeof(tmpcmd), "sox -v %.4f %s.%s %s.%s", vmu->volgain, filename, format, newtmp, format);
+ ast_safe_system(tmpcmd);
+ finalfilename = newtmp;
+ ast_debug(3, "VOLGAIN: Stored at: %s.%s - Level: %.4f - Mailbox: %s\n", filename, format, vmu->volgain, vmu->username);
+ }
} else {
finalfilename = ast_strdupa(filename);
}
@@ -1828,7 +1837,6 @@ static int leave_voicemail(struct ast_channel *chan, char *username, struct leav
char callerid[256];
FILE *txt;
int res = 0, txtdes;
- int msgnum;
int duration = 0;
char date[256];
char tmpdir[PATH_MAX];
@@ -1871,7 +1879,6 @@ static int leave_voicemail(struct ast_channel *chan, char *username, struct leav
pbx_builtin_setvar_helper(chan, "MVM_RECORD_STATUS", "FAILED");
return res;
}
- msgnum = 0;
userdir = check_dirpath(tmpdir, sizeof(tmpdir), vmu->domain, username, "tmp");
@@ -2452,7 +2459,6 @@ static int minivm_accmess_exec(struct ast_channel *chan, const char *data)
char *message = NULL;
char *prompt = NULL;
int duration;
- int cmd;
if (ast_strlen_zero(data)) {
ast_log(LOG_ERROR, "MinivmAccmess needs at least two arguments: account and option\n");
@@ -2526,7 +2532,7 @@ static int minivm_accmess_exec(struct ast_channel *chan, const char *data)
}
snprintf(filename,sizeof(filename), "%s%s/%s/%s", MVM_SPOOL_DIR, vmu->domain, vmu->username, message);
/* Maybe we should check the result of play_record_review ? */
- cmd = play_record_review(chan, prompt, filename, global_maxgreet, default_vmformat, 0, vmu, &duration, NULL, FALSE);
+ play_record_review(chan, prompt, filename, global_maxgreet, default_vmformat, 0, vmu, &duration, NULL, FALSE);
ast_debug(1, "Recorded new %s message in %s (duration %d)\n", message, filename, duration);
@@ -3238,12 +3244,10 @@ static int minivm_account_func_read(struct ast_channel *chan, const char *cmd, c
check_dirpath(buf, len, vmu->domain, vmu->username, NULL);
} else { /* Look in channel variables */
struct ast_variable *var;
- int found = 0;
for (var = vmu->chanvars ; var ; var = var->next)
if (!strcmp(var->name, colname)) {
ast_copy_string(buf, var->value, len);
- found = 1;
break;
}
}
diff --git a/apps/app_originate.c b/apps/app_originate.c
index 94ac3596c..bc811d958 100644
--- a/apps/app_originate.c
+++ b/apps/app_originate.c
@@ -101,7 +101,6 @@ static int originate_exec(struct ast_channel *chan, const char *data)
char *parse;
char *chantech, *chandata;
int res = -1;
- int outgoing_res = 0;
int outgoing_status = 0;
static const unsigned int timeout = 30;
static const char default_exten[] = "s";
@@ -154,14 +153,14 @@ static int originate_exec(struct ast_channel *chan, const char *data)
ast_debug(1, "Originating call to '%s/%s' and connecting them to extension %s,%s,%d\n",
chantech, chandata, args.arg1, exten, priority);
- outgoing_res = ast_pbx_outgoing_exten(chantech, cap_slin, chandata,
+ ast_pbx_outgoing_exten(chantech, cap_slin, chandata,
timeout * 1000, args.arg1, exten, priority, &outgoing_status, 0, NULL,
NULL, NULL, NULL, NULL);
} else if (!strcasecmp(args.type, "app")) {
ast_debug(1, "Originating call to '%s/%s' and connecting them to %s(%s)\n",
chantech, chandata, args.arg1, S_OR(args.arg2, ""));
- outgoing_res = ast_pbx_outgoing_app(chantech, cap_slin, chandata,
+ ast_pbx_outgoing_app(chantech, cap_slin, chandata,
timeout * 1000, args.arg1, args.arg2, &outgoing_status, 0, NULL,
NULL, NULL, NULL, NULL);
} else {
diff --git a/apps/app_privacy.c b/apps/app_privacy.c
index 77c3a1f2e..6a6c1a437 100644
--- a/apps/app_privacy.c
+++ b/apps/app_privacy.c
@@ -53,6 +53,9 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
<parameter name="minlength">
<para>Minimum allowable digits in the input callerid number. Defaults to <literal>10</literal>.</para>
</parameter>
+ <parameter name="options">
+ <para>Position reserved for options.</para>
+ </parameter>
<parameter name="context">
<para>Context to check the given callerid against patterns.</para>
</parameter>
diff --git a/apps/app_queue.c b/apps/app_queue.c
index 5c348b752..146cf63d6 100644
--- a/apps/app_queue.c
+++ b/apps/app_queue.c
@@ -999,7 +999,7 @@ struct callattempt {
struct queue_ent {
struct call_queue *parent; /*!< What queue is our parent */
char moh[80]; /*!< Name of musiconhold to be used */
- char announce[80]; /*!< Announcement to play for member when call is answered */
+ char announce[PATH_MAX]; /*!< Announcement to play for member when call is answered */
char context[AST_MAX_CONTEXT]; /*!< Context when user exits queue */
char digits[AST_MAX_EXTENSION]; /*!< Digits entered while in queue */
int valid_digits; /*!< Digits entered correspond to valid extension. Exited */
@@ -2072,9 +2072,9 @@ static void queue_set_param(struct call_queue *q, const char *param, const char
* \brief Find rt member record to update otherwise create one.
*
* Search for member in queue, if found update penalty/paused state,
- * if no member exists create one flag it as a RT member and add to queue member list.
+ * if no member exists create one flag it as a RT member and add to queue member list.
*/
-static void rt_handle_member_record(struct call_queue *q, char *interface, const char *rt_uniqueid, const char *membername, const char *penalty_str, const char *paused_str, const char* state_interface)
+static void rt_handle_member_record(struct call_queue *q, char *interface, struct ast_config *member_config)
{
struct member *m;
struct ao2_iterator mem_iter;
@@ -2082,6 +2082,12 @@ static void rt_handle_member_record(struct call_queue *q, char *interface, const
int paused = 0;
int found = 0;
+ const char *rt_uniqueid = ast_variable_retrieve(member_config, interface, "uniqueid");
+ const char *membername = S_OR(ast_variable_retrieve(member_config, interface, "membername"), interface);
+ const char *state_interface = S_OR(ast_variable_retrieve(member_config, interface, "state_interface"), interface);
+ const char *penalty_str = ast_variable_retrieve(member_config, interface, "penalty");
+ const char *paused_str = ast_variable_retrieve(member_config, interface, "paused");
+
if (ast_strlen_zero(rt_uniqueid)) {
ast_log(LOG_WARNING, "Realtime field uniqueid is empty for member %s\n", S_OR(membername, "NULL"));
return;
@@ -2299,12 +2305,7 @@ static struct call_queue *find_queue_by_name_rt(const char *queuename, struct as
ao2_iterator_destroy(&mem_iter);
while ((interface = ast_category_browse(member_config, interface))) {
- rt_handle_member_record(q, interface,
- ast_variable_retrieve(member_config, interface, "uniqueid"),
- S_OR(ast_variable_retrieve(member_config, interface, "membername"),interface),
- ast_variable_retrieve(member_config, interface, "penalty"),
- ast_variable_retrieve(member_config, interface, "paused"),
- S_OR(ast_variable_retrieve(member_config, interface, "state_interface"),interface));
+ rt_handle_member_record(q, interface, member_config);
}
/* Delete all realtime members that have been deleted in DB. */
@@ -2426,12 +2427,7 @@ static void update_realtime_members(struct call_queue *q)
ao2_iterator_destroy(&mem_iter);
while ((interface = ast_category_browse(member_config, interface))) {
- rt_handle_member_record(q, interface,
- ast_variable_retrieve(member_config, interface, "uniqueid"),
- S_OR(ast_variable_retrieve(member_config, interface, "membername"), interface),
- ast_variable_retrieve(member_config, interface, "penalty"),
- ast_variable_retrieve(member_config, interface, "paused"),
- S_OR(ast_variable_retrieve(member_config, interface, "state_interface"), interface));
+ rt_handle_member_record(q, interface, member_config);
}
/* Delete all realtime members that have been deleted in DB. */
@@ -2515,10 +2511,20 @@ static int join_queue(char *queuename, struct queue_ent *qe, enum queue_result *
q->count++;
res = 0;
ast_manager_event(qe->chan, EVENT_FLAG_CALL, "Join",
- "Channel: %s\r\nCallerIDNum: %s\r\nCallerIDName: %s\r\nQueue: %s\r\nPosition: %d\r\nCount: %d\r\nUniqueid: %s\r\n",
+ "Channel: %s\r\n"
+ "CallerIDNum: %s\r\n"
+ "CallerIDName: %s\r\n"
+ "ConnectedLineNum: %s\r\n"
+ "ConnectedLineName: %s\r\n"
+ "Queue: %s\r\n"
+ "Position: %d\r\n"
+ "Count: %d\r\n"
+ "Uniqueid: %s\r\n",
qe->chan->name,
S_COR(qe->chan->caller.id.number.valid, qe->chan->caller.id.number.str, "unknown"),/* XXX somewhere else it is <unknown> */
S_COR(qe->chan->caller.id.name.valid, qe->chan->caller.id.name.str, "unknown"),
+ S_COR(qe->chan->connected.id.number.valid, qe->chan->connected.id.number.str, "unknown"),/* XXX somewhere else it is <unknown> */
+ S_COR(qe->chan->connected.id.name.valid, qe->chan->connected.id.name.str, "unknown"),
q->name, qe->pos, q->count, qe->chan->uniqueid );
ast_debug(1, "Queue '%s' Join, Channel '%s', Position '%d'\n", q->name, qe->chan->name, qe->pos );
}
@@ -3152,6 +3158,8 @@ static int ring_entry(struct queue_ent *qe, struct callattempt *tmp, int *busies
"DestinationChannel: %s\r\n"
"CallerIDNum: %s\r\n"
"CallerIDName: %s\r\n"
+ "ConnectedLineNum: %s\r\n"
+ "ConnectedLineName: %s\r\n"
"Context: %s\r\n"
"Extension: %s\r\n"
"Priority: %d\r\n"
@@ -3160,6 +3168,8 @@ static int ring_entry(struct queue_ent *qe, struct callattempt *tmp, int *busies
qe->parent->name, tmp->interface, tmp->member->membername, qe->chan->name, tmp->chan->name,
S_COR(tmp->chan->caller.id.number.valid, tmp->chan->caller.id.number.str, "unknown"),
S_COR(tmp->chan->caller.id.name.valid, tmp->chan->caller.id.name.str, "unknown"),
+ S_COR(tmp->chan->connected.id.number.valid, tmp->chan->connected.id.number.str, "unknown"),
+ S_COR(tmp->chan->connected.id.name.valid, tmp->chan->connected.id.name.str, "unknown"),
qe->chan->context, qe->chan->exten, qe->chan->priority, qe->chan->uniqueid,
qe->parent->eventwhencalled == QUEUE_EVENT_VARIABLES ? vars2manager(qe->chan, vars, sizeof(vars)) : "");
ast_verb(3, "Called %s\n", tmp->interface);
@@ -4323,7 +4333,6 @@ static int try_calling(struct queue_ent *qe, const char *options, char *announce
char *agiexec = NULL;
char *macroexec = NULL;
char *gosubexec = NULL;
- int ret = 0;
const char *monitorfilename;
const char *monitor_exec;
const char *monitor_options;
@@ -4849,7 +4858,7 @@ static int try_calling(struct queue_ent *qe, const char *options, char *announce
/* We purposely lock the CDR so that pbx_exec does not update the application data */
if (qe->chan->cdr)
ast_set_flag(qe->chan->cdr, AST_CDR_FLAG_LOCKED);
- ret = pbx_exec(qe->chan, mixmonapp, mixmonargs);
+ pbx_exec(qe->chan, mixmonapp, mixmonargs);
if (qe->chan->cdr)
ast_clear_flag(qe->chan->cdr, AST_CDR_FLAG_LOCKED);
@@ -4981,7 +4990,7 @@ static int try_calling(struct queue_ent *qe, const char *options, char *announce
application = pbx_findapp("agi");
if (application) {
agiexec = ast_strdupa(agi);
- ret = pbx_exec(qe->chan, application, agiexec);
+ pbx_exec(qe->chan, application, agiexec);
} else
ast_log(LOG_WARNING, "Asked to execute an AGI on this channel, but could not find application (agi)!\n");
}
@@ -7248,12 +7257,16 @@ static int manager_queues_status(struct mansession *s, const struct message *m)
"Uniqueid: %s\r\n"
"CallerIDNum: %s\r\n"
"CallerIDName: %s\r\n"
+ "ConnectedLineNum: %s\r\n"
+ "ConnectedLineName: %s\r\n"
"Wait: %ld\r\n"
"%s"
"\r\n",
q->name, pos++, qe->chan->name, qe->chan->uniqueid,
S_COR(qe->chan->caller.id.number.valid, qe->chan->caller.id.number.str, "unknown"),
S_COR(qe->chan->caller.id.name.valid, qe->chan->caller.id.name.str, "unknown"),
+ S_COR(qe->chan->connected.id.number.valid, qe->chan->connected.id.number.str, "unknown"),
+ S_COR(qe->chan->connected.id.name.valid, qe->chan->connected.id.name.str, "unknown"),
(long) (now - qe->start), idText);
}
}
diff --git a/apps/app_rpt.c b/apps/app_rpt.c
index 88997936c..990f05423 100644
--- a/apps/app_rpt.c
+++ b/apps/app_rpt.c
@@ -1975,7 +1975,11 @@ unsigned int seq;
return;
}
n = finddelim(astr,astrs,100);
- if (n < 1) return;
+ if (n < 1) {
+ ast_free(str);
+ ast_free(astr);
+ return;
+ }
ast_mutex_lock(&myrpt->statpost_lock);
seq = ++myrpt->statpost_seqno;
ast_mutex_unlock(&myrpt->statpost_lock);
@@ -12218,7 +12222,7 @@ struct ast_format_cap *cap = NULL;
// ctcss code autopatch initiate
if (strstr((char *)f->data.ptr,"/M/")&& !myrpt->macropatch)
{
- char value[16];
+ char value[16] = "";
strcat(value,"*6");
myrpt->macropatch=1;
rpt_mutex_lock(&myrpt->lock);
diff --git a/apps/app_userevent.c b/apps/app_userevent.c
index f149d8524..1e1e4a9cd 100644
--- a/apps/app_userevent.c
+++ b/apps/app_userevent.c
@@ -85,7 +85,12 @@ static int userevent_exec(struct ast_channel *chan, const char *data)
ast_str_append(&body, 0, "%s\r\n", args.extra[x]);
}
- manager_event(EVENT_FLAG_USER, "UserEvent", "UserEvent: %s\r\n%s", args.eventname, ast_str_buffer(body));
+ manager_event(EVENT_FLAG_USER, "UserEvent",
+ "UserEvent: %s\r\n"
+ "Uniqueid: %s\r\n"
+ "%s",
+ args.eventname, chan->uniqueid, ast_str_buffer(body));
+
ast_free(body);
return 0;
diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c
index 396ed8bd9..5e342bda0 100644
--- a/apps/app_voicemail.c
+++ b/apps/app_voicemail.c
@@ -2177,11 +2177,16 @@ static int imap_store_file(const char *dir, const char *mailboxuser, const char
int ret; /* for better error checking */
char *imap_flags = NIL;
int msgcount = (messagecount(vmu->context, vmu->mailbox, "INBOX") + messagecount(vmu->context, vmu->mailbox, "Old"));
+ int box = NEW_FOLDER;
- /* Back out early if this is a greeting and we don't want to store greetings in IMAP */
- if (msgnum < 0 && !imapgreetings) {
- return 0;
- }
+ /* Back out early if this is a greeting and we don't want to store greetings in IMAP */
+ if (msgnum < 0) {
+ if(!imapgreetings) {
+ return 0;
+ } else {
+ box = GREETINGS_FOLDER;
+ }
+ }
if (imap_check_limits(chan, vms, vmu, msgcount)) {
return -1;
@@ -2264,9 +2269,9 @@ static int imap_store_file(const char *dir, const char *mailboxuser, const char
}
((char *) buf)[len] = '\0';
INIT(&str, mail_string, buf, len);
- ret = init_mailstream(vms, NEW_FOLDER);
+ ret = init_mailstream(vms, box);
if (ret == 0) {
- imap_mailbox_name(mailbox, sizeof(mailbox), vms, NEW_FOLDER, 1);
+ imap_mailbox_name(mailbox, sizeof(mailbox), vms, box, 1);
ast_mutex_lock(&vms->lock);
if(!mail_append_full(vms->mailstream, mailbox, imap_flags, NIL, &str))
ast_log(LOG_ERROR, "Error while sending the message to %s\n", mailbox);
@@ -4734,6 +4739,7 @@ static int add_email_attachment(FILE *p, struct ast_vm_user *vmu, char *format,
char fname[256];
char tmpcmd[256];
int tmpfd = -1;
+ int soxstatus = 0;
/* Eww. We want formats to tell us their own MIME type */
char *ctype = (!strcasecmp(format, "ogg")) ? "application/" : "audio/x-";
@@ -4745,7 +4751,6 @@ static int add_email_attachment(FILE *p, struct ast_vm_user *vmu, char *format,
chmod(newtmp, VOICEMAIL_FILE_MODE & ~my_umask);
ast_debug(3, "newtmp: %s\n", newtmp);
if (tmpfd > -1) {
- int soxstatus;
snprintf(tmpcmd, sizeof(tmpcmd), "sox -v %.4f %s.%s %s.%s", vmu->volgain, attach, format, newtmp, format);
if ((soxstatus = ast_safe_system(tmpcmd)) == 0) {
attach = newtmp;
@@ -4773,7 +4778,9 @@ static int add_email_attachment(FILE *p, struct ast_vm_user *vmu, char *format,
if (last)
fprintf(p, ENDL ENDL "--%s--" ENDL "." ENDL, bound);
if (tmpfd > -1) {
- unlink(fname);
+ if (soxstatus == 0) {
+ unlink(fname);
+ }
close(tmpfd);
unlink(newtmp);
}
@@ -6696,7 +6703,21 @@ static int get_folder(struct ast_channel *chan, int start)
if (d)
return d;
snprintf(fn, sizeof(fn), "vm-%s", mbox(NULL, x)); /* Folder name */
- d = vm_play_folder_name(chan, fn);
+
+ /* The inbox folder can have its name changed under certain conditions
+ * so this checks if the sound file exists for the inbox folder name and
+ * if it doesn't, plays the default name instead. */
+ if (x == 0) {
+ if (ast_fileexists(fn, NULL, NULL)) {
+ d = vm_play_folder_name(chan, fn);
+ } else {
+ ast_verb(1, "failed to find %s\n", fn);
+ d = vm_play_folder_name(chan, "vm-INBOX");
+ }
+ } else {
+ d = vm_play_folder_name(chan, fn);
+ }
+
if (d)
return d;
d = ast_waitfordigit(chan, 500);
@@ -7061,7 +7082,6 @@ static int forward_message(struct ast_channel *chan, char *context, struct vm_st
char *dir;
int curmsg;
char urgent_str[7] = "";
- char tmptxtfile[PATH_MAX];
int prompt_played = 0;
#ifndef IMAP_STORAGE
char msgfile[PATH_MAX], textfile[PATH_MAX], backup[PATH_MAX], backup_textfile[PATH_MAX];
@@ -7074,7 +7094,6 @@ static int forward_message(struct ast_channel *chan, char *context, struct vm_st
dir = vms->curdir;
curmsg = vms->curmsg;
- tmptxtfile[0] = '\0';
while (!res && !valid_extensions) {
int use_directory = 0;
if (ast_test_flag((&globalflags), VM_DIRECFORWARD)) {
@@ -12129,6 +12148,9 @@ static int load_config(int reload)
if (ucfg) {
for (cat = ast_category_browse(ucfg, NULL); cat ; cat = ast_category_browse(ucfg, cat)) {
+ if (!strcasecmp(cat, "general")) {
+ continue;
+ }
if (!ast_true(ast_config_option(ucfg, cat, "hasvoicemail")))
continue;
if ((current = find_or_create(userscontext, cat))) {
diff --git a/apps/confbridge/conf_config_parser.c b/apps/confbridge/conf_config_parser.c
new file mode 100644
index 000000000..dbec32bba
--- /dev/null
+++ b/apps/confbridge/conf_config_parser.c
@@ -0,0 +1,1444 @@
+/*
+ * Asterisk -- An open source telephony toolkit.
+ *
+ * Copyright (C) 2011, Digium, Inc.
+ *
+ * David Vossel <dvossel@digium.com>
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE file
+ * at the top of the source tree.
+ */
+
+/*! \file
+ *
+ * \brief ConfBridge config parser
+ *
+ * \author David Vossel <dvossel@digium.com>
+ */
+
+#include "asterisk.h"
+
+ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
+#include "asterisk/logger.h"
+#include "asterisk/config.h"
+#include "include/confbridge.h"
+#include "asterisk/astobj2.h"
+#include "asterisk/cli.h"
+#include "asterisk/bridging_features.h"
+#include "asterisk/stringfields.h"
+#include "asterisk/pbx.h"
+
+#define CONFBRIDGE_CONFIG "confbridge.conf"
+
+static struct ao2_container *user_profiles;
+static struct ao2_container *bridge_profiles;
+static struct ao2_container *menus;
+
+/*! bridge profile container functions */
+static int bridge_cmp_cb(void *obj, void *arg, int flags)
+{
+ const struct bridge_profile *entry1 = obj;
+ const struct bridge_profile *entry2 = arg;
+ return (!strcasecmp(entry1->name, entry2->name)) ? CMP_MATCH | CMP_STOP : 0;
+}
+static int bridge_hash_cb(const void *obj, const int flags)
+{
+ const struct bridge_profile *b_profile = obj;
+ return ast_str_case_hash(b_profile->name);
+}
+static int bridge_mark_delme_cb(void *obj, void *arg, int flag)
+{
+ struct bridge_profile *entry = obj;
+ entry->delme = 1;
+ return 0;
+}
+static int match_bridge_delme_cb(void *obj, void *arg, int flag)
+{
+ const struct bridge_profile *entry = obj;
+ return entry->delme ? CMP_MATCH : 0;
+}
+
+/*! menu container functions */
+static int menu_cmp_cb(void *obj, void *arg, int flags)
+{
+ const struct conf_menu *entry1 = obj;
+ const struct conf_menu *entry2 = arg;
+ return (!strcasecmp(entry1->name, entry2->name)) ? CMP_MATCH | CMP_STOP : 0;
+}
+static int menu_hash_cb(const void *obj, const int flags)
+{
+ const struct conf_menu *menu = obj;
+ return ast_str_case_hash(menu->name);
+}
+static int menu_mark_delme_cb(void *obj, void *arg, int flag)
+{
+ struct conf_menu *entry = obj;
+ entry->delme = 1;
+ return 0;
+}
+static int match_menu_delme_cb(void *obj, void *arg, int flag)
+{
+ const struct conf_menu *entry = obj;
+ return entry->delme ? CMP_MATCH : 0;
+}
+static void menu_destructor(void *obj)
+{
+ struct conf_menu *menu = obj;
+ struct conf_menu_entry *entry = NULL;
+
+ while ((entry = AST_LIST_REMOVE_HEAD(&menu->entries, entry))) {
+ conf_menu_entry_destroy(entry);
+ ast_free(entry);
+ }
+}
+
+/*! User profile container functions */
+static int user_cmp_cb(void *obj, void *arg, int flags)
+{
+ const struct user_profile *entry1 = obj;
+ const struct user_profile *entry2 = arg;
+ return (!strcasecmp(entry1->name, entry2->name)) ? CMP_MATCH | CMP_STOP : 0;
+}
+static int user_hash_cb(const void *obj, const int flags)
+{
+ const struct user_profile *u_profile = obj;
+ return ast_str_case_hash(u_profile->name);
+}
+static int user_mark_delme_cb(void *obj, void *arg, int flag)
+{
+ struct user_profile *entry = obj;
+ entry->delme = 1;
+ return 0;
+}
+static int match_user_delme_cb(void *obj, void *arg, int flag)
+{
+ const struct user_profile *entry = obj;
+ return entry->delme ? CMP_MATCH : 0;
+}
+
+/*! Bridge Profile Sounds functions */
+static void bridge_profile_sounds_destroy_cb(void *obj)
+{
+ struct bridge_profile_sounds *sounds = obj;
+ ast_string_field_free_memory(sounds);
+}
+
+static struct bridge_profile_sounds *bridge_profile_sounds_alloc(void)
+{
+ struct bridge_profile_sounds *sounds = ao2_alloc(sizeof(*sounds), bridge_profile_sounds_destroy_cb);
+
+ if (!sounds) {
+ return NULL;
+ }
+ if (ast_string_field_init(sounds, 512)) {
+ ao2_ref(sounds, -1);
+ return NULL;
+ }
+
+ return sounds;
+}
+
+static int set_user_option(const char *name, const char *value, struct user_profile *u_profile)
+{
+ if (!strcasecmp(name, "admin")) {
+ ast_set2_flag(u_profile, ast_true(value), USER_OPT_ADMIN);
+ } else if (!strcasecmp(name, "marked")) {
+ ast_set2_flag(u_profile, ast_true(value), USER_OPT_MARKEDUSER);
+ } else if (!strcasecmp(name, "startmuted")) {
+ ast_set2_flag(u_profile, ast_true(value), USER_OPT_STARTMUTED);
+ } else if (!strcasecmp(name, "music_on_hold_when_empty")) {
+ ast_set2_flag(u_profile, ast_true(value), USER_OPT_MUSICONHOLD);
+ } else if (!strcasecmp(name, "quiet")) {
+ ast_set2_flag(u_profile, ast_true(value), USER_OPT_QUIET);
+ } else if (!strcasecmp(name, "announce_user_count_all")) {
+ if (ast_true(value)) {
+ u_profile->flags = u_profile->flags | USER_OPT_ANNOUNCEUSERCOUNTALL;
+ } else if (ast_false(value)) {
+ u_profile->flags = u_profile->flags & ~USER_OPT_ANNOUNCEUSERCOUNTALL;
+ } else if (sscanf(value, "%30u", &u_profile->announce_user_count_all_after) == 1) {
+ u_profile->flags = u_profile->flags | USER_OPT_ANNOUNCEUSERCOUNTALL;
+ } else {
+ return -1;
+ }
+ } else if (!strcasecmp(name, "announce_user_count")) {
+ ast_set2_flag(u_profile, ast_true(value), USER_OPT_ANNOUNCEUSERCOUNT);
+ } else if (!strcasecmp(name, "announce_only_user")) {
+ u_profile->flags = ast_true(value) ?
+ u_profile->flags & ~USER_OPT_NOONLYPERSON :
+ u_profile->flags | USER_OPT_NOONLYPERSON;
+ } else if (!strcasecmp(name, "wait_marked")) {
+ ast_set2_flag(u_profile, ast_true(value), USER_OPT_WAITMARKED);
+ } else if (!strcasecmp(name, "end_marked")) {
+ ast_set2_flag(u_profile, ast_true(value), USER_OPT_ENDMARKED);
+ } else if (!strcasecmp(name, "talk_detection_events")) {
+ ast_set2_flag(u_profile, ast_true(value), USER_OPT_TALKER_DETECT);
+ } else if (!strcasecmp(name, "dtmf_passthrough")) {
+ ast_set2_flag(u_profile, ast_true(value), USER_OPT_DTMF_PASS);
+ } else if (!strcasecmp(name, "announce_join_leave")) {
+ ast_set2_flag(u_profile, ast_true(value), USER_OPT_ANNOUNCE_JOIN_LEAVE);
+ } else if (!strcasecmp(name, "pin")) {
+ ast_copy_string(u_profile->pin, value, sizeof(u_profile->pin));
+ } else if (!strcasecmp(name, "music_on_hold_class")) {
+ ast_copy_string(u_profile->moh_class, value, sizeof(u_profile->moh_class));
+ } else if (!strcasecmp(name, "denoise")) {
+ ast_set2_flag(u_profile, ast_true(value), USER_OPT_DENOISE);
+ } else if (!strcasecmp(name, "dsp_talking_threshold")) {
+ if (sscanf(value, "%30u", &u_profile->talking_threshold) != 1) {
+ return -1;
+ }
+ } else if (!strcasecmp(name, "dsp_silence_threshold")) {
+ if (sscanf(value, "%30u", &u_profile->silence_threshold) != 1) {
+ return -1;
+ }
+ } else if (!strcasecmp(name, "dsp_drop_silence")) {
+ ast_set2_flag(u_profile, ast_true(value), USER_OPT_DROP_SILENCE);
+ } else if (!strcasecmp(name, "template")) {
+ if (!(conf_find_user_profile(NULL, value, u_profile))) {
+ return -1;
+ }
+ } else if (!strcasecmp(name, "jitterbuffer")) {
+ ast_set2_flag(u_profile, ast_true(value), USER_OPT_JITTERBUFFER);
+ } else {
+ return -1;
+ }
+ return 0;
+}
+
+static int set_sound(const char *sound_name, const char *sound_file, struct bridge_profile_sounds *sounds)
+{
+ if (ast_strlen_zero(sound_file)) {
+ return -1;
+ }
+
+ if (!strcasecmp(sound_name, "sound_only_person")) {
+ ast_string_field_set(sounds, onlyperson, sound_file);
+ } else if (!strcasecmp(sound_name, "sound_has_joined")) {
+ ast_string_field_set(sounds, hasjoin, sound_file);
+ } else if (!strcasecmp(sound_name, "sound_has_left")) {
+ ast_string_field_set(sounds, hasleft, sound_file);
+ } else if (!strcasecmp(sound_name, "sound_kicked")) {
+ ast_string_field_set(sounds, kicked, sound_file);
+ } else if (!strcasecmp(sound_name, "sound_muted")) {
+ ast_string_field_set(sounds, muted, sound_file);
+ } else if (!strcasecmp(sound_name, "sound_unmuted")) {
+ ast_string_field_set(sounds, unmuted, sound_file);
+ } else if (!strcasecmp(sound_name, "sound_there_are")) {
+ ast_string_field_set(sounds, thereare, sound_file);
+ } else if (!strcasecmp(sound_name, "sound_other_in_party")) {
+ ast_string_field_set(sounds, otherinparty, sound_file);
+ } else if (!strcasecmp(sound_name, "sound_place_into_conference")) {
+ ast_string_field_set(sounds, placeintoconf, sound_file);
+ } else if (!strcasecmp(sound_name, "sound_wait_for_leader")) {
+ ast_string_field_set(sounds, waitforleader, sound_file);
+ } else if (!strcasecmp(sound_name, "sound_get_pin")) {
+ ast_string_field_set(sounds, getpin, sound_file);
+ } else if (!strcasecmp(sound_name, "sound_invalid_pin")) {
+ ast_string_field_set(sounds, invalidpin, sound_file);
+ } else if (!strcasecmp(sound_name, "sound_locked")) {
+ ast_string_field_set(sounds, locked, sound_file);
+ } else if (!strcasecmp(sound_name, "sound_unlocked_now")) {
+ ast_string_field_set(sounds, unlockednow, sound_file);
+ } else if (!strcasecmp(sound_name, "sound_locked_now")) {
+ ast_string_field_set(sounds, lockednow, sound_file);
+ } else if (!strcasecmp(sound_name, "sound_error_menu")) {
+ ast_string_field_set(sounds, errormenu, sound_file);
+ } else if (!strcasecmp(sound_name, "sound_join")) {
+ ast_string_field_set(sounds, join, sound_file);
+ } else if (!strcasecmp(sound_name, "sound_leave")) {
+ ast_string_field_set(sounds, leave, sound_file);
+ } else {
+ return -1;
+ }
+
+ return 0;
+}
+static int set_bridge_option(const char *name, const char *value, struct bridge_profile *b_profile)
+{
+ if (!strcasecmp(name, "internal_sample_rate")) {
+ if (!strcasecmp(value, "auto")) {
+ b_profile->internal_sample_rate = 0;
+ } else if (sscanf(value, "%30u", &b_profile->internal_sample_rate) != 1) {
+ return -1;
+ }
+ } else if (!strcasecmp(name, "mixing_interval")) {
+ if (sscanf(value, "%30u", &b_profile->mix_interval) != 1) {
+ return -1;
+ }
+ switch (b_profile->mix_interval) {
+ case 10:
+ case 20:
+ case 40:
+ case 80:
+ break;
+ default:
+ ast_log(LOG_WARNING, "invalid mixing interval %u\n", b_profile->mix_interval);
+ b_profile->mix_interval = 0;
+ return -1;
+ }
+ } else if (!strcasecmp(name, "record_conference")) {
+ ast_set2_flag(b_profile, ast_true(value), BRIDGE_OPT_RECORD_CONFERENCE);
+ } else if (!strcasecmp(name, "max_members")) {
+ if (sscanf(value, "%30u", &b_profile->max_members) != 1) {
+ return -1;
+ }
+ } else if (!strcasecmp(name, "record_file")) {
+ ast_copy_string(b_profile->rec_file, value, sizeof(b_profile->rec_file));
+ } else if (strlen(name) >= 5 && !strncasecmp(name, "sound", 5)) {
+ if (set_sound(name, value, b_profile->sounds)) {
+ return -1;
+ }
+ } else if (!strcasecmp(name, "template")) { /* Only documented for use in CONFBRIDGE dialplan function */
+ struct bridge_profile *tmp = b_profile;
+ struct bridge_profile_sounds *sounds = bridge_profile_sounds_alloc();
+ struct bridge_profile_sounds *oldsounds = b_profile->sounds;
+ if (!sounds) {
+ return -1;
+ }
+ if (!(conf_find_bridge_profile(NULL, value, tmp))) {
+ ao2_ref(sounds, -1);
+ return -1;
+ }
+ /* Using a bridge profile as a template is a little complicated due to the sounds. Since the sounds
+ * structure of a dynamic profile will need to be altered, a completely new sounds structure must be
+ * create instead of simply holding a reference to the one built by the config file. */
+ ast_string_field_set(sounds, onlyperson, tmp->sounds->onlyperson);
+ ast_string_field_set(sounds, hasjoin, tmp->sounds->hasjoin);
+ ast_string_field_set(sounds, hasleft, tmp->sounds->hasleft);
+ ast_string_field_set(sounds, kicked, tmp->sounds->kicked);
+ ast_string_field_set(sounds, muted, tmp->sounds->muted);
+ ast_string_field_set(sounds, unmuted, tmp->sounds->unmuted);
+ ast_string_field_set(sounds, thereare, tmp->sounds->thereare);
+ ast_string_field_set(sounds, otherinparty, tmp->sounds->otherinparty);
+ ast_string_field_set(sounds, placeintoconf, tmp->sounds->placeintoconf);
+ ast_string_field_set(sounds, waitforleader, tmp->sounds->waitforleader);
+ ast_string_field_set(sounds, getpin, tmp->sounds->getpin);
+ ast_string_field_set(sounds, invalidpin, tmp->sounds->invalidpin);
+ ast_string_field_set(sounds, locked, tmp->sounds->locked);
+ ast_string_field_set(sounds, unlockednow, tmp->sounds->unlockednow);
+ ast_string_field_set(sounds, lockednow, tmp->sounds->lockednow);
+ ast_string_field_set(sounds, errormenu, tmp->sounds->errormenu);
+
+ ao2_ref(tmp->sounds, -1); /* sounds struct copied over to it from the template by reference only. */
+ ao2_ref(oldsounds,-1); /* original sounds struct we don't need anymore */
+ tmp->sounds = sounds; /* the new sounds struct that is a deep copy of the one from the template. */
+ } else {
+ return -1;
+ }
+
+ return 0;
+}
+
+/*! CONFBRIDGE dialplan function functions and channel datastore. */
+struct func_confbridge_data {
+ struct bridge_profile b_profile;
+ struct user_profile u_profile;
+ unsigned int b_usable:1; /*!< Tells if bridge profile is usable or not */
+ unsigned int u_usable:1; /*!< Tells if user profile is usable or not */
+};
+static void func_confbridge_destroy_cb(void *data)
+{
+ struct func_confbridge_data *b_data = data;
+ conf_bridge_profile_destroy(&b_data->b_profile);
+ ast_free(b_data);
+};
+static const struct ast_datastore_info confbridge_datastore = {
+ .type = "confbridge",
+ .destroy = func_confbridge_destroy_cb
+};
+int func_confbridge_helper(struct ast_channel *chan, const char *cmd, char *data, const char *value)
+{
+ struct ast_datastore *datastore = NULL;
+ struct func_confbridge_data *b_data = NULL;
+ char *parse = NULL;
+ int new = 0;
+ AST_DECLARE_APP_ARGS(args,
+ AST_APP_ARG(type);
+ AST_APP_ARG(option);
+ );
+
+ /* parse all the required arguments and make sure they exist. */
+ if (ast_strlen_zero(data) || ast_strlen_zero(value)) {
+ return -1;
+ }
+ parse = ast_strdupa(data);
+ AST_STANDARD_APP_ARGS(args, parse);
+ if (ast_strlen_zero(args.type) || ast_strlen_zero(args.option)) {
+ return -1;
+ }
+
+ ast_channel_lock(chan);
+ if (!(datastore = ast_channel_datastore_find(chan, &confbridge_datastore, NULL))) {
+ ast_channel_unlock(chan);
+
+ if (!(datastore = ast_datastore_alloc(&confbridge_datastore, NULL))) {
+ return 0;
+ }
+ if (!(b_data = ast_calloc(1, sizeof(*b_data)))) {
+ ast_datastore_free(datastore);
+ return 0;
+ }
+ if (!(b_data->b_profile.sounds = bridge_profile_sounds_alloc())) {
+ ast_datastore_free(datastore);
+ ast_free(b_data);
+ return 0;
+ }
+ datastore->data = b_data;
+ new = 1;
+ } else {
+ ast_channel_unlock(chan);
+ b_data = datastore->data;
+ }
+
+ /* SET(CONFBRIDGE(type,option)=value) */
+ if (!strcasecmp(args.type, "bridge") && !set_bridge_option(args.option, value, &b_data->b_profile)) {
+ b_data->b_usable = 1;
+ } else if (!strcasecmp(args.type, "user") && !set_user_option(args.option, value, &b_data->u_profile)) {
+ b_data->u_usable = 1;
+ } else {
+ ast_log(LOG_WARNING, "Profile type \"%s\" can not be set in CONFBRIDGE function with option \"%s\" and value \"%s\"\n",
+ args.type, args.option, value);
+ goto cleanup_error;
+ }
+ if (new) {
+ ast_channel_lock(chan);
+ ast_channel_datastore_add(chan, datastore);
+ ast_channel_unlock(chan);
+ }
+ return 0;
+
+cleanup_error:
+ ast_log(LOG_ERROR, "Invalid argument provided to the %s function\n", cmd);
+ if (new) {
+ ast_datastore_free(datastore);
+ }
+ return -1;
+}
+
+/*!
+ * \brief Parse the bridge profile options
+ */
+static int parse_bridge(const char *cat, struct ast_config *cfg)
+{
+ struct ast_variable *var;
+ struct bridge_profile tmp;
+ struct bridge_profile *b_profile;
+
+ ast_copy_string(tmp.name, cat, sizeof(tmp.name));
+ if ((b_profile = ao2_find(bridge_profiles, &tmp, OBJ_POINTER))) {
+ b_profile->delme = 0;
+ } else if ((b_profile = ao2_alloc(sizeof(*b_profile), NULL))) {
+ ast_copy_string(b_profile->name, cat, sizeof(b_profile->name));
+ ao2_link(bridge_profiles, b_profile);
+ } else {
+ return -1;
+ }
+
+ ao2_lock(b_profile);
+ /* set defaults */
+ b_profile->internal_sample_rate = 0;
+ b_profile->flags = 0;
+ b_profile->max_members = 0;
+ b_profile->mix_interval = 0;
+ memset(b_profile->rec_file, 0, sizeof(b_profile->rec_file));
+ if (b_profile->sounds) {
+ ao2_ref(b_profile->sounds, -1); /* sounds is read only. Once it has been created
+ * it can never be altered. This prevents having to
+ * do any locking after it is built from the config. */
+ b_profile->sounds = NULL;
+ }
+
+ if (!(b_profile->sounds = bridge_profile_sounds_alloc())) {
+ ao2_unlock(b_profile);
+ ao2_ref(b_profile, -1);
+ ao2_unlink(bridge_profiles, b_profile);
+ return -1;
+ }
+
+ for (var = ast_variable_browse(cfg, cat); var; var = var->next) {
+ if (!strcasecmp(var->name, "type")) {
+ continue;
+ } else if (set_bridge_option(var->name, var->value, b_profile)) {
+ ast_log(LOG_WARNING, "Invalid: '%s' at line %d of %s is not supported.\n",
+ var->name, var->lineno, CONFBRIDGE_CONFIG);
+ }
+ }
+ ao2_unlock(b_profile);
+
+ ao2_ref(b_profile, -1);
+ return 0;
+}
+
+static int parse_user(const char *cat, struct ast_config *cfg)
+{
+ struct ast_variable *var;
+ struct user_profile tmp;
+ struct user_profile *u_profile;
+
+ ast_copy_string(tmp.name, cat, sizeof(tmp.name));
+ if ((u_profile = ao2_find(user_profiles, &tmp, OBJ_POINTER))) {
+ u_profile->delme = 0;
+ } else if ((u_profile = ao2_alloc(sizeof(*u_profile), NULL))) {
+ ast_copy_string(u_profile->name, cat, sizeof(u_profile->name));
+ ao2_link(user_profiles, u_profile);
+ } else {
+ return -1;
+ }
+
+ ao2_lock(u_profile);
+ /* set defaults */
+ u_profile->flags = 0;
+ u_profile->announce_user_count_all_after = 0;
+ u_profile->silence_threshold = DEFAULT_SILENCE_THRESHOLD;
+ u_profile->talking_threshold = DEFAULT_TALKING_THRESHOLD;
+ memset(u_profile->pin, 0, sizeof(u_profile->pin));
+ memset(u_profile->moh_class, 0, sizeof(u_profile->moh_class));
+ for (var = ast_variable_browse(cfg, cat); var; var = var->next) {
+ if (!strcasecmp(var->name, "type")) {
+ continue;
+ } else if (set_user_option(var->name, var->value, u_profile)) {
+ ast_log(LOG_WARNING, "Invalid option '%s' at line %d of %s is not supported.\n",
+ var->name, var->lineno, CONFBRIDGE_CONFIG);
+ }
+ }
+ ao2_unlock(u_profile);
+
+ ao2_ref(u_profile, -1);
+ return 0;
+}
+
+static int add_action_to_menu_entry(struct conf_menu_entry *menu_entry, enum conf_menu_action_id id, char *databuf)
+{
+ struct conf_menu_action *menu_action = ast_calloc(1, sizeof(*menu_action));
+
+ if (!menu_action) {
+ return -1;
+ }
+ menu_action->id = id;
+
+ switch (id) {
+ case MENU_ACTION_NOOP:
+ case MENU_ACTION_TOGGLE_MUTE:
+ case MENU_ACTION_INCREASE_LISTENING:
+ case MENU_ACTION_DECREASE_LISTENING:
+ case MENU_ACTION_INCREASE_TALKING:
+ case MENU_ACTION_DECREASE_TALKING:
+ case MENU_ACTION_RESET_LISTENING:
+ case MENU_ACTION_RESET_TALKING:
+ case MENU_ACTION_ADMIN_TOGGLE_LOCK:
+ case MENU_ACTION_ADMIN_KICK_LAST:
+ case MENU_ACTION_LEAVE:
+ break;
+ case MENU_ACTION_PLAYBACK:
+ case MENU_ACTION_PLAYBACK_AND_CONTINUE:
+ if (!(ast_strlen_zero(databuf))) {
+ ast_copy_string(menu_action->data.playback_file, databuf, sizeof(menu_action->data.playback_file));
+ } else {
+ ast_free(menu_action);
+ return -1;
+ }
+ break;
+ case MENU_ACTION_DIALPLAN_EXEC:
+ if (!(ast_strlen_zero(databuf))) {
+ AST_DECLARE_APP_ARGS(args,
+ AST_APP_ARG(context);
+ AST_APP_ARG(exten);
+ AST_APP_ARG(priority);
+ );
+ AST_STANDARD_APP_ARGS(args, databuf);
+ if (!ast_strlen_zero(args.context)) {
+ ast_copy_string(menu_action->data.dialplan_args.context,
+ args.context,
+ sizeof(menu_action->data.dialplan_args.context));
+ }
+ if (!ast_strlen_zero(args.exten)) {
+ ast_copy_string(menu_action->data.dialplan_args.exten,
+ args.exten,
+ sizeof(menu_action->data.dialplan_args.exten));
+ }
+ menu_action->data.dialplan_args.priority = 1; /* 1 by default */
+ if (!ast_strlen_zero(args.priority) &&
+ (sscanf(args.priority, "%30u", &menu_action->data.dialplan_args.priority) != 1)) {
+ /* invalid priority */
+ ast_free(menu_action);
+ return -1;
+ }
+ } else {
+ ast_free(menu_action);
+ return -1;
+ }
+ };
+
+ AST_LIST_INSERT_TAIL(&menu_entry->actions, menu_action, action);
+
+ return 0;
+}
+
+static int add_menu_entry(struct conf_menu *menu, const char *dtmf, const char *action_names)
+{
+ struct conf_menu_entry *menu_entry = NULL;
+ int res = 0;
+ char *tmp_action_names = ast_strdupa(action_names);
+ char *action = NULL;
+ char *action_args;
+ char *tmp;
+ char buf[PATH_MAX];
+ char *delimiter = ",";
+
+ if (!(menu_entry = ast_calloc(1, sizeof(*menu_entry)))) {
+ return -1;
+ }
+
+ for (;;) {
+ char *comma;
+ char *startbrace;
+ char *endbrace;
+ unsigned int action_len;
+
+ if (ast_strlen_zero(tmp_action_names)) {
+ break;
+ }
+ startbrace = strchr(tmp_action_names, '(');
+ endbrace = strchr(tmp_action_names, ')');
+ comma = strchr(tmp_action_names, ',');
+
+ /* If the next action has brackets with comma delimited arguments in it,
+ * make the delimeter ')' instead of a comma to preserve the argments */
+ if (startbrace && endbrace && comma && (comma > startbrace && comma < endbrace)) {
+ delimiter = ")";
+ } else {
+ delimiter = ",";
+ }
+
+ if (!(action = strsep(&tmp_action_names, delimiter))) {
+ break;
+ }
+
+ action = ast_strip(action);
+ if (ast_strlen_zero(action)) {
+ continue;
+ }
+
+ action_len = strlen(action);
+ ast_copy_string(menu_entry->dtmf, dtmf, sizeof(menu_entry->dtmf));
+ if (!strcasecmp(action, "toggle_mute")) {
+ res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_TOGGLE_MUTE, NULL);
+ } else if (!strcasecmp(action, "no_op")) {
+ res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_NOOP, NULL);
+ } else if (!strcasecmp(action, "increase_listening_volume")) {
+ res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_INCREASE_LISTENING, NULL);
+ } else if (!strcasecmp(action, "decrease_listening_volume")) {
+ res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_DECREASE_LISTENING, NULL);
+ } else if (!strcasecmp(action, "increase_talking_volume")) {
+ res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_INCREASE_TALKING, NULL);
+ } else if (!strcasecmp(action, "reset_listening_volume")) {
+ res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_RESET_LISTENING, NULL);
+ } else if (!strcasecmp(action, "reset_talking_volume")) {
+ res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_RESET_TALKING, NULL);
+ } else if (!strcasecmp(action, "decrease_talking_volume")) {
+ res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_DECREASE_TALKING, NULL);
+ } else if (!strcasecmp(action, "admin_toggle_conference_lock")) {
+ res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_ADMIN_TOGGLE_LOCK, NULL);
+ } else if (!strcasecmp(action, "admin_kick_last")) {
+ res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_ADMIN_KICK_LAST, NULL);
+ } else if (!strcasecmp(action, "leave_conference")) {
+ res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_LEAVE, NULL);
+ } else if (!strncasecmp(action, "dialplan_exec(", 14)) {
+ ast_copy_string(buf, action, sizeof(buf));
+ action_args = buf;
+ if ((action_args = strchr(action, '('))) {
+ action_args++;
+ }
+ /* it is possible that this argument may or may not
+ * have a closing brace at this point, it all depends on if
+ * comma delimited arguments were provided */
+ if ((tmp = strchr(action, ')'))) {
+ *tmp = '\0';
+ }
+ res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_DIALPLAN_EXEC, action_args);
+ } else if (action_len >= 21 && !strncasecmp(action, "playback_and_continue(", 22)) {
+ ast_copy_string(buf, action, sizeof(buf));
+ action_args = buf;
+ if ((action_args = strchr(action, '(')) && (tmp = strrchr(action_args, ')'))) {
+ *tmp = '\0';
+ action_args++;
+ }
+ res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_PLAYBACK_AND_CONTINUE, action_args);
+ } else if (action_len >= 8 && !strncasecmp(action, "playback(", 9)) {
+ ast_copy_string(buf, action, sizeof(buf));
+ action_args = buf;
+ if ((action_args = strchr(action, '(')) && (tmp = strrchr(action_args, ')'))) {
+ *tmp = '\0';
+ action_args++;
+ }
+ res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_PLAYBACK, action_args);
+ }
+ }
+
+ /* if adding any of the actions failed, bail */
+ if (res) {
+ struct conf_menu_action *action;
+ while ((action = AST_LIST_REMOVE_HEAD(&menu_entry->actions, action))) {
+ ast_free(action);
+ }
+ ast_free(menu_entry);
+ return -1;
+ }
+
+ AST_LIST_INSERT_TAIL(&menu->entries, menu_entry, entry);
+
+ return 0;
+}
+static int parse_menu(const char *cat, struct ast_config *cfg)
+{
+ struct ast_variable *var;
+ struct conf_menu tmp;
+ struct conf_menu *menu;
+
+ ast_copy_string(tmp.name, cat, sizeof(tmp.name));
+ if ((menu = ao2_find(menus, &tmp, OBJ_POINTER))) {
+ menu->delme = 0;
+ } else if ((menu = ao2_alloc(sizeof(*menu), menu_destructor))) {
+ ast_copy_string(menu->name, cat, sizeof(menu->name));
+ ao2_link(menus, menu);
+ } else {
+ return -1;
+ }
+
+ ao2_lock(menu);
+ /* this isn't freeing the menu, just destroying the menu list so it can be rebuilt.*/
+ menu_destructor(menu);
+ for (var = ast_variable_browse(cfg, cat); var; var = var->next) {
+ if (!strcasecmp(var->name, "type")) {
+ continue;
+ } else if (add_menu_entry(menu, var->name, var->value)) {
+ ast_log(LOG_WARNING, "Unknown option '%s' at line %d of %s is not supported.\n",
+ var->name, var->lineno, CONFBRIDGE_CONFIG);
+ }
+ }
+ ao2_unlock(menu);
+
+ ao2_ref(menu, -1);
+ return 0;
+}
+
+static char *complete_user_profile_name(const char *line, const char *word, int pos, int state)
+{
+ int which = 0;
+ char *res = NULL;
+ int wordlen = strlen(word);
+ struct ao2_iterator i;
+ struct user_profile *u_profile = NULL;
+
+ i = ao2_iterator_init(user_profiles, 0);
+ while ((u_profile = ao2_iterator_next(&i))) {
+ if (!strncasecmp(u_profile->name, word, wordlen) && ++which > state) {
+ res = ast_strdup(u_profile->name);
+ ao2_ref(u_profile, -1);
+ break;
+ }
+ ao2_ref(u_profile, -1);
+ }
+ ao2_iterator_destroy(&i);
+
+ return res;
+}
+
+static char *handle_cli_confbridge_show_user_profiles(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+{
+ struct ao2_iterator it;
+ struct user_profile *u_profile;
+
+ switch (cmd) {
+ case CLI_INIT:
+ e->command = "confbridge show profile users";
+ e->usage =
+ "Usage confbridge show profile users\n";
+ return NULL;
+ case CLI_GENERATE:
+ return NULL;
+ }
+
+ ast_cli(a->fd,"--------- User Profiles -----------\n");
+ ao2_lock(user_profiles);
+ it = ao2_iterator_init(user_profiles, 0);
+ while ((u_profile = ao2_iterator_next(&it))) {
+ ast_cli(a->fd,"%s\n", u_profile->name);
+ ao2_ref(u_profile, -1);
+ }
+ ao2_iterator_destroy(&it);
+ ao2_unlock(user_profiles);
+
+ return CLI_SUCCESS;
+}
+static char *handle_cli_confbridge_show_user_profile(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+{
+ struct user_profile u_profile;
+
+ switch (cmd) {
+ case CLI_INIT:
+ e->command = "confbridge show profile user";
+ e->usage =
+ "Usage confbridge show profile user [<profile name>]\n";
+ return NULL;
+ case CLI_GENERATE:
+ if (a->pos == 4) {
+ return complete_user_profile_name(a->line, a->word, a->pos, a->n);
+ }
+ return NULL;
+ }
+
+ if (a->argc != 5) {
+ return CLI_SHOWUSAGE;
+ }
+
+ if (!(conf_find_user_profile(NULL, a->argv[4], &u_profile))) {
+ ast_cli(a->fd, "No conference user profile named '%s' found!\n", a->argv[4]);
+ return CLI_SUCCESS;
+ }
+
+ ast_cli(a->fd,"--------------------------------------------\n");
+ ast_cli(a->fd,"Name: %s\n",
+ u_profile.name);
+ ast_cli(a->fd,"Admin: %s\n",
+ u_profile.flags & USER_OPT_ADMIN ?
+ "true" : "false");
+ ast_cli(a->fd,"Marked User: %s\n",
+ u_profile.flags & USER_OPT_MARKEDUSER ?
+ "true" : "false");
+ ast_cli(a->fd,"Start Muted: %s\n",
+ u_profile.flags & USER_OPT_STARTMUTED?
+ "true" : "false");
+ ast_cli(a->fd,"MOH When Empty: %s\n",
+ u_profile.flags & USER_OPT_MUSICONHOLD ?
+ "enabled" : "disabled");
+ ast_cli(a->fd,"MOH Class: %s\n",
+ ast_strlen_zero(u_profile.moh_class) ?
+ "default" : u_profile.moh_class);
+ ast_cli(a->fd,"Quiet: %s\n",
+ u_profile.flags & USER_OPT_QUIET ?
+ "enabled" : "disabled");
+ ast_cli(a->fd,"Wait Marked: %s\n",
+ u_profile.flags & USER_OPT_WAITMARKED ?
+ "enabled" : "disabled");
+ ast_cli(a->fd,"END Marked: %s\n",
+ u_profile.flags & USER_OPT_ENDMARKED ?
+ "enabled" : "disabled");
+ ast_cli(a->fd,"Drop_silence: %s\n",
+ u_profile.flags & USER_OPT_DROP_SILENCE ?
+ "enabled" : "disabled");
+ ast_cli(a->fd,"Silence Threshold: %dms\n",
+ u_profile.silence_threshold);
+ ast_cli(a->fd,"Talking Threshold: %dms\n",
+ u_profile.talking_threshold);
+ ast_cli(a->fd,"Denoise: %s\n",
+ u_profile.flags & USER_OPT_DENOISE ?
+ "enabled" : "disabled");
+ ast_cli(a->fd,"Jitterbuffer: %s\n",
+ u_profile.flags & USER_OPT_JITTERBUFFER ?
+ "enabled" : "disabled");
+ ast_cli(a->fd,"Talk Detect Events: %s\n",
+ u_profile.flags & USER_OPT_TALKER_DETECT ?
+ "enabled" : "disabled");
+ ast_cli(a->fd,"DTMF Pass Through: %s\n",
+ u_profile.flags & USER_OPT_DTMF_PASS ?
+ "enabled" : "disabled");
+ ast_cli(a->fd,"PIN: %s\n",
+ ast_strlen_zero(u_profile.pin) ?
+ "None" : u_profile.pin);
+ ast_cli(a->fd,"Announce User Count: %s\n",
+ u_profile.flags & USER_OPT_ANNOUNCEUSERCOUNT ?
+ "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,"Announce User Count all: %s\n",
+ u_profile.flags & USER_OPT_ANNOUNCEUSERCOUNTALL ?
+ "enabled" : "disabled");
+ ast_cli(a->fd,"\n");
+
+ return CLI_SUCCESS;
+}
+
+static char *complete_bridge_profile_name(const char *line, const char *word, int pos, int state)
+{
+ int which = 0;
+ char *res = NULL;
+ int wordlen = strlen(word);
+ struct ao2_iterator i;
+ struct bridge_profile *b_profile = NULL;
+
+ i = ao2_iterator_init(bridge_profiles, 0);
+ while ((b_profile = ao2_iterator_next(&i))) {
+ if (!strncasecmp(b_profile->name, word, wordlen) && ++which > state) {
+ res = ast_strdup(b_profile->name);
+ ao2_ref(b_profile, -1);
+ break;
+ }
+ ao2_ref(b_profile, -1);
+ }
+ ao2_iterator_destroy(&i);
+
+ return res;
+}
+
+static char *handle_cli_confbridge_show_bridge_profiles(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+{
+ struct ao2_iterator it;
+ struct bridge_profile *b_profile;
+
+ switch (cmd) {
+ case CLI_INIT:
+ e->command = "confbridge show profile bridges";
+ e->usage =
+ "Usage confbridge show profile bridges\n";
+ return NULL;
+ case CLI_GENERATE:
+ return NULL;
+ }
+
+ ast_cli(a->fd,"--------- Bridge Profiles -----------\n");
+ ao2_lock(bridge_profiles);
+ it = ao2_iterator_init(bridge_profiles, 0);
+ while ((b_profile = ao2_iterator_next(&it))) {
+ ast_cli(a->fd,"%s\n", b_profile->name);
+ ao2_ref(b_profile, -1);
+ }
+ ao2_iterator_destroy(&it);
+ ao2_unlock(bridge_profiles);
+
+ return CLI_SUCCESS;
+}
+
+static char *handle_cli_confbridge_show_bridge_profile(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+{
+ struct bridge_profile b_profile;
+ char tmp[64];
+
+ switch (cmd) {
+ case CLI_INIT:
+ e->command = "confbridge show profile bridge";
+ e->usage =
+ "Usage confbridge show profile bridge <profile name>\n";
+ return NULL;
+ case CLI_GENERATE:
+ if (a->pos == 4) {
+ return complete_bridge_profile_name(a->line, a->word, a->pos, a->n);
+ }
+ return NULL;
+ }
+
+ if (a->argc != 5) {
+ return CLI_SHOWUSAGE;
+ }
+
+ if (!(conf_find_bridge_profile(NULL, a->argv[4], &b_profile))) {
+ ast_cli(a->fd, "No conference bridge profile named '%s' found!\n", a->argv[4]);
+ return CLI_SUCCESS;
+ }
+
+ ast_cli(a->fd,"--------------------------------------------\n");
+ ast_cli(a->fd,"Name: %s\n", b_profile.name);
+
+ if (b_profile.internal_sample_rate) {
+ snprintf(tmp, sizeof(tmp), "%d", b_profile.internal_sample_rate);
+ } else {
+ ast_copy_string(tmp, "auto", sizeof(tmp));
+ }
+ ast_cli(a->fd,"Internal Sample Rate: %s\n", tmp);
+
+ if (b_profile.mix_interval) {
+ ast_cli(a->fd,"Mixing Interval: %d\n", b_profile.mix_interval);
+ } else {
+ ast_cli(a->fd,"Mixing Interval: Default 20ms\n");
+ }
+
+ ast_cli(a->fd,"Record Conference: %s\n",
+ b_profile.flags & BRIDGE_OPT_RECORD_CONFERENCE ?
+ "yes" : "no");
+
+ ast_cli(a->fd,"Record File: %s\n",
+ ast_strlen_zero(b_profile.rec_file) ? "Auto Generated" :
+ b_profile.rec_file);
+
+ if (b_profile.max_members) {
+ ast_cli(a->fd,"Max Members: %d\n", b_profile.max_members);
+ } else {
+ ast_cli(a->fd,"Max Members: No Limit\n");
+ }
+
+ ast_cli(a->fd,"sound_join: %s\n", conf_get_sound(CONF_SOUND_JOIN, b_profile.sounds));
+ ast_cli(a->fd,"sound_leave: %s\n", conf_get_sound(CONF_SOUND_LEAVE, b_profile.sounds));
+ ast_cli(a->fd,"sound_only_person: %s\n", conf_get_sound(CONF_SOUND_ONLY_PERSON, b_profile.sounds));
+ ast_cli(a->fd,"sound_has_joined: %s\n", conf_get_sound(CONF_SOUND_HAS_JOINED, b_profile.sounds));
+ ast_cli(a->fd,"sound_has_left: %s\n", conf_get_sound(CONF_SOUND_HAS_LEFT, b_profile.sounds));
+ ast_cli(a->fd,"sound_kicked: %s\n", conf_get_sound(CONF_SOUND_KICKED, b_profile.sounds));
+ ast_cli(a->fd,"sound_muted: %s\n", conf_get_sound(CONF_SOUND_MUTED, b_profile.sounds));
+ ast_cli(a->fd,"sound_unmuted: %s\n", conf_get_sound(CONF_SOUND_UNMUTED, b_profile.sounds));
+ ast_cli(a->fd,"sound_there_are: %s\n", conf_get_sound(CONF_SOUND_THERE_ARE, b_profile.sounds));
+ ast_cli(a->fd,"sound_other_in_party: %s\n", conf_get_sound(CONF_SOUND_OTHER_IN_PARTY, b_profile.sounds));
+ ast_cli(a->fd,"sound_place_into_conference: %s\n", conf_get_sound(CONF_SOUND_PLACE_IN_CONF, b_profile.sounds));
+ ast_cli(a->fd,"sound_wait_for_leader: %s\n", conf_get_sound(CONF_SOUND_WAIT_FOR_LEADER, b_profile.sounds));
+ ast_cli(a->fd,"sound_get_pin: %s\n", conf_get_sound(CONF_SOUND_GET_PIN, b_profile.sounds));
+ ast_cli(a->fd,"sound_invalid_pin: %s\n", conf_get_sound(CONF_SOUND_INVALID_PIN, b_profile.sounds));
+ ast_cli(a->fd,"sound_locked: %s\n", conf_get_sound(CONF_SOUND_LOCKED, b_profile.sounds));
+ ast_cli(a->fd,"sound_unlocked_now: %s\n", conf_get_sound(CONF_SOUND_UNLOCKED_NOW, b_profile.sounds));
+ ast_cli(a->fd,"sound_lockednow: %s\n", conf_get_sound(CONF_SOUND_LOCKED_NOW, b_profile.sounds));
+ ast_cli(a->fd,"sound_error_menu: %s\n", conf_get_sound(CONF_SOUND_ERROR_MENU, b_profile.sounds));
+ ast_cli(a->fd,"\n");
+
+ conf_bridge_profile_destroy(&b_profile);
+ return CLI_SUCCESS;
+}
+
+static char *complete_menu_name(const char *line, const char *word, int pos, int state)
+{
+ int which = 0;
+ char *res = NULL;
+ int wordlen = strlen(word);
+ struct ao2_iterator i;
+ struct conf_menu *menu = NULL;
+
+ i = ao2_iterator_init(menus, 0);
+ while ((menu = ao2_iterator_next(&i))) {
+ if (!strncasecmp(menu->name, word, wordlen) && ++which > state) {
+ res = ast_strdup(menu->name);
+ ao2_ref(menu, -1);
+ break;
+ }
+ ao2_ref(menu, -1);
+ }
+ ao2_iterator_destroy(&i);
+
+ return res;
+}
+
+static char *handle_cli_confbridge_show_menus(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+{
+ struct ao2_iterator it;
+ struct conf_menu *menu;
+
+ switch (cmd) {
+ case CLI_INIT:
+ e->command = "confbridge show menus";
+ e->usage =
+ "Usage confbridge show profile menus\n";
+ return NULL;
+ case CLI_GENERATE:
+ return NULL;
+ }
+
+ ast_cli(a->fd,"--------- Menus -----------\n");
+ ao2_lock(menus);
+ it = ao2_iterator_init(menus, 0);
+ while ((menu = ao2_iterator_next(&it))) {
+ ast_cli(a->fd,"%s\n", menu->name);
+ ao2_ref(menu, -1);
+ }
+ ao2_iterator_destroy(&it);
+ ao2_unlock(menus);
+
+ return CLI_SUCCESS;
+}
+
+static char *handle_cli_confbridge_show_menu(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+{
+ struct conf_menu tmp;
+ struct conf_menu *menu;
+ struct conf_menu_entry *menu_entry = NULL;
+ struct conf_menu_action *menu_action = NULL;
+
+ switch (cmd) {
+ case CLI_INIT:
+ e->command = "confbridge show menu";
+ e->usage =
+ "Usage confbridge show menu [<menu name>]\n";
+ return NULL;
+ case CLI_GENERATE:
+ if (a->pos == 3) {
+ return complete_menu_name(a->line, a->word, a->pos, a->n);
+ }
+ return NULL;
+ }
+
+ if (a->argc != 4) {
+ return CLI_SHOWUSAGE;
+ }
+
+ ast_copy_string(tmp.name, a->argv[3], sizeof(tmp.name));
+ if (!(menu = ao2_find(menus, &tmp, OBJ_POINTER))) {
+ ast_cli(a->fd, "No conference menu named '%s' found!\n", a->argv[3]);
+ return CLI_SUCCESS;
+ }
+ ao2_lock(menu);
+
+ ast_cli(a->fd,"Name: %s\n", menu->name);
+ AST_LIST_TRAVERSE(&menu->entries, menu_entry, entry) {
+ int action_num = 0;
+ ast_cli(a->fd, "%s=", menu_entry->dtmf);
+ AST_LIST_TRAVERSE(&menu_entry->actions, menu_action, action) {
+ if (action_num) {
+ ast_cli(a->fd, ", ");
+ }
+ switch (menu_action->id) {
+ case MENU_ACTION_TOGGLE_MUTE:
+ ast_cli(a->fd, "toggle_mute");
+ break;
+ case MENU_ACTION_NOOP:
+ ast_cli(a->fd, "no_op");
+ break;
+ case MENU_ACTION_INCREASE_LISTENING:
+ ast_cli(a->fd, "increase_listening_volume");
+ break;
+ case MENU_ACTION_DECREASE_LISTENING:
+ ast_cli(a->fd, "decrease_listening_volume");
+ break;
+ case MENU_ACTION_RESET_LISTENING:
+ ast_cli(a->fd, "reset_listening_volume");
+ break;
+ case MENU_ACTION_RESET_TALKING:
+ ast_cli(a->fd, "reset_talking_volume");
+ break;
+ case MENU_ACTION_INCREASE_TALKING:
+ ast_cli(a->fd, "increase_talking_volume");
+ break;
+ case MENU_ACTION_DECREASE_TALKING:
+ ast_cli(a->fd, "decrease_talking_volume");
+ break;
+ case MENU_ACTION_PLAYBACK:
+ ast_cli(a->fd, "playback(%s)", menu_action->data.playback_file);
+ break;
+ case MENU_ACTION_PLAYBACK_AND_CONTINUE:
+ ast_cli(a->fd, "playback_and_continue(%s)", menu_action->data.playback_file);
+ break;
+ case MENU_ACTION_DIALPLAN_EXEC:
+ ast_cli(a->fd, "dialplan_exec(%s,%s,%d)",
+ menu_action->data.dialplan_args.context,
+ menu_action->data.dialplan_args.exten,
+ menu_action->data.dialplan_args.priority);
+ break;
+ case MENU_ACTION_ADMIN_TOGGLE_LOCK:
+ ast_cli(a->fd, "admin_toggle_conference_lock");
+ break;
+ case MENU_ACTION_ADMIN_KICK_LAST:
+ ast_cli(a->fd, "admin_kick_last");
+ break;
+ case MENU_ACTION_LEAVE:
+ ast_cli(a->fd, "leave_conference");
+ break;
+ }
+ action_num++;
+ }
+ ast_cli(a->fd,"\n");
+ }
+
+
+ ao2_unlock(menu);
+ ao2_ref(menu, -1);
+ return CLI_SUCCESS;
+}
+
+static struct ast_cli_entry cli_confbridge_parser[] = {
+ AST_CLI_DEFINE(handle_cli_confbridge_show_user_profile, "Show a conference user profile."),
+ AST_CLI_DEFINE(handle_cli_confbridge_show_bridge_profile, "Show a conference bridge profile."),
+ AST_CLI_DEFINE(handle_cli_confbridge_show_menu, "Show a conference menu"),
+ AST_CLI_DEFINE(handle_cli_confbridge_show_user_profiles, "Show a list of conference user profiles."),
+ AST_CLI_DEFINE(handle_cli_confbridge_show_bridge_profiles, "Show a list of conference bridge profiles."),
+ AST_CLI_DEFINE(handle_cli_confbridge_show_menus, "Show a list of conference menus"),
+
+};
+
+static int conf_parse_init(void)
+{
+ if (!(user_profiles = ao2_container_alloc(283, user_hash_cb, user_cmp_cb))) {
+ conf_destroy_config();
+ return -1;
+ }
+
+ if (!(bridge_profiles = ao2_container_alloc(283, bridge_hash_cb, bridge_cmp_cb))) {
+ conf_destroy_config();
+ return -1;
+ }
+
+ if (!(menus = ao2_container_alloc(283, menu_hash_cb, menu_cmp_cb))) {
+ conf_destroy_config();
+ return -1;
+ }
+
+ ast_cli_register_multiple(cli_confbridge_parser, ARRAY_LEN(cli_confbridge_parser));
+
+ return 0;
+}
+
+void conf_destroy_config()
+{
+ if (user_profiles) {
+ ao2_ref(user_profiles, -1);
+ user_profiles = NULL;
+ }
+ if (bridge_profiles) {
+ ao2_ref(bridge_profiles, -1);
+ bridge_profiles = NULL;
+ }
+
+ if (menus) {
+ ao2_ref(menus, -1);
+ menus = NULL;
+ }
+ ast_cli_unregister_multiple(cli_confbridge_parser, sizeof(cli_confbridge_parser) / sizeof(struct ast_cli_entry));
+}
+
+static void remove_all_delme(void)
+{
+ ao2_callback(user_profiles, OBJ_NODATA | OBJ_MULTIPLE | OBJ_UNLINK, match_user_delme_cb, NULL);
+ ao2_callback(bridge_profiles, OBJ_NODATA | OBJ_MULTIPLE | OBJ_UNLINK, match_bridge_delme_cb, NULL);
+ ao2_callback(menus, OBJ_NODATA | OBJ_MULTIPLE | OBJ_UNLINK, match_menu_delme_cb, NULL);
+}
+
+static void mark_all_delme(void)
+{
+ ao2_callback(user_profiles, OBJ_NODATA | OBJ_MULTIPLE, user_mark_delme_cb, NULL);
+ ao2_callback(bridge_profiles, OBJ_NODATA | OBJ_MULTIPLE, bridge_mark_delme_cb, NULL);
+ ao2_callback(menus, OBJ_NODATA | OBJ_MULTIPLE, menu_mark_delme_cb, NULL);
+}
+
+int conf_load_config(int reload)
+{
+ struct ast_flags config_flags = { 0, };
+ struct ast_config *cfg = ast_config_load(CONFBRIDGE_CONFIG, config_flags);
+ const char *type = NULL;
+ char *cat = NULL;
+
+ if (!reload) {
+ conf_parse_init();
+ }
+
+ if (!cfg || cfg == CONFIG_STATUS_FILEMISSING || cfg == CONFIG_STATUS_FILEINVALID) {
+ return 0;
+ }
+
+ mark_all_delme();
+
+ while ((cat = ast_category_browse(cfg, cat))) {
+ if (!(type = (ast_variable_retrieve(cfg, cat, "type")))) {
+ if (strcasecmp(cat, "general")) {
+ ast_log(LOG_WARNING, "Section '%s' lacks type\n", cat);
+ }
+ continue;
+ }
+ if (!strcasecmp(type, "bridge")) {
+ parse_bridge(cat, cfg);
+ } else if (!strcasecmp(type, "user")) {
+ parse_user(cat, cfg);
+ } else if (!strcasecmp(type, "menu")) {
+ parse_menu(cat, cfg);
+ } else {
+ continue;
+ }
+ }
+
+ remove_all_delme();
+
+ return 0;
+}
+
+static void conf_user_profile_copy(struct user_profile *dst, struct user_profile *src)
+{
+ memcpy(dst, src, sizeof(*dst));
+}
+
+const struct user_profile *conf_find_user_profile(struct ast_channel *chan, const char *user_profile_name, struct user_profile *result)
+{
+ struct user_profile tmp;
+ struct user_profile *tmp2;
+ struct ast_datastore *datastore = NULL;
+ struct func_confbridge_data *b_data = NULL;
+ ast_copy_string(tmp.name, user_profile_name, sizeof(tmp.name));
+
+ if (chan) {
+ ast_channel_lock(chan);
+ if ((datastore = ast_channel_datastore_find(chan, &confbridge_datastore, NULL))) {
+ ast_channel_unlock(chan);
+ b_data = datastore->data;
+ if (b_data->u_usable) {
+ conf_user_profile_copy(result, &b_data->u_profile);
+ return result;
+ }
+ }
+ ast_channel_unlock(chan);
+ }
+
+ if (ast_strlen_zero(user_profile_name)) {
+ user_profile_name = DEFAULT_USER_PROFILE;
+ }
+ if (!(tmp2 = ao2_find(user_profiles, &tmp, OBJ_POINTER))) {
+ return NULL;
+ }
+ ao2_lock(tmp2);
+ conf_user_profile_copy(result, tmp2);
+ ao2_unlock(tmp2);
+ ao2_ref(tmp2, -1);
+
+ return result;
+}
+
+void conf_bridge_profile_copy(struct bridge_profile *dst, struct bridge_profile *src)
+{
+ memcpy(dst, src, sizeof(*dst));
+ if (src->sounds) {
+ ao2_ref(src->sounds, +1);
+ }
+}
+
+void conf_bridge_profile_destroy(struct bridge_profile *b_profile)
+{
+ if (b_profile->sounds) {
+ ao2_ref(b_profile->sounds, -1);
+ b_profile->sounds = NULL;
+ }
+}
+
+const struct bridge_profile *conf_find_bridge_profile(struct ast_channel *chan, const char *bridge_profile_name, struct bridge_profile *result)
+{
+ struct bridge_profile tmp;
+ struct bridge_profile *tmp2;
+ struct ast_datastore *datastore = NULL;
+ struct func_confbridge_data *b_data = NULL;
+
+ if (chan) {
+ ast_channel_lock(chan);
+ if ((datastore = ast_channel_datastore_find(chan, &confbridge_datastore, NULL))) {
+ ast_channel_unlock(chan);
+ b_data = datastore->data;
+ if (b_data->b_usable) {
+ conf_bridge_profile_copy(result, &b_data->b_profile);
+ return result;
+ }
+ }
+ ast_channel_unlock(chan);
+ }
+ if (ast_strlen_zero(bridge_profile_name)) {
+ bridge_profile_name = DEFAULT_BRIDGE_PROFILE;
+ }
+ ast_copy_string(tmp.name, bridge_profile_name, sizeof(tmp.name));
+ if (!(tmp2 = ao2_find(bridge_profiles, &tmp, OBJ_POINTER))) {
+ return NULL;
+ }
+ ao2_lock(tmp2);
+ conf_bridge_profile_copy(result, tmp2);
+ ao2_unlock(tmp2);
+ ao2_ref(tmp2, -1);
+
+ return result;
+}
+
+struct dtmf_menu_hook_pvt {
+ struct conference_bridge_user *conference_bridge_user;
+ struct conf_menu_entry menu_entry;
+ struct conf_menu *menu;
+};
+
+static void menu_hook_destroy(void *hook_pvt)
+{
+ struct dtmf_menu_hook_pvt *pvt = hook_pvt;
+ struct conf_menu_action *action = NULL;
+
+ ao2_ref(pvt->menu, -1);
+
+ while ((action = AST_LIST_REMOVE_HEAD(&pvt->menu_entry.actions, action))) {
+ ast_free(action);
+ }
+ ast_free(pvt);
+}
+
+static int menu_hook_callback(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel, void *hook_pvt)
+{
+ struct dtmf_menu_hook_pvt *pvt = hook_pvt;
+ return conf_handle_dtmf(bridge_channel, pvt->conference_bridge_user, &pvt->menu_entry, pvt->menu);
+}
+
+static int copy_menu_entry(struct conf_menu_entry *dst, struct conf_menu_entry *src)
+{
+ struct conf_menu_action *menu_action = NULL;
+ struct conf_menu_action *new_menu_action = NULL;
+
+ memcpy(dst, src, sizeof(*dst));
+ AST_LIST_HEAD_INIT_NOLOCK(&dst->actions);
+
+ AST_LIST_TRAVERSE(&src->actions, menu_action, action) {
+ if (!(new_menu_action = ast_calloc(1, sizeof(*new_menu_action)))) {
+ return -1;
+ }
+ memcpy(new_menu_action, menu_action, sizeof(*new_menu_action));
+ AST_LIST_INSERT_HEAD(&dst->actions, new_menu_action, action);
+ }
+ return 0;
+}
+
+void conf_menu_entry_destroy(struct conf_menu_entry *menu_entry)
+{
+ struct conf_menu_action *menu_action = NULL;
+ while ((menu_action = AST_LIST_REMOVE_HEAD(&menu_entry->actions, action))) {
+ ast_free(menu_action);
+ }
+}
+
+int conf_find_menu_entry_by_sequence(const char *dtmf_sequence, struct conf_menu *menu, struct conf_menu_entry *result)
+{
+ struct conf_menu_entry *menu_entry = NULL;
+
+ ao2_lock(menu);
+ AST_LIST_TRAVERSE(&menu->entries, menu_entry, entry) {
+ if (!strcasecmp(menu_entry->dtmf, dtmf_sequence)) {
+ copy_menu_entry(result, menu_entry);
+ ao2_unlock(menu);
+ return 1;
+ }
+ }
+ ao2_unlock(menu);
+
+ return 0;
+}
+
+int conf_set_menu_to_user(const char *menu_name, struct conference_bridge_user *conference_bridge_user)
+{
+ struct conf_menu tmp;
+ struct conf_menu *menu;
+ struct conf_menu_entry *menu_entry = NULL;
+ ast_copy_string(tmp.name, menu_name, sizeof(tmp.name));
+
+ if (!(menu = ao2_find(menus, &tmp, OBJ_POINTER))) {
+ return -1;
+ }
+ ao2_lock(menu);
+ AST_LIST_TRAVERSE(&menu->entries, menu_entry, entry) {
+ struct dtmf_menu_hook_pvt *pvt;
+ if (!(pvt = ast_calloc(1, sizeof(*pvt)))) {
+ ao2_unlock(menu);
+ ao2_ref(menu, -1);
+ return -1;
+ }
+ if (copy_menu_entry(&pvt->menu_entry, menu_entry)) {
+ ast_free(pvt);
+ ao2_unlock(menu);
+ ao2_ref(menu, -1);
+ return -1;
+ }
+ pvt->conference_bridge_user = conference_bridge_user;
+ ao2_ref(menu, +1);
+ pvt->menu = menu;
+
+ ast_bridge_features_hook(&conference_bridge_user->features, pvt->menu_entry.dtmf, menu_hook_callback, pvt, menu_hook_destroy);
+ }
+
+ ao2_unlock(menu);
+ ao2_ref(menu, -1);
+
+ return 0;
+}
diff --git a/apps/confbridge/include/confbridge.h b/apps/confbridge/include/confbridge.h
new file mode 100644
index 000000000..4b6c0615e
--- /dev/null
+++ b/apps/confbridge/include/confbridge.h
@@ -0,0 +1,320 @@
+/*
+ * Asterisk -- An open source telephony toolkit.
+ *
+ * Copyright (C) 2011, Digium, Inc.
+ *
+ * David Vossel <dvossel@digium.com>
+ * Joshua Colp <jcolp@digium.com>
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE file
+ * at the top of the source tree.
+ */
+
+
+#ifndef _CONFBRIDGE_H
+#define _CONFBRIDGE_H
+
+#include "asterisk.h"
+#include "asterisk/app.h"
+#include "asterisk/logger.h"
+#include "asterisk/linkedlists.h"
+#include "asterisk/channel.h"
+#include "asterisk/bridging.h"
+#include "asterisk/bridging_features.h"
+
+/* Maximum length of a conference bridge name */
+#define MAX_CONF_NAME 32
+/* Maximum length of a conference pin */
+#define MAX_PIN 80
+
+#define DEFAULT_USER_PROFILE "default_user"
+#define DEFAULT_BRIDGE_PROFILE "default_bridge"
+
+#define DEFAULT_TALKING_THRESHOLD 160
+#define DEFAULT_SILENCE_THRESHOLD 2500
+
+enum user_profile_flags {
+ USER_OPT_ADMIN = (1 << 0), /*!< Set if the caller is an administrator */
+ USER_OPT_NOONLYPERSON = (1 << 1), /*!< Set if the "you are currently the only person in this conference" sound file should not be played */
+ USER_OPT_MARKEDUSER = (1 << 2), /*!< Set if the caller is a marked user */
+ USER_OPT_STARTMUTED = (1 << 3), /*!< Set if the caller should be initially set muted */
+ USER_OPT_MUSICONHOLD = (1 << 4), /*!< Set if music on hold should be played if nobody else is in the conference bridge */
+ USER_OPT_QUIET = (1 << 5), /*!< Set if no audio prompts should be played */
+ USER_OPT_ANNOUNCEUSERCOUNT = (1 << 6), /*!< Set if the number of users should be announced to the caller */
+ USER_OPT_WAITMARKED = (1 << 7), /*!< Set if the user must wait for a marked user before starting */
+ 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. */
+ USER_OPT_DROP_SILENCE = (1 << 12), /*!< Sets if silence should be dropped from the mix or not. */
+ USER_OPT_DTMF_PASS = (1 << 13), /*!< Sets if dtmf should be passed into the conference or not */
+ USER_OPT_ANNOUNCEUSERCOUNTALL = (1 << 14), /*!< Sets if the number of users should be announced to everyone. */
+ USER_OPT_JITTERBUFFER = (1 << 15), /*!< Places a jitterbuffer on the user. */
+};
+
+enum bridge_profile_flags {
+ BRIDGE_OPT_RECORD_CONFERENCE = (1 << 0), /*!< Set if the conference should be recorded */
+};
+
+enum conf_menu_action_id {
+ MENU_ACTION_TOGGLE_MUTE = 1,
+ MENU_ACTION_PLAYBACK,
+ MENU_ACTION_PLAYBACK_AND_CONTINUE,
+ MENU_ACTION_INCREASE_LISTENING,
+ MENU_ACTION_DECREASE_LISTENING,
+ MENU_ACTION_RESET_LISTENING,
+ MENU_ACTION_RESET_TALKING,
+ MENU_ACTION_INCREASE_TALKING,
+ MENU_ACTION_DECREASE_TALKING,
+ MENU_ACTION_DIALPLAN_EXEC,
+ MENU_ACTION_ADMIN_TOGGLE_LOCK,
+ MENU_ACTION_ADMIN_KICK_LAST,
+ MENU_ACTION_LEAVE,
+ MENU_ACTION_NOOP,
+};
+
+/*! The conference menu action contains both
+ * the action id that represents the action that
+ * must take place, along with any data associated
+ * with that action. */
+struct conf_menu_action {
+ enum conf_menu_action_id id;
+ union {
+ char playback_file[PATH_MAX];
+ struct {
+ char context[AST_MAX_CONTEXT];
+ char exten[AST_MAX_EXTENSION];
+ int priority;
+ } dialplan_args;
+ } data;
+ AST_LIST_ENTRY(conf_menu_action) action;
+};
+
+/*! Conference menu entries contain the DTMF sequence
+ * and the list of actions that are associated with that
+ * sequence. */
+struct conf_menu_entry {
+ /*! the DTMF sequence that triggers the actions */
+ char dtmf[MAXIMUM_DTMF_FEATURE_STRING];
+ /*! The actions associated with this menu entry. */
+ AST_LIST_HEAD_NOLOCK(, conf_menu_action) actions;
+ AST_LIST_ENTRY(conf_menu_entry) entry;
+};
+
+/*! Conference menu structure. Contains a list
+ * of DTMF sequences coupled with the actions those
+ * sequences invoke.*/
+struct conf_menu {
+ char name[128];
+ int delme;
+ AST_LIST_HEAD_NOLOCK(, conf_menu_entry) entries;
+};
+
+struct user_profile {
+ char name[128];
+ char pin[MAX_PIN];
+ char moh_class[128];
+ unsigned int flags;
+ unsigned int announce_user_count_all_after;
+ /*! The time in ms of talking before a user is considered to be talking by the dsp. */
+ unsigned int talking_threshold;
+ /*! The time in ms of silence before a user is considered to be silent by the dsp. */
+ unsigned int silence_threshold;
+ int delme;
+};
+
+enum conf_sounds {
+ CONF_SOUND_HAS_JOINED,
+ CONF_SOUND_HAS_LEFT,
+ CONF_SOUND_KICKED,
+ CONF_SOUND_MUTED,
+ CONF_SOUND_UNMUTED,
+ CONF_SOUND_ONLY_ONE,
+ CONF_SOUND_THERE_ARE,
+ CONF_SOUND_OTHER_IN_PARTY,
+ CONF_SOUND_PLACE_IN_CONF,
+ CONF_SOUND_WAIT_FOR_LEADER,
+ CONF_SOUND_LEADER_HAS_LEFT,
+ CONF_SOUND_GET_PIN,
+ CONF_SOUND_INVALID_PIN,
+ CONF_SOUND_ONLY_PERSON,
+ CONF_SOUND_LOCKED,
+ CONF_SOUND_LOCKED_NOW,
+ CONF_SOUND_UNLOCKED_NOW,
+ CONF_SOUND_ERROR_MENU,
+ CONF_SOUND_JOIN,
+ CONF_SOUND_LEAVE,
+};
+
+struct bridge_profile_sounds {
+ AST_DECLARE_STRING_FIELDS(
+ AST_STRING_FIELD(hasjoin);
+ AST_STRING_FIELD(hasleft);
+ AST_STRING_FIELD(kicked);
+ AST_STRING_FIELD(muted);
+ AST_STRING_FIELD(unmuted);
+ AST_STRING_FIELD(onlyone);
+ AST_STRING_FIELD(thereare);
+ AST_STRING_FIELD(otherinparty);
+ AST_STRING_FIELD(placeintoconf);
+ AST_STRING_FIELD(waitforleader);
+ AST_STRING_FIELD(leaderhasleft);
+ AST_STRING_FIELD(getpin);
+ AST_STRING_FIELD(invalidpin);
+ AST_STRING_FIELD(onlyperson);
+ AST_STRING_FIELD(locked);
+ AST_STRING_FIELD(lockednow);
+ AST_STRING_FIELD(unlockednow);
+ AST_STRING_FIELD(errormenu);
+ AST_STRING_FIELD(leave);
+ AST_STRING_FIELD(join);
+ );
+};
+
+struct bridge_profile {
+ char name[64];
+ char rec_file[PATH_MAX];
+ unsigned int flags;
+ unsigned int max_members; /*!< The maximum number of participants allowed in the conference */
+ unsigned int internal_sample_rate; /*!< The internal sample rate of the bridge. 0 when set to auto adjust mode. */
+ unsigned int mix_interval; /*!< The internal mixing interval used by the bridge. When set to 0 the bridgewill use a default interval. */
+ struct bridge_profile_sounds *sounds;
+ int delme;
+};
+
+/*! \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 */
+ struct bridge_profile b_profile; /*!< The Bridge Configuration Profile */
+ unsigned int users; /*!< Number of users present */
+ unsigned int markedusers; /*!< Number of marked users present */
+ unsigned int locked:1; /*!< Is this conference bridge locked? */
+ struct ast_channel *playback_chan; /*!< Channel used for playback into the conference bridge */
+ struct ast_channel *record_chan; /*!< Channel used for recording the conference */
+ pthread_t record_thread; /*!< The thread the recording chan lives in */
+ ast_mutex_t playback_lock; /*!< Lock used for playback channel */
+ AST_LIST_HEAD_NOLOCK(, conference_bridge_user) users_list; /*!< List of users participating in the conference bridge */
+};
+
+/*! \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 bridge_profile b_profile; /*!< The Bridge Configuration Profile */
+ struct user_profile u_profile; /*!< The User Configuration Profile */
+ char menu_name[64]; /*!< The name of the DTMF menu assigned to this user */
+ char name_rec_location[PATH_MAX]; /*!< Location of the User's name recorded file if it exists */
+ struct ast_channel *chan; /*!< Asterisk channel participating */
+ struct ast_bridge_features features; /*!< Bridge features structure */
+ struct ast_bridge_tech_optimizations tech_args; /*!< Bridge technology optimizations for talk detection */
+ unsigned int kicked:1; /*!< User has been kicked from the conference */
+ AST_LIST_ENTRY(conference_bridge_user) list; /*!< Linked list information */
+};
+
+/*! \brief load confbridge.conf file */
+int conf_load_config(int reload);
+
+/*! \brief destroy the information loaded from the confbridge.conf file*/
+void conf_destroy_config(void);
+
+/*!
+ * \brief find a user profile given a user profile's name and store
+ * that profile in result structure.
+ *
+ * \details This function first attempts to find any custom user
+ * profile that might exist on a channel datastore, if that doesn't
+ * exist it looks up the provided user profile name, if that doesn't
+ * exist either the default_user profile is used.
+
+ * \retval user profile on success
+ * \retval NULL on failure
+ */
+const struct user_profile *conf_find_user_profile(struct ast_channel *chan, const char *user_profile_name, struct user_profile *result);
+
+/*!
+ * \brief Find a bridge profile
+ *
+ * \details Any bridge profile found using this function must be
+ * destroyed using conf_bridge_profile_destroy. This function first
+ * attempts to find any custom bridge profile that might exist on
+ * a channel datastore, if that doesn't exist it looks up the
+ * provided bridge profile name, if that doesn't exist either
+ * the default_bridge profile is used.
+ *
+ * \retval Bridge profile on success
+ * \retval NULL on failure
+ */
+const struct bridge_profile *conf_find_bridge_profile(struct ast_channel *chan, const char *bridge_profile_name, struct bridge_profile *result);
+
+/*!
+ * \brief Destroy a bridge profile found by 'conf_find_bridge_profile'
+ */
+void conf_bridge_profile_destroy(struct bridge_profile *b_profile);
+
+/*!
+ * \brief copies a bridge profile
+ * \note conf_bridge_profile_destroy must be called on the dst structure
+ */
+void conf_bridge_profile_copy(struct bridge_profile *dst, struct bridge_profile *src);
+
+/*!
+ * \brief Set a DTMF menu to a conference user by menu name.
+ *
+ * \retval 0 on success, menu was found and set
+ * \retval -1 on error, menu was not found
+ */
+int conf_set_menu_to_user(const char *menu_name, struct conference_bridge_user *conference_bridge_user);
+
+/*!
+ * \brief Finds a menu_entry in a menu structure matched by DTMF sequence.
+ *
+ * \note the menu entry found must be destroyed using conf_menu_entry_destroy()
+ *
+ * \retval 1 success, entry is found and stored in result
+ * \retval 0 failure, no entry found for given DTMF sequence
+ */
+int conf_find_menu_entry_by_sequence(const char *dtmf_sequence, struct conf_menu *menu, struct conf_menu_entry *result);
+
+/*!
+ * \brief Destroys and frees all the actions stored in a menu_entry structure
+ */
+void conf_menu_entry_destroy(struct conf_menu_entry *menu_entry);
+
+/*!
+ * \brief Once a DTMF sequence matches a sequence in the user's DTMF menu, this function will get
+ * called to perform the menu action.
+ *
+ * \param bridge_channel, Bridged channel this is involving
+ * \param conference_bridge_user, the conference user to perform the action on.
+ * \param menu_entry, the menu entry that invoked this callback to occur.
+ * \param menu, an AO2 referenced pointer to the entire menu structure the menu_entry
+ * derived from.
+ *
+ * \note The menu_entry is a deep copy of the entry found in the menu structure. This allows
+ * for the menu_entry to be accessed without requiring the menu lock. If the menu must
+ * be accessed, the menu lock must be held. Reference counting of the menu structure is
+ * handled outside of the scope of this function.
+ *
+ * \retval 0 success
+ * \retval -1 failure
+ */
+int conf_handle_dtmf(
+ struct ast_bridge_channel *bridge_channel,
+ struct conference_bridge_user *conference_bridge_user,
+ struct conf_menu_entry *menu_entry,
+ struct conf_menu *menu);
+
+
+/*! \brief Looks to see if sound file is stored in bridge profile sounds, if not
+ * default sound is provided.*/
+const char *conf_get_sound(enum conf_sounds sound, struct bridge_profile_sounds *custom_sounds);
+
+int func_confbridge_helper(struct ast_channel *chan, const char *cmd, char *data, const char *value);
+#endif