OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 907 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
918 | 918 |
919 if (port) { | 919 if (port) { |
920 // If shared socket is enabled, STUN candidate will be allocated by the | 920 // If shared socket is enabled, STUN candidate will be allocated by the |
921 // UDPPort. | 921 // UDPPort. |
922 if (IsFlagSet(PORTALLOCATOR_ENABLE_SHARED_SOCKET)) { | 922 if (IsFlagSet(PORTALLOCATOR_ENABLE_SHARED_SOCKET)) { |
923 udp_port_ = port; | 923 udp_port_ = port; |
924 port->SignalDestroyed.connect(this, &AllocationSequence::OnPortDestroyed); | 924 port->SignalDestroyed.connect(this, &AllocationSequence::OnPortDestroyed); |
925 | 925 |
926 // If STUN is not disabled, setting stun server address to port. | 926 // If STUN is not disabled, setting stun server address to port. |
927 if (!IsFlagSet(PORTALLOCATOR_DISABLE_STUN)) { | 927 if (!IsFlagSet(PORTALLOCATOR_DISABLE_STUN)) { |
928 // If config has stun_servers, use it to get server reflexive candidate | |
929 // otherwise use first TURN server which supports UDP. | |
930 if (config_ && !config_->StunServers().empty()) { | 928 if (config_ && !config_->StunServers().empty()) { |
pthatcher1
2015/07/06 22:28:32
Does it make sense to check for !empty() still? S
Taylor Brandstetter
2015/07/07 00:00:04
It's a little redundant but at least it means you
| |
931 LOG(LS_INFO) << "AllocationSequence: UDPPort will be handling the " | 929 LOG(LS_INFO) << "AllocationSequence: UDPPort will be handling the " |
932 << "STUN candidate generation."; | 930 << "STUN candidate generation."; |
933 port->set_server_addresses(config_->StunServers()); | 931 port->set_server_addresses(config_->StunServers()); |
934 } else if (config_ && | |
935 config_->SupportsProtocol(RELAY_TURN, PROTO_UDP)) { | |
936 port->set_server_addresses(config_->GetRelayServerAddresses( | |
937 RELAY_TURN, PROTO_UDP)); | |
938 LOG(LS_INFO) << "AllocationSequence: TURN Server address will be " | |
939 << " used for generating STUN candidate."; | |
940 } | 932 } |
941 } | 933 } |
942 } | 934 } |
943 | 935 |
944 session_->AddAllocatedPort(port, this, true); | 936 session_->AddAllocatedPort(port, this, true); |
945 } | 937 } |
946 } | 938 } |
947 | 939 |
948 void AllocationSequence::CreateTCPPorts() { | 940 void AllocationSequence::CreateTCPPorts() { |
949 if (IsFlagSet(PORTALLOCATOR_DISABLE_TCP)) { | 941 if (IsFlagSet(PORTALLOCATOR_DISABLE_TCP)) { |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1162 password(password) { | 1154 password(password) { |
1163 if (!stun_servers.empty()) | 1155 if (!stun_servers.empty()) |
1164 stun_address = *(stun_servers.begin()); | 1156 stun_address = *(stun_servers.begin()); |
1165 } | 1157 } |
1166 | 1158 |
1167 ServerAddresses PortConfiguration::StunServers() { | 1159 ServerAddresses PortConfiguration::StunServers() { |
1168 if (!stun_address.IsNil() && | 1160 if (!stun_address.IsNil() && |
1169 stun_servers.find(stun_address) == stun_servers.end()) { | 1161 stun_servers.find(stun_address) == stun_servers.end()) { |
1170 stun_servers.insert(stun_address); | 1162 stun_servers.insert(stun_address); |
1171 } | 1163 } |
1164 // Every UDP TURN server should also be used as a STUN server. | |
1165 ServerAddresses turn_servers = GetRelayServerAddresses(RELAY_TURN, | |
1166 PROTO_UDP); | |
pthatcher1
2015/07/06 22:28:32
Please run "git cl format" and use whatever style
pthatcher1
2015/07/06 22:28:32
Do we still need the check for SupportsProtocol(RE
Taylor Brandstetter
2015/07/07 00:00:04
Done
Taylor Brandstetter
2015/07/07 00:00:04
GetRelayServerAddresses(RELAY_TURN, PROTO_UDP) wil
| |
1167 for (ServerAddresses::iterator turn_server = turn_servers.begin(); | |
juberti1
2015/06/29 18:54:48
I think this could be done as
for (auto turn_ser
Taylor Brandstetter
2015/06/29 20:18:34
Good point. In this case I think I'll use "for (rt
pthatcher1
2015/07/06 22:28:32
I think
for (const rtc::SocketAddress& turn_serv
Taylor Brandstetter
2015/07/07 00:00:04
Already did that. :)
| |
1168 turn_server != turn_servers.end(); ++turn_server) { | |
1169 if (stun_servers.find(*turn_server) == stun_servers.end()) { | |
1170 stun_servers.insert(*turn_server); | |
1171 } | |
1172 } | |
1172 return stun_servers; | 1173 return stun_servers; |
1173 } | 1174 } |
1174 | 1175 |
1175 void PortConfiguration::AddRelay(const RelayServerConfig& config) { | 1176 void PortConfiguration::AddRelay(const RelayServerConfig& config) { |
1176 relays.push_back(config); | 1177 relays.push_back(config); |
1177 } | 1178 } |
1178 | 1179 |
1179 bool PortConfiguration::SupportsProtocol( | 1180 bool PortConfiguration::SupportsProtocol( |
1180 const RelayServerConfig& relay, ProtocolType type) const { | 1181 const RelayServerConfig& relay, ProtocolType type) const { |
1181 PortList::const_iterator relay_port; | 1182 PortList::const_iterator relay_port; |
(...skipping 21 matching lines...) Expand all Loading... | |
1203 ServerAddresses servers; | 1204 ServerAddresses servers; |
1204 for (size_t i = 0; i < relays.size(); ++i) { | 1205 for (size_t i = 0; i < relays.size(); ++i) { |
1205 if (relays[i].type == turn_type && SupportsProtocol(relays[i], type)) { | 1206 if (relays[i].type == turn_type && SupportsProtocol(relays[i], type)) { |
1206 servers.insert(relays[i].ports.front().address); | 1207 servers.insert(relays[i].ports.front().address); |
1207 } | 1208 } |
1208 } | 1209 } |
1209 return servers; | 1210 return servers; |
1210 } | 1211 } |
1211 | 1212 |
1212 } // namespace cricket | 1213 } // namespace cricket |
OLD | NEW |