2013-05-21 18:00:22 +00:00
|
|
|
/*
|
|
|
|
* Asterisk -- An open source telephony toolkit.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2013 Digium, Inc.
|
|
|
|
*
|
|
|
|
* Richard Mudgett <rmudgett@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 announcer channel driver
|
|
|
|
*
|
|
|
|
* \author Richard Mudgett <rmudgett@digium.com>
|
|
|
|
*
|
|
|
|
* See Also:
|
|
|
|
* \arg \ref AstCREDITS
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include "asterisk.h"
|
|
|
|
|
|
|
|
ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
|
|
|
|
|
|
|
#include "asterisk/channel.h"
|
2013-07-25 04:06:32 +00:00
|
|
|
#include "asterisk/bridge.h"
|
2013-05-21 18:00:22 +00:00
|
|
|
#include "asterisk/core_unreal.h"
|
|
|
|
#include "include/confbridge.h"
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
/*! ConfBridge announcer channel private. */
|
|
|
|
struct announce_pvt {
|
|
|
|
/*! Unreal channel driver base class values. */
|
|
|
|
struct ast_unreal_pvt base;
|
|
|
|
/*! Conference bridge associated with this announcer. */
|
|
|
|
struct ast_bridge *bridge;
|
|
|
|
};
|
|
|
|
|
|
|
|
static int announce_call(struct ast_channel *chan, const char *addr, int timeout)
|
|
|
|
{
|
|
|
|
/* Make sure anyone calling ast_call() for this channel driver is going to fail. */
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int announce_hangup(struct ast_channel *ast)
|
|
|
|
{
|
|
|
|
struct announce_pvt *p = ast_channel_tech_pvt(ast);
|
|
|
|
int res;
|
|
|
|
|
|
|
|
if (!p) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* give the pvt a ref to fulfill calling requirements. */
|
|
|
|
ao2_ref(p, +1);
|
|
|
|
res = ast_unreal_hangup(&p->base, ast);
|
|
|
|
ao2_ref(p, -1);
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void announce_pvt_destructor(void *vdoomed)
|
|
|
|
{
|
|
|
|
struct announce_pvt *doomed = vdoomed;
|
|
|
|
|
|
|
|
ao2_cleanup(doomed->bridge);
|
|
|
|
doomed->bridge = NULL;
|
2014-03-17 16:48:55 +00:00
|
|
|
ast_unreal_destructor(&doomed->base);
|
2013-05-21 18:00:22 +00:00
|
|
|
}
|
|
|
|
|
uniqueid: channel linkedid, ami, ari object creation with id's
Much needed was a way to assign id to objects on creation, and
much change was necessary to accomplish it. Channel uniqueids
and linkedids are split into separate string and creation time
components without breaking linkedid propgation. This allowed
the uniqueid to be specified by the user interface - and those
values are now carried through to channel creation, adding the
assignedids value to every function in the chain including the
channel drivers. For local channels, the second channel can be
specified or left to default to a ;2 suffix of first. In ARI,
bridge, playback, and snoop objects can also be created with a
specified uniqueid.
Along the way, the args order to allocating channels was fixed
in chan_mgcp and chan_gtalk, and linkedid is no longer lost as
masquerade occurs.
(closes issue ASTERISK-23120)
Review: https://reviewboard.asterisk.org/r/3191/
........
Merged revisions 410157 from http://svn.asterisk.org/svn/asterisk/branches/12
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@410158 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-03-07 15:47:55 +00:00
|
|
|
static struct ast_channel *announce_request(const char *type, struct ast_format_cap *cap, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const char *data, int *cause)
|
2013-05-21 18:00:22 +00:00
|
|
|
{
|
|
|
|
struct ast_channel *chan;
|
|
|
|
const char *conf_name = data;
|
|
|
|
RAII_VAR(struct confbridge_conference *, conference, NULL, ao2_cleanup);
|
|
|
|
RAII_VAR(struct announce_pvt *, pvt, NULL, ao2_cleanup);
|
|
|
|
|
|
|
|
conference = ao2_find(conference_bridges, conf_name, OBJ_KEY);
|
|
|
|
if (!conference) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
ast_assert(conference->bridge != NULL);
|
|
|
|
|
|
|
|
/* Allocate a new private structure and then Asterisk channels */
|
|
|
|
pvt = (struct announce_pvt *) ast_unreal_alloc(sizeof(*pvt), announce_pvt_destructor,
|
|
|
|
cap);
|
|
|
|
if (!pvt) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
ast_set_flag(&pvt->base, AST_UNREAL_NO_OPTIMIZATION);
|
|
|
|
ast_copy_string(pvt->base.name, conf_name, sizeof(pvt->base.name));
|
|
|
|
pvt->bridge = conference->bridge;
|
|
|
|
ao2_ref(pvt->bridge, +1);
|
|
|
|
|
|
|
|
chan = ast_unreal_new_channels(&pvt->base, conf_announce_get_tech(),
|
uniqueid: channel linkedid, ami, ari object creation with id's
Much needed was a way to assign id to objects on creation, and
much change was necessary to accomplish it. Channel uniqueids
and linkedids are split into separate string and creation time
components without breaking linkedid propgation. This allowed
the uniqueid to be specified by the user interface - and those
values are now carried through to channel creation, adding the
assignedids value to every function in the chain including the
channel drivers. For local channels, the second channel can be
specified or left to default to a ;2 suffix of first. In ARI,
bridge, playback, and snoop objects can also be created with a
specified uniqueid.
Along the way, the args order to allocating channels was fixed
in chan_mgcp and chan_gtalk, and linkedid is no longer lost as
masquerade occurs.
(closes issue ASTERISK-23120)
Review: https://reviewboard.asterisk.org/r/3191/
........
Merged revisions 410157 from http://svn.asterisk.org/svn/asterisk/branches/12
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@410158 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-03-07 15:47:55 +00:00
|
|
|
AST_STATE_UP, AST_STATE_UP, NULL, NULL, assignedids, requestor, NULL);
|
2013-05-21 18:00:22 +00:00
|
|
|
if (chan) {
|
|
|
|
ast_answer(pvt->base.owner);
|
|
|
|
ast_answer(pvt->base.chan);
|
|
|
|
if (ast_channel_add_bridge_role(pvt->base.chan, "announcer")) {
|
|
|
|
ast_hangup(chan);
|
|
|
|
chan = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return chan;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct ast_channel_tech announce_tech = {
|
|
|
|
.type = "CBAnn",
|
|
|
|
.description = "Conference Bridge Announcing Channel",
|
|
|
|
.requester = announce_request,
|
|
|
|
.call = announce_call,
|
|
|
|
.hangup = announce_hangup,
|
|
|
|
|
|
|
|
.send_digit_begin = ast_unreal_digit_begin,
|
|
|
|
.send_digit_end = ast_unreal_digit_end,
|
|
|
|
.read = ast_unreal_read,
|
|
|
|
.write = ast_unreal_write,
|
|
|
|
.write_video = ast_unreal_write,
|
|
|
|
.exception = ast_unreal_read,
|
|
|
|
.indicate = ast_unreal_indicate,
|
|
|
|
.fixup = ast_unreal_fixup,
|
|
|
|
.send_html = ast_unreal_sendhtml,
|
|
|
|
.send_text = ast_unreal_sendtext,
|
|
|
|
.queryoption = ast_unreal_queryoption,
|
|
|
|
.setoption = ast_unreal_setoption,
|
2013-08-08 14:13:05 +00:00
|
|
|
.properties = AST_CHAN_TP_INTERNAL,
|
2013-05-21 18:00:22 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct ast_channel_tech *conf_announce_get_tech(void)
|
|
|
|
{
|
|
|
|
return &announce_tech;
|
|
|
|
}
|
|
|
|
|
|
|
|
void conf_announce_channel_depart(struct ast_channel *chan)
|
|
|
|
{
|
|
|
|
struct announce_pvt *p = ast_channel_tech_pvt(chan);
|
|
|
|
|
|
|
|
if (!p) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ao2_ref(p, +1);
|
|
|
|
ao2_lock(p);
|
|
|
|
if (!ast_test_flag(&p->base, AST_UNREAL_CARETAKER_THREAD)) {
|
|
|
|
ao2_unlock(p);
|
|
|
|
ao2_ref(p, -1);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
ast_clear_flag(&p->base, AST_UNREAL_CARETAKER_THREAD);
|
|
|
|
chan = p->base.chan;
|
|
|
|
ao2_unlock(p);
|
|
|
|
ao2_ref(p, -1);
|
|
|
|
if (chan) {
|
|
|
|
ast_bridge_depart(chan);
|
|
|
|
ast_channel_unref(chan);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int conf_announce_channel_push(struct ast_channel *ast)
|
|
|
|
{
|
|
|
|
struct ast_bridge_features *features;
|
2013-06-26 01:46:30 +00:00
|
|
|
struct ast_channel *chan;
|
2013-05-21 18:00:22 +00:00
|
|
|
RAII_VAR(struct announce_pvt *, p, NULL, ao2_cleanup);
|
|
|
|
|
|
|
|
{
|
|
|
|
SCOPED_CHANNELLOCK(lock, ast);
|
|
|
|
|
|
|
|
p = ast_channel_tech_pvt(ast);
|
|
|
|
if (!p) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
ao2_ref(p, +1);
|
|
|
|
chan = p->base.chan;
|
|
|
|
if (!chan) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
ast_channel_ref(chan);
|
|
|
|
}
|
|
|
|
|
|
|
|
features = ast_bridge_features_new();
|
|
|
|
if (!features) {
|
2013-06-26 01:46:30 +00:00
|
|
|
ast_channel_unref(chan);
|
2013-05-21 18:00:22 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
ast_set_flag(&features->feature_flags, AST_BRIDGE_CHANNEL_FLAG_IMMOVABLE);
|
|
|
|
|
|
|
|
/* Impart the output channel into the bridge */
|
2013-09-13 22:19:23 +00:00
|
|
|
if (ast_bridge_impart(p->bridge, chan, NULL, features,
|
|
|
|
AST_BRIDGE_IMPART_CHAN_DEPARTABLE)) {
|
2013-06-26 01:46:30 +00:00
|
|
|
ast_bridge_features_destroy(features);
|
|
|
|
ast_channel_unref(chan);
|
2013-05-21 18:00:22 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
ao2_lock(p);
|
|
|
|
ast_set_flag(&p->base, AST_UNREAL_CARETAKER_THREAD);
|
|
|
|
ao2_unlock(p);
|
|
|
|
return 0;
|
|
|
|
}
|