소스 검색

Added bindAddress configuration setting

Paul-Louis Ageneau 4 년 전
부모
커밋
c5cb81762c
4개의 변경된 파일17개의 추가작업 그리고 7개의 파일을 삭제
  1. 1 0
      include/rtc/configuration.hpp
  2. 5 4
      include/rtc/rtc.h
  3. 6 3
      src/capi.cpp
  4. 5 0
      src/impl/icetransport.cpp

+ 1 - 0
include/rtc/configuration.hpp

@@ -74,6 +74,7 @@ struct RTC_CPP_EXPORT Configuration {
 	// ICE settings
 	std::vector<IceServer> iceServers;
 	optional<ProxyServer> proxyServer; // libnice only
+	optional<string> bindAddress;      // libjuice only, default any
 
 	// Options
 	CertificateType certificateType = CertificateType::Default;

+ 5 - 4
include/rtc/rtc.h

@@ -150,13 +150,14 @@ RTC_EXPORT void *rtcGetUserPointer(int i);
 typedef struct {
 	const char **iceServers;
 	int iceServersCount;
+	const char *bindAddress; // libjuice only, NULL means any
 	rtcCertificateType certificateType;
 	bool enableIceTcp;
 	bool disableAutoNegotiation;
-	uint16_t portRangeBegin;
-	uint16_t portRangeEnd;
-	int mtu;            // <= 0 means automatic
-	int maxMessageSize; // <= 0 means default
+	uint16_t portRangeBegin; // 0 means automatic
+	uint16_t portRangeEnd;   // 0 means automatic
+	int mtu;                 // <= 0 means automatic
+	int maxMessageSize;      // <= 0 means default
 } rtcConfiguration;
 
 RTC_EXPORT int rtcCreatePeerConnection(const rtcConfiguration *config); // returns pc id

+ 6 - 3
src/capi.cpp

@@ -290,15 +290,18 @@ int rtcCreatePeerConnection(const rtcConfiguration *config) {
 		for (int i = 0; i < config->iceServersCount; ++i)
 			c.iceServers.emplace_back(string(config->iceServers[i]));
 
-		c.certificateType = static_cast<CertificateType>(config->certificateType);
-		c.enableIceTcp = config->enableIceTcp;
-		c.disableAutoNegotiation = config->disableAutoNegotiation;
+		if (config->bindAddress)
+			c.bindAddress = string(config->bindAddress);
 
 		if (config->portRangeBegin > 0 || config->portRangeEnd > 0) {
 			c.portRangeBegin = config->portRangeBegin;
 			c.portRangeEnd = config->portRangeEnd;
 		}
 
+		c.certificateType = static_cast<CertificateType>(config->certificateType);
+		c.enableIceTcp = config->enableIceTcp;
+		c.disableAutoNegotiation = config->disableAutoNegotiation;
+
 		if (config->mtu > 0)
 			c.mtu = size_t(config->mtu);
 

+ 5 - 0
src/impl/icetransport.cpp

@@ -131,6 +131,11 @@ IceTransport::IceTransport(const Configuration &config, candidate_callback candi
 	jconfig.turn_servers = k > 0 ? turn_servers : nullptr;
 	jconfig.turn_servers_count = k;
 
+	// Bind address
+	if (config.bindAddress) {
+		jconfig.bind_address = config.bindAddress->c_str();
+	}
+
 	// Port range
 	if (config.portRangeBegin > 1024 ||
 	    (config.portRangeEnd != 0 && config.portRangeEnd != 65535)) {