Commit f2bc81a0 authored by yanmorin's avatar yanmorin
Browse files

Resolving bug when calling the same account

(adding codec map to new incoming call)

Adding debugging information
parent bac53689
...@@ -45,7 +45,7 @@ AudioLayer::~AudioLayer (void) ...@@ -45,7 +45,7 @@ AudioLayer::~AudioLayer (void)
try { try {
portaudio::System::terminate(); portaudio::System::terminate();
} catch (const portaudio::PaException &e) { } catch (const portaudio::PaException &e) {
_debug("Catch an exception when portaudio tried to terminate\n"); _debug("! AL: Catch an exception when portaudio tried to terminate\n");
} }
closeStream(); closeStream();
} }
...@@ -112,15 +112,16 @@ AudioLayer::startStream(void) ...@@ -112,15 +112,16 @@ AudioLayer::startStream(void)
try { try {
ost::MutexLock guard(_mutex); ost::MutexLock guard(_mutex);
if (_stream && !_stream->isActive()) { if (_stream && !_stream->isActive()) {
_debug("Starting sound stream\n"); _debug("- AL Action: Starting sound stream\n");
_stream->start(); _stream->start();
} } else {
else { _debug ("stream doesn't exist or is already active\n"); } _debug ("* AL Info: Stream doesn't exist or is already active\n");
}
} catch (const portaudio::PaException &e) { } catch (const portaudio::PaException &e) {
_debugException("Portaudio error: error on starting audiolayer stream"); _debugException("! AL: Portaudio error: error on starting audiolayer stream");
throw; throw;
} catch(...) { } catch(...) {
_debugException("stream start error"); _debugException("! AL: Stream start error");
throw; throw;
} }
} }
...@@ -137,10 +138,10 @@ AudioLayer::stopStream(void) ...@@ -137,10 +138,10 @@ AudioLayer::stopStream(void)
_micRingBuffer.flush(); _micRingBuffer.flush();
} }
} catch (const portaudio::PaException &e) { } catch (const portaudio::PaException &e) {
_debugException("Portaudio error: stoping audiolayer stream failed"); _debugException("! AL: Portaudio error: stoping audiolayer stream failed");
throw; throw;
} catch(...) { } catch(...) {
_debugException("stream stop error"); _debugException("! AL: Stream stop error");
throw; throw;
} }
} }
...@@ -162,7 +163,7 @@ AudioLayer::isStreamActive (void) ...@@ -162,7 +163,7 @@ AudioLayer::isStreamActive (void)
return true; return true;
} }
} catch (const portaudio::PaException &e) { } catch (const portaudio::PaException &e) {
_debugException("Portaudio error: isActive returned an error"); _debugException("! AL: Portaudio error: isActive returned an error");
} }
return false; return false;
} }
...@@ -239,7 +240,7 @@ AudioLayer::isStreamStopped (void) ...@@ -239,7 +240,7 @@ AudioLayer::isStreamStopped (void)
return true; return true;
} }
} catch (const portaudio::PaException &e) { } catch (const portaudio::PaException &e) {
_debugException("Portaudio error: isStopped returned an exception"); _debugException("! AL: Portaudio error: isStopped returned an exception");
} }
return false; return false;
} }
......
...@@ -54,7 +54,7 @@ AudioRtp::createNewSession (SIPCall *ca) { ...@@ -54,7 +54,7 @@ AudioRtp::createNewSession (SIPCall *ca) {
// something should stop the thread before... // something should stop the thread before...
if ( _RTXThread != 0 ) { if ( _RTXThread != 0 ) {
_debug("AudioRTP Failure: Thread already exists..., stopping it\n"); _debug("! ARTP Failure: Thread already exists..., stopping it\n");
delete _RTXThread; _RTXThread = 0; delete _RTXThread; _RTXThread = 0;
//return -1; //return -1;
} }
...@@ -65,11 +65,11 @@ AudioRtp::createNewSession (SIPCall *ca) { ...@@ -65,11 +65,11 @@ AudioRtp::createNewSession (SIPCall *ca) {
try { try {
if (_RTXThread->start() != 0) { if (_RTXThread->start() != 0) {
_debug("AudioRTP Failure: unable to start RTX Thread\n"); _debug("! ARTP Failure: unable to start RTX Thread\n");
return -1; return -1;
} }
} catch(...) { } catch(...) {
_debugException("AudioRTP try to start a thread"); _debugException("! ARTP Failure: when trying to start a thread");
throw; throw;
} }
return 0; return 0;
...@@ -84,7 +84,7 @@ AudioRtp::closeRtpSession () { ...@@ -84,7 +84,7 @@ AudioRtp::closeRtpSession () {
try { try {
delete _RTXThread; _RTXThread = 0; delete _RTXThread; _RTXThread = 0;
} catch(...) { } catch(...) {
_debugException("Exception when stopping audiortp\n"); _debugException("! ARTP Exception: when stopping audiortp\n");
throw; throw;
} }
} }
...@@ -133,7 +133,7 @@ AudioRtpRTX::~AudioRtpRTX () { ...@@ -133,7 +133,7 @@ AudioRtpRTX::~AudioRtpRTX () {
try { try {
this->terminate(); this->terminate();
} catch(...) { } catch(...) {
_debugException("AudioRTP Thread destructor didn't terminate correctly"); _debugException("! ARTP: Thread destructor didn't terminate correctly");
throw; throw;
} }
//_debug("terminate audiortprtx ended...\n"); //_debug("terminate audiortprtx ended...\n");
...@@ -164,7 +164,7 @@ AudioRtpRTX::initAudioRtpSession (void) ...@@ -164,7 +164,7 @@ AudioRtpRTX::initAudioRtpSession (void)
//_debug("Init audio RTP session\n"); //_debug("Init audio RTP session\n");
ost::InetHostAddress remote_ip(_ca->getRemoteIp().c_str()); ost::InetHostAddress remote_ip(_ca->getRemoteIp().c_str());
if (!remote_ip) { if (!remote_ip) {
_debug("AudioRTP Thread Error: Target IP address [%s] is not correct!\n", _ca->getRemoteIp().data()); _debug("! ARTP Thread Error: Target IP address [%s] is not correct!\n", _ca->getRemoteIp().data());
return; return;
} }
...@@ -186,7 +186,7 @@ AudioRtpRTX::initAudioRtpSession (void) ...@@ -186,7 +186,7 @@ AudioRtpRTX::initAudioRtpSession (void)
return; return;
} }
if (!_sessionSend->addDestination (remote_ip, (unsigned short) _ca->getRemoteAudioPort())) { if (!_sessionSend->addDestination (remote_ip, (unsigned short) _ca->getRemoteAudioPort())) {
_debug("AudioRTP Thread Error: could not connect to port %d\n", _ca->getRemoteAudioPort()); _debug("! ARTP Thread Error: could not connect to port %d\n", _ca->getRemoteAudioPort());
return; return;
} }
...@@ -220,7 +220,7 @@ AudioRtpRTX::initAudioRtpSession (void) ...@@ -220,7 +220,7 @@ AudioRtpRTX::initAudioRtpSession (void)
} }
} }
} catch(...) { } catch(...) {
_debugException("AudioRTP initialisation failed"); _debugException("! ARTP Failure: initialisation failed");
throw; throw;
} }
} }
...@@ -291,7 +291,7 @@ AudioRtpRTX::sendSessionFromMic (unsigned char* data_to_send, int16* data_from_m ...@@ -291,7 +291,7 @@ AudioRtpRTX::sendSessionFromMic (unsigned char* data_to_send, int16* data_from_m
int compSize = audiocodec->codecEncode(data_to_send, data_from_mic_to_codec, toSize*sizeOfData); int compSize = audiocodec->codecEncode(data_to_send, data_from_mic_to_codec, toSize*sizeOfData);
// encode divise by two // encode divise by two
// Send encoded audio sample over the network // Send encoded audio sample over the network
if (compSize > RTP_FRAMES2SEND) { _debug("%d should be %d\n", compSize, _nbFrames);} if (compSize > RTP_FRAMES2SEND) { _debug("! ARTP: %d should be %d\n", compSize, _nbFrames);}
//fprintf(stderr, "S"); //fprintf(stderr, "S");
if (!_sym) { if (!_sym) {
_sessionSend->putData(timestamp, data_to_send, compSize); _sessionSend->putData(timestamp, data_to_send, compSize);
...@@ -300,7 +300,7 @@ AudioRtpRTX::sendSessionFromMic (unsigned char* data_to_send, int16* data_from_m ...@@ -300,7 +300,7 @@ AudioRtpRTX::sendSessionFromMic (unsigned char* data_to_send, int16* data_from_m
} }
} }
} catch(...) { } catch(...) {
_debugException("AudioRTP sending failed"); _debugException("! ARTP: sending failed");
throw; throw;
} }
} }
...@@ -382,7 +382,7 @@ AudioRtpRTX::receiveSessionForSpkr (int16* data_for_speakers_stereo, int16* data ...@@ -382,7 +382,7 @@ AudioRtpRTX::receiveSessionForSpkr (int16* data_for_speakers_stereo, int16* data
delete adu; adu = NULL; delete adu; adu = NULL;
} catch(...) { } catch(...) {
_debugException("AudioRTP receiving failed"); _debugException("! ARTP: receiving failed");
throw; throw;
} }
} }
...@@ -430,7 +430,7 @@ AudioRtpRTX::run () { ...@@ -430,7 +430,7 @@ AudioRtpRTX::run () {
audiolayer->flushMic(); audiolayer->flushMic();
audiolayer->startStream(); audiolayer->startStream();
_start.post(); _start.post();
_debug("AudioRTP Start\n"); _debug("- ARTP Action: Start\n");
while (!testCancel()) { while (!testCancel()) {
//////////////////////////// ////////////////////////////
// Send session // Send session
...@@ -451,11 +451,11 @@ AudioRtpRTX::run () { ...@@ -451,11 +451,11 @@ AudioRtpRTX::run () {
audiolayer->stopStream(); audiolayer->stopStream();
} catch(std::exception &e) { } catch(std::exception &e) {
_start.post(); _start.post();
_debug("AudioRTP Stop: %s\n", e.what()); _debug("! ARTP: Stop %s\n", e.what());
throw; throw;
} catch(...) { } catch(...) {
_start.post(); _start.post();
_debugException("AudioRTP Stop"); _debugException("* ARTP Action: Stop");
throw; throw;
} }
delete [] data_for_speakers_stereo; data_for_speakers_stereo = 0; delete [] data_for_speakers_stereo; data_for_speakers_stereo = 0;
......
...@@ -29,10 +29,16 @@ typedef short int16; ...@@ -29,10 +29,16 @@ typedef short int16;
#ifdef DEBUG #ifdef DEBUG
#define _debug(...) fprintf(stderr, "[sfl-debug] " __VA_ARGS__) #define _debug(...) fprintf(stderr, "[sfl-debug] " __VA_ARGS__)
#define _debugStart(...) fprintf(stderr, "[sfl-debug] " __VA_ARGS__)
#define _debugMid(...) fprintf(stderr, __VA_ARGS__)
#define _debugEnd(...) fprintf(stderr, __VA_ARGS__)
#define _debugException(...) fprintf(stderr, "[sfl-excep] " __VA_ARGS__ "\n") #define _debugException(...) fprintf(stderr, "[sfl-excep] " __VA_ARGS__ "\n")
#define _debugInit(...) fprintf(stderr, "[sfl-init.] " __VA_ARGS__ "\n") #define _debugInit(...) fprintf(stderr, "[sfl-init.] " __VA_ARGS__ "\n")
#else #else
#define _debug(...) #define _debug(...)
#define _debugStart(...)
#define _debugMid(...)
#define _debugEnd(...)
#define _debugException(...) #define _debugException(...)
#define _debugInit(...) #define _debugInit(...)
#endif #endif
......
...@@ -242,32 +242,6 @@ GuiFramework::hasLoadedSetup() ...@@ -242,32 +242,6 @@ GuiFramework::hasLoadedSetup()
return Manager::instance().hasLoadedSetup(); return Manager::instance().hasLoadedSetup();
} }
bool
GuiFramework::getRegistrationState(std::string& stateCode, std::string& stateMessage) {
ManagerImpl::REGISTRATION_STATE state = Manager::instance().getRegistrationState();
bool returnValue = false;
switch( state ) {
case ManagerImpl::REGISTERED:
returnValue = true;
stateCode = "103";
stateMessage = _("Registration succeed");
break;
case ManagerImpl::FAILED:
returnValue = true;
stateCode = "104";
stateMessage = _("Registration failed");
break;
case ManagerImpl::UNREGISTERED:
returnValue = false;
stateCode = "";
stateMessage = "";
break;
}
return returnValue;
}
bool bool
GuiFramework::setSwitch(const std::string& switchName, std::string& returnMessage) GuiFramework::setSwitch(const std::string& switchName, std::string& returnMessage)
{ {
......
...@@ -97,7 +97,6 @@ public: ...@@ -97,7 +97,6 @@ public:
bool hasLoadedSetup(); bool hasLoadedSetup();
const CallID& getCurrentId(); const CallID& getCurrentId();
bool getRegistrationState(std::string& stateCode, std::string& stateMessage);
protected: protected:
std::string _message; std::string _message;
......
...@@ -112,17 +112,8 @@ GUIServerImpl::getEvents(const std::string& sequenceId) ...@@ -112,17 +112,8 @@ GUIServerImpl::getEvents(const std::string& sequenceId)
tk.push_back(_("Microphone volume changed")); tk.push_back(_("Microphone volume changed"));
_requestManager.sendResponse(ResponseMessage("022", sequenceId, tk)); _requestManager.sendResponse(ResponseMessage("022", sequenceId, tk));
std::string stateCode;
std::string stateMessage;
// try to register, if not done yet... // try to register, if not done yet...
GuiFramework::getEvents(); GuiFramework::getEvents();
if (GuiFramework::getRegistrationState(stateCode,stateMessage)) {
_requestManager.sendResponse(ResponseMessage(stateCode, sequenceId, stateMessage));
}
return true; return true;
} }
......
...@@ -56,8 +56,6 @@ ...@@ -56,8 +56,6 @@
ManagerImpl::ManagerImpl (void) ManagerImpl::ManagerImpl (void)
{ {
// Init private variables // Init private variables
//_error = new Error();
_hasZeroconf = false; _hasZeroconf = false;
#ifdef USE_ZEROCONF #ifdef USE_ZEROCONF
_hasZeroconf = true; _hasZeroconf = true;
...@@ -73,13 +71,12 @@ ManagerImpl::ManagerImpl (void) ...@@ -73,13 +71,12 @@ ManagerImpl::ManagerImpl (void)
// sound // sound
_audiodriverPA = NULL; _audiodriverPA = NULL;
_dtmfKey = 0; _dtmfKey = 0;
_spkr_volume = 0; // Initialize after by init() -> initVolume() _spkr_volume = 0; // Initialize after by init() -> initVolume()
_mic_volume = 0; // Initialize after by init() -> initVolume() _mic_volume = 0; // Initialize after by init() -> initVolume()
_mic_volume_before_mute = 0; _mic_volume_before_mute = 0;
// Call // Call
_nbIncomingWaitingCall=0; _nbIncomingWaitingCall=0;
_registerState = UNREGISTERED;
_hasTriedToRegister = false; _hasTriedToRegister = false;
// initialize random generator for call id // initialize random generator for call id
...@@ -209,24 +206,24 @@ bool ...@@ -209,24 +206,24 @@ bool
ManagerImpl::outgoingCall(const std::string& accountid, const CallID& id, const std::string& to) ManagerImpl::outgoingCall(const std::string& accountid, const CallID& id, const std::string& to)
{ {
if (!accountExists(accountid)) { if (!accountExists(accountid)) {
_debug("Outgoing Call: account doesn't exist\n"); _debug("! Manager Error: Outgoing Call: account doesn't exist\n");
return false; return false;
} }
if (getAccountFromCall(id) != AccountNULL) { if (getAccountFromCall(id) != AccountNULL) {
_debug("Outgoing Call: call id already exists\n"); _debug("! Manager Error: Outgoing Call: call id already exists\n");
return false; return false;
} }
if (hasCurrentCall()) { if (hasCurrentCall()) {
_debug("There is currently a call, try to hold it\n"); _debug("* Manager Info: there is currently a call, try to hold it\n");
onHoldCall(getCurrentCallId()); onHoldCall(getCurrentCallId());
} }
_debug("Adding Outgoing Call %s on account %s\n", id.data(), accountid.data()); _debug("- Manager Action: Adding Outgoing Call %s on account %s\n", id.data(), accountid.data());
if ( getAccountLink(accountid)->newOutgoingCall(id, to) ) { if ( getAccountLink(accountid)->newOutgoingCall(id, to) ) {
associateCallToAccount( id, accountid ); associateCallToAccount( id, accountid );
switchCall(id); switchCall(id);
return true; return true;
} else { } else {
_debug("An error occur, the call was not created\n"); _debug("! Manager Error: An error occur, the call was not created\n");
} }
return false; return false;
} }
...@@ -273,7 +270,7 @@ ManagerImpl::hangupCall(const CallID& id) ...@@ -273,7 +270,7 @@ ManagerImpl::hangupCall(const CallID& id)
AccountID accountid = getAccountFromCall( id ); AccountID accountid = getAccountFromCall( id );
if (accountid == AccountNULL) { if (accountid == AccountNULL) {
_debug("Hangup Call: Call doesn't exists\n"); _debug("! Manager Hangup Call: Call doesn't exists\n");
return false; return false;
} }
...@@ -291,7 +288,7 @@ ManagerImpl::cancelCall (const CallID& id) ...@@ -291,7 +288,7 @@ ManagerImpl::cancelCall (const CallID& id)
stopTone(); stopTone();
AccountID accountid = getAccountFromCall( id ); AccountID accountid = getAccountFromCall( id );
if (accountid == AccountNULL) { if (accountid == AccountNULL) {
_debug("Cancel Call: Call doesn't exists\n"); _debug("! Manager Cancel Call: Call doesn't exists\n");
return false; return false;
} }
...@@ -311,7 +308,7 @@ ManagerImpl::onHoldCall(const CallID& id) ...@@ -311,7 +308,7 @@ ManagerImpl::onHoldCall(const CallID& id)
stopTone(); stopTone();
AccountID accountid = getAccountFromCall( id ); AccountID accountid = getAccountFromCall( id );
if (accountid == AccountNULL) { if (accountid == AccountNULL) {
_debug("On Hold Call: Call doesn't exists\n"); _debug("5 Manager On Hold Call: Account ID %s or callid %s desn't exists\n", accountid.c_str(), id.c_str());
return false; return false;
} }
...@@ -329,7 +326,7 @@ ManagerImpl::offHoldCall(const CallID& id) ...@@ -329,7 +326,7 @@ ManagerImpl::offHoldCall(const CallID& id)
stopTone(); stopTone();
AccountID accountid = getAccountFromCall( id ); AccountID accountid = getAccountFromCall( id );
if (accountid == AccountNULL) { if (accountid == AccountNULL) {
_debug("OffHold Call: Call doesn't exists\n"); _debug("5 Manager OffHold Call: Call doesn't exists\n");
return false; return false;
} }
bool returnValue = getAccountLink(accountid)->offhold(id); bool returnValue = getAccountLink(accountid)->offhold(id);
...@@ -339,7 +336,7 @@ ManagerImpl::offHoldCall(const CallID& id) ...@@ -339,7 +336,7 @@ ManagerImpl::offHoldCall(const CallID& id)
try { try {
getAudioDriver()->startStream(); getAudioDriver()->startStream();
} catch(...) { } catch(...) {
_debugException("Off hold could not start audio stream"); _debugException("! Manager Off hold could not start audio stream");
} }
} }
return returnValue; return returnValue;
...@@ -352,7 +349,7 @@ ManagerImpl::transferCall(const CallID& id, const std::string& to) ...@@ -352,7 +349,7 @@ ManagerImpl::transferCall(const CallID& id, const std::string& to)
stopTone(); stopTone();
AccountID accountid = getAccountFromCall( id ); AccountID accountid = getAccountFromCall( id );
if (accountid == AccountNULL) { if (accountid == AccountNULL) {
_debug("Transfer Call: Call doesn't exists\n"); _debug("! Manager Transfer Call: Call doesn't exists\n");
return false; return false;
} }
bool returnValue = getAccountLink(accountid)->transfer(id, to); bool returnValue = getAccountLink(accountid)->transfer(id, to);
...@@ -385,7 +382,7 @@ ManagerImpl::refuseCall (const CallID& id) ...@@ -385,7 +382,7 @@ ManagerImpl::refuseCall (const CallID& id)
stopTone(); stopTone();
AccountID accountid = getAccountFromCall( id ); AccountID accountid = getAccountFromCall( id );
if (accountid == AccountNULL) { if (accountid == AccountNULL) {
_debug("OffHold Call: Call doesn't exists\n"); _debug("! Manager OffHold Call: Call doesn't exists\n");
return false; return false;
} }
bool returnValue = getAccountLink(accountid)->refuse(id); bool returnValue = getAccountLink(accountid)->refuse(id);
...@@ -415,7 +412,7 @@ ManagerImpl::saveConfig (void) ...@@ -415,7 +412,7 @@ ManagerImpl::saveConfig (void)
bool bool
ManagerImpl::initRegisterVoIPLink() ManagerImpl::initRegisterVoIPLink()
{ {
_debugInit("Initiate VoIP Links Registration\n"); _debugInit("Initiate VoIP Links Registration");
AccountMap::iterator iter = _accountMap.begin(); AccountMap::iterator iter = _accountMap.begin();
while( iter != _accountMap.end() ) { while( iter != _accountMap.end() ) {
if ( iter->second) { if ( iter->second) {
...@@ -1682,6 +1679,7 @@ ManagerImpl::getNewCallID() ...@@ -1682,6 +1679,7 @@ ManagerImpl::getNewCallID()
short short
ManagerImpl::loadAccountMap() ManagerImpl::loadAccountMap()
{ {
_debugStart("Load account:");
short nbAccount = 0; short nbAccount = 0;
Account* tmpAccount; Account* tmpAccount;
...@@ -1693,7 +1691,7 @@ ManagerImpl::loadAccountMap() ...@@ -1693,7 +1691,7 @@ ManagerImpl::loadAccountMap()
tmpAccount = AccountCreator::createAccount(AccountCreator::SIP_ACCOUNT, accountName.str()); tmpAccount = AccountCreator::createAccount(AccountCreator::SIP_ACCOUNT, accountName.str());
if (tmpAccount!=0) { if (tmpAccount!=0) {
_debug("Adding Account: %s\n", accountName.str().data()); _debugMid(" %s", accountName.str().data());
_accountMap[accountName.str()] = tmpAccount; _accountMap[accountName.str()] = tmpAccount;
nbAccount++; nbAccount++;
} }
...@@ -1706,11 +1704,12 @@ ManagerImpl::loadAccountMap() ...@@ -1706,11 +1704,12 @@ ManagerImpl::loadAccountMap()
accountName << "IAX" << iAccountIAX; accountName << "IAX" << iAccountIAX;
tmpAccount = AccountCreator::createAccount(AccountCreator::IAX_ACCOUNT, accountName.str()); tmpAccount = AccountCreator::createAccount(AccountCreator::IAX_ACCOUNT, accountName.str());
if (tmpAccount!=0) { if (tmpAccount!=0) {
_debug("Adding Account: %s\n", accountName.str().data()); _debugMid(" %s", accountName.str().data());
_accountMap[accountName.str()] = tmpAccount; _accountMap[accountName.str()] = tmpAccount;
nbAccount++; nbAccount++;
} }
} }
_debugEnd("\n");
return nbAccount; return nbAccount;
} }
......
...@@ -51,17 +51,6 @@ class VoIPLink; ...@@ -51,17 +51,6 @@ class VoIPLink;
class DNSService; class DNSService;
#endif #endif
// Status
//#define CONNECTED_STATUS "Connected"
//#define LOGGED_IN_STATUS "Logged in"
//#define RINGING_STATUS "Ringing"
//#define TRYING_STATUS "Trying ..."
//#define HANGUP_STATUS "Hang up"
//#define ONHOLD_STATUS "On hold ..."
//#define TRANSFER_STATUS "Transfer to:"
//#define MUTE_ON_STATUS "Mute on"
//#define ENTER_NUMBER_STATUS "Enter Phone Number:"
/** /**
* Define a type for a AccountMap container * Define a type for a AccountMap container
*/ */
...@@ -298,14 +287,6 @@ public: ...@@ -298,14 +287,6 @@ public:
*/ */
bool hasLoadedSetup() { return _setupLoaded; } bool hasLoadedSetup() { return _setupLoaded; }