Skip to content
Snippets Groups Projects
Commit 8e45d1d7 authored by Alexandre Savard's avatar Alexandre Savard
Browse files

#9833: handlingEvents_ must be initialized to true when starting iax thread

parent 54519120
No related branches found
No related tags found
No related merge requests found
......@@ -43,8 +43,7 @@
#include <dlfcn.h>
IAXVoIPLink::IAXVoIPLink(const std::string& accountID) :
evThread_(new EventThread(this))
, regSession_(NULL)
regSession_(NULL)
, nextRefreshStamp_(0)
, mutexIAX_()
, decData_()
......@@ -53,6 +52,7 @@ IAXVoIPLink::IAXVoIPLink(const std::string& accountID) :
, converter_(44100)
, initDone_(false)
, accountID_(accountID)
, evThread_(this)
{
srand(time(NULL)); // to get random number for RANDOM_PORT
}
......@@ -61,8 +61,6 @@ IAXVoIPLink::IAXVoIPLink(const std::string& accountID) :
IAXVoIPLink::~IAXVoIPLink()
{
handlingEvents_ = false;
delete evThread_;
regSession_ = NULL; // shall not delete it // XXX: but why?
terminate();
}
......@@ -75,8 +73,8 @@ IAXVoIPLink::init()
for (int port = IAX_DEFAULT_PORTNO, nbTry = 0; nbTry < 3 ; port = rand() % 64000 + 1024, nbTry++) {
if (iax_init(port) >= 0) {
handlingEvents_ = false;
evThread_->start();
handlingEvents_ = true;
evThread_.start();
initDone_ = true;
break;
}
......@@ -113,6 +111,7 @@ IAXVoIPLink::getEvent()
iax_event *event;
while ((event = iax_get_event(0)) != NULL) {
// If we received an 'ACK', libiax2 tells apps to ignore them.
if (event->etype == IAX_EVENT_NULL) {
iax_event_free(event);
......@@ -121,10 +120,12 @@ IAXVoIPLink::getEvent()
IAXCall *call = iaxFindCallBySession(event->session);
if (call)
if (call) {
iaxHandleCallEvent(event, call);
else if (event->session && event->session == regSession_)
}
else if (event->session && event->session == regSession_) {
iaxHandleRegReply(event); // This is a registration session, deal with it
}
else // We've got an event before it's associated with any call
iaxHandlePrecallEvent(event);
......@@ -208,6 +209,8 @@ IAXVoIPLink::getIAXCall(const std::string& id)
void
IAXVoIPLink::sendRegister(Account *a)
{
DEBUG("========================================= Send register");
IAXAccount *account = dynamic_cast<IAXAccount*>(a);
if (account->getHostname().empty())
......@@ -584,6 +587,8 @@ void IAXVoIPLink::iaxHandleVoiceEvent(iax_event* event, IAXCall* call)
*/
void IAXVoIPLink::iaxHandleRegReply(iax_event* event)
{
DEBUG("================== IAX REG REPLY");
IAXAccount *account = dynamic_cast<IAXAccount *>(Manager::instance().getAccount(accountID_));
if (event->etype != IAX_EVENT_REGREJ && event->etype != IAX_EVENT_REGACK)
......@@ -605,6 +610,8 @@ void IAXVoIPLink::iaxHandlePrecallEvent(iax_event* event)
std::string id;
int format;
DEBUG("================ HANDLE IAX PRECALL EVENT");
switch (event->etype) {
case IAX_EVENT_CONNECT:
id = Manager::instance().getNewCallID();
......
......@@ -33,20 +33,20 @@
#define IAXVOIPLINK_H
#include "voiplink.h"
#include <iax-client.h>
#include "audio/codecs/audiocodec.h" // for DEC_BUFFER_SIZE
#include "sfl_types.h"
#include "noncopyable.h"
#include "audio/samplerateconverter.h"
#include "eventthread.h"
#include <iax-client.h>
class EventThread;
class IAXCall;
class IAXAccount;
class AudioCodec;
class AudioLayer;
class IAXAccount;
/**
* @file iaxvoiplink.h
* @brief VoIPLink contains a thread that listen to external events
......@@ -234,9 +234,6 @@ class IAXVoIPLink : public VoIPLink {
*/
void iaxOutgoingInvite(IAXCall* call);
/** Threading object */
EventThread* evThread_;
/** registration session : 0 if not register */
iax_session* regSession_;
......@@ -264,6 +261,11 @@ class IAXVoIPLink : public VoIPLink {
bool initDone_;
const std::string accountID_;
/**
* Threading object
*/
EventThread evThread_;
};
#endif
......@@ -38,15 +38,13 @@
#include <map>
//////////////////////////////
/* PJSIP imports */
#include <pjsip.h>
#include <pjlib.h>
#include <pjsip_ua.h>
#include <pjlib-util.h>
#include <pjnath.h>
#include <pjnath/stun_config.h>
///////////////////////////////
#include "sipaccount.h"
#include "voiplink.h"
#include "siptransport.h"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment