Simple two channel bridging module. More...
#include "asterisk.h"#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"#include "asterisk/bridging.h"#include "asterisk/bridging_technology.h"#include "asterisk/frame.h"
Go to the source code of this file.
Functions | |
| static void | __reg_module (void) |
| static void | __unreg_module (void) |
| static int | load_module (void) |
| static int | simple_bridge_join (struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel) |
| static enum ast_bridge_write_result | simple_bridge_write (struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel, struct ast_frame *frame) |
| static int | unload_module (void) |
Variables | |
| static struct ast_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Simple two channel bridging module" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, } |
| static struct ast_module_info * | ast_module_info = &__mod_info |
| static struct ast_bridge_technology | simple_bridge |
Simple two channel bridging module.
Definition in file bridge_simple.c.
| static void __reg_module | ( | void | ) | [static] |
Definition at line 116 of file bridge_simple.c.
| static void __unreg_module | ( | void | ) | [static] |
Definition at line 116 of file bridge_simple.c.
| static int load_module | ( | void | ) | [static] |
Definition at line 104 of file bridge_simple.c.
References ast_bridge_technology_register, ast_format_cap_add_all_by_type(), ast_format_cap_alloc(), AST_FORMAT_TYPE_AUDIO, AST_FORMAT_TYPE_TEXT, AST_FORMAT_TYPE_VIDEO, AST_MODULE_LOAD_DECLINE, and ast_bridge_technology::format_capabilities.
{
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);
return ast_bridge_technology_register(&simple_bridge);
}
| static int simple_bridge_join | ( | struct ast_bridge * | bridge, |
| struct ast_bridge_channel * | bridge_channel | ||
| ) | [static] |
Definition at line 48 of file bridge_simple.c.
References ast_channel_make_compatible(), ast_channel_nativeformats(), ast_channel_readformat(), ast_channel_writeformat(), ast_format_cap_identical(), ast_format_cmp(), AST_FORMAT_CMP_EQUAL, AST_LIST_FIRST, and AST_LIST_LAST.
{
struct ast_channel *c0 = AST_LIST_FIRST(&bridge->channels)->chan, *c1 = AST_LIST_LAST(&bridge->channels)->chan;
/* If this is the first channel we can't make it compatible... unless we make it compatible with itself O.o */
if (AST_LIST_FIRST(&bridge->channels) == AST_LIST_LAST(&bridge->channels)) {
return 0;
}
/* See if we need to make these compatible */
if ((ast_format_cmp(ast_channel_writeformat(c0), ast_channel_readformat(c1)) == AST_FORMAT_CMP_EQUAL) &&
(ast_format_cmp(ast_channel_readformat(c0), ast_channel_writeformat(c1)) == AST_FORMAT_CMP_EQUAL) &&
(ast_format_cap_identical(ast_channel_nativeformats(c0), ast_channel_nativeformats(c1)))) {
return 0;
}
/* BOOM! We do. */
return ast_channel_make_compatible(c0, c1);
}
| static enum ast_bridge_write_result simple_bridge_write | ( | struct ast_bridge * | bridge, |
| struct ast_bridge_channel * | bridge_channel, | ||
| struct ast_frame * | frame | ||
| ) | [static] |
Definition at line 68 of file bridge_simple.c.
References AST_BRIDGE_CHANNEL_STATE_WAIT, AST_BRIDGE_WRITE_FAILED, AST_BRIDGE_WRITE_SUCCESS, AST_LIST_FIRST, AST_LIST_LAST, ast_write(), ast_bridge_channel::chan, and ast_bridge_channel::state.
{
struct ast_bridge_channel *other = NULL;
/* If this is the only channel in this bridge then immediately exit */
if (AST_LIST_FIRST(&bridge->channels) == AST_LIST_LAST(&bridge->channels)) {
return AST_BRIDGE_WRITE_FAILED;
}
/* Find the channel we actually want to write to */
if (!(other = (AST_LIST_FIRST(&bridge->channels) == bridge_channel ? AST_LIST_LAST(&bridge->channels) : AST_LIST_FIRST(&bridge->channels)))) {
return AST_BRIDGE_WRITE_FAILED;
}
/* Write the frame out if they are in the waiting state... don't worry about freeing it, the bridging core will take care of it */
if (other->state == AST_BRIDGE_CHANNEL_STATE_WAIT) {
ast_write(other->chan, frame);
}
return AST_BRIDGE_WRITE_SUCCESS;
}
| static int unload_module | ( | void | ) | [static] |
Definition at line 98 of file bridge_simple.c.
References ast_bridge_technology_unregister(), ast_format_cap_destroy(), and ast_bridge_technology::format_capabilities.
struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Simple two channel bridging module" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, } [static] |
Definition at line 116 of file bridge_simple.c.
struct ast_module_info* ast_module_info = &__mod_info [static] |
Definition at line 116 of file bridge_simple.c.
struct ast_bridge_technology simple_bridge [static] |
Definition at line 90 of file bridge_simple.c.