Browse Source

Merge pull request #1475 from paullouisageneau/juice-ice-tcp

Add ICE-TCP support with libjuice
Paul-Louis Ageneau 4 weeks ago
parent
commit
bd8f4fe938
6 changed files with 9 additions and 9 deletions
  1. 1 1
      CMakeLists.txt
  2. 1 1
      DOC.md
  3. 1 1
      include/rtc/configuration.hpp
  4. 1 1
      include/rtc/rtc.h
  5. 1 1
      pages/content/pages/reference.md
  6. 4 4
      src/impl/icetransport.cpp

+ 1 - 1
CMakeLists.txt

@@ -466,7 +466,7 @@ else()
 	target_compile_definitions(datachannel PRIVATE USE_NICE=0)
 	target_compile_definitions(datachannel-static PRIVATE USE_NICE=0)
 	if(USE_SYSTEM_JUICE)
-		find_package(LibJuice REQUIRED)
+		find_package(LibJuice 1.7.0 REQUIRED)
 		target_compile_definitions(datachannel PRIVATE RTC_SYSTEM_JUICE=1)
 		target_compile_definitions(datachannel-static PRIVATE RTC_SYSTEM_JUICE=1)
 		target_link_libraries(datachannel PRIVATE LibJuice::LibJuice)

+ 1 - 1
DOC.md

@@ -103,7 +103,7 @@ Arguments:
   - `bindAddress` (optional): if non-NULL, bind only to the given local address (ignored with libnice as ICE backend)
   - `certificateType` (optional): certificate type, either `RTC_CERTIFICATE_ECDSA` or `RTC_CERTIFICATE_RSA` (0 or `RTC_CERTIFICATE_DEFAULT` if default)
   - `iceTransportPolicy` (optional): ICE transport policy, if set to `RTC_TRANSPORT_POLICY_RELAY`, the PeerConnection will emit only relayed candidates (0 or `RTC_TRANSPORT_POLICY_ALL` if default)
-  - `enableIceTcp`: if true, generate TCP candidates for ICE (ignored with libjuice as ICE backend)
+  - `enableIceTcp`: if true, generate TCP candidates for ICE
   - `enableIceUdpMux`: if true, connections are multiplexed on the same UDP port (should be combined with `portRangeBegin` and `portRangeEnd`, ignored with libnice as ICE backend)
   - `disableAutoNegotiation`: if true, the user is responsible for calling `rtcSetLocalDescription` after creating a Data Channel and after setting the remote description
   - `forceMediaTransport`: if true, the connection allocates the SRTP media transport even if no tracks are present (necessary to add tracks during later renegotiation)

+ 1 - 1
include/rtc/configuration.hpp

@@ -72,7 +72,7 @@ struct RTC_CPP_EXPORT Configuration {
 	// Options
 	CertificateType certificateType = CertificateType::Default;
 	TransportPolicy iceTransportPolicy = TransportPolicy::All;
-	bool enableIceTcp = false;    // libnice only
+	bool enableIceTcp = false;
 	bool enableIceUdpMux = false; // libjuice only
 	bool disableAutoNegotiation = false;
 	bool disableAutoGathering = false;

+ 1 - 1
include/rtc/rtc.h

@@ -191,7 +191,7 @@ typedef struct {
 	const char *bindAddress; // libjuice only, NULL means any
 	rtcCertificateType certificateType;
 	rtcTransportPolicy iceTransportPolicy;
-	bool enableIceTcp;    // libnice only
+	bool enableIceTcp;
 	bool enableIceUdpMux; // libjuice only
 	bool disableAutoNegotiation;
 	bool forceMediaTransport;

+ 1 - 1
pages/content/pages/reference.md

@@ -106,7 +106,7 @@ Arguments:
   - `bindAddress` (optional): if non-NULL, bind only to the given local address (ignored with libnice as ICE backend)
   - `certificateType` (optional): certificate type, either `RTC_CERTIFICATE_ECDSA` or `RTC_CERTIFICATE_RSA` (0 or `RTC_CERTIFICATE_DEFAULT` if default)
   - `iceTransportPolicy` (optional): ICE transport policy, if set to `RTC_TRANSPORT_POLICY_RELAY`, the PeerConnection will emit only relayed candidates (0 or `RTC_TRANSPORT_POLICY_ALL` if default)
-  - `enableIceTcp`: if true, generate TCP candidates for ICE (ignored with libjuice as ICE backend)
+  - `enableIceTcp`: if true, generate TCP candidates for ICE
   - `enableIceUdpMux`: if true, connections are multiplexed on the same UDP port (should be combined with `portRangeBegin` and `portRangeEnd`, ignored with libnice as ICE backend)
   - `disableAutoNegotiation`: if true, the user is responsible for calling `rtcSetLocalDescription` after creating a Data Channel and after setting the remote description
   - `forceMediaTransport`: if true, the connection allocates the SRTP media transport even if no tracks are present (necessary to add tracks during later renegotiation)

+ 4 - 4
src/impl/icetransport.cpp

@@ -90,10 +90,6 @@ IceTransport::IceTransport(const Configuration &config, candidate_callback candi
 	jconfig.cb_recv = IceTransport::RecvCallback;
 	jconfig.user_ptr = this;
 
-	if (config.enableIceTcp) {
-		PLOG_WARNING << "ICE-TCP is not supported with libjuice";
-	}
-
 	if (config.enableIceUdpMux) {
 		PLOG_DEBUG << "Enabling ICE UDP mux";
 		jconfig.concurrency_mode = JUICE_CONCURRENCY_MODE_MUX;
@@ -134,6 +130,10 @@ IceTransport::IceTransport(const Configuration &config, candidate_callback candi
 	if (!mAgent)
 		throw std::runtime_error("Failed to create the ICE agent");
 
+	// ICE-TCP
+	juice_set_ice_tcp_mode(mAgent.get(), config.enableIceTcp ? JUICE_ICE_TCP_MODE_ACTIVE
+	                                                         : JUICE_ICE_TCP_MODE_NONE);
+
 	// Add TURN servers
 	for (const auto &server : servers)
 		if (!server.hostname.empty() && server.type != IceServer::Type::Stun)