Commit 9ca46a7a authored by Erwan Croze's avatar Erwan Croze 👋🏻

Implement conference in flexisip

[--force]
parent ff436bed
......@@ -31,3 +31,15 @@
[submodule "submodules/linphone"]
path = submodules/linphone
url = gitosis@git.linphone.org:linphone-private.git
[submodule "submodules/externals/xerces-c"]
path = submodules/externals/xerces-c
url = git://git.linphone.org/xerces-c.git
[submodule "submodules/externals/libxsd"]
path = submodules/externals/libxsd
url = git://git.linphone.org/libxsd
[submodule "submodules/belr"]
path = submodules/belr
url = git://git.linphone.org/belr
[submodule "submodules/externals/libxml2"]
path = submodules/externals/libxml2
url = git://git.linphone.org/libxml2
......@@ -234,8 +234,8 @@ if(ENABLE_CONFERENCE)
include("${EP_linphone_CONFIG_DIR}/LinphoneConfig.cmake")
include("${EP_linphone_CONFIG_DIR}/wrappers/cpp/LinphoneCxxConfig.cmake")
else ()
#find_package(Linphone REQUIRED)
#find_package(LinphoneCxx REQUIRED)
find_package(Linphone REQUIRED)
find_package(LinphoneCxx REQUIRED)
endif()
endif()
......
......@@ -20,7 +20,7 @@
#
############################################################################
set(FLEXISIP_LIBS ${ORTP_LIBRARIES} ${SOFIASIPUA_LIBRARIES} ${BCTOOLBOX_CORE_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
set(FLEXISIP_LIBS ${ORTP_LIBRARIES} ${SOFIASIPUA_LIBRARIES} ${LINPHONECXX_LIBRARIES} ${BCTOOLBOX_CORE_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
set(FLEXISIP_INCLUDES)
......
......@@ -18,24 +18,79 @@
#include "conference-server.hh"
#include "configmanager.hh"
using namespace flexisip;
using namespace linphone;
using namespace std;
ConferenceServer::ConferenceServer() : ServiceServer() {
}
ConferenceServer::~ConferenceServer() {
ConferenceServer::ConferenceServer(bool withThread) : ServiceServer(withThread) {
}
ConferenceServer::~ConferenceServer() {}
void ConferenceServer::_init() {
// Set config, transport, create core, etc
shared_ptr<Transports> cTransport = Factory::get()->createTransports();
string transport = "";
cTransport->setTcpPort(-1);
// Flexisip config
auto config = GenericManager::get()->getRoot()->get<GenericStruct>("conference-server");
transport = config->get<ConfigString>("transport")->read();
if (transport.length() > 0) {
SofiaAutoHome mHome;
sip_contact_t *sipContact = sip_contact_make(mHome.home(), transport.c_str());
if (sipContact->m_url->url_port != NULL) {
int port;
istringstream istr;
istr.str(sipContact->m_url->url_port);
istr >> port;
cTransport->setTcpPort(port);
}
}
// Core
this->mCore = Factory::get()->createCore(nullptr, "", "");
this->mCore->getConfig()->setBool("misc", "conference_server_enabled", 1);
this->mCore->setTransports(cTransport);
}
void ConferenceServer::_run() {
this->mCore->iterate();
}
void ConferenceServer::_stop() {
}
SofiaAutoHome ConferenceServer::mHome;
void ConferenceServer::bindConference() {
auto config = GenericManager::get()->getRoot()->get<GenericStruct>("conference-server");
if (config != nullptr && config->get<ConfigBoolean>("enabled")->read()) {
string transport_factory = config->get<ConfigString>("conference-factory-uri")->read();
sip_contact_t *sipContact = sip_contact_make(mHome.home(), transport_factory.c_str());
RegistrarDb::get()->bind(sipContact->m_url, sipContact, "CONFERENCE", 0,
NULL, NULL, NULL, TRUE, std::numeric_limits<int>::max(), FALSE, 0, NULL);
}
}
ConferenceServer::Init ConferenceServer::sStaticInit;
ConferenceServer::Init::Init() {
ConfigItemDescriptor items[] = {
{Boolean, "enabled", "Enable conference server", "true"},
{String, "transport",
"uri where the conference server must listen.",
"sip:127.0.0.1:6064"},
{String, "conference-factory-uri",
"uri where the client must ask to create a conference.",
"sip:conference-factory@sip1.linphone.org"},
config_item_end};
GenericStruct *s = new GenericStruct("conference-server", "Flexisip conference server parameters.", 0);
GenericManager::get()->getRoot()->addChild(s);
s->addChildrenValues(items);
}
......@@ -19,17 +19,35 @@
#ifndef __flexisip__conference_server__
#define __flexisip__conference_server__
#include "../service-server.hh"
#include "service-server.hh"
#include <registrardb.hh>
#include "linphone++/linphone.hh"
namespace flexisip {
class ConferenceServer : public ServiceServer {
public:
ConferenceServer();
ConferenceServer(bool withThread);
~ConferenceServer();
void _init();
void _run();
void _stop();
static void bindConference();
private:
std::shared_ptr<linphone::Core> mCore;
// Used to declare the service configuration
class Init {
public:
Init();
};
static Init sStaticInit;
static SofiaAutoHome mHome;
};
} // namespace flexisip
......
......@@ -35,6 +35,7 @@
#include <sofia-sip/su_md5.h>
using namespace std;
using namespace flexisip;
bool ConfigValueListener::sDirty = false;
ConfigValueListener::~ConfigValueListener() {
......
......@@ -61,6 +61,9 @@ typedef unsigned long oid;
#endif /* ENABLE_SNMP */
extern oid company_id;
namespace flexisip {
struct LpConfig;
};
#include "expressionparser.hh"
#include "utils/flexisip-exception.hh"
......@@ -260,7 +263,7 @@ class GenericEntry {
const std::string &syntax, const std::string &spacing) const;
GenericEntry(const std::string &name, GenericValueType type, const std::string &help, oid oid_index = 0);
static std::string escapeDoubleQuotes(const std::string &str);
Oid *mOid;
const std::string mName;
bool mReadOnly;
......@@ -578,7 +581,7 @@ class FileConfigReader {
static void onUnreadItem(void *p, const char *secname, const char *key, int lineno);
void onUnreadItem(const char *secname, const char *key, int lineno);
GenericStruct *mRoot;
struct _LpConfig *mCfg;
flexisip::LpConfig *mCfg;
bool mHaveUnreads;
};
......
......@@ -35,22 +35,24 @@
using namespace std;
typedef struct _LpItem {
namespace flexisip {
struct LpItem {
char *key;
char *value;
int is_read;
int lineno;
} LpItem;
};
typedef struct _LpSection {
struct LpSection {
char *name;
list<_LpItem *> items;
} LpSection;
list<LpItem *> items;
};
struct _LpConfig {
struct LpConfig {
FILE *file;
char *filename;
list<_LpSection *> sections;
list<LpSection *> sections;
int modified;
int readonly;
};
......@@ -108,7 +110,7 @@ static bool_t is_first_char(const char *start, const char *pos) {
struct LpSectionComp {
explicit LpSectionComp(const char *name) : name(name) {
}
inline bool operator()(const _LpSection *sec) const {
inline bool operator()(const LpSection *sec) const {
return strcasecmp(sec->name, name) == 0;
}
......@@ -123,7 +125,7 @@ LpSection *lp_config_find_section(LpConfig *lpconfig, const char *name) {
struct LpItemComp {
explicit LpItemComp(const char *key) : key(key) {
}
inline bool operator()(const _LpItem *item) const {
inline bool operator()(const LpItem *item) const {
return strcasecmp(item->key, key) == 0;
}
......@@ -408,3 +410,4 @@ void lp_config_clean_section(LpConfig *lpconfig, const char *section) {
int lp_config_needs_commit(const LpConfig *lpconfig) {
return lpconfig->modified > 0;
}
};//namespace
......@@ -25,6 +25,7 @@
#ifndef LPCONFIG_H
#define LPCONFIG_H
namespace flexisip {
/**
* The LpConfig object is used to manipulate a configuration file.
*
......@@ -43,11 +44,7 @@
* enabled=1
* @endcode
**/
typedef struct _LpConfig LpConfig;
#ifdef __cplusplus
extern "C" {
#endif
struct LpConfig;
LpConfig * lp_config_new(const char *filename);
int lp_config_read_file(LpConfig *lpconfig, const char *filename);
......@@ -111,9 +108,7 @@ void lp_config_for_each_unread(LpConfig *lpconfig, LpConfigUnreadCallback cb, vo
/*tells whether uncommited (with lp_config_sync()) modifications exist*/
int lp_config_needs_commit(const LpConfig *lpconfig);
void lp_config_destroy(LpConfig *cfg);
#ifdef __cplusplus
}
#endif
}; //namespace
#endif
......@@ -884,6 +884,7 @@ int main(int argc, char *argv[]) {
}
}
a->start(transportsArg.getValue(), passphrase);
flexisip::ConferenceServer::bindConference();
setOpenSSLThreadSafe();
#ifdef ENABLE_SNMP
bool snmpEnabled = cfg->getGlobal()->get<ConfigBoolean>("enable-snmp")->read();
......@@ -926,7 +927,7 @@ int main(int argc, char *argv[]) {
#ifdef ENABLE_PRESENCE
if (!startProxy) cfg->loadStrict();
bool enableLongTermPresence = (cfg->getRoot()->get<GenericStruct>("presence-server")->get<ConfigBoolean>("long-term-enabled")->read());
presenceServer = make_shared<flexisip::PresenceServer>();
presenceServer = make_shared<flexisip::PresenceServer>(startProxy);
if (enableLongTermPresence) {
auto presenceLongTerm = make_shared<flexisip::PresenceLongterm>(presenceServer->getBelleSipMainLoop());
presenceServer->addPresenceInfoObserver(presenceLongTerm);
......@@ -935,7 +936,6 @@ int main(int argc, char *argv[]) {
notifyWatchDog();
}
try{
presenceServer->setWithThread(startProxy);
presenceServer->init();
presenceServer->run();
}catch(FlexisipException &e){
......@@ -951,10 +951,8 @@ int main(int argc, char *argv[]) {
if (startConference){
#ifdef ENABLE_CONFERENCE
conferenceServer = make_shared<flexisip::ConferenceServer>();
conferenceServer = make_shared<flexisip::ConferenceServer>(startProxy);
try{
conferenceServer->setWithThread(startProxy);
conferenceServer->init();
conferenceServer->run();
}catch(FlexisipException &e){
......@@ -989,7 +987,7 @@ int main(int argc, char *argv[]) {
conference_stats->stop();
delete conference_stats;
}
//conferenceServer.reset();
conferenceServer.reset();
#endif // ENABLE_CONFERENCE
if (stun) {
......
......@@ -75,8 +75,10 @@ PresenceServer::Init::Init() {
s->addChildrenValues(items);
}
PresenceServer::PresenceServer() : ServiceServer() {
PresenceServer::PresenceServer() : PresenceServer(false) {
}
PresenceServer::PresenceServer(bool withThread) : ServiceServer(withThread){
auto config = GenericManager::get()->getRoot()->get<GenericStruct>("presence-server");
/*Enabling leak detector should be done asap.*/
belle_sip_object_enable_leak_detector(GenericManager::get()->getRoot()->get<GenericStruct>("presence-server")->get<ConfigBoolean>("leak-detector")->read());
......@@ -95,23 +97,23 @@ PresenceServer::PresenceServer() : ServiceServer() {
memset(&listener_callbacks, 0, sizeof(listener_callbacks));
listener_callbacks.process_dialog_terminated =
(void (*)(void *, const belle_sip_dialog_terminated_event_t *))PresenceServer::processDialogTerminated;
(void (*)(void *, const belle_sip_dialog_terminated_event_t *))PresenceServer::processDialogTerminated;
listener_callbacks.process_io_error =
(void (*)(void *, const belle_sip_io_error_event_t *))PresenceServer::processIoError;
(void (*)(void *, const belle_sip_io_error_event_t *))PresenceServer::processIoError;
listener_callbacks.process_request_event =
(void (*)(void *, const belle_sip_request_event_t *))PresenceServer::processRequestEvent;
(void (*)(void *, const belle_sip_request_event_t *))PresenceServer::processRequestEvent;
listener_callbacks.process_response_event =
(void (*)(void *, const belle_sip_response_event_t *))PresenceServer::processResponseEvent;
(void (*)(void *, const belle_sip_response_event_t *))PresenceServer::processResponseEvent;
listener_callbacks.process_timeout =
(void (*)(void *, const belle_sip_timeout_event_t *))PresenceServer::processTimeout;
(void (*)(void *, const belle_sip_timeout_event_t *))PresenceServer::processTimeout;
listener_callbacks.process_transaction_terminated =
(void (*)(void *,
const belle_sip_transaction_terminated_event_t *))PresenceServer::processTransactionTerminated;
mListener = belle_sip_listener_create_from_callbacks(&listener_callbacks, this);
belle_sip_provider_add_sip_listener(mProvider, mListener);
mDefaultExpires = config->get<ConfigInt>("expires")->read();
mBypass = config->get<ConfigString>("bypass-condition")->read();
mEnabled = config->get<ConfigBoolean>("enabled")->read();
(void (*)(void *,
const belle_sip_transaction_terminated_event_t *))PresenceServer::processTransactionTerminated;
mListener = belle_sip_listener_create_from_callbacks(&listener_callbacks, this);
belle_sip_provider_add_sip_listener(mProvider, mListener);
mDefaultExpires = config->get<ConfigInt>("expires")->read();
mBypass = config->get<ConfigString>("bypass-condition")->read();
mEnabled = config->get<ConfigBoolean>("enabled")->read();
}
static void remove_listening_point(belle_sip_listening_point_t* lp,belle_sip_provider_t* prov) {
......
......@@ -29,7 +29,7 @@
//#include "presence-configmanager.hh"
//#include "presentity-presenceinformation.hh"
#include "presentity-manager.hh"
#include "../service-server.hh"
#include "service-server.hh"
#include "belle-sip/sip-uri.h"
typedef struct belle_sip_main_loop belle_sip_main_loop_t;
......@@ -70,6 +70,7 @@ public:
class PresenceServer : public PresentityManager, public ServiceServer {
public:
PresenceServer();
PresenceServer(bool withThread);
~PresenceServer();
void _init();
void _run();
......@@ -78,8 +79,9 @@ public:
void addPresenceInfoObserver(const std::shared_ptr<PresenceInfoObserver> &observer);
void removePresenceInfoObserver(const std::shared_ptr<PresenceInfoObserver> &observer);
private:
class Init{
public:
// Used to declare the service configuration
class Init {
public:
Init();
};
static Init sStaticInit;
......
......@@ -25,7 +25,7 @@
#include <csignal>
namespace flexisip {
class ServiceServer {
public:
ServiceServer() : ServiceServer(false) {};
......@@ -52,6 +52,7 @@ public:
}
};
//Stop service server
void stop() {
mStarted = false;
this->_stop();
......@@ -67,7 +68,6 @@ public:
virtual void _init() = 0;
virtual void _run() = 0;
virtual void _stop() = 0;
protected:
bool mStarted;
bool mWithThread;
......
belle-sip @ e3b9709c
Subproject commit c64c5171e2e5364eee6f1f3d18872507e324dd18
Subproject commit e3b9709cc5c01250aa944a7cb6f8abbee885113f
belr @ 4f32b9c2
Subproject commit 4f32b9c29c4ab8c4ccfc1e0899019a811d495054
cmake-builder @ 03849335
Subproject commit 0433ac7b7a0681a08bda65133584eeda6137f1b5
Subproject commit 03849335fc10b887f8e8de509656049a1289ff60
libxml2 @ 32119739
Subproject commit 3211973961d01b9c5efb5c5f3b8620a2a3c17561
libxsd @ 97dfa5b7
Subproject commit 97dfa5b7af486a2730aa66ef4b2b04259c9ab21b
xerces-c @ 4a6d98d2
Subproject commit 4a6d98d2ad797c37a9d12c1da772ca813c2f95b7
linphone @ ba05da5b
Subproject commit 348ec8a985174f6fd43726becf13e383d399bde2
Subproject commit ba05da5b717fab05735df6646b06fb0d5850237e
ortp @ 5f8fcddc
Subproject commit e9c2d48c917d78c529eefb9f824ae52238f950d4
Subproject commit 5f8fcddce392f1510768949a4691f9e8c170badb
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment