Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 1 | /* $Id$ */ |
| 2 | /* |
| 3 | * Copyright (C) 2003-2006 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 __SIP_INVITE_SESSION_H__ |
| 20 | #define __SIP_INVITE_SESSION_H__ |
| 21 | |
| 22 | #include <pjsip/sip_dialog.h> |
| 23 | #include <pjmedia/sdp_neg.h> |
| 24 | |
Benny Prijono | f319507 | 2006-02-14 21:15:30 +0000 | [diff] [blame] | 25 | |
| 26 | PJ_BEGIN_DECL |
| 27 | |
| 28 | |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 29 | typedef enum pjsip_inv_state pjsip_inv_state; |
| 30 | typedef struct pjsip_inv_session pjsip_inv_session; |
| 31 | typedef struct pjsip_inv_callback pjsip_inv_callback; |
| 32 | |
| 33 | /** |
| 34 | * This enumeration describes invite session state. |
| 35 | */ |
| 36 | enum pjsip_inv_state |
| 37 | { |
| 38 | PJSIP_INV_STATE_NULL, /**< Before INVITE is sent or received */ |
| 39 | PJSIP_INV_STATE_CALLING, /**< After INVITE is sent */ |
| 40 | PJSIP_INV_STATE_INCOMING, /**< After INVITE is received. */ |
| 41 | PJSIP_INV_STATE_EARLY, /**< After response with To tag. */ |
| 42 | PJSIP_INV_STATE_CONNECTING, /**< After 2xx is sent/received. */ |
| 43 | PJSIP_INV_STATE_CONFIRMED, /**< After ACK is sent/received. */ |
| 44 | PJSIP_INV_STATE_DISCONNECTED, /**< Session is terminated. */ |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 45 | }; |
| 46 | |
| 47 | /** |
| 48 | * This structure contains callbacks to be registered by application to |
| 49 | * receieve notifications from the framework about various events in |
| 50 | * the invite session. |
| 51 | */ |
| 52 | struct pjsip_inv_callback |
| 53 | { |
| 54 | /** |
| 55 | * This callback is called when the invite sesion state has changed. |
| 56 | * Application should inspect the session state (inv_sess->state) to get |
| 57 | * the current state of the session. |
| 58 | * |
| 59 | * This callback is mandatory. |
| 60 | * |
| 61 | * @param inv The invite session. |
| 62 | * @param e The event which has caused the invite session's |
| 63 | * state to change. |
| 64 | */ |
| 65 | void (*on_state_changed)(pjsip_inv_session *inv, pjsip_event *e); |
| 66 | |
| 67 | |
| 68 | /** |
| 69 | * This callback is called when the invite usage module has created |
| 70 | * a new dialog and invite because of forked outgoing request. |
| 71 | * |
| 72 | * This callback is mandatory. |
| 73 | * |
| 74 | * @param inv The new invite session. |
| 75 | * @param e The event which has caused the dialog to fork. |
| 76 | * The type of this event can be either |
| 77 | * PJSIP_EVENT_RX_MSG or PJSIP_EVENT_RX_200_MSG. |
| 78 | */ |
| 79 | void (*on_new_session)(pjsip_inv_session *inv, pjsip_event *e); |
| 80 | |
| 81 | /** |
| 82 | * This callback is called whenever any transactions within the session |
| 83 | * has changed their state. Application MAY implement this callback, |
| 84 | * e.g. to monitor the progress of an outgoing request. |
| 85 | * |
| 86 | * This callback is optional. |
| 87 | * |
| 88 | * @param inv The invite session. |
| 89 | * @param tsx The transaction, which state has changed. |
| 90 | * @param e The event which has caused the transation state's |
| 91 | * to change. |
| 92 | */ |
| 93 | void (*on_tsx_state_changed)(pjsip_inv_session *inv, |
| 94 | pjsip_transaction *tsx, |
| 95 | pjsip_event *e); |
| 96 | |
| 97 | /** |
| 98 | * This callback is called when the invite session has received |
| 99 | * new offer from peer. Application can inspect the remote offer |
Benny Prijono | 26ff906 | 2006-02-21 23:47:00 +0000 | [diff] [blame] | 100 | * in "offer". |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 101 | * |
| 102 | * @param inv The invite session. |
Benny Prijono | 26ff906 | 2006-02-21 23:47:00 +0000 | [diff] [blame] | 103 | * @param offer Remote offer. |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 104 | */ |
Benny Prijono | 26ff906 | 2006-02-21 23:47:00 +0000 | [diff] [blame] | 105 | void (*on_rx_offer)(pjsip_inv_session *inv, |
| 106 | const pjmedia_sdp_session *offer); |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 107 | |
| 108 | /** |
| 109 | * This callback is called after SDP offer/answer session has completed. |
| 110 | * The status argument specifies the status of the offer/answer, |
| 111 | * as returned by pjmedia_sdp_neg_negotiate(). |
| 112 | * |
| 113 | * This callback is optional (from the point of view of the framework), |
| 114 | * but all useful applications normally need to implement this callback. |
| 115 | * |
| 116 | * @param inv The invite session. |
| 117 | * @param status The negotiation status. |
| 118 | */ |
| 119 | void (*on_media_update)(pjsip_inv_session *inv_ses, |
| 120 | pj_status_t status); |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 121 | }; |
| 122 | |
| 123 | |
| 124 | /** |
| 125 | * This enumeration shows various options that can be applied to a session. |
| 126 | * The bitmask combination of these options need to be specified when |
| 127 | * creating a session. After the dialog is established (including early), |
| 128 | * the options member of #pjsip_inv_session shows which capabilities are |
| 129 | * common in both endpoints. |
| 130 | */ |
| 131 | enum pjsip_inv_option |
| 132 | { |
| 133 | /** |
| 134 | * Indicate support for reliable provisional response extension |
| 135 | */ |
| 136 | PJSIP_INV_SUPPORT_100REL = 1, |
| 137 | |
| 138 | /** |
| 139 | * Indicate support for session timer extension. |
| 140 | */ |
| 141 | PJSIP_INV_SUPPORT_TIMER = 2, |
| 142 | |
| 143 | /** |
| 144 | * Indicate support for UPDATE method. This is automatically implied |
| 145 | * when creating outgoing dialog. After the dialog is established, |
| 146 | * the options member of #pjsip_inv_session shows whether peer supports |
| 147 | * this method as well. |
| 148 | */ |
| 149 | PJSIP_INV_SUPPORT_UPDATE = 4, |
| 150 | |
| 151 | /** |
| 152 | * Require reliable provisional response extension. |
| 153 | */ |
| 154 | PJSIP_INV_REQUIRE_100REL = 32, |
| 155 | |
| 156 | /** |
| 157 | * Require session timer extension. |
| 158 | */ |
| 159 | PJSIP_INV_REQUIRE_TIMER = 64, |
| 160 | |
| 161 | }; |
| 162 | |
| 163 | |
| 164 | /** |
| 165 | * This structure describes the invite session. |
| 166 | */ |
| 167 | struct pjsip_inv_session |
| 168 | { |
Benny Prijono | e4f2abb | 2006-02-10 14:04:05 +0000 | [diff] [blame] | 169 | char obj_name[PJ_MAX_OBJ_NAME]; /**< Log identification. */ |
| 170 | pj_pool_t *pool; /**< Dialog's pool. */ |
| 171 | pjsip_inv_state state; /**< Invite sess state. */ |
Benny Prijono | d4e0abd | 2006-03-05 11:53:36 +0000 | [diff] [blame] | 172 | pjsip_status_code cause; /**< Disconnect cause. */ |
| 173 | pj_bool_t notify; /**< Internal. */ |
Benny Prijono | e4f2abb | 2006-02-10 14:04:05 +0000 | [diff] [blame] | 174 | pjsip_dialog *dlg; /**< Underlying dialog. */ |
| 175 | pjsip_role_e role; /**< Invite role. */ |
| 176 | unsigned options; /**< Options in use. */ |
| 177 | pjmedia_sdp_neg *neg; /**< Negotiator. */ |
| 178 | pjsip_transaction *invite_tsx; /**< 1st invite tsx. */ |
| 179 | void *mod_data[PJSIP_MAX_MODULE];/**< Modules data. */ |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 180 | }; |
| 181 | |
| 182 | |
| 183 | /** |
| 184 | * Initialize the invite usage module and register it to the endpoint. |
| 185 | * The callback argument contains pointer to functions to be called on |
| 186 | * occurences of events in invite sessions. |
| 187 | * |
| 188 | * @param endpt The endpoint instance. |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 189 | * @param callback Callback structure. |
| 190 | * |
| 191 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 192 | */ |
| 193 | PJ_DECL(pj_status_t) pjsip_inv_usage_init(pjsip_endpoint *endpt, |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 194 | const pjsip_inv_callback *cb); |
| 195 | |
| 196 | /** |
| 197 | * Get the INVITE usage module instance. |
| 198 | * |
| 199 | * @return PJ_SUCCESS on success, or the appropriate error code. |
| 200 | */ |
| 201 | PJ_DECL(pjsip_module*) pjsip_inv_usage_instance(void); |
| 202 | |
| 203 | |
Benny Prijono | 632ce71 | 2006-02-09 14:01:40 +0000 | [diff] [blame] | 204 | /** |
| 205 | * Dump user agent contents (e.g. all dialogs). |
| 206 | */ |
| 207 | PJ_DECL(void) pjsip_inv_usage_dump(void); |
| 208 | |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 209 | |
| 210 | /** |
| 211 | * Create UAC invite session for the specified dialog in dlg. |
| 212 | * |
| 213 | * @param dlg The dialog which will be used by this invite session. |
| 214 | * @param local_sdp If application has determined its media capability, |
| 215 | * it can specify the SDP here. Otherwise it can leave |
| 216 | * this to NULL, to let remote UAS specifies an offer. |
| 217 | * @param options The options argument is bitmask combination of SIP |
| 218 | * features in pjsip_inv_options enumeration. |
| 219 | * @param p_inv On successful return, the invite session will be put |
| 220 | * in this argument. |
| 221 | * |
| 222 | * @return The function will return PJ_SUCCESS if it can create |
| 223 | * the session. Otherwise the appropriate error status |
| 224 | * will be returned on failure. |
| 225 | */ |
| 226 | PJ_DECL(pj_status_t) pjsip_inv_create_uac(pjsip_dialog *dlg, |
| 227 | const pjmedia_sdp_session *local_sdp, |
| 228 | unsigned options, |
| 229 | pjsip_inv_session **p_inv); |
| 230 | |
| 231 | |
| 232 | /** |
| 233 | * Application SHOULD call this function upon receiving the initial INVITE |
| 234 | * request in rdata before creating the invite session (or even dialog), |
| 235 | * to verify that the invite session can handle the INVITE request. |
| 236 | * This function verifies that local endpoint is capable to handle required |
| 237 | * SIP extensions in the request (i.e. Require header) and also the media, |
| 238 | * if media description is present in the request. |
| 239 | * |
| 240 | * @param rdata The incoming INVITE request. |
| 241 | * |
| 242 | * @param options Upon calling this function, the options argument |
| 243 | * MUST contain the desired SIP extensions to be |
| 244 | * applied to the session. Upon return, this argument |
| 245 | * will contain the SIP extension that will be applied |
| 246 | * to the session, after considering the Supported, |
| 247 | * Require, and Allow headers in the request. |
| 248 | * |
| 249 | * @param sdp If local media capability has been determined, |
| 250 | * and if application wishes to verify that it can |
| 251 | * handle the media offer in the incoming INVITE |
| 252 | * request, it SHOULD specify its local media capability |
| 253 | * in this argument. |
| 254 | * If it is not specified, media verification will not |
| 255 | * be performed by this function. |
| 256 | * |
| 257 | * @param dlg If tdata is not NULL, application needs to specify |
| 258 | * how to create the response. Either dlg or endpt |
| 259 | * argument MUST be specified, with dlg argument takes |
| 260 | * precedence when both are specified. |
| 261 | * |
| 262 | * If a dialog has been created prior to calling this |
| 263 | * function, then it MUST be specified in dlg argument. |
| 264 | * Otherwise application MUST specify the endpt argument |
| 265 | * (this is useful e.g. when application wants to send |
| 266 | * the response statelessly). |
| 267 | * |
| 268 | * @param endpt If tdata is not NULL, application needs to specify |
| 269 | * how to create the response. Either dlg or endpt |
| 270 | * argument MUST be specified, with dlg argument takes |
| 271 | * precedence when both are specified. |
| 272 | * |
| 273 | * @param tdata If this argument is not NULL, this function will |
| 274 | * create the appropriate non-2xx final response message |
| 275 | * when the verification fails. |
| 276 | * |
| 277 | * @return If everything has been negotiated successfully, |
| 278 | * the function will return PJ_SUCCESS. Otherwise it |
| 279 | * will return the reason of the failure as the return |
| 280 | * code. |
| 281 | * |
| 282 | * This function is capable to create the appropriate |
| 283 | * response message when the verification has failed. |
| 284 | * If tdata is specified, then a non-2xx final response |
| 285 | * will be created and put in this argument upon return, |
| 286 | * when the verification has failed. |
| 287 | * |
| 288 | * If a dialog has been created prior to calling this |
| 289 | * function, then it MUST be specified in dlg argument. |
| 290 | * Otherwise application MUST specify the endpt argument |
| 291 | * (this is useful e.g. when application wants to send |
| 292 | * the response statelessly). |
| 293 | */ |
| 294 | PJ_DECL(pj_status_t) pjsip_inv_verify_request( pjsip_rx_data *rdata, |
| 295 | unsigned *options, |
| 296 | const pjmedia_sdp_session *sdp, |
| 297 | pjsip_dialog *dlg, |
| 298 | pjsip_endpoint *endpt, |
| 299 | pjsip_tx_data **tdata); |
| 300 | |
| 301 | |
| 302 | /** |
| 303 | * Create UAS invite session for the specified dialog in dlg. Application |
| 304 | * SHOULD call the verification function before calling this function, |
| 305 | * to ensure that it can create the session successfully. |
| 306 | * |
| 307 | * @param dlg The dialog to be used. |
| 308 | * @param rdata Application MUST specify the received INVITE request |
| 309 | * in rdata. The invite session needs to inspect the |
| 310 | * received request to see if the request contains |
| 311 | * features that it supports. |
| 312 | * @param sdp If application has determined its media capability, |
| 313 | * it can specify this capability in this argument. |
| 314 | * If SDP is received in the initial INVITE, the UAS |
| 315 | * capability specified in this argument doesn't have to |
| 316 | * match the received offer; the SDP negotiator is able |
| 317 | * to rearrange the media lines in the answer so that it |
| 318 | * matches the offer. |
| 319 | * @param options The options argument is bitmask combination of SIP |
| 320 | * features in pjsip_inv_options enumeration. |
| 321 | * @param p_inv Pointer to receive the newly created invite session. |
| 322 | * |
| 323 | * @return On successful, the invite session will be put in |
| 324 | * p_inv argument and the function will return PJ_SUCCESS. |
| 325 | * Otherwise the appropriate error status will be returned |
| 326 | * on failure. |
| 327 | */ |
| 328 | PJ_DECL(pj_status_t) pjsip_inv_create_uas(pjsip_dialog *dlg, |
| 329 | pjsip_rx_data *rdata, |
| 330 | const pjmedia_sdp_session *local_sdp, |
| 331 | unsigned options, |
| 332 | pjsip_inv_session **p_inv); |
| 333 | |
| 334 | |
| 335 | /** |
Benny Prijono | d4e0abd | 2006-03-05 11:53:36 +0000 | [diff] [blame] | 336 | * Forcefully terminate and destroy INVITE session, regardless of |
| 337 | * the state of the session. Note that this function should only be used |
| 338 | * when there is failure in the INVITE session creation. After the |
| 339 | * invite session has been created and initialized, normally application |
| 340 | * SHOULD use #pjsip_inv_end_session() to end the INVITE session instead. |
| 341 | * |
| 342 | * Note also that this function may terminate the underlying dialog, if |
| 343 | * there are no other sessions in the dialog. |
| 344 | * |
| 345 | * @param inv The invite session. |
| 346 | * @param st_code Status code for the reason of the termination. |
| 347 | * @param notify If set to non-zero, then on_state_changed() |
| 348 | * callback will be called. |
| 349 | * |
| 350 | * @return PJ_SUCCESS if the INVITE session has been |
| 351 | * terminated. |
| 352 | */ |
| 353 | PJ_DECL(pj_status_t) pjsip_inv_terminate( pjsip_inv_session *inv, |
| 354 | int st_code, |
| 355 | pj_bool_t notify ); |
| 356 | |
| 357 | |
| 358 | /** |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 359 | * Create the initial INVITE request for this session. This function can only |
| 360 | * be called for UAC session. If local media capability is specified when |
| 361 | * the invite session was created, then this function will put an SDP offer |
| 362 | * in the outgoing INVITE request. Otherwise the outgoing request will not |
| 363 | * contain SDP body. |
| 364 | * |
| 365 | * @param inv The UAC invite session. |
| 366 | * @param p_tdata The initial INVITE request will be put in this |
| 367 | * argument if it can be created successfully. |
| 368 | * |
| 369 | * @return PJ_SUCCESS if the INVITE request can be created. |
| 370 | */ |
| 371 | PJ_DECL(pj_status_t) pjsip_inv_invite( pjsip_inv_session *inv, |
| 372 | pjsip_tx_data **p_tdata ); |
| 373 | |
| 374 | |
| 375 | /** |
Benny Prijono | 64f851e | 2006-02-23 13:49:28 +0000 | [diff] [blame] | 376 | * Create the initial response message for the incoming INVITE request in |
| 377 | * rdata with status code st_code and optional status text st_text. Use |
| 378 | * #pjsip_answer() to create subsequent response message. |
| 379 | */ |
| 380 | PJ_DECL(pj_status_t) pjsip_inv_initial_answer( pjsip_inv_session *inv, |
| 381 | pjsip_rx_data *rdata, |
| 382 | int st_code, |
| 383 | const pj_str_t *st_text, |
| 384 | const pjmedia_sdp_session *sdp, |
| 385 | pjsip_tx_data **p_tdata); |
| 386 | |
| 387 | /** |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 388 | * Create a response message to the initial INVITE request. This function |
| 389 | * can only be called for the initial INVITE request, as subsequent |
| 390 | * re-INVITE request will be answered automatically. |
| 391 | * |
| 392 | * @param inv The UAS invite session. |
| 393 | * @param st_code The st_code contains the status code to be sent, |
| 394 | * which may be a provisional or final response. |
| 395 | * @param st_text If custom status text is desired, application can |
| 396 | * specify the text in st_text; otherwise if this |
| 397 | * argument is NULL, default status text will be used. |
| 398 | * @param local_sdp If application has specified its media capability |
| 399 | * during creation of UAS invite session, the local_sdp |
| 400 | * argument MUST be NULL. This is because application |
| 401 | * can not perform more than one SDP offer/answer session |
| 402 | * in a single INVITE transaction. |
| 403 | * If application has not specified its media capability |
| 404 | * during creation of UAS invite session, it MAY or MUST |
| 405 | * specify its capability in local_sdp argument, |
| 406 | * depending whether st_code indicates a 2xx final |
| 407 | * response. |
| 408 | * @param p_tdata Pointer to receive the response message created by |
| 409 | * this function. |
| 410 | * |
| 411 | * @return PJ_SUCCESS if response message was created |
| 412 | * successfully. |
| 413 | */ |
| 414 | PJ_DECL(pj_status_t) pjsip_inv_answer( pjsip_inv_session *inv, |
| 415 | int st_code, |
| 416 | const pj_str_t *st_text, |
| 417 | const pjmedia_sdp_session *local_sdp, |
| 418 | pjsip_tx_data **p_tdata ); |
| 419 | |
| 420 | |
Benny Prijono | a66c715 | 2006-02-09 01:26:14 +0000 | [diff] [blame] | 421 | /** |
Benny Prijono | 26ff906 | 2006-02-21 23:47:00 +0000 | [diff] [blame] | 422 | * Set local answer to respond to remote SDP offer, to be carried by |
| 423 | * subsequent response (or request). |
Benny Prijono | a66c715 | 2006-02-09 01:26:14 +0000 | [diff] [blame] | 424 | * |
| 425 | * @param inv The invite session. |
| 426 | * @param sdp The SDP description which will be set as answer |
| 427 | * to remote. |
Benny Prijono | 26ff906 | 2006-02-21 23:47:00 +0000 | [diff] [blame] | 428 | * |
| 429 | * @return PJ_SUCCESS if local answer can be accepted by |
| 430 | * SDP negotiator. |
Benny Prijono | a66c715 | 2006-02-09 01:26:14 +0000 | [diff] [blame] | 431 | */ |
Benny Prijono | 26ff906 | 2006-02-21 23:47:00 +0000 | [diff] [blame] | 432 | PJ_DECL(pj_status_t) pjsip_inv_set_sdp_answer(pjsip_inv_session *inv, |
| 433 | const pjmedia_sdp_session *sdp ); |
| 434 | |
Benny Prijono | a66c715 | 2006-02-09 01:26:14 +0000 | [diff] [blame] | 435 | |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 436 | /** |
| 437 | * Create a SIP message to initiate invite session termination. Depending on |
| 438 | * the state of the session, this function may return CANCEL request, |
| 439 | * a non-2xx final response, or a BYE request. If the session has not answered |
| 440 | * the incoming INVITE, this function creates the non-2xx final response with |
| 441 | * the specified status code in st_code and optional status text in st_text. |
| 442 | * |
| 443 | * @param inv The invite session. |
| 444 | * @param st_code Status code to be used for terminating the session. |
| 445 | * @param st_text Optional status text. |
| 446 | * @param p_tdata Pointer to receive the message to be created. |
| 447 | * |
| 448 | * @return PJ_SUCCESS if termination message can be created. |
| 449 | */ |
| 450 | PJ_DECL(pj_status_t) pjsip_inv_end_session( pjsip_inv_session *inv, |
| 451 | int st_code, |
| 452 | const pj_str_t *st_text, |
| 453 | pjsip_tx_data **p_tdata ); |
| 454 | |
| 455 | |
| 456 | |
| 457 | /** |
| 458 | * Create a re-INVITE request. |
| 459 | * |
| 460 | * @param inv The invite session. |
| 461 | * @param new_contact If application wants to update its local contact and |
| 462 | * inform peer to perform target refresh with a new |
| 463 | * contact, it can specify the new contact in this |
| 464 | * argument; otherwise this argument must be NULL. |
| 465 | * @param new_offer Application MAY initiate a new SDP offer/answer |
| 466 | * session in the request when there is no pending |
| 467 | * answer to be sent or received. It can detect this |
| 468 | * condition by observing the state of the SDP |
| 469 | * negotiator of the invite session. If new offer |
| 470 | * should be sent to remote, the offer must be specified |
| 471 | * in this argument, otherwise it must be NULL. |
| 472 | * @param p_tdata Pointer to receive the re-INVITE request message to |
| 473 | * be created. |
| 474 | * |
| 475 | * @return PJ_SUCCESS if a re-INVITE request with the specified |
| 476 | * characteristics (e.g. to contain new offer) can be |
| 477 | * created. |
| 478 | */ |
| 479 | PJ_DECL(pj_status_t) pjsip_inv_reinvite(pjsip_inv_session *inv, |
| 480 | const pj_str_t *new_contact, |
| 481 | const pjmedia_sdp_session *new_offer, |
| 482 | pjsip_tx_data **p_tdata ); |
| 483 | |
| 484 | |
| 485 | |
| 486 | /** |
| 487 | * Create an UPDATE request. |
| 488 | * |
| 489 | * @param inv The invite session. |
| 490 | * @param new_contact If application wants to update its local contact |
| 491 | * and inform peer to perform target refresh with a new |
| 492 | * contact, it can specify the new contact in this |
| 493 | * argument; otherwise this argument must be NULL. |
| 494 | * @param new_offer Application MAY initiate a new SDP offer/answer |
| 495 | * session in the request when there is no pending answer |
| 496 | * to be sent or received. It can detect this condition |
| 497 | * by observing the state of the SDP negotiator of the |
| 498 | * invite session. If new offer should be sent to remote, |
| 499 | * the offer must be specified in this argument; otherwise |
| 500 | * this argument must be NULL. |
| 501 | * @param p_tdata Pointer to receive the UPDATE request message to |
| 502 | * be created. |
| 503 | * |
| 504 | * @return PJ_SUCCESS if a UPDATE request with the specified |
| 505 | * characteristics (e.g. to contain new offer) can be |
| 506 | * created. |
| 507 | */ |
| 508 | PJ_DECL(pj_status_t) pjsip_inv_update ( pjsip_inv_session *inv, |
| 509 | const pj_str_t *new_contact, |
| 510 | const pjmedia_sdp_session *new_offer, |
| 511 | pjsip_tx_data **p_tdata ); |
| 512 | |
| 513 | |
| 514 | /** |
| 515 | * Send request or response message in tdata. |
| 516 | * |
| 517 | * @param inv The invite session. |
| 518 | * @param tdata The message to be sent. |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 519 | * |
| 520 | * @return PJ_SUCCESS if transaction can be initiated |
| 521 | * successfully to send this message. Note that the |
| 522 | * actual final state of the transaction itself will |
| 523 | * be reported later, in on_tsx_state_changed() |
| 524 | * callback. |
| 525 | */ |
| 526 | PJ_DECL(pj_status_t) pjsip_inv_send_msg(pjsip_inv_session *inv, |
Benny Prijono | e8b0d3b | 2006-03-17 17:57:52 +0000 | [diff] [blame^] | 527 | pjsip_tx_data *tdata); |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 528 | |
| 529 | |
| 530 | |
| 531 | /** |
| 532 | * Get the invite session for the dialog, if any. |
| 533 | * |
| 534 | * @param dlg The dialog which invite session is being queried. |
| 535 | * |
| 536 | * @return The invite session instance which has been |
| 537 | * associated with this dialog, or NULL. |
| 538 | */ |
| 539 | PJ_DECL(pjsip_inv_session*) pjsip_dlg_get_inv_session(pjsip_dialog *dlg); |
| 540 | |
| 541 | /** |
| 542 | * Get the invite session instance associated with transaction tsx, if any. |
| 543 | * |
| 544 | * @param tsx The transaction, which invite session is being |
| 545 | * queried. |
| 546 | * |
| 547 | * @return The invite session instance which has been |
| 548 | * associated with this transaction, or NULL. |
| 549 | */ |
| 550 | PJ_DECL(pjsip_inv_session*) pjsip_tsx_get_inv_session(pjsip_transaction *tsx); |
| 551 | |
| 552 | |
Benny Prijono | e8b0d3b | 2006-03-17 17:57:52 +0000 | [diff] [blame^] | 553 | /** |
| 554 | * Get state names for INVITE session state. |
| 555 | * |
| 556 | * @param state The invite state. |
| 557 | * |
| 558 | * @return String describing the state. |
| 559 | */ |
| 560 | PJ_DECL(const char *) pjsip_inv_state_name(pjsip_inv_state state); |
| 561 | |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 562 | |
Benny Prijono | f319507 | 2006-02-14 21:15:30 +0000 | [diff] [blame] | 563 | PJ_END_DECL |
| 564 | |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 565 | |
| 566 | |
| 567 | #endif /* __SIP_INVITE_SESSION_H__ */ |