Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion erizo/src/erizo/IceConnection.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ class IceConfig {
std::string stun_server, network_interface;
uint16_t stun_port, turn_port, min_port, max_port;
bool should_trickle;
std::string public_ip;
bool ice_lite;
IceConfig()
: media_type{MediaType::OTHER},
transport_name{""},
Expand All @@ -66,7 +68,8 @@ class IceConfig {
turn_port{0},
min_port{0},
max_port{0},
should_trickle{false}
should_trickle{false},
ice_lite{false}
{
}
};
Expand Down
30 changes: 27 additions & 3 deletions erizo/src/erizo/NicerConnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ int NicerConnection::ice_connected(void *obj, nr_ice_peer_ctx *pctx) {
}
conn->updateIceState(IceState::READY);
conn->nicer_->IceContextFinalize(conn->ctx_, pctx);

conn->nicer_->IcePeerContextDumpState(pctx, 0);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

return 0;
}

Expand Down Expand Up @@ -149,7 +149,8 @@ NicerConnection::NicerConnection(std::shared_ptr<IOWorker> io_worker, std::share
ctx_{nullptr},
peer_{nullptr},
stream_{nullptr},
offerer_{!ice_config_.username.empty() && !ice_config_.password.empty()} {
offerer_{!ice_config_.username.empty() && !ice_config_.password.empty()},
enable_ice_lite_{ice_config_.ice_lite} {
}

NicerConnection::~NicerConnection() {
Expand All @@ -174,7 +175,13 @@ void NicerConnection::start() {
}

void NicerConnection::startSync() {
UINT4 flags = NR_ICE_CTX_FLAGS_AGGRESSIVE_NOMINATION;
UINT4 flags = 0;

if (enable_ice_lite_) {
flags |= NR_ICE_CTX_FLAGS_LITE;
} else {
flags |= NR_ICE_CTX_FLAGS_AGGRESSIVE_NOMINATION;
}

if (ufrag_.empty() || upass_.empty()) {
start_promise_.set_value();
Expand Down Expand Up @@ -256,6 +263,10 @@ void NicerConnection::startSync() {
peer_->controlling = 1;
}

if (enable_ice_lite_) {
peer_->controlling = 0;
}

start_promise_.set_value();
}

Expand Down Expand Up @@ -322,6 +333,9 @@ void NicerConnection::startGathering() {
}

bool NicerConnection::setRemoteCandidates(const std::vector<CandidateInfo> &candidates, bool is_bundle) {
if (enable_ice_lite_) {
return true;
}
std::vector<CandidateInfo> cands(candidates);
auto remote_candidates_promise = std::make_shared<std::promise<void>>();
async([cands, this, remote_candidates_promise]
Expand Down Expand Up @@ -405,6 +419,16 @@ void NicerConnection::onCandidate(nr_ice_media_stream *stream, int component_id,
if (cand->addr.ip_version != NR_IPV4) {
return;
}

// Note: This code means that we know our Public IP and we don't want to use STUN, so we treat the Srflx candidates
// as Host candidates. We do it because we would otherwise treat all local candidates as Prflx, which leads to
// different connectivity issues.
if (cand->type == nr_ice_candidate_type::HOST && !ice_config_.public_ip.empty()) {
nr_transport_addr addr;
nr_str_port_to_transport_addr(ice_config_.public_ip.c_str(),
getPortFromAddress(cand->addr), cand->addr.protocol, &addr);
cand->addr = addr;
}
cand_info.hostAddress = getStringFromAddress(cand->addr);
cand_info.hostPort = getPortFromAddress(cand->addr);
if (cand_info.hostPort == 0) {
Expand Down
1 change: 1 addition & 0 deletions erizo/src/erizo/NicerConnection.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ class NicerConnection : public IceConnection, public std::enable_shared_from_thi
std::future<void> start_future_;
boost::mutex close_mutex_;
boost::mutex close_sync_mutex_;
bool enable_ice_lite_;
};

} // namespace erizo
Expand Down
1 change: 1 addition & 0 deletions erizo/src/erizo/SdpInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ namespace erizo {

SdpInfo::SdpInfo(const std::vector<RtpMap> rtp_mappings) : internalPayloadVector_{rtp_mappings} {
isBundle = false;
isIceLite = false;
isRtcpMux = false;
isFingerprint = false;
dtlsRole = ACTPASS;
Expand Down
1 change: 1 addition & 0 deletions erizo/src/erizo/SdpInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ class SdpInfo {
* Is it Bundle
*/
bool isBundle;
bool isIceLite;
/**
* Has audio
*/
Expand Down
2 changes: 2 additions & 0 deletions erizo/src/erizo/WebRtcConnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ WebRtcConnection::WebRtcConnection(std::shared_ptr<Worker> worker, std::shared_p
trickle_enabled_ = ice_config_.should_trickle;
slide_show_mode_ = false;

local_sdp_->isIceLite = ice_config_.ice_lite;

sending_ = true;
}

Expand Down
4 changes: 4 additions & 0 deletions erizo/src/erizo/lib/NicerInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ void NicerInterfaceImpl::IceContextFinalize(nr_ice_ctx *ctx, nr_ice_peer_ctx *pc
nr_ice_ctx_finalize(ctx, pctxp);
}

void NicerInterfaceImpl::IcePeerContextDumpState(nr_ice_peer_ctx *pctx, uint log_level) {
nr_ice_peer_ctx_dump_state(pctx, log_level);
}

int NicerInterfaceImpl::IceContextSetStunServers(nr_ice_ctx *ctx, nr_ice_stun_server *servers, int ct) {
return nr_ice_ctx_set_stun_servers(ctx, servers, ct);
}
Expand Down
2 changes: 2 additions & 0 deletions erizo/src/erizo/lib/NicerInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class NicerInterface {
virtual int IceContextSetTrickleCallback(nr_ice_ctx *ctx, nr_ice_trickle_candidate_cb cb, void *cb_arg) = 0;
virtual void IceContextSetSocketFactory(nr_ice_ctx *ctx, nr_socket_factory *factory) = 0;
virtual void IceContextFinalize(nr_ice_ctx *ctx, nr_ice_peer_ctx *pctxp) = 0;
virtual void IcePeerContextDumpState(nr_ice_peer_ctx *pctx, uint log_level) = 0;
virtual int IceContextSetStunServers(nr_ice_ctx *ctx, nr_ice_stun_server *servers, int ct) = 0;
virtual int IceContextSetTurnServers(nr_ice_ctx *ctx, nr_ice_turn_server *servers, int ct) = 0;
virtual void IceContextSetPortRange(nr_ice_ctx *ctx, uint16_t min_port, uint16_t max_port) = 0;
Expand Down Expand Up @@ -71,6 +72,7 @@ class NicerInterfaceImpl: public NicerInterface {
int IceContextSetTrickleCallback(nr_ice_ctx *ctx, nr_ice_trickle_candidate_cb cb, void *cb_arg) override;
void IceContextSetSocketFactory(nr_ice_ctx *ctx, nr_socket_factory *factory) override;
void IceContextFinalize(nr_ice_ctx *ctx, nr_ice_peer_ctx *pctxp) override;
void IcePeerContextDumpState(nr_ice_peer_ctx *pctx, uint log_level) override;
int IceContextSetStunServers(nr_ice_ctx *ctx, nr_ice_stun_server *servers, int ct) override;
int IceContextSetTurnServers(nr_ice_ctx *ctx, nr_ice_turn_server *servers, int ct) override;
void IceContextSetPortRange(nr_ice_ctx *ctx, uint16_t min_port, uint16_t max_port) override;
Expand Down
1 change: 1 addition & 0 deletions erizo/src/test/NicerConnectionTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class MockNicer: public erizo::NicerInterface {
MOCK_METHOD3(IceContextSetTrickleCallback, int(nr_ice_ctx *, nr_ice_trickle_candidate_cb, void *));
MOCK_METHOD2(IceContextSetSocketFactory, void(nr_ice_ctx *, nr_socket_factory *));
MOCK_METHOD2(IceContextFinalize, void(nr_ice_ctx *, nr_ice_peer_ctx *));
MOCK_METHOD2(IcePeerContextDumpState, void(nr_ice_peer_ctx *, uint));
MOCK_METHOD3(IceContextSetStunServers, int(nr_ice_ctx *, nr_ice_stun_server *, int));
MOCK_METHOD3(IceContextSetTurnServers, int(nr_ice_ctx *, nr_ice_turn_server *, int));
MOCK_METHOD3(IceContextSetPortRange, void(nr_ice_ctx *, uint16_t, uint16_t));
Expand Down
2 changes: 1 addition & 1 deletion erizo/src/third_party/nicer.cmake
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
set(NICER_BUILD "${CMAKE_CURRENT_BINARY_DIR}/libdeps/nicer")
ExternalProject_Add(project_nicer
GIT_REPOSITORY "https://github.com/lynckia/nicer.git"
GIT_TAG "1.6"
GIT_TAG "origin/add/support_to_add_trickle_candidates"
PREFIX ${NICER_BUILD}
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${NICER_BUILD} -DTHIRD_PARTY_LIB=${THIRD_PARTY_LIB}
DOWNLOAD_DIR "${NICER_BUILD}/src"
Expand Down
15 changes: 14 additions & 1 deletion erizoAPI/ConnectionDescription.cc
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ NAN_MODULE_INIT(ConnectionDescription::Init) {

Nan::SetPrototypeMethod(tpl, "getRids", getRids);

Nan::SetPrototypeMethod(tpl, "setIceLite", setIceLite);
Nan::SetPrototypeMethod(tpl, "isIceLite", isIceLite);

Nan::SetPrototypeMethod(tpl, "postProcessInfo", postProcessInfo);
Nan::SetPrototypeMethod(tpl, "copyInfoFromSdp", copyInfoFromSdp);

Expand All @@ -125,7 +128,7 @@ NAN_METHOD(ConnectionDescription::New) {
// Invoked as a constructor with 'new ConnectionDescription()'
ConnectionDescription* obj = new ConnectionDescription();

if (info.Length() == 0) {
if (info.Length() != 1) {
obj->Wrap(info.This());
info.GetReturnValue().Set(info.This());
return;
Expand Down Expand Up @@ -748,6 +751,16 @@ NAN_METHOD(ConnectionDescription::getRids) {
info.GetReturnValue().Set(rids);
}

NAN_METHOD(ConnectionDescription::setIceLite) {
GET_SDP();
sdp->isIceLite = Nan::To<bool>(info[0]).FromJust();
}

NAN_METHOD(ConnectionDescription::isIceLite) {
GET_SDP();
info.GetReturnValue().Set(Nan::New(sdp->isIceLite));
}

NAN_METHOD(ConnectionDescription::postProcessInfo) {
GET_SDP();
bool success = sdp->postProcessInfo();
Expand Down
3 changes: 3 additions & 0 deletions erizoAPI/ConnectionDescription.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ class ConnectionDescription : public Nan::ObjectWrap {

static NAN_METHOD(getRids);

static NAN_METHOD(setIceLite);
static NAN_METHOD(isIceLite);

static NAN_METHOD(postProcessInfo);

static NAN_METHOD(copyInfoFromSdp);
Expand Down
17 changes: 11 additions & 6 deletions erizoAPI/WebRtcConnection.cc
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ NAN_METHOD(WebRtcConnection::New) {
bool trickle = Nan::To<bool>((info[7])).FromJust();
Nan::Utf8String json_param(Nan::To<v8::String>(info[8]).ToLocalChecked());
bool enable_connection_quality_check = Nan::To<bool>((info[9])).FromJust();
bool enable_ice_lite = Nan::To<bool>((info[10])).FromJust();
std::string media_config_string = std::string(*json_param);
json media_config = json::parse(media_config_string);
std::vector<erizo::RtpMap> rtp_mappings;
Expand Down Expand Up @@ -235,22 +236,25 @@ NAN_METHOD(WebRtcConnection::New) {
}

erizo::IceConfig iceConfig;
if (info.Length() == 15) {
Nan::Utf8String param2(Nan::To<v8::String>(info[10]).ToLocalChecked());
if (info.Length() == 17) {
Nan::Utf8String param2(Nan::To<v8::String>(info[11]).ToLocalChecked());
std::string turnServer = std::string(*param2);
int turnPort = Nan::To<int>(info[11]).FromJust();
Nan::Utf8String param3(Nan::To<v8::String>(info[12]).ToLocalChecked());
int turnPort = Nan::To<int>(info[12]).FromJust();
Nan::Utf8String param3(Nan::To<v8::String>(info[13]).ToLocalChecked());
std::string turnUsername = std::string(*param3);
Nan::Utf8String param4(Nan::To<v8::String>(info[13]).ToLocalChecked());
Nan::Utf8String param4(Nan::To<v8::String>(info[14]).ToLocalChecked());
std::string turnPass = std::string(*param4);
Nan::Utf8String param5(Nan::To<v8::String>(info[14]).ToLocalChecked());
Nan::Utf8String param5(Nan::To<v8::String>(info[15]).ToLocalChecked());
std::string network_interface = std::string(*param5);
Nan::Utf8String param6(Nan::To<v8::String>(info[16]).ToLocalChecked());
std::string public_ip = std::string(*param6);

iceConfig.turn_server = turnServer;
iceConfig.turn_port = turnPort;
iceConfig.turn_username = turnUsername;
iceConfig.turn_pass = turnPass;
iceConfig.network_interface = network_interface;
iceConfig.public_ip = public_ip;
}


Expand All @@ -259,6 +263,7 @@ NAN_METHOD(WebRtcConnection::New) {
iceConfig.min_port = minPort;
iceConfig.max_port = maxPort;
iceConfig.should_trickle = trickle;
iceConfig.ice_lite = enable_ice_lite;

std::shared_ptr<erizo::Worker> worker = thread_pool->me->getLessUsedWorker();
std::shared_ptr<erizo::IOWorker> io_worker = io_thread_pool->me->getLessUsedIOWorker();
Expand Down
8 changes: 4 additions & 4 deletions erizo_controller/common/semanticSdp/CandidateInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@ class CandidateInfo {
plain() {
const plain = {
foundation: this.foundation,
componentId: this.componentId,
component: this.componentId,
transport: this.transport,
priority: this.priority,
address: this.address,
ip: this.address,
port: this.port,
type: this.type,
generation: this.generation,
};
if (this.relAddr) plain.relAddr = this.relAddr;
if (this.relPort) plain.relPort = this.relPort;
if (this.relAddr) plain.raddr = this.relAddr;
if (this.relPort) plain.rport = this.relPort;
return plain;
}

Expand Down
28 changes: 14 additions & 14 deletions erizo_controller/common/semanticSdp/SDPInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,24 +270,14 @@ class SDPInfo {

const candidates = media.getCandidates();
candidates.forEach((candidate) => {
md.candidates.push({
foundation: candidate.getFoundation(),
component: candidate.getComponentId(),
transport: candidate.getTransport(),
priority: candidate.getPriority(),
ip: candidate.getAddress(),
port: candidate.getPort(),
type: candidate.getType(),
relAddr: candidate.getRelAddr(),
relPort: candidate.getRelPort(),
generation: candidate.getGeneration(),
});
md.candidates.push(candidate.plain());
});

ice = media.getICE();
if (ice) {
if (ice.isLite()) {
md.icelite = 'ice-lite';
sdp.icelite = 'ice-lite';
}
md.iceOptions = ice.getOpts();
md.iceUfrag = ice.getUfrag();
Expand Down Expand Up @@ -749,8 +739,13 @@ SDPInfo.process = (sdp) => {
let ufrag = sdp.iceUfrag;
let pwd = sdp.icePwd;
let iceOptions = sdp.iceOptions;
let iceLite = sdp.icelite === 'ice-lite';
if (ufrag || pwd || iceOptions) {
sdpInfo.setICE(new ICEInfo(ufrag, pwd, iceOptions));
const iceInfo = new ICEInfo(ufrag, pwd, iceOptions);
if (iceLite) {
iceInfo.setLite(iceLite);
}
sdpInfo.setICE(iceInfo);
}

let fingerprintAttr = sdp.fingerprint;
Expand Down Expand Up @@ -785,8 +780,13 @@ SDPInfo.process = (sdp) => {
ufrag = md.iceUfrag;
pwd = md.icePwd;
iceOptions = md.iceOptions;
iceLite = md.icelite === 'ice-lite';

if (ufrag || pwd || iceOptions) {
const thisIce = new ICEInfo(ufrag, pwd, iceOptions);
if (iceLite) {
thisIce.setLite(iceLite);
}
if (md.endOfCandidates) {
thisIce.setEndOfCandidates('end-of-candidates');
}
Expand Down Expand Up @@ -822,7 +822,7 @@ SDPInfo.process = (sdp) => {
candidates.forEach((candidate) => {
mediaInfo.addCandidate(new CandidateInfo(candidate.foundation, candidate.component,
candidate.transport, candidate.priority, candidate.ip, candidate.port, candidate.type,
candidate.generation, candidate.relAddr, candidate.relPort));
candidate.generation, candidate.raddr, candidate.rport));
});
}

Expand Down
1 change: 1 addition & 0 deletions erizo_controller/erizoJS/erizoJS.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ global.config.erizo.numWorkers = global.config.erizo.numWorkers || 24;
global.config.erizo.numIOWorkers = global.config.erizo.numIOWorkers || 1;
global.config.erizo.useConnectionQualityCheck =
global.config.erizo.useConnectionQualityCheck || false;
global.config.erizo.iceLite = global.config.erizo.iceLite || false;
global.config.erizo.stunserver = global.config.erizo.stunserver || '';
global.config.erizo.stunport = global.config.erizo.stunport || 0;
global.config.erizo.minport = global.config.erizo.minport || 0;
Expand Down
Loading