blob: f04f4aedce33c28a9ceac9f759370a5aec510466 [file] [log] [blame]
Benny Prijono268ca612006-02-07 12:34:11 +00001/* $Id$ */
2/*
Benny Prijonoa771a512007-02-19 01:13:53 +00003 * Copyright (C) 2003-2007 Benny Prijono <benny@prijono.org>
Benny Prijono268ca612006-02-07 12:34:11 +00004 *
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
Benny Prijono312aff92006-06-17 04:08:30 +000022/**
23 * @file sip_inv.h
24 * @brief INVITE sessions
25 */
26
27
Benny Prijono268ca612006-02-07 12:34:11 +000028#include <pjsip/sip_dialog.h>
29#include <pjmedia/sdp_neg.h>
30
Benny Prijonof3195072006-02-14 21:15:30 +000031
Benny Prijono312aff92006-06-17 04:08:30 +000032/**
33 * @defgroup PJSIP_HIGH_UA User Agent Library
34 * @ingroup PJSIP
35 * @brief Mid-level User Agent Library.
36 *
37 * This is the high level user agent library, which consists of:
38 * - @ref PJSIP_INV, to encapsulate INVITE sessions and SDP
39 * negotiation in the session,
40 * - @ref PJSUA_REGC, high level client registration API, and
41 * - @ref PJSUA_XFER.
42 *
43 * More detailed information is explained in
44 * <A HREF="/docs.htm">PJSIP Developer's Guide</A>
45 * PDF document, and readers are encouraged to read the document to
46 * get the concept behind dialog, dialog usages, and INVITE sessions.
47 *
48 * The User Agent Library is implemented in <b>pjsip-ua</b> static
49 * library.
50 */
51
52/**
53 * @defgroup PJSIP_INV INVITE Session
54 * @ingroup PJSIP_HIGH_UA
55 * @brief Provides INVITE session management.
56 * @{
57 *
58 * The INVITE session uses the @ref PJSIP_DIALOG framework to manage
59 * the underlying dialog, and is one type of usages that can use
60 * a particular dialog instance (other usages are event subscription,
61 * discussed in @ref PJSIP_EVENT_NOT). The INVITE session manages
62 * the life-time of the session, and also manages the SDP negotiation.
63 *
64 * Application must link with <b>pjsip-ua</b> static library to use this API.
65 *
66 * More detailed information is explained in
67 * <A HREF="/docs.htm">PJSIP Developer's Guide</A>
68 * PDF document, and readers are encouraged to read the document to
69 * get the concept behind dialog, dialog usages, and INVITE sessions.
70 *
71 * The INVITE session does NOT manage media. If application wants to
72 * use API that encapsulates both signaling and media in a very easy
73 * to use API, it can use @ref PJSUA_LIB for this purpose.
74 */
75
Benny Prijonof3195072006-02-14 21:15:30 +000076PJ_BEGIN_DECL
77
78
Benny Prijono312aff92006-06-17 04:08:30 +000079/**
80 * @see pjsip_inv_session
81 */
Benny Prijono268ca612006-02-07 12:34:11 +000082typedef struct pjsip_inv_session pjsip_inv_session;
Benny Prijono312aff92006-06-17 04:08:30 +000083
Benny Prijono268ca612006-02-07 12:34:11 +000084
85/**
86 * This enumeration describes invite session state.
87 */
Benny Prijono312aff92006-06-17 04:08:30 +000088typedef enum pjsip_inv_state
Benny Prijono268ca612006-02-07 12:34:11 +000089{
90 PJSIP_INV_STATE_NULL, /**< Before INVITE is sent or received */
91 PJSIP_INV_STATE_CALLING, /**< After INVITE is sent */
92 PJSIP_INV_STATE_INCOMING, /**< After INVITE is received. */
93 PJSIP_INV_STATE_EARLY, /**< After response with To tag. */
94 PJSIP_INV_STATE_CONNECTING, /**< After 2xx is sent/received. */
95 PJSIP_INV_STATE_CONFIRMED, /**< After ACK is sent/received. */
96 PJSIP_INV_STATE_DISCONNECTED, /**< Session is terminated. */
Benny Prijono312aff92006-06-17 04:08:30 +000097} pjsip_inv_state;
Benny Prijono268ca612006-02-07 12:34:11 +000098
99/**
100 * This structure contains callbacks to be registered by application to
101 * receieve notifications from the framework about various events in
102 * the invite session.
103 */
Benny Prijono312aff92006-06-17 04:08:30 +0000104typedef struct pjsip_inv_callback
Benny Prijono268ca612006-02-07 12:34:11 +0000105{
106 /**
107 * This callback is called when the invite sesion state has changed.
108 * Application should inspect the session state (inv_sess->state) to get
109 * the current state of the session.
110 *
111 * This callback is mandatory.
112 *
113 * @param inv The invite session.
114 * @param e The event which has caused the invite session's
115 * state to change.
116 */
117 void (*on_state_changed)(pjsip_inv_session *inv, pjsip_event *e);
118
119
120 /**
121 * This callback is called when the invite usage module has created
122 * a new dialog and invite because of forked outgoing request.
123 *
124 * This callback is mandatory.
125 *
126 * @param inv The new invite session.
127 * @param e The event which has caused the dialog to fork.
128 * The type of this event can be either
129 * PJSIP_EVENT_RX_MSG or PJSIP_EVENT_RX_200_MSG.
130 */
131 void (*on_new_session)(pjsip_inv_session *inv, pjsip_event *e);
132
133 /**
134 * This callback is called whenever any transactions within the session
135 * has changed their state. Application MAY implement this callback,
136 * e.g. to monitor the progress of an outgoing request.
137 *
138 * This callback is optional.
139 *
140 * @param inv The invite session.
141 * @param tsx The transaction, which state has changed.
142 * @param e The event which has caused the transation state's
143 * to change.
144 */
145 void (*on_tsx_state_changed)(pjsip_inv_session *inv,
146 pjsip_transaction *tsx,
147 pjsip_event *e);
148
149 /**
150 * This callback is called when the invite session has received
151 * new offer from peer. Application can inspect the remote offer
Benny Prijono77998ce2007-06-20 10:03:46 +0000152 * in "offer", and set the SDP answer with #pjsip_inv_set_sdp_answer().
153 * When the application sends a SIP message to send the answer,
154 * this SDP answer will be negotiated with the offer, and the result
155 * will be sent with the SIP message.
Benny Prijono268ca612006-02-07 12:34:11 +0000156 *
157 * @param inv The invite session.
Benny Prijono26ff9062006-02-21 23:47:00 +0000158 * @param offer Remote offer.
Benny Prijono268ca612006-02-07 12:34:11 +0000159 */
Benny Prijono26ff9062006-02-21 23:47:00 +0000160 void (*on_rx_offer)(pjsip_inv_session *inv,
161 const pjmedia_sdp_session *offer);
Benny Prijono268ca612006-02-07 12:34:11 +0000162
163 /**
Benny Prijono77998ce2007-06-20 10:03:46 +0000164 * This callback is optional, and it is used to ask the application
165 * to create a fresh offer, when the invite session has received
166 * re-INVITE without offer. This offer then will be sent in the
167 * 200/OK response to the re-INVITE request.
168 *
169 * If application doesn't implement this callback, the invite session
170 * will send the currently active SDP as the offer.
171 *
172 * @param inv The invite session.
173 * @param p_offer Pointer to receive the SDP offer created by
174 * application.
175 */
176 void (*on_create_offer)(pjsip_inv_session *inv,
177 pjmedia_sdp_session **p_offer);
178
179 /**
Benny Prijono268ca612006-02-07 12:34:11 +0000180 * This callback is called after SDP offer/answer session has completed.
181 * The status argument specifies the status of the offer/answer,
182 * as returned by pjmedia_sdp_neg_negotiate().
183 *
184 * This callback is optional (from the point of view of the framework),
185 * but all useful applications normally need to implement this callback.
186 *
187 * @param inv The invite session.
188 * @param status The negotiation status.
189 */
190 void (*on_media_update)(pjsip_inv_session *inv_ses,
191 pj_status_t status);
Benny Prijono312aff92006-06-17 04:08:30 +0000192
193} pjsip_inv_callback;
194
Benny Prijono268ca612006-02-07 12:34:11 +0000195
196
197/**
198 * This enumeration shows various options that can be applied to a session.
199 * The bitmask combination of these options need to be specified when
200 * creating a session. After the dialog is established (including early),
201 * the options member of #pjsip_inv_session shows which capabilities are
202 * common in both endpoints.
203 */
204enum pjsip_inv_option
205{
206 /**
207 * Indicate support for reliable provisional response extension
208 */
209 PJSIP_INV_SUPPORT_100REL = 1,
210
211 /**
212 * Indicate support for session timer extension.
213 */
214 PJSIP_INV_SUPPORT_TIMER = 2,
215
216 /**
217 * Indicate support for UPDATE method. This is automatically implied
218 * when creating outgoing dialog. After the dialog is established,
219 * the options member of #pjsip_inv_session shows whether peer supports
220 * this method as well.
221 */
222 PJSIP_INV_SUPPORT_UPDATE = 4,
223
224 /**
225 * Require reliable provisional response extension.
226 */
227 PJSIP_INV_REQUIRE_100REL = 32,
228
229 /**
230 * Require session timer extension.
231 */
232 PJSIP_INV_REQUIRE_TIMER = 64,
233
234};
235
236
237/**
238 * This structure describes the invite session.
239 */
240struct pjsip_inv_session
241{
Benny Prijono0b6340c2006-06-13 22:21:23 +0000242 char obj_name[PJ_MAX_OBJ_NAME]; /**< Log identification */
Benny Prijonoe4f2abb2006-02-10 14:04:05 +0000243 pj_pool_t *pool; /**< Dialog's pool. */
244 pjsip_inv_state state; /**< Invite sess state. */
Benny Prijono1dc8be02007-05-30 04:26:40 +0000245 pj_bool_t cancelling; /**< CANCEL requested */
246 pj_bool_t pending_cancel; /**< Wait to send CANCEL*/
Benny Prijonod4e0abd2006-03-05 11:53:36 +0000247 pjsip_status_code cause; /**< Disconnect cause. */
Benny Prijono0b6340c2006-06-13 22:21:23 +0000248 pj_str_t cause_text; /**< Cause text. */
Benny Prijonod4e0abd2006-03-05 11:53:36 +0000249 pj_bool_t notify; /**< Internal. */
Benny Prijonoe4f2abb2006-02-10 14:04:05 +0000250 pjsip_dialog *dlg; /**< Underlying dialog. */
251 pjsip_role_e role; /**< Invite role. */
252 unsigned options; /**< Options in use. */
253 pjmedia_sdp_neg *neg; /**< Negotiator. */
254 pjsip_transaction *invite_tsx; /**< 1st invite tsx. */
Benny Prijonodcfc0ba2007-09-30 16:50:27 +0000255 pjsip_tx_data *last_answer; /**< Last INVITE resp. */
Benny Prijonoe4f2abb2006-02-10 14:04:05 +0000256 void *mod_data[PJSIP_MAX_MODULE];/**< Modules data. */
Benny Prijono268ca612006-02-07 12:34:11 +0000257};
258
259
260/**
261 * Initialize the invite usage module and register it to the endpoint.
262 * The callback argument contains pointer to functions to be called on
263 * occurences of events in invite sessions.
264 *
265 * @param endpt The endpoint instance.
Benny Prijono312aff92006-06-17 04:08:30 +0000266 * @param cb Callback structure.
Benny Prijono268ca612006-02-07 12:34:11 +0000267 *
268 * @return PJ_SUCCESS on success, or the appropriate error code.
269 */
270PJ_DECL(pj_status_t) pjsip_inv_usage_init(pjsip_endpoint *endpt,
Benny Prijono268ca612006-02-07 12:34:11 +0000271 const pjsip_inv_callback *cb);
272
273/**
274 * Get the INVITE usage module instance.
275 *
276 * @return PJ_SUCCESS on success, or the appropriate error code.
277 */
278PJ_DECL(pjsip_module*) pjsip_inv_usage_instance(void);
279
280
Benny Prijono632ce712006-02-09 14:01:40 +0000281/**
282 * Dump user agent contents (e.g. all dialogs).
283 */
284PJ_DECL(void) pjsip_inv_usage_dump(void);
285
Benny Prijono268ca612006-02-07 12:34:11 +0000286
287/**
288 * Create UAC invite session for the specified dialog in dlg.
289 *
290 * @param dlg The dialog which will be used by this invite session.
291 * @param local_sdp If application has determined its media capability,
292 * it can specify the SDP here. Otherwise it can leave
293 * this to NULL, to let remote UAS specifies an offer.
294 * @param options The options argument is bitmask combination of SIP
295 * features in pjsip_inv_options enumeration.
296 * @param p_inv On successful return, the invite session will be put
297 * in this argument.
298 *
299 * @return The function will return PJ_SUCCESS if it can create
300 * the session. Otherwise the appropriate error status
301 * will be returned on failure.
302 */
303PJ_DECL(pj_status_t) pjsip_inv_create_uac(pjsip_dialog *dlg,
304 const pjmedia_sdp_session *local_sdp,
305 unsigned options,
306 pjsip_inv_session **p_inv);
307
308
309/**
310 * Application SHOULD call this function upon receiving the initial INVITE
311 * request in rdata before creating the invite session (or even dialog),
312 * to verify that the invite session can handle the INVITE request.
313 * This function verifies that local endpoint is capable to handle required
314 * SIP extensions in the request (i.e. Require header) and also the media,
315 * if media description is present in the request.
316 *
317 * @param rdata The incoming INVITE request.
318 *
319 * @param options Upon calling this function, the options argument
320 * MUST contain the desired SIP extensions to be
321 * applied to the session. Upon return, this argument
322 * will contain the SIP extension that will be applied
323 * to the session, after considering the Supported,
324 * Require, and Allow headers in the request.
325 *
326 * @param sdp If local media capability has been determined,
327 * and if application wishes to verify that it can
328 * handle the media offer in the incoming INVITE
329 * request, it SHOULD specify its local media capability
330 * in this argument.
331 * If it is not specified, media verification will not
332 * be performed by this function.
333 *
334 * @param dlg If tdata is not NULL, application needs to specify
335 * how to create the response. Either dlg or endpt
336 * argument MUST be specified, with dlg argument takes
337 * precedence when both are specified.
338 *
339 * If a dialog has been created prior to calling this
340 * function, then it MUST be specified in dlg argument.
341 * Otherwise application MUST specify the endpt argument
342 * (this is useful e.g. when application wants to send
343 * the response statelessly).
344 *
345 * @param endpt If tdata is not NULL, application needs to specify
346 * how to create the response. Either dlg or endpt
347 * argument MUST be specified, with dlg argument takes
348 * precedence when both are specified.
349 *
350 * @param tdata If this argument is not NULL, this function will
351 * create the appropriate non-2xx final response message
352 * when the verification fails.
353 *
354 * @return If everything has been negotiated successfully,
355 * the function will return PJ_SUCCESS. Otherwise it
356 * will return the reason of the failure as the return
357 * code.
358 *
359 * This function is capable to create the appropriate
360 * response message when the verification has failed.
361 * If tdata is specified, then a non-2xx final response
362 * will be created and put in this argument upon return,
363 * when the verification has failed.
364 *
365 * If a dialog has been created prior to calling this
366 * function, then it MUST be specified in dlg argument.
367 * Otherwise application MUST specify the endpt argument
368 * (this is useful e.g. when application wants to send
369 * the response statelessly).
370 */
371PJ_DECL(pj_status_t) pjsip_inv_verify_request( pjsip_rx_data *rdata,
372 unsigned *options,
373 const pjmedia_sdp_session *sdp,
374 pjsip_dialog *dlg,
375 pjsip_endpoint *endpt,
376 pjsip_tx_data **tdata);
377
378
379/**
380 * Create UAS invite session for the specified dialog in dlg. Application
381 * SHOULD call the verification function before calling this function,
382 * to ensure that it can create the session successfully.
383 *
384 * @param dlg The dialog to be used.
385 * @param rdata Application MUST specify the received INVITE request
386 * in rdata. The invite session needs to inspect the
387 * received request to see if the request contains
388 * features that it supports.
Benny Prijono312aff92006-06-17 04:08:30 +0000389 * @param local_sdp If application has determined its media capability,
Benny Prijono268ca612006-02-07 12:34:11 +0000390 * it can specify this capability in this argument.
391 * If SDP is received in the initial INVITE, the UAS
392 * capability specified in this argument doesn't have to
393 * match the received offer; the SDP negotiator is able
394 * to rearrange the media lines in the answer so that it
395 * matches the offer.
396 * @param options The options argument is bitmask combination of SIP
397 * features in pjsip_inv_options enumeration.
398 * @param p_inv Pointer to receive the newly created invite session.
399 *
400 * @return On successful, the invite session will be put in
401 * p_inv argument and the function will return PJ_SUCCESS.
402 * Otherwise the appropriate error status will be returned
403 * on failure.
404 */
405PJ_DECL(pj_status_t) pjsip_inv_create_uas(pjsip_dialog *dlg,
406 pjsip_rx_data *rdata,
407 const pjmedia_sdp_session *local_sdp,
408 unsigned options,
409 pjsip_inv_session **p_inv);
410
411
412/**
Benny Prijonod4e0abd2006-03-05 11:53:36 +0000413 * Forcefully terminate and destroy INVITE session, regardless of
414 * the state of the session. Note that this function should only be used
415 * when there is failure in the INVITE session creation. After the
416 * invite session has been created and initialized, normally application
417 * SHOULD use #pjsip_inv_end_session() to end the INVITE session instead.
418 *
419 * Note also that this function may terminate the underlying dialog, if
420 * there are no other sessions in the dialog.
421 *
422 * @param inv The invite session.
423 * @param st_code Status code for the reason of the termination.
424 * @param notify If set to non-zero, then on_state_changed()
425 * callback will be called.
426 *
427 * @return PJ_SUCCESS if the INVITE session has been
428 * terminated.
429 */
430PJ_DECL(pj_status_t) pjsip_inv_terminate( pjsip_inv_session *inv,
431 int st_code,
432 pj_bool_t notify );
433
434
435/**
Benny Prijono268ca612006-02-07 12:34:11 +0000436 * Create the initial INVITE request for this session. This function can only
437 * be called for UAC session. If local media capability is specified when
438 * the invite session was created, then this function will put an SDP offer
439 * in the outgoing INVITE request. Otherwise the outgoing request will not
440 * contain SDP body.
441 *
442 * @param inv The UAC invite session.
443 * @param p_tdata The initial INVITE request will be put in this
444 * argument if it can be created successfully.
445 *
446 * @return PJ_SUCCESS if the INVITE request can be created.
447 */
448PJ_DECL(pj_status_t) pjsip_inv_invite( pjsip_inv_session *inv,
449 pjsip_tx_data **p_tdata );
450
451
452/**
Benny Prijono64f851e2006-02-23 13:49:28 +0000453 * Create the initial response message for the incoming INVITE request in
454 * rdata with status code st_code and optional status text st_text. Use
455 * #pjsip_answer() to create subsequent response message.
456 */
457PJ_DECL(pj_status_t) pjsip_inv_initial_answer( pjsip_inv_session *inv,
458 pjsip_rx_data *rdata,
459 int st_code,
460 const pj_str_t *st_text,
461 const pjmedia_sdp_session *sdp,
462 pjsip_tx_data **p_tdata);
463
464/**
Benny Prijono268ca612006-02-07 12:34:11 +0000465 * Create a response message to the initial INVITE request. This function
466 * can only be called for the initial INVITE request, as subsequent
467 * re-INVITE request will be answered automatically.
468 *
469 * @param inv The UAS invite session.
470 * @param st_code The st_code contains the status code to be sent,
471 * which may be a provisional or final response.
472 * @param st_text If custom status text is desired, application can
473 * specify the text in st_text; otherwise if this
474 * argument is NULL, default status text will be used.
475 * @param local_sdp If application has specified its media capability
476 * during creation of UAS invite session, the local_sdp
477 * argument MUST be NULL. This is because application
478 * can not perform more than one SDP offer/answer session
479 * in a single INVITE transaction.
480 * If application has not specified its media capability
481 * during creation of UAS invite session, it MAY or MUST
482 * specify its capability in local_sdp argument,
483 * depending whether st_code indicates a 2xx final
484 * response.
485 * @param p_tdata Pointer to receive the response message created by
486 * this function.
487 *
488 * @return PJ_SUCCESS if response message was created
489 * successfully.
490 */
491PJ_DECL(pj_status_t) pjsip_inv_answer( pjsip_inv_session *inv,
492 int st_code,
493 const pj_str_t *st_text,
494 const pjmedia_sdp_session *local_sdp,
495 pjsip_tx_data **p_tdata );
496
497
Benny Prijonoa66c7152006-02-09 01:26:14 +0000498/**
Benny Prijono26ff9062006-02-21 23:47:00 +0000499 * Set local answer to respond to remote SDP offer, to be carried by
500 * subsequent response (or request).
Benny Prijonoa66c7152006-02-09 01:26:14 +0000501 *
502 * @param inv The invite session.
503 * @param sdp The SDP description which will be set as answer
504 * to remote.
Benny Prijono26ff9062006-02-21 23:47:00 +0000505 *
506 * @return PJ_SUCCESS if local answer can be accepted by
507 * SDP negotiator.
Benny Prijonoa66c7152006-02-09 01:26:14 +0000508 */
Benny Prijono26ff9062006-02-21 23:47:00 +0000509PJ_DECL(pj_status_t) pjsip_inv_set_sdp_answer(pjsip_inv_session *inv,
510 const pjmedia_sdp_session *sdp );
511
Benny Prijonoa66c7152006-02-09 01:26:14 +0000512
Benny Prijono268ca612006-02-07 12:34:11 +0000513/**
514 * Create a SIP message to initiate invite session termination. Depending on
515 * the state of the session, this function may return CANCEL request,
516 * a non-2xx final response, or a BYE request. If the session has not answered
517 * the incoming INVITE, this function creates the non-2xx final response with
518 * the specified status code in st_code and optional status text in st_text.
519 *
520 * @param inv The invite session.
521 * @param st_code Status code to be used for terminating the session.
522 * @param st_text Optional status text.
523 * @param p_tdata Pointer to receive the message to be created.
524 *
525 * @return PJ_SUCCESS if termination message can be created.
526 */
527PJ_DECL(pj_status_t) pjsip_inv_end_session( pjsip_inv_session *inv,
528 int st_code,
529 const pj_str_t *st_text,
530 pjsip_tx_data **p_tdata );
531
532
533
534/**
535 * Create a re-INVITE request.
536 *
537 * @param inv The invite session.
538 * @param new_contact If application wants to update its local contact and
539 * inform peer to perform target refresh with a new
540 * contact, it can specify the new contact in this
541 * argument; otherwise this argument must be NULL.
542 * @param new_offer Application MAY initiate a new SDP offer/answer
543 * session in the request when there is no pending
544 * answer to be sent or received. It can detect this
545 * condition by observing the state of the SDP
546 * negotiator of the invite session. If new offer
547 * should be sent to remote, the offer must be specified
548 * in this argument, otherwise it must be NULL.
549 * @param p_tdata Pointer to receive the re-INVITE request message to
550 * be created.
551 *
552 * @return PJ_SUCCESS if a re-INVITE request with the specified
553 * characteristics (e.g. to contain new offer) can be
554 * created.
555 */
556PJ_DECL(pj_status_t) pjsip_inv_reinvite(pjsip_inv_session *inv,
557 const pj_str_t *new_contact,
558 const pjmedia_sdp_session *new_offer,
559 pjsip_tx_data **p_tdata );
560
561
562
563/**
564 * Create an UPDATE request.
565 *
566 * @param inv The invite session.
567 * @param new_contact If application wants to update its local contact
568 * and inform peer to perform target refresh with a new
569 * contact, it can specify the new contact in this
570 * argument; otherwise this argument must be NULL.
571 * @param new_offer Application MAY initiate a new SDP offer/answer
572 * session in the request when there is no pending answer
573 * to be sent or received. It can detect this condition
574 * by observing the state of the SDP negotiator of the
575 * invite session. If new offer should be sent to remote,
576 * the offer must be specified in this argument; otherwise
577 * this argument must be NULL.
578 * @param p_tdata Pointer to receive the UPDATE request message to
579 * be created.
580 *
581 * @return PJ_SUCCESS if a UPDATE request with the specified
582 * characteristics (e.g. to contain new offer) can be
583 * created.
584 */
585PJ_DECL(pj_status_t) pjsip_inv_update ( pjsip_inv_session *inv,
586 const pj_str_t *new_contact,
587 const pjmedia_sdp_session *new_offer,
588 pjsip_tx_data **p_tdata );
589
590
591/**
592 * Send request or response message in tdata.
593 *
594 * @param inv The invite session.
595 * @param tdata The message to be sent.
Benny Prijono268ca612006-02-07 12:34:11 +0000596 *
597 * @return PJ_SUCCESS if transaction can be initiated
598 * successfully to send this message. Note that the
599 * actual final state of the transaction itself will
600 * be reported later, in on_tsx_state_changed()
601 * callback.
602 */
603PJ_DECL(pj_status_t) pjsip_inv_send_msg(pjsip_inv_session *inv,
Benny Prijonoe8b0d3b2006-03-17 17:57:52 +0000604 pjsip_tx_data *tdata);
Benny Prijono268ca612006-02-07 12:34:11 +0000605
606
607
608/**
609 * Get the invite session for the dialog, if any.
610 *
611 * @param dlg The dialog which invite session is being queried.
612 *
613 * @return The invite session instance which has been
614 * associated with this dialog, or NULL.
615 */
616PJ_DECL(pjsip_inv_session*) pjsip_dlg_get_inv_session(pjsip_dialog *dlg);
617
618/**
619 * Get the invite session instance associated with transaction tsx, if any.
620 *
621 * @param tsx The transaction, which invite session is being
622 * queried.
623 *
624 * @return The invite session instance which has been
625 * associated with this transaction, or NULL.
626 */
627PJ_DECL(pjsip_inv_session*) pjsip_tsx_get_inv_session(pjsip_transaction *tsx);
628
629
Benny Prijonoe8b0d3b2006-03-17 17:57:52 +0000630/**
631 * Get state names for INVITE session state.
632 *
633 * @param state The invite state.
634 *
635 * @return String describing the state.
636 */
637PJ_DECL(const char *) pjsip_inv_state_name(pjsip_inv_state state);
638
Benny Prijono268ca612006-02-07 12:34:11 +0000639
Benny Prijono56315612006-07-18 14:39:40 +0000640/**
641 * This is a utility function to create SIP body for SDP content.
642 *
643 * @param pool Pool to allocate memory.
644 * @param sdp SDP session to be put in the SIP message body.
645 * @param p_body Pointer to receive SIP message body containing
646 * the SDP session.
647 *
648 * @return PJ_SUCCESS on success.
649 */
650PJ_DECL(pj_status_t) pjsip_create_sdp_body(pj_pool_t *pool,
651 pjmedia_sdp_session *sdp,
652 pjsip_msg_body **p_body);
653
654
Benny Prijonof3195072006-02-14 21:15:30 +0000655PJ_END_DECL
656
Benny Prijono312aff92006-06-17 04:08:30 +0000657/**
658 * @}
659 */
Benny Prijono268ca612006-02-07 12:34:11 +0000660
661
662#endif /* __SIP_INVITE_SESSION_H__ */