conf_state.h 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /*
  2. * Asterisk -- An open source telephony toolkit.
  3. *
  4. * Copyright (C) 2012, Terry Wilson
  5. *
  6. * Terry Wilson <twilson@digium.com>
  7. *
  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.
  13. *
  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.
  17. *
  18. * Please follow coding guidelines
  19. * http://svn.digium.com/view/asterisk/trunk/doc/CODING-GUIDELINES
  20. */
  21. /*! \file
  22. *
  23. * \brief Confbridge state handling
  24. *
  25. * \author\verbatim Terry Wilson <twilson@digium.com> \endverbatim
  26. *
  27. * See https://wiki.asterisk.org/wiki/display/AST/Confbridge+state+changes for
  28. * a more complete description of how conference states work.
  29. */
  30. /*** MODULEINFO
  31. <support_level>core</support_level>
  32. ***/
  33. #ifndef _CONF_STATE_H_
  34. #define _CONF_STATE_H_
  35. struct confbridge_state;
  36. struct confbridge_conference;
  37. struct confbridge_user;
  38. typedef void (*conference_event_fn)(struct confbridge_user *user);
  39. typedef void (*conference_entry_fn)(struct confbridge_user *user);
  40. typedef void (*conference_exit_fn)(struct confbridge_user *user);
  41. /*! \brief A conference state object to hold the various state callback functions */
  42. struct confbridge_state {
  43. const char *name;
  44. conference_event_fn join_unmarked; /*!< Handle an unmarked join event */
  45. conference_event_fn join_waitmarked; /*!< Handle a waitmarked join event */
  46. conference_event_fn join_marked; /*!< Handle a marked join event */
  47. conference_event_fn leave_unmarked; /*!< Handle an unmarked leave event */
  48. conference_event_fn leave_waitmarked; /*!< Handle a waitmarked leave event */
  49. conference_event_fn leave_marked; /*!< Handle a marked leave event */
  50. conference_entry_fn entry; /*!< Function to handle entry to a state */
  51. conference_exit_fn exit; /*!< Function to handle exiting from a state */
  52. };
  53. /*! \brief Conference state with no active or waiting users */
  54. extern struct confbridge_state *CONF_STATE_EMPTY;
  55. /*! \brief Conference state with only waiting users */
  56. extern struct confbridge_state *CONF_STATE_INACTIVE;
  57. /*! \brief Conference state with only a single unmarked active user */
  58. extern struct confbridge_state *CONF_STATE_SINGLE;
  59. /*! \brief Conference state with only a single marked active user */
  60. extern struct confbridge_state *CONF_STATE_SINGLE_MARKED;
  61. /*! \brief Conference state with multiple active users, but no marked users */
  62. extern struct confbridge_state *CONF_STATE_MULTI;
  63. /*! \brief Conference state with multiple active users and at least one marked user */
  64. extern struct confbridge_state *CONF_STATE_MULTI_MARKED;
  65. /*! \brief Execute conference state transition because of a user action
  66. * \param user The user that joined/left
  67. * \param newstate The state to transition to
  68. */
  69. void conf_change_state(struct confbridge_user *user, struct confbridge_state *newstate);
  70. /* Common event handlers shared between different states */
  71. /*! \brief Logic to execute every time a waitmarked user joins an unmarked conference */
  72. void conf_default_join_waitmarked(struct confbridge_user *user);
  73. /*! \brief Logic to execute every time a waitmarked user leaves an unmarked conference */
  74. void conf_default_leave_waitmarked(struct confbridge_user *user);
  75. /*! \brief A handler for join/leave events that are invalid in a particular state */
  76. void conf_invalid_event_fn(struct confbridge_user *user);
  77. #endif