Commit c3c6b8f0 authored by Emmanuel Milou's avatar Emmanuel Milou
Browse files

Merge branch 'master' of...

Merge branch 'master' of git+ssh://repos-sflphone-git@git.sflphone.org/var/repos/sflphone/git/sflphone
parents 91eb17a7 e3ee8ce2
......@@ -167,8 +167,8 @@ void AudioRtpFactory::stop (void)
switch (_rtpSessionType) {
case Sdes:
delete static_cast<AudioSrtpSession *> (_rtpSession);
break;
delete static_cast<AudioSrtpSession *> (_rtpSession);
break;
case Symmetric:
delete static_cast<AudioSymmetricRtpSession *> (_rtpSession);
......
......@@ -267,6 +267,10 @@ namespace sfl {
delete [] _spkrDataConverted;
delete _time;
delete _converter;
if (_audiocodec) {
delete _audiocodec; _audiocodec = NULL;
}
}
template <typename D>
......@@ -615,7 +619,7 @@ namespace sfl {
_debug("RTP: Starting main thread");
setSessionTimeouts();
setSessionMedia(audiocodec);
initBuffers();
initBuffers();
return start(_mainloopSemaphore);
}
......
......@@ -31,17 +31,19 @@ CodecDescriptor::CodecDescriptor() : _CodecsMap(), _defaultCodecOrder(), _Cache(
CodecDescriptor::~CodecDescriptor()
{
}
void
CodecDescriptor::deleteHandlePointer (void)
{
int i;
_debug("CodecDesccriptor: Delete codec handle pointers");
for (i = 0 ; (unsigned int) i < _CodecInMemory.size() ; i++) {
for (int i = 0 ; (unsigned int) i < _CodecInMemory.size() ; i++) {
unloadCodec (_CodecInMemory[i]);
}
_CodecInMemory.clear();
}
void
......@@ -51,7 +53,7 @@ CodecDescriptor::init()
_nbCodecs = CodecDynamicList.size();
if (_nbCodecs <= 0) {
_debug (" Error - No codecs available in directory %s" , CODECS_DIR);
_error ("CodecDescriptro: Error - No codecs available in directory %s" , CODECS_DIR);
}
int i;
......@@ -97,7 +99,7 @@ CodecDescriptor::getCodec (AudioCodecType payload)
return (iter->second);
}
_debug ("Error cannont found codec %i in _CodecsMap from codec descriptor", payload);
_error ("CodecDescriptor: Error cannont found codec %i in _CodecsMap from codec descriptor", payload);
return NULL;
}
......@@ -167,7 +169,7 @@ std::vector<AudioCodec*> CodecDescriptor::scanCodecDirectory (void) {
for (i = 0 ; (unsigned int) i < dirToScan.size() ; i++) {
std::string dirStr = dirToScan[i];
_debug ("Scanning %s to find audio codecs....", dirStr.c_str());
_debug ("CodecDescriptor: Scanning %s to find audio codecs....", dirStr.c_str());
DIR *dir = opendir (dirStr.c_str());
AudioCodec* audioCodec;
......@@ -248,15 +250,15 @@ AudioCodec* CodecDescriptor::instantiateCodec (AudioCodecType payload) {
AudioCodec* a = createCodec();
return a;
}
iter++;
}
return NULL;
}
AudioCodec* CodecDescriptor::getFirstCodecAvailable (void) {
CodecsMap::iterator iter = _CodecsMap.begin();
......@@ -349,7 +351,7 @@ bool CodecDescriptor::isCodecLoaded (int payload) {
std::vector <std::string> CodecDescriptor::getCodecSpecifications (const int32_t& payload) {
_warn ("Gathering codec specifications for payload %i", payload);
_debug ("CodecDescriptor: Gathering codec specifications for payload %i", payload);
std::vector<std::string> v;
std::stringstream ss;
......
......@@ -107,6 +107,9 @@ class Speex : public AudioCodec
speex_bits_destroy (&_speex_enc_bits);
speex_encoder_destroy (_speex_enc_state);
_speex_enc_state = 0;
speex_preprocess_state_destroy( _preprocess_state);
_preprocess_state = NULL;
}
virtual int codecDecode (short *dst, unsigned char *src, unsigned int size) {
......
......@@ -106,6 +106,9 @@ class Speex : public AudioCodec
speex_bits_destroy (&_speex_enc_bits);
speex_encoder_destroy (_speex_enc_state);
_speex_enc_state = 0;
speex_preprocess_state_destroy( _preprocess_state);
_preprocess_state = NULL;
}
virtual int codecDecode (short *dst, unsigned char *src, unsigned int size) {
......
......@@ -105,6 +105,9 @@ class Speex : public AudioCodec
speex_bits_destroy (&_speex_enc_bits);
speex_encoder_destroy (_speex_enc_state);
_speex_enc_state = 0;
speex_preprocess_state_destroy( _preprocess_state);
_preprocess_state = NULL;
}
virtual int codecDecode (short *dst, unsigned char *src, unsigned int size) {
......
......@@ -65,7 +65,6 @@ bool MainBuffer::createCallIDSet (CallID set_id)
CallIDSet* newCallIDSet = new CallIDSet;
_callIDMap.insert (pair<CallID, CallIDSet*> (set_id, newCallIDSet));
// _callIDMap[set_id] = new CallIDSet;
return true;
......@@ -79,6 +78,7 @@ bool MainBuffer::removeCallIDSet (CallID set_id)
if (callid_set != NULL) {
if (_callIDMap.erase (set_id) != 0) {
delete callid_set; callid_set = NULL;
return true;
} else {
_debug ("removeCallIDSet error while removing callid set %s!", set_id.c_str());
......@@ -146,13 +146,14 @@ bool MainBuffer::removeRingBuffer (CallID call_id)
if (ring_buffer != NULL) {
if (_ringBufferMap.erase (call_id) != 0) {
delete ring_buffer;
return true;
} else {
_debug ("removeRingBuffer error while deleting ringbuffer %s!", call_id.c_str());
_error ("BufferManager: Error: Fail to delete ringbuffer %s!", call_id.c_str());
return false;
}
} else {
_debug ("removeRingBuffer error ringbuffer %s does not exist!", call_id.c_str());
_debug ("BufferManager: Error: Ringbuffer %s does not exist!", call_id.c_str());
return true;
}
}
......
......@@ -51,9 +51,9 @@ class CallManager
* you will have to implement them in your ObjectAdaptor
*/
/* Call related methods */
/* Call related methods */
void placeCall( const std::string& accountID, const std::string& callID, const std::string& to );
void placeCallFirstAccount( const std::string& callID, const std::string& to );
void placeCallFirstAccount( const std::string& callID, const std::string& to );
void refuse( const std::string& callID );
void accept( const std::string& callID );
......@@ -61,12 +61,12 @@ class CallManager
void hold( const std::string& callID );
void unhold( const std::string& callID );
void transfert( const std::string& callID, const std::string& to );
std::map< std::string, std::string > getCallDetails( const std::string& callID );
std::map< std::string, std::string > getCallDetails( const std::string& callID );
std::vector< std::string > getCallList (void);
std::string getCurrentCallID( );
std::string getCurrentCallID( );
/* Conference related methods */
void joinParticipant( const std::string& sel_callID, const std::string& drag_callID );
/* Conference related methods */
void joinParticipant( const std::string& sel_callID, const std::string& drag_callID );
void addParticipant( const std::string& callID, const std::string& confID );
void addMainParticipant( const std::string& confID );
void detachParticipant( const std::string& callID );
......
......@@ -423,9 +423,13 @@
<method name="getCodecDetails" tp:name-for-bindings="getCodecDetails">
<tp:docstring>
Get specification details provided
codec's RTP payload.
</tp:docstring>
<arg type="i" name="payload" direction="in">
<tp:docstring>
A list of codec specification details:
Name, Samplerate, Bit rate, Bandwidth.
</tp:docstring>
</arg>
<annotation name="com.trolltech.QtDBus.QtTypeName.Out0" value="VectorString"/>
......@@ -441,10 +445,14 @@
<annotation name="com.trolltech.QtDBus.QtTypeName.Out0" value="VectorString"/>
<arg type="s" name="accountID" direction="in">
<tp:docstring>
Currently activated codec listed as there
preference. This is the list used for
codec negotiation.
</tp:docstring>
</arg>
<arg type="as" name="list" direction="out">
<tp:docstring>
A list of codecs, identified by their RTP payload, delimited by '/'
</tp:docstring>
</arg>
</method>
......@@ -455,23 +463,25 @@
<annotation name="com.trolltech.QtDBus.QtTypeName.In0" value="VectorString"/>
<arg type="as" name="list" direction="in">
<tp:docstring>
Set the active codec list used for codec negotiation.
</tp:docstring>
</arg>
<arg type="s" name="accountID" direction="in">
<tp:docstring>
A list of codecs, identified by their RTP payload, delimited by '/'
</tp:docstring>
</arg>
</method>
<!-- Audio devices methods -->
<method name="getInputAudioPluginList" tp:name-for-bindings="getInputAudioPluginList">
<tp:docstring>
</tp:docstring>
<annotation name="com.trolltech.QtDBus.QtTypeName.Out0" value="VectorString"/>
<arg type="as" name="list" direction="out">
<tp:docstring>
</tp:docstring>
</arg>
</method>
......
......@@ -493,7 +493,7 @@ std::vector<std::string> ConfigurationManager::getActiveCodecList(
void ConfigurationManager::setActiveCodecList(
const std::vector<std::string>& list, const std::string& accountID) {
_debug ("ConfigurationManager::setActiveCodecList received");
_debug ("ConfigurationManager: Active codec list received");
Account *acc;
......@@ -504,9 +504,12 @@ void ConfigurationManager::setActiveCodecList(
}
}
// Audio devices related methods
std::vector<std::string> ConfigurationManager::getInputAudioPluginList() {
_debug("ConfigurationManager: Active codec list received");
std::vector<std::string> v;
v.push_back("default");
......@@ -516,6 +519,8 @@ std::vector<std::string> ConfigurationManager::getInputAudioPluginList() {
return v;
}
std::vector<std::string> ConfigurationManager::getOutputAudioPluginList() {
std::vector<std::string> v;
......@@ -526,6 +531,7 @@ std::vector<std::string> ConfigurationManager::getOutputAudioPluginList() {
return v;
}
void ConfigurationManager::setInputAudioPlugin(const std::string& audioPlugin) {
return Manager::instance().setInputAudioPlugin(audioPlugin);
}
......
......@@ -60,5 +60,13 @@ DBusManagerImpl::exit()
_dispatcher.leave();
delete _callManager;
delete _configurationManager;
delete _instanceManager;
#ifdef USE_NETWORKMANAGER
delete _networkManager;
#endif
}
......@@ -32,9 +32,18 @@ HistoryManager::HistoryManager ()
HistoryManager::~HistoryManager ()
{
HistoryItemMap::iterator iter = _history_items.begin();
HistoryItem * item;
while(iter != _history_items.end()){
item = iter->second;
delete item;
iter++;
}
// Clear the history map
_history_items.clear ();
}
int HistoryManager::load_history (int limit, std::string path)
......
......@@ -91,9 +91,10 @@ ManagerImpl::ManagerImpl (void) :
// never call if we use only the singleton...
ManagerImpl::~ManagerImpl (void) {
// terminate();
delete _cleaner;
_cleaner = 0;
_debug ("%s stop correctly.", PROGNAME);
delete _cleaner; _cleaner = NULL;
delete _history; _history = NULL;
_debug ("Manager: %s stop correctly.", PROGNAME);
}
void ManagerImpl::init () {
......@@ -104,7 +105,7 @@ void ManagerImpl::init () {
initVolume();
if (_exist == 0) {
_debug ("Cannot create config file in your home directory");
_warn ("Manager: Cannot create config file in your home directory");
}
initAudioDriver();
......@@ -119,11 +120,11 @@ void ManagerImpl::init () {
if (audiolayer != 0) {
unsigned int sampleRate = audiolayer->getSampleRate();
_debugInit ("Load Telephone Tone");
_debugInit ("Manager: Load telephone tone");
std::string country = getConfigString(PREFERENCES, ZONE_TONE);
_telephoneTone = new TelephoneTone(country, sampleRate);
_debugInit ("Loading DTMF key");
_debugInit ("Manager: Loading DTMF key");
_dtmfKey = new DTMF(sampleRate);
}
......@@ -135,23 +136,25 @@ void ManagerImpl::init () {
}
void ManagerImpl::terminate () {
_debug ("ManagerImpl::terminate ");
_debug ("Manager: Terminate ");
saveConfig();
unloadAccountMap();
_debug ("Unload DTMF Key ");
_debug ("Manager: Unload DTMF key");
delete _dtmfKey;
_debug ("Unload Audio Driver ");
delete _audiodriver;
_audiodriver = NULL;
_debug("Manager: Unload telephone tone");
delete _telephoneTone; _telephoneTone = NULL;
_debug ("Manager: Unload audio driver");
delete _audiodriver; _audiodriver = NULL;
_debug ("Unload Telephone Tone ");
delete _telephoneTone;
_telephoneTone = NULL;
_debug ("Manager: Unload telephone tone");
delete _telephoneTone; _telephoneTone = NULL;
_debug ("Unload Audio Codecs ");
_debug ("Manager: Unload audio codecs ");
_codecDescriptorMap.deleteHandlePointer();
}
......@@ -179,38 +182,6 @@ void ManagerImpl::switchCall (const CallID& id) {
ost::MutexLock m(_currentCallMutex);
_debug ("----- Switch current call id to %s -----", id.c_str());
_currentCallId2 = id;
/*
AudioLayer *al = getAudioDriver();
if (id != "") {
if(isConference(id)) {
Conference *conf;
ConferenceMap::iterator iter = _conferencemap.find(id);
if(iter != _conferencemap.end())
{
_debug(" set call recordable in audio layer");
conf = iter->second;
al->setRecorderInstance((Recordable*)conf);
}
}
else {
// set the recordable instance in audiolayer
AccountID account_id = getAccountFromCall(id);
Call *call = NULL;
call = getAccountLink (account_id)->getCall(id);
_debug(" set call recordable in audio layer");
al->setRecorderInstance((Recordable*)call);
}
}
*/
}
///////////////////////////////////////////////////////////////////////////////
......@@ -220,11 +191,12 @@ void ManagerImpl::switchCall (const CallID& id) {
bool ManagerImpl::outgoingCall (const std::string& account_id,
const CallID& call_id, const std::string& to) {
std::string pattern, to_cleaned;
Call::CallConfiguration callConfig;
SIPVoIPLink *siplink;
_debug ("ManagerImpl::outgoingCall(%s)", call_id.c_str());
_debug ("Manager: New outgoing call %s", call_id.c_str());
CallID current_call_id = getCurrentCallId();
......@@ -258,7 +230,7 @@ bool ManagerImpl::outgoingCall (const std::string& account_id,
}
if (callConfig == Call::IPtoIP) {
_debug (" outgoingCall: Start IP to IP call");
_debug ("Manager: Start IP to IP call");
/* We need to retrieve the sip voiplink instance */
siplink = SIPVoIPLink::instance("");
......@@ -273,16 +245,16 @@ bool ManagerImpl::outgoingCall (const std::string& account_id,
}
if (!accountExists(account_id)) {
_debug ("! Manager Error: Outgoing Call: account doesn't exist");
_error ("Manager: Error: Account doesn't exist in new outgoing call");
return false;
}
if (getAccountFromCall(call_id) != AccountNULL) {
_debug ("! Manager Error: Outgoing Call: call id already exists");
_error ("Manager: Error: Call id already exists in outgoing call");
return false;
}
_debug ("- Manager Action: Adding Outgoing Call %s on account %s", call_id.data(), account_id.data());
_debug ("Manager: Action: Adding Outgoing Call %s on account %s", call_id.data(), account_id.data());
associateCallToAccount(call_id, account_id);
......@@ -291,7 +263,7 @@ bool ManagerImpl::outgoingCall (const std::string& account_id,
return true;
} else {
callFailure(call_id);
_debug ("! Manager Error: An error occur, the call was not created");
_debug ("Manager: Error: An error occur, the call was not created");
}
return false;
......@@ -419,12 +391,11 @@ bool ManagerImpl::hangupCall (const CallID& call_id) {
else {
account_id = getAccountFromCall(call_id);
// Account may be NULL if call have not been sent yet
if (account_id == AccountNULL) {
_error ("Manager: Error: account id is NULL in hangup");
returnValue = false;
} else {
returnValue = getAccountLink(account_id)->hangup(call_id);
removeCallAccount(call_id);
}
......@@ -1066,11 +1037,26 @@ void ManagerImpl::joinParticipant (const CallID& call_id1, const CallID& call_id
_debug ("Manager: Join participants %s, %s", call_id1.c_str(), call_id2.c_str());
std::map<std::string, std::string> call1_details = getCallDetails(call_id1);
std::map<std::string, std::string> call2_details = getCallDetails(call_id2);
std::map<std::string, std::string>::iterator iter_details;
// Test if we have valid call ids
iter_details = call1_details.find("PEER_NUMBER");
if(iter_details->second == "Unknown") {
_error("Manager: Error: Id %s is not a valid call", call_id1.c_str());
return;
}
iter_details = call2_details.find("PEER_NUMBER");
if(iter_details->second == "Unknown") {
_error("Manager: Error: Id %s is not a valid call", call_id2.c_str());
return;
}
AccountID currentAccountId;
Call* call = NULL;
......@@ -1206,7 +1192,7 @@ void ManagerImpl::detachParticipant (const CallID& call_id,
}
void ManagerImpl::removeParticipant (const CallID& call_id) {
_debug ("ManagerImpl::removeParticipant(%s)", call_id.c_str());
_debug ("Manager: Remove participant %s", call_id.c_str());
// TODO: add conference_id as a second parameter
Conference* conf;
......@@ -1295,7 +1281,7 @@ void ManagerImpl::processRemainingParticipant (CallID current_call_id,
void ManagerImpl::joinConference (const CallID& conf_id1,
const CallID& conf_id2) {
_debug ("ManagerImpl::joinConference(%s, %s)", conf_id1.c_str(), conf_id2.c_str());
_debug ("Manager: Join conference %s, %s", conf_id1.c_str(), conf_id2.c_str());
ConferenceMap::iterator iter;
......@@ -1304,13 +1290,23 @@ void ManagerImpl::joinConference (const CallID& conf_id1,
iter = _conferencemap.find(conf_id1);
if (iter != _conferencemap.end())
if (iter != _conferencemap.end()) {
conf1 = iter->second;
}
else {
_error("Manager: Error: Not a valid conference ID");
return;
}
iter = _conferencemap.find(conf_id2);
if (iter != _conferencemap.end())
if (iter != _conferencemap.end()) {
conf2 = iter->second;
}
else {
_error("Manager: Error: Not a valid conference ID");
return;
}
ParticipantSet participants = conf1->getParticipantList();
......@@ -1769,12 +1765,11 @@ void ManagerImpl::connectionStatusNotification () {
* Multi Thread
*/
bool ManagerImpl::playATone (Tone::TONEID toneId) {
bool hasToPlayTone;
// AudioLoop *audioloop;
AudioLayer *audiolayer;
// unsigned int nbSamples;
_debug ("ManagerImpl::playATone");
// _debug ("Manager: Play tone %d", toneId);
hasToPlayTone = getConfigBool(SIGNALISATION, PLAY_TONES);
......@@ -1793,17 +1788,6 @@ bool ManagerImpl::playATone (Tone::TONEID toneId) {
_toneMutex.enterMutex();
_telephoneTone->setCurrentTone(toneId);
_toneMutex.leaveMutex();
/*
audioloop = getTelephoneTone();
nbSamples = audioloop->getSize();
SFLDataFormat buf[nbSamples];
if (audiolayer) {
audiolayer->putUrgent (buf, nbSamples);
} else
return false;
*/
}
return true;
......@@ -1826,10 +1810,6 @@ void ManagerImpl::stopTone () {
_telephoneTone->setCurrentTone(Tone::TONE_NULL);
}
_toneMutex.leaveMutex();
// for ringing tone..