sip_ua_layer.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. /*
  2. * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
  3. * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  18. */
  19. #ifndef __PJSIP_SIP_UA_LAYER_H__
  20. #define __PJSIP_SIP_UA_LAYER_H__
  21. /**
  22. * @file sip_ua_layer.h
  23. * @brief SIP User Agent Layer Module
  24. */
  25. #include <pjsip/sip_types.h>
  26. PJ_BEGIN_DECL
  27. /**
  28. * @defgroup PJSIP_UA Base User Agent Layer/Common Dialog Layer
  29. * @brief Dialog management.
  30. *
  31. * This module provides basic dialog management, which is used by higher
  32. * layer dialog usages such as INVITE sessions and SIP Event Subscription
  33. * framework (RFC 3265). Application should link with <b>pjsip-core</b>
  34. * library to use this base UA layer. The base UA layer module is initialized
  35. * with #pjsip_ua_init_module().
  36. */
  37. /**
  38. * @defgroup PJSUA_UA SIP User Agent Module
  39. * @ingroup PJSIP_UA
  40. * @brief Provides dialog management.
  41. * @{
  42. *
  43. * Application MUST initialize the user agent layer module by calling
  44. * #pjsip_ua_init_module() before using any of the dialog API, and link
  45. * the application with with <b>pjsip-core</b> library.
  46. */
  47. /** User agent initialization parameter. */
  48. typedef struct pjsip_ua_init_param
  49. {
  50. /** Callback to be called when the UA layer detects that outgoing
  51. * dialog has forked.
  52. */
  53. pjsip_dialog* (*on_dlg_forked)(pjsip_dialog *first_set, pjsip_rx_data *res);
  54. } pjsip_ua_init_param;
  55. /**
  56. * Initialize user agent layer and register it to the specified endpoint.
  57. *
  58. * @param endpt The endpoint where the user agent will be
  59. * registered.
  60. * @param prm UA initialization parameter.
  61. *
  62. * @return PJ_SUCCESS on success.
  63. */
  64. PJ_DECL(pj_status_t) pjsip_ua_init_module(pjsip_endpoint *endpt,
  65. const pjsip_ua_init_param *prm);
  66. /**
  67. * Get the instance of the user agent.
  68. *
  69. * @return The user agent module instance.
  70. */
  71. PJ_DECL(pjsip_user_agent*) pjsip_ua_instance(void);
  72. /**
  73. * Retrieve the current number of dialog-set currently registered
  74. * in the hash table. Note that dialog-set is different than dialog
  75. * when the request forks. In this case, all dialogs created from
  76. * the original request will belong to the same dialog set. When
  77. * no forking occurs, the number of dialog sets will be equal to
  78. * the number of dialogs.
  79. *
  80. * @return Number of dialog sets.
  81. */
  82. PJ_DECL(pj_uint32_t) pjsip_ua_get_dlg_set_count(void);
  83. /**
  84. * Find a dialog with the specified Call-ID and tags properties. This
  85. * function may optionally lock the matching dialog instance before
  86. * returning it back to the caller.
  87. *
  88. * @param call_id The call ID to be matched.
  89. * @param local_tag The local tag to be matched.
  90. * @param remote_tag The remote tag to be matched.
  91. * @param lock_dialog If non-zero, instruct the function to lock the
  92. * matching dialog with #pjsip_dlg_inc_lock().
  93. * Application is responsible to release the dialog's
  94. * lock after it has finished manipulating the dialog,
  95. * by calling #pjsip_dlg_dec_lock().
  96. *
  97. * @return The matching dialog instance, or NULL if no matching
  98. * dialog is found.
  99. */
  100. PJ_DECL(pjsip_dialog*) pjsip_ua_find_dialog(const pj_str_t *call_id,
  101. const pj_str_t *local_tag,
  102. const pj_str_t *remote_tag,
  103. pj_bool_t lock_dialog);
  104. /**
  105. * Destroy the user agent layer.
  106. *
  107. * @return PJ_SUCCESS on success.
  108. */
  109. PJ_DECL(pj_status_t) pjsip_ua_destroy(void);
  110. /**
  111. * Dump user agent contents (e.g. all dialogs).
  112. *
  113. * @param detail If non-zero, list of dialogs will be printed.
  114. */
  115. PJ_DECL(void) pjsip_ua_dump(pj_bool_t detail);
  116. /**
  117. * Get the endpoint instance of a user agent module.
  118. *
  119. * @param ua The user agent instance.
  120. *
  121. * @return The endpoint instance where the user agent is
  122. * registered.
  123. */
  124. PJ_DECL(pjsip_endpoint*) pjsip_ua_get_endpt(pjsip_user_agent *ua);
  125. /**
  126. * @}
  127. */
  128. /** Internal (called by sip_dialog.c). */
  129. PJ_DECL(pj_status_t) pjsip_ua_register_dlg( pjsip_user_agent *ua,
  130. pjsip_dialog *dlg );
  131. /** Internal (called by sip_dialog.c). */
  132. PJ_DECL(pj_status_t) pjsip_ua_unregister_dlg(pjsip_user_agent *ua,
  133. pjsip_dialog *dlg );
  134. PJ_END_DECL
  135. #endif /* __PJSIP_SIP_UA_LAYER_H__ */