control.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. /*
  2. * Asterisk -- An open source telephony toolkit.
  3. *
  4. * Copyright (C) 2013, Digium, Inc.
  5. *
  6. * David M. Lee, II <dlee@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. #ifndef _ASTERISK_RES_STASIS_CONTROL_H
  19. #define _ASTERISK_RES_STASIS_CONTROL_H
  20. /*! \file
  21. *
  22. * \brief Internal API for the Stasis application controller.
  23. *
  24. * \author David M. Lee, II <dlee@digium.com>
  25. * \since 12
  26. */
  27. #include "asterisk/stasis_app.h"
  28. /*!
  29. * \brief Create a control object.
  30. *
  31. * \param channel Channel to control.
  32. * \param app stasis_app for which this control is being created.
  33. *
  34. * \return New control object.
  35. * \return \c NULL on error.
  36. */
  37. struct stasis_app_control *control_create(struct ast_channel *channel, struct stasis_app *app);
  38. /*!
  39. * \brief Flush the control command queue.
  40. * \since 13.9.0
  41. *
  42. * \param control Control object to flush command queue.
  43. *
  44. * \return Nothing
  45. */
  46. void control_flush_queue(struct stasis_app_control *control);
  47. /*!
  48. * \brief Dispatch all commands enqueued to this control.
  49. *
  50. * \param control Control object to dispatch.
  51. * \param chan Associated channel.
  52. * \return Number of commands executed
  53. */
  54. int control_dispatch_all(struct stasis_app_control *control,
  55. struct ast_channel *chan);
  56. /*!
  57. * \brief Blocks until \a control's command queue has a command available.
  58. *
  59. * \param control Control to block on.
  60. */
  61. void control_wait(struct stasis_app_control *control);
  62. /*!
  63. * \brief Returns the count of items in a control's command queue.
  64. *
  65. * \param control Control to count commands on
  66. *
  67. * \retval number of commands in the command que
  68. */
  69. int control_command_count(struct stasis_app_control *control);
  70. /*!
  71. * \brief Returns true if control_continue() has been called on this \a control.
  72. *
  73. * \param control Control to query.
  74. * \return True (non-zero) if control_continue() has been called.
  75. * \return False (zero) otherwise.
  76. */
  77. int control_is_done(struct stasis_app_control *control);
  78. void control_mark_done(struct stasis_app_control *control);
  79. /*!
  80. * \brief Dispatch all queued prestart commands
  81. *
  82. * \param control The control for chan
  83. * \param channel The channel on which commands should be executed
  84. *
  85. * \return The number of commands executed
  86. */
  87. int control_prestart_dispatch_all(struct stasis_app_control *control,
  88. struct ast_channel *chan);
  89. /*!
  90. * \brief Returns the pointer (non-reffed) to the app associated with this control
  91. *
  92. * \param control Control to query.
  93. *
  94. * \returns A pointer to the associated stasis_app
  95. */
  96. struct stasis_app *control_app(struct stasis_app_control *control);
  97. /*!
  98. * \brief Command callback for adding a channel to a bridge
  99. *
  100. * \param control The control for chan
  101. * \param chan The channel on which commands should be executed
  102. * \param data Bridge to be passed to the callback
  103. */
  104. int control_add_channel_to_bridge(struct stasis_app_control *control, struct ast_channel *chan, void *data);
  105. /*!
  106. * \brief Command for swapping a channel in a bridge
  107. *
  108. * \param control The control for chan
  109. * \param chan The channel on which commands should be executed
  110. * \param bridge Bridge to be passed to the callback
  111. * \param swap Channel to swap with when joining the bridge
  112. */
  113. int control_swap_channel_in_bridge(struct stasis_app_control *control, struct ast_bridge *bridge, struct ast_channel *chan, struct ast_channel *swap);
  114. /*!
  115. * \brief Stop playing silence to a channel right now.
  116. * \since 13.9.0
  117. *
  118. * \param control The control for chan
  119. */
  120. void control_silence_stop_now(struct stasis_app_control *control);
  121. #endif /* _ASTERISK_RES_STASIS_CONTROL_H */