- Timestamp:
- Oct 1, 2013 9:41:01 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/branches/projects/pjsua2/pjsip/src/pjsua2/endpoint.cpp
r4598 r4608 18 18 */ 19 19 #include <pjsua2/endpoint.hpp> 20 #include "util.hpp" 20 21 21 22 using namespace pj; … … 29 30 { 30 31 pj_uint32_t signature; 31 TimerCompleteParam prm;32 OnTimerParam prm; 32 33 pj_timer_entry entry; 33 34 }; … … 35 36 36 37 /////////////////////////////////////////////////////////////////////////////// 38 39 UaConfig::UaConfig() 40 { 41 pjsua_config ua_cfg; 42 43 pjsua_config_default(&ua_cfg); 44 fromPj(ua_cfg); 45 } 46 47 void UaConfig::fromPj(const pjsua_config &ua_cfg) 48 { 49 unsigned i; 50 51 this->maxCalls = ua_cfg.max_calls; 52 this->threadCnt = ua_cfg.thread_cnt; 53 this->userAgent = pj2Str(ua_cfg.user_agent); 54 55 for (i=0; i<ua_cfg.nameserver_count; ++i) { 56 this->nameserver.push_back(pj2Str(ua_cfg.nameserver[i])); 57 } 58 59 for (i=0; i<ua_cfg.stun_srv_cnt; ++i) { 60 this->stunServer.push_back(pj2Str(ua_cfg.stun_srv[i])); 61 } 62 63 this->stunIgnoreFailure = ua_cfg.stun_ignore_failure; 64 this->natTypeInSdp = ua_cfg.nat_type_in_sdp; 65 this->mwiUnsolicitedEnabled = ua_cfg.enable_unsolicited_mwi; 66 } 67 68 pjsua_config UaConfig::toPj() const 69 { 70 unsigned i; 71 pjsua_config pua_cfg; 72 73 pjsua_config_default(&pua_cfg); 74 75 pua_cfg.max_calls = this->maxCalls; 76 pua_cfg.thread_cnt = this->threadCnt; 77 pua_cfg.user_agent = str2Pj(this->userAgent); 78 79 for (i=0; i<this->nameserver.size() && i<PJ_ARRAY_SIZE(pua_cfg.nameserver); 80 ++i) 81 { 82 pua_cfg.nameserver[i] = str2Pj(this->nameserver[i]); 83 } 84 pua_cfg.nameserver_count = i; 85 86 for (i=0; i<this->stunServer.size() && i<PJ_ARRAY_SIZE(pua_cfg.stun_srv); 87 ++i) 88 { 89 pua_cfg.stun_srv[i] = str2Pj(this->stunServer[i]); 90 } 91 pua_cfg.stun_srv_cnt = i; 92 93 pua_cfg.nat_type_in_sdp = this->natTypeInSdp; 94 pua_cfg.enable_unsolicited_mwi = this->mwiUnsolicitedEnabled; 95 96 return pua_cfg; 97 } 98 99 /////////////////////////////////////////////////////////////////////////////// 100 101 LogConfig::LogConfig() 102 { 103 pjsua_logging_config lc; 104 105 pjsua_logging_config_default(&lc); 106 fromPj(lc); 107 } 108 109 void LogConfig::fromPj(const pjsua_logging_config &lc) 110 { 111 this->msgLogging = lc.msg_logging; 112 this->level = lc.level; 113 this->consoleLevel = lc.console_level; 114 this->decor = lc.decor; 115 this->filename = pj2Str(lc.log_filename); 116 this->fileFlags = lc.log_file_flags; 117 this->writer = NULL; 118 } 119 120 pjsua_logging_config LogConfig::toPj() const 121 { 122 pjsua_logging_config lc; 123 124 pjsua_logging_config_default(&lc); 125 126 lc.msg_logging = this->msgLogging; 127 lc.level = this->level; 128 lc.console_level = this->consoleLevel; 129 lc.decor = this->decor; 130 lc.log_file_flags = this->fileFlags; 131 lc.log_filename = str2Pj(this->filename); 132 133 return lc; 134 } 135 136 /////////////////////////////////////////////////////////////////////////////// 137 138 MediaConfig::MediaConfig() 139 { 140 pjsua_media_config mc; 141 142 pjsua_media_config_default(&mc); 143 fromPj(mc); 144 } 145 146 void MediaConfig::fromPj(const pjsua_media_config &mc) 147 { 148 this->clockRate = mc.clock_rate; 149 this->sndClockRate = mc.snd_clock_rate; 150 this->channelCount = mc.channel_count; 151 this->audioFramePtime = mc.audio_frame_ptime; 152 this->maxMediaPorts = mc.max_media_ports; 153 this->hasIoqueue = mc.has_ioqueue; 154 this->threadCnt = mc.thread_cnt; 155 this->quality = mc.quality; 156 this->ptime = mc.ptime; 157 this->noVad = mc.no_vad; 158 this->ilbcMode = mc.ilbc_mode; 159 this->txDropPct = mc.tx_drop_pct; 160 this->rxDropPct = mc.rx_drop_pct; 161 this->ecOptions = mc.ec_options; 162 this->ecTailLen = mc.ec_tail_len; 163 this->sndRecLatency = mc.snd_rec_latency; 164 this->sndPlayLatency = mc.snd_play_latency; 165 this->jbInit = mc.jb_init; 166 this->jbMinPre = mc.jb_min_pre; 167 this->jbMaxPre = mc.jb_max_pre; 168 this->jbMax = mc.jb_max; 169 this->sndAutoCloseTime = mc.snd_auto_close_time; 170 this->vidPreviewEnableNative = mc.vid_preview_enable_native; 171 } 172 173 pjsua_media_config MediaConfig::toPj() const 174 { 175 pjsua_media_config mcfg; 176 177 pjsua_media_config_default(&mcfg); 178 179 mcfg.clock_rate = this->clockRate; 180 mcfg.snd_clock_rate = this->sndClockRate; 181 mcfg.channel_count = this->channelCount; 182 mcfg.audio_frame_ptime = this->audioFramePtime; 183 mcfg.max_media_ports = this->maxMediaPorts; 184 mcfg.has_ioqueue = this->hasIoqueue; 185 mcfg.thread_cnt = this->threadCnt; 186 mcfg.quality = this->quality; 187 mcfg.ptime = this->ptime; 188 mcfg.no_vad = this->noVad; 189 mcfg.ilbc_mode = this->ilbcMode; 190 mcfg.tx_drop_pct = this->txDropPct; 191 mcfg.rx_drop_pct = this->rxDropPct; 192 mcfg.ec_options = this->ecOptions; 193 mcfg.ec_tail_len = this->ecTailLen; 194 mcfg.snd_rec_latency = this->sndRecLatency; 195 mcfg.snd_play_latency = this->sndPlayLatency; 196 mcfg.jb_init = this->jbInit; 197 mcfg.jb_min_pre = this->jbMinPre; 198 mcfg.jb_max_pre = this->jbMaxPre; 199 mcfg.jb_max = this->jbMax; 200 mcfg.snd_auto_close_time = this->sndAutoCloseTime; 201 mcfg.vid_preview_enable_native = this->vidPreviewEnableNative; 202 203 return mcfg; 204 } 205 206 207 /////////////////////////////////////////////////////////////////////////////// 37 208 /* 38 209 * Endpoint instance … … 51 222 void Endpoint::testException() throw(Error) 52 223 { 53 PJSUA2_CHECK_RAISE_ERROR( "Endpoint::testException()",PJ_EINVALIDOP);224 PJSUA2_CHECK_RAISE_ERROR(PJ_EINVALIDOP); 54 225 } 55 226 … … 82 253 return; 83 254 84 NatCheckStunServersCompleteParam prm;255 OnNatCheckStunServersCompleteParam prm; 85 256 86 257 prm.userData = res->token; … … 106 277 return; 107 278 108 ep.epCallback-> OnTimerComplete(ut->prm);279 ep.epCallback->onTimer(ut->prm); 109 280 } 110 281 … … 116 287 return; 117 288 118 NatDetectionCompleteParam prm;289 OnNatDetectionCompleteParam prm; 119 290 120 291 prm.status = res->status; … … 135 306 return; 136 307 137 TransportStateChangedParam prm;308 OnTransportStateParam prm; 138 309 139 310 prm.hnd = (TransportHandle)tp; … … 141 312 prm.lastError = info ? info->status : PJ_SUCCESS; 142 313 143 ep.epCallback->onTransportState Changed(prm);314 ep.epCallback->onTransportState(prm); 144 315 } 145 316 … … 153 324 154 325 status = pjsua_create(); 155 PJSUA2_CHECK_RAISE_ERROR( "Endpoint::libCreate()",status);326 PJSUA2_CHECK_RAISE_ERROR(status); 156 327 } 157 328 … … 186 357 /* Init! */ 187 358 status = pjsua_init(&ua_cfg, &log_cfg, &med_cfg); 188 PJSUA2_CHECK_RAISE_ERROR( "Endpoint::libInit()",status);359 PJSUA2_CHECK_RAISE_ERROR(status); 189 360 } 190 361 … … 194 365 195 366 status = pjsua_start(); 196 PJSUA2_CHECK_RAISE_ERROR( "Endpoint::libStart()",status);367 PJSUA2_CHECK_RAISE_ERROR(status); 197 368 } 198 369 … … 210 381 } 211 382 212 PJSUA2_CHECK_RAISE_ERROR( "Endpoint::libDestroy()",status);383 PJSUA2_CHECK_RAISE_ERROR(status); 213 384 } 214 385 … … 271 442 if (status != PJ_SUCCESS) { 272 443 delete ut; 273 PJSUA2_CHECK_RAISE_ERROR( "Endpoint::utilTimerSchedule()",status);444 PJSUA2_CHECK_RAISE_ERROR(status); 274 445 } 275 446 … … 302 473 303 474 status = pj_ssl_cipher_get_availables(ciphers, &count); 304 PJSUA2_CHECK_RAISE_ERROR( "Endpoint::utilSslGetAvailableCiphers()",status);475 PJSUA2_CHECK_RAISE_ERROR(status); 305 476 306 477 return IntVector(ciphers, ciphers + count); … … 319 490 320 491 status = pjsua_detect_nat_type(); 321 PJSUA2_CHECK_RAISE_ERROR( "Endpoint::natDetectType()",status);492 PJSUA2_CHECK_RAISE_ERROR(status); 322 493 } 323 494 … … 328 499 329 500 status = pjsua_get_nat_type(&type); 330 PJSUA2_CHECK_RAISE_ERROR( "Endpoint::natGetType()",status);501 PJSUA2_CHECK_RAISE_ERROR(status); 331 502 332 503 return type; … … 349 520 status = pjsua_resolve_stun_servers(count, srv, wait, token, 350 521 &Endpoint::stun_resolve_cb); 351 PJSUA2_CHECK_RAISE_ERROR( "Endpoint::natCheckStunServers()",status);522 PJSUA2_CHECK_RAISE_ERROR(status); 352 523 } 353 524 … … 358 529 359 530 status = pjsua_cancel_stun_resolution(token, notify_cb); 360 PJSUA2_CHECK_RAISE_ERROR( "Endpoint::natCancelCheckStunServers()",status);531 PJSUA2_CHECK_RAISE_ERROR(status); 361 532 } 362 533 … … 374 545 tcfg = cfg.toPj(); 375 546 status = pjsua_transport_create(type, &tcfg, &tid); 376 PJSUA2_CHECK_RAISE_ERROR( "Endpoint::transportCreate()",status);547 PJSUA2_CHECK_RAISE_ERROR(status); 377 548 378 549 return tid; … … 386 557 387 558 status = pjsua_enum_transports(tids, &count); 388 PJSUA2_CHECK_RAISE_ERROR( "Endpoint::transportEnum()",status);559 PJSUA2_CHECK_RAISE_ERROR(status); 389 560 390 561 return IntVector(tids, tids+count); … … 397 568 398 569 status = pjsua_transport_get_info(id, &tinfo); 399 PJSUA2_CHECK_RAISE_ERROR( "Endpoint::transportGetInfo()",status);570 PJSUA2_CHECK_RAISE_ERROR(status); 400 571 401 572 return TransportInfo(tinfo); … … 407 578 408 579 status = pjsua_transport_set_enable(id, enabled); 409 PJSUA2_CHECK_RAISE_ERROR( "Endpoint::transportSetEnable()",status);580 PJSUA2_CHECK_RAISE_ERROR(status); 410 581 } 411 582 … … 415 586 416 587 status = pjsua_transport_close(id, PJ_FALSE); 417 PJSUA2_CHECK_RAISE_ERROR( "Endpoint::transportClose()",status);418 } 419 588 PJSUA2_CHECK_RAISE_ERROR(status); 589 } 590
Note: See TracChangeset
for help on using the changeset viewer.