bridge_features.h 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866
  1. /*
  2. * Asterisk -- An open source telephony toolkit.
  3. *
  4. * Copyright (C) 2009, Digium, Inc.
  5. *
  6. * Joshua Colp <jcolp@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 Channel Bridging API
  21. * \author Joshua Colp <jcolp@digium.com>
  22. */
  23. #ifndef _ASTERISK_BRIDGING_FEATURES_H
  24. #define _ASTERISK_BRIDGING_FEATURES_H
  25. #include "asterisk/channel.h"
  26. #if defined(__cplusplus) || defined(c_plusplus)
  27. extern "C" {
  28. #endif
  29. /*! \brief Flags used for bridge features */
  30. enum ast_bridge_feature_flags {
  31. /*! Upon channel hangup all bridge participants should be kicked out. */
  32. AST_BRIDGE_FLAG_DISSOLVE_HANGUP = (1 << 0),
  33. /*! The last channel to leave the bridge dissolves it. */
  34. AST_BRIDGE_FLAG_DISSOLVE_EMPTY = (1 << 1),
  35. /*! Move between bridging technologies as needed. */
  36. AST_BRIDGE_FLAG_SMART = (1 << 2),
  37. /*! Bridge channels cannot be merged from this bridge. */
  38. AST_BRIDGE_FLAG_MERGE_INHIBIT_FROM = (1 << 3),
  39. /*! Bridge channels cannot be merged to this bridge. */
  40. AST_BRIDGE_FLAG_MERGE_INHIBIT_TO = (1 << 4),
  41. /*! Bridge channels cannot be local channel swap optimized from this bridge. */
  42. AST_BRIDGE_FLAG_SWAP_INHIBIT_FROM = (1 << 5),
  43. /*! Bridge channels cannot be local channel swap optimized to this bridge. */
  44. AST_BRIDGE_FLAG_SWAP_INHIBIT_TO = (1 << 6),
  45. /*! Bridge channels can be moved to another bridge only by masquerade (ConfBridge) */
  46. AST_BRIDGE_FLAG_MASQUERADE_ONLY = (1 << 7),
  47. /*! Bridge does not allow transfers of channels out */
  48. AST_BRIDGE_FLAG_TRANSFER_PROHIBITED = (1 << 8),
  49. /*! Bridge transfers require transfer of entire bridge rather than individual channels */
  50. AST_BRIDGE_FLAG_TRANSFER_BRIDGE_ONLY = (1 << 9),
  51. };
  52. /*! \brief Flags used for per bridge channel features */
  53. enum ast_bridge_channel_feature_flags {
  54. /*! Upon channel hangup all bridge participants should be kicked out. */
  55. AST_BRIDGE_CHANNEL_FLAG_DISSOLVE_HANGUP = (1 << 0),
  56. /*! This channel leaves the bridge if all participants have this flag set. */
  57. AST_BRIDGE_CHANNEL_FLAG_LONELY = (1 << 1),
  58. /*! This channel cannot be moved to another bridge. */
  59. AST_BRIDGE_CHANNEL_FLAG_IMMOVABLE = (1 << 2),
  60. };
  61. /*! \brief Built in DTMF features */
  62. enum ast_bridge_builtin_feature {
  63. /*! DTMF based Blind Transfer */
  64. AST_BRIDGE_BUILTIN_BLINDTRANSFER,
  65. /*! DTMF based Attended Transfer */
  66. AST_BRIDGE_BUILTIN_ATTENDEDTRANSFER,
  67. /*!
  68. * DTMF based depart bridge feature
  69. *
  70. * \note Imparted channels are optionally hangup depending upon
  71. * how it was imparted.
  72. *
  73. * \note Joined channels exit the bridge with
  74. * BRIDGE_CHANNEL_STATE_END_WITH_DISSOLVE.
  75. */
  76. AST_BRIDGE_BUILTIN_HANGUP,
  77. /*!
  78. * DTMF based Park
  79. *
  80. * \details The bridge is parked and the channel hears the
  81. * parking slot to which it was parked.
  82. */
  83. AST_BRIDGE_BUILTIN_PARKCALL,
  84. /*!
  85. * DTMF one-touch-record toggle using Monitor app.
  86. *
  87. * \note Only valid on two party bridges.
  88. */
  89. AST_BRIDGE_BUILTIN_AUTOMON,
  90. /*!
  91. * DTMF one-touch-record toggle using MixMonitor app.
  92. *
  93. * \note Only valid on two party bridges.
  94. */
  95. AST_BRIDGE_BUILTIN_AUTOMIXMON,
  96. /*! End terminator for list of built in features. Must remain last. */
  97. AST_BRIDGE_BUILTIN_END
  98. };
  99. enum ast_bridge_builtin_interval {
  100. /*! Apply Call Duration Limits */
  101. AST_BRIDGE_BUILTIN_INTERVAL_LIMITS,
  102. /*! End terminator for list of built in interval features. Must remain last. */
  103. AST_BRIDGE_BUILTIN_INTERVAL_END
  104. };
  105. struct ast_bridge;
  106. struct ast_bridge_channel;
  107. /*!
  108. * \brief Hook callback type
  109. *
  110. * \param bridge_channel Channel executing the feature
  111. * \param hook_pvt Private data passed in when the hook was created
  112. *
  113. * For interval hooks:
  114. * \retval 0 Setup to fire again at the last interval.
  115. * \retval positive Setup to fire again at the new interval returned.
  116. * \retval -1 Remove the callback hook.
  117. *
  118. * For other hooks:
  119. * \retval 0 Keep the callback hook.
  120. * \retval -1 Remove the callback hook.
  121. */
  122. typedef int (*ast_bridge_hook_callback)(struct ast_bridge_channel *bridge_channel, void *hook_pvt);
  123. /*!
  124. * \brief Hook pvt destructor callback
  125. *
  126. * \param hook_pvt Private data passed in when the hook was created to destroy
  127. */
  128. typedef void (*ast_bridge_hook_pvt_destructor)(void *hook_pvt);
  129. /*!
  130. * \brief Talking indicator callback
  131. *
  132. * \details
  133. * This callback can be registered with the bridge channel in
  134. * order to receive updates when the bridge_channel has started
  135. * and stopped talking.
  136. *
  137. * \param bridge_channel Channel executing the feature
  138. * \param hook_pvt Private data passed in when the hook was created
  139. * \param talking TRUE if the channel is now talking
  140. *
  141. * \retval 0 Keep the callback hook.
  142. * \retval -1 Remove the callback hook.
  143. */
  144. typedef int (*ast_bridge_talking_indicate_callback)(struct ast_bridge_channel *bridge_channel, void *hook_pvt, int talking);
  145. /*!
  146. * \brief Move indicator callback
  147. *
  148. * \details
  149. * This callback can be registered with the bridge channel in order
  150. * to be notified when the bridge channel is being moved from one
  151. * bridge to another.
  152. *
  153. * \param bridge_channel The channel executing the feature
  154. * \param hook_pvt Private data passed in when the hook was created
  155. * \param src The bridge from which the bridge channel is moving
  156. * \param dst The bridge into which the bridge channel is moving
  157. *
  158. * \retval 0 Keep the callback hook.
  159. * \retval -1 Remove the callback hook.
  160. */
  161. typedef int (*ast_bridge_move_indicate_callback)(struct ast_bridge_channel *bridge_channel,
  162. void *hook_pvt, struct ast_bridge *src, struct ast_bridge *dst);
  163. enum ast_bridge_hook_remove_flags {
  164. /*! The hook is removed when the channel is pulled from the bridge. */
  165. AST_BRIDGE_HOOK_REMOVE_ON_PULL = (1 << 0),
  166. /*! The hook is removed when the bridge's personality changes. */
  167. AST_BRIDGE_HOOK_REMOVE_ON_PERSONALITY_CHANGE = (1 << 1),
  168. };
  169. enum ast_bridge_hook_type {
  170. /*! The hook type has not been specified. */
  171. AST_BRIDGE_HOOK_TYPE_NONE,
  172. AST_BRIDGE_HOOK_TYPE_DTMF,
  173. AST_BRIDGE_HOOK_TYPE_TIMER,
  174. AST_BRIDGE_HOOK_TYPE_HANGUP,
  175. AST_BRIDGE_HOOK_TYPE_JOIN,
  176. AST_BRIDGE_HOOK_TYPE_LEAVE,
  177. AST_BRIDGE_HOOK_TYPE_TALK,
  178. AST_BRIDGE_HOOK_TYPE_MOVE,
  179. };
  180. /*! \brief Structure that is the essence of a feature hook. */
  181. struct ast_bridge_hook {
  182. /*! Callback that is called when hook is tripped */
  183. ast_bridge_hook_callback callback;
  184. /*! Callback to destroy hook_pvt data right before destruction. */
  185. ast_bridge_hook_pvt_destructor destructor;
  186. /*! Unique data that was passed into us */
  187. void *hook_pvt;
  188. /*! Flags determining when hooks should be removed from a bridge channel */
  189. struct ast_flags remove_flags;
  190. /*! What kind of hook this is. */
  191. enum ast_bridge_hook_type type;
  192. };
  193. /*!
  194. * \brief Maximum length of a DTMF feature string
  195. */
  196. #define MAXIMUM_DTMF_FEATURE_STRING (11 + 1)
  197. /*! Extra parameters for a DTMF feature hook. */
  198. struct ast_bridge_hook_dtmf_parms {
  199. /*! DTMF String that is examined during a feature hook lookup */
  200. char code[MAXIMUM_DTMF_FEATURE_STRING];
  201. };
  202. /*! DTMF specific hook. */
  203. struct ast_bridge_hook_dtmf {
  204. /*! Generic feature hook information. */
  205. struct ast_bridge_hook generic;
  206. /*! Extra parameters for a DTMF feature hook. */
  207. struct ast_bridge_hook_dtmf_parms dtmf;
  208. };
  209. enum ast_bridge_hook_timer_option {
  210. /*! The timer temporarily affects media. (Like a custom playfile.) */
  211. AST_BRIDGE_HOOK_TIMER_OPTION_MEDIA = (1 << 0),
  212. };
  213. /*! Extra parameters for an interval timer hook. */
  214. struct ast_bridge_hook_timer_parms {
  215. /*! Time at which the hook should actually trip */
  216. struct timeval trip_time;
  217. /*! Heap index for interval hook */
  218. ssize_t heap_index;
  219. /*! Interval that the hook should execute at in milliseconds */
  220. unsigned int interval;
  221. /*! Sequence number for the hook to ensure expiration ordering */
  222. unsigned int seqno;
  223. /*! Option flags determining how callback is called. */
  224. unsigned int flags;
  225. };
  226. /*! Timer specific hook. */
  227. struct ast_bridge_hook_timer {
  228. /*! Generic feature hook information. */
  229. struct ast_bridge_hook generic;
  230. /*! Extra parameters for an interval timer hook. */
  231. struct ast_bridge_hook_timer_parms timer;
  232. };
  233. /*!
  234. * \brief Structure that contains features information
  235. */
  236. struct ast_bridge_features {
  237. /*! Attached DTMF feature hooks */
  238. struct ao2_container *dtmf_hooks;
  239. /*! Attached miscellaneous other hooks. */
  240. struct ao2_container *other_hooks;
  241. /*! Attached interval hooks */
  242. struct ast_heap *interval_hooks;
  243. /*! Feature flags that are enabled */
  244. struct ast_flags feature_flags;
  245. /*! Used to assign the sequence number to the next interval hook added. */
  246. unsigned int interval_sequence;
  247. /*! TRUE if feature_flags is setup */
  248. unsigned int usable:1;
  249. /*! TRUE if the channel/bridge is muted. */
  250. unsigned int mute:1;
  251. /*! TRUE if DTMF should be passed into the bridge tech. */
  252. unsigned int dtmf_passthrough:1;
  253. };
  254. /*!
  255. * \brief Structure that contains configuration information for the blind transfer built in feature
  256. */
  257. struct ast_bridge_features_blind_transfer {
  258. /*! Context to use for transfers (If not empty.) */
  259. char context[AST_MAX_CONTEXT];
  260. };
  261. /*!
  262. * \brief Structure that contains configuration information for the attended transfer built in feature
  263. */
  264. struct ast_bridge_features_attended_transfer {
  265. /*! Context to use for transfers (If not empty.) */
  266. char context[AST_MAX_CONTEXT];
  267. /*! DTMF string used to abort the transfer (If not empty.) */
  268. char abort[MAXIMUM_DTMF_FEATURE_STRING];
  269. /*! DTMF string used to turn the transfer into a three way conference (If not empty.) */
  270. char threeway[MAXIMUM_DTMF_FEATURE_STRING];
  271. /*! DTMF string used to complete the transfer (If not empty.) */
  272. char complete[MAXIMUM_DTMF_FEATURE_STRING];
  273. /*! DTMF string used to swap bridged targets (If not empty.) */
  274. char swap[MAXIMUM_DTMF_FEATURE_STRING];
  275. };
  276. enum ast_bridge_features_monitor {
  277. /*! Toggle start/stop of Monitor/MixMonitor. */
  278. AUTO_MONITOR_TOGGLE,
  279. /*! Start Monitor/MixMonitor if not already started. */
  280. AUTO_MONITOR_START,
  281. /*! Stop Monitor/MixMonitor if not already stopped. */
  282. AUTO_MONITOR_STOP,
  283. };
  284. struct ast_bridge_features_automonitor {
  285. /*! Start/Stop behavior. */
  286. enum ast_bridge_features_monitor start_stop;
  287. };
  288. struct ast_bridge_features_automixmonitor {
  289. /*! Start/Stop behavior. */
  290. enum ast_bridge_features_monitor start_stop;
  291. };
  292. /*!
  293. * \brief Structure that contains configuration information for the limits feature
  294. */
  295. struct ast_bridge_features_limits {
  296. AST_DECLARE_STRING_FIELDS(
  297. /*! Sound file to play when the maximum duration is reached (if empty, then nothing will be played) */
  298. AST_STRING_FIELD(duration_sound);
  299. /*! Sound file to play when the warning time is reached (if empty, then the remaining time will be played) */
  300. AST_STRING_FIELD(warning_sound);
  301. /*! Sound file to play when the call is first entered (if empty, then the remaining time will be played) */
  302. AST_STRING_FIELD(connect_sound);
  303. );
  304. /*! Time when the bridge will be terminated by the limits feature */
  305. struct timeval quitting_time;
  306. /*! Maximum duration that the channel is allowed to be in the bridge (specified in milliseconds) */
  307. unsigned int duration;
  308. /*! Duration into the call when warnings should begin (specified in milliseconds or 0 to disable) */
  309. unsigned int warning;
  310. /*! Interval between the warnings (specified in milliseconds or 0 to disable) */
  311. unsigned int frequency;
  312. };
  313. /*!
  314. * \brief Register a handler for a built in feature
  315. *
  316. * \param feature The feature that the handler will be responsible for
  317. * \param callback The callback function that will handle it
  318. * \param dtmf Default DTMF string used to activate the feature
  319. *
  320. * \retval 0 on success
  321. * \retval -1 on failure
  322. *
  323. * Example usage:
  324. *
  325. * \code
  326. * ast_bridge_features_register(AST_BRIDGE_BUILTIN_ATTENDED_TRANSFER, bridge_builtin_attended_transfer, "*1");
  327. * \endcode
  328. *
  329. * This registers the function bridge_builtin_attended_transfer as the function responsible for the built in
  330. * attended transfer feature.
  331. */
  332. int ast_bridge_features_register(enum ast_bridge_builtin_feature feature, ast_bridge_hook_callback callback, const char *dtmf);
  333. /*!
  334. * \brief Unregister a handler for a built in feature
  335. *
  336. * \param feature The feature to unregister
  337. *
  338. * \retval 0 on success
  339. * \retval -1 on failure
  340. *
  341. * Example usage:
  342. *
  343. * \code
  344. * ast_bridge_features_unregister(AST_BRIDGE_BUILTIN_ATTENDED_TRANSFER);
  345. * \endcode
  346. *
  347. * This unregisters the function that is handling the built in attended transfer feature.
  348. */
  349. int ast_bridge_features_unregister(enum ast_bridge_builtin_feature feature);
  350. /*!
  351. * \brief Invoke a built in feature hook now.
  352. *
  353. * \param feature The feature to invoke
  354. * \param bridge_channel Channel executing the feature
  355. * \param hook_pvt Private data passed in when the hook was created
  356. *
  357. * \note This API call is only meant to be used by bridge
  358. * subclasses and hook callbacks to request a builtin feature
  359. * hook to be executed.
  360. *
  361. * \retval 0 on success
  362. * \retval -1 on failure
  363. *
  364. * Example usage:
  365. *
  366. * \code
  367. * ast_bridge_features_do(AST_BRIDGE_BUILTIN_ATTENDED_TRANSFER, bridge_channel, hook_pvt);
  368. * \endcode
  369. */
  370. int ast_bridge_features_do(enum ast_bridge_builtin_feature feature, struct ast_bridge_channel *bridge_channel, void *hook_pvt);
  371. /*!
  372. * \brief Attach interval hooks to a bridge features structure
  373. *
  374. * \param features Bridge features structure
  375. * \param limits Configured limits applicable to the channel
  376. * \param remove_flags Dictates what situations the hook should be removed.
  377. *
  378. * \retval 0 on success
  379. * \retval -1 on failure
  380. */
  381. typedef int (*ast_bridge_builtin_set_limits_fn)(struct ast_bridge_features *features,
  382. struct ast_bridge_features_limits *limits, enum ast_bridge_hook_remove_flags remove_flags);
  383. /*!
  384. * \brief Register a handler for a built in interval feature
  385. *
  386. * \param interval The interval feature that the handler will be responsible for
  387. * \param callback the Callback function that will handle it
  388. *
  389. * \retval 0 on success
  390. * \retval -1 on failure
  391. *
  392. * Example usage:
  393. *
  394. * \code
  395. * ast_bridge_interval_register(AST_BRIDGE_BUILTIN_INTERVAL_LIMITS, bridge_builtin_set_limits);
  396. * \endcode
  397. *
  398. * This registers the function bridge_builtin_set_limits as the function responsible for the built in
  399. * duration limit feature.
  400. */
  401. int ast_bridge_interval_register(enum ast_bridge_builtin_interval interval, ast_bridge_builtin_set_limits_fn callback);
  402. /*!
  403. * \brief Unregisters a handler for a built in interval feature
  404. *
  405. * \param interval the interval feature to unregister
  406. *
  407. * \retval 0 on success
  408. * \retval -1 on failure
  409. *
  410. * Example usage:
  411. *
  412. * \code
  413. * ast_bridge_interval_unregister(AST_BRIDGE_BULTIN_INTERVAL_LIMITS)
  414. * /endcode
  415. *
  416. * This unregisters the function that is handling the built in duration limit feature.
  417. */
  418. int ast_bridge_interval_unregister(enum ast_bridge_builtin_interval interval);
  419. /*!
  420. * \brief Attach a bridge channel join hook to a bridge features structure
  421. *
  422. * \param features Bridge features structure
  423. * \param callback Function to execute upon activation
  424. * \param hook_pvt Unique data
  425. * \param destructor Optional destructor callback for hook_pvt data
  426. * \param remove_flags Dictates what situations the hook should be removed.
  427. *
  428. * \retval 0 on success
  429. * \retval -1 on failure (The caller must cleanup any hook_pvt resources.)
  430. *
  431. * Example usage:
  432. *
  433. * \code
  434. * struct ast_bridge_features features;
  435. * ast_bridge_features_init(&features);
  436. * ast_bridge_join_hook(&features, join_callback, NULL, NULL, 0);
  437. * \endcode
  438. *
  439. * This makes the bridging core call join_callback when a
  440. * channel successfully joins the bridging system. A pointer to
  441. * useful data may be provided to the hook_pvt parameter.
  442. */
  443. int ast_bridge_join_hook(struct ast_bridge_features *features,
  444. ast_bridge_hook_callback callback,
  445. void *hook_pvt,
  446. ast_bridge_hook_pvt_destructor destructor,
  447. enum ast_bridge_hook_remove_flags remove_flags);
  448. /*!
  449. * \brief Attach a bridge channel leave hook to a bridge features structure
  450. *
  451. * \param features Bridge features structure
  452. * \param callback Function to execute upon activation
  453. * \param hook_pvt Unique data
  454. * \param destructor Optional destructor callback for hook_pvt data
  455. * \param remove_flags Dictates what situations the hook should be removed.
  456. *
  457. * \retval 0 on success
  458. * \retval -1 on failure (The caller must cleanup any hook_pvt resources.)
  459. *
  460. * Example usage:
  461. *
  462. * \code
  463. * struct ast_bridge_features features;
  464. * ast_bridge_features_init(&features);
  465. * ast_bridge_leave_hook(&features, leave_callback, NULL, NULL, 0);
  466. * \endcode
  467. *
  468. * This makes the bridging core call leave_callback when a
  469. * channel successfully leaves the bridging system. A pointer
  470. * to useful data may be provided to the hook_pvt parameter.
  471. */
  472. int ast_bridge_leave_hook(struct ast_bridge_features *features,
  473. ast_bridge_hook_callback callback,
  474. void *hook_pvt,
  475. ast_bridge_hook_pvt_destructor destructor,
  476. enum ast_bridge_hook_remove_flags remove_flags);
  477. /*!
  478. * \brief Attach a hangup hook to a bridge features structure
  479. *
  480. * \param features Bridge features structure
  481. * \param callback Function to execute upon activation
  482. * \param hook_pvt Unique data
  483. * \param destructor Optional destructor callback for hook_pvt data
  484. * \param remove_flags Dictates what situations the hook should be removed.
  485. *
  486. * \retval 0 on success
  487. * \retval -1 on failure (The caller must cleanup any hook_pvt resources.)
  488. *
  489. * Example usage:
  490. *
  491. * \code
  492. * struct ast_bridge_features features;
  493. * ast_bridge_features_init(&features);
  494. * ast_bridge_hangup_hook(&features, hangup_callback, NULL, NULL, 0);
  495. * \endcode
  496. *
  497. * This makes the bridging core call hangup_callback if a
  498. * channel that has this hook hangs up. A pointer to useful
  499. * data may be provided to the hook_pvt parameter.
  500. */
  501. int ast_bridge_hangup_hook(struct ast_bridge_features *features,
  502. ast_bridge_hook_callback callback,
  503. void *hook_pvt,
  504. ast_bridge_hook_pvt_destructor destructor,
  505. enum ast_bridge_hook_remove_flags remove_flags);
  506. /*!
  507. * \brief Attach a DTMF hook to a bridge features structure
  508. *
  509. * \param features Bridge features structure
  510. * \param dtmf DTMF string to be activated upon
  511. * \param callback Function to execute upon activation
  512. * \param hook_pvt Unique data
  513. * \param destructor Optional destructor callback for hook_pvt data
  514. * \param remove_flags Dictates what situations the hook should be removed.
  515. *
  516. * \retval 0 on success
  517. * \retval -1 on failure (The caller must cleanup any hook_pvt resources.)
  518. *
  519. * Example usage:
  520. *
  521. * \code
  522. * struct ast_bridge_features features;
  523. * ast_bridge_features_init(&features);
  524. * ast_bridge_dtmf_hook(&features, "#", pound_callback, NULL, NULL, 0);
  525. * \endcode
  526. *
  527. * This makes the bridging core call pound_callback if a channel that has this
  528. * feature structure inputs the DTMF string '#'. A pointer to useful data may be
  529. * provided to the hook_pvt parameter.
  530. */
  531. int ast_bridge_dtmf_hook(struct ast_bridge_features *features,
  532. const char *dtmf,
  533. ast_bridge_hook_callback callback,
  534. void *hook_pvt,
  535. ast_bridge_hook_pvt_destructor destructor,
  536. enum ast_bridge_hook_remove_flags remove_flags);
  537. /*!
  538. * \brief Attach an interval hook to a bridge features structure
  539. *
  540. * \param features Bridge features structure
  541. * \param flags Interval timer callback option flags.
  542. * \param interval The interval that the hook should execute at in milliseconds
  543. * \param callback Function to execute upon activation
  544. * \param hook_pvt Unique data
  545. * \param destructor Optional destructor callback for hook_pvt data
  546. * \param remove_flags Dictates what situations the hook should be removed.
  547. *
  548. * \retval 0 on success
  549. * \retval -1 on failure (The caller must cleanup any hook_pvt resources.)
  550. *
  551. * \code
  552. * struct ast_bridge_features features;
  553. * ast_bridge_features_init(&features);
  554. * ast_bridge_interval_hook(&features, 1000, playback_callback, NULL, NULL, 0);
  555. * \endcode
  556. *
  557. * This makes the bridging core call playback_callback every second. A pointer to useful
  558. * data may be provided to the hook_pvt parameter.
  559. */
  560. int ast_bridge_interval_hook(struct ast_bridge_features *features,
  561. enum ast_bridge_hook_timer_option flags,
  562. unsigned int interval,
  563. ast_bridge_hook_callback callback,
  564. void *hook_pvt,
  565. ast_bridge_hook_pvt_destructor destructor,
  566. enum ast_bridge_hook_remove_flags remove_flags);
  567. /*!
  568. * \brief Attach a bridge channel talk detection hook to a bridge features structure
  569. *
  570. * \param features Bridge features structure
  571. * \param callback Function to execute upon activation
  572. * \param hook_pvt Unique data
  573. * \param destructor Optional destructor callback for hook_pvt data
  574. * \param remove_flags Dictates what situations the hook should be removed.
  575. *
  576. * \retval 0 on success
  577. * \retval -1 on failure (The caller must cleanup any hook_pvt resources.)
  578. *
  579. * Example usage:
  580. *
  581. * \code
  582. * struct ast_bridge_features features;
  583. * ast_bridge_features_init(&features);
  584. * ast_bridge_talk_hook(&features, talk_callback, NULL, NULL, 0);
  585. * \endcode
  586. *
  587. * This makes the bridging technology call talk_callback when a
  588. * channel is recognized as starting and stopping talking. A
  589. * pointer to useful data may be provided to the hook_pvt
  590. * parameter.
  591. *
  592. * \note This hook is currently only supported by softmix.
  593. */
  594. int ast_bridge_talk_detector_hook(struct ast_bridge_features *features,
  595. ast_bridge_talking_indicate_callback callback,
  596. void *hook_pvt,
  597. ast_bridge_hook_pvt_destructor destructor,
  598. enum ast_bridge_hook_remove_flags remove_flags);
  599. /*!
  600. * \brief Attach a bridge channel move detection hook to a bridge features structure
  601. *
  602. * \param features Bridge features structure
  603. * \param callback Function to execute upon activation
  604. * \param hook_pvt Unique data
  605. * \param destructor Optional destructor callback for hook_pvt data
  606. * \param remove_flags Dictates what situations the hook should be removed.
  607. *
  608. * \retval 0 on success
  609. * \retval -1 on failure (The caller must cleanup any hook_pvt resources.)
  610. *
  611. * Example usage:
  612. *
  613. * \code
  614. * struct ast_bridge_features features;
  615. * ast_bridge_features_init(&features);
  616. * ast_bridge_move_hook(&features, move_callback, NULL, NULL, 0);
  617. * \endcode
  618. *
  619. * This makes the bridging core call \ref callback when a
  620. * channel is moved from one bridge to another. A
  621. * pointer to useful data may be provided to the hook_pvt
  622. * parameter.
  623. */
  624. int ast_bridge_move_hook(struct ast_bridge_features *features,
  625. ast_bridge_move_indicate_callback callback,
  626. void *hook_pvt,
  627. ast_bridge_hook_pvt_destructor destructor,
  628. enum ast_bridge_hook_remove_flags remove_flags);
  629. /*!
  630. * \brief Enable a built in feature on a bridge features structure
  631. *
  632. * \param features Bridge features structure
  633. * \param feature Feature to enable
  634. * \param dtmf Optionally the DTMF stream to trigger the feature, if not specified it will be the default
  635. * \param config Configuration structure unique to the built in type
  636. * \param destructor Optional destructor callback for config data
  637. * \param remove_flags Dictates what situations the hook should be removed.
  638. *
  639. * \retval 0 on success
  640. * \retval -1 on failure
  641. *
  642. * Example usage:
  643. *
  644. * \code
  645. * struct ast_bridge_features features;
  646. * ast_bridge_features_init(&features);
  647. * ast_bridge_features_enable(&features, AST_BRIDGE_BUILTIN_ATTENDEDTRANSFER, NULL, NULL, 0);
  648. * \endcode
  649. *
  650. * This enables the attended transfer DTMF option using the default DTMF string. An alternate
  651. * string may be provided using the dtmf parameter. Internally this is simply setting up a hook
  652. * to a built in feature callback function.
  653. */
  654. int ast_bridge_features_enable(struct ast_bridge_features *features,
  655. enum ast_bridge_builtin_feature feature,
  656. const char *dtmf,
  657. void *config,
  658. ast_bridge_hook_pvt_destructor destructor,
  659. enum ast_bridge_hook_remove_flags remove_flags);
  660. /*!
  661. * \brief Constructor function for ast_bridge_features_limits
  662. *
  663. * \param limits pointer to a ast_bridge_features_limits struct that has been allocted, but not initialized
  664. *
  665. * \retval 0 on success
  666. * \retval -1 on failure
  667. */
  668. int ast_bridge_features_limits_construct(struct ast_bridge_features_limits *limits);
  669. /*!
  670. * \brief Destructor function for ast_bridge_features_limits
  671. *
  672. * \param limits pointer to an ast_bridge_features_limits struct that needs to be destroyed
  673. *
  674. * This function does not free memory allocated to the ast_bridge_features_limits struct, it only frees elements within the struct.
  675. * You must still call ast_free on the struct if you allocated it with malloc.
  676. */
  677. void ast_bridge_features_limits_destroy(struct ast_bridge_features_limits *limits);
  678. /*!
  679. * \brief Limit the amount of time a channel may stay in the bridge and optionally play warning messages as time runs out
  680. *
  681. * \param features Bridge features structure
  682. * \param limits Configured limits applicable to the channel
  683. * \param remove_flags Dictates what situations the hook should be removed.
  684. *
  685. * \retval 0 on success
  686. * \retval -1 on failure
  687. *
  688. * Example usage:
  689. *
  690. * \code
  691. * struct ast_bridge_features features;
  692. * struct ast_bridge_features_limits limits;
  693. * ast_bridge_features_init(&features);
  694. * ast_bridge_features_limits_construct(&limits);
  695. * ast_bridge_features_set_limits(&features, &limits, 0);
  696. * ast_bridge_features_limits_destroy(&limits);
  697. * \endcode
  698. *
  699. * This sets the maximum time the channel can be in the bridge to 10 seconds and does not play any warnings.
  700. *
  701. * \note This API call can only be used on a features structure that will be used in association with a bridge channel.
  702. * \note The ast_bridge_features_limits structure must remain accessible for the lifetime of the features structure.
  703. */
  704. int ast_bridge_features_set_limits(struct ast_bridge_features *features, struct ast_bridge_features_limits *limits, enum ast_bridge_hook_remove_flags remove_flags);
  705. /*!
  706. * \brief Set a flag on a bridge channel features structure
  707. *
  708. * \param features Bridge channel features structure
  709. * \param flag Flag to enable
  710. *
  711. * \return Nothing
  712. *
  713. * Example usage:
  714. *
  715. * \code
  716. * struct ast_bridge_features features;
  717. * ast_bridge_features_init(&features);
  718. * ast_bridge_features_set_flag(&features, AST_BRIDGE_CHANNEL_FLAG_DISSOLVE_HANGUP);
  719. * \endcode
  720. *
  721. * This sets the AST_BRIDGE_CHANNEL_FLAG_DISSOLVE_HANGUP feature
  722. * to be enabled on the features structure 'features'.
  723. */
  724. void ast_bridge_features_set_flag(struct ast_bridge_features *features, unsigned int flag);
  725. /*!
  726. * \brief Merge one ast_bridge_features into another
  727. *
  728. * \param into The ast_bridge_features that will be merged into
  729. * \param from The ast_bridge_features that will be merged from
  730. */
  731. void ast_bridge_features_merge(struct ast_bridge_features *into, const struct ast_bridge_features *from);
  732. /*!
  733. * \brief Initialize bridge features structure
  734. *
  735. * \param features Bridge featues structure
  736. *
  737. * \retval 0 on success
  738. * \retval -1 on failure
  739. *
  740. * Example usage:
  741. *
  742. * \code
  743. * struct ast_bridge_features features;
  744. * ast_bridge_features_init(&features);
  745. * \endcode
  746. *
  747. * This initializes the feature structure 'features' to have nothing enabled.
  748. *
  749. * \note This MUST be called before enabling features or flags. Failure to do so
  750. * may result in a crash.
  751. */
  752. int ast_bridge_features_init(struct ast_bridge_features *features);
  753. /*!
  754. * \brief Clean up the contents of a bridge features structure
  755. *
  756. * \param features Bridge features structure
  757. *
  758. * \return Nothing
  759. *
  760. * Example usage:
  761. *
  762. * \code
  763. * struct ast_bridge_features features;
  764. * ast_bridge_features_init(&features);
  765. * ast_bridge_features_cleanup(&features);
  766. * \endcode
  767. *
  768. * This cleans up the feature structure 'features'.
  769. *
  770. * \note This MUST be called after the features structure is done being used
  771. * or a memory leak may occur.
  772. */
  773. void ast_bridge_features_cleanup(struct ast_bridge_features *features);
  774. /*!
  775. * \brief Allocate a new bridge features struct.
  776. * \since 12.0.0
  777. *
  778. * Example usage:
  779. *
  780. * \code
  781. * struct ast_bridge_features *features;
  782. * features = ast_bridge_features_new();
  783. * ast_bridge_features_destroy(features);
  784. * \endcode
  785. *
  786. * \retval features New allocated features struct.
  787. * \retval NULL on error.
  788. */
  789. struct ast_bridge_features *ast_bridge_features_new(void);
  790. /*!
  791. * \brief Destroy an allocated bridge features struct.
  792. * \since 12.0.0
  793. *
  794. * \param features Bridge features structure
  795. *
  796. * Example usage:
  797. *
  798. * \code
  799. * struct ast_bridge_features *features;
  800. * features = ast_bridge_features_new();
  801. * ast_bridge_features_destroy(features);
  802. * \endcode
  803. *
  804. * \return Nothing
  805. */
  806. void ast_bridge_features_destroy(struct ast_bridge_features *features);
  807. #if defined(__cplusplus) || defined(c_plusplus)
  808. }
  809. #endif
  810. #endif /* _ASTERISK_BRIDGING_FEATURES_H */