Sat Apr 26 2014 22:01:29

Asterisk developer's documentation


bridging_technology.h
Go to the documentation of this file.
00001 /*
00002  * Asterisk -- An open source telephony toolkit.
00003  *
00004  * Copyright (C) 2009, 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  * \brief Channel Bridging API
00021  * \author Joshua Colp <jcolp@digium.com>
00022  */
00023 
00024 #ifndef _ASTERISK_BRIDGING_TECHNOLOGY_H
00025 #define _ASTERISK_BRIDGING_TECHNOLOGY_H
00026 
00027 #if defined(__cplusplus) || defined(c_plusplus)
00028 extern "C" {
00029 #endif
00030 
00031 /*! \brief Preference for choosing the bridge technology */
00032 enum ast_bridge_preference {
00033    /*! Bridge technology should have high precedence over other bridge technologies */
00034    AST_BRIDGE_PREFERENCE_HIGH = 0,
00035    /*! Bridge technology is decent, not the best but should still be considered over low */
00036    AST_BRIDGE_PREFERENCE_MEDIUM,
00037    /*! Bridge technology is low, it should not be considered unless it is absolutely needed */
00038    AST_BRIDGE_PREFERENCE_LOW,
00039 };
00040 
00041 /*!
00042  * \brief Structure that is the essence of a bridge technology
00043  */
00044 struct ast_bridge_technology {
00045    /*! Unique name to this bridge technology */
00046    const char *name;
00047    /*! The capabilities that this bridge technology is capable of.  This has nothing to do with
00048     * format capabilities. */
00049    uint32_t capabilities;
00050    /*! Preference level that should be used when determining whether to use this bridge technology or not */
00051    enum ast_bridge_preference preference;
00052    /*! Callback for when a bridge is being created */
00053    int (*create)(struct ast_bridge *bridge);
00054    /*! Callback for when a bridge is being destroyed */
00055    int (*destroy)(struct ast_bridge *bridge);
00056    /*! Callback for when a channel is being added to a bridge */
00057    int (*join)(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel);
00058    /*! Callback for when a channel is leaving a bridge */
00059    int (*leave)(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel);
00060    /*! Callback for when a channel is suspended from the bridge */
00061    void (*suspend)(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel);
00062    /*! Callback for when a channel is unsuspended from the bridge */
00063    void (*unsuspend)(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel);
00064    /*! Callback to see if a channel is compatible with the bridging technology */
00065    int (*compatible)(struct ast_bridge_channel *bridge_channel);
00066    /*! Callback for writing a frame into the bridging technology */
00067    enum ast_bridge_write_result (*write)(struct ast_bridge *bridge, struct ast_bridge_channel *bridged_channel, struct ast_frame *frame);
00068    /*! Callback for when a file descriptor trips */
00069    int (*fd)(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel, int fd);
00070    /*! Callback for replacement thread function */
00071    int (*thread)(struct ast_bridge *bridge);
00072    /*! Callback for poking a bridge thread */
00073    int (*poke)(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel);
00074    /*! Formats that the bridge technology supports */
00075    struct ast_format_cap *format_capabilities;
00076    /*! Bit to indicate whether the bridge technology is currently suspended or not */
00077    unsigned int suspended:1;
00078    /*! Module this bridge technology belongs to. Is used for reference counting when creating/destroying a bridge. */
00079    struct ast_module *mod;
00080    /*! Linked list information */
00081    AST_RWLIST_ENTRY(ast_bridge_technology) entry;
00082 };
00083 
00084 /*! \brief Register a bridge technology for use
00085  *
00086  * \param technology The bridge technology to register
00087  * \param mod The module that is registering the bridge technology
00088  *
00089  * \retval 0 on success
00090  * \retval -1 on failure
00091  *
00092  * Example usage:
00093  *
00094  * \code
00095  * ast_bridge_technology_register(&simple_bridge_tech);
00096  * \endcode
00097  *
00098  * This registers a bridge technology declared as the structure
00099  * simple_bridge_tech with the bridging core and makes it available for
00100  * use when creating bridges.
00101  */
00102 int __ast_bridge_technology_register(struct ast_bridge_technology *technology, struct ast_module *mod);
00103 
00104 /*! \brief See \ref __ast_bridge_technology_register() */
00105 #define ast_bridge_technology_register(technology) __ast_bridge_technology_register(technology, ast_module_info->self)
00106 
00107 /*! \brief Unregister a bridge technology from use
00108  *
00109  * \param technology The bridge technology to unregister
00110  *
00111  * \retval 0 on success
00112  * \retval -1 on failure
00113  *
00114  * Example usage:
00115  *
00116  * \code
00117  * ast_bridge_technology_unregister(&simple_bridge_tech);
00118  * \endcode
00119  *
00120  * This unregisters a bridge technlogy declared as the structure
00121  * simple_bridge_tech with the bridging core. It will no longer be
00122  * considered when creating a new bridge.
00123  */
00124 int ast_bridge_technology_unregister(struct ast_bridge_technology *technology);
00125 
00126 /*! \brief Feed notification that a frame is waiting on a channel into the bridging core
00127  *
00128  * \param bridge The bridge that the notification should influence
00129  * \param bridge_channel Bridge channel the notification was received on (if known)
00130  * \param chan Channel the notification was received on (if known)
00131  * \param outfd File descriptor that the notification was received on (if known)
00132  *
00133  * Example usage:
00134  *
00135  * \code
00136  * ast_bridge_handle_trip(bridge, NULL, chan, -1);
00137  * \endcode
00138  *
00139  * This tells the bridging core that a frame has been received on
00140  * the channel pointed to by chan and that it should be read and handled.
00141  *
00142  * \note This should only be used by bridging technologies.
00143  */
00144 void ast_bridge_handle_trip(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel, struct ast_channel *chan, int outfd);
00145 
00146 /*! \brief Lets the bridging indicate when a bridge channel has stopped or started talking.
00147  *
00148  * \note All DSP functionality on the bridge has been pushed down to the lowest possible
00149  * layer, which in this case is the specific bridging technology being used. Since it
00150  * is necessary for the knowledge of which channels are talking to make its way up to the
00151  * application, this function has been created to allow the bridging technology to communicate
00152  * that information with the bridging core.
00153  *
00154  * \param bridge The bridge that the channel is a part of.
00155  * \param bridge_channel The bridge channel that has either started or stopped talking.
00156  * \param started_talking, set to 1 when this indicates the channel has started talking, set to 0
00157  * when this indicates the channel has stopped talking.
00158  */
00159 void ast_bridge_notify_talking(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel, int started_talking);
00160 
00161 /*! \brief Suspend a bridge technology from consideration
00162  *
00163  * \param technology The bridge technology to suspend
00164  *
00165  * Example usage:
00166  *
00167  * \code
00168  * ast_bridge_technology_suspend(&simple_bridge_tech);
00169  * \endcode
00170  *
00171  * This suspends the bridge technology simple_bridge_tech from being considered
00172  * when creating a new bridge. Existing bridges using the bridge technology
00173  * are not affected.
00174  */
00175 void ast_bridge_technology_suspend(struct ast_bridge_technology *technology);
00176 
00177 /*! \brief Unsuspend a bridge technology
00178  *
00179  * \param technology The bridge technology to unsuspend
00180  *
00181  * Example usage:
00182  *
00183  * \code
00184  * ast_bridge_technology_unsuspend(&simple_bridge_tech);
00185  * \endcode
00186  *
00187  * This makes the bridge technology simple_bridge_tech considered when
00188  * creating a new bridge again.
00189  */
00190 void ast_bridge_technology_unsuspend(struct ast_bridge_technology *technology);
00191 
00192 #if defined(__cplusplus) || defined(c_plusplus)
00193 }
00194 #endif
00195 
00196 #endif /* _ASTERISK_BRIDGING_TECHNOLOGY_H */