bridge_simple.c

Go to the documentation of this file.
00001 /*
00002  * Asterisk -- An open source telephony toolkit.
00003  *
00004  * Copyright (C) 2007, Digium, Inc.
00005  *
00006  * Joshua Colp <jcolp@digium.com>
00007  *
00008  * See http://www.asterisk.org for more information about
00009  * the Asterisk project. Please do not directly contact
00010  * any of the maintainers of this project for assistance;
00011  * the project provides a web site, mailing lists and IRC
00012  * channels for your use.
00013  *
00014  * This program is free software, distributed under the terms of
00015  * the GNU General Public License Version 2. See the LICENSE file
00016  * at the top of the source tree.
00017  */
00018 
00019 /*! \file
00020  *
00021  * \brief Simple two channel bridging module
00022  *
00023  * \author Joshua Colp <jcolp@digium.com>
00024  *
00025  * \ingroup bridges
00026  */
00027 
00028 /*** MODULEINFO
00029    <support_level>core</support_level>
00030  ***/
00031 
00032 #include "asterisk.h"
00033 
00034 ASTERISK_FILE_VERSION(__FILE__, "$Revision: 434430 $")
00035 
00036 #include <stdio.h>
00037 #include <stdlib.h>
00038 #include <string.h>
00039 #include <sys/types.h>
00040 #include <sys/stat.h>
00041 
00042 #include "asterisk/module.h"
00043 #include "asterisk/channel.h"
00044 #include "asterisk/bridge.h"
00045 #include "asterisk/bridge_technology.h"
00046 #include "asterisk/frame.h"
00047 
00048 static int simple_bridge_join(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel)
00049 {
00050    struct ast_channel *c0 = AST_LIST_FIRST(&bridge->channels)->chan;
00051    struct ast_channel *c1 = AST_LIST_LAST(&bridge->channels)->chan;
00052 
00053    /*
00054     * If this is the first channel we can't make it compatible...
00055     * unless we make it compatible with itself.  O.o
00056     */
00057    if (c0 == c1) {
00058       return 0;
00059    }
00060 
00061    return ast_channel_make_compatible(c0, c1);
00062 }
00063 
00064 static int simple_bridge_write(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel, struct ast_frame *frame)
00065 {
00066    return ast_bridge_queue_everyone_else(bridge, bridge_channel, frame);
00067 }
00068 
00069 static struct ast_bridge_technology simple_bridge = {
00070    .name = "simple_bridge",
00071    .capabilities = AST_BRIDGE_CAPABILITY_1TO1MIX,
00072    .preference = AST_BRIDGE_PREFERENCE_BASE_1TO1MIX,
00073    .join = simple_bridge_join,
00074    .write = simple_bridge_write,
00075 };
00076 
00077 static int unload_module(void)
00078 {
00079    ast_bridge_technology_unregister(&simple_bridge);
00080    return 0;
00081 }
00082 
00083 static int load_module(void)
00084 {
00085    if (ast_bridge_technology_register(&simple_bridge)) {
00086       unload_module();
00087       return AST_MODULE_LOAD_DECLINE;
00088    }
00089    return AST_MODULE_LOAD_SUCCESS;
00090 }
00091 
00092 AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Simple two channel bridging module");

Generated on Thu Apr 16 06:27:16 2015 for Asterisk - The Open Source Telephony Project by  doxygen 1.5.6