call.hpp 69 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266
  1. /*
  2. * Copyright (C) 2012-2013 Teluu Inc. (http://www.teluu.com)
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  17. */
  18. #ifndef __PJSUA2_CALL_HPP__
  19. #define __PJSUA2_CALL_HPP__
  20. /**
  21. * @file pjsua2/call.hpp
  22. * @brief PJSUA2 Call manipulation
  23. */
  24. #include <pjsua-lib/pjsua.h>
  25. #include <pjsua2/media.hpp>
  26. /** PJSUA2 API is inside pj namespace */
  27. namespace pj
  28. {
  29. /**
  30. * @defgroup PJSUA2_CALL Call
  31. * @ingroup PJSUA2_Ref
  32. */
  33. /**
  34. * @defgroup PJSUA2_Call_Data_Structure Call Related Types
  35. * @ingroup PJSUA2_DS
  36. * @{
  37. */
  38. using std::string;
  39. using std::vector;
  40. //////////////////////////////////////////////////////////////////////////////
  41. /**
  42. * Media stream, corresponds to pjmedia_stream
  43. */
  44. typedef void *MediaStream;
  45. /**
  46. * Media transport, corresponds to pjmedia_transport
  47. */
  48. typedef void *MediaTransport;
  49. /**
  50. * This structure describes statistics state.
  51. */
  52. struct MathStat
  53. {
  54. int n; /**< number of samples */
  55. int max; /**< maximum value */
  56. int min; /**< minimum value */
  57. int last; /**< last value */
  58. int mean; /**< mean */
  59. public:
  60. /**
  61. * Default constructor
  62. */
  63. MathStat();
  64. /**
  65. * Convert from pjsip
  66. */
  67. void fromPj(const pj_math_stat &prm);
  68. };
  69. /**
  70. * Types of loss detected.
  71. */
  72. struct LossType
  73. {
  74. unsigned burst; /**< Burst/sequential packet lost detected */
  75. unsigned random; /**< Random packet lost detected. */
  76. };
  77. /**
  78. * Unidirectional RTP stream statistics.
  79. */
  80. struct RtcpStreamStat
  81. {
  82. TimeVal update; /**< Time of last update. */
  83. unsigned updateCount;/**< Number of updates (to calculate avg) */
  84. unsigned pkt; /**< Total number of packets */
  85. unsigned bytes; /**< Total number of payload/bytes */
  86. unsigned discard; /**< Total number of discarded packets. */
  87. unsigned loss; /**< Total number of packets lost */
  88. unsigned reorder; /**< Total number of out of order packets */
  89. unsigned dup; /**< Total number of duplicates packets */
  90. MathStat lossPeriodUsec; /**< Loss period statistics */
  91. LossType lossType; /**< Types of loss detected. */
  92. MathStat jitterUsec; /**< Jitter statistics */
  93. public:
  94. /**
  95. * Convert from pjsip
  96. */
  97. void fromPj(const pjmedia_rtcp_stream_stat &prm);
  98. };
  99. /**
  100. * RTCP SDES structure.
  101. */
  102. struct RtcpSdes
  103. {
  104. string cname; /**< RTCP SDES type CNAME. */
  105. string name; /**< RTCP SDES type NAME. */
  106. string email; /**< RTCP SDES type EMAIL. */
  107. string phone; /**< RTCP SDES type PHONE. */
  108. string loc; /**< RTCP SDES type LOC. */
  109. string tool; /**< RTCP SDES type TOOL. */
  110. string note; /**< RTCP SDES type NOTE. */
  111. public:
  112. /**
  113. * Convert from pjsip
  114. */
  115. void fromPj(const pjmedia_rtcp_sdes &prm);
  116. };
  117. /**
  118. * Bidirectional RTP stream statistics.
  119. */
  120. struct RtcpStat
  121. {
  122. TimeVal start; /**< Time when session was created */
  123. RtcpStreamStat txStat; /**< Encoder stream statistics. */
  124. RtcpStreamStat rxStat; /**< Decoder stream statistics. */
  125. MathStat rttUsec; /**< Round trip delay statistic. */
  126. pj_uint32_t rtpTxLastTs; /**< Last TX RTP timestamp. */
  127. pj_uint16_t rtpTxLastSeq; /**< Last TX RTP sequence. */
  128. MathStat rxIpdvUsec; /**< Statistics of IP packet delay
  129. variation in receiving
  130. direction. It is only used when
  131. PJMEDIA_RTCP_STAT_HAS_IPDV is
  132. set to non-zero. */
  133. MathStat rxRawJitterUsec;/**< Statistic of raw jitter in
  134. receiving direction. It is only
  135. used when
  136. PJMEDIA_RTCP_STAT_HAS_RAW_JITTER
  137. is set to non-zero. */
  138. RtcpSdes peerSdes; /**< Peer SDES. */
  139. public:
  140. /**
  141. * Convert from pjsip
  142. */
  143. void fromPj(const pjmedia_rtcp_stat &prm);
  144. };
  145. /**
  146. * This structure describes jitter buffer state.
  147. */
  148. struct JbufState
  149. {
  150. /* Setting */
  151. unsigned frameSize; /**< Individual frame size, in bytes. */
  152. unsigned minPrefetch; /**< Minimum allowed prefetch, in frms. */
  153. unsigned maxPrefetch; /**< Maximum allowed prefetch, in frms. */
  154. /* Status */
  155. unsigned burst; /**< Current burst level, in frames */
  156. unsigned prefetch; /**< Current prefetch value, in frames */
  157. unsigned size; /**< Current buffer size, in frames. */
  158. /* Statistic */
  159. unsigned avgDelayMsec; /**< Average delay, in ms. */
  160. unsigned minDelayMsec; /**< Minimum delay, in ms. */
  161. unsigned maxDelayMsec; /**< Maximum delay, in ms. */
  162. unsigned devDelayMsec; /**< Standard deviation of delay, in ms.*/
  163. unsigned avgBurst; /**< Average burst, in frames. */
  164. unsigned lost; /**< Number of lost frames. */
  165. unsigned discard; /**< Number of discarded frames. */
  166. unsigned empty; /**< Number of empty on GET events. */
  167. public:
  168. /**
  169. * Convert from pjsip
  170. */
  171. void fromPj(const pjmedia_jb_state &prm);
  172. };
  173. /**
  174. * This structure describes SDP session description. It corresponds to the
  175. * pjmedia_sdp_session structure.
  176. */
  177. struct SdpSession
  178. {
  179. /**
  180. * The whole SDP as a string.
  181. */
  182. string wholeSdp;
  183. /**
  184. * Pointer to its original pjmedia_sdp_session. Only valid when the struct
  185. * is converted from PJSIP's pjmedia_sdp_session.
  186. */
  187. void *pjSdpSession;
  188. public:
  189. /**
  190. * Convert from pjsip
  191. */
  192. void fromPj(const pjmedia_sdp_session &sdp);
  193. };
  194. /**
  195. * This structure describes media transport informations. It corresponds to the
  196. * pjmedia_transport_info structure. The address name field can be empty string
  197. * if the address in the pjmedia_transport_info is invalid.
  198. */
  199. struct MediaTransportInfo
  200. {
  201. /**
  202. * Address to be advertised as the local address for the RTP socket,
  203. * which does not need to be equal as the bound address (for example,
  204. * this address can be the address resolved with STUN).
  205. */
  206. SocketAddress localRtpName;
  207. /**
  208. * Address to be advertised as the local address for the RTCP socket,
  209. * which does not need to be equal as the bound address (for example,
  210. * this address can be the address resolved with STUN).
  211. */
  212. SocketAddress localRtcpName;
  213. /**
  214. * Remote address where RTP originated from. This can be empty string if
  215. * no data is received from the remote.
  216. */
  217. SocketAddress srcRtpName;
  218. /**
  219. * Remote address where RTCP originated from. This can be empty string if
  220. * no data is recevied from the remote.
  221. */
  222. SocketAddress srcRtcpName;
  223. public:
  224. /**
  225. * Convert from pjsip
  226. */
  227. void fromPj(const pjmedia_transport_info &info);
  228. };
  229. //////////////////////////////////////////////////////////////////////////////
  230. /** Array of media direction */
  231. typedef IntVector MediaDirVector;
  232. /**
  233. * Call settings.
  234. */
  235. struct CallSetting
  236. {
  237. /**
  238. * Bitmask of pjsua_call_flag constants.
  239. *
  240. * Default: PJSUA_CALL_INCLUDE_DISABLED_MEDIA
  241. */
  242. unsigned flag;
  243. /**
  244. * This flag controls what methods to request keyframe are allowed on
  245. * the call. Value is bitmask of pjsua_vid_req_keyframe_method.
  246. *
  247. * Default: PJSUA_VID_REQ_KEYFRAME_SIP_INFO |
  248. * PJSUA_VID_REQ_KEYFRAME_RTCP_PLI
  249. */
  250. unsigned reqKeyframeMethod;
  251. /**
  252. * Number of simultaneous active audio streams for this call. Setting
  253. * this to zero will disable audio in this call.
  254. *
  255. * Default: 1
  256. */
  257. unsigned audioCount;
  258. /**
  259. * Number of simultaneous active video streams for this call. Setting
  260. * this to zero will disable video in this call.
  261. *
  262. * Default: 1 (if video feature is enabled, otherwise it is zero)
  263. */
  264. unsigned videoCount;
  265. /**
  266. * Media direction. This setting will only be used if the flag
  267. * PJSUA_CALL_SET_MEDIA_DIR is set, and it will persist for subsequent
  268. * offers or answers.
  269. * For example, a media that is set as PJMEDIA_DIR_ENCODING can only
  270. * mark the stream in the SDP as sendonly or inactive, but will not
  271. * become sendrecv in subsequent offers and answers.
  272. * Application can update the media direction in any API or callback
  273. * that accepts CallSetting as a parameter, such as via
  274. * Call::reinvite/update() or in onCallRxOffer/Reinvite()
  275. * callback.
  276. *
  277. * The index of the media dir will correspond to the provisional media
  278. * in CallInfo.provMedia.
  279. * For offers that involve adding new medias (such as initial offer),
  280. * the index will correspond to all new audio media first, then video.
  281. * For example, for a new call with 2 audios and 1 video, mediaDir[0]
  282. * and mediaDir[1] will be for the audios, and mediaDir[2] video.
  283. *
  284. * Default: empty vector
  285. */
  286. MediaDirVector mediaDir;
  287. /**
  288. * User defined Call-ID to be sent out with outgoing INVITE.
  289. *
  290. * Note: It is up to the developer to verify uniqueness of the
  291. * Call-ID as there will be no verification. The developer must
  292. * change the Call-ID between calls creating a unique id for each
  293. * outgoing call.
  294. *
  295. * This setting will only be used when creating a new outgoing call
  296. * via Call::makeCall().
  297. */
  298. string customCallId;
  299. public:
  300. /**
  301. * Default constructor initializes with empty or default values.
  302. */
  303. CallSetting(bool useDefaultValues = false);
  304. /**
  305. * Check if the settings are set with empty values.
  306. *
  307. * @return True if the settings are empty.
  308. */
  309. bool isEmpty() const;
  310. /**
  311. * Convert from pjsip
  312. */
  313. void fromPj(const pjsua_call_setting &prm);
  314. /**
  315. * Convert to pjsip
  316. */
  317. pjsua_call_setting toPj() const;
  318. };
  319. /**
  320. * Call media information.
  321. *
  322. * Application can query conference bridge port of this media using
  323. * Call::getAudioMedia() if the media type is audio,
  324. * or Call::getEncodingVideoMedia() / Call::getDecodingVideoMedia()
  325. * if the media type is video.
  326. */
  327. struct CallMediaInfo
  328. {
  329. /**
  330. * Media index in SDP.
  331. */
  332. unsigned index;
  333. /**
  334. * Media type.
  335. */
  336. pjmedia_type type;
  337. /**
  338. * Media direction.
  339. */
  340. pjmedia_dir dir;
  341. /**
  342. * Call media status.
  343. */
  344. pjsua_call_media_status status;
  345. /**
  346. * Warning: this is deprecated, application can query conference bridge
  347. * port of this media using Call::getAudioMedia().
  348. *
  349. * The conference port number for the call. Only valid if the media type
  350. * is audio.
  351. */
  352. int audioConfSlot;
  353. /**
  354. * The window id for incoming video, if any, or
  355. * PJSUA_INVALID_ID. Only valid if the media type is video.
  356. */
  357. pjsua_vid_win_id videoIncomingWindowId;
  358. /**
  359. * The video window instance for incoming video. Only valid if
  360. * videoIncomingWindowId is not PJSUA_INVALID_ID and
  361. * the media type is video.
  362. */
  363. VideoWindow videoWindow;
  364. /**
  365. * The video capture device for outgoing transmission, if any,
  366. * or PJMEDIA_VID_INVALID_DEV. Only valid if the media type is video.
  367. */
  368. pjmedia_vid_dev_index videoCapDev;
  369. public:
  370. /**
  371. * Default constructor
  372. */
  373. CallMediaInfo();
  374. /**
  375. * Convert from pjsip
  376. */
  377. void fromPj(const pjsua_call_media_info &prm);
  378. };
  379. /** Array of call media info */
  380. typedef std::vector<CallMediaInfo> CallMediaInfoVector;
  381. /**
  382. * Call information. Application can query the call information
  383. * by calling Call::getInfo().
  384. */
  385. struct CallInfo
  386. {
  387. /**
  388. * Call identification.
  389. */
  390. pjsua_call_id id;
  391. /**
  392. * Initial call role (UAC == caller)
  393. */
  394. pjsip_role_e role;
  395. /**
  396. * The account ID where this call belongs.
  397. */
  398. pjsua_acc_id accId;
  399. /**
  400. * Local URI
  401. */
  402. string localUri;
  403. /**
  404. * Local Contact
  405. */
  406. string localContact;
  407. /**
  408. * Remote URI
  409. */
  410. string remoteUri;
  411. /**
  412. * Remote contact
  413. */
  414. string remoteContact;
  415. /**
  416. * Dialog Call-ID string.
  417. */
  418. string callIdString;
  419. /**
  420. * Call setting
  421. */
  422. CallSetting setting;
  423. /**
  424. * Call state
  425. */
  426. pjsip_inv_state state;
  427. /**
  428. * Text describing the state
  429. */
  430. string stateText;
  431. /**
  432. * Last status code heard, which can be used as cause code
  433. */
  434. pjsip_status_code lastStatusCode;
  435. /**
  436. * The reason phrase describing the last status.
  437. */
  438. string lastReason;
  439. /**
  440. * Array of active media information.
  441. */
  442. CallMediaInfoVector media;
  443. /**
  444. * Array of provisional media information. This contains the media info
  445. * in the provisioning state, that is when the media session is being
  446. * created/updated (SDP offer/answer is on progress).
  447. */
  448. CallMediaInfoVector provMedia;
  449. /**
  450. * Up-to-date call connected duration (zero when call is not
  451. * established)
  452. */
  453. TimeVal connectDuration;
  454. /**
  455. * Total call duration, including set-up time
  456. */
  457. TimeVal totalDuration;
  458. /**
  459. * Flag if remote was SDP offerer
  460. */
  461. bool remOfferer;
  462. /**
  463. * Number of audio streams offered by remote
  464. */
  465. unsigned remAudioCount;
  466. /**
  467. * Number of video streams offered by remote
  468. */
  469. unsigned remVideoCount;
  470. public:
  471. /**
  472. * Default constructor
  473. */
  474. CallInfo() : id(PJSUA_INVALID_ID),
  475. role(PJSIP_ROLE_UAC),
  476. accId(PJSUA_INVALID_ID),
  477. state(PJSIP_INV_STATE_NULL),
  478. lastStatusCode(PJSIP_SC_NULL),
  479. remOfferer(false),
  480. remAudioCount(0),
  481. remVideoCount(0)
  482. {}
  483. /**
  484. * Convert from pjsip
  485. */
  486. void fromPj(const pjsua_call_info &pci);
  487. };
  488. /**
  489. * Media stream info.
  490. */
  491. struct StreamInfo
  492. {
  493. /**
  494. * Media type of this stream.
  495. */
  496. pjmedia_type type;
  497. /**
  498. * Transport protocol (RTP/AVP, etc.)
  499. */
  500. pjmedia_tp_proto proto;
  501. /**
  502. * Media direction.
  503. */
  504. pjmedia_dir dir;
  505. /**
  506. * Remote RTP address
  507. */
  508. SocketAddress remoteRtpAddress;
  509. /**
  510. * Optional remote RTCP address
  511. */
  512. SocketAddress remoteRtcpAddress;
  513. /**
  514. * Outgoing codec payload type.
  515. */
  516. unsigned txPt;
  517. /**
  518. * Incoming codec payload type.
  519. */
  520. unsigned rxPt;
  521. /**
  522. * Outgoing pt for audio telephone-events.
  523. */
  524. int audTxEventPt;
  525. /**
  526. * Incoming pt for audio telephone-events.
  527. */
  528. int audRxEventPt;
  529. /**
  530. * Codec name.
  531. */
  532. string codecName;
  533. /**
  534. * Codec clock rate.
  535. */
  536. unsigned codecClockRate;
  537. /**
  538. * Optional audio codec param.
  539. */
  540. CodecParam audCodecParam;
  541. /**
  542. * Optional video codec param.
  543. */
  544. VidCodecParam vidCodecParam;
  545. /**
  546. * Jitter buffer init delay in msec.
  547. */
  548. int jbInit;
  549. /**
  550. * Jitter buffer minimum prefetch delay in msec.
  551. */
  552. int jbMinPre;
  553. /**
  554. * Jitter buffer maximum prefetch delay in msec.
  555. */
  556. int jbMaxPre;
  557. /**
  558. * Jitter buffer max delay in msec.
  559. */
  560. int jbMax;
  561. /**
  562. * Jitter buffer discard algorithm.
  563. */
  564. pjmedia_jb_discard_algo jbDiscardAlgo;
  565. #if defined(PJMEDIA_STREAM_ENABLE_KA) && PJMEDIA_STREAM_ENABLE_KA!=0
  566. /**
  567. * Stream keep-alive and NAT hole punch (see #PJMEDIA_STREAM_ENABLE_KA) is
  568. * enabled?
  569. */
  570. bool useKa;
  571. #endif
  572. /**
  573. * Disable automatic sending of RTCP SDES and BYE.
  574. */
  575. bool rtcpSdesByeDisabled;
  576. public:
  577. /**
  578. * Default constructor
  579. */
  580. StreamInfo()
  581. : type(PJMEDIA_TYPE_NONE),
  582. proto(PJMEDIA_TP_PROTO_NONE),
  583. dir(PJMEDIA_DIR_NONE),
  584. txPt(0),
  585. rxPt(0),
  586. audTxEventPt(0),
  587. audRxEventPt(0),
  588. codecClockRate(0),
  589. jbInit(-1),
  590. jbMinPre(-1),
  591. jbMaxPre(-1),
  592. jbMax(-1),
  593. jbDiscardAlgo(PJMEDIA_JB_DISCARD_NONE),
  594. #if defined(PJMEDIA_STREAM_ENABLE_KA) && PJMEDIA_STREAM_ENABLE_KA!=0
  595. useKa(false),
  596. #endif
  597. rtcpSdesByeDisabled(false)
  598. {}
  599. /**
  600. * Convert from pjsip
  601. */
  602. void fromPj(const pjsua_stream_info &info);
  603. };
  604. /**
  605. * Media stream statistic.
  606. */
  607. struct StreamStat
  608. {
  609. /**
  610. * RTCP statistic.
  611. */
  612. RtcpStat rtcp;
  613. /**
  614. * Jitter buffer statistic.
  615. */
  616. JbufState jbuf;
  617. public:
  618. /**
  619. * Convert from pjsip
  620. */
  621. void fromPj(const pjsua_stream_stat &prm);
  622. };
  623. /**
  624. * This structure contains parameters for Call::onCallState() callback.
  625. */
  626. struct OnCallStateParam
  627. {
  628. /**
  629. * Event which causes the call state to change.
  630. */
  631. SipEvent e;
  632. };
  633. /**
  634. * This structure contains parameters for Call::onCallTsxState() callback.
  635. */
  636. struct OnCallTsxStateParam
  637. {
  638. /**
  639. * Transaction event that caused the state change.
  640. */
  641. SipEvent e;
  642. };
  643. /**
  644. * This structure contains parameters for Call::onCallMediaState() callback.
  645. */
  646. struct OnCallMediaStateParam
  647. {
  648. };
  649. /**
  650. * This structure contains parameters for Call::onCallSdpCreated() callback.
  651. */
  652. struct OnCallSdpCreatedParam
  653. {
  654. /**
  655. * The SDP has just been created.
  656. */
  657. SdpSession sdp;
  658. /**
  659. * The remote SDP, will be empty if local is SDP offerer.
  660. */
  661. SdpSession remSdp;
  662. };
  663. /**
  664. * This structure contains parameters for Call::onStreamPreCreate()
  665. * callback.
  666. */
  667. struct OnStreamPreCreateParam
  668. {
  669. /**
  670. * Stream index in the media session, read-only.
  671. */
  672. unsigned streamIdx;
  673. /**
  674. * Parameters that the stream will be created from.
  675. */
  676. StreamInfo streamInfo;
  677. };
  678. /**
  679. * This structure contains parameters for Call::onStreamCreated()
  680. * callback.
  681. */
  682. struct OnStreamCreatedParam
  683. {
  684. /**
  685. * Audio media stream, read-only.
  686. */
  687. MediaStream stream;
  688. /**
  689. * Stream index in the audio media session, read-only.
  690. */
  691. unsigned streamIdx;
  692. /**
  693. * Specify if PJSUA2 should take ownership of the port returned in
  694. * the pPort parameter below. If set to true,
  695. * pjmedia_port_destroy() will be called on the port when it is
  696. * no longer needed.
  697. *
  698. * Default: false
  699. */
  700. bool destroyPort;
  701. /**
  702. * On input, it specifies the audio media port of the stream. Application
  703. * may modify this pointer to point to different media port to be
  704. * registered to the conference bridge.
  705. */
  706. MediaPort pPort;
  707. };
  708. /**
  709. * This structure contains parameters for Call::onStreamDestroyed()
  710. * callback.
  711. */
  712. struct OnStreamDestroyedParam
  713. {
  714. /**
  715. * Audio media stream.
  716. */
  717. MediaStream stream;
  718. /**
  719. * Stream index in the audio media session.
  720. */
  721. unsigned streamIdx;
  722. };
  723. /**
  724. * This structure contains parameters for Call::onDtmfDigit()
  725. * callback.
  726. */
  727. struct OnDtmfDigitParam
  728. {
  729. /**
  730. * DTMF sending method.
  731. */
  732. pjsua_dtmf_method method;
  733. /**
  734. * DTMF ASCII digit.
  735. */
  736. string digit;
  737. /**
  738. * DTMF signal duration. If the duration is unknown, this value is set to
  739. * PJSUA_UNKNOWN_DTMF_DURATION.
  740. */
  741. unsigned duration;
  742. };
  743. /**
  744. * This structure contains parameters for Call::onDtmfEvent()
  745. * callback.
  746. */
  747. struct OnDtmfEventParam
  748. {
  749. /**
  750. * DTMF sending method.
  751. */
  752. pjsua_dtmf_method method;
  753. /**
  754. * The timestamp identifying the begin of the event. Timestamp units are
  755. * expressed in milliseconds.
  756. * Note that this value should only be used to compare multiple events
  757. * received via the same method relatively to each other, as the time-base
  758. * is randomized.
  759. */
  760. unsigned timestamp;
  761. /**
  762. * DTMF ASCII digit.
  763. */
  764. string digit;
  765. /**
  766. * DTMF signal duration in milliseconds. Interpretation of the duration
  767. * depends on the flag PJMEDIA_STREAM_DTMF_IS_END.
  768. * depends on the method.
  769. * If the method is PJSUA_DTMF_METHOD_SIP_INFO, this contains the total
  770. * duration of the DTMF signal or PJSUA_UNKNOWN_DTMF_DURATION if no signal
  771. * duration was indicated.
  772. * If the method is PJSUA_DTMF_METHOD_RFC2833, this contains the total
  773. * duration of the DTMF signal received up to this point in time.
  774. */
  775. unsigned duration;
  776. /**
  777. * Flags indicating additional information about the DTMF event.
  778. * If PJMEDIA_STREAM_DTMF_IS_UPDATE is set, the event was already
  779. * indicated earlier. The new indication contains an updated event
  780. * duration.
  781. * If PJMEDIA_STREAM_DTMF_IS_END is set, the event has ended and this
  782. * indication contains the final event duration. Note that end
  783. * indications might get lost. Hence it is not guaranteed to receive
  784. * an event with PJMEDIA_STREAM_DTMF_IS_END for every event.
  785. */
  786. unsigned flags;
  787. };
  788. /**
  789. * This structure contains parameters for Call::onCallTransferRequest()
  790. * callback.
  791. */
  792. struct OnCallTransferRequestParam
  793. {
  794. /**
  795. * The destination where the call will be transferred to.
  796. */
  797. string dstUri;
  798. /**
  799. * Status code to be returned for the call transfer request. On input,
  800. * it contains status code 202.
  801. */
  802. pjsip_status_code statusCode;
  803. /**
  804. * The current call setting, application can update this setting
  805. * for the call being transferred.
  806. */
  807. CallSetting opt;
  808. /**
  809. * New Call derived object instantiated by application when the call
  810. * transfer is about to be accepted.
  811. */
  812. Call *newCall;
  813. };
  814. /**
  815. * This structure contains parameters for Call::onCallTransferStatus()
  816. * callback.
  817. */
  818. struct OnCallTransferStatusParam
  819. {
  820. /**
  821. * Status progress of the transfer request.
  822. */
  823. pjsip_status_code statusCode;
  824. /**
  825. * Status progress reason.
  826. */
  827. string reason;
  828. /**
  829. * If true, no further notification will be reported. The statusCode
  830. * specified in this callback is the final status.
  831. */
  832. bool finalNotify;
  833. /**
  834. * Initially will be set to true, application can set this to false
  835. * if it no longer wants to receive further notification (for example,
  836. * after it hangs up the call).
  837. */
  838. bool cont;
  839. };
  840. /**
  841. * This structure contains parameters for Call::onCallReplaceRequest()
  842. * callback.
  843. */
  844. struct OnCallReplaceRequestParam
  845. {
  846. /**
  847. * The incoming INVITE request to replace the call.
  848. */
  849. SipRxData rdata;
  850. /**
  851. * Status code to be set by application. Application should only
  852. * return a final status (>= PJSIP_SC_OK (200))
  853. */
  854. pjsip_status_code statusCode;
  855. /**
  856. * Optional status text to be set by application.
  857. */
  858. string reason;
  859. /**
  860. * The current call setting, application can update this setting for
  861. * the call being replaced.
  862. */
  863. CallSetting opt;
  864. /**
  865. * New Call derived object instantiated by application.
  866. */
  867. Call *newCall;
  868. };
  869. /**
  870. * This structure contains parameters for Call::onCallReplaced() callback.
  871. */
  872. struct OnCallReplacedParam
  873. {
  874. /**
  875. * The new call id.
  876. */
  877. pjsua_call_id newCallId;
  878. /**
  879. * New Call derived object instantiated by application.
  880. */
  881. Call *newCall;
  882. };
  883. /**
  884. * This structure contains parameters for Call::onCallRxOffer() callback.
  885. */
  886. struct OnCallRxOfferParam
  887. {
  888. /**
  889. * The new offer received.
  890. */
  891. SdpSession offer;
  892. /**
  893. * Status code to be returned for answering the offer. On input,
  894. * it contains status code PJSIP_SC_OK (200). Currently, valid values are only
  895. * PJSIP_SC_OK (200) and PJSIP_SC_NOT_ACCEPTABLE_HERE (488).
  896. */
  897. pjsip_status_code statusCode;
  898. /**
  899. * The current call setting, application can update this setting for
  900. * answering the offer.
  901. */
  902. CallSetting opt;
  903. };
  904. /**
  905. * This structure contains parameters for Call::onCallRxReinvite() callback.
  906. */
  907. struct OnCallRxReinviteParam
  908. {
  909. /**
  910. * The new offer received.
  911. */
  912. SdpSession offer;
  913. /**
  914. * The incoming re-INVITE.
  915. */
  916. SipRxData rdata;
  917. /**
  918. * On input, it is false. Set to true if app wants to manually answer
  919. * the re-INVITE.
  920. */
  921. bool isAsync;
  922. /**
  923. * Status code to be returned for answering the offer. On input,
  924. * it contains status code PJSIP_SC_OK (200). Currently, valid values are only
  925. * PJSIP_SC_OK (200) and PJSIP_SC_NOT_ACCEPTABLE_HERE (488).
  926. */
  927. pjsip_status_code statusCode;
  928. /**
  929. * The current call setting, application can update this setting for
  930. * answering the offer.
  931. */
  932. CallSetting opt;
  933. };
  934. /**
  935. * This structure contains parameters for Call::onCallTxOffer() callback.
  936. */
  937. struct OnCallTxOfferParam
  938. {
  939. /**
  940. * The current call setting, application can update this setting for
  941. * generating the offer. Note that application should maintain any
  942. * active media to avoid the need for the peer to reject the offer.
  943. */
  944. CallSetting opt;
  945. };
  946. /**
  947. * This structure contains parameters for Call::onCallRedirected() callback.
  948. */
  949. struct OnCallRedirectedParam
  950. {
  951. /**
  952. * The current target to be tried.
  953. */
  954. string targetUri;
  955. /**
  956. * The event that caused this callback to be called.
  957. * This could be the receipt of 3xx response, or 4xx/5xx response
  958. * received for the INVITE sent to subsequent targets, or empty
  959. * (e.type == PJSIP_EVENT_UNKNOWN) if this callback is called from
  960. * within Call::processRedirect() context.
  961. */
  962. SipEvent e;
  963. };
  964. /**
  965. * This structure contains parameters for Call::onCallMediaEvent() callback.
  966. */
  967. struct OnCallMediaEventParam
  968. {
  969. /**
  970. * The media stream index.
  971. */
  972. unsigned medIdx;
  973. /**
  974. * The media event.
  975. */
  976. MediaEvent ev;
  977. };
  978. /**
  979. * This structure contains parameters for Call::onCallMediaTransportState()
  980. * callback.
  981. */
  982. struct OnCallMediaTransportStateParam
  983. {
  984. /**
  985. * The media index.
  986. */
  987. unsigned medIdx;
  988. /**
  989. * The media transport state
  990. */
  991. pjsua_med_tp_st state;
  992. /**
  993. * The last error code related to the media transport state.
  994. */
  995. pj_status_t status;
  996. /**
  997. * Optional SIP error code.
  998. */
  999. int sipErrorCode;
  1000. };
  1001. /**
  1002. * This structure contains parameters for Call::onCreateMediaTransport()
  1003. * callback.
  1004. */
  1005. struct OnCreateMediaTransportParam
  1006. {
  1007. /**
  1008. * The media index in the SDP for which this media transport will be used.
  1009. */
  1010. unsigned mediaIdx;
  1011. /**
  1012. * The media transport which otherwise will be used by the call has this
  1013. * callback not been implemented. Application can change this to its own
  1014. * instance of media transport to be used by the call.
  1015. */
  1016. MediaTransport mediaTp;
  1017. /**
  1018. * Bitmask from pjsua_create_media_transport_flag.
  1019. */
  1020. unsigned flags;
  1021. };
  1022. /**
  1023. * This structure contains parameters for Call::onCreateMediaTransportSrtp()
  1024. * callback.
  1025. */
  1026. struct OnCreateMediaTransportSrtpParam
  1027. {
  1028. /**
  1029. * The media index in the SDP for which the SRTP media transport
  1030. * will be used.
  1031. */
  1032. unsigned mediaIdx;
  1033. /**
  1034. * Specify whether secure media transport should be used. Application
  1035. * can modify this only for initial INVITE.
  1036. * Valid values are PJMEDIA_SRTP_DISABLED, PJMEDIA_SRTP_OPTIONAL, and
  1037. * PJMEDIA_SRTP_MANDATORY.
  1038. */
  1039. pjmedia_srtp_use srtpUse;
  1040. /**
  1041. * Application can modify this to specify the cryptos and keys
  1042. * which are going to be used.
  1043. */
  1044. SrtpCryptoVector cryptos;
  1045. };
  1046. /**
  1047. * @} // PJSUA2_Call_Data_Structure
  1048. */
  1049. /**
  1050. * @addtogroup PJSUA2_CALL
  1051. * @{
  1052. */
  1053. /**
  1054. * This structure contains parameters for Call::answer(), Call::hangup(),
  1055. * Call::reinvite(), Call::update(), Call::xfer(), Call::xferReplaces(),
  1056. * Call::setHold().
  1057. */
  1058. struct CallOpParam
  1059. {
  1060. /**
  1061. * The call setting.
  1062. */
  1063. CallSetting opt;
  1064. /**
  1065. * Status code.
  1066. */
  1067. pjsip_status_code statusCode;
  1068. /**
  1069. * Reason phrase.
  1070. */
  1071. string reason;
  1072. /**
  1073. * Options.
  1074. */
  1075. unsigned options;
  1076. /**
  1077. * List of headers etc to be added to outgoing response message.
  1078. * Note that this message data will be persistent in all next
  1079. * answers/responses for this INVITE request.
  1080. */
  1081. SipTxOption txOption;
  1082. /**
  1083. * SDP answer. Currently only used for Call::answer().
  1084. */
  1085. SdpSession sdp;
  1086. public:
  1087. /**
  1088. * Default constructor initializes with zero/empty values.
  1089. * Setting useDefaultCallSetting to true will initialize opt with default
  1090. * call setting values.
  1091. */
  1092. CallOpParam(bool useDefaultCallSetting = false);
  1093. };
  1094. /**
  1095. * This structure contains parameters for Call::sendRequest()
  1096. */
  1097. struct CallSendRequestParam
  1098. {
  1099. /**
  1100. * SIP method of the request.
  1101. */
  1102. string method;
  1103. /**
  1104. * Message body and/or list of headers etc to be included in
  1105. * outgoing request.
  1106. */
  1107. SipTxOption txOption;
  1108. public:
  1109. /**
  1110. * Default constructor initializes with zero/empty values.
  1111. */
  1112. CallSendRequestParam();
  1113. };
  1114. /**
  1115. * This structure contains parameters for Call::vidSetStream()
  1116. */
  1117. struct CallVidSetStreamParam
  1118. {
  1119. /**
  1120. * Specify the media stream index. This can be set to -1 to denote
  1121. * the default video stream in the call, which is the first active
  1122. * video stream or any first video stream if none is active.
  1123. *
  1124. * This field is valid for all video stream operations, except
  1125. * PJSUA_CALL_VID_STRM_ADD.
  1126. *
  1127. * Default: -1 (first active video stream, or any first video stream
  1128. * if none is active)
  1129. */
  1130. int medIdx;
  1131. /**
  1132. * Specify the media stream direction.
  1133. *
  1134. * This field is valid for the following video stream operations:
  1135. * PJSUA_CALL_VID_STRM_ADD and PJSUA_CALL_VID_STRM_CHANGE_DIR.
  1136. *
  1137. * Default: PJMEDIA_DIR_ENCODING_DECODING
  1138. */
  1139. pjmedia_dir dir;
  1140. /**
  1141. * Specify the video capture device ID. This can be set to
  1142. * PJMEDIA_VID_DEFAULT_CAPTURE_DEV to specify the default capture
  1143. * device as configured in the account.
  1144. *
  1145. * This field is valid for the following video stream operations:
  1146. * PJSUA_CALL_VID_STRM_ADD and PJSUA_CALL_VID_STRM_CHANGE_CAP_DEV.
  1147. *
  1148. * Default: PJMEDIA_VID_DEFAULT_CAPTURE_DEV.
  1149. */
  1150. pjmedia_vid_dev_index capDev;
  1151. public:
  1152. /**
  1153. * Default constructor
  1154. */
  1155. CallVidSetStreamParam();
  1156. };
  1157. /**
  1158. * This structure contains parameters for Call::sendDtmf()
  1159. */
  1160. struct CallSendDtmfParam
  1161. {
  1162. /**
  1163. * The method used to send DTMF.
  1164. *
  1165. * Default: PJSUA_DTMF_METHOD_RFC2833
  1166. */
  1167. pjsua_dtmf_method method;
  1168. /**
  1169. * The signal duration used for the DTMF.
  1170. *
  1171. * Default: PJSUA_CALL_SEND_DTMF_DURATION_DEFAULT
  1172. */
  1173. unsigned duration;
  1174. /**
  1175. * The DTMF digits to be sent.
  1176. */
  1177. string digits;
  1178. public:
  1179. /**
  1180. * Default constructor initialize with default value.
  1181. */
  1182. CallSendDtmfParam();
  1183. /**
  1184. * Convert to pjsip.
  1185. */
  1186. pjsua_call_send_dtmf_param toPj() const;
  1187. /**
  1188. * Convert from pjsip.
  1189. */
  1190. void fromPj(const pjsua_call_send_dtmf_param &param);
  1191. };
  1192. /**
  1193. * Call.
  1194. */
  1195. class Call
  1196. {
  1197. public:
  1198. /**
  1199. * Constructor.
  1200. */
  1201. Call(Account& acc, int call_id = PJSUA_INVALID_ID);
  1202. /**
  1203. * Destructor.
  1204. */
  1205. virtual ~Call();
  1206. /**
  1207. * Obtain detail information about this call.
  1208. *
  1209. * @return Call info.
  1210. */
  1211. CallInfo getInfo() const PJSUA2_THROW(Error);
  1212. /**
  1213. * Check if this call has active INVITE session and the INVITE
  1214. * session has not been disconnected.
  1215. *
  1216. * @return True if call is active.
  1217. */
  1218. bool isActive() const;
  1219. /**
  1220. * Get PJSUA-LIB call ID or index associated with this call.
  1221. *
  1222. * @return Integer greater than or equal to zero.
  1223. */
  1224. int getId() const;
  1225. /**
  1226. * Get the Call class for the specified call Id.
  1227. *
  1228. * @param call_id The call ID to lookup
  1229. *
  1230. * @return The Call instance or NULL if not found.
  1231. */
  1232. static Call *lookup(int call_id);
  1233. /**
  1234. * Check if call has an active media session.
  1235. *
  1236. * @return True if yes.
  1237. */
  1238. bool hasMedia() const;
  1239. /**
  1240. * Warning: deprecated, use getAudioMedia() instead. This function is not
  1241. * safe in multithreaded environment.
  1242. *
  1243. * Get media for the specified media index.
  1244. *
  1245. * @param med_idx Media index.
  1246. *
  1247. * @return The media or NULL if invalid or inactive.
  1248. */
  1249. Media *getMedia(unsigned med_idx) const;
  1250. /**
  1251. * Get audio media for the specified media index. If the specified media
  1252. * index is not audio or invalid or inactive, exception will be thrown.
  1253. *
  1254. * @param med_idx Media index, or -1 to specify any first audio
  1255. * media registered in the conference bridge.
  1256. *
  1257. * @return The audio media.
  1258. */
  1259. AudioMedia getAudioMedia(int med_idx) const PJSUA2_THROW(Error);
  1260. /**
  1261. * Get video media in encoding direction for the specified media index.
  1262. * If the specified media index is not video or invalid or the direction
  1263. * is receive only, exception will be thrown.
  1264. *
  1265. * @param med_idx Media index, or -1 to specify any first video
  1266. * media with encoding direction registered in the
  1267. * conference bridge.
  1268. *
  1269. * @return The video media.
  1270. */
  1271. VideoMedia getEncodingVideoMedia(int med_idx) const PJSUA2_THROW(Error);
  1272. /**
  1273. * Get video media in decoding direction for the specified media index.
  1274. * If the specified media index is not video or invalid or the direction
  1275. * is send only, exception will be thrown.
  1276. *
  1277. * @param med_idx Media index, or -1 to specify any first video
  1278. * media with decoding direction registered in the
  1279. * conference bridge.
  1280. *
  1281. * @return The video media.
  1282. */
  1283. VideoMedia getDecodingVideoMedia(int med_idx) const PJSUA2_THROW(Error);
  1284. /**
  1285. * Check if remote peer support the specified capability.
  1286. *
  1287. * @param htype The header type (pjsip_hdr_e) to be checked, which
  1288. * value may be:
  1289. * - PJSIP_H_ACCEPT
  1290. * - PJSIP_H_ALLOW
  1291. * - PJSIP_H_SUPPORTED
  1292. * @param hname If htype specifies PJSIP_H_OTHER, then the header
  1293. * name must be supplied in this argument. Otherwise
  1294. * the value must be set to empty string ("").
  1295. * @param token The capability token to check. For example, if \a
  1296. * htype is PJSIP_H_ALLOW, then \a token specifies the
  1297. * method names; if \a htype is PJSIP_H_SUPPORTED, then
  1298. * \a token specifies the extension names such as
  1299. * "100rel".
  1300. *
  1301. * @return PJSIP_DIALOG_CAP_SUPPORTED if the specified
  1302. * capability is explicitly supported, see
  1303. * pjsip_dialog_cap_status for more info.
  1304. */
  1305. pjsip_dialog_cap_status remoteHasCap(int htype,
  1306. const string &hname,
  1307. const string &token) const;
  1308. /**
  1309. * Attach application specific data to the call. Application can then
  1310. * inspect this data by calling getUserData().
  1311. *
  1312. * @param user_data Arbitrary data to be attached to the call.
  1313. */
  1314. void setUserData(Token user_data);
  1315. /**
  1316. * Get user data attached to the call, which has been previously set with
  1317. * setUserData().
  1318. *
  1319. * @return The user data.
  1320. */
  1321. Token getUserData() const;
  1322. /**
  1323. * Get the NAT type of remote's endpoint. This is a proprietary feature
  1324. * of PJSUA-LIB which sends its NAT type in the SDP when \a natTypeInSdp
  1325. * is set in UaConfig.
  1326. *
  1327. * This function can only be called after SDP has been received from remote,
  1328. * which means for incoming call, this function can be called as soon as
  1329. * call is received as long as incoming call contains SDP, and for outgoing
  1330. * call, this function can be called only after SDP is received (normally in
  1331. * PJSIP_SC_OK (200) response to INVITE). As a general case, application
  1332. * should call this function after or in \a onCallMediaState() callback.
  1333. *
  1334. * @return The NAT type.
  1335. *
  1336. * @see Endpoint::natGetType(), natTypeInSdp
  1337. */
  1338. pj_stun_nat_type getRemNatType() PJSUA2_THROW(Error);
  1339. /**
  1340. * Make outgoing call to the specified URI.
  1341. *
  1342. * @param dst_uri URI to be put in the To header (normally is the same
  1343. * as the target URI).
  1344. * @param prm.opt Optional call setting.
  1345. * @param prm.txOption Optional headers etc to be added to outgoing INVITE
  1346. * request.
  1347. */
  1348. void makeCall(const string &dst_uri, const CallOpParam &prm)
  1349. PJSUA2_THROW(Error);
  1350. /**
  1351. * Send response to incoming INVITE request with call setting param.
  1352. * Depending on the status code specified as parameter, this function may
  1353. * send provisional response, establish the call, or terminate the call.
  1354. * Notes about call setting:
  1355. * - if call setting is changed in the subsequent call to this function,
  1356. * only the first call setting supplied will applied. So normally
  1357. * application will not supply call setting before getting confirmation
  1358. * from the user.
  1359. * - if no call setting is supplied when SDP has to be sent, i.e: answer
  1360. * with status code 183 or 2xx, the default call setting will be used,
  1361. * check CallSetting for its default values.
  1362. *
  1363. * @param prm.opt Optional call setting.
  1364. * @param prm.statusCode Status code, (>= PJSIP_SC_TRYING (100)).
  1365. * @param prm.reason Optional reason phrase. If empty, default text
  1366. * will be used.
  1367. * @param prm.txOption Optional list of headers etc to be added to outgoing
  1368. * response message. Note that this message data will
  1369. * be persistent in all next answers/responses for this
  1370. * INVITE request.
  1371. */
  1372. void answer(const CallOpParam &prm) PJSUA2_THROW(Error);
  1373. /**
  1374. * Hangup call by using method that is appropriate according to the
  1375. * call state. This function is different than answering the call with
  1376. * 3xx-6xx response (with answer()), in that this function
  1377. * will hangup the call regardless of the state and role of the call,
  1378. * while answer() only works with incoming calls on EARLY
  1379. * state.
  1380. *
  1381. * @param prm.statusCode
  1382. * Optional status code to be sent when we're rejecting
  1383. * incoming call. If the value is zero, "603/Decline"
  1384. * will be sent.
  1385. * @param prm.reason Optional reason phrase to be sent when we're
  1386. * rejecting incoming call. If empty, default text
  1387. * will be used.
  1388. * @param prm.txOption Optional list of headers etc to be added to outgoing
  1389. * request/response message.
  1390. */
  1391. void hangup(const CallOpParam &prm) PJSUA2_THROW(Error);
  1392. /**
  1393. * Put the specified call on hold. This will send re-INVITE with the
  1394. * appropriate SDP to inform remote that the call is being put on hold.
  1395. * The final status of the request itself will be reported on the
  1396. * \a onCallMediaState() callback, which inform the application that
  1397. * the media state of the call has changed.
  1398. *
  1399. * @param prm.options Bitmask of pjsua_call_flag constants. Currently,
  1400. * only the flag PJSUA_CALL_UPDATE_CONTACT can be used.
  1401. * @param prm.txOption Optional message components to be sent with
  1402. * the request.
  1403. */
  1404. void setHold(const CallOpParam &prm) PJSUA2_THROW(Error);
  1405. /**
  1406. * Send re-INVITE.
  1407. * The final status of the request itself will be reported on the
  1408. * \a onCallMediaState() callback, which inform the application that
  1409. * the media state of the call has changed.
  1410. *
  1411. * @param prm.opt Optional call setting, if empty, the current call
  1412. * setting will remain unchanged.
  1413. * @param prm.opt.flag Bitmask of pjsua_call_flag constants. Specifying
  1414. * PJSUA_CALL_UNHOLD here will release call hold.
  1415. * @param prm.txOption Optional message components to be sent with
  1416. * the request.
  1417. */
  1418. void reinvite(const CallOpParam &prm) PJSUA2_THROW(Error);
  1419. /**
  1420. * Send UPDATE request.
  1421. *
  1422. * @param prm.opt Optional call setting, if empty, the current call
  1423. * setting will remain unchanged.
  1424. * @param prm.txOption Optional message components to be sent with
  1425. * the request.
  1426. */
  1427. void update(const CallOpParam &prm) PJSUA2_THROW(Error);
  1428. /**
  1429. * Initiate call transfer to the specified address. This function will send
  1430. * REFER request to instruct remote call party to initiate a new INVITE
  1431. * session to the specified destination/target.
  1432. *
  1433. * If application is interested to monitor the successfulness and
  1434. * the progress of the transfer request, it can implement
  1435. * \a onCallTransferStatus() callback which will report the progress
  1436. * of the call transfer request.
  1437. *
  1438. * @param dest URI of new target to be contacted. The URI may be
  1439. * in name address or addr-spec format.
  1440. * @param prm.txOption Optional message components to be sent with
  1441. * the request.
  1442. */
  1443. void xfer(const string &dest, const CallOpParam &prm) PJSUA2_THROW(Error);
  1444. /**
  1445. * Initiate attended call transfer. This function will send REFER request
  1446. * to instruct remote call party to initiate new INVITE session to the URL
  1447. * of \a destCall. The party at \a dest_call then should "replace"
  1448. * the call with us with the new call from the REFER recipient.
  1449. *
  1450. * @param dest_call The call to be replaced.
  1451. * @param prm.options Application may specify
  1452. * PJSUA_XFER_NO_REQUIRE_REPLACES to suppress the
  1453. * inclusion of "Require: replaces" in
  1454. * the outgoing INVITE request created by the REFER
  1455. * request.
  1456. * @param prm.txOption Optional message components to be sent with
  1457. * the request.
  1458. */
  1459. void xferReplaces(const Call& dest_call,
  1460. const CallOpParam &prm) PJSUA2_THROW(Error);
  1461. /**
  1462. * Accept or reject redirection response. Application MUST call this
  1463. * function after it signaled PJSIP_REDIRECT_PENDING in the
  1464. * \a onCallRedirected() callback,
  1465. * to notify the call whether to accept or reject the redirection
  1466. * to the current target. Application can use the combination of
  1467. * PJSIP_REDIRECT_PENDING command in \a onCallRedirected() callback and
  1468. * this function to ask for user permission before redirecting the call.
  1469. *
  1470. * Note that if the application chooses to reject or stop redirection (by
  1471. * using PJSIP_REDIRECT_REJECT or PJSIP_REDIRECT_STOP respectively), the
  1472. * call disconnection callback will be called before this function returns.
  1473. * And if the application rejects the target, the \a onCallRedirected()
  1474. * callback may also be called before this function returns if there is
  1475. * another target to try.
  1476. *
  1477. * @param cmd Redirection operation to be applied to the current
  1478. * target. The semantic of this argument is similar
  1479. * to the description in the \a onCallRedirected()
  1480. * callback, except that the PJSIP_REDIRECT_PENDING is
  1481. * not accepted here.
  1482. */
  1483. void processRedirect(pjsip_redirect_op cmd) PJSUA2_THROW(Error);
  1484. /**
  1485. * Send DTMF digits to remote using RFC 2833 payload formats.
  1486. *
  1487. * @param digits DTMF string digits to be sent.
  1488. */
  1489. void dialDtmf(const string &digits) PJSUA2_THROW(Error);
  1490. /**
  1491. * Send DTMF digits to remote.
  1492. *
  1493. * @param param The send DTMF parameter.
  1494. */
  1495. void sendDtmf(const CallSendDtmfParam &param) PJSUA2_THROW(Error);
  1496. /**
  1497. * Send instant messaging inside INVITE session.
  1498. *
  1499. * @param prm.contentType
  1500. * MIME type.
  1501. * @param prm.content The message content.
  1502. * @param prm.txOption Optional list of headers etc to be included in
  1503. * outgoing request. The body descriptor in the
  1504. * txOption is ignored.
  1505. * @param prm.userData Optional user data, which will be given back when
  1506. * the IM callback is called.
  1507. */
  1508. void sendInstantMessage(const SendInstantMessageParam& prm)
  1509. PJSUA2_THROW(Error);
  1510. /**
  1511. * Send IM typing indication inside INVITE session.
  1512. *
  1513. * @param prm.isTyping True to indicate to remote that local person is
  1514. * currently typing an IM.
  1515. * @param prm.txOption Optional list of headers etc to be included in
  1516. * outgoing request.
  1517. */
  1518. void sendTypingIndication(const SendTypingIndicationParam &prm)
  1519. PJSUA2_THROW(Error);
  1520. /**
  1521. * Send arbitrary request with the call. This is useful for example to send
  1522. * INFO request. Note that application should not use this function to send
  1523. * requests which would change the invite session's state, such as
  1524. * re-INVITE, UPDATE, PRACK, and BYE.
  1525. *
  1526. * @param prm.method SIP method of the request.
  1527. * @param prm.txOption Optional message body and/or list of headers to be
  1528. * included in outgoing request.
  1529. */
  1530. void sendRequest(const CallSendRequestParam &prm) PJSUA2_THROW(Error);
  1531. /**
  1532. * Dump call and media statistics to string.
  1533. *
  1534. * @param with_media True to include media information too.
  1535. * @param indent Spaces for left indentation.
  1536. *
  1537. * @return Call dump and media statistics string.
  1538. */
  1539. string dump(bool with_media, const string indent) PJSUA2_THROW(Error);
  1540. /**
  1541. * Get the media stream index of the default video stream in the call.
  1542. * Typically this will just retrieve the stream index of the first
  1543. * activated video stream in the call. If none is active, it will return
  1544. * the first inactive video stream.
  1545. *
  1546. * @return The media stream index or -1 if no video stream
  1547. * is present in the call.
  1548. */
  1549. int vidGetStreamIdx() const;
  1550. /**
  1551. * Determine if video stream for the specified call is currently running
  1552. * (i.e. has been created, started, and not being paused) for the specified
  1553. * direction.
  1554. *
  1555. * @param med_idx Media stream index, or -1 to specify default video
  1556. * media.
  1557. * @param dir The direction to be checked.
  1558. *
  1559. * @return True if stream is currently running for the
  1560. * specified direction.
  1561. */
  1562. bool vidStreamIsRunning(int med_idx, pjmedia_dir dir) const;
  1563. /**
  1564. * Add, remove, modify, and/or manipulate video media stream for the
  1565. * specified call. This may trigger a re-INVITE or UPDATE to be sent
  1566. * for the call.
  1567. *
  1568. * @param op The video stream operation to be performed,
  1569. * possible values are pjsua_call_vid_strm_op.
  1570. * @param param The parameters for the video stream operation
  1571. * (see CallVidSetStreamParam).
  1572. */
  1573. void vidSetStream(pjsua_call_vid_strm_op op,
  1574. const CallVidSetStreamParam &param) PJSUA2_THROW(Error);
  1575. /**
  1576. * Modify the video stream's codec parameter after the codec is opened.
  1577. * Note that not all codec backends support modifying parameters during
  1578. * runtime and only certain parameters can be changed.
  1579. *
  1580. * Currently, only Video Toolbox and OpenH264 backends support runtime
  1581. * adjustment of encoding bitrate (avg_bps and max_bps).
  1582. *
  1583. * @param med_idx Video stream index.
  1584. * @param param The new codec parameter.
  1585. *
  1586. * @return PJ_SUCCESS on success.
  1587. */
  1588. void vidStreamModifyCodecParam(int med_idx, const VidCodecParam &param)
  1589. PJSUA2_THROW(Error);
  1590. /**
  1591. * Modify the audio stream's codec parameter after the codec is opened.
  1592. * Note that not all codec parameters can be modified during run-time.
  1593. * Currently, only Opus codec supports changing key codec parameters
  1594. * such as bitrate and bandwidth, while other codecs may only be able to
  1595. * modify minor settings such as VAD or PLC.
  1596. *
  1597. * @param med_idx Media stream index, or -1 to specify default audio
  1598. * media.
  1599. * @param param The new codec parameter.
  1600. *
  1601. * @return PJ_SUCCESS on success.
  1602. */
  1603. void audStreamModifyCodecParam(int med_idx, const CodecParam &param)
  1604. PJSUA2_THROW(Error);
  1605. /**
  1606. * Get media stream info for the specified media index.
  1607. *
  1608. * @param med_idx Media stream index.
  1609. *
  1610. * @return The stream info.
  1611. */
  1612. StreamInfo getStreamInfo(unsigned med_idx) const PJSUA2_THROW(Error);
  1613. /**
  1614. * Get media stream statistic for the specified media index.
  1615. *
  1616. * @param med_idx Media stream index.
  1617. *
  1618. * @return The stream statistic.
  1619. */
  1620. StreamStat getStreamStat(unsigned med_idx) const PJSUA2_THROW(Error);
  1621. /**
  1622. * Get media transport info for the specified media index.
  1623. *
  1624. * @param med_idx Media stream index.
  1625. *
  1626. * @return The transport info.
  1627. */
  1628. MediaTransportInfo getMedTransportInfo(unsigned med_idx) const
  1629. PJSUA2_THROW(Error);
  1630. /**
  1631. * Internal function (callled by Endpoint( to process update to call
  1632. * medias when call media state changes.
  1633. */
  1634. void processMediaUpdate(OnCallMediaStateParam &prm);
  1635. /**
  1636. * Internal function (called by Endpoint) to process call state change.
  1637. */
  1638. void processStateChange(OnCallStateParam &prm);
  1639. public:
  1640. /*
  1641. * Callbacks
  1642. */
  1643. /**
  1644. * Notify application when call state has changed.
  1645. * Application may then query the call info to get the
  1646. * detail call states by calling getInfo() function.
  1647. *
  1648. * @param prm Callback parameter.
  1649. */
  1650. virtual void onCallState(OnCallStateParam &prm)
  1651. { PJ_UNUSED_ARG(prm); }
  1652. /**
  1653. * This is a general notification callback which is called whenever
  1654. * a transaction within the call has changed state. Application can
  1655. * implement this callback for example to monitor the state of
  1656. * outgoing requests, or to answer unhandled incoming requests
  1657. * (such as INFO) with a final response.
  1658. *
  1659. * @param prm Callback parameter.
  1660. */
  1661. virtual void onCallTsxState(OnCallTsxStateParam &prm)
  1662. { PJ_UNUSED_ARG(prm); }
  1663. /**
  1664. * Notify application when media state in the call has changed.
  1665. * Normal application would need to implement this callback, e.g.
  1666. * to connect the call's media to sound device. When ICE is used,
  1667. * this callback will also be called to report ICE negotiation
  1668. * failure.
  1669. *
  1670. * @param prm Callback parameter.
  1671. */
  1672. virtual void onCallMediaState(OnCallMediaStateParam &prm)
  1673. { PJ_UNUSED_ARG(prm); }
  1674. /**
  1675. * Notify application when a call has just created a local SDP (for
  1676. * initial or subsequent SDP offer/answer). Application can implement
  1677. * this callback to modify the SDP, before it is being sent and/or
  1678. * negotiated with remote SDP, for example to apply per account/call
  1679. * basis codecs priority or to add custom/proprietary SDP attributes.
  1680. *
  1681. * @param prm Callback parameter.
  1682. */
  1683. virtual void onCallSdpCreated(OnCallSdpCreatedParam &prm)
  1684. { PJ_UNUSED_ARG(prm); }
  1685. /**
  1686. * Notify application when an audio media session is about to be created
  1687. * (as opposed to onStreamCreated(), which is called *after* the session
  1688. * has been created). The application may change
  1689. * some stream info parameter values, i.e: jbInit, jbMinPre, jbMaxPre,
  1690. * jbMax, useKa, rtcpSdesByeDisabled, jbDiscardAlgo (audio),
  1691. * vidCodecParam.encFmt (video).
  1692. *
  1693. * @param prm Callback parameter.
  1694. */
  1695. virtual void onStreamPreCreate(OnStreamPreCreateParam &prm)
  1696. { PJ_UNUSED_ARG(prm); }
  1697. /**
  1698. * Notify application when audio media session is created and before it is
  1699. * registered to the conference bridge. Application may return different
  1700. * audio media port if it has added media processing port to the stream.
  1701. * This media port then will be added to the conference bridge instead.
  1702. *
  1703. * @param prm Callback parameter.
  1704. */
  1705. virtual void onStreamCreated(OnStreamCreatedParam &prm)
  1706. { PJ_UNUSED_ARG(prm); }
  1707. /**
  1708. * Notify application when audio media session has been unregistered from
  1709. * the conference bridge and about to be destroyed.
  1710. *
  1711. * @param prm Callback parameter.
  1712. */
  1713. virtual void onStreamDestroyed(OnStreamDestroyedParam &prm)
  1714. { PJ_UNUSED_ARG(prm); }
  1715. /**
  1716. * Notify application upon incoming DTMF digits.
  1717. *
  1718. * @param prm Callback parameter.
  1719. */
  1720. virtual void onDtmfDigit(OnDtmfDigitParam &prm)
  1721. { PJ_UNUSED_ARG(prm); }
  1722. /**
  1723. * Notify application upon incoming DTMF events.
  1724. *
  1725. * @param prm Callback parameter.
  1726. */
  1727. virtual void onDtmfEvent(OnDtmfEventParam &prm)
  1728. { PJ_UNUSED_ARG(prm); }
  1729. /**
  1730. * Notify application on call being transferred (i.e. REFER is received).
  1731. * Application can decide to accept/reject transfer request by setting
  1732. * the code (default is 202). When this callback is not implemented,
  1733. * the default behavior is to accept the transfer.
  1734. *
  1735. * If application decides to accept the transfer request, it must also
  1736. * instantiate the new Call object for the transfer operation and return
  1737. * this new Call object to prm.newCall. For the new Call instance,
  1738. * the account should use the same account as this call and the call ID
  1739. * must be set to PJSUA_INVALID_ID.
  1740. *
  1741. * If application does not specify new Call object, library will reuse the
  1742. * existing Call object for initiating the new call (to the transfer
  1743. * destination). In this case, any events from both calls (transferred and
  1744. * transferring) will be delivered to the same Call object, where the call
  1745. * ID will be switched back and forth between callbacks. Application must
  1746. * be careful to not destroy the Call object when receiving disconnection
  1747. * event of the transferred call after the transfer process is completed.
  1748. *
  1749. * @param prm Callback parameter.
  1750. */
  1751. virtual void onCallTransferRequest(OnCallTransferRequestParam &prm)
  1752. { PJ_UNUSED_ARG(prm); }
  1753. /**
  1754. * Notify application of the status of previously sent call
  1755. * transfer request. Application can monitor the status of the
  1756. * call transfer request, for example to decide whether to
  1757. * terminate existing call.
  1758. *
  1759. * @param prm Callback parameter.
  1760. */
  1761. virtual void onCallTransferStatus(OnCallTransferStatusParam &prm)
  1762. { PJ_UNUSED_ARG(prm); }
  1763. /**
  1764. * Notify application about incoming INVITE with Replaces header.
  1765. * Application may reject the request by setting non-2xx code.
  1766. *
  1767. * In this callback, application should create a new Call instance and
  1768. * return the Call object via prm.newCall. In creating the new Call
  1769. * instance, the account should use the same account as this call and
  1770. * the call ID must be set to PJSUA_INVALID_ID.
  1771. *
  1772. * If application does not specify new Call object, library will reuse the
  1773. * existing Call object for callbacks. In this case, any events from
  1774. * both calls (replaced and new) will be delivered to the same Call object,
  1775. * where the call ID will be switched back and forth between callbacks.
  1776. * Application must be careful to not destroy the Call object when
  1777. * receiving disconnection event of the replaced call after the transfer
  1778. * process is completed.
  1779. *
  1780. * @param prm Callback parameter.
  1781. */
  1782. virtual void onCallReplaceRequest(OnCallReplaceRequestParam &prm)
  1783. { PJ_UNUSED_ARG(prm); }
  1784. /**
  1785. * Notify application that an existing call has been replaced with
  1786. * a new call. This happens when PJSUA-API receives incoming INVITE
  1787. * request with Replaces header.
  1788. *
  1789. * After this callback is called, normally PJSUA-API will disconnect
  1790. * this call and establish a new call.
  1791. *
  1792. * If not yet done in onCallReplaceRequest(), application can create
  1793. * the new Call instance and return the Call object via prm.newCall.
  1794. * In creating the new Call instance, the account should use the same
  1795. * account as this call and the call ID must be set to prm.newCallId.
  1796. *
  1797. * If the new Call instance has been setup in onCallReplaceRequest(),
  1798. * the prm.newCall should contain the new Call instance and application
  1799. * MUST not change it.
  1800. *
  1801. * If application does not specify new Call object, library will reuse the
  1802. * existing Call object for callbacks. In this case, any events from
  1803. * both calls (replaced and new) will be delivered to the same Call object,
  1804. * where the call ID will be switched back and forth between callbacks.
  1805. * Application must be careful to not destroy the Call object when
  1806. * receiving disconnection event of the replaced call after the transfer
  1807. * process is completed.
  1808. *
  1809. * @param prm Callback parameter.
  1810. */
  1811. virtual void onCallReplaced(OnCallReplacedParam &prm)
  1812. { PJ_UNUSED_ARG(prm); }
  1813. /**
  1814. * Notify application when call has received new offer from remote
  1815. * (i.e. re-INVITE/UPDATE with SDP is received). Application can
  1816. * decide to accept/reject the offer by setting the code (default
  1817. * is PJSIP_SC_OK (200)). If the offer is accepted, application can update
  1818. * the call setting to be applied in the answer. When this callback is
  1819. * not implemented, the default behavior is to accept the offer using
  1820. * current call setting.
  1821. *
  1822. * @param prm Callback parameter.
  1823. */
  1824. virtual void onCallRxOffer(OnCallRxOfferParam &prm)
  1825. { PJ_UNUSED_ARG(prm); }
  1826. /**
  1827. * Notify application when call has received a re-INVITE offer from
  1828. * the peer. It allows more fine-grained control over the response to
  1829. * a re-INVITE. If application sets prm.isAsync to true, it can send
  1830. * the reply manually using the function #pj::Call::answer() and setting
  1831. * the SDP answer. Otherwise, by default the re-INVITE will be
  1832. * answered automatically after the callback returns.
  1833. *
  1834. * Currently, this callback is only called for re-INVITE with
  1835. * SDP, but app should be prepared to handle the case of re-INVITE
  1836. * without SDP.
  1837. *
  1838. * Remarks: If manually answering at a later timing, application may
  1839. * need to monitor onCallTsxState() callback to check whether
  1840. * the re-INVITE is already answered automatically with
  1841. * PJSIP_SC_REQUEST_TERMINATED (487) due to being cancelled.
  1842. *
  1843. * Note: onCallRxOffer() will still be called after this callback,
  1844. * but only if prm.isAsync is false and prm.statusCode is PJSIP_SC_OK
  1845. * (200).
  1846. *
  1847. * @param prm Callback parameter.
  1848. */
  1849. virtual void onCallRxReinvite(OnCallRxReinviteParam &prm)
  1850. { PJ_UNUSED_ARG(prm); }
  1851. /**
  1852. * Notify application when call has received INVITE with no SDP offer.
  1853. * Application can update the call setting (e.g: add audio/video), or
  1854. * enable/disable codecs, or update other media session settings from
  1855. * within the callback, however, as mandated by the standard (RFC3261
  1856. * section 14.2), it must ensure that the update overlaps with the
  1857. * existing media session (in codecs, transports, or other parameters)
  1858. * that require support from the peer, this is to avoid the need for
  1859. * the peer to reject the offer.
  1860. *
  1861. * When this callback is not implemented, the default behavior is to send
  1862. * SDP offer using current active media session (with all enabled codecs
  1863. * on each media type).
  1864. *
  1865. * @param prm Callback parameter.
  1866. */
  1867. virtual void onCallTxOffer(OnCallTxOfferParam &prm)
  1868. { PJ_UNUSED_ARG(prm); }
  1869. /**
  1870. * Notify application on incoming MESSAGE request.
  1871. *
  1872. * @param prm Callback parameter.
  1873. */
  1874. virtual void onInstantMessage(OnInstantMessageParam &prm)
  1875. { PJ_UNUSED_ARG(prm); }
  1876. /**
  1877. * Notify application about the delivery status of outgoing MESSAGE
  1878. * request.
  1879. *
  1880. * @param prm Callback parameter.
  1881. */
  1882. virtual void onInstantMessageStatus(OnInstantMessageStatusParam &prm)
  1883. { PJ_UNUSED_ARG(prm); }
  1884. /**
  1885. * Notify application about typing indication.
  1886. *
  1887. * @param prm Callback parameter.
  1888. */
  1889. virtual void onTypingIndication(OnTypingIndicationParam &prm)
  1890. { PJ_UNUSED_ARG(prm); }
  1891. /**
  1892. * This callback is called when the call is about to resend the
  1893. * INVITE request to the specified target, following the previously
  1894. * received redirection response.
  1895. *
  1896. * Application may accept the redirection to the specified target,
  1897. * reject this target only and make the session continue to try the next
  1898. * target in the list if such target exists, stop the whole
  1899. * redirection process altogether and cause the session to be
  1900. * disconnected, or defer the decision to ask for user confirmation.
  1901. *
  1902. * This callback is optional,
  1903. * the default behavior is to NOT follow the redirection response.
  1904. *
  1905. * @param prm Callback parameter.
  1906. *
  1907. * @return Action to be performed for the target. Set this
  1908. * parameter to one of the value below:
  1909. * - PJSIP_REDIRECT_ACCEPT: immediately accept the
  1910. * redirection. When set, the call will immediately
  1911. * resend INVITE request to the target.
  1912. * - PJSIP_REDIRECT_ACCEPT_REPLACE: immediately accept
  1913. * the redirection and replace the To header with the
  1914. * current target. When set, the call will immediately
  1915. * resend INVITE request to the target.
  1916. * - PJSIP_REDIRECT_REJECT: immediately reject this
  1917. * target. The call will continue retrying with
  1918. * next target if present, or disconnect the call
  1919. * if there is no more target to try.
  1920. * - PJSIP_REDIRECT_STOP: stop the whole redirection
  1921. * process and immediately disconnect the call. The
  1922. * onCallState() callback will be called with
  1923. * PJSIP_INV_STATE_DISCONNECTED state immediately
  1924. * after this callback returns.
  1925. * - PJSIP_REDIRECT_PENDING: set to this value if
  1926. * no decision can be made immediately (for example
  1927. * to request confirmation from user). Application
  1928. * then MUST call processRedirect()
  1929. * to either accept or reject the redirection upon
  1930. * getting user decision.
  1931. */
  1932. virtual pjsip_redirect_op onCallRedirected(OnCallRedirectedParam &prm)
  1933. {
  1934. PJ_UNUSED_ARG(prm);
  1935. return PJSIP_REDIRECT_STOP;
  1936. }
  1937. /**
  1938. * This callback is called when media transport state is changed.
  1939. *
  1940. * @param prm Callback parameter.
  1941. */
  1942. virtual void onCallMediaTransportState(OnCallMediaTransportStateParam &prm)
  1943. { PJ_UNUSED_ARG(prm); }
  1944. /**
  1945. * Notification about media events such as video notifications. This
  1946. * callback will most likely be called from media threads, thus
  1947. * application must not perform heavy processing in this callback.
  1948. * Especially, application must not destroy the call or media in this
  1949. * callback. If application needs to perform more complex tasks to
  1950. * handle the event, it should post the task to another thread.
  1951. *
  1952. * @param prm Callback parameter.
  1953. */
  1954. virtual void onCallMediaEvent(OnCallMediaEventParam &prm)
  1955. { PJ_UNUSED_ARG(prm); }
  1956. /**
  1957. * This callback can be used by application to implement custom media
  1958. * transport adapter for the call, or to replace the media transport
  1959. * with something completely new altogether.
  1960. *
  1961. * This callback is called when a new call is created. The library has
  1962. * created a media transport for the call, and it is provided as the
  1963. * \a mediaTp argument of this callback. The callback may change it
  1964. * with the instance of media transport to be used by the call.
  1965. *
  1966. * @param prm Callback parameter.
  1967. */
  1968. virtual void
  1969. onCreateMediaTransport(OnCreateMediaTransportParam &prm)
  1970. { PJ_UNUSED_ARG(prm); }
  1971. /**
  1972. * Warning: deprecated and may be removed in future release.
  1973. * Application can set SRTP crypto settings (including keys) and
  1974. * keying methods via AccountConfig.mediaConfig.srtpOpt.
  1975. * See also ticket #2100.
  1976. *
  1977. * This callback is called when SRTP media transport is created.
  1978. * Application can modify the SRTP setting \a srtpOpt to specify
  1979. * the cryptos and keys which are going to be used. Note that
  1980. * application should not modify the field
  1981. * \a pjmedia_srtp_setting.close_member_tp and can only modify
  1982. * the field \a pjmedia_srtp_setting.use for initial INVITE.
  1983. *
  1984. * @param prm Callback parameter.
  1985. */
  1986. virtual void
  1987. onCreateMediaTransportSrtp(OnCreateMediaTransportSrtpParam &prm)
  1988. { PJ_UNUSED_ARG(prm); }
  1989. private:
  1990. friend class Endpoint;
  1991. Account &acc;
  1992. pjsua_call_id id;
  1993. Token userData;
  1994. std::vector<Media *> medias;
  1995. pj_pool_t *sdp_pool;
  1996. Call *child; /* New outgoing call in call transfer. */
  1997. };
  1998. /**
  1999. * @} // PJSUA2_CALL
  2000. */
  2001. } // namespace pj
  2002. #endif /* __PJSUA2_CALL_HPP__ */