endpoint.hpp 67 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190
  1. /*
  2. * Copyright (C) 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_UA_HPP__
  19. #define __PJSUA2_UA_HPP__
  20. /**
  21. * @file pjsua2/endpoint.hpp
  22. * @brief PJSUA2 Base Agent Operation
  23. */
  24. #include <pjsua2/persistent.hpp>
  25. #include <pjsua2/media.hpp>
  26. #include <pjsua2/siptypes.hpp>
  27. #include <list>
  28. #include <map>
  29. /** PJSUA2 API is inside pj namespace */
  30. namespace pj
  31. {
  32. /**
  33. * @defgroup PJSUA2_UA Endpoint
  34. * @ingroup PJSUA2_Ref
  35. * @{
  36. */
  37. using std::string;
  38. using std::vector;
  39. //////////////////////////////////////////////////////////////////////////////
  40. /**
  41. * Argument to Endpoint::onNatDetectionComplete() callback.
  42. */
  43. struct OnNatDetectionCompleteParam
  44. {
  45. /**
  46. * Status of the detection process. If this value is not PJ_SUCCESS,
  47. * the detection has failed and \a nat_type field will contain
  48. * PJ_STUN_NAT_TYPE_UNKNOWN.
  49. */
  50. pj_status_t status;
  51. /**
  52. * The text describing the status, if the status is not PJ_SUCCESS.
  53. */
  54. string reason;
  55. /**
  56. * This contains the NAT type as detected by the detection procedure.
  57. * This value is only valid when the \a status is PJ_SUCCESS.
  58. */
  59. pj_stun_nat_type natType;
  60. /**
  61. * Text describing that NAT type.
  62. */
  63. string natTypeName;
  64. };
  65. /**
  66. * Argument to Endpoint::onNatCheckStunServersComplete() callback.
  67. */
  68. struct OnNatCheckStunServersCompleteParam
  69. {
  70. /**
  71. * Arbitrary user data that was passed to Endpoint::natCheckStunServers()
  72. * function.
  73. */
  74. Token userData;
  75. /**
  76. * This will contain PJ_SUCCESS if at least one usable STUN server
  77. * is found, otherwise it will contain the last error code during
  78. * the operation.
  79. */
  80. pj_status_t status;
  81. /**
  82. * The server name that yields successful result. This will only
  83. * contain value if status is successful.
  84. */
  85. string name;
  86. /**
  87. * The server IP address and port in "IP:port" format. This will only
  88. * contain value if status is successful.
  89. */
  90. SocketAddress addr;
  91. };
  92. /**
  93. * Parameter of Endpoint::onTimer() callback.
  94. */
  95. struct OnTimerParam
  96. {
  97. /**
  98. * Arbitrary user data that was passed to Endpoint::utilTimerSchedule()
  99. * function.
  100. */
  101. Token userData;
  102. /**
  103. * The interval of this timer, in miliseconds.
  104. */
  105. unsigned msecDelay;
  106. };
  107. /**
  108. * SSL certificate type and name structure.
  109. */
  110. struct SslCertName
  111. {
  112. pj_ssl_cert_name_type type; /**< Name type */
  113. string name; /**< The name */
  114. public:
  115. /**
  116. * Default constructor
  117. */
  118. SslCertName() : type(PJ_SSL_CERT_NAME_UNKNOWN)
  119. {}
  120. };
  121. /** Array of SSL certificate type and name. */
  122. typedef std::vector<SslCertName> SslCertNameVector;
  123. /**
  124. * SSL certificate information.
  125. */
  126. struct SslCertInfo
  127. {
  128. unsigned version; /**< Certificate version */
  129. unsigned char serialNo[20]; /**< Serial number, array
  130. of octets, first index
  131. is MSB */
  132. string subjectCn; /**< Subject common name */
  133. string subjectInfo; /**< One line subject, fields
  134. are separated by slash, e.g:
  135. "CN=sample.org/OU=HRD" */
  136. string issuerCn; /**< Issuer common name */
  137. string issuerInfo; /**< One line subject, fields
  138. are separated by slash */
  139. TimeVal validityStart; /**< Validity start */
  140. TimeVal validityEnd; /**< Validity end */
  141. bool validityGmt; /**< Flag if validity
  142. date/time use GMT */
  143. SslCertNameVector subjectAltName; /**< Subject alternative
  144. name extension */
  145. string raw; /**< Raw certificate in PEM
  146. format, only available
  147. for remote certificate */
  148. public:
  149. /**
  150. * Constructor.
  151. */
  152. SslCertInfo();
  153. /**
  154. * Check if the info is set with empty values.
  155. *
  156. * @return True if the info is empty.
  157. */
  158. bool isEmpty() const;
  159. /**
  160. * Convert from pjsip
  161. */
  162. void fromPj(const pj_ssl_cert_info &info);
  163. private:
  164. bool empty;
  165. };
  166. /**
  167. * TLS transport information.
  168. */
  169. struct TlsInfo
  170. {
  171. /**
  172. * Describes whether secure socket connection is established, i.e: TLS/SSL
  173. * handshaking has been done successfully.
  174. */
  175. bool established;
  176. /**
  177. * Describes secure socket protocol being used, see #pj_ssl_sock_proto.
  178. * Use bitwise OR operation to combine the protocol type.
  179. */
  180. unsigned protocol;
  181. /**
  182. * Describes cipher suite being used, this will only be set when connection
  183. * is established.
  184. */
  185. pj_ssl_cipher cipher;
  186. /**
  187. * Describes cipher name being used, this will only be set when connection
  188. * is established.
  189. */
  190. string cipherName;
  191. /**
  192. * Describes local address.
  193. */
  194. SocketAddress localAddr;
  195. /**
  196. * Describes remote address.
  197. */
  198. SocketAddress remoteAddr;
  199. /**
  200. * Describes active local certificate info. Use SslCertInfo.isEmpty()
  201. * to check if the local cert info is available.
  202. */
  203. SslCertInfo localCertInfo;
  204. /**
  205. * Describes active remote certificate info. Use SslCertInfo.isEmpty()
  206. * to check if the remote cert info is available.
  207. */
  208. SslCertInfo remoteCertInfo;
  209. /**
  210. * Status of peer certificate verification.
  211. */
  212. unsigned verifyStatus;
  213. /**
  214. * Error messages (if any) of peer certificate verification, based on
  215. * the field verifyStatus above.
  216. */
  217. StringVector verifyMsgs;
  218. public:
  219. /**
  220. * Constructor.
  221. */
  222. TlsInfo();
  223. /**
  224. * Check if the info is set with empty values.
  225. *
  226. * @return True if the info is empty.
  227. */
  228. bool isEmpty() const;
  229. /**
  230. * Convert from pjsip
  231. */
  232. void fromPj(const pjsip_tls_state_info &info);
  233. private:
  234. bool empty;
  235. };
  236. /**
  237. * Parameter of Endpoint::onTransportState() callback.
  238. */
  239. struct OnTransportStateParam
  240. {
  241. /**
  242. * The transport handle.
  243. */
  244. TransportHandle hnd;
  245. /**
  246. * The transport type.
  247. */
  248. string type;
  249. /**
  250. * Transport current state.
  251. */
  252. pjsip_transport_state state;
  253. /**
  254. * The last error code related to the transport state.
  255. */
  256. pj_status_t lastError;
  257. /**
  258. * TLS transport info, only used if transport type is TLS. Use
  259. * TlsInfo.isEmpty() to check if this info is available.
  260. */
  261. TlsInfo tlsInfo;
  262. };
  263. /**
  264. * Parameter of Endpoint::onSelectAccount() callback.
  265. */
  266. struct OnSelectAccountParam
  267. {
  268. /**
  269. * The incoming request.
  270. */
  271. SipRxData rdata;
  272. /**
  273. * The account index to be used to handle the request.
  274. * Upon entry, this will be filled by the account index
  275. * chosen by the library. Application may change it to
  276. * another value to use another account.
  277. */
  278. int accountIndex;
  279. };
  280. /**
  281. * Parameter of Endpoint::handleIpChange().
  282. */
  283. struct IpChangeParam {
  284. /**
  285. * If set to PJ_TRUE, this will restart the transport listener.
  286. *
  287. * Default : PJ_TRUE
  288. */
  289. bool restartListener;
  290. /**
  291. * If \a restartListener is set to PJ_TRUE, some delay might be needed
  292. * for the listener to be restarted. Use this to set the delay.
  293. *
  294. * Default : PJSUA_TRANSPORT_RESTART_DELAY_TIME
  295. */
  296. unsigned restartLisDelay;
  297. /**
  298. * If set to PJ_TRUE, this will forcefully shutdown all transports.
  299. * Note that this will shutdown TCP/TLS transports only, UDP transport
  300. * should be restarted via restart_listener.
  301. *
  302. * Default : PJ_TRUE
  303. */
  304. bool shutdownTransport;
  305. public:
  306. /**
  307. * Constructor.
  308. */
  309. IpChangeParam();
  310. /**
  311. * Export to pjsua_ip_change_param.
  312. */
  313. pjsua_ip_change_param toPj() const;
  314. /**
  315. * Convert from pjsip
  316. */
  317. void fromPj(const pjsua_ip_change_param &param);
  318. };
  319. /**
  320. * Information of Update contact on IP change progress.
  321. */
  322. struct RegProgressParam
  323. {
  324. /**
  325. * Indicate if this is a Register or Un-Register message.
  326. */
  327. bool isRegister;
  328. /**
  329. * SIP status code received.
  330. */
  331. int code;
  332. };
  333. /**
  334. * Parameter of Endpoint::onIpChangeProgress().
  335. */
  336. struct OnIpChangeProgressParam
  337. {
  338. /**
  339. * The IP change progress operation.
  340. */
  341. pjsua_ip_change_op op;
  342. /**
  343. * The operation progress status.
  344. */
  345. pj_status_t status;
  346. /**
  347. * Information of the transport id. This is only available when the
  348. * operation is PJSUA_IP_CHANGE_OP_RESTART_LIS.
  349. */
  350. TransportId transportId;
  351. /**
  352. * Information of the account id. This is only available when the
  353. * operation is:
  354. * - PJSUA_IP_CHANGE_OP_ACC_SHUTDOWN_TP
  355. * - PJSUA_IP_CHANGE_OP_ACC_UPDATE_CONTACT
  356. * - PJSUA_IP_CHANGE_OP_ACC_HANGUP_CALLS
  357. * - PJSUA_IP_CHANGE_OP_ACC_REINVITE_CALLS
  358. */
  359. int accId;
  360. /**
  361. * Information of the call id. This is only available when the operation is
  362. * PJSUA_IP_CHANGE_OP_ACC_HANGUP_CALLS or
  363. * PJSUA_IP_CHANGE_OP_ACC_REINVITE_CALLS
  364. */
  365. int callId;
  366. /**
  367. * Registration information. This is only available when the operation is
  368. * PJSUA_IP_CHANGE_OP_ACC_UPDATE_CONTACT
  369. */
  370. RegProgressParam regInfo;
  371. };
  372. /**
  373. * Parameter of Endpoint::onCallMediaEvent() callback.
  374. */
  375. struct OnMediaEventParam
  376. {
  377. /**
  378. * The media event.
  379. */
  380. MediaEvent ev;
  381. };
  382. /**
  383. * Parameter of Endpoint::onRejectedIncomingCall() callback.
  384. */
  385. struct OnRejectedIncomingCallParam
  386. {
  387. /**
  388. * The incoming call id. This will be set to PJSUA_INVALID_ID when there is
  389. * no available call slot at the time.
  390. */
  391. pjsua_call_id callId;
  392. /**
  393. * Local URI.
  394. */
  395. std::string localInfo;
  396. /**
  397. * Remote URI.
  398. */
  399. std::string remoteInfo;
  400. /**
  401. * Rejection code.
  402. */
  403. int statusCode;
  404. /**
  405. * Rejection text.
  406. */
  407. std::string reason;
  408. /**
  409. * The original INVITE message, on some cases it is not available.
  410. */
  411. SipRxData rdata;
  412. };
  413. /**
  414. * This structure describes authentication challenge used in Proxy-Authenticate
  415. * or WWW-Authenticate for digest authentication scheme.
  416. */
  417. struct DigestChallenge
  418. {
  419. /**
  420. * Realm for the challenge.
  421. * */
  422. std::string realm;
  423. /**
  424. * Other parameters.
  425. */
  426. StringToStringMap otherParam;
  427. /**
  428. * Domain.
  429. */
  430. std::string domain;
  431. /**
  432. * Nonce challenge.
  433. */
  434. std::string nonce;
  435. /**
  436. * Opaque value.
  437. */
  438. std::string opaque;
  439. /**
  440. * Stale parameter.
  441. */
  442. int stale;
  443. /**
  444. * Algorithm parameter.
  445. */
  446. std::string algorithm;
  447. /**
  448. * Quality of protection.
  449. */
  450. std::string qop;
  451. /**
  452. * Convert from pjsip
  453. */
  454. void fromPj(const pjsip_digest_challenge &prm);
  455. /**
  456. * Convert to pjsip
  457. */
  458. pjsip_digest_challenge toPj() const;
  459. };
  460. /**
  461. * This structure describe credential used in Authorization and
  462. * Proxy-Authorization header for digest authentication scheme.
  463. */
  464. struct DigestCredential
  465. {
  466. /**
  467. * Realm of the credential
  468. */
  469. std::string realm;
  470. /**
  471. * Other parameters.
  472. */
  473. StringToStringMap otherParam;
  474. /**
  475. * Username parameter.
  476. */
  477. std::string username;
  478. /**
  479. * Nonce parameter.
  480. */
  481. std::string nonce;
  482. /**
  483. * URI parameter.
  484. */
  485. std::string uri;
  486. /**
  487. * Response digest.
  488. */
  489. std::string response;
  490. /**
  491. * Algorithm.
  492. */
  493. std::string algorithm;
  494. /**
  495. * Cnonce.
  496. */
  497. std::string cnonce;
  498. /**
  499. * Opaque value.
  500. */
  501. std::string opaque;
  502. /**
  503. * Quality of protection.
  504. */
  505. std::string qop;
  506. /**
  507. * Nonce count.
  508. */
  509. std::string nc;
  510. /**
  511. * Convert from pjsip
  512. */
  513. void fromPj(const pjsip_digest_credential &prm);
  514. /**
  515. * Convert to pjsip
  516. */
  517. pjsip_digest_credential toPj() const;
  518. };
  519. /**
  520. * Parameter of Endpoint::onCredAuth() callback.
  521. */
  522. struct OnCredAuthParam
  523. {
  524. /**
  525. * Digest challenge.
  526. * The authentication challenge sent by server in 401 or 401 response,
  527. * as either Proxy-Authenticate or WWW-Authenticate header.
  528. */
  529. DigestChallenge digestChallenge;
  530. /**
  531. * Credential info.
  532. */
  533. AuthCredInfo credentialInfo;
  534. /**
  535. * The request method.
  536. */
  537. std::string method;
  538. /**
  539. * The digest credential where the digest response will be placed to.
  540. *
  541. * Upon calling this function, the nonce, nc, cnonce, qop, uri, and realm
  542. * fields of this structure must be set by the caller.
  543. *
  544. * Upon return, the callback must set the response in
  545. * \a DigestCredential.response.
  546. */
  547. DigestCredential digestCredential;
  548. };
  549. //////////////////////////////////////////////////////////////////////////////
  550. /**
  551. * SIP User Agent related settings.
  552. */
  553. struct UaConfig : public PersistentObject
  554. {
  555. /**
  556. * Maximum calls to support (default: 4). The value specified here
  557. * must be smaller than the compile time maximum settings
  558. * PJSUA_MAX_CALLS, which by default is 32. To increase this
  559. * limit, the library must be recompiled with new PJSUA_MAX_CALLS
  560. * value.
  561. */
  562. unsigned maxCalls;
  563. /**
  564. * Number of worker threads. Normally application will want to have at
  565. * least one worker thread, unless when it wants to poll the library
  566. * periodically, which in this case the worker thread can be set to
  567. * zero.
  568. */
  569. unsigned threadCnt;
  570. /**
  571. * When this flag is non-zero, all callbacks that come from thread
  572. * other than main thread will be posted to the main thread and
  573. * to be executed by Endpoint::libHandleEvents() function. This
  574. * includes the logging callback. Note that this will only work if
  575. * threadCnt is set to zero and Endpoint::libHandleEvents() is
  576. * performed by main thread. By default, the main thread is set
  577. * from the thread that invoke Endpoint::libCreate()
  578. *
  579. * Default: false
  580. */
  581. bool mainThreadOnly;
  582. /**
  583. * Array of nameservers to be used by the SIP resolver subsystem.
  584. * The order of the name server specifies the priority (first name
  585. * server will be used first, unless it is not reachable).
  586. */
  587. StringVector nameserver;
  588. /**
  589. * Specify the URL of outbound proxies to visit for all outgoing requests.
  590. * The outbound proxies will be used for all accounts, and it will
  591. * be used to build the route set for outgoing requests. The final
  592. * route set for outgoing requests will consists of the outbound proxies
  593. * and the proxy configured in the account.
  594. */
  595. StringVector outboundProxies;
  596. /**
  597. * Optional user agent string (default empty). If it's empty, no
  598. * User-Agent header will be sent with outgoing requests.
  599. */
  600. string userAgent;
  601. /**
  602. * Array of STUN servers to try. The library will try to resolve and
  603. * contact each of the STUN server entry until it finds one that is
  604. * usable. Each entry may be a domain name, host name, IP address, and
  605. * it may contain an optional port number. For example:
  606. * - "pjsip.org" (domain name)
  607. * - "sip.pjsip.org" (host name)
  608. * - "pjsip.org:33478" (domain name and a non-standard port number)
  609. * - "10.0.0.1:3478" (IP address and port number)
  610. *
  611. * When nameserver is configured in the \a pjsua_config.nameserver field,
  612. * if entry is not an IP address, it will be resolved with DNS SRV
  613. * resolution first, and it will fallback to use DNS A resolution if this
  614. * fails. Port number may be specified even if the entry is a domain name,
  615. * in case the DNS SRV resolution should fallback to a non-standard port.
  616. *
  617. * When nameserver is not configured, entries will be resolved with
  618. * pj_gethostbyname() if it's not an IP address. Port number may be
  619. * specified if the server is not listening in standard STUN port.
  620. */
  621. StringVector stunServer;
  622. /**
  623. * This specifies if the library should try to do an IPv6 resolution of
  624. * the STUN servers if the IPv4 resolution fails. It can be useful
  625. * in an IPv6-only environment, including on NAT64.
  626. *
  627. * Default: FALSE
  628. */
  629. bool stunTryIpv6;
  630. /**
  631. * This specifies if the library startup should ignore failure with the
  632. * STUN servers. If this is set to PJ_FALSE, the library will refuse to
  633. * start if it fails to resolve or contact any of the STUN servers.
  634. *
  635. * Default: TRUE
  636. */
  637. bool stunIgnoreFailure;
  638. /**
  639. * Support for adding and parsing NAT type in the SDP to assist
  640. * troubleshooting. The valid values are:
  641. * - 0: no information will be added in SDP, and parsing is disabled.
  642. * - 1: only the NAT type number is added.
  643. * - 2: add both NAT type number and name.
  644. *
  645. * Default: 1
  646. */
  647. int natTypeInSdp;
  648. /**
  649. * Handle unsolicited NOTIFY requests containing message waiting
  650. * indication (MWI) info. Unsolicited MWI is incoming NOTIFY requests
  651. * which are not requested by client with SUBSCRIBE request.
  652. *
  653. * If this is enabled, the library will respond 200/OK to the NOTIFY
  654. * request and forward the request to Endpoint::onMwiInfo() callback.
  655. *
  656. * Note: the callback will not be invoked and 481/"No account to handle" response
  657. * will be sent if this is enabled but no account is configured.
  658. *
  659. * See also AccountMwiConfig.enabled.
  660. *
  661. * Default: PJ_TRUE
  662. */
  663. bool mwiUnsolicitedEnabled;
  664. /**
  665. * Specify whether to enable UPnP.
  666. *
  667. * Note that this setting can be further customized in account
  668. * configuration (#pjsua_acc_config).
  669. *
  670. * Default: FALSE
  671. */
  672. bool enableUpnp;
  673. /**
  674. * Specify which interface to use for UPnP. If empty, UPnP will use
  675. * the first suitable interface found.
  676. *
  677. * Note that this setting is only applicable if UPnP is enabled.
  678. *
  679. * Default: empty string
  680. */
  681. string upnpIfName;
  682. public:
  683. /**
  684. * Default constructor to initialize with default values.
  685. */
  686. UaConfig();
  687. /**
  688. * Construct from pjsua_config.
  689. */
  690. void fromPj(const pjsua_config &ua_cfg);
  691. /**
  692. * Export to pjsua_config
  693. */
  694. pjsua_config toPj() const;
  695. /**
  696. * Read this object from a container.
  697. *
  698. * @param node Container to write values from.
  699. */
  700. virtual void readObject(const ContainerNode &node) PJSUA2_THROW(Error);
  701. /**
  702. * Write this object to a container.
  703. *
  704. * @param node Container to write values to.
  705. */
  706. virtual void writeObject(ContainerNode &node) const PJSUA2_THROW(Error);
  707. };
  708. /**
  709. * Data containing log entry to be written by the LogWriter.
  710. */
  711. struct LogEntry
  712. {
  713. /** Log verbosity level of this message */
  714. int level;
  715. /** The log message */
  716. string msg;
  717. /** ID of current thread */
  718. long threadId;
  719. /** The name of the thread that writes this log */
  720. string threadName;
  721. };
  722. /**
  723. * Interface for writing log messages. Applications can inherit this class
  724. * and supply it in the LogConfig structure to implement custom log
  725. * writing facility.
  726. */
  727. class LogWriter
  728. {
  729. public:
  730. /** Destructor */
  731. virtual ~LogWriter() {}
  732. /** Write a log entry. */
  733. virtual void write(const LogEntry &entry) = 0;
  734. };
  735. /**
  736. * Logging configuration, which can be (optionally) specified when calling
  737. * Lib::init().
  738. */
  739. struct LogConfig : public PersistentObject
  740. {
  741. /** Log incoming and outgoing SIP message? Yes! */
  742. unsigned msgLogging;
  743. /** Input verbosity level. Value 5 is reasonable. */
  744. unsigned level;
  745. /** Verbosity level for console. Value 4 is reasonable. */
  746. unsigned consoleLevel;
  747. /** Log decoration. */
  748. unsigned decor;
  749. /** Optional log filename if app wishes the library to write to log file.
  750. */
  751. string filename;
  752. /**
  753. * Additional flags to be given to pj_file_open() when opening
  754. * the log file. By default, the flag is PJ_O_WRONLY. Application
  755. * may set PJ_O_APPEND here so that logs are appended to existing
  756. * file instead of overwriting it.
  757. *
  758. * Default is 0.
  759. */
  760. unsigned fileFlags;
  761. /**
  762. * Custom log writer, if required. This instance will be destroyed
  763. * by the endpoint when the endpoint is destroyed.
  764. */
  765. LogWriter *writer;
  766. public:
  767. /** Default constructor initialises with default values */
  768. LogConfig();
  769. /** Construct from pjsua_logging_config */
  770. void fromPj(const pjsua_logging_config &lc);
  771. /** Generate pjsua_logging_config. */
  772. pjsua_logging_config toPj() const;
  773. /**
  774. * Read this object from a container.
  775. *
  776. * @param node Container to write values from.
  777. */
  778. virtual void readObject(const ContainerNode &node) PJSUA2_THROW(Error);
  779. /**
  780. * Write this object to a container.
  781. *
  782. * @param node Container to write values to.
  783. */
  784. virtual void writeObject(ContainerNode &node) const PJSUA2_THROW(Error);
  785. };
  786. /**
  787. * This structure describes media configuration, which will be specified
  788. * when calling Lib::init().
  789. */
  790. struct MediaConfig : public PersistentObject
  791. {
  792. public:
  793. /**
  794. * Clock rate to be applied to the conference bridge.
  795. * If value is zero, default clock rate will be used
  796. * (PJSUA_DEFAULT_CLOCK_RATE, which by default is 16KHz).
  797. */
  798. unsigned clockRate;
  799. /**
  800. * Clock rate to be applied when opening the sound device.
  801. * If value is zero, conference bridge clock rate will be used.
  802. */
  803. unsigned sndClockRate;
  804. /**
  805. * Channel count be applied when opening the sound device and
  806. * conference bridge.
  807. */
  808. unsigned channelCount;
  809. /**
  810. * Specify audio frame ptime. The value here will affect the
  811. * samples per frame of both the sound device and the conference
  812. * bridge. Specifying lower ptime will normally reduce the
  813. * latency.
  814. *
  815. * Default value: PJSUA_DEFAULT_AUDIO_FRAME_PTIME
  816. */
  817. unsigned audioFramePtime;
  818. /**
  819. * Specify maximum number of media ports to be created in the
  820. * conference bridge. Since all media terminate in the bridge
  821. * (calls, file player, file recorder, etc), the value must be
  822. * large enough to support all of them. However, the larger
  823. * the value, the more computations are performed.
  824. *
  825. * Default value: PJSUA_MAX_CONF_PORTS
  826. */
  827. unsigned maxMediaPorts;
  828. /**
  829. * Specify whether the media manager should manage its own
  830. * ioqueue for the RTP/RTCP sockets. If yes, ioqueue will be created
  831. * and at least one worker thread will be created too. If no,
  832. * the RTP/RTCP sockets will share the same ioqueue as SIP sockets,
  833. * and no worker thread is needed.
  834. *
  835. * Normally application would say yes here, unless it wants to
  836. * run everything from a single thread.
  837. */
  838. bool hasIoqueue;
  839. /**
  840. * Specify the number of worker threads to handle incoming RTP
  841. * packets. A value of one is recommended for most applications.
  842. */
  843. unsigned threadCnt;
  844. /**
  845. * Media quality, 0-10, according to this table:
  846. * 5-10: resampling use large filter,
  847. * 3-4: resampling use small filter,
  848. * 1-2: resampling use linear.
  849. * The media quality also sets speex codec quality/complexity to the
  850. * number.
  851. *
  852. * Default: PJSUA_DEFAULT_CODEC_QUALITY.
  853. */
  854. unsigned quality;
  855. /**
  856. * Specify default codec ptime.
  857. *
  858. * Default: 0 (codec specific)
  859. */
  860. unsigned ptime;
  861. /**
  862. * Disable VAD?
  863. *
  864. * Default: 0 (codec specific)
  865. */
  866. bool noVad;
  867. /**
  868. * iLBC mode (20 or 30).
  869. *
  870. * Default: 30 (PJSUA_DEFAULT_ILBC_MODE)
  871. */
  872. unsigned ilbcMode;
  873. /**
  874. * Percentage of RTP packet to drop in TX direction
  875. * (to simulate packet lost).
  876. *
  877. * Default: 0
  878. */
  879. unsigned txDropPct;
  880. /**
  881. * Percentage of RTP packet to drop in RX direction
  882. * (to simulate packet lost).
  883. *
  884. * Default: 0
  885. */
  886. unsigned rxDropPct;
  887. /**
  888. * Echo canceller options (see pjmedia_echo_create()).
  889. * Specify PJMEDIA_ECHO_USE_SW_ECHO here if application wishes
  890. * to use software echo canceller instead of device EC.
  891. *
  892. * Default: 0.
  893. */
  894. unsigned ecOptions;
  895. /**
  896. * Echo canceller tail length, in miliseconds. Setting this to zero
  897. * will disable echo cancellation.
  898. *
  899. * Default: PJSUA_DEFAULT_EC_TAIL_LEN
  900. */
  901. unsigned ecTailLen;
  902. /**
  903. * Audio capture buffer length, in milliseconds.
  904. *
  905. * Default: PJMEDIA_SND_DEFAULT_REC_LATENCY
  906. */
  907. unsigned sndRecLatency;
  908. /**
  909. * Audio playback buffer length, in milliseconds.
  910. *
  911. * Default: PJMEDIA_SND_DEFAULT_PLAY_LATENCY
  912. */
  913. unsigned sndPlayLatency;
  914. /**
  915. * Jitter buffer initial prefetch delay in msec. The value must be
  916. * between jb_min_pre and jb_max_pre below. If the value is 0,
  917. * prefetching will be disabled.
  918. *
  919. * Default: -1 (to use default stream settings, currently 0)
  920. */
  921. int jbInit;
  922. /**
  923. * Jitter buffer minimum prefetch delay in msec.
  924. *
  925. * Default: -1 (to use default stream settings, currently codec ptime)
  926. */
  927. int jbMinPre;
  928. /**
  929. * Jitter buffer maximum prefetch delay in msec.
  930. *
  931. * Default: -1 (to use default stream settings, currently 80% of jbMax)
  932. */
  933. int jbMaxPre;
  934. /**
  935. * Set maximum delay that can be accomodated by the jitter buffer msec.
  936. *
  937. * Default: -1 (to use default stream settings, currently 500 msec)
  938. */
  939. int jbMax;
  940. /**
  941. * Set the algorithm the jitter buffer uses to discard frames in order to
  942. * adjust the latency.
  943. *
  944. * Default: PJMEDIA_JB_DISCARD_PROGRESSIVE
  945. */
  946. pjmedia_jb_discard_algo jbDiscardAlgo;
  947. /**
  948. * Specify idle time of sound device before it is automatically closed,
  949. * in seconds. Use value -1 to disable the auto-close feature of sound
  950. * device
  951. *
  952. * Default : 1
  953. */
  954. int sndAutoCloseTime;
  955. /**
  956. * Specify whether built-in/native preview should be used if available.
  957. * In some systems, video input devices have built-in capability to show
  958. * preview window of the device. Using this built-in preview is preferable
  959. * as it consumes less CPU power. If built-in preview is not available,
  960. * the library will perform software rendering of the input. If this
  961. * field is set to PJ_FALSE, software preview will always be used.
  962. *
  963. * Default: PJ_TRUE
  964. */
  965. bool vidPreviewEnableNative;
  966. public:
  967. /** Default constructor initialises with default values */
  968. MediaConfig();
  969. /** Construct from pjsua_media_config. */
  970. void fromPj(const pjsua_media_config &mc);
  971. /** Export */
  972. pjsua_media_config toPj() const;
  973. /**
  974. * Read this object from a container.
  975. *
  976. * @param node Container to write values from.
  977. */
  978. virtual void readObject(const ContainerNode &node) PJSUA2_THROW(Error);
  979. /**
  980. * Write this object to a container.
  981. *
  982. * @param node Container to write values to.
  983. */
  984. virtual void writeObject(ContainerNode &node) const PJSUA2_THROW(Error);
  985. };
  986. /**
  987. * Endpoint configuration
  988. */
  989. struct EpConfig : public PersistentObject
  990. {
  991. /** UA config */
  992. UaConfig uaConfig;
  993. /** Logging config */
  994. LogConfig logConfig;
  995. /** Media config */
  996. MediaConfig medConfig;
  997. /**
  998. * Read this object from a container.
  999. *
  1000. * @param node Container to write values from.
  1001. */
  1002. virtual void readObject(const ContainerNode &node) PJSUA2_THROW(Error);
  1003. /**
  1004. * Write this object to a container.
  1005. *
  1006. * @param node Container to write values to.
  1007. */
  1008. virtual void writeObject(ContainerNode &node) const PJSUA2_THROW(Error);
  1009. };
  1010. /* This represents posted job */
  1011. struct PendingJob
  1012. {
  1013. /** Perform the job */
  1014. virtual void execute(bool is_pending) = 0;
  1015. /** Virtual destructor */
  1016. virtual ~PendingJob() {}
  1017. };
  1018. //////////////////////////////////////////////////////////////////////////////
  1019. /**
  1020. * Endpoint represents an instance of pjsua library. There can only be
  1021. * one instance of pjsua library in an application, hence this class
  1022. * is a singleton.
  1023. */
  1024. class Endpoint
  1025. {
  1026. public:
  1027. /** Retrieve the singleton instance of the endpoint */
  1028. static Endpoint &instance() PJSUA2_THROW(Error);
  1029. /** Default constructor */
  1030. Endpoint();
  1031. /** Virtual destructor */
  1032. virtual ~Endpoint();
  1033. /*************************************************************************
  1034. * Base library operations
  1035. */
  1036. /**
  1037. * Get library version.
  1038. */
  1039. Version libVersion() const;
  1040. /**
  1041. * Instantiate pjsua application. Application must call this function before
  1042. * calling any other functions, to make sure that the underlying libraries
  1043. * are properly initialized. Once this function has returned success,
  1044. * application must call libDestroy() before quitting.
  1045. */
  1046. void libCreate() PJSUA2_THROW(Error);
  1047. /**
  1048. * Get library state.
  1049. *
  1050. * @return library state.
  1051. */
  1052. pjsua_state libGetState() const;
  1053. /**
  1054. * Initialize pjsua with the specified settings. All the settings are
  1055. * optional, and the default values will be used when the config is not
  1056. * specified.
  1057. *
  1058. * Note that create() MUST be called before calling this function.
  1059. *
  1060. * @param prmEpConfig Endpoint configurations
  1061. */
  1062. void libInit( const EpConfig &prmEpConfig) PJSUA2_THROW(Error);
  1063. /**
  1064. * Call this function after all initialization is done, so that the
  1065. * library can do additional checking set up. Application may call this
  1066. * function any time after init().
  1067. */
  1068. void libStart() PJSUA2_THROW(Error);
  1069. /**
  1070. * Register a thread that was created by external or native API to the
  1071. * library. Note that each time this function is called, it will allocate
  1072. * some memory to store the thread description, which will only be freed
  1073. * when the library is destroyed.
  1074. *
  1075. * @param name The optional name to be assigned to the thread.
  1076. */
  1077. void libRegisterThread(const string &name) PJSUA2_THROW(Error);
  1078. /**
  1079. * Check if this thread has been registered to the library. Note that
  1080. * this function is only applicable for library main & worker threads and
  1081. * external/native threads registered using libRegisterThread().
  1082. */
  1083. bool libIsThreadRegistered();
  1084. /**
  1085. * Stop all worker threads.
  1086. */
  1087. void libStopWorkerThreads();
  1088. /**
  1089. * Poll pjsua for events, and if necessary block the caller thread for
  1090. * the specified maximum interval (in miliseconds).
  1091. *
  1092. * Application doesn't normally need to call this function if it has
  1093. * configured worker thread (\a thread_cnt field) in pjsua_config
  1094. * structure, because polling then will be done by these worker threads
  1095. * instead.
  1096. *
  1097. * If EpConfig::UaConfig::mainThreadOnly is enabled and this function
  1098. * is called from the main thread (by default the main thread is thread
  1099. * that calls libCreate()), this function will also scan and run any
  1100. * pending jobs in the list.
  1101. *
  1102. * @param msec_timeout Maximum time to wait, in miliseconds.
  1103. *
  1104. * @return The number of events that have been handled during the
  1105. * poll. Negative value indicates error, and application
  1106. * can retrieve the error as (status = -return_value).
  1107. */
  1108. int libHandleEvents(unsigned msec_timeout);
  1109. /**
  1110. * Destroy pjsua. Application is recommended to perform graceful shutdown
  1111. * before calling this function (such as unregister the account from the
  1112. * SIP server, terminate presense subscription, and hangup active calls),
  1113. * however, this function will do all of these if it finds there are
  1114. * active sessions that need to be terminated. This function will
  1115. * block for few seconds to wait for replies from remote.
  1116. *
  1117. * Application.may safely call this function more than once if it doesn't
  1118. * keep track of it's state.
  1119. *
  1120. * @param prmFlags Combination of pjsua_destroy_flag enumeration.
  1121. */
  1122. void libDestroy(unsigned prmFlags=0) PJSUA2_THROW(Error);
  1123. /*************************************************************************
  1124. * Utilities
  1125. */
  1126. /**
  1127. * Retrieve the error string for the specified status code.
  1128. *
  1129. * @param prmErr The error code.
  1130. */
  1131. string utilStrError(pj_status_t prmErr);
  1132. /**
  1133. * Write a log message.
  1134. *
  1135. * @param prmLevel Log verbosity level (1-5)
  1136. * @param prmSender The log sender.
  1137. * @param prmMsg The log message.
  1138. */
  1139. void utilLogWrite(int prmLevel,
  1140. const string &prmSender,
  1141. const string &prmMsg);
  1142. /**
  1143. * Write a log entry.
  1144. * Application must implement its own custom LogWriter and
  1145. * this function will then call the LogWriter::write() method.
  1146. * Note that this function does not call PJSIP's internal
  1147. * logging functionality. For that, you should use
  1148. * utilLogWrite(prmLevel, prmSender, prmMsg) above.
  1149. *
  1150. * @param e The log entry.
  1151. */
  1152. void utilLogWrite(LogEntry &e);
  1153. /**
  1154. * This is a utility function to verify that valid SIP url is given. If the
  1155. * URL is a valid SIP/SIPS scheme, PJ_SUCCESS will be returned.
  1156. *
  1157. * @param prmUri The URL string.
  1158. *
  1159. * @return PJ_SUCCESS on success, or the appropriate error
  1160. * code.
  1161. *
  1162. * @see utilVerifyUri()
  1163. */
  1164. pj_status_t utilVerifySipUri(const string &prmUri);
  1165. /**
  1166. * This is a utility function to verify that valid URI is given. Unlike
  1167. * utilVerifySipUri(), this function will return PJ_SUCCESS if tel: URI
  1168. * is given.
  1169. *
  1170. * @param prmUri The URL string.
  1171. *
  1172. * @return PJ_SUCCESS on success, or the appropriate error
  1173. * code.
  1174. *
  1175. * @see pjsua_verify_sip_url()
  1176. */
  1177. pj_status_t utilVerifyUri(const string &prmUri);
  1178. /**
  1179. * Schedule a timer with the specified interval and user data. When the
  1180. * interval elapsed, onTimer() callback will be
  1181. * called. Note that the callback may be executed by different thread,
  1182. * depending on whether worker thread is enabled or not.
  1183. *
  1184. * @param prmMsecDelay The time interval in msec.
  1185. * @param prmUserData Arbitrary user data, to be given back to
  1186. * application in the callback.
  1187. *
  1188. * @return Token to identify the timer, which could be
  1189. * given to utilTimerCancel().
  1190. */
  1191. Token utilTimerSchedule(unsigned prmMsecDelay,
  1192. Token prmUserData) PJSUA2_THROW(Error);
  1193. /**
  1194. * Cancel previously scheduled timer with the specified timer token.
  1195. *
  1196. * @param prmToken The timer token, which was returned from
  1197. * previous utilTimerSchedule() call.
  1198. */
  1199. void utilTimerCancel(Token prmToken);
  1200. /**
  1201. * Utility to register a pending job to be executed by main thread.
  1202. * If EpConfig::UaConfig::mainThreadOnly is false, the job will be
  1203. * executed immediately.
  1204. *
  1205. * @param job The job class.
  1206. */
  1207. void utilAddPendingJob(PendingJob *job);
  1208. /**
  1209. * Get cipher list supported by SSL/TLS backend.
  1210. */
  1211. IntVector utilSslGetAvailableCiphers() PJSUA2_THROW(Error);
  1212. /*************************************************************************
  1213. * NAT operations
  1214. */
  1215. /**
  1216. * This is a utility function to detect NAT type in front of this endpoint.
  1217. * Once invoked successfully, this function will complete asynchronously
  1218. * and report the result in onNatDetectionComplete().
  1219. *
  1220. * After NAT has been detected and the callback is called, application can
  1221. * get the detected NAT type by calling natGetType(). Application
  1222. * can also perform NAT detection by calling natDetectType()
  1223. * again at later time.
  1224. *
  1225. * Note that STUN must be enabled to run this function successfully.
  1226. */
  1227. void natDetectType(void) PJSUA2_THROW(Error);
  1228. /**
  1229. * Get the NAT type as detected by natDetectType() function. This
  1230. * function will only return useful NAT type after natDetectType()
  1231. * has completed successfully and onNatDetectionComplete()
  1232. * callback has been called.
  1233. *
  1234. * Exception: if this function is called while detection is in progress,
  1235. * PJ_EPENDING exception will be raised.
  1236. */
  1237. pj_stun_nat_type natGetType() PJSUA2_THROW(Error);
  1238. /**
  1239. * Update the STUN servers list. The libInit() must have been called
  1240. * before calling this function.
  1241. *
  1242. * @param prmServers Array of STUN servers to try. The endpoint
  1243. * will try to resolve and contact each of the
  1244. * STUN server entry until it finds one that is
  1245. * usable. Each entry may be a domain name, host
  1246. * name, IP address, and it may contain an
  1247. * optional port number. For example:
  1248. * - "pjsip.org" (domain name)
  1249. * - "sip.pjsip.org" (host name)
  1250. * - "pjsip.org:33478" (domain name and a non-
  1251. * standard port number)
  1252. * - "10.0.0.1:3478" (IP address and port number)
  1253. * @param prmWait Specify if the function should block until
  1254. * it gets the result. In this case, the
  1255. * function will block while the resolution
  1256. * is being done, and the callback
  1257. * onNatCheckStunServersComplete() will be called
  1258. * before this function returns.
  1259. *
  1260. */
  1261. void natUpdateStunServers(const StringVector &prmServers,
  1262. bool prmWait) PJSUA2_THROW(Error);
  1263. /**
  1264. * Auxiliary function to resolve and contact each of the STUN server
  1265. * entries (sequentially) to find which is usable. The libInit() must
  1266. * have been called before calling this function.
  1267. *
  1268. * @param prmServers Array of STUN servers to try. The endpoint
  1269. * will try to resolve and contact each of the
  1270. * STUN server entry until it finds one that is
  1271. * usable. Each entry may be a domain name, host
  1272. * name, IP address, and it may contain an
  1273. * optional port number. For example:
  1274. * - "pjsip.org" (domain name)
  1275. * - "sip.pjsip.org" (host name)
  1276. * - "pjsip.org:33478" (domain name and a non-
  1277. * standard port number)
  1278. * - "10.0.0.1:3478" (IP address and port number)
  1279. * @param prmWait Specify if the function should block until
  1280. * it gets the result. In this case, the function
  1281. * will block while the resolution is being done,
  1282. * and the callback will be called before this
  1283. * function returns.
  1284. * @param prmUserData Arbitrary user data to be passed back to
  1285. * application in the callback.
  1286. *
  1287. * @see natCancelCheckStunServers()
  1288. */
  1289. void natCheckStunServers(const StringVector &prmServers,
  1290. bool prmWait,
  1291. Token prmUserData) PJSUA2_THROW(Error);
  1292. /**
  1293. * Cancel pending STUN resolution which match the specified token.
  1294. *
  1295. * @param token The token to match. This token was given to
  1296. * natCheckStunServers()
  1297. * @param notify_cb Boolean to control whether the callback should
  1298. * be called for cancelled resolutions. When the
  1299. * callback is called, the status in the result
  1300. * will be set as PJ_ECANCELLED.
  1301. *
  1302. * Exception: PJ_ENOTFOUND if there is no matching one, or other error.
  1303. */
  1304. void natCancelCheckStunServers(Token token,
  1305. bool notify_cb = false) PJSUA2_THROW(Error);
  1306. /*************************************************************************
  1307. * Transport operations
  1308. */
  1309. /**
  1310. * Create and start a new SIP transport according to the specified
  1311. * settings.
  1312. *
  1313. * @param type Transport type.
  1314. * @param cfg Transport configuration.
  1315. *
  1316. * @return The transport ID.
  1317. */
  1318. TransportId transportCreate(pjsip_transport_type_e type,
  1319. const TransportConfig &cfg) PJSUA2_THROW(Error);
  1320. /**
  1321. * Enumerate all transports currently created in the system. This
  1322. * function will return all transport IDs, and application may then
  1323. * call transportGetInfo() function to retrieve detailed information
  1324. * about the transport.
  1325. *
  1326. * @return Array of transport IDs.
  1327. */
  1328. IntVector transportEnum() const PJSUA2_THROW(Error);
  1329. /**
  1330. * Get information about transport.
  1331. *
  1332. * @param id Transport ID.
  1333. *
  1334. * @return Transport info.
  1335. */
  1336. TransportInfo transportGetInfo(TransportId id) const PJSUA2_THROW(Error);
  1337. #if 0
  1338. // Not implemented.
  1339. /**
  1340. * Disable a transport or re-enable it. By default transport is always
  1341. * enabled after it is created. Disabling a transport does not necessarily
  1342. * close the socket, it will only discard incoming messages and prevent
  1343. * the transport from being used to send outgoing messages.
  1344. *
  1345. * @param id Transport ID.
  1346. * @param enabled Enable or disable the transport.
  1347. *
  1348. */
  1349. void transportSetEnable(TransportId id, bool enabled) PJSUA2_THROW(Error);
  1350. #endif
  1351. /**
  1352. * Close the transport. The system will wait until all transactions are
  1353. * closed while preventing new users from using the transport, and will
  1354. * close the transport when its usage count reaches zero.
  1355. *
  1356. * @param id Transport ID.
  1357. */
  1358. void transportClose(TransportId id) PJSUA2_THROW(Error);
  1359. /**
  1360. * Start graceful shutdown procedure for this transport handle. After
  1361. * graceful shutdown has been initiated, no new reference can be
  1362. * obtained for the transport. However, existing objects that currently
  1363. * uses the transport may still use this transport to send and receive
  1364. * packets. After all objects release their reference to this transport,
  1365. * the transport will be destroyed immediately.
  1366. *
  1367. * Note: application normally uses this API after obtaining the handle
  1368. * from onTransportState() callback.
  1369. *
  1370. * @param tp The transport.
  1371. */
  1372. void transportShutdown(TransportHandle tp) PJSUA2_THROW(Error);
  1373. /*************************************************************************
  1374. * Call operations
  1375. */
  1376. /**
  1377. * Terminate all calls. This will initiate call hangup for all
  1378. * currently active calls.
  1379. */
  1380. void hangupAllCalls(void);
  1381. /*************************************************************************
  1382. * Media operations
  1383. */
  1384. /**
  1385. * Add media to the media list.
  1386. *
  1387. * @param media media to be added.
  1388. */
  1389. void mediaAdd(AudioMedia &media);
  1390. /**
  1391. * Remove media from the media list.
  1392. *
  1393. * @param media media to be removed.
  1394. */
  1395. void mediaRemove(AudioMedia &media);
  1396. /**
  1397. * Check if media has been added to the media list.
  1398. *
  1399. * @param media media to be check.
  1400. *
  1401. * @return True if media has been added, false otherwise.
  1402. */
  1403. bool mediaExists(const AudioMedia &media) const;
  1404. /**
  1405. * Get maximum number of media port.
  1406. *
  1407. * @return Maximum number of media port in the conference bridge.
  1408. */
  1409. unsigned mediaMaxPorts() const;
  1410. /**
  1411. * Get current number of active media port in the bridge.
  1412. *
  1413. * @return The number of active media port.
  1414. */
  1415. unsigned mediaActivePorts() const;
  1416. #if !DEPRECATED_FOR_TICKET_2232
  1417. /**
  1418. * Warning: deprecated, use mediaEnumPorts2() instead. This function is
  1419. * not safe in multithreaded environment.
  1420. *
  1421. * Enumerate all media port.
  1422. *
  1423. * @return The list of media port.
  1424. */
  1425. const AudioMediaVector &mediaEnumPorts() const PJSUA2_THROW(Error);
  1426. #endif
  1427. /**
  1428. * Enumerate all audio media port.
  1429. *
  1430. * @return The list of audio media port.
  1431. */
  1432. AudioMediaVector2 mediaEnumPorts2() const PJSUA2_THROW(Error);
  1433. /**
  1434. * Enumerate all video media port.
  1435. *
  1436. * @return The list of video media port.
  1437. */
  1438. VideoMediaVector mediaEnumVidPorts() const PJSUA2_THROW(Error);
  1439. /**
  1440. * Get the instance of Audio Device Manager.
  1441. *
  1442. * @return The Audio Device Manager.
  1443. */
  1444. AudDevManager &audDevManager();
  1445. /**
  1446. * Get the instance of Video Device Manager.
  1447. *
  1448. * @return The Video Device Manager.
  1449. */
  1450. VidDevManager &vidDevManager();
  1451. /*************************************************************************
  1452. * Codec management operations
  1453. */
  1454. #if !DEPRECATED_FOR_TICKET_2232
  1455. /**
  1456. * Warning: deprecated, use codecEnum2() instead. This function is not
  1457. * safe in multithreaded environment.
  1458. *
  1459. * Enum all supported codecs in the system.
  1460. *
  1461. * @return Array of codec info.
  1462. */
  1463. const CodecInfoVector &codecEnum() PJSUA2_THROW(Error);
  1464. #endif
  1465. /**
  1466. * Enum all supported codecs in the system.
  1467. *
  1468. * @return Array of codec info.
  1469. */
  1470. CodecInfoVector2 codecEnum2() const PJSUA2_THROW(Error);
  1471. /**
  1472. * Change codec priority.
  1473. *
  1474. * @param codec_id Codec ID, which is a string that uniquely identify
  1475. * the codec (such as "speex/8000").
  1476. * @param priority Codec priority, 0-255, where zero means to disable
  1477. * the codec.
  1478. *
  1479. */
  1480. void codecSetPriority(const string &codec_id,
  1481. pj_uint8_t priority) PJSUA2_THROW(Error);
  1482. /**
  1483. * Get codec parameters.
  1484. *
  1485. * @param codec_id Codec ID.
  1486. *
  1487. * @return Codec parameters. If codec is not found, Error
  1488. * will be thrown.
  1489. *
  1490. */
  1491. CodecParam codecGetParam(const string &codec_id) const PJSUA2_THROW(Error);
  1492. /**
  1493. * Set codec parameters.
  1494. *
  1495. * @param codec_id Codec ID.
  1496. * @param param Codec parameter to set. Set to NULL to reset
  1497. * codec parameter to library default settings.
  1498. *
  1499. */
  1500. void codecSetParam(const string &codec_id,
  1501. const CodecParam param) PJSUA2_THROW(Error);
  1502. #if !DEPRECATED_FOR_TICKET_2232
  1503. /**
  1504. * Warning: deprecated, use videoCodecEnum2() instead. This function is
  1505. * not safe in multithreaded environment.
  1506. *
  1507. * Enum all supported video codecs in the system.
  1508. *
  1509. * @return Array of video codec info.
  1510. */
  1511. const CodecInfoVector &videoCodecEnum() PJSUA2_THROW(Error);
  1512. #endif
  1513. /**
  1514. * Enum all supported video codecs in the system.
  1515. *
  1516. * @return Array of video codec info.
  1517. */
  1518. CodecInfoVector2 videoCodecEnum2() const PJSUA2_THROW(Error);
  1519. /**
  1520. * Change video codec priority.
  1521. *
  1522. * @param codec_id Codec ID, which is a string that uniquely identify
  1523. * the codec (such as "H263/90000"). Please see pjsua
  1524. * manual or pjmedia codec reference for details.
  1525. * @param priority Codec priority, 0-255, where zero means to disable
  1526. * the codec.
  1527. *
  1528. */
  1529. void videoCodecSetPriority(const string &codec_id,
  1530. pj_uint8_t priority) PJSUA2_THROW(Error);
  1531. /**
  1532. * Get video codec parameters.
  1533. *
  1534. * @param codec_id Codec ID.
  1535. *
  1536. * @return Codec parameters. If codec is not found, Error
  1537. * will be thrown.
  1538. *
  1539. */
  1540. VidCodecParam getVideoCodecParam(const string &codec_id) const
  1541. PJSUA2_THROW(Error);
  1542. /**
  1543. * Set video codec parameters.
  1544. *
  1545. * @param codec_id Codec ID.
  1546. * @param param Codec parameter to set.
  1547. *
  1548. */
  1549. void setVideoCodecParam(const string &codec_id,
  1550. const VidCodecParam &param) PJSUA2_THROW(Error);
  1551. /**
  1552. * Reset video codec parameters to library default settings.
  1553. *
  1554. * @param codec_id Codec ID.
  1555. *
  1556. */
  1557. void resetVideoCodecParam(const string &codec_id) PJSUA2_THROW(Error);
  1558. /**
  1559. * Get codec Opus config.
  1560. *
  1561. */
  1562. CodecOpusConfig getCodecOpusConfig() const PJSUA2_THROW(Error);
  1563. /**
  1564. * Set codec Opus config.
  1565. *
  1566. * @param opus_cfg Codec Opus configuration.
  1567. *
  1568. */
  1569. void setCodecOpusConfig(const CodecOpusConfig &opus_cfg)
  1570. PJSUA2_THROW(Error);
  1571. /**
  1572. * Get codec Lyra config.
  1573. *
  1574. */
  1575. CodecLyraConfig getCodecLyraConfig() const PJSUA2_THROW(Error);
  1576. /**
  1577. * Set codec Lyra config.
  1578. *
  1579. * @param lyra_cfg Codec Lyra configuration.
  1580. *
  1581. */
  1582. void setCodecLyraConfig(const CodecLyraConfig &lyra_cfg)
  1583. PJSUA2_THROW(Error);
  1584. /**
  1585. * Enumerate all SRTP crypto-suite names.
  1586. *
  1587. * @return The list of SRTP crypto-suite name.
  1588. */
  1589. StringVector srtpCryptoEnum() PJSUA2_THROW(Error);
  1590. /*************************************************************************
  1591. * IP Change
  1592. */
  1593. /**
  1594. * Inform the stack that IP address change event was detected.
  1595. * The stack will:
  1596. * 1. Restart the listener (this step is configurable via
  1597. * \a IpChangeParam.restartListener).
  1598. * 2. Shutdown the transport used by account registration (this step is
  1599. * configurable via \a AccountConfig.ipChangeConfig.shutdownTp).
  1600. * 3. Update contact URI by sending re-Registration (this step is
  1601. * configurable via a\ AccountConfig.natConfig.contactRewriteUse and
  1602. * a\ AccountConfig.natConfig.contactRewriteMethod)
  1603. * 4. Hangup active calls (this step is configurable via
  1604. * a\ AccountConfig.ipChangeConfig.hangupCalls) or
  1605. * continue the call by sending re-INVITE
  1606. * (configurable via \a AccountConfig.ipChangeConfig.reinviteFlags).
  1607. *
  1608. * @param param The IP change parameter, have a look at IpChangeParam.
  1609. */
  1610. void handleIpChange(const IpChangeParam &param) PJSUA2_THROW(Error);
  1611. public:
  1612. /*
  1613. * Overrideables callbacks
  1614. */
  1615. /**
  1616. * Callback when the Endpoint has finished performing NAT type
  1617. * detection that is initiated with natDetectType().
  1618. *
  1619. * @param prm Callback parameters containing the detection
  1620. * result.
  1621. */
  1622. virtual void onNatDetectionComplete(
  1623. const OnNatDetectionCompleteParam &prm)
  1624. { PJ_UNUSED_ARG(prm); }
  1625. /**
  1626. * Callback when the Endpoint has finished performing STUN server
  1627. * checking that is initiated when calling libInit(), or by
  1628. * calling natCheckStunServers() or natUpdateStunServers().
  1629. *
  1630. * @param prm Callback parameters.
  1631. */
  1632. virtual void onNatCheckStunServersComplete(
  1633. const OnNatCheckStunServersCompleteParam &prm)
  1634. { PJ_UNUSED_ARG(prm); }
  1635. /**
  1636. * This callback is called when transport state has changed.
  1637. *
  1638. * @param prm Callback parameters.
  1639. */
  1640. virtual void onTransportState(
  1641. const OnTransportStateParam &prm)
  1642. { PJ_UNUSED_ARG(prm); }
  1643. /**
  1644. * Callback when a timer has fired. The timer was scheduled by
  1645. * utilTimerSchedule().
  1646. *
  1647. * @param prm Callback parameters.
  1648. */
  1649. virtual void onTimer(const OnTimerParam &prm)
  1650. { PJ_UNUSED_ARG(prm); }
  1651. /**
  1652. * This callback can be used by application to override the account
  1653. * to be used to handle an incoming message. Initially, the account to
  1654. * be used will be calculated automatically by the library. This initial
  1655. * account will be used if application does not implement this callback,
  1656. * or application sets an invalid account upon returning from this
  1657. * callback.
  1658. *
  1659. * Note that currently the incoming messages requiring account assignment
  1660. * are INVITE, MESSAGE, SUBSCRIBE, and unsolicited NOTIFY. This callback
  1661. * may be called before the callback of the SIP event itself, i.e:
  1662. * incoming call, pager, subscription, or unsolicited-event.
  1663. *
  1664. * @param prm Callback parameters.
  1665. */
  1666. virtual void onSelectAccount(OnSelectAccountParam &prm)
  1667. { PJ_UNUSED_ARG(prm); }
  1668. /**
  1669. * Calling #handleIpChange() may involve different operation. This
  1670. * callback is called to report the progress of each enabled operation.
  1671. *
  1672. * @param prm Callback parameters.
  1673. *
  1674. */
  1675. virtual void onIpChangeProgress(OnIpChangeProgressParam &prm)
  1676. { PJ_UNUSED_ARG(prm); }
  1677. /**
  1678. * Notification about media events such as video notifications. This
  1679. * callback will most likely be called from media threads, thus
  1680. * application must not perform heavy processing in this callback.
  1681. * If application needs to perform more complex tasks to handle the
  1682. * event, it should post the task to another thread.
  1683. *
  1684. * @param prm Callback parameter.
  1685. */
  1686. virtual void onMediaEvent(OnMediaEventParam &prm)
  1687. { PJ_UNUSED_ARG(prm); }
  1688. /**
  1689. * Callback for custom computation of the digest AKA response.
  1690. *
  1691. * Usually an application does not need to implement (overload) this
  1692. * callback because by default the response digest AKA is automatically
  1693. * computed using <b>libmilenage</b>.
  1694. *
  1695. * To use Digest AKA authentication, add \a PJSIP_CRED_DATA_EXT_AKA flag
  1696. * in the AuthCredInfo's \a dataType field of the AccountConfig, and
  1697. * fill up other AKA specific information in AuthCredInfo.
  1698. * Please see \ref PJSIP_AUTH_AKA_API for more information.
  1699. *
  1700. * @param prm Callback parameter.
  1701. *
  1702. * @return Return PJ_ENOTSUP to let the library compute
  1703. * the response digest automatically.
  1704. * Return PJ_SUCCESS if application does the computation
  1705. * and sets the response digest in
  1706. * \a prm.DigestCredential.response.
  1707. */
  1708. virtual pj_status_t onCredAuth(OnCredAuthParam &prm);
  1709. /**
  1710. * This callback will be invoked when the library implicitly rejects
  1711. * an incoming call.
  1712. *
  1713. * In addition to being declined explicitly using the Call::answer()
  1714. * method, the library may also automatically reject the incoming call
  1715. * due to different scenarios, e.g:
  1716. * - no available call slot.
  1717. * - no available account to handle the call.
  1718. * - when an incoming INVITE is received with, for instance, a message
  1719. * containing invalid SDP.
  1720. *
  1721. * @param prm Callback parameters.
  1722. */
  1723. virtual void onRejectedIncomingCall(OnRejectedIncomingCallParam &prm)
  1724. { PJ_UNUSED_ARG(prm); }
  1725. private:
  1726. static Endpoint *instance_; // static instance
  1727. LogWriter *writer; // Custom writer, if any
  1728. AudDevManager *audioDevMgr;
  1729. VidDevManager *videoDevMgr;
  1730. #if !DEPRECATED_FOR_TICKET_2232
  1731. CodecInfoVector codecInfoList;
  1732. CodecInfoVector videoCodecInfoList;
  1733. #endif
  1734. std::map<pj_thread_t*, pj_thread_desc*> threadDescMap;
  1735. pj_mutex_t *threadDescMutex;
  1736. #if !DEPRECATED_FOR_TICKET_2232
  1737. AudioMediaVector mediaList;
  1738. pj_mutex_t *mediaListMutex;
  1739. #endif
  1740. /* Pending logging */
  1741. bool mainThreadOnly;
  1742. void *mainThread;
  1743. unsigned pendingJobSize;
  1744. std::list<PendingJob*> pendingJobs;
  1745. void performPendingJobs();
  1746. /* Endpoint static callbacks */
  1747. static void logFunc(int level, const char *data, int len);
  1748. static void stun_resolve_cb(const pj_stun_resolve_result *result);
  1749. static void on_timer(pj_timer_heap_t *timer_heap,
  1750. struct pj_timer_entry *entry);
  1751. static void on_nat_detect(const pj_stun_nat_detect_result *res);
  1752. static void on_transport_state(pjsip_transport *tp,
  1753. pjsip_transport_state state,
  1754. const pjsip_transport_state_info *info);
  1755. private:
  1756. /*
  1757. * Account & Call lookups
  1758. */
  1759. static Account *lookupAcc(int acc_id, const char *op);
  1760. static Call *lookupCall(int call_id, const char *op);
  1761. /* static callbacks */
  1762. static void on_incoming_call(pjsua_acc_id acc_id,
  1763. pjsua_call_id call_id,
  1764. pjsip_rx_data *rdata);
  1765. static void on_reg_started(pjsua_acc_id acc_id,
  1766. pj_bool_t renew);
  1767. static void on_reg_state2(pjsua_acc_id acc_id,
  1768. pjsua_reg_info *info);
  1769. static void on_incoming_subscribe(pjsua_acc_id acc_id,
  1770. pjsua_srv_pres *srv_pres,
  1771. pjsua_buddy_id buddy_id,
  1772. const pj_str_t *from,
  1773. pjsip_rx_data *rdata,
  1774. pjsip_status_code *code,
  1775. pj_str_t *reason,
  1776. pjsua_msg_data *msg_data);
  1777. static void on_pager2(pjsua_call_id call_id,
  1778. const pj_str_t *from,
  1779. const pj_str_t *to,
  1780. const pj_str_t *contact,
  1781. const pj_str_t *mime_type,
  1782. const pj_str_t *body,
  1783. pjsip_rx_data *rdata,
  1784. pjsua_acc_id acc_id);
  1785. static void on_pager_status2(pjsua_call_id call_id,
  1786. const pj_str_t *to,
  1787. const pj_str_t *body,
  1788. void *user_data,
  1789. pjsip_status_code status,
  1790. const pj_str_t *reason,
  1791. pjsip_tx_data *tdata,
  1792. pjsip_rx_data *rdata,
  1793. pjsua_acc_id acc_id);
  1794. static void on_typing2(pjsua_call_id call_id,
  1795. const pj_str_t *from,
  1796. const pj_str_t *to,
  1797. const pj_str_t *contact,
  1798. pj_bool_t is_typing,
  1799. pjsip_rx_data *rdata,
  1800. pjsua_acc_id acc_id);
  1801. static void on_mwi_info(pjsua_acc_id acc_id,
  1802. pjsua_mwi_info *mwi_info);
  1803. static void on_acc_find_for_incoming(const pjsip_rx_data *rdata,
  1804. pjsua_acc_id* acc_id);
  1805. static void on_buddy_state(pjsua_buddy_id buddy_id);
  1806. static void on_buddy_evsub_state(pjsua_buddy_id buddy_id,
  1807. pjsip_evsub *sub,
  1808. pjsip_event *event);
  1809. // Call callbacks
  1810. static void on_call_state(pjsua_call_id call_id, pjsip_event *e);
  1811. static void on_call_tsx_state(pjsua_call_id call_id,
  1812. pjsip_transaction *tsx,
  1813. pjsip_event *e);
  1814. static void on_call_media_state(pjsua_call_id call_id);
  1815. static void on_call_sdp_created(pjsua_call_id call_id,
  1816. pjmedia_sdp_session *sdp,
  1817. pj_pool_t *pool,
  1818. const pjmedia_sdp_session *rem_sdp);
  1819. static void on_stream_precreate(pjsua_call_id call_id,
  1820. pjsua_on_stream_precreate_param *param);
  1821. static void on_stream_created2(pjsua_call_id call_id,
  1822. pjsua_on_stream_created_param *param);
  1823. static void on_stream_destroyed(pjsua_call_id call_id,
  1824. pjmedia_stream *strm,
  1825. unsigned stream_idx);
  1826. static void on_dtmf_digit(pjsua_call_id call_id, int digit);
  1827. static void on_dtmf_digit2(pjsua_call_id call_id,
  1828. const pjsua_dtmf_info *info);
  1829. static void on_dtmf_event(pjsua_call_id call_id,
  1830. const pjsua_dtmf_event *event);
  1831. static void on_call_transfer_request(pjsua_call_id call_id,
  1832. const pj_str_t *dst,
  1833. pjsip_status_code *code);
  1834. static void on_call_transfer_request2(pjsua_call_id call_id,
  1835. const pj_str_t *dst,
  1836. pjsip_status_code *code,
  1837. pjsua_call_setting *opt);
  1838. static void on_call_transfer_status(pjsua_call_id call_id,
  1839. int st_code,
  1840. const pj_str_t *st_text,
  1841. pj_bool_t final,
  1842. pj_bool_t *p_cont);
  1843. static void on_call_replace_request(pjsua_call_id call_id,
  1844. pjsip_rx_data *rdata,
  1845. int *st_code,
  1846. pj_str_t *st_text);
  1847. static void on_call_replace_request2(pjsua_call_id call_id,
  1848. pjsip_rx_data *rdata,
  1849. int *st_code,
  1850. pj_str_t *st_text,
  1851. pjsua_call_setting *opt);
  1852. static void on_call_replaced(pjsua_call_id old_call_id,
  1853. pjsua_call_id new_call_id);
  1854. static void on_call_rx_offer(pjsua_call_id call_id,
  1855. const pjmedia_sdp_session *offer,
  1856. void *reserved,
  1857. pjsip_status_code *code,
  1858. pjsua_call_setting *opt);
  1859. static void on_call_rx_reinvite(pjsua_call_id call_id,
  1860. const pjmedia_sdp_session *offer,
  1861. pjsip_rx_data *rdata,
  1862. void *reserved,
  1863. pj_bool_t *async,
  1864. pjsip_status_code *code,
  1865. pjsua_call_setting *opt);
  1866. static void on_call_tx_offer(pjsua_call_id call_id,
  1867. void *reserved,
  1868. pjsua_call_setting *opt);
  1869. static pjsip_redirect_op on_call_redirected(pjsua_call_id call_id,
  1870. const pjsip_uri *target,
  1871. const pjsip_event *e);
  1872. static pj_status_t
  1873. on_call_media_transport_state(pjsua_call_id call_id,
  1874. const pjsua_med_tp_state_info *info);
  1875. static void on_media_event(pjmedia_event *event);
  1876. static void on_call_media_event(pjsua_call_id call_id,
  1877. unsigned med_idx,
  1878. pjmedia_event *event);
  1879. static pjmedia_transport*
  1880. on_create_media_transport(pjsua_call_id call_id,
  1881. unsigned media_idx,
  1882. pjmedia_transport *base_tp,
  1883. unsigned flags);
  1884. static void
  1885. on_create_media_transport_srtp(pjsua_call_id call_id,
  1886. unsigned media_idx,
  1887. pjmedia_srtp_setting *srtp_opt);
  1888. static void
  1889. on_ip_change_progress(pjsua_ip_change_op op,
  1890. pj_status_t status,
  1891. const pjsua_ip_change_op_info *info);
  1892. static pj_status_t on_auth_create_aka_response_callback(
  1893. pj_pool_t *pool,
  1894. const pjsip_digest_challenge*chal,
  1895. const pjsip_cred_info *cred,
  1896. const pj_str_t *method,
  1897. pjsip_digest_credential *auth);
  1898. static void on_rejected_incoming_call(
  1899. const pjsua_on_rejected_incoming_call_param *param);
  1900. friend class Account;
  1901. private:
  1902. void clearCodecInfoList(CodecInfoVector &codec_list);
  1903. void updateCodecInfoList(pjsua_codec_info pj_codec[], unsigned count,
  1904. CodecInfoVector &codec_list);
  1905. };
  1906. /**
  1907. * @} PJSUA2_UA
  1908. */
  1909. }
  1910. /* End pj namespace */
  1911. #endif /* __PJSUA2_UA_HPP__ */