res_pjproject.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. /*
  2. * Asterisk -- An open source telephony toolkit.
  3. *
  4. * Copyright (C) 2016, Fairview 5 Engineering, LLC
  5. *
  6. * George Joseph <george.joseph@fairview5.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 _RES_PJPROJECT_H
  19. #define _RES_PJPROJECT_H
  20. #include <pj/types.h>
  21. #include <pj/pool.h>
  22. struct ast_sockaddr;
  23. /*! \brief Determines whether the res_pjproject module is loaded */
  24. #define CHECK_PJPROJECT_MODULE_LOADED() \
  25. do { \
  26. if (!ast_module_check("res_pjproject.so")) { \
  27. return AST_MODULE_LOAD_DECLINE; \
  28. } \
  29. } while(0)
  30. /*!
  31. * \brief Retrieve a pjproject build option
  32. *
  33. * \param option The build option requested
  34. * \param format_string A scanf-style format string to parse the option value into
  35. * \param ... Pointers to variables to receive the values parsed
  36. *
  37. * \retval The number of values parsed
  38. *
  39. * \since 13.8.0
  40. *
  41. * \note The option requested must be from those returned by pj_dump_config()
  42. * which can be displayed with the 'pjsip show buildopts' CLI command.
  43. *
  44. * <b>Sample Usage:</b>
  45. * \code
  46. *
  47. * int max_hostname;
  48. *
  49. * ast_sip_get_pjproject_buildopt("PJ_MAX_HOSTNAME", "%d", &max_hostname);
  50. *
  51. * \endcode
  52. *
  53. */
  54. int ast_pjproject_get_buildopt(char *option, char *format_string, ...) __attribute__((format(scanf, 2, 3)));
  55. /*!
  56. * \brief Begin PJPROJECT log interception for CLI output.
  57. * \since 13.8.0
  58. *
  59. * \param fd CLI file descriptior to send intercepted output.
  60. *
  61. * \note ast_pjproject_log_intercept_begin() and
  62. * ast_pjproject_log_intercept_end() must always be called
  63. * in pairs.
  64. *
  65. * \return Nothing
  66. */
  67. void ast_pjproject_log_intercept_begin(int fd);
  68. /*!
  69. * \brief End PJPROJECT log interception for CLI output.
  70. * \since 13.8.0
  71. *
  72. * \note ast_pjproject_log_intercept_begin() and
  73. * ast_pjproject_log_intercept_end() must always be called
  74. * in pairs.
  75. *
  76. * \return Nothing
  77. */
  78. void ast_pjproject_log_intercept_end(void);
  79. /*!
  80. * \brief Increment the res_pjproject reference count.
  81. *
  82. * This ensures graceful shutdown happens in the proper order.
  83. */
  84. void ast_pjproject_ref(void);
  85. /*!
  86. * \brief Decrement the res_pjproject reference count.
  87. *
  88. * This ensures graceful shutdown happens in the proper order.
  89. */
  90. void ast_pjproject_unref(void);
  91. /*!
  92. * \brief Initialize the caching pool factory.
  93. * \since 13.21.0
  94. *
  95. * \param cp Caching pool factory to initialize
  96. * \param policy Pool factory policy
  97. * \param max_capacity Total capacity to be retained in the cache. Zero disables caching.
  98. *
  99. * \return Nothing
  100. */
  101. void ast_pjproject_caching_pool_init(pj_caching_pool *cp,
  102. const pj_pool_factory_policy *policy, pj_size_t max_capacity);
  103. /*!
  104. * \brief Destroy caching pool factory and all cached pools.
  105. * \since 13.21.0
  106. *
  107. * \param cp Caching pool factory to destroy
  108. *
  109. * \return Nothing
  110. */
  111. void ast_pjproject_caching_pool_destroy(pj_caching_pool *cp);
  112. /*!
  113. * \brief Fill a pj_sockaddr from an ast_sockaddr
  114. * \since 13.24.0
  115. *
  116. * \param addr The source address to copy
  117. * \param pjaddr The target address to receive the copied address
  118. *
  119. * \retval 0 Success
  120. * \retval -1 Failure
  121. */
  122. int ast_sockaddr_to_pj_sockaddr(const struct ast_sockaddr *addr, pj_sockaddr *pjaddr);
  123. /*!
  124. * \brief Fill an ast_sockaddr from a pj_sockaddr
  125. * \since 13.24.0
  126. *
  127. * \param addr The target address to receive the copied address
  128. * \param pjaddr The source address to copy
  129. *
  130. * \retval 0 Success
  131. * \retval -1 Failure
  132. */
  133. int ast_sockaddr_from_pj_sockaddr(struct ast_sockaddr *addr, const pj_sockaddr *pjaddr);
  134. #endif /* _RES_PJPROJECT_H */