Skip to content

Commit

Permalink
Bring back the option to use libnice (#1752)
Browse files Browse the repository at this point in the history
  • Loading branch information
lodoyun committed Oct 4, 2021
1 parent f79bbf2 commit dd417f6
Show file tree
Hide file tree
Showing 34 changed files with 1,128 additions and 60 deletions.
11 changes: 11 additions & 0 deletions erizo/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,28 @@ IF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
include_directories("/usr/local/include")
ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")

include(${CMAKE_CURRENT_SOURCE_DIR}/../conan_paths.cmake)
# GLIB
find_package(glib)
include_directories(${GLIB_INCLUDE_DIRS})

# BOOST
set (BOOST_LIBS thread regex system)
find_package(Boost)
include_directories(${Boost_INCLUDE_DIRS})

set(ERIZO_CMAKE_CXX_FLAGS "${ERIZO_CMAKE_CXX_FLAGS} -DBOOST_THREAD_PROVIDES_FUTURE -DBOOST_THREAD_PROVIDES_FUTURE_CONTINUATION -DBOOST_THREAD_PROVIDES_FUTURE_WHEN_ALL_WHEN_ANY")
# GTHREAD
find_library(GTHREAD gthread-2.0 HINTS "${THIRD_PARTY_LIB}")
test_lib(${GTHREAD})

# SRTP
find_library(SRTP srtp2 HINTS "${THIRD_PARTY_LIB}")
test_lib(${SRTP})

# NICE
find_library(NICE nice HINTS "${THIRD_PARTY_LIB}")
test_lib(${NICE})

# OPENSSL
find_library(SSL ssl HINTS "${THIRD_PARTY_LIB}")
Expand Down
52 changes: 52 additions & 0 deletions erizo/src/cmake/Findglib.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
pkg_check_modules(GLIB_PKG glib-2.0)

if (GLIB_PKG_FOUND)
find_path(GLIB_INCLUDE_DIR NAMES glib.h PATH_SUFFIXES glib-2.0
PATHS
${GLIB_PKG_INCLUDE_DIRS}
/usr/include/glib-2.0
/usr/include
/usr/local/include
)
find_path(GLIB_CONFIG_INCLUDE_DIR NAMES glibconfig.h PATHS ${GLIB_PKG_LIBDIR} PATH_SUFFIXES glib-2.0/include)
find_library(GLIB_LIBRARIES2 NAMES glib-2.0
PATHS
${GLIB_PKG_LIBRARY_DIRS}
/usr/lib
/usr/local/lib
)

find_library(GOBJECT_LIBRARIES NAMES gobject-2.0
PATHS
${GLIB_PKG_LIBRARY_DIRS}
/usr/lib
/usr/local/lib
)

find_library(GTHREAD_LIBRARIES NAMES gthread-2.0
PATHS
${GLIB_PKG_LIBRARY_DIRS}
/usr/lib
/usr/local/lib
)

set(GLIB_LIBRARIES ${GLIB_LIBRARIES2} ${GOBJECT_LIBRARIES} ${GTHREAD_LIBRARIES})

else (GLIB_PKG_FOUND)
message (FATAL_ERROR "pkg-config is needed")
return()
endif (GLIB_PKG_FOUND)

if (GLIB_INCLUDE_DIR AND GLIB_CONFIG_INCLUDE_DIR AND GLIB_LIBRARIES)
set(GLIB_INCLUDE_DIRS ${GLIB_INCLUDE_DIR} ${GLIB_CONFIG_INCLUDE_DIR})
endif (GLIB_INCLUDE_DIR AND GLIB_CONFIG_INCLUDE_DIR AND GLIB_LIBRARIES)

if(GLIB_INCLUDE_DIRS AND GLIB_LIBRARIES)
set(GLIB_FOUND TRUE CACHE INTERNAL "glib-2.0 found")
message(STATUS "Found glib-2.0: ${GLIB_INCLUDE_DIR}, ${GLIB_LIBRARIES}")
else(GLIB_INCLUDE_DIRS AND GLIB_LIBRARIES)
set(GLIB_FOUND FALSE CACHE INTERNAL "glib-2.0 found")
message(STATUS "glib-2.0 not found.")
endif(GLIB_INCLUDE_DIRS AND GLIB_LIBRARIES)

mark_as_advanced(GLIB_INCLUDE_DIR GLIB_CONFIG_INCLUDE_DIR GLIB_INCLUDE_DIRS GLIB_LIBRARIES)
2 changes: 1 addition & 1 deletion erizo/src/erizo/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ file(GLOB_RECURSE ERIZO_SOURCES "${ERIZO_SOURCE_DIR}/*.h" "${ERIZO_SOURCE_DIR}/*
add_library(erizo SHARED ${ERIZO_SOURCES})


target_link_libraries(erizo ${Boost_LIBRARIES} ${apr_LIBRARIES} ${apr-util_LIBRARIES} ${SRTP} ${SSL} ${CRYPTO} ${LIBS} webrtc nicer nrappkit log4cxx)
target_link_libraries(erizo ${GLIB_LIBRARIES} ${Boost_LIBRARIES} ${apr_LIBRARIES} ${apr-util_LIBRARIES} ${SRTP} ${NICE} ${GTHREAD} ${SSL} ${CRYPTO} ${LIBS} webrtc nicer nrappkit log4cxx)
add_dependencies(erizo log4cxxInstall)
9 changes: 8 additions & 1 deletion erizo/src/erizo/DtlsTransport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#include "./SrtpChannel.h"
#include "rtp/RtpHeaders.h"
#include "./LibNiceConnection.h"
#include "./NicerConnection.h"

using erizo::TimeoutChecker;
Expand Down Expand Up @@ -106,7 +107,11 @@ DtlsTransport::DtlsTransport(MediaType med, const std::string &transport_name, c
iceConfig_.ice_components = comps;
iceConfig_.username = username;
iceConfig_.password = password;
ice_ = NicerConnection::create(io_worker_, iceConfig_);
if (iceConfig_.use_nicer) {
ice_ = (NicerConnection::create(io_worker_, iceConfig_));
} else {
ice_ = (LibNiceConnection::create(io_worker_, iceConfig_));
}

rtp_timeout_checker_.reset(new TimeoutChecker(this, dtlsRtp.get()));
if (!rtcp_mux) {
Expand Down Expand Up @@ -347,8 +352,10 @@ void DtlsTransport::updateIceStateSync(IceState state, IceConnection *conn) {
ELOG_DEBUG("%s message:IceState, transportName: %s, state: %d, isBundle: %d, transportState: %d",
toLog(), transport_name.c_str(), state, bundle_, getTransportState());
if (state == IceState::INITIAL && this->getTransportState() != TRANSPORT_STARTED) {
ELOG_DEBUG("%s message: Transport started", toLog());
updateTransportState(TRANSPORT_STARTED);
} else if (state == IceState::CANDIDATES_RECEIVED && this->getTransportState() != TRANSPORT_GATHERED) {
ELOG_DEBUG("%s message: Transport Gathered", toLog());
updateTransportState(TRANSPORT_GATHERED);
} else if (state == IceState::FAILED) {
ELOG_DEBUG("%s message: Ice Failed", toLog());
Expand Down
3 changes: 0 additions & 3 deletions erizo/src/erizo/IceConnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ const std::string& IceConnection::getLocalPassword() const {
return upass_;
}

void IceConnection::maybeRestartIce(std::string remote_ufrag, std::string remote_pass) {
}

IceState IceConnection::checkIceState() {
return ice_state_;
}
Expand Down
15 changes: 8 additions & 7 deletions erizo/src/erizo/IceConnection.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@
#include "./SdpInfo.h"
#include "./logger.h"

typedef struct _NiceAgent NiceAgent;
typedef struct _GMainContext GMainContext;
typedef struct _GMainLoop GMainLoop;

typedef unsigned int uint;

Expand Down Expand Up @@ -50,6 +47,8 @@ class IceConfig {
std::string stun_server, network_interface;
uint16_t stun_port, turn_port, min_port, max_port;
bool should_trickle;
bool use_nicer;
bool ice_lite;
IceConfig()
: media_type{MediaType::OTHER},
transport_name{""},
Expand All @@ -66,7 +65,9 @@ class IceConfig {
turn_port{0},
min_port{0},
max_port{0},
should_trickle{false}
should_trickle{false},
use_nicer{true},
ice_lite{false}
{
}
};
Expand Down Expand Up @@ -98,11 +99,11 @@ class IceConnection : public LogContext {
virtual void setRemoteCredentials(const std::string& username, const std::string& password) = 0;
virtual int sendData(unsigned int component_id, const void* buf, int len) = 0;

virtual void onData(unsigned int component_id, char* buf, int len) = 0;
virtual void onData(unsigned int component_id, char* buf, int len) {}
virtual void onData(unsigned int component_id, packetPtr) {}
virtual CandidatePair getSelectedPair() = 0;
virtual void setReceivedLastCandidate(bool hasReceived) = 0;
virtual void close() = 0;
virtual void maybeRestartIce(std::string remote_ufrag, std::string remote_pass);
virtual void maybeRestartIce(std::string remote_ufrag, std::string remote_pass) = 0;

virtual void updateIceState(IceState state);
virtual IceState checkIceState();
Expand Down
Loading

0 comments on commit dd417f6

Please sign in to comment.