sip_inv.h 53 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224
  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 __SIP_INVITE_SESSION_H__
  20. #define __SIP_INVITE_SESSION_H__
  21. /**
  22. * @file sip_inv.h
  23. * @brief INVITE sessions
  24. */
  25. #include <pjsip/sip_dialog.h>
  26. #include <pjmedia/sdp_neg.h>
  27. /**
  28. * @defgroup PJSIP_HIGH_UA User Agent Library
  29. * @brief Mid-level User Agent Library.
  30. *
  31. * This is the high level user agent library, which consists of:
  32. * - @ref PJSIP_INV, to encapsulate INVITE sessions and SDP
  33. * negotiation in the session,
  34. * - @ref PJSUA_REGC, high level client registration API, and
  35. * - @ref PJSUA_XFER.
  36. *
  37. * More detailed information is explained in
  38. * <A HREF="/docs.htm">PJSIP Developer's Guide</A>
  39. * PDF document, and readers are encouraged to read the document to
  40. * get the concept behind dialog, dialog usages, and INVITE sessions.
  41. *
  42. * The User Agent Library is implemented in <b>pjsip-ua</b> static
  43. * library.
  44. */
  45. /**
  46. * @defgroup PJSIP_INV INVITE Session
  47. * @ingroup PJSIP_HIGH_UA
  48. * @brief Provides INVITE session management.
  49. * @{
  50. *
  51. * The INVITE session uses the @ref PJSIP_DIALOG framework to manage
  52. * the underlying dialog, and is one type of usages that can use
  53. * a particular dialog instance (other usages are event subscription,
  54. * discussed in @ref PJSIP_EVENT_NOT). The INVITE session manages
  55. * the life-time of the session, and also manages the SDP negotiation.
  56. *
  57. * Application must link with <b>pjsip-ua</b> static library to use this API.
  58. *
  59. * More detailed information is explained in
  60. * <A HREF="/docs.htm">PJSIP Developer's Guide</A>
  61. * PDF document, and readers are encouraged to read the document to
  62. * get the concept behind dialog, dialog usages, and INVITE sessions.
  63. *
  64. * The INVITE session does NOT manage media. If application wants to
  65. * use API that encapsulates both signaling and media in a very easy
  66. * to use API, it can use @ref PJSUA_LIB for this purpose.
  67. */
  68. PJ_BEGIN_DECL
  69. /**
  70. * @see pjsip_inv_session
  71. */
  72. typedef struct pjsip_inv_session pjsip_inv_session;
  73. /**
  74. * This enumeration describes invite session state.
  75. */
  76. typedef enum pjsip_inv_state
  77. {
  78. PJSIP_INV_STATE_NULL, /**< Before INVITE is sent or received */
  79. PJSIP_INV_STATE_CALLING, /**< After INVITE is sent */
  80. PJSIP_INV_STATE_INCOMING, /**< After INVITE is received. */
  81. PJSIP_INV_STATE_EARLY, /**< After response with To tag. */
  82. PJSIP_INV_STATE_CONNECTING, /**< After 2xx is sent/received. */
  83. PJSIP_INV_STATE_CONFIRMED, /**< After ACK is sent/received. */
  84. PJSIP_INV_STATE_DISCONNECTED, /**< Session is terminated. */
  85. } pjsip_inv_state;
  86. /**
  87. * Structure to hold parameters when calling the callback
  88. * on_rx_offer2().
  89. */
  90. struct pjsip_inv_on_rx_offer_cb_param
  91. {
  92. const pjmedia_sdp_session *offer; /**< Remote offer. */
  93. const pjsip_rx_data *rdata; /**< The received request. */
  94. };
  95. /**
  96. * This structure contains callbacks to be registered by application to
  97. * receive notifications from the framework about various events in
  98. * the invite session.
  99. */
  100. typedef struct pjsip_inv_callback
  101. {
  102. /**
  103. * This callback is called when the invite sesion state has changed.
  104. * Application should inspect the session state (inv_sess->state) to get
  105. * the current state of the session.
  106. *
  107. * This callback is mandatory.
  108. *
  109. * @param inv The invite session.
  110. * @param e The event which has caused the invite session's
  111. * state to change.
  112. */
  113. void (*on_state_changed)(pjsip_inv_session *inv, pjsip_event *e);
  114. /**
  115. * This callback is called when the invite usage module has created
  116. * a new dialog and invite because of forked outgoing request.
  117. *
  118. * Currently the invite session does not create a new dialog in
  119. * forking scenario, so this callback will never be invoked.
  120. *
  121. * @param inv The new invite session.
  122. * @param e The event which has caused the dialog to fork.
  123. * The type of this event can be either
  124. * PJSIP_EVENT_RX_MSG or PJSIP_EVENT_RX_200_MSG.
  125. */
  126. void (*on_new_session)(pjsip_inv_session *inv, pjsip_event *e);
  127. /**
  128. * This callback is called whenever any transactions within the session
  129. * has changed their state. Application MAY implement this callback,
  130. * e.g. to monitor the progress of an outgoing request, or to send
  131. * response to unhandled incoming request (such as INFO).
  132. *
  133. * This callback is optional.
  134. *
  135. * @param inv The invite session.
  136. * @param tsx The transaction, which state has changed.
  137. * @param e The event which has caused the transation state's
  138. * to change.
  139. */
  140. void (*on_tsx_state_changed)(pjsip_inv_session *inv,
  141. pjsip_transaction *tsx,
  142. pjsip_event *e);
  143. /**
  144. * This callback is called when the invite session has received
  145. * new offer from peer. Application can inspect the remote offer
  146. * in "offer", and set the SDP answer with #pjsip_inv_set_sdp_answer().
  147. * When the application sends a SIP message to send the answer,
  148. * this SDP answer will be negotiated with the offer, and the result
  149. * will be sent with the SIP message.
  150. *
  151. * Note: if callback #on_rx_offer2() is implemented, this callback will
  152. * not be called.
  153. *
  154. * @param inv The invite session.
  155. * @param offer Remote offer.
  156. */
  157. void (*on_rx_offer)(pjsip_inv_session *inv,
  158. const pjmedia_sdp_session *offer);
  159. /**
  160. * This callback is called when the invite session has received
  161. * new offer from peer. Variant of #on_rx_offer() callback.
  162. *
  163. * @param inv The invite session.
  164. * @param param The callback parameters.
  165. */
  166. void (*on_rx_offer2)(pjsip_inv_session *inv,
  167. struct pjsip_inv_on_rx_offer_cb_param *param);
  168. /**
  169. * This callback is optional, and is called when the invite session has
  170. * received a re-INVITE from the peer. It will be called after
  171. * on_rx_offer() callback and works only for re-INVITEs. It allows more
  172. * fine-grained control over the response to a re-INVITE, e.g. sending
  173. * a provisional response first. Application can return PJ_SUCCESS and
  174. * send a reply using the function #pjsip_inv_initial_answer() or
  175. * #pjsip_inv_answer(), as with the initial INVITE. If application
  176. * returns non-PJ_SUCCESS, it needs to set the SDP answer with
  177. * #pjsip_inv_set_sdp_answer() and the re-INVITE will be answered
  178. * automatically.
  179. *
  180. * Remarks: Application may need to monitor on_tsx_state_changed()
  181. * callback to check whether the re-INVITE is already answered
  182. * automatically with 487 due to being cancelled.
  183. *
  184. * @param inv The invite session.
  185. * @param offer Remote offer.
  186. * @param rdata The received re-INVITE request.
  187. *
  188. * @return - PJ_SUCCESS: application will answer the re-INVITE
  189. * manually
  190. * - non-PJ_SUCCESS: answer the re-INVITE automatically
  191. * using the SDP set via #pjsip_inv_set_sdp_answer()
  192. */
  193. pj_status_t (*on_rx_reinvite)(pjsip_inv_session *inv,
  194. const pjmedia_sdp_session *offer,
  195. pjsip_rx_data *rdata);
  196. /**
  197. * This callback is optional, and it is used to ask the application
  198. * to create a fresh offer, when the invite session has received
  199. * re-INVITE without offer. This offer then will be sent in the
  200. * 200/OK response to the re-INVITE request.
  201. *
  202. * If application doesn't implement this callback, the invite session
  203. * will send the currently active SDP as the offer.
  204. *
  205. * @param inv The invite session.
  206. * @param p_offer Pointer to receive the SDP offer created by
  207. * application.
  208. */
  209. void (*on_create_offer)(pjsip_inv_session *inv,
  210. pjmedia_sdp_session **p_offer);
  211. /**
  212. * This callback is called after SDP offer/answer session has completed.
  213. * The status argument specifies the status of the offer/answer,
  214. * i.e. whether the SDP answer is valid or the negotiation result
  215. * as returned by pjmedia_sdp_neg_negotiate().
  216. *
  217. * This callback is optional (from the point of view of the framework),
  218. * but all useful applications normally need to implement this callback.
  219. *
  220. * @param inv The invite session.
  221. * @param status The negotiation status.
  222. */
  223. void (*on_media_update)(pjsip_inv_session *inv_ses,
  224. pj_status_t status);
  225. /**
  226. * This callback is called when the framework needs to send
  227. * ACK request after it receives incoming 2xx response for
  228. * INVITE. It allows application to manually handle the
  229. * transmission of ACK request, which is required by some 3PCC
  230. * scenarios. If this callback is not implemented, the framework
  231. * will handle the ACK transmission automatically.
  232. *
  233. * When this callback is overridden, application may delay the
  234. * sending of the ACK request (for example, when it needs to
  235. * wait for answer from the other call leg, in 3PCC scenarios).
  236. *
  237. * Application MUST create the ACK request using pjsip_inv_create_ack()
  238. * and send it using pjsip_inv_send_msg().
  239. *
  240. * Once it has sent the ACK request, the framework will keep
  241. * this ACK request in the cache. Subsequent receipt of 2xx response
  242. * will not cause this callback to be called (but see exception below),
  243. * and instead automatic retransmission of this ACK request from
  244. * the cache will be done by the framework.
  245. * Exception: if app has created the ACK but has not sent it,
  246. * while it receives a retransmission of 2xx response, this callback
  247. * will be called again.
  248. *
  249. * This callback is optional.
  250. */
  251. void (*on_send_ack)(pjsip_inv_session *inv, pjsip_rx_data *rdata);
  252. /**
  253. * This callback is called when the session is about to resend the
  254. * INVITE request to the specified target, following the previously
  255. * received redirection response.
  256. *
  257. * Application may accept the redirection to the specified target
  258. * (the default behavior if this callback is implemented), reject
  259. * this target only and make the session continue to try the next
  260. * target in the list if such target exists, stop the whole
  261. * redirection process altogether and cause the session to be
  262. * disconnected, or defer the decision to ask for user confirmation.
  263. *
  264. * This callback is optional. If this callback is not implemented,
  265. * the default behavior is to NOT follow the redirection response.
  266. *
  267. * @param inv The invite session.
  268. * @param target The current target to be tried.
  269. * @param e The event that caused this callback to be called.
  270. * This could be the receipt of 3xx response, or
  271. * 4xx/5xx response received for the INVITE sent to
  272. * subsequent targets, or NULL if this callback is
  273. * called from within #pjsip_inv_process_redirect()
  274. * context.
  275. *
  276. * @return Action to be performed for the target. Set this
  277. * parameter to one of the value below:
  278. * - PJSIP_REDIRECT_ACCEPT: immediately accept the
  279. * redirection to this target. When set, the
  280. * session will immediately resend INVITE request
  281. * to the target after this callback returns.
  282. * - PJSIP_REDIRECT_REJECT: immediately reject this
  283. * target. The session will continue retrying with
  284. * next target if present, or disconnect the call
  285. * if there is no more target to try.
  286. * - PJSIP_REDIRECT_STOP: stop the whole redirection
  287. * process and immediately disconnect the call. The
  288. * on_state_changed() callback will be called with
  289. * PJSIP_INV_STATE_DISCONNECTED state immediately
  290. * after this callback returns.
  291. * - PJSIP_REDIRECT_PENDING: set to this value if
  292. * no decision can be made immediately (for example
  293. * to request confirmation from user). Application
  294. * then MUST call #pjsip_inv_process_redirect()
  295. * to either accept or reject the redirection upon
  296. * getting user decision.
  297. */
  298. pjsip_redirect_op (*on_redirected)(pjsip_inv_session *inv,
  299. const pjsip_uri *target,
  300. const pjsip_event *e);
  301. } pjsip_inv_callback;
  302. /**
  303. * This enumeration shows various options that can be applied to a session.
  304. * The bitmask combination of these options need to be specified when
  305. * creating a session. After the dialog is established (including early),
  306. * the options member of #pjsip_inv_session shows which capabilities are
  307. * common in both endpoints.
  308. */
  309. enum pjsip_inv_option
  310. {
  311. /**
  312. * Indicate support for reliable provisional response extension
  313. */
  314. PJSIP_INV_SUPPORT_100REL = 1,
  315. /**
  316. * Indicate support for session timer extension.
  317. */
  318. PJSIP_INV_SUPPORT_TIMER = 2,
  319. /**
  320. * Indicate support for UPDATE method. This is automatically implied
  321. * when creating outgoing dialog. After the dialog is established,
  322. * the options member of #pjsip_inv_session shows whether peer supports
  323. * this method as well.
  324. */
  325. PJSIP_INV_SUPPORT_UPDATE = 4,
  326. /**
  327. * Indicate support for ICE
  328. */
  329. PJSIP_INV_SUPPORT_ICE = 8,
  330. /**
  331. * Require ICE support.
  332. */
  333. PJSIP_INV_REQUIRE_ICE = 16,
  334. /**
  335. * Require reliable provisional response extension.
  336. */
  337. PJSIP_INV_REQUIRE_100REL = 32,
  338. /**
  339. * Require session timer extension.
  340. */
  341. PJSIP_INV_REQUIRE_TIMER = 64,
  342. /**
  343. * Session timer extension will always be used even when peer doesn't
  344. * support/want session timer.
  345. */
  346. PJSIP_INV_ALWAYS_USE_TIMER = 128,
  347. /**
  348. * Indicate support for trickle ICE
  349. */
  350. PJSIP_INV_SUPPORT_TRICKLE_ICE = 256,
  351. /**
  352. * Require trickle ICE support.
  353. */
  354. PJSIP_INV_REQUIRE_TRICKLE_ICE = 512,
  355. };
  356. /* Forward declaration of Session Timers */
  357. struct pjsip_timer;
  358. /**
  359. * This structure describes the invite session.
  360. *
  361. * Note regarding the invite session's pools. The inv_sess used to have
  362. * only one pool, which is just a pointer to the dialog's pool. Ticket
  363. * https://github.com/pjsip/pjproject/issues/877 has found that the memory
  364. * usage will grow considerably everytime re-INVITE or UPDATE is
  365. * performed.
  366. *
  367. * Ticket #877 then created two more memory pools for the inv_sess, so
  368. * now we have three memory pools:
  369. * - pool: to be used to allocate long term data for the session
  370. * - pool_prov and pool_active: this is a flip-flop pools to be used
  371. * interchangably during re-INVITE and UPDATE. pool_prov is
  372. * "provisional" pool, used to allocate SDP offer or answer for
  373. * the re-INVITE and UPDATE. Once SDP negotiation is done, the
  374. * provisional pool will be made as the active pool, then the
  375. * existing active pool will be reset, to release the memory
  376. * back to the OS. So these pool's lifetime is synchronized to
  377. * the SDP offer-answer negotiation.
  378. *
  379. * Higher level application such as PJSUA-LIB has been modified to
  380. * make use of these flip-flop pools, i.e. by creating media objects
  381. * from the provisional pool rather than from the long term pool.
  382. *
  383. * Other applications that want to use these pools must understand
  384. * that the flip-flop pool's lifetimes are synchronized to the
  385. * SDP offer-answer negotiation.
  386. *
  387. * The lifetime of this session is controlled by the reference counter in this
  388. * structure, which is manipulated by calling #pjsip_inv_add_ref and
  389. * #pjsip_inv_dec_ref. When the reference counter has reached zero, then
  390. * this session will be destroyed.
  391. */
  392. struct pjsip_inv_session
  393. {
  394. char obj_name[PJ_MAX_OBJ_NAME]; /**< Log identification */
  395. pj_pool_t *pool; /**< Long term pool. */
  396. pj_pool_t *pool_prov; /**< Provisional pool */
  397. pj_pool_t *pool_active; /**< Active/current pool*/
  398. pjsip_inv_state state; /**< Invite sess state. */
  399. pj_bool_t cancelling; /**< CANCEL requested */
  400. pj_bool_t pending_cancel; /**< Wait to send CANCEL*/
  401. pjsip_tx_data *pending_bye; /**< BYE to send later */
  402. pjsip_status_code cause; /**< Disconnect cause. */
  403. pj_str_t cause_text; /**< Cause text. */
  404. pj_bool_t notify; /**< Internal. */
  405. pj_bool_t sdp_done_early_rel; /**< Nego done in early
  406. med was reliable? */
  407. unsigned cb_called; /**< Cb has been called */
  408. pjsip_dialog *dlg; /**< Underlying dialog. */
  409. pjsip_role_e role; /**< Invite role. */
  410. unsigned options; /**< Options in use. */
  411. pjmedia_sdp_neg *neg; /**< Negotiator. */
  412. unsigned sdp_neg_flags; /**< SDP neg flags. */
  413. pjsip_transaction *invite_tsx; /**< 1st invite tsx. */
  414. pjsip_tx_data *invite_req; /**< Saved invite req */
  415. pjsip_tx_data *last_answer; /**< Last INVITE resp. */
  416. pjsip_tx_data *last_ack; /**< Last ACK request */
  417. pj_int32_t last_ack_cseq; /**< CSeq of last ACK */
  418. void *mod_data[PJSIP_MAX_MODULE];/**< Modules data. */
  419. struct pjsip_timer *timer; /**< Session Timers. */
  420. pj_bool_t following_fork; /**< Internal, following
  421. forked media? */
  422. pj_atomic_t *ref_cnt; /**< Reference counter. */
  423. pj_bool_t updated_sdp_answer; /**< SDP answer just been
  424. updated? */
  425. };
  426. /**
  427. * This structure represents SDP information in a pjsip_(rx|tx)_data. Application
  428. * retrieve this information by calling #pjsip_get_sdp_info(). This
  429. * mechanism supports multipart message body.
  430. */
  431. typedef struct pjsip_sdp_info
  432. {
  433. /**
  434. * Pointer and length of the text body in the incoming message. If
  435. * the pointer is NULL, it means the message does not contain SDP
  436. * body.
  437. */
  438. pj_str_t body;
  439. /**
  440. * This will contain non-zero if an invalid SDP body is found in the
  441. * message.
  442. */
  443. pj_status_t sdp_err;
  444. /**
  445. * A parsed and validated SDP body.
  446. */
  447. pjmedia_sdp_session *sdp;
  448. } pjsip_sdp_info;
  449. /**
  450. * For backwards compatibility and completeness,
  451. * pjsip_rdata_sdp_info and pjsip_tdata_sdp_info
  452. * are typedef'd to pjsip_sdp_info.
  453. */
  454. typedef pjsip_sdp_info pjsip_rdata_sdp_info;
  455. /**
  456. * For backwards compatibility and completeness,
  457. * pjsip_rdata_sdp_info and pjsip_tdata_sdp_info
  458. * are typedef'd to pjsip_sdp_info.
  459. */
  460. typedef pjsip_sdp_info pjsip_tdata_sdp_info;
  461. /**
  462. * Initialize the invite usage module and register it to the endpoint.
  463. * The callback argument contains pointer to functions to be called on
  464. * occurences of events in invite sessions.
  465. *
  466. * @param endpt The endpoint instance.
  467. * @param cb Callback structure.
  468. *
  469. * @return PJ_SUCCESS on success, or the appropriate error code.
  470. */
  471. PJ_DECL(pj_status_t) pjsip_inv_usage_init(pjsip_endpoint *endpt,
  472. const pjsip_inv_callback *cb);
  473. /**
  474. * Get the INVITE usage module instance.
  475. *
  476. * @return PJ_SUCCESS on success, or the appropriate error code.
  477. */
  478. PJ_DECL(pjsip_module*) pjsip_inv_usage_instance(void);
  479. /**
  480. * Dump user agent contents (e.g. all dialogs).
  481. */
  482. PJ_DECL(void) pjsip_inv_usage_dump(void);
  483. /**
  484. * Create UAC invite session for the specified dialog in dlg.
  485. *
  486. * @param dlg The dialog which will be used by this invite session.
  487. * @param local_sdp If application has determined its media capability,
  488. * it can specify the SDP here. Otherwise it can leave
  489. * this to NULL, if app wishes to specify the SDP at
  490. * a later time using the API pjsip_inv_set_local_sdp(),
  491. * or if it wants to let remote UAS specify an offer.
  492. * @param options The options argument is bitmask combination of SIP
  493. * features in pjsip_inv_option enumeration.
  494. * @param p_inv On successful return, the invite session will be put
  495. * in this argument.
  496. *
  497. * @return The function will return PJ_SUCCESS if it can create
  498. * the session. Otherwise the appropriate error status
  499. * will be returned on failure.
  500. */
  501. PJ_DECL(pj_status_t) pjsip_inv_create_uac(pjsip_dialog *dlg,
  502. const pjmedia_sdp_session *local_sdp,
  503. unsigned options,
  504. pjsip_inv_session **p_inv);
  505. /**
  506. * Application SHOULD call this function upon receiving the initial INVITE
  507. * request in rdata before creating the invite session (or even dialog),
  508. * to verify that the invite session can handle the INVITE request.
  509. * This function verifies that local endpoint is capable to handle required
  510. * SIP extensions in the request (i.e. Require header) and also the media,
  511. * if media description is present in the request.
  512. *
  513. * @param rdata The incoming INVITE request.
  514. *
  515. * @param options Upon calling this function, the options argument
  516. * MUST contain the desired SIP extensions to be
  517. * applied to the session. Upon return, this argument
  518. * will contain the SIP extension that will be applied
  519. * to the session, after considering the Supported,
  520. * Require, and Allow headers in the request.
  521. *
  522. * @param sdp If local media capability has been determined,
  523. * and if application wishes to verify that it can
  524. * handle the media offer in the incoming INVITE
  525. * request, it SHOULD specify its local media capability
  526. * in this argument.
  527. * If it is not specified, media verification will not
  528. * be performed by this function.
  529. *
  530. * @param dlg If tdata is not NULL, application needs to specify
  531. * how to create the response. Either dlg or endpt
  532. * argument MUST be specified, with dlg argument takes
  533. * precedence when both are specified.
  534. *
  535. * If a dialog has been created prior to calling this
  536. * function, then it MUST be specified in dlg argument.
  537. * Otherwise application MUST specify the endpt argument
  538. * (this is useful e.g. when application wants to send
  539. * the response statelessly).
  540. *
  541. * @param endpt If tdata is not NULL, application needs to specify
  542. * how to create the response. Either dlg or endpt
  543. * argument MUST be specified, with dlg argument takes
  544. * precedence when both are specified.
  545. *
  546. * @param tdata If this argument is not NULL, this function will
  547. * create the appropriate non-2xx final response message
  548. * when the verification fails.
  549. *
  550. * @return If everything has been negotiated successfully,
  551. * the function will return PJ_SUCCESS. Otherwise it
  552. * will return the reason of the failure as the return
  553. * code.
  554. *
  555. * This function is capable to create the appropriate
  556. * response message when the verification has failed.
  557. * If tdata is specified, then a non-2xx final response
  558. * will be created and put in this argument upon return,
  559. * when the verification has failed.
  560. *
  561. * If a dialog has been created prior to calling this
  562. * function, then it MUST be specified in dlg argument.
  563. * Otherwise application MUST specify the endpt argument
  564. * (this is useful e.g. when application wants to send
  565. * the response statelessly).
  566. *
  567. * @see pjsip_inv_verify_request2()
  568. */
  569. PJ_DECL(pj_status_t) pjsip_inv_verify_request( pjsip_rx_data *rdata,
  570. unsigned *options,
  571. const pjmedia_sdp_session *sdp,
  572. pjsip_dialog *dlg,
  573. pjsip_endpoint *endpt,
  574. pjsip_tx_data **tdata);
  575. /**
  576. * Variant of #pjsip_inv_verify_request() which allows application to specify
  577. * the parsed SDP in the \a offer argument. This is useful to avoid having to
  578. * re-parse the SDP in the incoming request.
  579. *
  580. * @see pjsip_inv_verify_request()
  581. */
  582. PJ_DECL(pj_status_t) pjsip_inv_verify_request2( pjsip_rx_data *rdata,
  583. unsigned *options,
  584. const pjmedia_sdp_session *offer,
  585. const pjmedia_sdp_session *answer,
  586. pjsip_dialog *dlg,
  587. pjsip_endpoint *endpt,
  588. pjsip_tx_data **tdata);
  589. /**
  590. * Variant of #pjsip_inv_verify_request() which allows application not to
  591. * specify the rdata (i.e. pass NULL as the rdata parameter) and specify
  592. * the parsed SDP in the \a offer argument and a temporary pool in the
  593. * \a tmp_pool argument.
  594. * This is useful if application no longer has access to the rdata.
  595. *
  596. * @see pjsip_inv_verify_request()
  597. */
  598. PJ_DECL(pj_status_t) pjsip_inv_verify_request3( pjsip_rx_data *rdata,
  599. pj_pool_t *tmp_pool,
  600. unsigned *options,
  601. const pjmedia_sdp_session *offer,
  602. const pjmedia_sdp_session *answer,
  603. pjsip_dialog *dlg,
  604. pjsip_endpoint *endpt,
  605. pjsip_tx_data **tdata);
  606. /**
  607. * Create UAS invite session for the specified dialog in dlg. Application
  608. * SHOULD call the verification function before calling this function,
  609. * to ensure that it can create the session successfully.
  610. *
  611. * @param dlg The dialog to be used.
  612. * @param rdata Application MUST specify the received INVITE request
  613. * in rdata. The invite session needs to inspect the
  614. * received request to see if the request contains
  615. * features that it supports.
  616. * @param local_sdp If application has determined its media capability,
  617. * it can specify this capability in this argument.
  618. * If SDP is received in the initial INVITE, the UAS
  619. * capability specified in this argument doesn't have to
  620. * match the received offer; the SDP negotiator is able
  621. * to rearrange the media lines in the answer so that it
  622. * matches the offer.
  623. * @param options The options argument is bitmask combination of SIP
  624. * features in pjsip_inv_option enumeration.
  625. * @param p_inv Pointer to receive the newly created invite session.
  626. *
  627. * @return On successful, the invite session will be put in
  628. * p_inv argument and the function will return PJ_SUCCESS.
  629. * Otherwise the appropriate error status will be returned
  630. * on failure.
  631. */
  632. PJ_DECL(pj_status_t) pjsip_inv_create_uas(pjsip_dialog *dlg,
  633. pjsip_rx_data *rdata,
  634. const pjmedia_sdp_session *local_sdp,
  635. unsigned options,
  636. pjsip_inv_session **p_inv);
  637. /**
  638. * Add reference counter to the INVITE session. The reference counter controls
  639. * the life time of the session, ie. when the counter reaches zero, then it
  640. * will be destroyed.
  641. *
  642. * @param inv The INVITE session.
  643. * @return PJ_SUCCESS if the INVITE session reference counter
  644. * was increased.
  645. */
  646. PJ_DECL(pj_status_t) pjsip_inv_add_ref( pjsip_inv_session *inv );
  647. /**
  648. * Decrement reference counter of the INVITE session.
  649. * When the session is no longer used, it will be destroyed and
  650. * caller is informed with PJ_EGONE return status.
  651. *
  652. * @param inv The INVITE session.
  653. * @return PJ_SUCCESS if the INVITE session reference counter
  654. * was decreased. A status PJ_EGONE will be returned to
  655. * inform that session is destroyed.
  656. */
  657. PJ_DECL(pj_status_t) pjsip_inv_dec_ref( pjsip_inv_session *inv );
  658. /**
  659. * Forcefully terminate and destroy INVITE session, regardless of
  660. * the state of the session. Note that this function should only be used
  661. * when there is failure in the INVITE session creation. After the
  662. * invite session has been created and initialized, normally application
  663. * SHOULD use #pjsip_inv_end_session() to end the INVITE session instead.
  664. *
  665. * Note also that this function may terminate the underlying dialog, if
  666. * there are no other sessions in the dialog.
  667. *
  668. * @param inv The invite session.
  669. * @param st_code Status code for the reason of the termination.
  670. * @param notify If set to non-zero, then on_state_changed()
  671. * callback will be called.
  672. *
  673. * @return PJ_SUCCESS if the INVITE session has been
  674. * terminated.
  675. */
  676. PJ_DECL(pj_status_t) pjsip_inv_terminate( pjsip_inv_session *inv,
  677. int st_code,
  678. pj_bool_t notify );
  679. /**
  680. * Restart UAC session and prepare the session for a new initial INVITE.
  681. * This function can be called for example when the application wants to
  682. * follow redirection response with a new call reusing this session so
  683. * that the new call will have the same Call-ID and From headers. After
  684. * the session is restarted, application may create and send a new INVITE
  685. * request.
  686. *
  687. * @param inv The invite session.
  688. * @param new_offer Should be set to PJ_TRUE since the application will
  689. * restart the session.
  690. *
  691. * @return PJ_SUCCESS on successful operation.
  692. */
  693. PJ_DECL(pj_status_t) pjsip_inv_uac_restart(pjsip_inv_session *inv,
  694. pj_bool_t new_offer);
  695. /**
  696. * Accept or reject redirection response. Application MUST call this function
  697. * after it signaled PJSIP_REDIRECT_PENDING in the \a on_redirected()
  698. * callback, to notify the invite session whether to accept or reject the
  699. * redirection to the current target. Application can use the combination of
  700. * PJSIP_REDIRECT_PENDING command in \a on_redirected() callback and this
  701. * function to ask for user permission before redirecting the call.
  702. *
  703. * Note that if the application chooses to reject or stop redirection (by
  704. * using PJSIP_REDIRECT_REJECT or PJSIP_REDIRECT_STOP respectively), the
  705. * session disconnection callback will be called before this function returns.
  706. * And if the application rejects the target, the \a on_redirected() callback
  707. * may also be called before this function returns if there is another target
  708. * to try.
  709. *
  710. * @param inv The invite session.
  711. * @param cmd Redirection operation. The semantic of this argument
  712. * is similar to the description in the \a on_redirected()
  713. * callback, except that the PJSIP_REDIRECT_PENDING is
  714. * not accepted here.
  715. * @param e Should be set to NULL.
  716. *
  717. * @return PJ_SUCCESS on successful operation.
  718. */
  719. PJ_DECL(pj_status_t) pjsip_inv_process_redirect(pjsip_inv_session *inv,
  720. pjsip_redirect_op cmd,
  721. pjsip_event *e);
  722. /**
  723. * Create the initial INVITE request for this session. This function can only
  724. * be called for UAC session. If local media capability is specified when
  725. * the invite session was created, then this function will put an SDP offer
  726. * in the outgoing INVITE request. Otherwise the outgoing request will not
  727. * contain SDP body.
  728. *
  729. * @param inv The UAC invite session.
  730. * @param p_tdata The initial INVITE request will be put in this
  731. * argument if it can be created successfully.
  732. *
  733. * @return PJ_SUCCESS if the INVITE request can be created.
  734. */
  735. PJ_DECL(pj_status_t) pjsip_inv_invite( pjsip_inv_session *inv,
  736. pjsip_tx_data **p_tdata );
  737. /**
  738. * Create the initial response message for the incoming INVITE request in
  739. * rdata with status code st_code and optional status text st_text. Use
  740. * #pjsip_inv_answer() to create subsequent response message.
  741. *
  742. * When this function returning non-PJ_SUCCESS, it may be caused by an
  743. * unacceptable INVITE request. In such cases the function will generate
  744. * an appropriate answer in p_tdata,
  745. * e.g: when session timer header Session-Expires is too low,
  746. * the generated answer will include Min-SE header.
  747. * If the generated answer is not sent, it must be destroyed.
  748. * i.e: using #pjsip_tx_data_dec_ref(), to avoid resource leak.
  749. *
  750. * @param inv The UAS invite session.
  751. * @param rdata The incoming request message.
  752. * @param st_code The st_code contains the status code to be sent,
  753. * which may be a provisional or final response.
  754. * @param st_text If custom status text is desired, application can
  755. * specify the text in st_text; otherwise if this
  756. * argument is NULL, default status text will be used.
  757. * @param sdp If application has specified its media capability
  758. * during creation of UAS invite session, the sdp
  759. * argument MUST be NULL. This is because application
  760. * can not perform more than one SDP offer/answer session
  761. * in a single INVITE transaction.
  762. * If application has not specified its media capability
  763. * during creation of UAS invite session, it MAY or MUST
  764. * specify its capability in sdp argument,
  765. * depending whether st_code indicates a 2xx final
  766. * response.
  767. * @param p_tdata Pointer to receive the response message created by
  768. * this function.
  769. *
  770. * @return PJ_SUCCESS if response message was created
  771. * successfully.
  772. */
  773. PJ_DECL(pj_status_t) pjsip_inv_initial_answer( pjsip_inv_session *inv,
  774. pjsip_rx_data *rdata,
  775. int st_code,
  776. const pj_str_t *st_text,
  777. const pjmedia_sdp_session *sdp,
  778. pjsip_tx_data **p_tdata);
  779. /**
  780. * Create a response message to an INVITE request.
  781. *
  782. * @param inv The UAS invite session.
  783. * @param st_code The st_code contains the status code to be sent,
  784. * which may be a provisional or final response.
  785. * @param st_text If custom status text is desired, application can
  786. * specify the text in st_text; otherwise if this
  787. * argument is NULL, default status text will be used.
  788. * @param local_sdp If application has specified its media capability
  789. * during creation of UAS invite session, the local_sdp
  790. * argument MUST be NULL. This is because application
  791. * can not perform more than one SDP offer/answer session
  792. * in a single INVITE transaction.
  793. * If application has not specified its media capability
  794. * during creation of UAS invite session, it MAY or MUST
  795. * specify its capability in local_sdp argument,
  796. * depending whether st_code indicates a 2xx final
  797. * response.
  798. * @param p_tdata Pointer to receive the response message created by
  799. * this function.
  800. *
  801. * @return PJ_SUCCESS if response message was created
  802. * successfully.
  803. */
  804. PJ_DECL(pj_status_t) pjsip_inv_answer( pjsip_inv_session *inv,
  805. int st_code,
  806. const pj_str_t *st_text,
  807. const pjmedia_sdp_session *local_sdp,
  808. pjsip_tx_data **p_tdata );
  809. /**
  810. * Set local offer or answer depending on negotiator state (it may also
  811. * create a negotiator if it doesn't exist yet).
  812. *
  813. * @param inv The invite session.
  814. * @param sdp The SDP description which will be set as
  815. * an offer/answer to remote.
  816. *
  817. * @return PJ_SUCCESS if local offer/answer can be accepted by
  818. * SDP negotiator.
  819. */
  820. PJ_DECL(pj_status_t) pjsip_inv_set_local_sdp(pjsip_inv_session *inv,
  821. const pjmedia_sdp_session *sdp );
  822. /**
  823. * Set local answer to respond to remote SDP offer, to be carried by
  824. * subsequent response (or request).
  825. *
  826. * @param inv The invite session.
  827. * @param sdp The SDP description which will be set as answer
  828. * to remote.
  829. *
  830. * @return PJ_SUCCESS if local answer can be accepted by
  831. * SDP negotiator.
  832. */
  833. PJ_DECL(pj_status_t) pjsip_inv_set_sdp_answer(pjsip_inv_session *inv,
  834. const pjmedia_sdp_session *sdp );
  835. /**
  836. * Create a SIP message to initiate invite session termination. Depending on
  837. * the state of the session, this function may return CANCEL request,
  838. * a non-2xx final response, a BYE request, or even no request.
  839. *
  840. * For UAS, if the session has not answered the incoming INVITE, this function
  841. * creates the non-2xx final response with the specified status code in
  842. * \a st_code and optional status text in \a st_text.
  843. *
  844. * For UAC, if the original INVITE has not been answered with a final
  845. * response, the behavior depends on whether provisional response has been
  846. * received. If provisional response has been received, this function will
  847. * create CANCEL request. If no provisional response has been received, the
  848. * function will not create CANCEL request (the function will return
  849. * PJ_SUCCESS but the \a p_tdata will contain NULL) because we cannot send
  850. * CANCEL before receiving provisional response. If then a provisional
  851. * response is received, the invite session will send CANCEL automatically.
  852. *
  853. * For both UAC and UAS, if the INVITE session has been answered with final
  854. * response, a BYE request will be created.
  855. *
  856. * @param inv The invite session.
  857. * @param st_code Status code to be used for terminating the session.
  858. * @param st_text Optional status text.
  859. * @param p_tdata Pointer to receive the message to be created. Note
  860. * that it's possible to receive NULL here while the
  861. * function returns PJ_SUCCESS, see the description.
  862. *
  863. * @return PJ_SUCCESS if termination is initiated.
  864. */
  865. PJ_DECL(pj_status_t) pjsip_inv_end_session( pjsip_inv_session *inv,
  866. int st_code,
  867. const pj_str_t *st_text,
  868. pjsip_tx_data **p_tdata );
  869. /**
  870. * Create a CANCEL request for an ongoing re-INVITE transaction. If no
  871. * provisional response has been received, the function will not create
  872. * CANCEL request (the function will return PJ_SUCCESS but the \a p_tdata
  873. * will contain NULL) because we cannot send CANCEL before receiving
  874. * provisional response. If then a provisional response is received,
  875. * the invite session will send CANCEL automatically.
  876. *
  877. * @param inv The invite session.
  878. * @param p_tdata Pointer to receive the message to be created. Note
  879. * that it's possible to receive NULL here while the
  880. * function returns PJ_SUCCESS, see the description.
  881. *
  882. * @return PJ_SUCCESS if termination is initiated.
  883. */
  884. PJ_DECL(pj_status_t) pjsip_inv_cancel_reinvite( pjsip_inv_session *inv,
  885. pjsip_tx_data **p_tdata );
  886. /**
  887. * Create a re-INVITE request.
  888. *
  889. * @param inv The invite session.
  890. * @param new_contact If application wants to update its local contact and
  891. * inform peer to perform target refresh with a new
  892. * contact, it can specify the new contact in this
  893. * argument; otherwise this argument must be NULL.
  894. * @param new_offer Application MAY initiate a new SDP offer/answer
  895. * session in the request when there is no pending
  896. * answer to be sent or received. It can detect this
  897. * condition by observing the state of the SDP
  898. * negotiator of the invite session. If new offer
  899. * should be sent to remote, the offer must be specified
  900. * in this argument, otherwise it must be NULL.
  901. * @param p_tdata Pointer to receive the re-INVITE request message to
  902. * be created.
  903. *
  904. * @return PJ_SUCCESS if a re-INVITE request with the specified
  905. * characteristics (e.g. to contain new offer) can be
  906. * created.
  907. */
  908. PJ_DECL(pj_status_t) pjsip_inv_reinvite(pjsip_inv_session *inv,
  909. const pj_str_t *new_contact,
  910. const pjmedia_sdp_session *new_offer,
  911. pjsip_tx_data **p_tdata );
  912. /**
  913. * Create an UPDATE request to initiate new SDP offer.
  914. *
  915. * @param inv The invite session.
  916. * @param new_contact If application wants to update its local contact
  917. * and inform peer to perform target refresh with a new
  918. * contact, it can specify the new contact in this
  919. * argument; otherwise this argument must be NULL.
  920. * @param offer Offer to be sent to remote. This argument is
  921. * mandatory.
  922. * @param p_tdata Pointer to receive the UPDATE request message to
  923. * be created.
  924. *
  925. * @return PJ_SUCCESS if a UPDATE request with the specified
  926. * characteristics (e.g. to contain new offer) can be
  927. * created.
  928. */
  929. PJ_DECL(pj_status_t) pjsip_inv_update ( pjsip_inv_session *inv,
  930. const pj_str_t *new_contact,
  931. const pjmedia_sdp_session *offer,
  932. pjsip_tx_data **p_tdata );
  933. /**
  934. * Create an ACK request. Normally ACK request transmission is handled
  935. * by the framework. Application only needs to use this function if it
  936. * handles the ACK transmission manually, by overriding \a on_send_ack()
  937. * callback in #pjsip_inv_callback.
  938. *
  939. * Note that if the invite session has a pending offer to be answered
  940. * (for example when the last 2xx response to INVITE contains an offer),
  941. * application MUST have set the SDP answer with #pjsip_inv_set_sdp_answer()
  942. * prior to creating the ACK request. In this case, the ACK request
  943. * will be added with SDP message body.
  944. *
  945. * @param inv The invite session.
  946. * @param cseq Mandatory argument to specify the CSeq of the
  947. * ACK request. This value MUST match the value
  948. * of the INVITE transaction to be acknowledged.
  949. * @param p_tdata Pointer to receive the ACK request message to
  950. * be created.
  951. *
  952. * @return PJ_SUCCESS if ACK request has been created.
  953. */
  954. PJ_DECL(pj_status_t) pjsip_inv_create_ack(pjsip_inv_session *inv,
  955. int cseq,
  956. pjsip_tx_data **p_tdata);
  957. /**
  958. * Send request or response message in tdata.
  959. *
  960. * @param inv The invite session.
  961. * @param tdata The message to be sent.
  962. *
  963. * @return PJ_SUCCESS if transaction can be initiated
  964. * successfully to send this message. Note that the
  965. * actual final state of the transaction itself will
  966. * be reported later, in on_tsx_state_changed()
  967. * callback.
  968. */
  969. PJ_DECL(pj_status_t) pjsip_inv_send_msg(pjsip_inv_session *inv,
  970. pjsip_tx_data *tdata);
  971. /**
  972. * Get the invite session for the dialog, if any.
  973. *
  974. * @param dlg The dialog which invite session is being queried.
  975. *
  976. * @return The invite session instance which has been
  977. * associated with this dialog, or NULL.
  978. */
  979. PJ_DECL(pjsip_inv_session*) pjsip_dlg_get_inv_session(pjsip_dialog *dlg);
  980. /**
  981. * Get the invite session instance associated with transaction tsx, if any.
  982. *
  983. * @param tsx The transaction, which invite session is being
  984. * queried.
  985. *
  986. * @return The invite session instance which has been
  987. * associated with this transaction, or NULL.
  988. */
  989. PJ_DECL(pjsip_inv_session*) pjsip_tsx_get_inv_session(pjsip_transaction *tsx);
  990. /**
  991. * Get state names for INVITE session state.
  992. *
  993. * @param state The invite state.
  994. *
  995. * @return String describing the state.
  996. */
  997. PJ_DECL(const char *) pjsip_inv_state_name(pjsip_inv_state state);
  998. /**
  999. * This is a utility function to create SIP body for SDP content.
  1000. *
  1001. * @param pool Pool to allocate memory.
  1002. * @param sdp SDP session to be put in the SIP message body.
  1003. * @param p_body Pointer to receive SIP message body containing
  1004. * the SDP session.
  1005. *
  1006. * @return PJ_SUCCESS on success.
  1007. */
  1008. PJ_DECL(pj_status_t) pjsip_create_sdp_body(pj_pool_t *pool,
  1009. pjmedia_sdp_session *sdp,
  1010. pjsip_msg_body **p_body);
  1011. /**
  1012. * This is a utility function to create a multipart body with the
  1013. * SIP body as the first part.
  1014. *
  1015. * @param pool Pool to allocate memory.
  1016. * @param sdp SDP session to be put in the SIP message body.
  1017. * @param p_body Pointer to receive SIP message body containing
  1018. * the SDP session.
  1019. *
  1020. * @return PJ_SUCCESS on success.
  1021. */
  1022. PJ_DECL(pj_status_t) pjsip_create_multipart_sdp_body( pj_pool_t *pool,
  1023. pjmedia_sdp_session *sdp,
  1024. pjsip_msg_body **p_body);
  1025. /**
  1026. * Retrieve SDP information from a message body. Application should
  1027. * prefer to use this function rather than parsing the SDP manually since
  1028. * this function supports multipart message body.
  1029. *
  1030. * This function will only parse the SDP once, the first time it is called
  1031. * on the same message. Subsequent call on the same message will just pick
  1032. * up the already parsed SDP from the message.
  1033. *
  1034. * @param pool Pool to allocate memory.
  1035. * @param body The message body.
  1036. * @param msg_media_type From the rdata or tdata Content-Type header, if available.
  1037. * If NULL, the content_type from the body will be used.
  1038. * @param search_media_type The media type to search for.
  1039. * If NULL, "application/sdp" will be used.
  1040. *
  1041. * @return The SDP info.
  1042. */
  1043. PJ_DECL(pjsip_sdp_info*) pjsip_get_sdp_info(pj_pool_t *pool,
  1044. pjsip_msg_body *body,
  1045. pjsip_media_type *msg_media_type,
  1046. const pjsip_media_type *search_media_type);
  1047. /**
  1048. * Retrieve SDP information from an incoming message. Application should
  1049. * prefer to use this function rather than parsing the SDP manually since
  1050. * this function supports multipart message body.
  1051. *
  1052. * This function will only parse the SDP once, the first time it is called
  1053. * on the same message. Subsequent call on the same message will just pick
  1054. * up the already parsed SDP from the message.
  1055. *
  1056. * @param rdata The incoming message.
  1057. *
  1058. * @return The SDP info.
  1059. */
  1060. PJ_DECL(pjsip_rdata_sdp_info*) pjsip_rdata_get_sdp_info(pjsip_rx_data *rdata);
  1061. /**
  1062. * Retrieve SDP information from an incoming message. Application should
  1063. * prefer to use this function rather than parsing the SDP manually since
  1064. * this function supports multipart message body.
  1065. *
  1066. * This function will only parse the SDP once, the first time it is called
  1067. * on the same message. Subsequent call on the same message will just pick
  1068. * up the already parsed SDP from the message.
  1069. *
  1070. * @param rdata The incoming message.
  1071. * @param search_media_type The SDP media type to search for.
  1072. * If NULL, "application/sdp" will be used.
  1073. *
  1074. * @return The SDP info.
  1075. */
  1076. PJ_DECL(pjsip_rdata_sdp_info*) pjsip_rdata_get_sdp_info2(
  1077. pjsip_rx_data *rdata,
  1078. const pjsip_media_type *search_media_type);
  1079. /**
  1080. * Retrieve SDP information from an outgoing message. Application should
  1081. * prefer to use this function rather than parsing the SDP manually since
  1082. * this function supports multipart message body.
  1083. *
  1084. * This function will only parse the SDP once, the first time it is called
  1085. * on the same message. Subsequent call on the same message will just pick
  1086. * up the already parsed SDP from the message.
  1087. *
  1088. * @param tdata The outgoing message.
  1089. *
  1090. * @return The SDP info.
  1091. */
  1092. PJ_DECL(pjsip_tdata_sdp_info*) pjsip_tdata_get_sdp_info(pjsip_tx_data *tdata);
  1093. /**
  1094. * Retrieve SDP information from an outgoing message. Application should
  1095. * prefer to use this function rather than parsing the SDP manually since
  1096. * this function supports multipart message body.
  1097. *
  1098. * This function will only parse the SDP once, the first time it is called
  1099. * on the same message. Subsequent call on the same message will just pick
  1100. * up the already parsed SDP from the message.
  1101. *
  1102. * @param tdata The outgoing message.
  1103. * @param search_media_type The SDP media type to search for.
  1104. * If NULL, "application/sdp" will be used.
  1105. *
  1106. * @return The SDP info.
  1107. */
  1108. PJ_DECL(pjsip_tdata_sdp_info*) pjsip_tdata_get_sdp_info2(
  1109. pjsip_tx_data *tdata,
  1110. const pjsip_media_type *search_media_type);
  1111. PJ_END_DECL
  1112. /**
  1113. * @}
  1114. */
  1115. #endif /* __SIP_INVITE_SESSION_H__ */