Tristan Matthews | 0a329cc | 2013-07-17 13:20:14 -0400 | [diff] [blame] | 1 | /* $Id$ */ |
| 2 | /* |
| 3 | * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com) |
| 4 | * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org> |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; either version 2 of the License, or |
| 9 | * (at your option) any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program; if not, write to the Free Software |
| 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 19 | */ |
| 20 | #ifndef __PJSIP_XFER_H__ |
| 21 | #define __PJSIP_XFER_H__ |
| 22 | |
| 23 | |
| 24 | |
| 25 | /** |
| 26 | * @file sip_xfer.h |
| 27 | * @brief SIP Transfer (REFER, RFC 3515) |
| 28 | */ |
| 29 | #include <pjsip-simple/evsub.h> |
| 30 | #include <pjsip/sip_msg.h> |
| 31 | |
| 32 | /** |
| 33 | * @defgroup PJSUA_XFER SIP REFER (RFC 3515) for Call Transfer etc. |
| 34 | * @ingroup PJSIP_HIGH_UA |
| 35 | * @brief SIP REFER dialog usage (call transfer, etc.) |
| 36 | * @{ |
| 37 | * |
| 38 | * This describes a generic handling of SIP REFER request. The SIP REFER |
| 39 | * request is described in RFC 3515, and commonly used to perform call |
| 40 | * transfer functionality. Other types of SIP REFER usages are described |
| 41 | * in draft-worley-sip-many-refers-00 draft, for example: |
| 42 | * - Remote Dial: where UAC sends REFER to instruct REFER recipient to |
| 43 | * initiate an INVITE session to some target. |
| 44 | * |
| 45 | * A REFER request can be sent inside or outside existing dialog context, |
| 46 | * although for call transfer case, it is more common to send REFER inside |
| 47 | * existing INVITE session context. PJSIP supports both sending REFER request |
| 48 | * inside or outside dialog context. |
| 49 | * |
| 50 | * The REFER framework uses @ref PJSIP_EVENT_NOT to manage the event |
| 51 | * subscription created by the REFER request. Because of this, application |
| 52 | * must link with <b>pjsip-ua</b> AND <b>pjsip-simple</b> static libraries |
| 53 | * to use REFER functionality. |
| 54 | * |
| 55 | * Reference: |
| 56 | * - <A HREF="http://www.ietf.org/rfc/rfc3515.txt">RFC 3515: The Session |
| 57 | * Initiation Protocol (SIP) Refer Method</A> |
| 58 | * - @ref PJSIP_EVENT_NOT |
| 59 | */ |
| 60 | |
| 61 | |
| 62 | PJ_BEGIN_DECL |
| 63 | |
| 64 | |
| 65 | /** Declaration for REFER method constant. */ |
| 66 | PJ_DECL_DATA(const pjsip_method) pjsip_refer_method; |
| 67 | |
| 68 | /** Get REFER method constant */ |
| 69 | PJ_DECL(const pjsip_method*) pjsip_get_refer_method(void); |
| 70 | |
| 71 | |
| 72 | /** |
| 73 | * Initialize the REFER subsystem. |
| 74 | * This currently does very little (only register REFER as supported method). |
| 75 | */ |
| 76 | PJ_DECL(pj_status_t) pjsip_xfer_init_module(pjsip_endpoint *endpt); |
| 77 | |
| 78 | |
| 79 | |
| 80 | /** |
| 81 | * Create transferer (sender of REFER request). |
| 82 | * |
| 83 | * @param dlg The underlying dialog to use. |
| 84 | * @param user_cb Pointer to callbacks to receive presence subscription |
| 85 | * events. |
| 86 | * @param p_evsub Pointer to receive the presence subscription |
| 87 | * session. |
| 88 | * |
| 89 | * @return PJ_SUCCESS on success. |
| 90 | */ |
| 91 | PJ_DECL(pj_status_t) pjsip_xfer_create_uac( pjsip_dialog *dlg, |
| 92 | const pjsip_evsub_user *user_cb, |
| 93 | pjsip_evsub **p_evsub ); |
| 94 | |
| 95 | |
| 96 | /** |
| 97 | * Create transferee (receiver of REFER request). |
| 98 | * |
| 99 | * @param dlg The underlying dialog to use. |
| 100 | * @param user_cb Pointer to callbacks to receive presence subscription |
| 101 | * events. |
| 102 | * @param rdata The incoming SUBSCRIBE request that creates the event |
| 103 | * subscription. |
| 104 | * @param p_evsub Pointer to receive the presence subscription |
| 105 | * session. |
| 106 | * |
| 107 | * @return PJ_SUCCESS on success. |
| 108 | */ |
| 109 | PJ_DECL(pj_status_t) pjsip_xfer_create_uas( pjsip_dialog *dlg, |
| 110 | const pjsip_evsub_user *user_cb, |
| 111 | pjsip_rx_data *rdata, |
| 112 | pjsip_evsub **p_evsub ); |
| 113 | |
| 114 | /** |
| 115 | * Call this function to create request to initiate REFER subscription, |
| 116 | * to refresh subscription, or to unsubscribe. For request other than |
| 117 | * the initial REFER request, "refer_to_uri" argument may be NULL. |
| 118 | * |
| 119 | * @param sub Client subscription instance. |
| 120 | * @param refer_to_uri URI to be put to the Refer-To header. This argument |
| 121 | * may be NULL for subsequent REFER requests. |
| 122 | * @param p_tdata Pointer to receive the request. |
| 123 | * |
| 124 | * @return PJ_SUCCESS on success. |
| 125 | */ |
| 126 | PJ_DECL(pj_status_t) pjsip_xfer_initiate( pjsip_evsub *sub, |
| 127 | const pj_str_t *refer_to_uri, |
| 128 | pjsip_tx_data **p_tdata); |
| 129 | |
| 130 | |
| 131 | /** |
| 132 | * Accept the incoming REFER request by sending 2xx response. |
| 133 | * |
| 134 | * @param sub Server subscription instance. |
| 135 | * @param rdata The incoming subscription request message. |
| 136 | * @param st_code Status code, which MUST be 2xx. |
| 137 | * @param hdr_list Optional list of headers to be added in the response. |
| 138 | * |
| 139 | * @return PJ_SUCCESS on success. |
| 140 | */ |
| 141 | PJ_DECL(pj_status_t) pjsip_xfer_accept( pjsip_evsub *sub, |
| 142 | pjsip_rx_data *rdata, |
| 143 | int st_code, |
| 144 | const pjsip_hdr *hdr_list ); |
| 145 | |
| 146 | |
| 147 | /** |
| 148 | * For notifier, create NOTIFY request to subscriber, and set the state |
| 149 | * of the subscription. |
| 150 | * |
| 151 | * @param sub The server subscription (notifier) instance. |
| 152 | * @param state New state to set. |
| 153 | * @param xfer_st_code The call status code to be reported with the NOTIFY |
| 154 | * request. |
| 155 | * @param xfer_st_text Optional call status text to be reported with the |
| 156 | * NOTIFY request. If the value is NULL, default |
| 157 | * status text will be used. |
| 158 | * @param p_tdata Pointer to receive the request. |
| 159 | * |
| 160 | * @return PJ_SUCCESS on success. |
| 161 | */ |
| 162 | PJ_DECL(pj_status_t) pjsip_xfer_notify( pjsip_evsub *sub, |
| 163 | pjsip_evsub_state state, |
| 164 | int xfer_st_code, |
| 165 | const pj_str_t *xfer_st_text, |
| 166 | pjsip_tx_data **p_tdata); |
| 167 | |
| 168 | |
| 169 | /** |
| 170 | * Create NOTIFY request to reflect current subscription status. Application |
| 171 | * can only call this function after it has sent NOTIFY before. |
| 172 | * This will also re-send the last "message/sipfrag" body that was sent |
| 173 | * in the previous NOTIFY. |
| 174 | * |
| 175 | * @param sub Server subscription object. |
| 176 | * @param p_tdata Pointer to receive request. |
| 177 | * |
| 178 | * @return PJ_SUCCESS on success. |
| 179 | */ |
| 180 | PJ_DECL(pj_status_t) pjsip_xfer_current_notify( pjsip_evsub *sub, |
| 181 | pjsip_tx_data **p_tdata ); |
| 182 | |
| 183 | |
| 184 | |
| 185 | /** |
| 186 | * Send request message that was previously created with initiate(), notify(), |
| 187 | * or current_notify(). Application may also send request created with other |
| 188 | * functions, e.g. authentication. But the request MUST be either request |
| 189 | * that creates/refresh subscription or NOTIFY request. |
| 190 | * |
| 191 | * |
| 192 | * @param sub The event subscription object. |
| 193 | * @param tdata Request message to be send. |
| 194 | * |
| 195 | * @return PJ_SUCCESS on success. |
| 196 | */ |
| 197 | PJ_DECL(pj_status_t) pjsip_xfer_send_request( pjsip_evsub *sub, |
| 198 | pjsip_tx_data *tdata); |
| 199 | |
| 200 | |
| 201 | PJ_END_DECL |
| 202 | |
| 203 | /** |
| 204 | * @} |
| 205 | */ |
| 206 | |
| 207 | #endif /* __PJSIP_XFER_H__ */ |
| 208 | |