2
0
Эх сурвалжийг харах

Option for enabling ICE TCP Candidates

Murat Dogan 5 жил өмнө
parent
commit
278ac22766

+ 1 - 0
include/rtc/configuration.hpp

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

+ 5 - 1
src/candidate.cpp

@@ -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);
 }
-

+ 2 - 1
src/icetransport.cpp

@@ -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);

+ 1 - 0
test/main.cpp

@@ -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);