bridge_after.h 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. /*
  2. * Asterisk -- An open source telephony toolkit.
  3. *
  4. * Copyright (C) 2013 Digium, Inc.
  5. *
  6. * Richard Mudgett <rmudgett@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. /*!
  19. * \file
  20. * \brief After Bridge Execution API
  21. *
  22. * \author Richard Mudgett <rmudgett@digium.com>
  23. *
  24. * See Also:
  25. * \arg \ref AstCREDITS
  26. */
  27. #ifndef _ASTERISK_BRIDGING_AFTER_H
  28. #define _ASTERISK_BRIDGING_AFTER_H
  29. #if defined(__cplusplus) || defined(c_plusplus)
  30. extern "C" {
  31. #endif
  32. /*! Reason the after bridge callback will not be called. */
  33. enum ast_bridge_after_cb_reason {
  34. /*! The datastore is being destroyed. Likely due to hangup. (Enum value must be zero.) */
  35. AST_BRIDGE_AFTER_CB_REASON_DESTROY,
  36. /*! Something else replaced the callback with another. */
  37. AST_BRIDGE_AFTER_CB_REASON_REPLACED,
  38. /*! The callback was removed because of a masquerade. (fixup) */
  39. AST_BRIDGE_AFTER_CB_REASON_MASQUERADE,
  40. /*! The channel was departed from the bridge. */
  41. AST_BRIDGE_AFTER_CB_REASON_DEPART,
  42. /*! Was explicitly removed by external code. */
  43. AST_BRIDGE_AFTER_CB_REASON_REMOVED,
  44. /*! The channel failed to enter the bridge. */
  45. AST_BRIDGE_AFTER_CB_REASON_IMPART_FAILED,
  46. };
  47. /*!
  48. * \brief Set channel to goto specific location after the bridge.
  49. * \since 12.0.0
  50. *
  51. * \param chan Channel to setup after bridge goto location.
  52. * \param context Context to goto after bridge.
  53. * \param exten Exten to goto after bridge.
  54. * \param priority Priority to goto after bridge.
  55. *
  56. * \note chan is locked by this function.
  57. *
  58. * \details Add a channel datastore to setup the goto location
  59. * when the channel leaves the bridge and run a PBX from there.
  60. *
  61. * \return Nothing
  62. */
  63. void ast_bridge_set_after_goto(struct ast_channel *chan, const char *context, const char *exten, int priority);
  64. /*!
  65. * \brief Set channel to run the h exten after the bridge.
  66. * \since 12.0.0
  67. *
  68. * \param chan Channel to setup after bridge goto location.
  69. * \param context Context to goto after bridge.
  70. *
  71. * \note chan is locked by this function.
  72. *
  73. * \details Add a channel datastore to setup the goto location
  74. * when the channel leaves the bridge and run a PBX from there.
  75. *
  76. * \return Nothing
  77. */
  78. void ast_bridge_set_after_h(struct ast_channel *chan, const char *context);
  79. /*!
  80. * \brief Set channel to go on in the dialplan after the bridge.
  81. * \since 12.0.0
  82. *
  83. * \param chan Channel to setup after bridge goto location.
  84. * \param context Current context of the caller channel.
  85. * \param exten Current exten of the caller channel.
  86. * \param priority Current priority of the caller channel
  87. * \param parseable_goto User specified goto string from dialplan.
  88. *
  89. * \note chan is locked by this function.
  90. *
  91. * \details Add a channel datastore to setup the goto location
  92. * when the channel leaves the bridge and run a PBX from there.
  93. *
  94. * If parseable_goto then use the given context/exten/priority
  95. * as the relative position for the parseable_goto.
  96. * Else goto the given context/exten/priority+1.
  97. *
  98. * \return Nothing
  99. */
  100. void ast_bridge_set_after_go_on(struct ast_channel *chan, const char *context, const char *exten, int priority, const char *parseable_goto);
  101. /*!
  102. * \brief Setup any after bridge goto location to begin execution.
  103. * \since 12.0.0
  104. *
  105. * \param chan Channel to setup after bridge goto location.
  106. *
  107. * \note chan is locked by this function.
  108. *
  109. * \details Pull off any after bridge goto location datastore and
  110. * setup for dialplan execution there.
  111. *
  112. * \retval 0 on success. The goto location is set for a PBX to run it.
  113. * \retval non-zero on error or no goto location.
  114. *
  115. * \note If the after bridge goto is set to run an h exten it is
  116. * run here immediately.
  117. */
  118. int ast_bridge_setup_after_goto(struct ast_channel *chan);
  119. /*!
  120. * \brief Run any after bridge callback.
  121. * \since 12.0.0
  122. *
  123. * \param chan Channel to run after bridge callback.
  124. *
  125. * \return Nothing
  126. */
  127. void ast_bridge_run_after_callback(struct ast_channel *chan);
  128. /*!
  129. * \brief Run discarding any after bridge callbacks.
  130. * \since 12.0.0
  131. *
  132. * \param chan Channel to run after bridge callback.
  133. *
  134. * \return Nothing
  135. */
  136. void ast_bridge_discard_after_callback(struct ast_channel *chan, enum ast_bridge_after_cb_reason reason);
  137. /*!
  138. * \brief Run a PBX on any after bridge goto location.
  139. * \since 12.0.0
  140. *
  141. * \param chan Channel to execute after bridge goto location.
  142. *
  143. * \note chan is locked by this function.
  144. *
  145. * \details Pull off any after bridge goto location datastore
  146. * and run a PBX at that location.
  147. *
  148. * \note On return, the chan pointer is no longer valid because
  149. * the channel has hung up.
  150. *
  151. * \return Nothing
  152. */
  153. void ast_bridge_run_after_goto(struct ast_channel *chan);
  154. /*!
  155. * \brief Discard channel after bridge goto location.
  156. * \since 12.0.0
  157. *
  158. * \param chan Channel to discard after bridge goto location.
  159. *
  160. * \note chan is locked by this function.
  161. *
  162. * \return Nothing
  163. */
  164. void ast_bridge_discard_after_goto(struct ast_channel *chan);
  165. /*!
  166. * \brief Read after bridge goto if it exists
  167. * \since 12.0.0
  168. *
  169. * \param chan Channel to read the after bridge goto parseable goto string from
  170. * \param buffer Buffer to write the after bridge goto data to
  171. * \param buf_size size of the buffer being written to
  172. */
  173. void ast_bridge_read_after_goto(struct ast_channel *chan, char *buffer, size_t buf_size);
  174. /*!
  175. * \brief After bridge callback failed.
  176. * \since 12.0.0
  177. *
  178. * \param reason Reason callback is failing.
  179. * \param data Extra data what setup the callback wanted to pass.
  180. *
  181. * \note Called when the channel leaves the bridging system or
  182. * is destroyed.
  183. *
  184. * \return Nothing
  185. */
  186. typedef void (*ast_bridge_after_cb_failed)(enum ast_bridge_after_cb_reason reason, void *data);
  187. /*!
  188. * \brief After bridge callback function.
  189. * \since 12.0.0
  190. *
  191. * \param chan Channel just leaving bridging system.
  192. * \param data Extra data what setup the callback wanted to pass.
  193. *
  194. * \return Nothing
  195. */
  196. typedef void (*ast_bridge_after_cb)(struct ast_channel *chan, void *data);
  197. /*!
  198. * \brief Setup an after bridge callback for when the channel leaves the bridging system.
  199. * \since 12.0.0
  200. *
  201. * \param chan Channel to setup an after bridge callback on.
  202. * \param callback Function to call when the channel leaves the bridging system.
  203. * \param failed Function to call when it will not be calling the callback.
  204. * \param data Extra data to pass with the callback.
  205. *
  206. * \note chan is locked by this function.
  207. *
  208. * \note failed is called when the channel leaves the bridging
  209. * system or is destroyed.
  210. *
  211. * \retval 0 on success.
  212. * \retval -1 on error.
  213. */
  214. int ast_bridge_set_after_callback(struct ast_channel *chan, ast_bridge_after_cb callback, ast_bridge_after_cb_failed failed, void *data);
  215. /*!
  216. * \brief Get a string representation of an after bridge callback reason
  217. * \since 12.0.0
  218. *
  219. * \param reason The reason to interpret to a string
  220. * \retval NULL Unrecognized reason
  221. * \retval non-NULL String representation of reason
  222. */
  223. const char *ast_bridge_after_cb_reason_string(enum ast_bridge_after_cb_reason reason);
  224. #if defined(__cplusplus) || defined(c_plusplus)
  225. }
  226. #endif
  227. #endif /* _ASTERISK_BRIDGING_H */