Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hack to make sure we pass candidates in libnice even when there's only mdns #1766

Merged
merged 1 commit into from
Nov 10, 2021
Merged
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
19 changes: 15 additions & 4 deletions erizo/src/erizo/LibNiceConnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,17 @@ bool LibNiceConnection::setRemoteCandidatesSync(const std::vector<CandidateInfo>
if (cinfo.hostPort == 0) {
continue;
}
std::string host_address = cinfo.hostAddress;
int host_port = cinfo.hostPort;

if (host_address.find("local") != std::string::npos) {
// HACK for mdns. Theres currently an issue in libnice where if no valid candidates
// are received - More details https://gitlab.freedesktop.org/libnice/libnice/-/merge_requests/182
// We are forcing a "dummy" candidate to unlock the process.
ELOG_WARN("%s hostAddress is mdns, using dummy candidate", toLog());
host_address = "127.0.0.1";
host_port = 4;
}
NiceCandidate* thecandidate = nice_candidate_new(nice_cand_type);
if (!remote_ufrag_.empty()) {
thecandidate->username = strdup(remote_ufrag_.c_str());
Expand All @@ -423,13 +434,13 @@ bool LibNiceConnection::setRemoteCandidatesSync(const std::vector<CandidateInfo>
thecandidate->component_id = cinfo.componentId;
thecandidate->priority = cinfo.priority;
thecandidate->transport = NICE_CANDIDATE_TRANSPORT_UDP;
nice_address_set_from_string(&thecandidate->addr, cinfo.hostAddress.c_str());
nice_address_set_port(&thecandidate->addr, cinfo.hostPort);
nice_address_set_from_string(&thecandidate->addr, host_address.c_str());
nice_address_set_port(&thecandidate->addr, host_port);

std::ostringstream host_info;
host_info << "hostType: " << cinfo.hostType
<< ", hostAddress: " << cinfo.hostAddress
<< ", hostPort: " << cinfo.hostPort;
<< ", hostAddress: " << host_address
<< ", hostPort: " << host_port;

if (cinfo.hostType == RELAY || cinfo.hostType == SRFLX) {
nice_address_set_from_string(&thecandidate->base_addr, cinfo.rAddress.c_str());
Expand Down