From 567e11c5b474928bb9b724a2aba262601623ed26 Mon Sep 17 00:00:00 2001 From: yanmorin <yanmorin> Date: Thu, 3 Aug 2006 21:12:36 +0000 Subject: [PATCH] Adding new method to iaxvoiplink (answer, refuse, transfer, senddtmf) --- TODO | 2 +- src/audio/audiortp.cpp | 6 +++-- src/iaxvoiplink.cpp | 51 ++++++++++++++++++++++++++++++++++++++++ src/iaxvoiplink.h | 8 +++---- src/sipvoiplink.cpp | 13 +++++----- tools/sflphone-bash/call | 2 +- 6 files changed, 68 insertions(+), 14 deletions(-) diff --git a/TODO b/TODO index e4fd4291f7..745302dc2d 100644 --- a/TODO +++ b/TODO @@ -17,7 +17,7 @@ For sflphone-qt: --------------- Add samplerate combobox if sample rate is compiled Save account status if modified in configuration - +Bug when moving sflphone and clicking inside the lcd From FIXME: diff --git a/src/audio/audiortp.cpp b/src/audio/audiortp.cpp index caff8b83b0..095829f826 100644 --- a/src/audio/audiortp.cpp +++ b/src/audio/audiortp.cpp @@ -54,8 +54,9 @@ AudioRtp::createNewSession (SIPCall *ca) { // something should stop the thread before... if ( _RTXThread != 0 ) { - _debug("Try to create a new audio rtp thread...\n"); - return -1; + _debug("AudioRTP Failure: Thread already exists..., stopping it\n"); + delete _RTXThread; _RTXThread = 0; + //return -1; } // Start RTP Send/Receive threads @@ -64,6 +65,7 @@ AudioRtp::createNewSession (SIPCall *ca) { try { if (_RTXThread->start() != 0) { + _debug("AudioRTP Failure: unable to start RTX Thread\n"); return -1; } } catch(...) { diff --git a/src/iaxvoiplink.cpp b/src/iaxvoiplink.cpp index 6b0a22b939..fe59762514 100644 --- a/src/iaxvoiplink.cpp +++ b/src/iaxvoiplink.cpp @@ -292,6 +292,19 @@ IAXVoIPLink::newOutgoingCall(const CallID& id, const std::string& toUrl) return call; } +bool +IAXVoIPLink::answer(const CallID& id) +{ + IAXCall* call = getIAXCall(id); + if (call==0) { _debug("Call doesn't exists\n"); return false; } + _mutexIAX.enterMutex(); + iax_answer(call->getSession()); + _mutexIAX.leaveMutex(); + call->setState(Call::Active); + call->setConnectionState(Call::Connected); + return true; +} + bool IAXVoIPLink::hangup(const CallID& id) { @@ -335,6 +348,44 @@ IAXVoIPLink::offhold(const CallID& id) return true; } +bool +IAXVoIPLink::transfer(const CallID& id, const std::string& to) +{ + IAXCall* call = getIAXCall(id); + if (call==0) { _debug("Call doesn't exists\n"); return false; } + + char callto[to.length()+1]; + strcpy(callto, to.c_str()); + + _mutexIAX.enterMutex(); + iax_transfer(call->getSession(), callto); + _mutexIAX.leaveMutex(); + + // should we remove it? + // removeCall(id); +} + +bool +IAXVoIPLink::refuse(const CallID& id) +{ + IAXCall* call = getIAXCall(id); + if (call==0) { _debug("Call doesn't exists\n"); return false; } + _mutexIAX.enterMutex(); + iax_reject(call->getSession(), "Call rejected manually."); + _mutexIAX.leaveMutex(); + removeCall(id); +} + +bool +IAXVoIPLink::carryingDTMFdigits(const CallID& id, char code) +{ + IAXCall* call = getIAXCall(id); + if (call==0) { _debug("Call doesn't exists\n"); return false; } + _mutexIAX.enterMutex(); + iax_send_dtmf(call->getSession(), code); + _mutexIAX.leaveMutex(); +} + bool IAXVoIPLink::iaxOutgoingInvite(IAXCall* call) { diff --git a/src/iaxvoiplink.h b/src/iaxvoiplink.h index c6e35fa089..9a2f2d04f1 100644 --- a/src/iaxvoiplink.h +++ b/src/iaxvoiplink.h @@ -51,15 +51,15 @@ public: bool setUnregister (void); Call* newOutgoingCall(const CallID& id, const std::string& toUrl); - bool answer(const CallID& id) {return false;} + bool answer(const CallID& id); bool hangup(const CallID& id); bool cancel(const CallID& id) { return false; } bool onhold(const CallID& id); bool offhold(const CallID& id); - bool transfer(const CallID& id, const std::string& to) { return false; } - bool refuse (const CallID& id) { return false; } - bool carryingDTMFdigits(const CallID& id, char code) { return false; } + bool transfer(const CallID& id, const std::string& to); + bool refuse (const CallID& id); + bool carryingDTMFdigits(const CallID& id, char code); bool sendMessage(const std::string& to, const std::string& body) { return false; } public: // iaxvoiplink only diff --git a/src/sipvoiplink.cpp b/src/sipvoiplink.cpp index 05dce99b33..b1b2a8b788 100644 --- a/src/sipvoiplink.cpp +++ b/src/sipvoiplink.cpp @@ -613,6 +613,13 @@ SIPVoIPLink::onhold(const CallID& id) SIPCall* call = getSIPCall(id); if (call==0) { _debug("Call doesn't exist\n"); return false; } + // Stop sound + call->setAudioStart(false); + call->setState(Call::Hold); + _debug("SIP: Stopping AudioRTP when onhold\n"); + _audiortp.closeRtpSession(); + + int did = call->getDid(); eXosip_lock (); @@ -661,12 +668,6 @@ SIPVoIPLink::onhold(const CallID& id) osip_message_set_content_type (invite, "application/sdp"); } - // Stop sound - call->setAudioStart(false); - call->setState(Call::Hold); - _debug("SIP: Stopping AudioRTP when onhold\n"); - _audiortp.closeRtpSession(); - // send request _debug("< Send on hold request\n"); eXosip_lock (); diff --git a/tools/sflphone-bash/call b/tools/sflphone-bash/call index d6b965e6d3..fae1284358 100755 --- a/tools/sflphone-bash/call +++ b/tools/sflphone-bash/call @@ -30,7 +30,7 @@ if [ -z `$pidof 'sflphoned'` ]; then echo -en "\n"; fi -callstring="call someone with $callid $telephonenumber\n" +callstring="call someone SIP0 $callid $telephonenumber\n" echo "Calling $telephonenumber..." echo -en $callstring | $netcat -- GitLab