2009-03-05 18:18:27 +00:00
|
|
|
/*
|
|
|
|
* Asterisk -- An open source telephony toolkit.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2007, Digium, Inc.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*! \file
|
|
|
|
*
|
|
|
|
* \brief Simple two channel bridging module
|
|
|
|
*
|
|
|
|
* \author Joshua Colp <jcolp@digium.com>
|
|
|
|
*
|
|
|
|
* \ingroup bridges
|
|
|
|
*/
|
|
|
|
|
2011-07-14 20:28:54 +00:00
|
|
|
/*** MODULEINFO
|
|
|
|
<support_level>core</support_level>
|
|
|
|
***/
|
|
|
|
|
2009-03-05 18:18:27 +00:00
|
|
|
#include "asterisk.h"
|
|
|
|
|
|
|
|
ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
|
|
|
|
#include "asterisk/module.h"
|
|
|
|
#include "asterisk/channel.h"
|
2013-07-25 04:06:32 +00:00
|
|
|
#include "asterisk/bridge.h"
|
|
|
|
#include "asterisk/bridge_technology.h"
|
2009-03-05 18:18:27 +00:00
|
|
|
#include "asterisk/frame.h"
|
|
|
|
|
|
|
|
static int simple_bridge_join(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel)
|
|
|
|
{
|
2013-01-25 19:29:04 +00:00
|
|
|
struct ast_channel *c0 = AST_LIST_FIRST(&bridge->channels)->chan;
|
|
|
|
struct ast_channel *c1 = AST_LIST_LAST(&bridge->channels)->chan;
|
2009-03-05 18:18:27 +00:00
|
|
|
|
2013-07-16 18:48:49 +00:00
|
|
|
/*
|
|
|
|
* If this is the first channel we can't make it compatible...
|
|
|
|
* unless we make it compatible with itself. O.o
|
|
|
|
*/
|
|
|
|
if (c0 == c1) {
|
2009-03-05 18:18:27 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ast_channel_make_compatible(c0, c1);
|
|
|
|
}
|
|
|
|
|
2013-05-21 18:00:22 +00:00
|
|
|
static int simple_bridge_write(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel, struct ast_frame *frame)
|
2009-03-05 18:18:27 +00:00
|
|
|
{
|
2013-06-21 22:39:27 +00:00
|
|
|
return ast_bridge_queue_everyone_else(bridge, bridge_channel, frame);
|
2009-03-05 18:18:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static struct ast_bridge_technology simple_bridge = {
|
|
|
|
.name = "simple_bridge",
|
2013-05-21 18:00:22 +00:00
|
|
|
.capabilities = AST_BRIDGE_CAPABILITY_1TO1MIX,
|
|
|
|
.preference = AST_BRIDGE_PREFERENCE_BASE_1TO1MIX,
|
2009-03-05 18:18:27 +00:00
|
|
|
.join = simple_bridge_join,
|
|
|
|
.write = simple_bridge_write,
|
|
|
|
};
|
|
|
|
|
|
|
|
static int unload_module(void)
|
|
|
|
{
|
2011-02-03 16:22:10 +00:00
|
|
|
ast_format_cap_destroy(simple_bridge.format_capabilities);
|
2009-03-05 18:18:27 +00:00
|
|
|
return ast_bridge_technology_unregister(&simple_bridge);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int load_module(void)
|
|
|
|
{
|
2011-02-03 16:22:10 +00:00
|
|
|
if (!(simple_bridge.format_capabilities = ast_format_cap_alloc())) {
|
|
|
|
return AST_MODULE_LOAD_DECLINE;
|
|
|
|
}
|
|
|
|
ast_format_cap_add_all_by_type(simple_bridge.format_capabilities, AST_FORMAT_TYPE_AUDIO);
|
|
|
|
ast_format_cap_add_all_by_type(simple_bridge.format_capabilities, AST_FORMAT_TYPE_VIDEO);
|
|
|
|
ast_format_cap_add_all_by_type(simple_bridge.format_capabilities, AST_FORMAT_TYPE_TEXT);
|
|
|
|
|
2009-03-05 18:18:27 +00:00
|
|
|
return ast_bridge_technology_register(&simple_bridge);
|
|
|
|
}
|
|
|
|
|
|
|
|
AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Simple two channel bridging module");
|