Skip to content
Snippets Groups Projects
Commit 068128fc authored by Emmanuel Milou's avatar Emmanuel Milou
Browse files

Merge branch 'yun-pjsip' of ssh://milou@192.168.1.203/home/yun/release/sflphone into sip_dev

Conflicts:

	src/Makefile.am
parents 66e1a4dc 1213ca76
Branches
Tags
No related merge requests found
...@@ -133,12 +133,6 @@ SFLPHONE_LIBS="$SFLPHONE_LIBS $EXOSIP_LIBS" ...@@ -133,12 +133,6 @@ SFLPHONE_LIBS="$SFLPHONE_LIBS $EXOSIP_LIBS"
dnl Check for GNU ccRTP dnl Check for GNU ccRTP
PKG_PROG_PKG_CONFIG PKG_PROG_PKG_CONFIG
#Trying to set PJSIP using pkg-config
PKG_CHECK_MODULES(PJSIP, libpj, have_libpj=true, have_libpj=false)
if test "x${have_libpj}" = "xfalse" ; then
AC_MSG_ERROR([PJSIP not found. http://www.pjsip.org/download.htm])
fi
LIBOSIP2_OSIPLISTNOPOINTER_MIN_VERSION=3.0.0 LIBOSIP2_OSIPLISTNOPOINTER_MIN_VERSION=3.0.0
PKG_CHECK_MODULES([libosip2], [libosip2 >= ${LIBOSIP2_OSIPLISTNOPOINTER_MIN_VERSION}], PKG_CHECK_MODULES([libosip2], [libosip2 >= ${LIBOSIP2_OSIPLISTNOPOINTER_MIN_VERSION}],
[LIBOSIP2_CFLAGS=""], [LIBOSIP2_CFLAGS="-DLIBOSIP2_WITHPOINTER"]) [LIBOSIP2_CFLAGS=""], [LIBOSIP2_CFLAGS="-DLIBOSIP2_WITHPOINTER"])
......
...@@ -31,30 +31,18 @@ endif ...@@ -31,30 +31,18 @@ endif
ALSAFLAG= -lasound ALSAFLAG= -lasound
PULSEAUDIO_LIBS=-lpulse PULSEAUDIO_LIBS=-lpulse
PJSIP_LIBS = -L/usr/local/lib -lpjnath -lpjsua -lpjsip -lpjmedia -lpjsip-simple -lpjsip-ua -lpjmedia-codec -lpjlib-util -lpj
SUBDIRS = audio config dbus $(ZEROCONFDIR) #contact memmanager video mixer SUBDIRS = audio config dbus $(ZEROCONFDIR) #contact memmanager video mixer
sflphoned_SOURCES = \ sflphoned_SOURCES = eventthread.cpp main.cpp voiplink.cpp \
eventthread.cpp \ managerimpl.cpp observer.cpp samplerateconverter.cpp \
main.cpp \ account.cpp sipaccount.cpp accountcreator.cpp \
voiplink.cpp \ sipvoiplink.cpp call.cpp sipcall.cpp sipmanager.cpp \
managerimpl.cpp \ $(IAXSOURCES)
observer.cpp \
samplerateconverter.cpp \
account.cpp \
sipaccount.cpp \
accountcreator.cpp \
sipvoiplink.cpp \
call.cpp \
sipcall.cpp \
$(IAXSOURCES) \
sipmanager.cpp
sflphoned_CXXFLAGS = -DPREFIX=\"$(prefix)\" -DPROGSHAREDIR=\"${datadir}/sflphone\" $(ZEROCONFFLAGS) $(IAX_FLAGS) $(SFLPHONE_CFLAGS) $(SIP_CFLAGS) sflphoned_CXXFLAGS = -DPREFIX=\"$(prefix)\" -DPROGSHAREDIR=\"${datadir}/sflphone\" $(ZEROCONFFLAGS) $(IAX_FLAGS) $(SFLPHONE_CFLAGS) $(SIP_CFLAGS)
#sflphoned_LDFLAGS = -static #sflphoned_LDFLAGS = -static
sflphoned_LDADD = ./libsflphone.la $(SFLPHONE_LIBS) $(ZEROCONFLIB) $(LIB_DNSSD) $(IAX_LIBS) $(EXOSIP_LIBS) $(ALSAFLAG) $(PULSEAUDIO_LIBS) $(PJSIP_LIBS) sflphoned_LDADD = ./libsflphone.la $(SFLPHONE_LIBS) $(ZEROCONFLIB) $(LIB_DNSSD) $(IAX_LIBS) $(EXOSIP_LIBS) $(ALSAFLAG) $(PULSEAUDIO_LIBS)
AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/libs $(libccext2_CFLAGS) $(libccgnu2_CFLAGS) $(IAX_CFLAGS) $(USER_INCLUDES) $(libdbuscpp_CFLAGS) \ AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/libs $(libccext2_CFLAGS) $(libccgnu2_CFLAGS) $(IAX_CFLAGS) $(USER_INCLUDES) $(libdbuscpp_CFLAGS) \
-DCODECS_DIR=\""$(sflcodecdir)"\" -DCODECS_DIR=\""$(sflcodecdir)"\"
-DENABLE_TRACE -DENABLE_TRACE
...@@ -67,8 +55,7 @@ libsflphone_la_LIBADD = \ ...@@ -67,8 +55,7 @@ libsflphone_la_LIBADD = \
./audio/libaudio.la \ ./audio/libaudio.la \
./dbus/libdbus.la \ ./dbus/libdbus.la \
./config/libconfig.la \ ./config/libconfig.la \
$(IAX_LIBS) \ $(IAX_LIBS)
$(PJSIP_LIBS)
libsflphone_la_SOURCES = libsflphone_la_SOURCES =
...@@ -91,3 +78,7 @@ noinst_HEADERS = \ ...@@ -91,3 +78,7 @@ noinst_HEADERS = \
$(IAXHEADERS) \ $(IAXHEADERS) \
sipmanager.h sipmanager.h
#./contact/libcontact.la \
# ./memmanager/libmemmanager.la \
# ./mixer/libmixer.la \
# ./video/libvideo.la
...@@ -166,6 +166,12 @@ void ManagerImpl::terminate() ...@@ -166,6 +166,12 @@ void ManagerImpl::terminate()
unloadAccountMap(); unloadAccountMap();
if(_sipManagerInitlized) {
delete _sipManager;
_sipManager = NULL;
_sipManagerInitlized = false;
}
_debug("Unload DTMF Key\n"); _debug("Unload DTMF Key\n");
delete _dtmfKey; delete _dtmfKey;
...@@ -288,12 +294,14 @@ ManagerImpl::hangupCall(const CallID& id) ...@@ -288,12 +294,14 @@ ManagerImpl::hangupCall(const CallID& id)
} }
bool returnValue = getAccountLink(accountid)->hangup(id); bool returnValue = getAccountLink(accountid)->hangup(id);
_debug("After voip link hungup!\n");
removeCallAccount(id); removeCallAccount(id);
switchCall(""); switchCall("");
if( getConfigInt( PREFERENCES , CONFIG_PA_VOLUME_CTRL ) ) if( getConfigInt( PREFERENCES , CONFIG_PA_VOLUME_CTRL ) )
_audiodriver->restorePulseAppsVolume(); _audiodriver->restorePulseAppsVolume();
_debug("Before hungup return!\n");
return returnValue; return returnValue;
} }
...@@ -2080,7 +2088,20 @@ ManagerImpl::addAccount(const std::map< ::DBus::String, ::DBus::String >& detail ...@@ -2080,7 +2088,20 @@ ManagerImpl::addAccount(const std::map< ::DBus::String, ::DBus::String >& detail
/** @todo Verify the uniqueness, in case a program adds accounts, two in a row. */ /** @todo Verify the uniqueness, in case a program adds accounts, two in a row. */
if (accountType == "SIP") { if (accountType == "SIP") {
if(!_sipManagerInitlized) {
// Initialize the SIP Manager
_sipManager = new SIPManager();
_sipManagerInitlized = true;
}
newAccount = AccountCreator::createAccount(AccountCreator::SIP_ACCOUNT, newAccountID); newAccount = AccountCreator::createAccount(AccountCreator::SIP_ACCOUNT, newAccountID);
// Determine whether to use stun for the current account or not
int useStun = Manager::instance().getConfigInt(newAccount->getAccountID(),SIP_USE_STUN);
if(useStun == 1) {
_sipManager->setStunServer(Manager::instance().getConfigString(newAccount->getAccountID(), SIP_STUN_SERVER).data());
}
} }
else if (accountType == "IAX") { else if (accountType == "IAX") {
newAccount = AccountCreator::createAccount(AccountCreator::IAX_ACCOUNT, newAccountID); newAccount = AccountCreator::createAccount(AccountCreator::IAX_ACCOUNT, newAccountID);
...@@ -2193,7 +2214,7 @@ ManagerImpl::loadAccountMap() ...@@ -2193,7 +2214,7 @@ ManagerImpl::loadAccountMap()
accountType = getConfigString(*iter, CONFIG_ACCOUNT_TYPE); accountType = getConfigString(*iter, CONFIG_ACCOUNT_TYPE);
if (accountType == "SIP") { if (accountType == "SIP") {
if(!_sipManagerInitlized) { if(!_sipManagerInitlized) {
// Initialize the SIP Link Manager // Initialize the SIP Manager
_sipManager = new SIPManager(); _sipManager = new SIPManager();
_sipManagerInitlized = true; _sipManagerInitlized = true;
} }
......
...@@ -1032,6 +1032,8 @@ private: ...@@ -1032,6 +1032,8 @@ private:
/** Whether the _SIPManager has been initialized */ /** Whether the _SIPManager has been initialized */
bool _sipManagerInitlized; bool _sipManagerInitlized;
bool _sipThreadStop;
#ifdef TEST #ifdef TEST
bool testCallAccountMap(); bool testCallAccountMap();
bool testAccountMap(); bool testAccountMap();
...@@ -1042,6 +1044,10 @@ public: ...@@ -1042,6 +1044,10 @@ public:
* Retuun the instance of sip manager * Retuun the instance of sip manager
*/ */
SIPManager *getSipManager(); SIPManager *getSipManager();
void setSipThreadStatus(bool status) {_sipThreadStop = status;}
bool getSipThreadStatus() {return _sipThreadStop;}
}; };
#endif // __MANAGER_H__ #endif // __MANAGER_H__
...@@ -35,6 +35,8 @@ SIPCall::SIPCall(const CallID& id, Call::CallType type) : Call(id, type) ...@@ -35,6 +35,8 @@ SIPCall::SIPCall(const CallID& id, Call::CallType type) : Call(id, type)
_cid = 0; _cid = 0;
_did = 0; _did = 0;
_tid = 0; _tid = 0;
_xferSub = NULL;
_invSession = NULL;
} }
SIPCall::~SIPCall() SIPCall::~SIPCall()
......
src/sipcall.h 100644 → 100755
...@@ -30,6 +30,8 @@ struct pjmedia_sdp_session; ...@@ -30,6 +30,8 @@ struct pjmedia_sdp_session;
struct pjmedia_sdp_media; struct pjmedia_sdp_media;
struct pjmedia_sdp_neg; struct pjmedia_sdp_neg;
struct pj_pool_t; struct pj_pool_t;
struct pjsip_inv_session;
struct pjsip_evsub;
class AudioCodec; class AudioCodec;
...@@ -152,6 +154,12 @@ class SIPCall : public Call ...@@ -152,6 +154,12 @@ class SIPCall : public Call
*/ */
bool createInitialOffer(pj_pool_t *pool); bool createInitialOffer(pj_pool_t *pool);
void setXferSub(pjsip_evsub* sub) {_xferSub = sub;}
pjsip_evsub *getXferSub() {return _xferSub;}
void setInvSession(pjsip_inv_session* inv) {_invSession = inv;}
pjsip_inv_session *getInvSession() {return _invSession;}
private: private:
/** No longer being used */ /** No longer being used */
...@@ -232,6 +240,9 @@ class SIPCall : public Call ...@@ -232,6 +240,9 @@ class SIPCall : public Call
/** IP address */ /** IP address */
std::string _ipAddr; std::string _ipAddr;
pjsip_evsub *_xferSub;
pjsip_inv_session *_invSession;
}; };
#endif #endif
This diff is collapsed.
...@@ -24,8 +24,7 @@ ...@@ -24,8 +24,7 @@
#include <pjsip.h> #include <pjsip.h>
#include <pjlib-util.h> #include <pjlib-util.h>
#include <pjlib.h> #include <pjlib.h>
//#include <pjnath/stun_config.h> #include <pjnath/stun_config.h>
#include <pjnath.h>
#include <pjsip_simple.h> #include <pjsip_simple.h>
#include <pjsip_ua.h> #include <pjsip_ua.h>
#include <pjmedia/sdp.h> #include <pjmedia/sdp.h>
...@@ -71,8 +70,6 @@ private: ...@@ -71,8 +70,6 @@ private:
static SIPManager *_current; static SIPManager *_current;
static pjsip_inv_session* _invSession;
struct AccBaseInfo { struct AccBaseInfo {
std::string userName; std::string userName;
std::string server; std::string server;
...@@ -83,7 +80,9 @@ private: ...@@ -83,7 +80,9 @@ private:
typedef std::vector<AccBaseInfo *> AccBaseInfoList; typedef std::vector<AccBaseInfo *> AccBaseInfoList;
AccBaseInfoList _accBaseInfoList; AccBaseInfoList _accBaseInfoList;
/* Sleep with polling */
void busy_sleep(unsigned msec);
void sipDestory();
public: public:
SIPManager(); SIPManager();
~SIPManager(); ~SIPManager();
...@@ -99,12 +98,12 @@ public: ...@@ -99,12 +98,12 @@ public:
int createUDPServer(); int createUDPServer();
/** Set whether it will use stun server */ /** Set whether it will use stun server */
void setStunServer(const char *server); //{_stunHost = pj_str(server); _useStun = true;}; void setStunServer(const char *server);
pj_str_t getStunServer() {return _stunHost;} pj_str_t getStunServer() {return _stunHost;}
//bool addAccount(AccountID id, pjsip_regc *regc, const pj_str_t& registrar, pj_str_t& user, pjsip_cred_info& cred, int& timeout); bool addAccount(AccountID id, pjsip_regc **regc, const std::string& server, const std::string& user, const std::string& passwd, const int& timeout);
bool addAccount(AccountID id, pjsip_regc *regc, const std::string& server, const std::string& user, const std::string& passwd, const int& timeout); bool removeAccount(pjsip_regc *regc);
pj_str_t buildContact(char *userName); pj_str_t buildContact(char *userName);
...@@ -125,15 +124,17 @@ public: ...@@ -125,15 +124,17 @@ public:
int answer(SIPCall* call); int answer(SIPCall* call);
bool hangup(); bool hangup(SIPCall* call);
bool refuse(); bool refuse(SIPCall* call);
bool onhold(SIPCall *call); bool onhold(SIPCall *call);
bool offhold(SIPCall *call); bool offhold(SIPCall *call);
bool transfer(SIPCall *call, const std::string& to); bool transfer(SIPCall *call, const std::string& to);
void onCallTransfered(pjsip_inv_session *inv, pjsip_rx_data *rdata);
bool makeOutgoingCall(const std::string& to, SIPCall* call, const AccountID& id); bool makeOutgoingCall(const std::string& to, SIPCall* call, const AccountID& id);
pj_pool_t *getAppPool() {return _pool;} pj_pool_t *getAppPool() {return _pool;}
static pj_bool_t mod_on_rx_request(pjsip_rx_data *rdata); static pj_bool_t mod_on_rx_request(pjsip_rx_data *rdata);
...@@ -141,6 +142,7 @@ public: ...@@ -141,6 +142,7 @@ public:
static pj_bool_t options_on_rx_request(pjsip_rx_data *rdata) {return PJ_SUCCESS;} static pj_bool_t options_on_rx_request(pjsip_rx_data *rdata) {return PJ_SUCCESS;}
static void regc_cb(struct pjsip_regc_cbparam *param); static void regc_cb(struct pjsip_regc_cbparam *param);
static void xfer_func_cb( pjsip_evsub *sub, pjsip_event *event); static void xfer_func_cb( pjsip_evsub *sub, pjsip_event *event);
static void xfer_svr_cb(pjsip_evsub *sub, pjsip_event *event);
static void call_on_media_update( pjsip_inv_session *inv, pj_status_t status) {} static void call_on_media_update( pjsip_inv_session *inv, pj_status_t status) {}
static void call_on_state_changed( pjsip_inv_session *inv, pjsip_event *e); static void call_on_state_changed( pjsip_inv_session *inv, pjsip_event *e);
static void call_on_forked(pjsip_inv_session *inv, pjsip_event *e); static void call_on_forked(pjsip_inv_session *inv, pjsip_event *e);
......
...@@ -457,15 +457,14 @@ SIPVoIPLink::sendRegister() ...@@ -457,15 +457,14 @@ SIPVoIPLink::sendRegister()
_regc = NULL; _regc = NULL;
} }
_bRegister = true;
int expire_value = Manager::instance().getRegistrationExpireValue(); int expire_value = Manager::instance().getRegistrationExpireValue();
_debug("SIP Registration Expire Value = %i\n" , expire_value); _debug("SIP Registration Expire Value = %i\n" , expire_value);
setRegistrationState(Trying); setRegistrationState(Trying);
SIPManager *sipManager = Manager::instance().getSipManager(); return Manager::instance().getSipManager()->addAccount(id, &_regc, _server, _authname, _password, expire_value);
_debug("Get manager of sip\n");
return sipManager->addAccount(id, _regc, _server, _authname, _password, expire_value);
} }
std::string std::string
...@@ -497,33 +496,10 @@ bool ...@@ -497,33 +496,10 @@ bool
SIPVoIPLink::sendUnregister() SIPVoIPLink::sendUnregister()
{ {
_debug("SEND UNREGISTER for account %s\n" , getAccountID().c_str()); _debug("SEND UNREGISTER for account %s\n" , getAccountID().c_str());
if ( _eXosipRegID == EXOSIP_ERROR_STD) return false;
int eXosipErr = EXOSIP_ERROR_NO;
osip_message_t *reg = NULL;
eXosip_lock();
eXosipErr = eXosip_register_build_register (_eXosipRegID, 0, &reg);
eXosip_unlock();
if (eXosipErr != EXOSIP_ERROR_NO) {
_debug("! SIP Failure: Unable to build registration for sendUnregister");
return false;
}
eXosip_lock(); _bRegister = false;
_debug("< Sending REGISTER (expire=0)\n");
eXosipErr = eXosip_register_send_register (_eXosipRegID, reg);
if (eXosipErr == EXOSIP_ERROR_BUILDING) {
_debug("! SIP Failure: Cannot build registration (unregister), check the setup\n");
eXosip_unlock();
return false;
}
if (eXosipErr == EXOSIP_ERROR_STD) {
_debug("! SIP Failure: Unable to send registration (unregister)\n");
}
_eXosipRegID = EXOSIP_ERROR_STD;
eXosip_unlock();
Manager::instance().getSipManager()->removeAccount(_regc);
return true; return true;
} }
...@@ -592,7 +568,7 @@ SIPVoIPLink::hangup(const CallID& id) ...@@ -592,7 +568,7 @@ SIPVoIPLink::hangup(const CallID& id)
//eXosip_lock(); //eXosip_lock();
//eXosip_call_terminate(call->getCid(), call->getDid()); //eXosip_call_terminate(call->getCid(), call->getDid());
//eXosip_unlock(); //eXosip_unlock();
Manager::instance().getSipManager()->hangup(); Manager::instance().getSipManager()->hangup(call);
// Release RTP thread // Release RTP thread
if (Manager::instance().isCurrentCall(id)) { if (Manager::instance().isCurrentCall(id)) {
...@@ -816,7 +792,7 @@ SIPVoIPLink::refuse (const CallID& id) ...@@ -816,7 +792,7 @@ SIPVoIPLink::refuse (const CallID& id)
return false; return false;
} }
Manager::instance().getSipManager()->refuse(); Manager::instance().getSipManager()->refuse(call);
/*osip_message_t *answerMessage = NULL; /*osip_message_t *answerMessage = NULL;
eXosip_lock(); eXosip_lock();
// not BUSY.. where decline the invitation! // not BUSY.. where decline the invitation!
...@@ -1439,8 +1415,10 @@ SIPVoIPLink::SIPCallClosed(SIPCall *call) ...@@ -1439,8 +1415,10 @@ SIPVoIPLink::SIPCallClosed(SIPCall *call)
_debug("* SIP Info: Stopping AudioRTP when closing\n"); _debug("* SIP Info: Stopping AudioRTP when closing\n");
_audiortp->closeRtpSession(); _audiortp->closeRtpSession();
} }
_debug("After close RTP\n");
Manager::instance().peerHungupCall(id); Manager::instance().peerHungupCall(id);
removeCall(id); removeCall(id);
_debug("After remove call ID\n");
} }
void void
......
...@@ -204,7 +204,7 @@ class SIPVoIPLink : public VoIPLink ...@@ -204,7 +204,7 @@ class SIPVoIPLink : public VoIPLink
void setSipServer(const std::string& sipServer); void setSipServer(const std::string& sipServer);
//void setS bool isRegister() {return _bRegister;}
public: public:
...@@ -446,6 +446,7 @@ class SIPVoIPLink : public VoIPLink ...@@ -446,6 +446,7 @@ class SIPVoIPLink : public VoIPLink
private: private:
pjsip_regc *_regc; pjsip_regc *_regc;
std::string _server; std::string _server;
bool _bRegister;
}; };
#endif #endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment