conf_state_single.c 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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 for the SINGLE state
  24. *
  25. * \author\verbatim Terry Wilson <twilson@digium.com> \endverbatim
  26. *
  27. * \ingroup applications
  28. */
  29. /*** MODULEINFO
  30. <support_level>core</support_level>
  31. ***/
  32. #include "include/confbridge.h"
  33. #include "include/conf_state.h"
  34. static void join_unmarked(struct confbridge_user *user);
  35. static void join_marked(struct confbridge_user *user);
  36. static void leave_unmarked(struct confbridge_user *user);
  37. static void transition_to_single(struct confbridge_user *user);
  38. struct confbridge_state STATE_SINGLE = {
  39. .name = "SINGLE",
  40. .join_unmarked = join_unmarked,
  41. .join_waitmarked = conf_default_join_waitmarked,
  42. .join_marked = join_marked,
  43. .leave_unmarked = leave_unmarked,
  44. .leave_waitmarked = conf_default_leave_waitmarked,
  45. .entry = transition_to_single,
  46. };
  47. struct confbridge_state *CONF_STATE_SINGLE = &STATE_SINGLE;
  48. static void join_unmarked(struct confbridge_user *user)
  49. {
  50. conf_add_user_active(user->conference, user);
  51. conf_handle_second_active(user->conference);
  52. conf_update_user_mute(user);
  53. conf_change_state(user, CONF_STATE_MULTI);
  54. }
  55. static void join_marked(struct confbridge_user *user)
  56. {
  57. conf_add_user_marked(user->conference, user);
  58. conf_handle_second_active(user->conference);
  59. conf_update_user_mute(user);
  60. conf_change_state(user, CONF_STATE_MULTI_MARKED);
  61. }
  62. static void leave_unmarked(struct confbridge_user *user)
  63. {
  64. conf_remove_user_active(user->conference, user);
  65. if (user->playing_moh) {
  66. conf_moh_stop(user);
  67. }
  68. if (user->conference->waitingusers) {
  69. conf_change_state(user, CONF_STATE_INACTIVE);
  70. } else {
  71. conf_change_state(user, CONF_STATE_EMPTY);
  72. }
  73. }
  74. static void transition_to_single(struct confbridge_user *user)
  75. {
  76. conf_mute_only_active(user->conference);
  77. }