sip_xfer.h 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  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_XFER_H__
  20. #define __PJSIP_XFER_H__
  21. /**
  22. * @file sip_xfer.h
  23. * @brief SIP Transfer (REFER, RFC 3515)
  24. */
  25. #include <pjsip-simple/evsub.h>
  26. #include <pjsip/sip_msg.h>
  27. /**
  28. * @defgroup PJSUA_XFER SIP REFER (RFC 3515) for Call Transfer etc.
  29. * @ingroup PJSIP_HIGH_UA
  30. * @brief SIP REFER dialog usage (call transfer, etc.)
  31. * @{
  32. *
  33. * This describes a generic handling of SIP REFER request. The SIP REFER
  34. * request is described in RFC 3515, and commonly used to perform call
  35. * transfer functionality. Other types of SIP REFER usages are described
  36. * in draft-worley-sip-many-refers-00 draft, for example:
  37. * - Remote Dial: where UAC sends REFER to instruct REFER recipient to
  38. * initiate an INVITE session to some target.
  39. *
  40. * A REFER request can be sent inside or outside existing dialog context,
  41. * although for call transfer case, it is more common to send REFER inside
  42. * existing INVITE session context. PJSIP supports both sending REFER request
  43. * inside or outside dialog context.
  44. *
  45. * The REFER framework uses @ref PJSIP_EVENT_NOT to manage the event
  46. * subscription created by the REFER request. Because of this, application
  47. * must link with <b>pjsip-ua</b> AND <b>pjsip-simple</b> static libraries
  48. * to use REFER functionality.
  49. *
  50. * Reference:
  51. * - <A HREF="http://www.ietf.org/rfc/rfc3515.txt">RFC 3515: The Session
  52. * Initiation Protocol (SIP) Refer Method</A>
  53. * - @ref PJSIP_EVENT_NOT
  54. */
  55. PJ_BEGIN_DECL
  56. /** Declaration for REFER method constant. */
  57. PJ_DECL_DATA(const pjsip_method) pjsip_refer_method;
  58. /** Get REFER method constant */
  59. PJ_DECL(const pjsip_method*) pjsip_get_refer_method(void);
  60. /**
  61. * Initialize the REFER subsystem.
  62. * This currently does very little (only register REFER as supported method).
  63. */
  64. PJ_DECL(pj_status_t) pjsip_xfer_init_module(pjsip_endpoint *endpt);
  65. /**
  66. * Create transferer (sender of REFER request).
  67. *
  68. * @param dlg The underlying dialog to use.
  69. * @param user_cb Pointer to callbacks to receive presence subscription
  70. * events.
  71. * @param p_evsub Pointer to receive the presence subscription
  72. * session.
  73. *
  74. * @return PJ_SUCCESS on success.
  75. */
  76. PJ_DECL(pj_status_t) pjsip_xfer_create_uac( pjsip_dialog *dlg,
  77. const pjsip_evsub_user *user_cb,
  78. pjsip_evsub **p_evsub );
  79. /**
  80. * Create transferee (receiver of REFER request).
  81. *
  82. * @param dlg The underlying dialog to use.
  83. * @param user_cb Pointer to callbacks to receive presence subscription
  84. * events.
  85. * @param rdata The incoming SUBSCRIBE request that creates the event
  86. * subscription.
  87. * @param p_evsub Pointer to receive the presence subscription
  88. * session.
  89. *
  90. * @return PJ_SUCCESS on success.
  91. */
  92. PJ_DECL(pj_status_t) pjsip_xfer_create_uas( pjsip_dialog *dlg,
  93. const pjsip_evsub_user *user_cb,
  94. pjsip_rx_data *rdata,
  95. pjsip_evsub **p_evsub );
  96. /**
  97. * Call this function to create request to initiate REFER subscription,
  98. * to refresh subscription, or to unsubscribe. For request other than
  99. * the initial REFER request, "refer_to_uri" argument may be NULL.
  100. *
  101. * @param sub Client subscription instance.
  102. * @param refer_to_uri URI to be put to the Refer-To header. This argument
  103. * may be NULL for subsequent REFER requests.
  104. * @param p_tdata Pointer to receive the request.
  105. *
  106. * @return PJ_SUCCESS on success.
  107. */
  108. PJ_DECL(pj_status_t) pjsip_xfer_initiate( pjsip_evsub *sub,
  109. const pj_str_t *refer_to_uri,
  110. pjsip_tx_data **p_tdata);
  111. /**
  112. * Accept the incoming REFER request by sending 2xx response.
  113. *
  114. * @param sub Server subscription instance.
  115. * @param rdata The incoming subscription request message.
  116. * @param st_code Status code, which MUST be 2xx.
  117. * @param hdr_list Optional list of headers to be added in the response.
  118. *
  119. * @return PJ_SUCCESS on success.
  120. */
  121. PJ_DECL(pj_status_t) pjsip_xfer_accept( pjsip_evsub *sub,
  122. pjsip_rx_data *rdata,
  123. int st_code,
  124. const pjsip_hdr *hdr_list );
  125. /**
  126. * For notifier, create NOTIFY request to subscriber, and set the state
  127. * of the subscription.
  128. *
  129. * @param sub The server subscription (notifier) instance.
  130. * @param state New state to set.
  131. * @param xfer_st_code The call status code to be reported with the NOTIFY
  132. * request.
  133. * @param xfer_st_text Optional call status text to be reported with the
  134. * NOTIFY request. If the value is NULL, default
  135. * status text will be used.
  136. * @param p_tdata Pointer to receive the request.
  137. *
  138. * @return PJ_SUCCESS on success.
  139. */
  140. PJ_DECL(pj_status_t) pjsip_xfer_notify( pjsip_evsub *sub,
  141. pjsip_evsub_state state,
  142. int xfer_st_code,
  143. const pj_str_t *xfer_st_text,
  144. pjsip_tx_data **p_tdata);
  145. /**
  146. * Create NOTIFY request to reflect current subscription status. Application
  147. * can only call this function after it has sent NOTIFY before.
  148. * This will also re-send the last "message/sipfrag" body that was sent
  149. * in the previous NOTIFY.
  150. *
  151. * @param sub Server subscription object.
  152. * @param p_tdata Pointer to receive request.
  153. *
  154. * @return PJ_SUCCESS on success.
  155. */
  156. PJ_DECL(pj_status_t) pjsip_xfer_current_notify( pjsip_evsub *sub,
  157. pjsip_tx_data **p_tdata );
  158. /**
  159. * Send request message that was previously created with initiate(), notify(),
  160. * or current_notify(). Application may also send request created with other
  161. * functions, e.g. authentication. But the request MUST be either request
  162. * that creates/refresh subscription or NOTIFY request.
  163. *
  164. *
  165. * @param sub The event subscription object.
  166. * @param tdata Request message to be send.
  167. *
  168. * @return PJ_SUCCESS on success.
  169. */
  170. PJ_DECL(pj_status_t) pjsip_xfer_send_request( pjsip_evsub *sub,
  171. pjsip_tx_data *tdata);
  172. PJ_END_DECL
  173. /**
  174. * @}
  175. */
  176. #endif /* __PJSIP_XFER_H__ */