call.hpp 68 KB

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