Commit ea00c340 authored by Alexandre Savard's avatar Alexandre Savard
Browse files

[#2926] Cleanup and add usefull debug messages for issue #2618

parent a36aa008
......@@ -196,7 +196,7 @@ bool ManagerImpl::outgoingCall (const std::string& account_id,
Call::CallConfiguration callConfig;
SIPVoIPLink *siplink;
_debug ("Manager: New outgoing call %s", call_id.c_str());
_debug ("Manager: New outgoing call %s to %s", call_id.c_str(), to.c_str());
CallID current_call_id = getCurrentCallId();
......@@ -214,23 +214,17 @@ bool ManagerImpl::outgoingCall (const std::string& account_id,
// in any cases we have to detach from current communication
if (hasCurrentCall()) {
_debug (" outgoingCall: Has current call (%s) put it onhold", current_call_id.c_str());
_debug ("Manager: Has current call (%s) put it onhold", current_call_id.c_str());
// if this is not a conferenceand this and is not a conference participant
if (!isConference(current_call_id) && !participToConference(
current_call_id)) {
_debug (" outgoingCall: Put the current call (%s) on hold", current_call_id.c_str());
if (!isConference(current_call_id) && !participToConference(current_call_id)) {
onHoldCall(current_call_id);
} else if (isConference(current_call_id) && !participToConference(
call_id)) {
_debug (" outgoingCall: detach main participant from conference");
} else if (isConference(current_call_id) && !participToConference(call_id)) {
detachParticipant(default_id, current_call_id);
}
}
if (callConfig == Call::IPtoIP) {
_debug ("Manager: Start IP to IP call");
_debug ("Manager: Start IP2IP call");
/* We need to retrieve the sip voiplink instance */
siplink = SIPVoIPLink::instance("");
......@@ -244,6 +238,7 @@ bool ManagerImpl::outgoingCall (const std::string& account_id,
return false;
}
_debug("Manager: Selecting account %s", account_id.c_str());
if (!accountExists(account_id)) {
_error ("Manager: Error: Account doesn't exist in new outgoing call");
return false;
......@@ -254,16 +249,15 @@ bool ManagerImpl::outgoingCall (const std::string& account_id,
return false;
}
_debug ("Manager: Action: Adding Outgoing Call %s on account %s", call_id.data(), account_id.data());
_debug ("Manager: Adding Outgoing Call %s on account %s", call_id.data(), account_id.data());
associateCallToAccount(call_id, account_id);
if (getAccountLink(account_id)->newOutgoingCall(call_id, to_cleaned)) {
switchCall(call_id);
return true;
switchCall(call_id);
return true;
} else {
callFailure(call_id);
_debug ("Manager: Error: An error occur, the call was not created");
callFailure(call_id);
_debug ("Manager: Error: An error occur, the call was not created");
}
return false;
......@@ -272,7 +266,7 @@ bool ManagerImpl::outgoingCall (const std::string& account_id,
//THREAD=Main : for outgoing Call
bool ManagerImpl::answerCall (const CallID& call_id) {
_debug ("ManagerImpl::answerCall(%s)", call_id.c_str());
_debug ("ManagerImpl: Answer call %s", call_id.c_str());
stopTone();
......@@ -494,7 +488,7 @@ bool ManagerImpl::onHoldCall (const CallID& call_id) {
AccountID account_id;
bool returnValue;
_debug ("Manager: Put call %s on hold", call_id.c_str());
_debug ("Manager: Put call %s on hold", call_id.c_str());
stopTone();
......@@ -1127,7 +1121,7 @@ void ManagerImpl::joinParticipant (const CallID& call_id1, const CallID& call_id
void ManagerImpl::detachParticipant (const CallID& call_id,
const CallID& current_id) {
_debug ("ManagerImpl::detachParticipant(%s)", call_id.c_str());
_debug ("Manager: Detach participant %s from conference", call_id.c_str());
CallID current_call_id = current_id;
......@@ -1147,8 +1141,7 @@ void ManagerImpl::detachParticipant (const CallID& call_id,
if (conf != NULL) {
_debug (" detachParticipant: detaching participant %s", call_id.c_str());
_debug ("Manager: Detaching participant %s", call_id.c_str());
std::map<std::string, std::string> call_details = getCallDetails(
call_id);
std::map<std::string, std::string>::iterator iter_details;
......@@ -1167,11 +1160,11 @@ void ManagerImpl::detachParticipant (const CallID& call_id,
}
} else {
_debug (" detachParticipant: call is not conferencing, cannot detach");
_debug ("Manager: Call is not conferencing, cannot detach");
}
} else {
_debug (" detachParticipant: unbind main participant from all");
_debug ("Manager: Unbind main participant from all");
_audiodriver->getMainBuffer()->unBindAll(default_id);
if (isConference(current_call_id)) {
......@@ -4152,7 +4145,7 @@ void ManagerImpl::check_call_configuration (const CallID& id,
Call::CallConfiguration config;
if (to.find(SIP_SCHEME) == 0 || to.find(SIPS_SCHEME) == 0) {
_debug ("Sending Sip Call ");
_debug ("Manager: Sip scheme detected (sip: or sips:), sending IP2IP Call");
config = Call::IPtoIP;
} else {
config = Call::Classic;
......
......@@ -21,6 +21,7 @@
#ifndef _NUMBER_CLEANER_H
#define _NUMBER_CLEANER_H
#include "logger.h"
#include <string>
class NumberCleaner {
......@@ -31,7 +32,8 @@ class NumberCleaner {
std::string clean (std::string to_clean);
inline void set_phone_number_prefix (std::string prefix) { _prefix = prefix; }
inline void set_phone_number_prefix (std::string prefix) {
_debug("Number: Set phone number prefix %s", _prefix.c_str()); _prefix = prefix; }
inline std::string get_phone_number_prefix (void) { return _prefix; }
......
......@@ -749,6 +749,8 @@ SIPVoIPLink::newOutgoingCall (const CallID& id, const std::string& toUrl)
pj_status_t status;
std::string localAddr, addrSdp;
_debug("UserAgent: New outgoing call %s to %s", id.c_str(), toUrl.c_str());
SIPCall* call = new SIPCall (id, Call::Outgoing, _pool);
if (call) {
......@@ -769,6 +771,8 @@ SIPVoIPLink::newOutgoingCall (const CallID& id, const std::string& toUrl)
localAddr = getInterfaceAddrFromName(account->getLocalInterface ());
_debug("UserAgent: Local address for call: %s", localAddr.c_str());
if (localAddr == "0.0.0.0")
loadSIPLocalIP (&localAddr);
......@@ -1378,6 +1382,8 @@ SIPVoIPLink::SIPStartCall (SIPCall* call, const std::string& subject UNUSED)
AccountID id;
_debug("UserAgent: Start sip call");
if (call == NULL)
return false;
......@@ -1389,7 +1395,7 @@ SIPVoIPLink::SIPStartCall (SIPCall* call, const std::string& subject UNUSED)
account = dynamic_cast<SIPAccount *> (Manager::instance().getAccount (id));
if (account == NULL) {
_debug ("Account is null in SIPStartCall");
_debug ("UserAgent: Error: Account is null in SIPStartCall");
return false;
}
......@@ -1411,7 +1417,7 @@ SIPVoIPLink::SIPStartCall (SIPCall* call, const std::string& subject UNUSED)
contactUri = account->getContactHeader (address, portStr);
_debug ("SIPStartCall: fromUri: %s toUri: %s contactUri: %s",
_debug ("UserAgent: FROM uri: %s, TO uri: %s, CONTACT uri: %s",
fromUri.c_str(),
toUri.c_str(),
contactUri.c_str());
......@@ -1433,7 +1439,7 @@ SIPVoIPLink::SIPStartCall (SIPCall* call, const std::string& subject UNUSED)
&dialog);
if (status != PJ_SUCCESS) {
_debug ("UAC creation failed");
_error ("UserAgent: Error: UAC creation failed");
return false;
}
......@@ -1469,13 +1475,13 @@ SIPVoIPLink::SIPStartCall (SIPCall* call, const std::string& subject UNUSED)
status = pjsip_inv_send_msg (inv, tdata);
if (status != PJ_SUCCESS) {
_debug (" SIPStartCall: failed to send invite");
_error ("UserAgent: Error: failed to send invite");
return false;
}
if(account->getAccountTransport()) {
_debug("Sent invite request using transport: %s %s (refcnt=%d)",
_debug("UserAgent: Sent invite request using transport: %s %s (refcnt=%d)",
account->getAccountTransport()->obj_name,
account->getAccountTransport()->info,
(int)pj_atomic_get(account->getAccountTransport()->ref_cnt));
......@@ -1586,6 +1592,8 @@ bool SIPVoIPLink::new_ip_to_ip_call (const CallID& id, const std::string& to)
pjsip_tx_data *tdata;
std::string localAddress, addrSdp;
_debug("UserAgent: New IP2IP call %s to %s", id.c_str(), to.c_str());
/* Create the call */
call = new SIPCall (id, Call::Outgoing, _pool);
......@@ -1594,13 +1602,12 @@ bool SIPVoIPLink::new_ip_to_ip_call (const CallID& id, const std::string& to)
call->setCallConfiguration (Call::IPtoIP);
call->initRecFileName();
// AccountID accountId = Manager::instance().getAccountFromCall (id);
SIPAccount * account = NULL;
account = dynamic_cast<SIPAccount *> (Manager::instance().getAccount (IP2IP_PROFILE));
if (account == NULL) {
_debug ("UserAgent: Account %s is null. Returning", IP2IP_PROFILE);
return !PJ_SUCCESS;
_error ("UserAgent: Error: Account %s is null. Returning", IP2IP_PROFILE);
return !PJ_SUCCESS;
}
// Set the local address
......@@ -1608,25 +1615,27 @@ bool SIPVoIPLink::new_ip_to_ip_call (const CallID& id, const std::string& to)
// Set SDP parameters - Set to local
addrSdp = localAddress;
_debug ("UserAgent: Local Address for IP2IP call: %s", localAddress.c_str());
// If local address bound to ANY, reslove it using PJSIP
if (localAddress == "0.0.0.0") {
loadSIPLocalIP (&localAddress);
}
_debug ("UserAgent: Local Address for IP2IP call: %s", localAddress.c_str());
// Local address to appear in SDP
if (addrSdp == "0.0.0.0") {
addrSdp = localAddress;
}
_debug ("UserAgent: Media Address for IP2IP call: %s", localAddress.c_str());
// Set local address for RTP media
setCallAudioLocal (call, localAddress);
std::string toUri = account->getToUri (to);
call->setPeerNumber (toUri);
_debug ("UserAgent: TO uri: %s", toUri.c_str());
_debug ("UserAgent: TO uri for IP2IP call: %s", toUri.c_str());
// Building the local SDP offer
call->getLocalSDP()->set_ip_address (addrSdp);
......@@ -1645,13 +1654,13 @@ bool SIPVoIPLink::new_ip_to_ip_call (const CallID& id, const std::string& to)
// Init TLS transport if enabled
if(account->isTlsEnabled()) {
_debug("UserAgent: TLS enabled for IP to IP calls");
_debug("UserAgent: TLS enabled for IP2IP calls");
int at = toUri.find("@");
int trns = toUri.find(";transport");
std::string remoteAddr = toUri.substr(at+1, trns-at-1);
if(toUri.find("sips:") != 1) {
_debug("UserAgent: Error \"sips\" scheme required TLS call");
_debug("UserAgent: Error \"sips\" scheme required for TLS call");
return false;
}
......@@ -1665,91 +1674,90 @@ bool SIPVoIPLink::new_ip_to_ip_call (const CallID& id, const std::string& to)
account->setAccountTransport (_localUDPTransport);
}
_debug ("UserAgent: new IP2IP local port %i", account->getLocalPort());
_debug ("UserAgent: Local port %i for IP2IP call", account->getLocalPort());
_debug ("UserAgent: new IP2IP local address in sdp %s", localAddress.c_str());
_debug ("UserAgent: Local address in sdp %s for IP2IP call", localAddress.c_str());
// Create URI
std::string fromUri = account->getFromUri();
std::string address = findLocalAddressFromUri (toUri, account->getAccountTransport());
int port = findLocalPortFromUri (toUri, account->getAccountTransport());
std::stringstream ss;
std::string portStr;
ss << port;
ss >> portStr;
std::string contactUri = account->getContactHeader (address, portStr);
_debug ("UserAgent: FROM uri: %s TO uri: %s CONTACT uri: %s",
fromUri.c_str(), toUri.c_str(), contactUri.c_str());
pj_str_t pjFrom;
pj_cstr (&pjFrom, fromUri.c_str());
pj_str_t pjTo;
pj_cstr (&pjTo, toUri.c_str());
pj_str_t pjContact;
pj_cstr (&pjContact, contactUri.c_str());
std::string portStr;
ss << port;
ss >> portStr;
std::string contactUri = account->getContactHeader (address, portStr);
// Create the dialog (UAC)
// (Parameters are "strduped" inside this function)
status = pjsip_dlg_create_uac (pjsip_ua_instance(), &pjFrom, &pjContact, &pjTo, NULL, &dialog);
PJ_ASSERT_RETURN (status == PJ_SUCCESS, false);
_debug ("UserAgent: FROM uri: %s, TO uri: %s, CONTACT uri: %s",
fromUri.c_str(), toUri.c_str(), contactUri.c_str());
// Create the invite session for this call
status = pjsip_inv_create_uac (dialog, call->getLocalSDP()->get_local_sdp_session(), 0, &inv);
PJ_ASSERT_RETURN (status == PJ_SUCCESS, false);
pj_str_t pjFrom;
pj_cstr (&pjFrom, fromUri.c_str());
// Set the appropriate transport
pjsip_tpselector *tp;
pj_str_t pjTo;
pj_cstr (&pjTo, toUri.c_str());
init_transport_selector (account->getAccountTransport(), &tp);
pj_str_t pjContact;
pj_cstr (&pjContact, contactUri.c_str());
if(!account->getAccountTransport()) {
_error("UserAgent: Error: Transport is NULL in ip to ip call");
}
// Create the dialog (UAC)
// (Parameters are "strduped" inside this function)
status = pjsip_dlg_create_uac (pjsip_ua_instance(), &pjFrom, &pjContact, &pjTo, NULL, &dialog);
PJ_ASSERT_RETURN (status == PJ_SUCCESS, false);
// Create the invite session for this call
status = pjsip_inv_create_uac (dialog, call->getLocalSDP()->get_local_sdp_session(), 0, &inv);
PJ_ASSERT_RETURN (status == PJ_SUCCESS, false);
// Set the appropriate transport
pjsip_tpselector *tp;
// set_transport methods increment transport's ref_count
status = pjsip_dlg_set_transport (dialog, tp);
init_transport_selector (account->getAccountTransport(), &tp);
// decrement transport's ref count
// pjsip_transport_dec_ref(account->getAccountTransport());
if(!account->getAccountTransport()) {
_error("UserAgent: Error: Transport is NULL in IP2IP call");
}
if (status != PJ_SUCCESS) {
_error ("UserAgent: Error: Failed to set the transport for an IP2IP call");
return status;
}
// set_transport methods increment transport's ref_count
status = pjsip_dlg_set_transport (dialog, tp);
// Associate current call in the invite session
inv->mod_data[getModId() ] = call;
// decrement transport's ref count
// pjsip_transport_dec_ref(account->getAccountTransport());
status = pjsip_inv_invite (inv, &tdata);
if (status != PJ_SUCCESS) {
_error ("UserAgent: Error: Failed to set the transport for an IP2IP call");
return status;
}
PJ_ASSERT_RETURN (status == PJ_SUCCESS, false);
// Associate current call in the invite session
inv->mod_data[getModId() ] = call;
// Associate current invite session in the call
call->setInvSession (inv);
status = pjsip_inv_invite (inv, &tdata);
PJ_ASSERT_RETURN (status == PJ_SUCCESS, false);
// Associate current invite session in the call
call->setInvSession (inv);
status = pjsip_inv_send_msg (inv, tdata);
status = pjsip_inv_send_msg (inv, tdata);
if (status != PJ_SUCCESS) {
delete call;
call = 0;
return false;
}
if (status != PJ_SUCCESS) {
delete call;
call = 0;
return false;
}
call->setConnectionState (Call::Progressing);
call->setConnectionState (Call::Progressing);
call->setState (Call::Active);
addCall (call);
call->setState (Call::Active);
addCall (call);
return true;
} else
return false;
return true;
} else
return false;
}
......@@ -3597,6 +3605,8 @@ mod_on_rx_request (pjsip_rx_data *rdata)
if (Manager::instance().getConfigString (HOOKS, URLHOOK_SIP_ENABLED) == "1") {
_debug("UserAgent: Set sip url hooks");
std::string header_value;
header_value = fetch_header_value (rdata->msg_info.msg, Manager::instance().getConfigString (HOOKS, URLHOOK_SIP_FIELD));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment