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)
try {
portaudio::System::terminate();
} 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();
}
......@@ -112,15 +112,16 @@ AudioLayer::startStream(void)
try {
ost::MutexLock guard(_mutex);
if (_stream && !_stream->isActive()) {
_debug("Starting sound stream\n");
_debug("- AL Action: Starting sound stream\n");
_stream->start();
}
else { _debug ("stream doesn't exist or is already active\n"); }
} else {
_debug ("* AL Info: Stream doesn't exist or is already active\n");
}
} catch (const portaudio::PaException &e) {
_debugException("Portaudio error: error on starting audiolayer stream");
_debugException("! AL: Portaudio error: error on starting audiolayer stream");
throw;
} catch(...) {
_debugException("stream start error");
_debugException("! AL: Stream start error");
throw;
}
}
......@@ -137,10 +138,10 @@ AudioLayer::stopStream(void)
_micRingBuffer.flush();
}
} catch (const portaudio::PaException &e) {
_debugException("Portaudio error: stoping audiolayer stream failed");
_debugException("! AL: Portaudio error: stoping audiolayer stream failed");
throw;
} catch(...) {
_debugException("stream stop error");
_debugException("! AL: Stream stop error");
throw;
}
}
......@@ -162,7 +163,7 @@ AudioLayer::isStreamActive (void)
return true;
}
} catch (const portaudio::PaException &e) {
_debugException("Portaudio error: isActive returned an error");
_debugException("! AL: Portaudio error: isActive returned an error");
}
return false;
}
......@@ -239,7 +240,7 @@ AudioLayer::isStreamStopped (void)
return true;
}
} catch (const portaudio::PaException &e) {
_debugException("Portaudio error: isStopped returned an exception");
_debugException("! AL: Portaudio error: isStopped returned an exception");
}
return false;
}
......
......@@ -54,7 +54,7 @@ AudioRtp::createNewSession (SIPCall *ca) {
// something should stop the thread before...
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;
//return -1;
}
......@@ -65,11 +65,11 @@ AudioRtp::createNewSession (SIPCall *ca) {
try {
if (_RTXThread->start() != 0) {
_debug("AudioRTP Failure: unable to start RTX Thread\n");
_debug("! ARTP Failure: unable to start RTX Thread\n");
return -1;
}
} catch(...) {
_debugException("AudioRTP try to start a thread");
_debugException("! ARTP Failure: when trying to start a thread");
throw;
}
return 0;
......@@ -84,7 +84,7 @@ AudioRtp::closeRtpSession () {
try {
delete _RTXThread; _RTXThread = 0;
} catch(...) {
_debugException("Exception when stopping audiortp\n");
_debugException("! ARTP Exception: when stopping audiortp\n");
throw;
}
}
......@@ -133,7 +133,7 @@ AudioRtpRTX::~AudioRtpRTX () {
try {
this->terminate();
} catch(...) {
_debugException("AudioRTP Thread destructor didn't terminate correctly");
_debugException("! ARTP: Thread destructor didn't terminate correctly");
throw;
}
//_debug("terminate audiortprtx ended...\n");
......@@ -164,7 +164,7 @@ AudioRtpRTX::initAudioRtpSession (void)
//_debug("Init audio RTP session\n");
ost::InetHostAddress remote_ip(_ca->getRemoteIp().c_str());
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;
}
......@@ -186,7 +186,7 @@ AudioRtpRTX::initAudioRtpSession (void)
return;
}
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;
}
......@@ -220,7 +220,7 @@ AudioRtpRTX::initAudioRtpSession (void)
}
}
} catch(...) {
_debugException("AudioRTP initialisation failed");
_debugException("! ARTP Failure: initialisation failed");
throw;
}
}
......@@ -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);
// encode divise by two
// 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");
if (!_sym) {
_sessionSend->putData(timestamp, data_to_send, compSize);
......@@ -300,7 +300,7 @@ AudioRtpRTX::sendSessionFromMic (unsigned char* data_to_send, int16* data_from_m
}
}
} catch(...) {
_debugException("AudioRTP sending failed");
_debugException("! ARTP: sending failed");
throw;
}
}
......@@ -382,7 +382,7 @@ AudioRtpRTX::receiveSessionForSpkr (int16* data_for_speakers_stereo, int16* data
delete adu; adu = NULL;
} catch(...) {
_debugException("AudioRTP receiving failed");
_debugException("! ARTP: receiving failed");
throw;
}
}
......@@ -430,7 +430,7 @@ AudioRtpRTX::run () {
audiolayer->flushMic();
audiolayer->startStream();
_start.post();
_debug("AudioRTP Start\n");
_debug("- ARTP Action: Start\n");
while (!testCancel()) {
////////////////////////////
// Send session
......@@ -451,11 +451,11 @@ AudioRtpRTX::run () {
audiolayer->stopStream();
} catch(std::exception &e) {
_start.post();
_debug("AudioRTP Stop: %s\n", e.what());
_debug("! ARTP: Stop %s\n", e.what());
throw;
} catch(...) {
_start.post();
_debugException("AudioRTP Stop");
_debugException("* ARTP Action: Stop");
throw;
}
delete [] data_for_speakers_stereo; data_for_speakers_stereo = 0;
......
......@@ -29,10 +29,16 @@ typedef short int16;
#ifdef DEBUG
#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 _debugInit(...) fprintf(stderr, "[sfl-init.] " __VA_ARGS__ "\n")
#else
#define _debug(...)
#define _debugStart(...)
#define _debugMid(...)
#define _debugEnd(...)
#define _debugException(...)
#define _debugInit(...)
#endif
......
......@@ -242,32 +242,6 @@ GuiFramework::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
GuiFramework::setSwitch(const std::string& switchName, std::string& returnMessage)
{
......
......@@ -97,7 +97,6 @@ public:
bool hasLoadedSetup();
const CallID& getCurrentId();
bool getRegistrationState(std::string& stateCode, std::string& stateMessage);
protected:
std::string _message;
......
......@@ -112,17 +112,8 @@ GUIServerImpl::getEvents(const std::string& sequenceId)
tk.push_back(_("Microphone volume changed"));
_requestManager.sendResponse(ResponseMessage("022", sequenceId, tk));
std::string stateCode;
std::string stateMessage;
// try to register, if not done yet...
GuiFramework::getEvents();
if (GuiFramework::getRegistrationState(stateCode,stateMessage)) {
_requestManager.sendResponse(ResponseMessage(stateCode, sequenceId, stateMessage));
}
return true;
}
......
......@@ -56,8 +56,6 @@
ManagerImpl::ManagerImpl (void)
{
// Init private variables
//_error = new Error();
_hasZeroconf = false;
#ifdef USE_ZEROCONF
_hasZeroconf = true;
......@@ -73,13 +71,12 @@ ManagerImpl::ManagerImpl (void)
// sound
_audiodriverPA = NULL;
_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_before_mute = 0;
// Call
_nbIncomingWaitingCall=0;
_registerState = UNREGISTERED;
_hasTriedToRegister = false;
// initialize random generator for call id
......@@ -209,24 +206,24 @@ bool
ManagerImpl::outgoingCall(const std::string& accountid, const CallID& id, const std::string& to)
{
if (!accountExists(accountid)) {
_debug("Outgoing Call: account doesn't exist\n");
_debug("! Manager Error: Outgoing Call: account doesn't exist\n");
return false;
}
if (getAccountFromCall(id) != AccountNULL) {
_debug("Outgoing Call: call id already exists\n");
_debug("! Manager Error: Outgoing Call: call id already exists\n");
return false;
}
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());
}
_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) ) {
associateCallToAccount( id, accountid );
switchCall(id);
return true;
} 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;
}
......@@ -273,7 +270,7 @@ ManagerImpl::hangupCall(const CallID& id)
AccountID accountid = getAccountFromCall( id );
if (accountid == AccountNULL) {
_debug("Hangup Call: Call doesn't exists\n");
_debug("! Manager Hangup Call: Call doesn't exists\n");
return false;
}
......@@ -291,7 +288,7 @@ ManagerImpl::cancelCall (const CallID& id)
stopTone();
AccountID accountid = getAccountFromCall( id );
if (accountid == AccountNULL) {
_debug("Cancel Call: Call doesn't exists\n");
_debug("! Manager Cancel Call: Call doesn't exists\n");
return false;
}
......@@ -311,7 +308,7 @@ ManagerImpl::onHoldCall(const CallID& id)
stopTone();
AccountID accountid = getAccountFromCall( id );
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;
}
......@@ -329,7 +326,7 @@ ManagerImpl::offHoldCall(const CallID& id)
stopTone();
AccountID accountid = getAccountFromCall( id );
if (accountid == AccountNULL) {
_debug("OffHold Call: Call doesn't exists\n");
_debug("5 Manager OffHold Call: Call doesn't exists\n");
return false;
}
bool returnValue = getAccountLink(accountid)->offhold(id);
......@@ -339,7 +336,7 @@ ManagerImpl::offHoldCall(const CallID& id)
try {
getAudioDriver()->startStream();
} catch(...) {
_debugException("Off hold could not start audio stream");
_debugException("! Manager Off hold could not start audio stream");
}
}
return returnValue;
......@@ -352,7 +349,7 @@ ManagerImpl::transferCall(const CallID& id, const std::string& to)
stopTone();
AccountID accountid = getAccountFromCall( id );
if (accountid == AccountNULL) {
_debug("Transfer Call: Call doesn't exists\n");
_debug("! Manager Transfer Call: Call doesn't exists\n");
return false;
}
bool returnValue = getAccountLink(accountid)->transfer(id, to);
......@@ -385,7 +382,7 @@ ManagerImpl::refuseCall (const CallID& id)
stopTone();
AccountID accountid = getAccountFromCall( id );
if (accountid == AccountNULL) {
_debug("OffHold Call: Call doesn't exists\n");
_debug("! Manager OffHold Call: Call doesn't exists\n");
return false;
}
bool returnValue = getAccountLink(accountid)->refuse(id);
......@@ -415,7 +412,7 @@ ManagerImpl::saveConfig (void)
bool
ManagerImpl::initRegisterVoIPLink()
{
_debugInit("Initiate VoIP Links Registration\n");
_debugInit("Initiate VoIP Links Registration");
AccountMap::iterator iter = _accountMap.begin();
while( iter != _accountMap.end() ) {
if ( iter->second) {
......@@ -1682,6 +1679,7 @@ ManagerImpl::getNewCallID()
short
ManagerImpl::loadAccountMap()
{
_debugStart("Load account:");
short nbAccount = 0;
Account* tmpAccount;
......@@ -1693,7 +1691,7 @@ ManagerImpl::loadAccountMap()
tmpAccount = AccountCreator::createAccount(AccountCreator::SIP_ACCOUNT, accountName.str());
if (tmpAccount!=0) {
_debug("Adding Account: %s\n", accountName.str().data());
_debugMid(" %s", accountName.str().data());
_accountMap[accountName.str()] = tmpAccount;
nbAccount++;
}
......@@ -1706,11 +1704,12 @@ ManagerImpl::loadAccountMap()
accountName << "IAX" << iAccountIAX;
tmpAccount = AccountCreator::createAccount(AccountCreator::IAX_ACCOUNT, accountName.str());
if (tmpAccount!=0) {
_debug("Adding Account: %s\n", accountName.str().data());
_debugMid(" %s", accountName.str().data());
_accountMap[accountName.str()] = tmpAccount;
nbAccount++;
}
}
_debugEnd("\n");
return nbAccount;
}
......
......@@ -51,17 +51,6 @@ class VoIPLink;
class DNSService;
#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
*/
......@@ -298,14 +287,6 @@ public:
*/
bool hasLoadedSetup() { return _setupLoaded; }
enum REGISTRATION_STATE {
UNREGISTERED,
REGISTERED,
FAILED
};
REGISTRATION_STATE getRegistrationState() { return _registerState; }
/** Return a new random callid that is not present in the list
* @return a brand new callid
*/
......@@ -475,8 +456,6 @@ private:
bool initRegisterVoIPLink();
// true if we tried to register Once
bool _hasTriedToRegister;
// Register state
REGISTRATION_STATE _registerState;
// tell if we have zeroconf is enabled
int _hasZeroconf;
......
......@@ -420,7 +420,7 @@ SIPCall::sdp_complete_message(sdp_message_t * remote_sdp, osip_message_t * msg)
AudioCodec* audiocodec = _codecMap.getCodec((CodecType)payload);
if (audiocodec!=0 && audiocodec->isActive()) {
listCodec << payload << " ";
listRtpMap << "a=rtpmap: " << payload << " " << audiocodec->getCodecName() << "/" << audiocodec->getClockRate();
listRtpMap << "a=rtpmap:" << payload << " " << audiocodec->getCodecName() << "/" << audiocodec->getClockRate();
if ( audiocodec->getChannel() != 1) {
listRtpMap << "/" << audiocodec->getChannel();
}
......
This diff is collapsed.
Supports Markdown
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