core_local.h 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  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 Local proxy channel special access.
  21. *
  22. * \author Richard Mudgett <rmudgett@digium.com>
  23. *
  24. * See Also:
  25. * \arg \ref AstCREDITS
  26. */
  27. #ifndef _ASTERISK_CORE_LOCAL_H
  28. #define _ASTERISK_CORE_LOCAL_H
  29. #if defined(__cplusplus) || defined(c_plusplus)
  30. extern "C" {
  31. #endif
  32. /* Forward declare some struct names */
  33. struct ast_channel;
  34. struct ast_bridge;
  35. struct ast_bridge_features;
  36. struct stasis_message_type;
  37. /* ------------------------------------------------------------------- */
  38. /*!
  39. * \brief Lock the "chan" and "owner" channels (and return them) on the base
  40. * private structure as well as the base private structure itself.
  41. *
  42. * \deprecated - *DO NOT USE* Please use ast_local_lock_all2 instead.
  43. *
  44. * \note This also adds references to each of the above mentioned elements and
  45. * also the underlying private local structure.
  46. * \note None of these locks should be held prior to calling this function.
  47. * \note To undo this process call ast_local_unlock_all.
  48. *
  49. * \since 13.8.0
  50. *
  51. * \param chan Must be a local channel
  52. * \param outchan The local channel's "chan" channel
  53. * \param outowner The local channel's "owner" channel
  54. */
  55. void ast_local_lock_all(struct ast_channel *chan, struct ast_channel **outchan,
  56. struct ast_channel **outowner);
  57. /*!
  58. * \brief Add a reference to the local channel's private tech, lock the local channel's
  59. * private base, and add references and lock both sides of the local channel.
  60. *
  61. * \note None of these locks should be held prior to calling this function.
  62. * \note To undo this process call ast_local_unlock_all2.
  63. *
  64. * \since 13.17.0, 14.6.0
  65. *
  66. * \param chan Must be a local channel
  67. * \param tech_pvt [out] channel's private tech (ref and lock added)
  68. * \param base_chan [out] One side of the local channel (ref and lock added)
  69. * \param base_owner [out] Other side of the local channel (ref and lock added)
  70. */
  71. void ast_local_lock_all2(struct ast_channel *chan, void **tech_pvt,
  72. struct ast_channel **base_chan, struct ast_channel **base_owner);
  73. /*!
  74. * \brief Unlock the "chan" and "owner" channels on the base private structure
  75. * as well as the base private structure itself.
  76. *
  77. * \deprecated - *DO NOT USE* Please use ast_local_unlock_all2 instead.
  78. *
  79. * \note This also removes references to each of the above mentioned elements and
  80. * also the underlying private local structure.
  81. * \note This function should be used in conjunction with ast_local_lock_all.
  82. *
  83. * \since 13.8.0
  84. *
  85. * \param chan Must be a local channel
  86. */
  87. void ast_local_unlock_all(struct ast_channel *chan);
  88. /*!
  89. * \brief Remove a reference to the given local channel's private tech, unlock the given
  90. * local channel's private base, and remove references and unlock both sides of
  91. * given the local channel.
  92. *
  93. * \note This function should be used in conjunction with ast_local_lock_all2.
  94. *
  95. * \since 13.17.0, 14.6.0
  96. *
  97. * \param tech_pvt channel's private tech (ref and lock removed)
  98. * \param base_chan One side of the local channel (ref and lock removed)
  99. * \param base_owner Other side of the local channel (ref and lock removed)
  100. */
  101. void ast_local_unlock_all2(void *tech_pvt, struct ast_channel *base_chan,
  102. struct ast_channel *base_owner);
  103. /*!
  104. * \brief Get the other local channel in the pair.
  105. * \since 12.0.0
  106. *
  107. * \param ast Local channel to get peer.
  108. *
  109. * \note On entry, ast must be locked.
  110. *
  111. * \retval peer reffed on success.
  112. * \retval NULL if no peer or error.
  113. */
  114. struct ast_channel *ast_local_get_peer(struct ast_channel *ast);
  115. /*!
  116. * \brief Setup the outgoing local channel to join a bridge on ast_call().
  117. * \since 12.0.0
  118. *
  119. * \param ast Either channel of a local channel pair.
  120. * \param bridge Bridge to join.
  121. * \param swap Channel to swap with when joining.
  122. * \param features Bridge features structure.
  123. *
  124. * \note The features parameter must be NULL or obtained by
  125. * ast_bridge_features_new(). You must not dereference features
  126. * after calling even if the call fails.
  127. *
  128. * \note Intended to be called after ast_request() and before
  129. * ast_call() on a local channel.
  130. *
  131. * \retval 0 on success.
  132. * \retval -1 on error.
  133. */
  134. int ast_local_setup_bridge(struct ast_channel *ast, struct ast_bridge *bridge, struct ast_channel *swap, struct ast_bridge_features *features);
  135. /*!
  136. * \brief Setup the outgoing local channel to masquerade into a channel on ast_call().
  137. * \since 12.0.0
  138. *
  139. * \param ast Either channel of a local channel pair.
  140. * \param masq Channel to masquerade into.
  141. *
  142. * \note Intended to be called after ast_request() and before
  143. * ast_call() on a local channel.
  144. *
  145. * \retval 0 on success.
  146. * \retval -1 on error.
  147. */
  148. int ast_local_setup_masquerade(struct ast_channel *ast, struct ast_channel *masq);
  149. /* ------------------------------------------------------------------- */
  150. /*!
  151. * \brief Message type for when two local channel halves are bridged together
  152. * \since 12.0.0
  153. *
  154. * \note Payloads for the \ref ast_local_bridge_type are a \ref ast_multi_channel_blob.
  155. * Roles for the channels in the \ref ast_multi_channel_blob are "1" and "2", reflecting
  156. * the two halves. Unlike most other bridges, the 'bridge' between two local channels is
  157. * not part of the bridge framework; as such, the message simply references the two local
  158. * channel halves that are now bridged.
  159. *
  160. * \retval A \ref stasis message type
  161. */
  162. struct stasis_message_type *ast_local_bridge_type(void);
  163. /*!
  164. * \brief Message type for when a local channel optimization begins
  165. * \since 12.0.0
  166. *
  167. * \note Payloads for the \ref ast_local_optimization_begin_type are a
  168. * \ref ast_multi_channel_blob. Roles for the channels in the \ref ast_multi_channel_blob
  169. * are "1" and "2", reflecting the two halves.
  170. *
  171. * \retval A \ref stasis message type
  172. */
  173. struct stasis_message_type *ast_local_optimization_begin_type(void);
  174. /*!
  175. * \brief Message type for when a local channel optimization completes
  176. * \since 12.0.0
  177. *
  178. * \note Payloads for the \ref ast_local_optimization_end_type are a
  179. * \ref ast_multi_channel_blob. Roles for the channels in the \ref ast_multi_channel_blob
  180. * are "1" and "2", reflecting the two halves.
  181. *
  182. * \retval A \ref stasis message type
  183. */
  184. struct stasis_message_type *ast_local_optimization_end_type(void);
  185. #if defined(__cplusplus) || defined(c_plusplus)
  186. }
  187. #endif
  188. #endif /* _ASTERISK_CORE_LOCAL_H */