2 * Asterisk -- An open source telephony toolkit.
4 * Copyright (C) 2012, Terry Wilson
6 * Terry Wilson <twilson@digium.com>
8 * See http://www.asterisk.org for more information about
9 * the Asterisk project. Please do not directly contact
10 * any of the maintainers of this project for assistance;
11 * the project provides a web site, mailing lists and IRC
12 * channels for your use.
14 * This program is free software, distributed under the terms of
15 * the GNU General Public License Version 2. See the LICENSE file
16 * at the top of the source tree.
18 * Please follow coding guidelines
19 * http://svn.digium.com/view/asterisk/trunk/doc/CODING-GUIDELINES
24 * \brief Confbridge state handling
26 * \author\verbatim Terry Wilson <twilson@digium.com> \endverbatim
28 * See https://wiki.asterisk.org/wiki/display/AST/Confbridge+state+changes for
29 * a more complete description of how conference states work.
33 <support_level>core</support_level>
36 #ifndef _CONF_STATE_H_
37 #define _CONF_STATE_H_
39 struct conference_state;
40 struct conference_bridge;
41 struct conference_bridge_user;
43 typedef void (*conference_event_fn)(struct conference_bridge_user *cbu);
44 typedef void (*conference_entry_fn)(struct conference_bridge_user *cbu);
45 typedef void (*conference_exit_fn)(struct conference_bridge_user *cbu);
47 /*! \brief A conference state object to hold the various state callback functions */
48 struct conference_state {
50 conference_event_fn join_unmarked; /*!< Handle an unmarked join event */
51 conference_event_fn join_waitmarked; /*!< Handle a waitmarked join event */
52 conference_event_fn join_marked; /*!< Handle a marked join event */
53 conference_event_fn leave_unmarked; /*!< Handle an unmarked leave event */
54 conference_event_fn leave_waitmarked; /*!< Handle a waitmarked leave event */
55 conference_event_fn leave_marked; /*!< Handle a marked leave event */
56 conference_entry_fn entry; /*!< Function to handle entry to a state */
57 conference_exit_fn exit; /*!< Function to handle exiting from a state */
60 /*! \brief Conference state with no active or waiting users */
61 extern struct conference_state *CONF_STATE_EMPTY;
63 /*! \brief Conference state with only waiting users */
64 extern struct conference_state *CONF_STATE_INACTIVE;
66 /*! \brief Conference state with only a single unmarked active user */
67 extern struct conference_state *CONF_STATE_SINGLE;
69 /*! \brief Conference state with only a single marked active user */
70 extern struct conference_state *CONF_STATE_SINGLE_MARKED;
72 /*! \brief Conference state with multiple active users, but no marked users */
73 extern struct conference_state *CONF_STATE_MULTI;
75 /*! \brief Conference state with multiple active users and at least one marked user */
76 extern struct conference_state *CONF_STATE_MULTI_MARKED;
78 /*! \brief Execute conference state transition because of a user action
79 * \param cbu The user that joined/left
80 * \param newstate The state to transition to
82 void conf_change_state(struct conference_bridge_user *cbu, struct conference_state *newstate);
84 /* Common event handlers shared between different states */
86 /*! \brief Logic to execute every time a waitmarked user joins an unmarked conference */
87 void conf_default_join_waitmarked(struct conference_bridge_user *cbu);
89 /*! \brief Logic to execute every time a waitmarked user leaves an unmarked conference */
90 void conf_default_leave_waitmarked(struct conference_bridge_user *cbu);
92 /*! \brief A handler for join/leave events that are invalid in a particular state */
93 void conf_invalid_event_fn(struct conference_bridge_user *cbu);