OLD | NEW |
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 Google Inc. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 #include "webrtc/system_wrappers/include/field_trial.h" | 59 #include "webrtc/system_wrappers/include/field_trial.h" |
60 | 60 |
61 namespace { | 61 namespace { |
62 | 62 |
63 using webrtc::DataChannel; | 63 using webrtc::DataChannel; |
64 using webrtc::MediaConstraintsInterface; | 64 using webrtc::MediaConstraintsInterface; |
65 using webrtc::MediaStreamInterface; | 65 using webrtc::MediaStreamInterface; |
66 using webrtc::PeerConnectionInterface; | 66 using webrtc::PeerConnectionInterface; |
67 using webrtc::RtpSenderInterface; | 67 using webrtc::RtpSenderInterface; |
68 using webrtc::StreamCollection; | 68 using webrtc::StreamCollection; |
69 using webrtc::StunConfigurations; | |
70 using webrtc::TurnConfigurations; | |
71 typedef webrtc::PortAllocatorFactoryInterface::StunConfiguration | |
72 StunConfiguration; | |
73 typedef webrtc::PortAllocatorFactoryInterface::TurnConfiguration | |
74 TurnConfiguration; | |
75 | 69 |
76 static const char kDefaultStreamLabel[] = "default"; | 70 static const char kDefaultStreamLabel[] = "default"; |
77 static const char kDefaultAudioTrackLabel[] = "defaulta0"; | 71 static const char kDefaultAudioTrackLabel[] = "defaulta0"; |
78 static const char kDefaultVideoTrackLabel[] = "defaultv0"; | 72 static const char kDefaultVideoTrackLabel[] = "defaultv0"; |
79 | 73 |
80 // The min number of tokens must present in Turn host uri. | 74 // The min number of tokens must present in Turn host uri. |
81 // e.g. user@turn.example.org | 75 // e.g. user@turn.example.org |
82 static const size_t kTurnHostTokensNum = 2; | 76 static const size_t kTurnHostTokensNum = 2; |
83 // Number of tokens must be preset when TURN uri has transport param. | 77 // Number of tokens must be preset when TURN uri has transport param. |
84 static const size_t kTurnTransportTokensNum = 2; | 78 static const size_t kTurnTransportTokensNum = 2; |
85 // The default stun port. | 79 // The default stun port. |
86 static const int kDefaultStunPort = 3478; | 80 static const int kDefaultStunPort = 3478; |
87 static const int kDefaultStunTlsPort = 5349; | 81 static const int kDefaultStunTlsPort = 5349; |
88 static const char kTransport[] = "transport"; | 82 static const char kTransport[] = "transport"; |
89 static const char kUdpTransportType[] = "udp"; | |
90 static const char kTcpTransportType[] = "tcp"; | |
91 | 83 |
92 // NOTE: Must be in the same order as the ServiceType enum. | 84 // NOTE: Must be in the same order as the ServiceType enum. |
93 static const char* kValidIceServiceTypes[] = {"stun", "stuns", "turn", "turns"}; | 85 static const char* kValidIceServiceTypes[] = {"stun", "stuns", "turn", "turns"}; |
94 | 86 |
95 // NOTE: A loop below assumes that the first value of this enum is 0 and all | 87 // NOTE: A loop below assumes that the first value of this enum is 0 and all |
96 // other values are incremental. | 88 // other values are incremental. |
97 enum ServiceType { | 89 enum ServiceType { |
98 STUN = 0, // Indicates a STUN server. | 90 STUN = 0, // Indicates a STUN server. |
99 STUNS, // Indicates a STUN server used with a TLS session. | 91 STUNS, // Indicates a STUN server used with a TLS session. |
100 TURN, // Indicates a TURN server | 92 TURN, // Indicates a TURN server |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 return false; | 208 return false; |
217 } | 209 } |
218 *host = in_str.substr(0, colonpos); | 210 *host = in_str.substr(0, colonpos); |
219 } else { | 211 } else { |
220 *host = in_str; | 212 *host = in_str; |
221 } | 213 } |
222 } | 214 } |
223 return !host->empty(); | 215 return !host->empty(); |
224 } | 216 } |
225 | 217 |
226 // Adds a StunConfiguration or TurnConfiguration to the appropriate list, | 218 // Adds a STUN or TURN server to the appropriate list, |
227 // by parsing |url| and using the username/password in |server|. | 219 // by parsing |url| and using the username/password in |server|. |
228 bool ParseIceServerUrl(const PeerConnectionInterface::IceServer& server, | 220 bool ParseIceServerUrl(const PeerConnectionInterface::IceServer& server, |
229 const std::string& url, | 221 const std::string& url, |
230 StunConfigurations* stun_config, | 222 cricket::ServerAddresses* stun_servers, |
231 TurnConfigurations* turn_config) { | 223 std::vector<cricket::RelayServerConfig>* turn_servers) { |
232 // draft-nandakumar-rtcweb-stun-uri-01 | 224 // draft-nandakumar-rtcweb-stun-uri-01 |
233 // stunURI = scheme ":" stun-host [ ":" stun-port ] | 225 // stunURI = scheme ":" stun-host [ ":" stun-port ] |
234 // scheme = "stun" / "stuns" | 226 // scheme = "stun" / "stuns" |
235 // stun-host = IP-literal / IPv4address / reg-name | 227 // stun-host = IP-literal / IPv4address / reg-name |
236 // stun-port = *DIGIT | 228 // stun-port = *DIGIT |
237 | 229 |
238 // draft-petithuguenin-behave-turn-uris-01 | 230 // draft-petithuguenin-behave-turn-uris-01 |
239 // turnURI = scheme ":" turn-host [ ":" turn-port ] | 231 // turnURI = scheme ":" turn-host [ ":" turn-port ] |
240 // [ "?transport=" transport ] | 232 // [ "?transport=" transport ] |
241 // scheme = "turn" / "turns" | 233 // scheme = "turn" / "turns" |
242 // transport = "udp" / "tcp" / transport-ext | 234 // transport = "udp" / "tcp" / transport-ext |
243 // transport-ext = 1*unreserved | 235 // transport-ext = 1*unreserved |
244 // turn-host = IP-literal / IPv4address / reg-name | 236 // turn-host = IP-literal / IPv4address / reg-name |
245 // turn-port = *DIGIT | 237 // turn-port = *DIGIT |
246 RTC_DCHECK(stun_config != nullptr); | 238 RTC_DCHECK(stun_servers != nullptr); |
247 RTC_DCHECK(turn_config != nullptr); | 239 RTC_DCHECK(turn_servers != nullptr); |
248 std::vector<std::string> tokens; | 240 std::vector<std::string> tokens; |
249 std::string turn_transport_type = kUdpTransportType; | 241 cricket::ProtocolType turn_transport_type = cricket::PROTO_UDP; |
250 RTC_DCHECK(!url.empty()); | 242 RTC_DCHECK(!url.empty()); |
251 rtc::tokenize(url, '?', &tokens); | 243 rtc::tokenize(url, '?', &tokens); |
252 std::string uri_without_transport = tokens[0]; | 244 std::string uri_without_transport = tokens[0]; |
253 // Let's look into transport= param, if it exists. | 245 // Let's look into transport= param, if it exists. |
254 if (tokens.size() == kTurnTransportTokensNum) { // ?transport= is present. | 246 if (tokens.size() == kTurnTransportTokensNum) { // ?transport= is present. |
255 std::string uri_transport_param = tokens[1]; | 247 std::string uri_transport_param = tokens[1]; |
256 rtc::tokenize(uri_transport_param, '=', &tokens); | 248 rtc::tokenize(uri_transport_param, '=', &tokens); |
257 if (tokens[0] == kTransport) { | 249 if (tokens[0] == kTransport) { |
258 // As per above grammar transport param will be consist of lower case | 250 // As per above grammar transport param will be consist of lower case |
259 // letters. | 251 // letters. |
260 if (tokens[1] != kUdpTransportType && tokens[1] != kTcpTransportType) { | 252 if (!cricket::StringToProto(tokens[1].c_str(), &turn_transport_type) || |
| 253 (turn_transport_type != cricket::PROTO_UDP && |
| 254 turn_transport_type != cricket::PROTO_TCP)) { |
261 LOG(LS_WARNING) << "Transport param should always be udp or tcp."; | 255 LOG(LS_WARNING) << "Transport param should always be udp or tcp."; |
262 return false; | 256 return false; |
263 } | 257 } |
264 turn_transport_type = tokens[1]; | |
265 } | 258 } |
266 } | 259 } |
267 | 260 |
268 std::string hoststring; | 261 std::string hoststring; |
269 ServiceType service_type; | 262 ServiceType service_type; |
270 if (!GetServiceTypeAndHostnameFromUri(uri_without_transport, | 263 if (!GetServiceTypeAndHostnameFromUri(uri_without_transport, |
271 &service_type, | 264 &service_type, |
272 &hoststring)) { | 265 &hoststring)) { |
273 LOG(LS_WARNING) << "Invalid transport parameter in ICE URI: " << url; | 266 LOG(LS_WARNING) << "Invalid transport parameter in ICE URI: " << url; |
274 return false; | 267 return false; |
(...skipping 18 matching lines...) Expand all Loading... |
293 } | 286 } |
294 username.assign(rtc::s_url_decode(tokens[0])); | 287 username.assign(rtc::s_url_decode(tokens[0])); |
295 hoststring = tokens[1]; | 288 hoststring = tokens[1]; |
296 } else { | 289 } else { |
297 hoststring = tokens[0]; | 290 hoststring = tokens[0]; |
298 } | 291 } |
299 | 292 |
300 int port = kDefaultStunPort; | 293 int port = kDefaultStunPort; |
301 if (service_type == TURNS) { | 294 if (service_type == TURNS) { |
302 port = kDefaultStunTlsPort; | 295 port = kDefaultStunTlsPort; |
303 turn_transport_type = kTcpTransportType; | 296 turn_transport_type = cricket::PROTO_TCP; |
304 } | 297 } |
305 | 298 |
306 std::string address; | 299 std::string address; |
307 if (!ParseHostnameAndPortFromString(hoststring, &address, &port)) { | 300 if (!ParseHostnameAndPortFromString(hoststring, &address, &port)) { |
308 LOG(WARNING) << "Invalid hostname format: " << uri_without_transport; | 301 LOG(WARNING) << "Invalid hostname format: " << uri_without_transport; |
309 return false; | 302 return false; |
310 } | 303 } |
311 | 304 |
312 if (port <= 0 || port > 0xffff) { | 305 if (port <= 0 || port > 0xffff) { |
313 LOG(WARNING) << "Invalid port: " << port; | 306 LOG(WARNING) << "Invalid port: " << port; |
314 return false; | 307 return false; |
315 } | 308 } |
316 | 309 |
317 switch (service_type) { | 310 switch (service_type) { |
318 case STUN: | 311 case STUN: |
319 case STUNS: | 312 case STUNS: |
320 stun_config->push_back(StunConfiguration(address, port)); | 313 stun_servers->insert(rtc::SocketAddress(address, port)); |
321 break; | 314 break; |
322 case TURN: | 315 case TURN: |
323 case TURNS: { | 316 case TURNS: { |
324 bool secure = (service_type == TURNS); | 317 bool secure = (service_type == TURNS); |
325 turn_config->push_back(TurnConfiguration(address, port, | 318 turn_servers->push_back( |
326 username, | 319 cricket::RelayServerConfig(address, port, username, server.password, |
327 server.password, | 320 turn_transport_type, secure)); |
328 turn_transport_type, | |
329 secure)); | |
330 break; | 321 break; |
331 } | 322 } |
332 case INVALID: | 323 case INVALID: |
333 default: | 324 default: |
334 LOG(WARNING) << "Configuration not supported: " << url; | 325 LOG(WARNING) << "Configuration not supported: " << url; |
335 return false; | 326 return false; |
336 } | 327 } |
337 return true; | 328 return true; |
338 } | 329 } |
339 | 330 |
340 void ConvertToCricketIceServers( | |
341 const std::vector<StunConfiguration>& stuns, | |
342 const std::vector<TurnConfiguration>& turns, | |
343 cricket::ServerAddresses* cricket_stuns, | |
344 std::vector<cricket::RelayServerConfig>* cricket_turns) { | |
345 RTC_DCHECK(cricket_stuns && cricket_turns); | |
346 for (const StunConfiguration& stun : stuns) { | |
347 cricket_stuns->insert(stun.server); | |
348 } | |
349 | |
350 int priority = static_cast<int>(turns.size() - 1); | |
351 for (const TurnConfiguration& turn : turns) { | |
352 cricket::RelayCredentials credentials(turn.username, turn.password); | |
353 cricket::RelayServerConfig relay_server(cricket::RELAY_TURN); | |
354 cricket::ProtocolType protocol; | |
355 // Using VERIFY because ParseIceServers should have already caught an | |
356 // invalid transport type. | |
357 if (!VERIFY( | |
358 cricket::StringToProto(turn.transport_type.c_str(), &protocol))) { | |
359 LOG(LS_WARNING) << "Ignoring TURN server " << turn.server << ". " | |
360 << "Reason= Incorrect " << turn.transport_type | |
361 << " transport parameter."; | |
362 } else { | |
363 relay_server.ports.push_back( | |
364 cricket::ProtocolAddress(turn.server, protocol, turn.secure)); | |
365 relay_server.credentials = credentials; | |
366 relay_server.priority = priority; | |
367 cricket_turns->push_back(relay_server); | |
368 } | |
369 // First in the list gets highest priority. | |
370 --priority; | |
371 } | |
372 } | |
373 | |
374 // Check if we can send |new_stream| on a PeerConnection. | 331 // Check if we can send |new_stream| on a PeerConnection. |
375 bool CanAddLocalMediaStream(webrtc::StreamCollectionInterface* current_streams, | 332 bool CanAddLocalMediaStream(webrtc::StreamCollectionInterface* current_streams, |
376 webrtc::MediaStreamInterface* new_stream) { | 333 webrtc::MediaStreamInterface* new_stream) { |
377 if (!new_stream || !current_streams) { | 334 if (!new_stream || !current_streams) { |
378 return false; | 335 return false; |
379 } | 336 } |
380 if (current_streams->find(new_stream->label()) != nullptr) { | 337 if (current_streams->find(new_stream->label()) != nullptr) { |
381 LOG(LS_ERROR) << "MediaStream with label " << new_stream->label() | 338 LOG(LS_ERROR) << "MediaStream with label " << new_stream->label() |
382 << " is already added."; | 339 << " is already added."; |
383 return false; | 340 return false; |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
556 session_options->transport_options.ice_restart = false; | 513 session_options->transport_options.ice_restart = false; |
557 } | 514 } |
558 | 515 |
559 if (!constraints) { | 516 if (!constraints) { |
560 return true; | 517 return true; |
561 } | 518 } |
562 return mandatory_constraints_satisfied == constraints->GetMandatory().size(); | 519 return mandatory_constraints_satisfied == constraints->GetMandatory().size(); |
563 } | 520 } |
564 | 521 |
565 bool ParseIceServers(const PeerConnectionInterface::IceServers& servers, | 522 bool ParseIceServers(const PeerConnectionInterface::IceServers& servers, |
566 StunConfigurations* stun_config, | 523 cricket::ServerAddresses* stun_servers, |
567 TurnConfigurations* turn_config) { | 524 std::vector<cricket::RelayServerConfig>* turn_servers) { |
568 for (const webrtc::PeerConnectionInterface::IceServer& server : servers) { | 525 for (const webrtc::PeerConnectionInterface::IceServer& server : servers) { |
569 if (!server.urls.empty()) { | 526 if (!server.urls.empty()) { |
570 for (const std::string& url : server.urls) { | 527 for (const std::string& url : server.urls) { |
571 if (url.empty()) { | 528 if (url.empty()) { |
572 LOG(LS_ERROR) << "Empty uri."; | 529 LOG(LS_ERROR) << "Empty uri."; |
573 return false; | 530 return false; |
574 } | 531 } |
575 if (!ParseIceServerUrl(server, url, stun_config, turn_config)) { | 532 if (!ParseIceServerUrl(server, url, stun_servers, turn_servers)) { |
576 return false; | 533 return false; |
577 } | 534 } |
578 } | 535 } |
579 } else if (!server.uri.empty()) { | 536 } else if (!server.uri.empty()) { |
580 // Fallback to old .uri if new .urls isn't present. | 537 // Fallback to old .uri if new .urls isn't present. |
581 if (!ParseIceServerUrl(server, server.uri, stun_config, turn_config)) { | 538 if (!ParseIceServerUrl(server, server.uri, stun_servers, turn_servers)) { |
582 return false; | 539 return false; |
583 } | 540 } |
584 } else { | 541 } else { |
585 LOG(LS_ERROR) << "Empty uri."; | 542 LOG(LS_ERROR) << "Empty uri."; |
586 return false; | 543 return false; |
587 } | 544 } |
588 } | 545 } |
| 546 // Candidates must have unique priorities, so that connectivity checks |
| 547 // are performed in a well-defined order. |
| 548 int priority = static_cast<int>(turn_servers->size() - 1); |
| 549 for (cricket::RelayServerConfig& turn_server : *turn_servers) { |
| 550 // First in the list gets highest priority. |
| 551 turn_server.priority = priority--; |
| 552 } |
589 return true; | 553 return true; |
590 } | 554 } |
591 | 555 |
592 PeerConnection::PeerConnection(PeerConnectionFactory* factory) | 556 PeerConnection::PeerConnection(PeerConnectionFactory* factory) |
593 : factory_(factory), | 557 : factory_(factory), |
594 observer_(NULL), | 558 observer_(NULL), |
595 uma_observer_(NULL), | 559 uma_observer_(NULL), |
596 signaling_state_(kStable), | 560 signaling_state_(kStable), |
597 ice_state_(kIceNew), | 561 ice_state_(kIceNew), |
598 ice_connection_state_(kIceConnectionNew), | 562 ice_connection_state_(kIceConnectionNew), |
(...skipping 10 matching lines...) Expand all Loading... |
609 sender->Stop(); | 573 sender->Stop(); |
610 } | 574 } |
611 for (const auto& receiver : receivers_) { | 575 for (const auto& receiver : receivers_) { |
612 receiver->Stop(); | 576 receiver->Stop(); |
613 } | 577 } |
614 } | 578 } |
615 | 579 |
616 bool PeerConnection::Initialize( | 580 bool PeerConnection::Initialize( |
617 const PeerConnectionInterface::RTCConfiguration& configuration, | 581 const PeerConnectionInterface::RTCConfiguration& configuration, |
618 const MediaConstraintsInterface* constraints, | 582 const MediaConstraintsInterface* constraints, |
619 PortAllocatorFactoryInterface* allocator_factory, | |
620 rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store, | |
621 PeerConnectionObserver* observer) { | |
622 RTC_DCHECK(observer != nullptr); | |
623 if (!observer) { | |
624 return false; | |
625 } | |
626 | |
627 // This Initialize function parses ICE servers an extra time, but it will | |
628 // be removed once all PortAllocaotrs support SetIceServers. | |
629 std::vector<PortAllocatorFactoryInterface::StunConfiguration> stun_config; | |
630 std::vector<PortAllocatorFactoryInterface::TurnConfiguration> turn_config; | |
631 if (!ParseIceServers(configuration.servers, &stun_config, &turn_config)) { | |
632 return false; | |
633 } | |
634 rtc::scoped_ptr<cricket::PortAllocator> allocator( | |
635 allocator_factory->CreatePortAllocator(stun_config, turn_config)); | |
636 return Initialize(configuration, constraints, std::move(allocator), | |
637 std::move(dtls_identity_store), observer); | |
638 } | |
639 | |
640 bool PeerConnection::Initialize( | |
641 const PeerConnectionInterface::RTCConfiguration& configuration, | |
642 const MediaConstraintsInterface* constraints, | |
643 rtc::scoped_ptr<cricket::PortAllocator> allocator, | 583 rtc::scoped_ptr<cricket::PortAllocator> allocator, |
644 rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store, | 584 rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store, |
645 PeerConnectionObserver* observer) { | 585 PeerConnectionObserver* observer) { |
646 TRACE_EVENT0("webrtc", "PeerConnection::Initialize"); | 586 TRACE_EVENT0("webrtc", "PeerConnection::Initialize"); |
647 RTC_DCHECK(observer != nullptr); | 587 RTC_DCHECK(observer != nullptr); |
648 if (!observer) { | 588 if (!observer) { |
649 return false; | 589 return false; |
650 } | 590 } |
651 observer_ = observer; | 591 observer_ = observer; |
652 | 592 |
653 port_allocator_ = std::move(allocator); | 593 port_allocator_ = std::move(allocator); |
654 | 594 |
655 std::vector<PortAllocatorFactoryInterface::StunConfiguration> stun_config; | 595 cricket::ServerAddresses stun_servers; |
656 std::vector<PortAllocatorFactoryInterface::TurnConfiguration> turn_config; | 596 std::vector<cricket::RelayServerConfig> turn_servers; |
657 if (!ParseIceServers(configuration.servers, &stun_config, &turn_config)) { | 597 if (!ParseIceServers(configuration.servers, &stun_servers, &turn_servers)) { |
658 return false; | 598 return false; |
659 } | 599 } |
660 | 600 port_allocator_->SetIceServers(stun_servers, turn_servers); |
661 cricket::ServerAddresses cricket_stuns; | |
662 std::vector<cricket::RelayServerConfig> cricket_turns; | |
663 ConvertToCricketIceServers(stun_config, turn_config, &cricket_stuns, | |
664 &cricket_turns); | |
665 port_allocator_->SetIceServers(cricket_stuns, cricket_turns); | |
666 | 601 |
667 // To handle both internal and externally created port allocator, we will | 602 // To handle both internal and externally created port allocator, we will |
668 // enable BUNDLE here. | 603 // enable BUNDLE here. |
669 int portallocator_flags = port_allocator_->flags(); | 604 int portallocator_flags = port_allocator_->flags(); |
670 portallocator_flags |= cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET | | 605 portallocator_flags |= cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET | |
671 cricket::PORTALLOCATOR_ENABLE_IPV6; | 606 cricket::PORTALLOCATOR_ENABLE_IPV6; |
672 bool value; | 607 bool value; |
673 // If IPv6 flag was specified, we'll not override it by experiment. | 608 // If IPv6 flag was specified, we'll not override it by experiment. |
674 if (FindConstraint(constraints, MediaConstraintsInterface::kEnableIPv6, | 609 if (FindConstraint(constraints, MediaConstraintsInterface::kEnableIPv6, |
675 &value, nullptr)) { | 610 &value, nullptr)) { |
(...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1174 | 1109 |
1175 UpdateEndedRemoteMediaStreams(); | 1110 UpdateEndedRemoteMediaStreams(); |
1176 | 1111 |
1177 SetSessionDescriptionMsg* msg = new SetSessionDescriptionMsg(observer); | 1112 SetSessionDescriptionMsg* msg = new SetSessionDescriptionMsg(observer); |
1178 signaling_thread()->Post(this, MSG_SET_SESSIONDESCRIPTION_SUCCESS, msg); | 1113 signaling_thread()->Post(this, MSG_SET_SESSIONDESCRIPTION_SUCCESS, msg); |
1179 } | 1114 } |
1180 | 1115 |
1181 bool PeerConnection::SetConfiguration(const RTCConfiguration& config) { | 1116 bool PeerConnection::SetConfiguration(const RTCConfiguration& config) { |
1182 TRACE_EVENT0("webrtc", "PeerConnection::SetConfiguration"); | 1117 TRACE_EVENT0("webrtc", "PeerConnection::SetConfiguration"); |
1183 if (port_allocator_) { | 1118 if (port_allocator_) { |
1184 std::vector<PortAllocatorFactoryInterface::StunConfiguration> stuns; | 1119 cricket::ServerAddresses stun_servers; |
1185 std::vector<PortAllocatorFactoryInterface::TurnConfiguration> turns; | 1120 std::vector<cricket::RelayServerConfig> turn_servers; |
1186 if (!ParseIceServers(config.servers, &stuns, &turns)) { | 1121 if (!ParseIceServers(config.servers, &stun_servers, &turn_servers)) { |
1187 return false; | 1122 return false; |
1188 } | 1123 } |
1189 | 1124 port_allocator_->SetIceServers(stun_servers, turn_servers); |
1190 cricket::ServerAddresses cricket_stuns; | |
1191 std::vector<cricket::RelayServerConfig> cricket_turns; | |
1192 ConvertToCricketIceServers(stuns, turns, &cricket_stuns, &cricket_turns); | |
1193 port_allocator_->SetIceServers(cricket_stuns, cricket_turns); | |
1194 } | 1125 } |
1195 session_->SetIceConfig(session_->ParseIceConfig(config)); | 1126 session_->SetIceConfig(session_->ParseIceConfig(config)); |
1196 return session_->SetIceTransports(config.type); | 1127 return session_->SetIceTransports(config.type); |
1197 } | 1128 } |
1198 | 1129 |
1199 bool PeerConnection::AddIceCandidate( | 1130 bool PeerConnection::AddIceCandidate( |
1200 const IceCandidateInterface* ice_candidate) { | 1131 const IceCandidateInterface* ice_candidate) { |
1201 TRACE_EVENT0("webrtc", "PeerConnection::AddIceCandidate"); | 1132 TRACE_EVENT0("webrtc", "PeerConnection::AddIceCandidate"); |
1202 return session_->ProcessIceMessage(ice_candidate); | 1133 return session_->ProcessIceMessage(ice_candidate); |
1203 } | 1134 } |
(...skipping 868 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2072 DataChannel* PeerConnection::FindDataChannelBySid(int sid) const { | 2003 DataChannel* PeerConnection::FindDataChannelBySid(int sid) const { |
2073 for (const auto& channel : sctp_data_channels_) { | 2004 for (const auto& channel : sctp_data_channels_) { |
2074 if (channel->id() == sid) { | 2005 if (channel->id() == sid) { |
2075 return channel; | 2006 return channel; |
2076 } | 2007 } |
2077 } | 2008 } |
2078 return nullptr; | 2009 return nullptr; |
2079 } | 2010 } |
2080 | 2011 |
2081 } // namespace webrtc | 2012 } // namespace webrtc |
OLD | NEW |