mirror of
https://github.com/mii443/libdatachannel.git
synced 2025-12-16 17:08:46 +00:00
Option for enabling ICE TCP Candidates
This commit is contained in:
@@ -48,6 +48,7 @@ struct IceServer {
|
||||
|
||||
struct Configuration {
|
||||
std::vector<IceServer> iceServers;
|
||||
bool enableIceTcp = false;
|
||||
uint16_t portRangeBegin = 1024;
|
||||
uint16_t portRangeEnd = 65535;
|
||||
};
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user