Commit 014cf030 authored by Emmanuel Lepage's avatar Emmanuel Lepage
Browse files
parents 8f2b65ee 130f92bc
...@@ -52,9 +52,12 @@ ...@@ -52,9 +52,12 @@
# define wcsicmp _wcsicmp # define wcsicmp _wcsicmp
# define wcsnicmp _wcsnicmp # define wcsnicmp _wcsnicmp
#else #else
#ifndef stricmp
# define stricmp strcasecmp # define stricmp strcasecmp
#endif
#ifndef strnicmp
# define strnicmp strncasecmp # define strnicmp strncasecmp
#endif
# if defined(PJ_NATIVE_STRING_IS_UNICODE) && PJ_NATIVE_STRING_IS_UNICODE!=0 # if defined(PJ_NATIVE_STRING_IS_UNICODE) && PJ_NATIVE_STRING_IS_UNICODE!=0
# error "Implement Unicode string functions" # error "Implement Unicode string functions"
# endif # endif
......
...@@ -92,15 +92,6 @@ static cipher_name_t cipher_names[] = ...@@ -92,15 +92,6 @@ static cipher_name_t cipher_names[] =
{PJ_SSL_FORTEZZA_KEA_WITH_NULL_SHA, "SSL_FORTEZZA_KEA_WITH_NULL_SHA"}, {PJ_SSL_FORTEZZA_KEA_WITH_NULL_SHA, "SSL_FORTEZZA_KEA_WITH_NULL_SHA"},
{PJ_SSL_FORTEZZA_KEA_WITH_FORTEZZA_CBC_SHA,"SSL_FORTEZZA_KEA_WITH_FORTEZZA_CBC_SHA"}, {PJ_SSL_FORTEZZA_KEA_WITH_FORTEZZA_CBC_SHA,"SSL_FORTEZZA_KEA_WITH_FORTEZZA_CBC_SHA"},
{PJ_SSL_FORTEZZA_KEA_WITH_RC4_128_SHA, "SSL_FORTEZZA_KEA_WITH_RC4_128_SHA"}, {PJ_SSL_FORTEZZA_KEA_WITH_RC4_128_SHA, "SSL_FORTEZZA_KEA_WITH_RC4_128_SHA"},
/* SSLv2 */
{PJ_SSL_CK_RC4_128_WITH_MD5, "SSL_CK_RC4_128_WITH_MD5"},
{PJ_SSL_CK_RC4_128_EXPORT40_WITH_MD5, "SSL_CK_RC4_128_EXPORT40_WITH_MD5"},
{PJ_SSL_CK_RC2_128_CBC_WITH_MD5, "SSL_CK_RC2_128_CBC_WITH_MD5"},
{PJ_SSL_CK_RC2_128_CBC_EXPORT40_WITH_MD5, "SSL_CK_RC2_128_CBC_EXPORT40_WITH_MD5"},
{PJ_SSL_CK_IDEA_128_CBC_WITH_MD5, "SSL_CK_IDEA_128_CBC_WITH_MD5"},
{PJ_SSL_CK_DES_64_CBC_WITH_MD5, "SSL_CK_DES_64_CBC_WITH_MD5"},
{PJ_SSL_CK_DES_192_EDE3_CBC_WITH_MD5, "SSL_CK_DES_192_EDE3_CBC_WITH_MD5"}
}; };
......
...@@ -70,7 +70,6 @@ static const char *const CONFIG_ACCOUNT_TYPE = "Account.type"; ...@@ -70,7 +70,6 @@ static const char *const CONFIG_ACCOUNT_TYPE = "Account.type";
static const char *const CONFIG_ACCOUNT_ALIAS = "Account.alias"; static const char *const CONFIG_ACCOUNT_ALIAS = "Account.alias";
static const char *const CONFIG_ACCOUNT_MAILBOX = "Account.mailbox"; static const char *const CONFIG_ACCOUNT_MAILBOX = "Account.mailbox";
static const char *const CONFIG_ACCOUNT_ENABLE = "Account.enable"; static const char *const CONFIG_ACCOUNT_ENABLE = "Account.enable";
static const char *const CONFIG_ACCOUNT_RESOLVE_ONCE = "Account.resolveOnce";
static const char *const CONFIG_ACCOUNT_REGISTRATION_EXPIRE = "Account.expire"; static const char *const CONFIG_ACCOUNT_REGISTRATION_EXPIRE = "Account.expire";
static const char *const CONFIG_CREDENTIAL_NUMBER = "Credential.count"; static const char *const CONFIG_CREDENTIAL_NUMBER = "Credential.count";
static const char *const ACCOUNT_DTMF_TYPE = "Account.dtmfType"; static const char *const ACCOUNT_DTMF_TYPE = "Account.dtmfType";
......
...@@ -158,25 +158,17 @@ void AudioRtpFactory::start (AudioCodec* audiocodec) ...@@ -158,25 +158,17 @@ void AudioRtpFactory::start (AudioCodec* audiocodec)
void AudioRtpFactory::stop (void) void AudioRtpFactory::stop (void)
{ {
ost::MutexLock mutex (_audioRtpThreadMutex); ost::MutexLock mutex (_audioRtpThreadMutex);
_info ("AudioRtpFactory: Stopping audio rtp session");
if (_rtpSession == NULL) { if (_rtpSession == NULL)
_debug ("AudioRtpFactory: Rtp session already deleted");
return; return;
}
try { if (_rtpSession->getAudioRtpType() == Sdes) {
if (_rtpSession->getAudioRtpType() == Sdes) { localContext = static_cast<AudioSrtpSession *> (_rtpSession)->_localCryptoCtx;
localContext = static_cast<AudioSrtpSession *> (_rtpSession)->_localCryptoCtx; remoteContext = static_cast<AudioSrtpSession *> (_rtpSession)->_remoteCryptoCtx;
remoteContext = static_cast<AudioSrtpSession *> (_rtpSession)->_remoteCryptoCtx; }
}
delete _rtpSession; delete _rtpSession;
_rtpSession = NULL; _rtpSession = NULL;
} catch (...) {
_debug ("AudioRtpFactory: Error: Exception caught when stopping the audio rtp session");
throw AudioRtpFactoryException ("AudioRtpFactory: Error: caught exception in AudioRtpFactory::stop");
}
} }
int AudioRtpFactory::getSessionMedia() int AudioRtpFactory::getSessionMedia()
...@@ -192,8 +184,6 @@ int AudioRtpFactory::getSessionMedia() ...@@ -192,8 +184,6 @@ int AudioRtpFactory::getSessionMedia()
void AudioRtpFactory::updateSessionMedia (AudioCodec *audiocodec) void AudioRtpFactory::updateSessionMedia (AudioCodec *audiocodec)
{ {
_info ("AudioRtpFactory: Updating session media");
if (_rtpSession == NULL) { if (_rtpSession == NULL) {
throw AudioRtpFactoryException ("AudioRtpFactory: Error: _rtpSession was null when trying to update IP address"); throw AudioRtpFactoryException ("AudioRtpFactory: Error: _rtpSession was null when trying to update IP address");
} }
...@@ -202,8 +192,6 @@ void AudioRtpFactory::updateSessionMedia (AudioCodec *audiocodec) ...@@ -202,8 +192,6 @@ void AudioRtpFactory::updateSessionMedia (AudioCodec *audiocodec)
void AudioRtpFactory::updateDestinationIpAddress (void) void AudioRtpFactory::updateDestinationIpAddress (void)
{ {
_info ("AudioRtpFactory: Updating IP address");
if (_rtpSession == NULL) { if (_rtpSession == NULL) {
throw AudioRtpFactoryException ("AudioRtpFactory: Error: RtpSession was null when trying to update IP address"); throw AudioRtpFactoryException ("AudioRtpFactory: Error: RtpSession was null when trying to update IP address");
} }
...@@ -244,9 +232,7 @@ void AudioRtpFactory::setDtmfPayloadType(unsigned int payloadType) ...@@ -244,9 +232,7 @@ void AudioRtpFactory::setDtmfPayloadType(unsigned int payloadType)
void AudioRtpFactory::sendDtmfDigit (int digit) void AudioRtpFactory::sendDtmfDigit (int digit)
{ {
_rtpSession->putDtmfEvent (digit); _rtpSession->putDtmfEvent(digit);
} }
} }
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include "AudioRtpRecordHandler.h" #include "AudioRtpRecordHandler.h"
#include <fstream> #include <fstream>
#include "sip/sipcall.h"
#include "audio/audiolayer.h" #include "audio/audiolayer.h"
#include "manager.h" #include "manager.h"
......
...@@ -36,7 +36,7 @@ using std::ptrdiff_t; ...@@ -36,7 +36,7 @@ using std::ptrdiff_t;
#include <ccrtp/rtp.h> #include <ccrtp/rtp.h>
#include <list> #include <list>
#include "sip/sipcall.h" class SIPCall;
#include "audio/codecs/audiocodec.h" #include "audio/codecs/audiocodec.h"
#include "audio/samplerateconverter.h" #include "audio/samplerateconverter.h"
#include "audio/noisesuppress.h" #include "audio/noisesuppress.h"
...@@ -105,7 +105,7 @@ class AudioRtpRecord ...@@ -105,7 +105,7 @@ class AudioRtpRecord
class AudioRtpRecordHandler class AudioRtpRecordHandler
{ {
public: public:
AudioRtpRecordHandler (SIPCall *ca); AudioRtpRecordHandler(SIPCall *);
virtual ~AudioRtpRecordHandler(); virtual ~AudioRtpRecordHandler();
/** /**
......
...@@ -60,15 +60,11 @@ AudioRtpSession::AudioRtpSession (SIPCall * sipcall, RtpMethod type, ost::RTPDat ...@@ -60,15 +60,11 @@ AudioRtpSession::AudioRtpSession (SIPCall * sipcall, RtpMethod type, ost::RTPDat
AudioRtpSession::~AudioRtpSession() AudioRtpSession::~AudioRtpSession()
{ {
_info ("AudioRtpSession: Delete AudioRtpSession instance");
_queue->disableStack(); _queue->disableStack();
} }
void AudioRtpSession::updateSessionMedia (AudioCodec *audioCodec) void AudioRtpSession::updateSessionMedia (AudioCodec *audioCodec)
{ {
_debug ("AudioSymmetricRtpSession: Update session media");
// Update internal codec for this session
int lastSamplingRate = _audioRtpRecord._codecSampleRate; int lastSamplingRate = _audioRtpRecord._codecSampleRate;
setSessionMedia(audioCodec); setSessionMedia(audioCodec);
...@@ -84,9 +80,6 @@ void AudioRtpSession::updateSessionMedia (AudioCodec *audioCodec) ...@@ -84,9 +80,6 @@ void AudioRtpSession::updateSessionMedia (AudioCodec *audioCodec)
void AudioRtpSession::setSessionMedia (AudioCodec *audioCodec) void AudioRtpSession::setSessionMedia (AudioCodec *audioCodec)
{ {
_debug ("AudioSymmetricRtpSession: Set session media");
// set internal codec info for this session
setRtpMedia (audioCodec); setRtpMedia (audioCodec);
// store codec info locally // store codec info locally
......
...@@ -87,51 +87,26 @@ Call::getState() ...@@ -87,51 +87,26 @@ Call::getState()
std::string std::string
Call::getStateStr () Call::getStateStr ()
{ {
CallState state = getState(); switch (getState()) {
ConnectionState connection = getConnectionState ();
CallType type = _type;
std::string state_str;
switch (state) {
case Active: case Active:
switch (connection) { switch (getConnectionState()) {
case Ringing: case Ringing: return isIncoming() ? "INCOMING" : "RINGING";
(type == Incoming) ? state_str = "INCOMING":state_str = "RINGING";
break;
case Connected: case Connected:
default: default: return isRecording() ? "RECORD" : "CURRENT";
isRecording() ? state_str = "RECORD" : state_str = "CURRENT";
break;
} }
case Hold: case Hold: return "HOLD";
state_str = "HOLD"; case Busy: return "BUSY";
break;
case Busy:
state_str = "BUSY";
break;
case Inactive: case Inactive:
switch (connection) { switch (getConnectionState()) {
case Ringing: case Ringing: return isIncoming() ? "INCOMING" : "RINGING";
(type == Incoming) ? state_str = "INCOMING":state_str = "RINGING"; case Connected: return "CURRENT";
break; default: return "INACTIVE";
case Connected:
state_str = "CURRENT";
break;
default:
state_str = "INACTIVE";
break;
} }
break; case Conferencing: return "CONFERENCING";
case Conferencing:
state_str = "CONFERENCING";
break;
case Refused: case Refused:
case Error: case Error:
default: default: return "FAILURE";
state_str = "FAILURE";
break;
} }
return state_str;
} }
...@@ -152,36 +127,20 @@ Call::getLocalAudioPort() ...@@ -152,36 +127,20 @@ Call::getLocalAudioPort()
bool bool
Call::setRecording() Call::setRecording()
{ {
_debug ("Call: Set recording");
bool recordStatus = Recordable::recAudio.isRecording(); bool recordStatus = Recordable::recAudio.isRecording();
Recordable::recAudio.setRecording(); Recordable::recAudio.setRecording();
MainBuffer *mbuffer = Manager::instance().getMainBuffer();
std::string process_id = Recordable::recorder.getRecorderID();
// Start recording
if (!recordStatus) { if (!recordStatus) {
_debug ("Call: Call not recording yet, set ringbuffers");
MainBuffer *mbuffer = Manager::instance().getMainBuffer();
std::string process_id = Recordable::recorder.getRecorderID();
mbuffer->bindHalfDuplexOut (process_id, _id); mbuffer->bindHalfDuplexOut (process_id, _id);
mbuffer->bindHalfDuplexOut (process_id); mbuffer->bindHalfDuplexOut (process_id);
Recordable::recorder.start(); Recordable::recorder.start();
} } else {
// Stop recording
else {
_debug ("Call: Stop recording");
MainBuffer *mbuffer = Manager::instance().getMainBuffer();
std::string process_id = Recordable::recorder.getRecorderID();
mbuffer->unBindHalfDuplexOut (process_id, _id); mbuffer->unBindHalfDuplexOut (process_id, _id);
mbuffer->unBindHalfDuplexOut (process_id); mbuffer->unBindHalfDuplexOut (process_id);
} }
Manager::instance().getMainBuffer()->stateInfo(); Manager::instance().getMainBuffer()->stateInfo();
......
...@@ -170,7 +170,7 @@ class Call: public Recordable ...@@ -170,7 +170,7 @@ class Call: public Recordable
* false otherwise * false otherwise
*/ */
bool isIncoming() { bool isIncoming() {
return (_type == Incoming) ? true : false; return _type == Incoming;
} }
/** /**
......
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include "global.h" #include "global.h"
#include "callmanager.h" #include "callmanager.h"
#include "sip/sipcall.h"
#include "sip/sipvoiplink.h" #include "sip/sipvoiplink.h"
#include "audio/audiortp/AudioRtpFactory.h" #include "audio/audiortp/AudioRtpFactory.h"
#include "audio/audiortp/AudioZrtpSession.h" #include "audio/audiortp/AudioZrtpSession.h"
...@@ -366,26 +367,15 @@ sfl::AudioZrtpSession * CallManager::getAudioZrtpSession (const std::string& cal ...@@ -366,26 +367,15 @@ sfl::AudioZrtpSession * CallManager::getAudioZrtpSession (const std::string& cal
SIPCall *call; SIPCall *call;
try { try {
call = link->getSIPCall (callID); call = link->getSIPCall(callID);
} }
catch (const VoipLinkException &e) { catch (const VoipLinkException &e) {
throw CallManagerException("Call id " + callID + " is not valid"); throw CallManagerException("Call id " + callID + " is not valid");
} }
sfl::AudioRtpFactory * audioRtp = NULL; sfl::AudioZrtpSession * zSession = call->getAudioRtp()->getAudioZrtpSession();
audioRtp = call->getAudioRtp(); if (!zSession)
if (!audioRtp) {
throw CallManagerException("Failed to get AudioRtpFactory");
}
sfl::AudioZrtpSession * zSession = NULL;
zSession = audioRtp->getAudioZrtpSession();
if (!zSession) {
throw CallManagerException("Failed to get AudioZrtpSession"); throw CallManagerException("Failed to get AudioZrtpSession");
}
return zSession; return zSession;
} }
......
...@@ -33,6 +33,8 @@ ...@@ -33,6 +33,8 @@
void UrlHook::runAction (std::string command, std::string args) void UrlHook::runAction (std::string command, std::string args)
{ {
if (args.empty())
return;
//FIXME : use fork and execve, so no need to escape shell arguments //FIXME : use fork and execve, so no need to escape shell arguments
std::string cmd = command + "\"" + args + "\" &"; std::string cmd = command + "\"" + args + "\" &";
system(cmd.c_str()); system(cmd.c_str());
......
...@@ -170,7 +170,7 @@ IAXVoIPLink::getEvent() ...@@ -170,7 +170,7 @@ IAXVoIPLink::getEvent()
{ {
ost::MutexLock m(mutexIAX_); ost::MutexLock m(mutexIAX_);
while ((event = iax_get_event (IAX_NONBLOCKING)) != NULL) { while ((event = iax_get_event (IAX_NONBLOCKING)) != NULL) {
// If we received an 'ACK', libiax2 tells apps to ignore them. // If we received an 'ACK', libiax2 tells apps to ignore them.
if (event->etype == IAX_EVENT_NULL) if (event->etype == IAX_EVENT_NULL)
continue; continue;
...@@ -178,24 +178,20 @@ IAXVoIPLink::getEvent() ...@@ -178,24 +178,20 @@ IAXVoIPLink::getEvent()
if (call) if (call)
iaxHandleCallEvent (event, call); iaxHandleCallEvent (event, call);
else if (event->session && event->session == regSession_) { else if (event->session && event->session == regSession_) // This is a registration session, deal with it
// This is a registration session, deal with it
iaxHandleRegReply (event); iaxHandleRegReply (event);
} else { else // We've got an event before it's associated with any call
// We've got an event before it's associated with any call
iaxHandlePrecallEvent (event); iaxHandlePrecallEvent (event);
}
iax_event_free (event); iax_event_free (event);
} }
free(event);
} }
sendAudioFromMic(); sendAudioFromMic();
// thread wait 3 millisecond // thread wait 3 millisecond
evThread_->sleep(3); evThread_->sleep(3);
free (event);
} }
void void
...@@ -432,11 +428,12 @@ IAXVoIPLink::offhold (const std::string& id) ...@@ -432,11 +428,12 @@ IAXVoIPLink::offhold (const std::string& id)
call->setState (Call::Active); call->setState (Call::Active);
} }
bool void
IAXVoIPLink::transfer (const std::string& id, const std::string& to) IAXVoIPLink::transfer (const std::string& id, const std::string& to)
{ {
IAXCall* call = getIAXCall (id); IAXCall* call = getIAXCall (id);
CHK_VALID_CALL; if (!call)
return;
char callto[to.length() +1]; char callto[to.length() +1];
strcpy (callto, to.c_str()); strcpy (callto, to.c_str());
...@@ -444,11 +441,6 @@ IAXVoIPLink::transfer (const std::string& id, const std::string& to) ...@@ -444,11 +441,6 @@ IAXVoIPLink::transfer (const std::string& id, const std::string& to)
mutexIAX_.enterMutex(); mutexIAX_.enterMutex();
iax_transfer (call->getSession(), callto); iax_transfer (call->getSession(), callto);
mutexIAX_.leaveMutex(); mutexIAX_.leaveMutex();
return true;
// should we remove it?
// removeCall(id);
} }
bool bool
...@@ -474,36 +466,29 @@ IAXVoIPLink::refuse (const std::string& id) ...@@ -474,36 +466,29 @@ IAXVoIPLink::refuse (const std::string& id)
} }
bool void
IAXVoIPLink::carryingDTMFdigits (const std::string& id, char code) IAXVoIPLink::carryingDTMFdigits (const std::string& id, char code)
{ {
IAXCall* call = getIAXCall (id); IAXCall* call = getIAXCall (id);
CHK_VALID_CALL; if (call) {
mutexIAX_.enterMutex();
mutexIAX_.enterMutex(); iax_send_dtmf (call->getSession(), code);
iax_send_dtmf (call->getSession(), code); mutexIAX_.leaveMutex();
mutexIAX_.leaveMutex(); }
return true;
} }
bool void
IAXVoIPLink::sendTextMessage (sfl::InstantMessaging *module, IAXVoIPLink::sendTextMessage (sfl::InstantMessaging *module,
const std::string& callID, const std::string& message, const std::string& callID, const std::string& message,
const std::string& /*from*/) const std::string& /*from*/)
{ {
IAXCall* call = getIAXCall (callID); IAXCall* call = getIAXCall (callID);
CHK_VALID_CALL; if (!call)
return;
// Must active the mutex for this session
mutexIAX_.enterMutex(); mutexIAX_.enterMutex();
module->send_iax_message (call->getSession(), callID, message.c_str()); module->send_iax_message (call->getSession(), callID, message.c_str());
// iax_send_text (call->getSession(), message.c_str());
mutexIAX_.leaveMutex(); mutexIAX_.leaveMutex();
return true;
} }
...@@ -649,28 +634,17 @@ IAXVoIPLink::iaxHandleCallEvent (iax_event* event, IAXCall* call) ...@@ -649,28 +634,17 @@ IAXVoIPLink::iaxHandleCallEvent (iax_event* event, IAXCall* call)
break; break;
case IAX_IE_MSGCOUNT: case IAX_IE_MSGCOUNT:
break; case IAX_EVENT_TIMEOUT:
case IAX_EVENT_PONG: case IAX_EVENT_PONG:
default:
break; break;
case IAX_EVENT_URL: case IAX_EVENT_URL:
if (Manager::instance().getConfigString (HOOKS, URLHOOK_IAX2_ENABLED) == "1") { if (Manager::instance().getConfigString (HOOKS, URLHOOK_IAX2_ENABLED) == "1")
if (*event->data) { UrlHook::runAction (Manager::instance().getConfigString (HOOKS, URLHOOK_COMMAND), (char*) event->data);
_debug ("> IAX_EVENT_URL received: %s", event->data);
UrlHook::runAction (Manager::instance().getConfigString (HOOKS, URLHOOK_COMMAND), (char*) event->data);
}
}
break; break;
case IAX_EVENT_TIMEOUT:
break;