[Asterisk-code-review] app bridgeaddchan: ability to barge into existing call (asterisk[master])
Matt Jordan
asteriskteam at digium.com
Wed Nov 18 21:30:49 CST 2015
Matt Jordan has submitted this change and it was merged.
Change subject: app_bridgeaddchan: ability to barge into existing call
......................................................................
app_bridgeaddchan: ability to barge into existing call
To be able to barge into a call by dialling a prefix+extension that maps
to the extensions device.
Senario is that DECT headset users may be away from their desks and need
to transfer the call, the goal is that from any phone they dial a prefix
then their extension and are added to the bridge that they are in, from
there they can drop the headset call, as it's also on the handset,
and transfer the caller.
The dialplan would look like, where prefix=73, extension = 8512;
exten => _738512,1,BridgeAdd(SIP/cisco0001)
ASTERISK-25551 #close
Reported By: Alec Davis
Change-Id: I8eb5096a02168dcc8d7aeea416ef36ba4ed10540
---
M CHANGES
A apps/app_bridgeaddchan.c
2 files changed, 129 insertions(+), 0 deletions(-)
Approvals:
Richard Mudgett: Looks good to me, but someone else must approve
Anonymous Coward #1000019: Verified
Matt Jordan: Looks good to me, approved
diff --git a/CHANGES b/CHANGES
index d6fea74..6e96515 100644
--- a/CHANGES
+++ b/CHANGES
@@ -15,6 +15,11 @@
Applications
------------------
+BridgeAdd
+------------------
+ * A new application in Asterisk, this will join the calling channel
+ to an existing bridge containing the named channel prefix.
+
ConfBridge
------------------
* Added the ability to pass options to MixMonitor when recording is used with
diff --git a/apps/app_bridgeaddchan.c b/apps/app_bridgeaddchan.c
new file mode 100644
index 0000000..fda6ca5
--- /dev/null
+++ b/apps/app_bridgeaddchan.c
@@ -0,0 +1,124 @@
+/*
+ * Asterisk -- An open source telephony toolkit.
+ *
+ * Copyright (C) 2015, Digium, Inc.
+ *
+ * Alec Davis <sivad.a at paradise.net.nz>
+ *
+ * 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 Application to place the channel into an existing Bridge
+ *
+ * \author Alec Davis
+ *
+ * \ingroup applications
+ */
+
+/*** MODULEINFO
+ <support_level>core</support_level>
+ ***/
+
+#include "asterisk.h"
+
+ASTERISK_REGISTER_FILE()
+
+#include "asterisk/file.h"
+#include "asterisk/module.h"
+#include "asterisk/channel.h"
+#include "asterisk/bridge.h"
+#include "asterisk/features.h"
+
+/*** DOCUMENTATION
+ <application name="BridgeAdd" language="en_US">
+ <synopsis>
+ Join a bridge that contains the specified channel.
+ </synopsis>
+ <syntax>
+ <parameter name="name">
+ <para>Name of the channel in an existing bridge
+ </para>
+ </parameter>
+ </syntax>
+ <description>
+ <para>This application places the incoming channel into
+ the bridge containing the specified channel. The specified
+ channel only needs to be the prefix of a full channel name
+ IE. 'SIP/cisco0001'.
+ </para>
+ </description>
+ </application>
+ ***/
+
+static const char app[] = "BridgeAdd";
+
+static int bridgeadd_exec(struct ast_channel *chan, const char *data)
+{
+ struct ast_channel *c_ref;
+ struct ast_bridge_features chan_features;
+ struct ast_bridge *bridge;
+ char *c_name;
+
+ /* Answer the channel if needed */
+ if (ast_channel_state(chan) != AST_STATE_UP) {
+ ast_answer(chan);
+ }
+
+ if (!(c_ref = ast_channel_get_by_name_prefix(data, strlen(data)))) {
+ ast_log(LOG_WARNING, "Channel %s not found\n", data);
+ return -1;
+ }
+
+ c_name = ast_strdupa(ast_channel_name(c_ref));
+
+ ast_channel_lock(c_ref);
+ bridge = ast_channel_get_bridge(c_ref);
+ ast_channel_unlock(c_ref);
+
+ ast_channel_unref(c_ref);
+
+ if (!bridge) {
+ ast_log(LOG_WARNING, "Channel %s is not in a bridge\n", c_name);
+ return -1;
+ }
+
+ ast_verb(3, "%s is joining %s in bridge %s\n", ast_channel_name(chan),
+ c_name, bridge->uniqueid);
+
+ if (ast_bridge_features_init(&chan_features)
+ || ast_bridge_join(bridge, chan, NULL, &chan_features, NULL, 0)) {
+
+ ast_log(LOG_WARNING, "%s failed to join %s in bridge %s\n", ast_channel_name(chan),
+ c_name, bridge->uniqueid);
+
+ ast_bridge_features_cleanup(&chan_features);
+ ao2_cleanup(bridge);
+ return -1;
+ }
+
+ ast_bridge_features_cleanup(&chan_features);
+ ao2_cleanup(bridge);
+ return 0;
+}
+
+static int unload_module(void)
+{
+ return ast_unregister_application(app);
+}
+
+static int load_module(void)
+{
+ return ast_register_application_xml(app, bridgeadd_exec);
+}
+
+AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Bridge Add Channel Application");
--
To view, visit https://gerrit.asterisk.org/1631
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I8eb5096a02168dcc8d7aeea416ef36ba4ed10540
Gerrit-PatchSet: 12
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Owner: Alec Davis <sivad.a at paradise.net.nz>
Gerrit-Reviewer: Alec Davis <sivad.a at paradise.net.nz>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Mark Michelson <mmichelson at digium.com>
Gerrit-Reviewer: Matt Jordan <mjordan at digium.com>
Gerrit-Reviewer: Richard Mudgett <rmudgett at digium.com>
More information about the asterisk-code-review
mailing list