diff --git a/sflphone-common/src/audio/mainbuffer.cpp b/sflphone-common/src/audio/mainbuffer.cpp index 46bec0f75183fa91be8d14f30e303e2670408f35..35c2470dec2ee9565d7a3ff44f981c063a62204c 100644 --- a/sflphone-common/src/audio/mainbuffer.cpp +++ b/sflphone-common/src/audio/mainbuffer.cpp @@ -79,7 +79,7 @@ bool MainBuffer::removeCallIDSet (CallID set_id) if (callid_set != NULL) { if (_callIDMap.erase (set_id) != 0) { - // _debug (" callid set %s erased!\n", set_id.c_str()); + // _debug (" callid set %s erased!\n", set_id.c_str()); return true; } else { _debug ("removeCallIDSet error while removing callid set %s!\n", set_id.c_str()); @@ -107,7 +107,7 @@ void MainBuffer::removeCallIDfromSet (CallID set_id, CallID call_id) if (callid_set != NULL) { if (callid_set->erase (call_id) != 0) { - // _debug (" callid %s erased from set %s!\n", call_id.c_str(), set_id.c_str()); + // _debug (" callid %s erased from set %s!\n", call_id.c_str(), set_id.c_str()); } else { _debug ("removeCallIDfromSet error while removing callid %s from set %s!\n", call_id.c_str(), set_id.c_str()); } @@ -147,7 +147,7 @@ bool MainBuffer::removeRingBuffer (CallID call_id) if (ring_buffer != NULL) { if (_ringBufferMap.erase (call_id) != 0) { - // _debug ("removeRingBuffer ringbuffer %s removed!\n", call_id.c_str()); + // _debug ("removeRingBuffer ringbuffer %s removed!\n", call_id.c_str()); return true; } else { _debug ("removeRingBuffer error while deleting ringbuffer %s!\n", call_id.c_str()); @@ -545,27 +545,28 @@ void MainBuffer::stateInfo() CallIDMap::iterator iter_call = _callIDMap.begin(); // print each call and bound call ids - while(iter_call != _callIDMap.end()) { - std::string dbg_str(" Call: "); - dbg_str.append(std::string(iter_call->first.c_str())); - dbg_str.append(std::string(" is bound to: ")); - - CallIDSet* call_id_set = (CallIDSet*)iter_call->second; + while (iter_call != _callIDMap.end()) { - CallIDSet::iterator iter_call_id = call_id_set->begin(); + std::string dbg_str (" Call: "); + dbg_str.append (std::string (iter_call->first.c_str())); + dbg_str.append (std::string (" is bound to: ")); - while (iter_call_id != call_id_set->end()) { + CallIDSet* call_id_set = (CallIDSet*) iter_call->second; - dbg_str.append (std::string (*iter_call_id)); - dbg_str.append (std::string (", ")); + CallIDSet::iterator iter_call_id = call_id_set->begin(); - iter_call_id++; - } + while (iter_call_id != call_id_set->end()) { - _debug ("%s\n", dbg_str.c_str()); + dbg_str.append (std::string (*iter_call_id)); + dbg_str.append (std::string (", ")); - iter_call++; + iter_call_id++; + } + + _debug ("%s\n", dbg_str.c_str()); + + iter_call++; } // Print ringbuffers ids and readpointers @@ -573,36 +574,36 @@ void MainBuffer::stateInfo() while (iter_buffer != _ringBufferMap.end()) { - RingBuffer* rbuffer = (RingBuffer*)iter_buffer->second; - ReadPointer* rpointer = NULL; + RingBuffer* rbuffer = (RingBuffer*) iter_buffer->second; + ReadPointer* rpointer = NULL; std::string dbg_str (" Buffer: "); dbg_str.append (std::string (iter_buffer->first.c_str())); dbg_str.append (std::string (" as read pointer: ")); - if(rbuffer) - rpointer = rbuffer->getReadPointerList(); + if (rbuffer) + rpointer = rbuffer->getReadPointerList(); + + if (rpointer) { - if(rpointer) { + ReadPointer::iterator iter_pointer = rpointer->begin(); - ReadPointer::iterator iter_pointer = rpointer->begin(); - - while(iter_pointer != rpointer->end()) { + while (iter_pointer != rpointer->end()) { - dbg_str.append (string (iter_pointer->first.c_str())); + dbg_str.append (string (iter_pointer->first.c_str())); dbg_str.append (string (", ")); - iter_pointer++; - } - } + iter_pointer++; + } + } - _debug ("%s\n", dbg_str.c_str()); + _debug ("%s\n", dbg_str.c_str()); iter_buffer++; } - + } diff --git a/sflphone-common/src/conference.cpp b/sflphone-common/src/conference.cpp index 4149e29caf1b0c7a4e16e1e7e71f3ae89edf4072..70e70d831e6a3c175735faeb44f7e8f3c073ab46 100644 --- a/sflphone-common/src/conference.cpp +++ b/sflphone-common/src/conference.cpp @@ -100,7 +100,7 @@ void Conference::bindParticipant (CallID participant_id) if (participant_id != (*iter)) { - // _debug ("---- Conference:: bind callid %s with %s in conference add\n", participant_id.c_str(), (*iter).c_str()); + // _debug ("---- Conference:: bind callid %s with %s in conference add\n", participant_id.c_str(), (*iter).c_str()); Manager::instance().getAudioDriver()->getMainBuffer()->bindCallID (participant_id, *iter); } diff --git a/sflphone-common/src/iax/iaxvoiplink.cpp b/sflphone-common/src/iax/iaxvoiplink.cpp index b6377ea7f4cec4aee220e81afcc3ce8528742f69..d6c3b4f17dc894cc072a730ae44e5f2c25d67bf8 100644 --- a/sflphone-common/src/iax/iaxvoiplink.cpp +++ b/sflphone-common/src/iax/iaxvoiplink.cpp @@ -831,7 +831,7 @@ IAXVoIPLink::iaxHandleCallEvent (iax_event* event, IAXCall* call) Manager::instance().peerAnsweredCall (id); // start audio here? - audiolayer->startStream(); + audiolayer->startStream(); audiolayer->flushMain(); } else { // deja connecté ? diff --git a/sflphone-common/src/managerimpl.cpp b/sflphone-common/src/managerimpl.cpp index c97310af27cedc02fae385a230022acf4db545c5..e8b7edaaa8e7e82a8c9f044ed25515578e4c7edb 100644 --- a/sflphone-common/src/managerimpl.cpp +++ b/sflphone-common/src/managerimpl.cpp @@ -1246,8 +1246,8 @@ ManagerImpl::joinParticipant (const CallID& call_id1, const CallID& call_id2) // switchCall(conf->getConfID()); - if(_audiodriver) - _audiodriver->getMainBuffer()->stateInfo(); + if (_audiodriver) + _audiodriver->getMainBuffer()->stateInfo(); } @@ -1349,7 +1349,7 @@ ManagerImpl::removeParticipant (const CallID& call_id) } - if(_audiodriver) + if (_audiodriver) _audiodriver->getMainBuffer()->stateInfo(); } @@ -1498,7 +1498,7 @@ ManagerImpl::addStream (const CallID& call_id) } - if(_audiodriver) + if (_audiodriver) _audiodriver->getMainBuffer()->stateInfo(); } @@ -1513,7 +1513,7 @@ ManagerImpl::removeStream (const CallID& call_id) removeParticipant (call_id); } - if(_audiodriver) + if (_audiodriver) _audiodriver->getMainBuffer()->stateInfo(); } @@ -1546,10 +1546,11 @@ ManagerImpl::initRegisterAccounts() if (iter->second) { iter->second->loadConfig(); - // TODO: take off this protection by storing localIPAddress using interface name - setConfig(iter->second->getAccountID(), LOCAL_ADDRESS, "0.0.0.0"); + // TODO: take off this protection by storing localIPAddress using interface name + setConfig (iter->second->getAccountID(), LOCAL_ADDRESS, "0.0.0.0"); /* If the account is set as enabled, try to register */ + if (iter->second->isEnabled()) { status = iter->second->registerVoIPLink(); diff --git a/sflphone-common/src/sip/sipvoiplink.cpp b/sflphone-common/src/sip/sipvoiplink.cpp index a712ae4636fecf6640ea14b5fa19f1b432a72923..3cf1daf653887425708e53d5b8b97c56a02f1830 100644 --- a/sflphone-common/src/sip/sipvoiplink.cpp +++ b/sflphone-common/src/sip/sipvoiplink.cpp @@ -682,15 +682,18 @@ SIPVoIPLink::newOutgoingCall (const CallID& id, const std::string& toUrl) call->setPeerNumber (toUri); - localAddr = account->getLocalAddress (); - if (localAddr == "0.0.0.0") - loadSIPLocalIP (&localAddr); + localAddr = account->getLocalAddress (); + + if (localAddr == "0.0.0.0") + loadSIPLocalIP (&localAddr); + setCallAudioLocal (call, localAddr); // May use the published address as well - account->isStunEnabled () ? addrSdp = account->getPublishedAddress () : addrSdp = account->getLocalAddress (); - if (addrSdp == "0.0.0.0") - loadSIPLocalIP (&addrSdp); + account->isStunEnabled () ? addrSdp = account->getPublishedAddress () : addrSdp = account->getLocalAddress (); + + if (addrSdp == "0.0.0.0") + loadSIPLocalIP (&addrSdp); try { _debug ("Creating new rtp session in newOutgoingCall\n"); @@ -946,7 +949,7 @@ int SIPVoIPLink::inv_session_reinvite (SIPCall *call, std::string direction) _debug ("! SIP Failure: unable to find local_sdp\n"); return !PJ_SUCCESS; } - + // Reinvite only if connected // Build the local SDP offer status = call->getLocalSDP()->create_initial_offer(); @@ -1460,10 +1463,11 @@ bool SIPVoIPLink::new_ip_to_ip_call (const CallID& id, const std::string& to) return !PJ_SUCCESS; } - // Set the local address - localAddress = account->getLocalAddress (); + // Set the local address + localAddress = account->getLocalAddress (); + // Set SDP parameters - Set to local or published address - account->isStunEnabled () ? addrSdp = account->getPublishedAddress () : addrSdp = account->getLocalAddress (); + account->isStunEnabled () ? addrSdp = account->getPublishedAddress () : addrSdp = account->getLocalAddress (); _debug ("new_ip_to_ip_call localAddress: %s\n", localAddress.c_str()); @@ -1472,9 +1476,9 @@ bool SIPVoIPLink::new_ip_to_ip_call (const CallID& id, const std::string& to) loadSIPLocalIP (&localAddress); } - if (addrSdp == "0.0.0.0") { - addrSdp = localAddress; - } + if (addrSdp == "0.0.0.0") { + addrSdp = localAddress; + } setCallAudioLocal (call, localAddress); @@ -1649,11 +1653,11 @@ pj_status_t SIPVoIPLink::enable_dns_srv_resolver (pjsip_endpoint *endpt, pj_dns_ } // Build the nameservers list needed by pjsip - if ((scount = dns_servers.size ()) <= 0) { - _debug("No server detected while fetching DNS information, stop dns resolution\n"); - return 0; + if ( (scount = dns_servers.size ()) <= 0) { + _debug ("No server detected while fetching DNS information, stop dns resolution\n"); + return 0; } - + pj_str_t nameservers[scount]; for (i = 0; i<scount; i++) { @@ -1970,8 +1974,8 @@ int SIPVoIPLink::createUDPServer (AccountID id) } else { // We are trying to initialize a UDP transport available for all local accounts and direct IP calls if (account->getLocalAddress () != "0.0.0.0") { - listeningAddress = account->getLocalAddress (); - } + listeningAddress = account->getLocalAddress (); + } listeningPort = account->getLocalPort (); } @@ -2033,8 +2037,8 @@ int SIPVoIPLink::createUDPServer (AccountID id) if (account == NULL) _localUDPTransport = transport; else { - account->setAccountTransport (transport); - } + account->setAccountTransport (transport); + } } _debug ("Transport initialized successfully on %s:%i\n", listeningAddress.c_str (), listeningPort); @@ -2856,35 +2860,34 @@ void call_on_forked (pjsip_inv_session *inv, pjsip_event *e) void call_on_tsx_changed (pjsip_inv_session *inv, pjsip_transaction *tsx, pjsip_event *e) { - _debug("call_on_tsx_changed to state %s\n", transactionStateMap[tsx->state]); + _debug ("call_on_tsx_changed to state %s\n", transactionStateMap[tsx->state]); if (tsx->role==PJSIP_ROLE_UAS && tsx->state==PJSIP_TSX_STATE_TRYING && - pjsip_method_cmp (&tsx->method, &pjsip_refer_method) ==0) { + pjsip_method_cmp (&tsx->method, &pjsip_refer_method) ==0) { /** Handle the refer method **/ onCallTransfered (inv, e->body.tsx_state.src.rdata); - } - else if (tsx->role==PJSIP_ROLE_UAS && tsx->state==PJSIP_TSX_STATE_TRYING) { + } else if (tsx->role==PJSIP_ROLE_UAS && tsx->state==PJSIP_TSX_STATE_TRYING) { - if (e && e->body.rx_msg.rdata) { + if (e && e->body.rx_msg.rdata) { - pjsip_tx_data* t_data; - pjsip_rx_data* r_data = e->body.rx_msg.rdata; + pjsip_tx_data* t_data; + pjsip_rx_data* r_data = e->body.rx_msg.rdata; - if(r_data->msg_info.msg->line.req.method.id == PJSIP_OTHER_METHOD) { + if (r_data->msg_info.msg->line.req.method.id == PJSIP_OTHER_METHOD) { - std::string method_name = "INFO"; - std::string request = r_data->msg_info.msg->line.req.method.name.ptr; + std::string method_name = "INFO"; + std::string request = r_data->msg_info.msg->line.req.method.name.ptr; - if (request.find (method_name) != (size_t)-1) { + if (request.find (method_name) != (size_t)-1) { - _debug("%s\n", pjsip_rx_data_get_info(r_data)); + _debug ("%s\n", pjsip_rx_data_get_info (r_data)); - pjsip_dlg_create_response (inv->dlg, r_data, PJSIP_SC_OK, NULL, &t_data); - - pjsip_dlg_send_response(inv->dlg, tsx, t_data); - } - } - } + pjsip_dlg_create_response (inv->dlg, r_data, PJSIP_SC_OK, NULL, &t_data); + + pjsip_dlg_send_response (inv->dlg, tsx, t_data); + } + } + } } } @@ -3121,7 +3124,7 @@ mod_on_rx_request (pjsip_rx_data *rdata) /************************************************************************************************/ - _debug("create a new call\n"); + _debug ("create a new call\n"); // Generate a new call ID for the incoming call! id = Manager::instance().getNewCallID(); @@ -3137,6 +3140,7 @@ mod_on_rx_request (pjsip_rx_data *rdata) std::string addrToUse, addrSdp ="0.0.0.0"; + pjsip_tpselector *tp; account = dynamic_cast<SIPAccount *> (Manager::instance().getAccount (account_id)); @@ -3144,12 +3148,12 @@ mod_on_rx_request (pjsip_rx_data *rdata) if (account != NULL) { // May use the published address as well - addrToUse = account->getLocalAddress (); - account->isStunEnabled () ? addrSdp = account->getPublishedAddress () : addrSdp = account->getLocalAddress (); - // Set the appropriate transport to have the right VIA header - link->init_transport_selector (account->getAccountTransport (), &tp); + addrToUse = account->getLocalAddress (); + account->isStunEnabled () ? addrSdp = account->getPublishedAddress () : addrSdp = account->getLocalAddress (); + // Set the appropriate transport to have the right VIA header + link->init_transport_selector (account->getAccountTransport (), &tp); } - + if (addrToUse == "0.0.0.0") { link->loadSIPLocalIP (&addrToUse); } @@ -3169,7 +3173,8 @@ mod_on_rx_request (pjsip_rx_data *rdata) // Notify UI there is an incoming call - _debug("Add call to account link\n"); + _debug ("Add call to account link\n"); + if (Manager::instance().incomingCall (call, account_id)) { // Add this call to the callAccountMap in ManagerImpl Manager::instance().getAccountLink (account_id)->addCall (call); @@ -3210,8 +3215,9 @@ mod_on_rx_request (pjsip_rx_data *rdata) // Specify media capability during invite session creation status = pjsip_inv_create_uas (dialog, rdata, call->getLocalSDP()->get_local_sdp_session(), 0, &inv); - // Explicitly set the transport - status = pjsip_dlg_set_transport (dialog, tp); + + // Explicitly set the transport + status = pjsip_dlg_set_transport (dialog, tp); PJ_ASSERT_RETURN (status == PJ_SUCCESS, 1); @@ -3768,7 +3774,7 @@ bool setCallAudioLocal (SIPCall* call, std::string localIP) if (account->isStunEnabled ()) { // If use Stun server callLocalExternAudioPort = account->getStunPort (); - //localIP = account->getPublishedAddress (); + //localIP = account->getPublishedAddress (); } _debug (" Setting local ip address: %s\n", localIP.c_str());