conf_state.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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. * This file contains functions that are used from multiple conf_state
  28. * files for handling stage change behavior.
  29. *
  30. * \ingroup applications
  31. */
  32. /*** MODULEINFO
  33. <support_level>core</support_level>
  34. ***/
  35. #include "asterisk.h"
  36. #include "asterisk/logger.h"
  37. #include "asterisk/test.h"
  38. #include "include/conf_state.h"
  39. #include "include/confbridge.h"
  40. void conf_invalid_event_fn(struct confbridge_user *user)
  41. {
  42. ast_log(LOG_ERROR, "Invalid event for confbridge user '%s'\n", user->u_profile.name);
  43. }
  44. /*!
  45. * \internal
  46. * \brief Mute the user and play MOH if the user requires it.
  47. *
  48. * \param user Conference user to mute and optionally start MOH on.
  49. *
  50. * \return Nothing
  51. */
  52. static void conf_mute_moh_inactive_waitmarked(struct confbridge_user *user)
  53. {
  54. /* Start music on hold if needed */
  55. if (ast_test_flag(&user->u_profile, USER_OPT_MUSICONHOLD)) {
  56. conf_moh_start(user);
  57. }
  58. conf_update_user_mute(user);
  59. }
  60. void conf_default_join_waitmarked(struct confbridge_user *user)
  61. {
  62. conf_add_user_waiting(user->conference, user);
  63. conf_mute_moh_inactive_waitmarked(user);
  64. conf_add_post_join_action(user, conf_handle_inactive_waitmarked);
  65. }
  66. void conf_default_leave_waitmarked(struct confbridge_user *user)
  67. {
  68. conf_remove_user_waiting(user->conference, user);
  69. if (user->playing_moh) {
  70. conf_moh_stop(user);
  71. }
  72. }
  73. void conf_change_state(struct confbridge_user *user, struct confbridge_state *newstate)
  74. {
  75. ast_debug(1, "Changing conference '%s' state from %s to %s\n", user->conference->name, user->conference->state->name, newstate->name);
  76. ast_test_suite_event_notify("CONF_CHANGE_STATE", "Conference: %s\r\nOldState: %s\r\nNewState: %s\r\n",
  77. user->conference->name,
  78. user->conference->state->name,
  79. newstate->name);
  80. if (user->conference->state->exit) {
  81. user->conference->state->exit(user);
  82. }
  83. user->conference->state = newstate;
  84. if (user->conference->state->entry) {
  85. user->conference->state->entry(user);
  86. }
  87. }