Option for enabling ICE TCP Candidates

This commit is contained in:
Murat Dogan
2019-12-17 07:49:26 +03:00
parent 432be41b9a
commit 278ac22766
4 changed files with 9 additions and 2 deletions

View File

@@ -48,6 +48,7 @@ struct IceServer {
struct Configuration {
std::vector<IceServer> iceServers;
bool enableIceTcp = false;
uint16_t portRangeBegin = 1024;
uint16_t portRangeEnd = 65535;
};

View File

@@ -70,6 +70,11 @@ bool Candidate::resolve(ResolveMode mode) {
hints.ai_protocol = IPPROTO_UDP;
}
if (transport == "TCP" || transport == "tcp") {
hints.ai_socktype = SOCK_STREAM;
hints.ai_protocol = IPPROTO_TCP;
}
if (mode == ResolveMode::Simple)
hints.ai_flags |= AI_NUMERICHOST;
@@ -120,4 +125,3 @@ Candidate::operator string() const {
std::ostream &operator<<(std::ostream &out, const rtc::Candidate &candidate) {
return out << std::string(candidate);
}

View File

@@ -61,7 +61,8 @@ IceTransport::IceTransport(const Configuration &config, Description::Role role,
g_object_set(G_OBJECT(mNiceAgent.get()), "controlling-mode", TRUE, nullptr);
g_object_set(G_OBJECT(mNiceAgent.get()), "ice-udp", TRUE, nullptr);
g_object_set(G_OBJECT(mNiceAgent.get()), "ice-tcp", FALSE, nullptr);
g_object_set(G_OBJECT(mNiceAgent.get()), "ice-tcp", config.enableIceTcp ? TRUE : FALSE,
nullptr);
g_object_set(G_OBJECT(mNiceAgent.get()), "stun-initial-timeout", 200, nullptr);
g_object_set(G_OBJECT(mNiceAgent.get()), "stun-max-retransmissions", 3, nullptr);
g_object_set(G_OBJECT(mNiceAgent.get()), "stun-pacing-timer", 20, nullptr);

View File

@@ -31,6 +31,7 @@ template <class T> weak_ptr<T> make_weak_ptr(shared_ptr<T> ptr) { return ptr; }
int main(int argc, char **argv) {
rtc::Configuration config;
// config.iceServers.emplace_back("stun.l.google.com:19302");
// config.enableIceTcp = true;
// IceServer turnServer("TURN_SERVER_URL", "PORT_NO", IceServer::Type::TURN, "USERNAME",
// "PASSWORD", IceServer::RelayType::RELAY_TYPE_TURN_TLS);