Skip to content
Snippets Groups Projects
Commit 474b2d6c authored by Tristan Matthews's avatar Tristan Matthews
Browse files

* #6554: cleanup in iaxvoiplink

parent 71920bb2
Branches
Tags
No related merge requests found
......@@ -43,7 +43,6 @@ class VoIPLink;
class EventThread : public ost::Thread
{
public:
/**
* Thread constructor
......
......@@ -159,7 +159,7 @@ IAXAccount::unregisterVoIPLink()
{
try {
link_->sendUnregister (this);
link_->terminate();
dynamic_cast<IAXVoIPLink*>(link_)->terminate();
}
catch (const VoipLinkException &e) {
_error("IAXAccount: %s", e.what());
......
This diff is collapsed.
......@@ -183,10 +183,6 @@ class IAXVoIPLink : public VoIPLink
virtual bool sendTextMessage (sfl::InstantMessaging *module, const std::string& callID, const std::string& message, const std::string& from);
bool isContactPresenceSupported() {
return false;
}
/**
* Return the codec protocol used for this call
* @param id The call identifier
......@@ -266,40 +262,39 @@ class IAXVoIPLink : public VoIPLink
bool iaxOutgoingInvite (IAXCall* call);
/** Threading object */
EventThread* _evThread;
EventThread* evThread_;
/** registration session : 0 if not register */
struct iax_session* _regSession;
struct iax_session* regSession_;
/** Timestamp of when we should refresh the registration up with
* the registrar. Values can be: EPOCH timestamp, 0 if we want no registration, 1
* to force a registration. */
int _nextRefreshStamp;
int nextRefreshStamp_;
/** Mutex for iax_ calls, since we're the only one dealing with the incorporated
* iax_stuff inside this class. */
ost::Mutex _mutexIAX;
ost::Mutex mutexIAX_;
/** Connection to audio card/device */
AudioLayer* audiolayer;
AudioLayer* audiolayer_;
/** encoder/decoder/resampler buffers */
SFLDataFormat decData[DEC_BUFFER_SIZE];
SFLDataFormat resampledData[DEC_BUFFER_SIZE];
unsigned char encodedData[DEC_BUFFER_SIZE];
int converterSamplingRate_;
/** Sample rate converter object */
SamplerateConverter* converter;
int converterSamplingRate;
SamplerateConverter* converter_;
/** Whether init() was called already or not
* This should be used in init() and terminate(), to
* indicate that init() was called, or reset by terminate().
*/
bool _initDone;
bool initDone_;
const std::string _accountID;
const std::string accountID_;
};
#endif
......@@ -34,27 +34,25 @@
#include "voiplink.h"
#include "manager.h"
VoIPLink::VoIPLink () : _localPort (0)
{
}
VoIPLink::~VoIPLink (void)
{
clearCallMap();
ost::MutexLock m(_callMapMutex);
for (CallMap::const_iterator iter = _callMap.begin();
iter != _callMap.end(); ++iter)
delete iter->second;
_callMap.clear();
}
bool VoIPLink::addCall (Call* call)
void VoIPLink::addCall (Call* call)
{
if (call) {
if (getCall (call->getCallId()) == NULL) {
if (call and getCall (call->getCallId()) == NULL) {
ost::MutexLock m(_callMapMutex);
_callMap[call->getCallId()] = call;
}
}
return false;
}
void VoIPLink::removeCall (const std::string& id)
{
ost::MutexLock m(_callMapMutex);
......@@ -70,26 +68,8 @@ Call* VoIPLink::getCall (const std::string& id)
ost::MutexLock m(_callMapMutex);
CallMap::iterator iter = _callMap.find (id);
if (iter != _callMap.end()) {
if (iter != _callMap.end())
return iter->second;
}
else
return NULL;
}
bool VoIPLink::clearCallMap()
{
ost::MutexLock m (_callMapMutex);
CallMap::iterator iter = _callMap.begin();
while (iter != _callMap.end()) {
// if (iter) ?
delete iter->second;
iter->second = 0;
iter++;
}
_callMap.clear();
return true;
}
......@@ -60,11 +60,6 @@ class VoipLinkException : public std::runtime_error
class VoIPLink
{
public:
/**
* Constructor
*/
VoIPLink ();
/**
* Virtual destructor
*/
......@@ -83,12 +78,6 @@ class VoIPLink
*/
virtual void init (void) = 0;
/**
* Virtual method
* Delete link-related stuff like calls
*/
virtual void terminate (void) = 0;
/**
* Virtual method
* Build and send account registration request
......@@ -200,18 +189,7 @@ class VoIPLink
* @param call A call pointer with a unique pointer
* @return bool True if the call was unique and added
*/
bool addCall (Call* call);
/** Remove a call from the call map (protected by mutex)
* @param id A Call ID
*/
void removeCall (const std::string& id);
/**
* Remove all the call from the map
* @return bool True on success
*/
bool clearCallMap();
void addCall (Call* call);
/**
* Get the call pointer from the call map (protected by mutex)
......@@ -227,8 +205,10 @@ class VoIPLink
/** Mutex to protect call map */
ost::Mutex _callMapMutex;
/** Get local listening port (5060 for SIP, ...) */
unsigned int _localPort;
/** Remove a call from the call map (protected by mutex)
* @param id A Call ID
*/
void removeCall (const std::string& id);
};
#endif // __VOIP_LINK_H__
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment