- Timestamp:
- Nov 27, 2013 9:37:32 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/branches/projects/pjsua2/pjsip/src/pjsua2/account.cpp
r4644 r4657 19 19 #include <pjsua2/account.hpp> 20 20 #include <pjsua2/endpoint.hpp> 21 #include <pjsua2/presence.hpp> 21 22 #include <pj/ctype.h> 22 23 #include "util.hpp" … … 446 447 regConfig.firstRetryIntervalSec = prm.reg_first_retry_interval; 447 448 regConfig.delayBeforeRefreshSec = prm.reg_delay_before_refresh; 448 regConfig.dropCallsOnFail = prm.drop_calls_on_reg_fail;449 regConfig.dropCallsOnFail = PJ2BOOL(prm.drop_calls_on_reg_fail); 449 450 regConfig.unregWaitSec = prm.unreg_timeout; 450 451 regConfig.proxyUse = prm.reg_use_proxy; … … 484 485 sipConfig.contactParams = pj2Str(prm.contact_params); 485 486 sipConfig.contactUriParams = pj2Str(prm.contact_uri_params); 486 sipConfig.authInitialEmpty = prm.auth_pref.initial_auth;487 sipConfig.authInitialEmpty = PJ2BOOL(prm.auth_pref.initial_auth); 487 488 sipConfig.authInitialAlgorithm = pj2Str(prm.auth_pref.algorithm); 488 489 sipConfig.transportId = prm.transport_id; … … 504 505 hdr = hdr->next; 505 506 } 506 presConfig.publishEnabled = prm.publish_enabled;507 presConfig.publishQueue = prm.publish_opt.queue_request;507 presConfig.publishEnabled = PJ2BOOL(prm.publish_enabled); 508 presConfig.publishQueue = PJ2BOOL(prm.publish_opt.queue_request); 508 509 presConfig.publishShutdownWaitMsec = prm.unpublish_max_wait_time_msec; 509 510 presConfig.pidfTupleId = pj2Str(prm.pidf_tuple_id); 510 511 511 512 // AccountMwiConfig 512 mwiConfig.enabled = prm.mwi_enabled;513 mwiConfig.enabled = PJ2BOOL(prm.mwi_enabled); 513 514 mwiConfig.expirationSec = prm.mwi_expires; 514 515 … … 517 518 natConfig.mediaStunUse = prm.media_stun_use; 518 519 if (prm.ice_cfg_use == PJSUA_ICE_CONFIG_USE_CUSTOM) { 519 natConfig.iceEnabled = prm.ice_cfg.enable_ice;520 natConfig.iceEnabled = PJ2BOOL(prm.ice_cfg.enable_ice); 520 521 natConfig.iceMaxHostCands = prm.ice_cfg.ice_max_host_cands; 521 natConfig.iceAggressiveNomination = prm.ice_cfg.ice_opt.aggressive;522 natConfig.iceAggressiveNomination = PJ2BOOL(prm.ice_cfg.ice_opt.aggressive); 522 523 natConfig.iceNominatedCheckDelayMsec = prm.ice_cfg.ice_opt.nominated_check_delay; 523 524 natConfig.iceWaitNominationTimeoutMsec = prm.ice_cfg.ice_opt.controlled_agent_want_nom_timeout; 524 natConfig.iceNoRtcp = prm.ice_cfg.ice_no_rtcp;525 natConfig.iceAlwaysUpdate = prm.ice_cfg.ice_always_update;525 natConfig.iceNoRtcp = PJ2BOOL(prm.ice_cfg.ice_no_rtcp); 526 natConfig.iceAlwaysUpdate = PJ2BOOL(prm.ice_cfg.ice_always_update); 526 527 } else { 527 528 pjsua_media_config default_mcfg; … … 530 531 mcfg = &default_mcfg; 531 532 } 532 natConfig.iceEnabled = mcfg->enable_ice;533 natConfig.iceEnabled = PJ2BOOL(mcfg->enable_ice); 533 534 natConfig.iceMaxHostCands= mcfg->ice_max_host_cands; 534 natConfig.iceAggressiveNomination = mcfg->ice_opt.aggressive;535 natConfig.iceAggressiveNomination = PJ2BOOL(mcfg->ice_opt.aggressive); 535 536 natConfig.iceNominatedCheckDelayMsec = mcfg->ice_opt.nominated_check_delay; 536 537 natConfig.iceWaitNominationTimeoutMsec = mcfg->ice_opt.controlled_agent_want_nom_timeout; 537 natConfig.iceNoRtcp = mcfg->ice_no_rtcp;538 natConfig.iceAlwaysUpdate = mcfg->ice_always_update;538 natConfig.iceNoRtcp = PJ2BOOL(mcfg->ice_no_rtcp); 539 natConfig.iceAlwaysUpdate = PJ2BOOL(mcfg->ice_always_update); 539 540 } 540 541 541 542 if (prm.turn_cfg_use == PJSUA_TURN_CONFIG_USE_CUSTOM) { 542 natConfig.turnEnabled = prm.turn_cfg.enable_turn;543 natConfig.turnEnabled = PJ2BOOL(prm.turn_cfg.enable_turn); 543 544 natConfig.turnServer = pj2Str(prm.turn_cfg.turn_server); 544 545 natConfig.turnConnType = prm.turn_cfg.turn_conn_type; … … 552 553 mcfg = &default_mcfg; 553 554 } 554 natConfig.turnEnabled = mcfg->enable_turn;555 natConfig.turnEnabled = PJ2BOOL(mcfg->enable_turn); 555 556 natConfig.turnServer = pj2Str(mcfg->turn_server); 556 557 natConfig.turnConnType = mcfg->turn_conn_type; … … 571 572 // AccountMediaConfig 572 573 mediaConfig.transportConfig.fromPj(prm.rtp_cfg); 573 mediaConfig.lockCodecEnabled= prm.lock_codec;574 mediaConfig.lockCodecEnabled= PJ2BOOL(prm.lock_codec); 574 575 #if defined(PJMEDIA_STREAM_ENABLE_KA) && (PJMEDIA_STREAM_ENABLE_KA != 0) 575 mediaConfig.streamKaEnabled = prm.use_stream_ka;576 mediaConfig.streamKaEnabled = PJ2BOOL(prm.use_stream_ka); 576 577 #else 577 578 mediaConfig.streamKaEnabled = false; … … 582 583 583 584 // AccountVideoConfig 584 videoConfig.autoShowIncoming = prm.vid_in_auto_show;585 videoConfig.autoTransmitOutgoing = prm.vid_out_auto_transmit;585 videoConfig.autoShowIncoming = PJ2BOOL(prm.vid_in_auto_show); 586 videoConfig.autoTransmitOutgoing = PJ2BOOL(prm.vid_out_auto_transmit); 586 587 videoConfig.windowFlags = prm.vid_wnd_flags; 587 588 videoConfig.defaultCaptureDevice = prm.vid_cap_dev; … … 623 624 } 624 625 625 626 ///////////////////////////////////////////////////////////////////////////////627 628 AccountPresenceStatus::AccountPresenceStatus()629 : isOnline(false), activity(PJRPID_ACTIVITY_UNKNOWN)630 {631 }632 626 633 627 /////////////////////////////////////////////////////////////////////////////// … … 662 656 */ 663 657 if (isValid() && pjsua_get_state() < PJSUA_STATE_CLOSING) { 658 // Cleanup buddies in the buddy list 659 while(buddyList.size() > 0) { 660 Buddy *b = buddyList[0]; 661 delete b; 662 } 663 664 664 PJSUA2_CHECK_EXPR( pjsua_acc_set_user_data(id, NULL) ); 665 665 PJSUA2_CHECK_EXPR( pjsua_acc_del(id) ); … … 724 724 725 725 void 726 Account::setOnlineStatus(const AccountPresenceStatus &pres_st) throw(Error)726 Account::setOnlineStatus(const PresenceStatus &pres_st) throw(Error) 727 727 { 728 728 pjrpid_element pj_rpid; … … 734 734 pj_rpid.note = str2Pj(pres_st.note); 735 735 736 PJSUA2_CHECK_EXPR( pjsua_acc_set_online_status2(id, pres_st.isOnline, 737 &pj_rpid) ); 736 PJSUA2_CHECK_EXPR( pjsua_acc_set_online_status2( 737 id, pres_st.status == PJSUA_BUDDY_STATUS_ONLINE, 738 &pj_rpid) ); 738 739 } 739 740 … … 743 744 } 744 745 746 void Account::presNotify(const PresNotifyParam &prm) throw(Error) 747 { 748 pj_str_t pj_state_str = str2Pj(prm.stateStr); 749 pj_str_t pj_reason = str2Pj(prm.reason); 750 pjsua_msg_data msg_data; 751 prm.txOption.toPj(msg_data); 752 753 PJSUA2_CHECK_EXPR( pjsua_pres_notify(id, (pjsua_srv_pres*)prm.srvPres, 754 prm.state, &pj_state_str, 755 &pj_reason, prm.withBody, 756 &msg_data) ); 757 } 758 759 const BuddyVector& Account::enumBuddies() const throw(Error) 760 { 761 return buddyList; 762 } 763 764 Buddy* Account::findBuddy(string uri, FindBuddyMatch *buddy_match) const 765 throw(Error) 766 { 767 if (!buddy_match) { 768 static FindBuddyMatch def_bm; 769 buddy_match = &def_bm; 770 } 771 772 for (unsigned i = 0; i < buddyList.size(); i++) { 773 if (buddy_match->match(uri, *buddyList[i])) 774 return buddyList[i]; 775 } 776 PJSUA2_RAISE_ERROR(PJ_ENOTFOUND); 777 } 778 779 void Account::addBuddy(Buddy *buddy) 780 { 781 pj_assert(buddy); 782 783 buddyList.push_back(buddy); 784 } 785 786 void Account::removeBuddy(Buddy *buddy) 787 { 788 pj_assert(buddy); 789 790 BuddyVector::iterator it; 791 for (it = buddyList.begin(); it != buddyList.end(); it++) { 792 if (*it == buddy) { 793 buddyList.erase(it); 794 return; 795 } 796 } 797 798 pj_assert(!"Bug! Buddy to be removed is not in the buddy list!"); 799 }
Note: See TracChangeset
for help on using the changeset viewer.