bridge_channel_internal.h 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. /*
  2. * Asterisk -- An open source telephony toolkit.
  3. *
  4. * Copyright (C) 2013 Digium, Inc.
  5. *
  6. * Matt Jordan <mjordan@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_PRIVATE_BRIDGING_CHANNEL_H
  19. #define _ASTERISK_PRIVATE_BRIDGING_CHANNEL_H
  20. /*!
  21. * \file
  22. * \brief Private Bridging Channel API
  23. *
  24. * \author Matt Jordan <mjordan@digium.com>
  25. *
  26. * A private API to manipulate channels in a bridge. These can be called on a channel in
  27. * a bridge by \ref bridge.c. These functions should not be called elsewhere, including
  28. * by other members of the Bridging API.
  29. *
  30. * See Also:
  31. * \arg \ref AstCREDITS
  32. * \arg \ref Ast
  33. */
  34. /*!
  35. * \internal
  36. * \brief Actions that can be taken on a channel in a bridge
  37. */
  38. enum bridge_channel_action_type {
  39. /*! Bridged channel is to send a DTMF stream out */
  40. BRIDGE_CHANNEL_ACTION_DTMF_STREAM,
  41. /*! Bridged channel is to indicate talking start */
  42. BRIDGE_CHANNEL_ACTION_TALKING_START,
  43. /*! Bridged channel is to indicate talking stop */
  44. BRIDGE_CHANNEL_ACTION_TALKING_STOP,
  45. /*! Bridge channel is to play the indicated sound file. */
  46. BRIDGE_CHANNEL_ACTION_PLAY_FILE,
  47. /*! Bridge channel is to run the indicated application. */
  48. BRIDGE_CHANNEL_ACTION_RUN_APP,
  49. /*! Bridge channel is to run the custom callback routine. */
  50. BRIDGE_CHANNEL_ACTION_CALLBACK,
  51. /*! Bridge channel is to get parked. */
  52. BRIDGE_CHANNEL_ACTION_PARK,
  53. /*! Bridge channel is to execute a blind transfer. */
  54. BRIDGE_CHANNEL_ACTION_BLIND_TRANSFER,
  55. /*! Bridge channel is to execute an attended transfer */
  56. BRIDGE_CHANNEL_ACTION_ATTENDED_TRANSFER,
  57. /*
  58. * Bridge actions put after this comment must never be put onto
  59. * the bridge_channel wr_queue because they have other resources
  60. * that must be freed.
  61. */
  62. /*! Bridge reconfiguration deferred technology destruction. */
  63. BRIDGE_CHANNEL_ACTION_DEFERRED_TECH_DESTROY = 1000,
  64. /*! Bridge deferred dissolving. */
  65. BRIDGE_CHANNEL_ACTION_DEFERRED_DISSOLVING,
  66. };
  67. /*!
  68. * \internal
  69. * \brief Allocate a new ao2 ref counted bridge_channel
  70. * \since 12.0.0
  71. *
  72. * \param bridge The bridge to make the bridge_channel for
  73. *
  74. * \retval NULL on error
  75. * \retval ao2 ref counted object on success
  76. */
  77. struct ast_bridge_channel *bridge_channel_internal_alloc(struct ast_bridge *bridge);
  78. /*!
  79. * \internal
  80. * \brief Settle owed events by the channel to the original bridge.
  81. * \since 12.0.0
  82. *
  83. * \param orig_bridge Original bridge the channel was in before leaving.
  84. * \param bridge_channel Channel that owes events to the original bridge.
  85. *
  86. * \note On entry, the orig_bridge is already locked.
  87. *
  88. * \return Nothing
  89. */
  90. void bridge_channel_settle_owed_events(struct ast_bridge *orig_bridge, struct ast_bridge_channel *bridge_channel);
  91. /*!
  92. * \internal
  93. * \brief Queue any deferred frames on the channel.
  94. * \since 13.17.0
  95. *
  96. * \param bridge_channel Channel that the deferred frames should be pulled from and queued to.
  97. *
  98. * \return Nothing
  99. */
  100. void bridge_channel_queue_deferred_frames(struct ast_bridge_channel *bridge_channel);
  101. /*!
  102. * \internal
  103. * \brief Push the bridge channel into its specified bridge.
  104. * \since 12.0.0
  105. *
  106. * \param bridge_channel Channel to push.
  107. *
  108. * \note A ref is not held by bridge_channel->swap when calling because the
  109. * push with swap happens immediately.
  110. *
  111. * \note On entry, bridge_channel->bridge is already locked.
  112. *
  113. * \retval 0 on success.
  114. * \retval -1 on failure. The channel did not get pushed.
  115. *
  116. * \note On failure the caller must call
  117. * ast_bridge_features_remove(bridge_channel->features, AST_BRIDGE_HOOK_REMOVE_ON_PULL);
  118. */
  119. int bridge_channel_internal_push(struct ast_bridge_channel *bridge_channel);
  120. /*!
  121. * \internal
  122. * \brief Push the bridge channel into its specified bridge.
  123. * \since 13.8.0
  124. *
  125. * \param bridge_channel Channel to push.
  126. * \param optimized non-zero if the push with swap is for an optimization.
  127. *
  128. * \note A ref is not held by bridge_channel->swap when calling because the
  129. * push with swap happens immediately.
  130. *
  131. * \note On entry, bridge_channel->bridge is already locked.
  132. *
  133. * \retval 0 on success.
  134. * \retval -1 on failure. The channel did not get pushed.
  135. *
  136. * \note On failure the caller must call
  137. * ast_bridge_features_remove(bridge_channel->features, AST_BRIDGE_HOOK_REMOVE_ON_PULL);
  138. */
  139. int bridge_channel_internal_push_full(struct ast_bridge_channel *bridge_channel, int optimized);
  140. /*!
  141. * \internal
  142. * \brief Pull the bridge channel out of its current bridge.
  143. * \since 12.0.0
  144. *
  145. * \param bridge_channel Channel to pull.
  146. *
  147. * \note On entry, bridge_channel->bridge is already locked.
  148. *
  149. * \return Nothing
  150. */
  151. void bridge_channel_internal_pull(struct ast_bridge_channel *bridge_channel);
  152. /*!
  153. * \brief Signal imparting threads to wake up.
  154. * \since 13.9.0
  155. *
  156. * \param chan Channel imparted that we need to signal.
  157. *
  158. * \return Nothing
  159. */
  160. void bridge_channel_impart_signal(struct ast_channel *chan);
  161. /*!
  162. * \internal
  163. * \brief Join the bridge_channel to the bridge (blocking)
  164. *
  165. * \param bridge_channel The Channel in the bridge
  166. *
  167. * \note The bridge_channel->swap holds a channel reference for the swap
  168. * channel going into the bridging system. The ref ensures that the swap
  169. * pointer is valid for the bridge subclass push callbacks. The pointer
  170. * will be NULL on return if the ref was consumed.
  171. *
  172. * \details
  173. * This API call puts the bridge_channel into the bridge and handles the
  174. * bridge_channel's processing of events while it is in the bridge. It
  175. * will return when the channel has been instructed to leave the bridge.
  176. *
  177. * \retval 0 bridge channel successfully joined the bridge
  178. * \retval -1 bridge channel failed to join the bridge
  179. */
  180. int bridge_channel_internal_join(struct ast_bridge_channel *bridge_channel);
  181. /*!
  182. * \internal
  183. * \brief Temporarily suspend a channel from a bridge, handing control over to some
  184. * other system
  185. *
  186. * \param bridge_channel The channel in the bridge
  187. * \note This function assumes that \ref bridge_channel is already locked
  188. */
  189. void bridge_channel_internal_suspend_nolock(struct ast_bridge_channel *bridge_channel);
  190. /*!
  191. * \internal
  192. * \brief Unsuspend a channel that was previously suspended
  193. *
  194. * \param bridge_channel The channel in the bridge
  195. * \note This function assumes that \ref bridge_channel is already locked
  196. */
  197. void bridge_channel_internal_unsuspend_nolock(struct ast_bridge_channel *bridge_channel);
  198. /*!
  199. * \internal
  200. * \brief Queue a blind transfer action on a transferee bridge channel
  201. *
  202. * This is only relevant for when a blind transfer is performed on a two-party
  203. * bridge. The transferee's bridge channel will have a blind transfer bridge
  204. * action queued onto it, resulting in the party being redirected to a new
  205. * destination
  206. *
  207. * \param transferee The channel to have the action queued on
  208. * \param exten The destination extension for the transferee
  209. * \param context The destination context for the transferee
  210. * \param hook Frame hook to attach to transferee
  211. *
  212. * \retval 0 on success.
  213. * \retval -1 on error.
  214. */
  215. int bridge_channel_internal_queue_blind_transfer(struct ast_channel *transferee,
  216. const char *exten, const char *context,
  217. transfer_channel_cb new_channel_cb, void *user_data);
  218. /*!
  219. * \internal
  220. * \brief Queue an attended transfer action on a transferee bridge channel
  221. *
  222. * This is only relevant for when an attended transfer is performed on a two-party
  223. * bridge. The transferee's bridge channel will have an attended transfer bridge
  224. * action queued onto it.
  225. *
  226. * \param transferee The channel to have the action queued on
  227. * \param unbridged_chan The unbridged channel who is the target of the attended
  228. * transfer
  229. *
  230. * \retval 0 on success.
  231. * \retval -1 on error.
  232. */
  233. int bridge_channel_internal_queue_attended_transfer(struct ast_channel *transferee,
  234. struct ast_channel *unbridged_chan);
  235. /*!
  236. * \internal
  237. * \brief Return whether or not the bridge_channel would allow optimization
  238. *
  239. * \retval 0 if optimization is not allowed
  240. * \retval non-zero if optimization is allowed
  241. */
  242. int bridge_channel_internal_allows_optimization(struct ast_bridge_channel *bridge_channel);
  243. #endif /* _ASTERISK_PRIVATE_BRIDGING_H */