Chromium Code Reviews| 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 57 #include "webrtc/system_wrappers/include/field_trial.h" | 57 #include "webrtc/system_wrappers/include/field_trial.h" |
| 58 | 58 |
| 59 namespace { | 59 namespace { |
| 60 | 60 |
| 61 using webrtc::DataChannel; | 61 using webrtc::DataChannel; |
| 62 using webrtc::MediaConstraintsInterface; | 62 using webrtc::MediaConstraintsInterface; |
| 63 using webrtc::MediaStreamInterface; | 63 using webrtc::MediaStreamInterface; |
| 64 using webrtc::PeerConnectionInterface; | 64 using webrtc::PeerConnectionInterface; |
| 65 using webrtc::RtpSenderInterface; | 65 using webrtc::RtpSenderInterface; |
| 66 using webrtc::StreamCollection; | 66 using webrtc::StreamCollection; |
| 67 using webrtc::StunConfigurations; | |
| 68 using webrtc::TurnConfigurations; | |
| 69 typedef webrtc::PortAllocatorFactoryInterface::StunConfiguration | |
| 70 StunConfiguration; | |
| 71 typedef webrtc::PortAllocatorFactoryInterface::TurnConfiguration | |
| 72 TurnConfiguration; | |
| 73 | 67 |
| 74 static const char kDefaultStreamLabel[] = "default"; | 68 static const char kDefaultStreamLabel[] = "default"; |
| 75 static const char kDefaultAudioTrackLabel[] = "defaulta0"; | 69 static const char kDefaultAudioTrackLabel[] = "defaulta0"; |
| 76 static const char kDefaultVideoTrackLabel[] = "defaultv0"; | 70 static const char kDefaultVideoTrackLabel[] = "defaultv0"; |
| 77 | 71 |
| 78 // The min number of tokens must present in Turn host uri. | 72 // The min number of tokens must present in Turn host uri. |
| 79 // e.g. user@turn.example.org | 73 // e.g. user@turn.example.org |
| 80 static const size_t kTurnHostTokensNum = 2; | 74 static const size_t kTurnHostTokensNum = 2; |
| 81 // Number of tokens must be preset when TURN uri has transport param. | 75 // Number of tokens must be preset when TURN uri has transport param. |
| 82 static const size_t kTurnTransportTokensNum = 2; | 76 static const size_t kTurnTransportTokensNum = 2; |
| 83 // The default stun port. | 77 // The default stun port. |
| 84 static const int kDefaultStunPort = 3478; | 78 static const int kDefaultStunPort = 3478; |
| 85 static const int kDefaultStunTlsPort = 5349; | 79 static const int kDefaultStunTlsPort = 5349; |
| 86 static const char kTransport[] = "transport"; | 80 static const char kTransport[] = "transport"; |
| 87 static const char kUdpTransportType[] = "udp"; | |
| 88 static const char kTcpTransportType[] = "tcp"; | |
| 89 | 81 |
| 90 // NOTE: Must be in the same order as the ServiceType enum. | 82 // NOTE: Must be in the same order as the ServiceType enum. |
| 91 static const char* kValidIceServiceTypes[] = {"stun", "stuns", "turn", "turns"}; | 83 static const char* kValidIceServiceTypes[] = {"stun", "stuns", "turn", "turns"}; |
| 92 | 84 |
| 93 // NOTE: A loop below assumes that the first value of this enum is 0 and all | 85 // NOTE: A loop below assumes that the first value of this enum is 0 and all |
| 94 // other values are incremental. | 86 // other values are incremental. |
| 95 enum ServiceType { | 87 enum ServiceType { |
| 96 STUN = 0, // Indicates a STUN server. | 88 STUN = 0, // Indicates a STUN server. |
| 97 STUNS, // Indicates a STUN server used with a TLS session. | 89 STUNS, // Indicates a STUN server used with a TLS session. |
| 98 TURN, // Indicates a TURN server | 90 TURN, // Indicates a TURN server |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 213 return false; | 205 return false; |
| 214 } | 206 } |
| 215 *host = in_str.substr(0, colonpos); | 207 *host = in_str.substr(0, colonpos); |
| 216 } else { | 208 } else { |
| 217 *host = in_str; | 209 *host = in_str; |
| 218 } | 210 } |
| 219 } | 211 } |
| 220 return !host->empty(); | 212 return !host->empty(); |
| 221 } | 213 } |
| 222 | 214 |
| 223 // Adds a StunConfiguration or TurnConfiguration to the appropriate list, | 215 // Adds a STUN or TURN server to the appropriate list, |
| 224 // by parsing |url| and using the username/password in |server|. | 216 // by parsing |url| and using the username/password in |server|. |
| 225 bool ParseIceServerUrl(const PeerConnectionInterface::IceServer& server, | 217 bool ParseIceServerUrl(const PeerConnectionInterface::IceServer& server, |
| 226 const std::string& url, | 218 const std::string& url, |
| 227 StunConfigurations* stun_config, | 219 cricket::ServerAddresses* stun_servers, |
| 228 TurnConfigurations* turn_config) { | 220 std::vector<cricket::RelayServerConfig>* turn_servers) { |
| 229 // draft-nandakumar-rtcweb-stun-uri-01 | 221 // draft-nandakumar-rtcweb-stun-uri-01 |
| 230 // stunURI = scheme ":" stun-host [ ":" stun-port ] | 222 // stunURI = scheme ":" stun-host [ ":" stun-port ] |
| 231 // scheme = "stun" / "stuns" | 223 // scheme = "stun" / "stuns" |
| 232 // stun-host = IP-literal / IPv4address / reg-name | 224 // stun-host = IP-literal / IPv4address / reg-name |
| 233 // stun-port = *DIGIT | 225 // stun-port = *DIGIT |
| 234 | 226 |
| 235 // draft-petithuguenin-behave-turn-uris-01 | 227 // draft-petithuguenin-behave-turn-uris-01 |
| 236 // turnURI = scheme ":" turn-host [ ":" turn-port ] | 228 // turnURI = scheme ":" turn-host [ ":" turn-port ] |
| 237 // [ "?transport=" transport ] | 229 // [ "?transport=" transport ] |
| 238 // scheme = "turn" / "turns" | 230 // scheme = "turn" / "turns" |
| 239 // transport = "udp" / "tcp" / transport-ext | 231 // transport = "udp" / "tcp" / transport-ext |
| 240 // transport-ext = 1*unreserved | 232 // transport-ext = 1*unreserved |
| 241 // turn-host = IP-literal / IPv4address / reg-name | 233 // turn-host = IP-literal / IPv4address / reg-name |
| 242 // turn-port = *DIGIT | 234 // turn-port = *DIGIT |
| 243 RTC_DCHECK(stun_config != nullptr); | 235 RTC_DCHECK(stun_servers != nullptr); |
| 244 RTC_DCHECK(turn_config != nullptr); | 236 RTC_DCHECK(turn_servers != nullptr); |
| 245 std::vector<std::string> tokens; | 237 std::vector<std::string> tokens; |
| 246 std::string turn_transport_type = kUdpTransportType; | 238 cricket::ProtocolType turn_transport_type = cricket::PROTO_UDP; |
| 247 RTC_DCHECK(!url.empty()); | 239 RTC_DCHECK(!url.empty()); |
| 248 rtc::tokenize(url, '?', &tokens); | 240 rtc::tokenize(url, '?', &tokens); |
| 249 std::string uri_without_transport = tokens[0]; | 241 std::string uri_without_transport = tokens[0]; |
| 250 // Let's look into transport= param, if it exists. | 242 // Let's look into transport= param, if it exists. |
| 251 if (tokens.size() == kTurnTransportTokensNum) { // ?transport= is present. | 243 if (tokens.size() == kTurnTransportTokensNum) { // ?transport= is present. |
| 252 std::string uri_transport_param = tokens[1]; | 244 std::string uri_transport_param = tokens[1]; |
| 253 rtc::tokenize(uri_transport_param, '=', &tokens); | 245 rtc::tokenize(uri_transport_param, '=', &tokens); |
| 254 if (tokens[0] == kTransport) { | 246 if (tokens[0] == kTransport) { |
| 255 // As per above grammar transport param will be consist of lower case | 247 // As per above grammar transport param will be consist of lower case |
| 256 // letters. | 248 // letters. |
| 257 if (tokens[1] != kUdpTransportType && tokens[1] != kTcpTransportType) { | 249 if (!cricket::StringToProto(tokens[1].c_str(), &turn_transport_type) || |
| 250 (turn_transport_type != cricket::PROTO_UDP && | |
| 251 turn_transport_type != cricket::PROTO_TCP)) { | |
| 258 LOG(LS_WARNING) << "Transport param should always be udp or tcp."; | 252 LOG(LS_WARNING) << "Transport param should always be udp or tcp."; |
| 259 return false; | 253 return false; |
| 260 } | 254 } |
| 261 turn_transport_type = tokens[1]; | |
| 262 } | 255 } |
| 263 } | 256 } |
| 264 | 257 |
| 265 std::string hoststring; | 258 std::string hoststring; |
| 266 ServiceType service_type; | 259 ServiceType service_type; |
| 267 if (!GetServiceTypeAndHostnameFromUri(uri_without_transport, | 260 if (!GetServiceTypeAndHostnameFromUri(uri_without_transport, |
| 268 &service_type, | 261 &service_type, |
| 269 &hoststring)) { | 262 &hoststring)) { |
| 270 LOG(LS_WARNING) << "Invalid transport parameter in ICE URI: " << url; | 263 LOG(LS_WARNING) << "Invalid transport parameter in ICE URI: " << url; |
| 271 return false; | 264 return false; |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 290 } | 283 } |
| 291 username.assign(rtc::s_url_decode(tokens[0])); | 284 username.assign(rtc::s_url_decode(tokens[0])); |
| 292 hoststring = tokens[1]; | 285 hoststring = tokens[1]; |
| 293 } else { | 286 } else { |
| 294 hoststring = tokens[0]; | 287 hoststring = tokens[0]; |
| 295 } | 288 } |
| 296 | 289 |
| 297 int port = kDefaultStunPort; | 290 int port = kDefaultStunPort; |
| 298 if (service_type == TURNS) { | 291 if (service_type == TURNS) { |
| 299 port = kDefaultStunTlsPort; | 292 port = kDefaultStunTlsPort; |
| 300 turn_transport_type = kTcpTransportType; | 293 turn_transport_type = cricket::PROTO_TCP; |
| 301 } | 294 } |
| 302 | 295 |
| 303 std::string address; | 296 std::string address; |
| 304 if (!ParseHostnameAndPortFromString(hoststring, &address, &port)) { | 297 if (!ParseHostnameAndPortFromString(hoststring, &address, &port)) { |
| 305 LOG(WARNING) << "Invalid hostname format: " << uri_without_transport; | 298 LOG(WARNING) << "Invalid hostname format: " << uri_without_transport; |
| 306 return false; | 299 return false; |
| 307 } | 300 } |
| 308 | 301 |
| 309 if (port <= 0 || port > 0xffff) { | 302 if (port <= 0 || port > 0xffff) { |
| 310 LOG(WARNING) << "Invalid port: " << port; | 303 LOG(WARNING) << "Invalid port: " << port; |
| 311 return false; | 304 return false; |
| 312 } | 305 } |
| 313 | 306 |
| 314 switch (service_type) { | 307 switch (service_type) { |
| 315 case STUN: | 308 case STUN: |
| 316 case STUNS: | 309 case STUNS: |
| 317 stun_config->push_back(StunConfiguration(address, port)); | 310 stun_servers->insert(rtc::SocketAddress(address, port)); |
| 318 break; | 311 break; |
| 319 case TURN: | 312 case TURN: |
| 320 case TURNS: { | 313 case TURNS: { |
| 321 bool secure = (service_type == TURNS); | 314 bool secure = (service_type == TURNS); |
| 322 turn_config->push_back(TurnConfiguration(address, port, | 315 turn_servers->push_back( |
| 323 username, | 316 cricket::RelayServerConfig(address, port, username, server.password, |
| 324 server.password, | 317 turn_transport_type, secure)); |
| 325 turn_transport_type, | |
| 326 secure)); | |
| 327 break; | 318 break; |
| 328 } | 319 } |
| 329 case INVALID: | 320 case INVALID: |
| 330 default: | 321 default: |
| 331 LOG(WARNING) << "Configuration not supported: " << url; | 322 LOG(WARNING) << "Configuration not supported: " << url; |
| 332 return false; | 323 return false; |
| 333 } | 324 } |
| 334 return true; | 325 return true; |
| 335 } | 326 } |
| 336 | 327 |
| 337 void ConvertToCricketIceServers( | |
| 338 const std::vector<StunConfiguration>& stuns, | |
| 339 const std::vector<TurnConfiguration>& turns, | |
| 340 cricket::ServerAddresses* cricket_stuns, | |
| 341 std::vector<cricket::RelayServerConfig>* cricket_turns) { | |
| 342 RTC_DCHECK(cricket_stuns && cricket_turns); | |
| 343 for (const StunConfiguration& stun : stuns) { | |
| 344 cricket_stuns->insert(stun.server); | |
| 345 } | |
| 346 | |
| 347 int priority = static_cast<int>(turns.size() - 1); | |
| 348 for (const TurnConfiguration& turn : turns) { | |
| 349 cricket::RelayCredentials credentials(turn.username, turn.password); | |
| 350 cricket::RelayServerConfig relay_server(cricket::RELAY_TURN); | |
| 351 cricket::ProtocolType protocol; | |
| 352 // Using VERIFY because ParseIceServers should have already caught an | |
| 353 // invalid transport type. | |
| 354 if (!VERIFY( | |
| 355 cricket::StringToProto(turn.transport_type.c_str(), &protocol))) { | |
| 356 LOG(LS_WARNING) << "Ignoring TURN server " << turn.server << ". " | |
| 357 << "Reason= Incorrect " << turn.transport_type | |
| 358 << " transport parameter."; | |
| 359 } else { | |
| 360 relay_server.ports.push_back( | |
| 361 cricket::ProtocolAddress(turn.server, protocol, turn.secure)); | |
| 362 relay_server.credentials = credentials; | |
| 363 relay_server.priority = priority; | |
| 364 cricket_turns->push_back(relay_server); | |
| 365 } | |
| 366 // First in the list gets highest priority. | |
| 367 --priority; | |
| 368 } | |
| 369 } | |
| 370 | |
| 371 // Check if we can send |new_stream| on a PeerConnection. | 328 // Check if we can send |new_stream| on a PeerConnection. |
| 372 bool CanAddLocalMediaStream(webrtc::StreamCollectionInterface* current_streams, | 329 bool CanAddLocalMediaStream(webrtc::StreamCollectionInterface* current_streams, |
| 373 webrtc::MediaStreamInterface* new_stream) { | 330 webrtc::MediaStreamInterface* new_stream) { |
| 374 if (!new_stream || !current_streams) { | 331 if (!new_stream || !current_streams) { |
| 375 return false; | 332 return false; |
| 376 } | 333 } |
| 377 if (current_streams->find(new_stream->label()) != nullptr) { | 334 if (current_streams->find(new_stream->label()) != nullptr) { |
| 378 LOG(LS_ERROR) << "MediaStream with label " << new_stream->label() | 335 LOG(LS_ERROR) << "MediaStream with label " << new_stream->label() |
| 379 << " is already added."; | 336 << " is already added."; |
| 380 return false; | 337 return false; |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 553 session_options->transport_options.ice_restart = false; | 510 session_options->transport_options.ice_restart = false; |
| 554 } | 511 } |
| 555 | 512 |
| 556 if (!constraints) { | 513 if (!constraints) { |
| 557 return true; | 514 return true; |
| 558 } | 515 } |
| 559 return mandatory_constraints_satisfied == constraints->GetMandatory().size(); | 516 return mandatory_constraints_satisfied == constraints->GetMandatory().size(); |
| 560 } | 517 } |
| 561 | 518 |
| 562 bool ParseIceServers(const PeerConnectionInterface::IceServers& servers, | 519 bool ParseIceServers(const PeerConnectionInterface::IceServers& servers, |
| 563 StunConfigurations* stun_config, | 520 cricket::ServerAddresses* stun_servers, |
| 564 TurnConfigurations* turn_config) { | 521 std::vector<cricket::RelayServerConfig>* turn_servers) { |
| 565 for (const webrtc::PeerConnectionInterface::IceServer& server : servers) { | 522 for (const webrtc::PeerConnectionInterface::IceServer& server : servers) { |
| 566 if (!server.urls.empty()) { | 523 if (!server.urls.empty()) { |
| 567 for (const std::string& url : server.urls) { | 524 for (const std::string& url : server.urls) { |
| 568 if (url.empty()) { | 525 if (url.empty()) { |
| 569 LOG(LS_ERROR) << "Empty uri."; | 526 LOG(LS_ERROR) << "Empty uri."; |
| 570 return false; | 527 return false; |
| 571 } | 528 } |
| 572 if (!ParseIceServerUrl(server, url, stun_config, turn_config)) { | 529 if (!ParseIceServerUrl(server, url, stun_servers, turn_servers)) { |
| 573 return false; | 530 return false; |
| 574 } | 531 } |
| 575 } | 532 } |
| 576 } else if (!server.uri.empty()) { | 533 } else if (!server.uri.empty()) { |
| 577 // Fallback to old .uri if new .urls isn't present. | 534 // Fallback to old .uri if new .urls isn't present. |
| 578 if (!ParseIceServerUrl(server, server.uri, stun_config, turn_config)) { | 535 if (!ParseIceServerUrl(server, server.uri, stun_servers, turn_servers)) { |
| 579 return false; | 536 return false; |
| 580 } | 537 } |
| 581 } else { | 538 } else { |
| 582 LOG(LS_ERROR) << "Empty uri."; | 539 LOG(LS_ERROR) << "Empty uri."; |
| 583 return false; | 540 return false; |
| 584 } | 541 } |
| 585 } | 542 } |
|
pthatcher1
2015/12/15 07:58:44
Can you leave a comment explaining why this is imp
Taylor Brandstetter
2015/12/15 21:31:54
Done.
| |
| 543 int priority = static_cast<int>(turn_servers->size() - 1); | |
| 544 for (cricket::RelayServerConfig& turn_server : *turn_servers) { | |
| 545 // First in the list gets highest priority. | |
| 546 turn_server.priority = priority--; | |
| 547 } | |
| 586 return true; | 548 return true; |
| 587 } | 549 } |
| 588 | 550 |
| 589 PeerConnection::PeerConnection(PeerConnectionFactory* factory) | 551 PeerConnection::PeerConnection(PeerConnectionFactory* factory) |
| 590 : factory_(factory), | 552 : factory_(factory), |
| 591 observer_(NULL), | 553 observer_(NULL), |
| 592 uma_observer_(NULL), | 554 uma_observer_(NULL), |
| 593 signaling_state_(kStable), | 555 signaling_state_(kStable), |
| 594 ice_state_(kIceNew), | 556 ice_state_(kIceNew), |
| 595 ice_connection_state_(kIceConnectionNew), | 557 ice_connection_state_(kIceConnectionNew), |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 606 sender->Stop(); | 568 sender->Stop(); |
| 607 } | 569 } |
| 608 for (const auto& receiver : receivers_) { | 570 for (const auto& receiver : receivers_) { |
| 609 receiver->Stop(); | 571 receiver->Stop(); |
| 610 } | 572 } |
| 611 } | 573 } |
| 612 | 574 |
| 613 bool PeerConnection::Initialize( | 575 bool PeerConnection::Initialize( |
| 614 const PeerConnectionInterface::RTCConfiguration& configuration, | 576 const PeerConnectionInterface::RTCConfiguration& configuration, |
| 615 const MediaConstraintsInterface* constraints, | 577 const MediaConstraintsInterface* constraints, |
| 616 PortAllocatorFactoryInterface* allocator_factory, | |
| 617 rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store, | |
| 618 PeerConnectionObserver* observer) { | |
| 619 RTC_DCHECK(observer != nullptr); | |
| 620 if (!observer) { | |
| 621 return false; | |
| 622 } | |
| 623 | |
| 624 // This Initialize function parses ICE servers an extra time, but it will | |
| 625 // be removed once all PortAllocaotrs support SetIceServers. | |
| 626 std::vector<PortAllocatorFactoryInterface::StunConfiguration> stun_config; | |
| 627 std::vector<PortAllocatorFactoryInterface::TurnConfiguration> turn_config; | |
| 628 if (!ParseIceServers(configuration.servers, &stun_config, &turn_config)) { | |
| 629 return false; | |
| 630 } | |
| 631 rtc::scoped_ptr<cricket::PortAllocator> allocator( | |
| 632 allocator_factory->CreatePortAllocator(stun_config, turn_config)); | |
| 633 return Initialize(configuration, constraints, allocator.Pass(), | |
| 634 dtls_identity_store.Pass(), observer); | |
| 635 } | |
| 636 | |
| 637 bool PeerConnection::Initialize( | |
| 638 const PeerConnectionInterface::RTCConfiguration& configuration, | |
| 639 const MediaConstraintsInterface* constraints, | |
| 640 rtc::scoped_ptr<cricket::PortAllocator> allocator, | 578 rtc::scoped_ptr<cricket::PortAllocator> allocator, |
| 641 rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store, | 579 rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store, |
| 642 PeerConnectionObserver* observer) { | 580 PeerConnectionObserver* observer) { |
| 643 TRACE_EVENT0("webrtc", "PeerConnection::Initialize"); | 581 TRACE_EVENT0("webrtc", "PeerConnection::Initialize"); |
| 644 RTC_DCHECK(observer != nullptr); | 582 RTC_DCHECK(observer != nullptr); |
| 645 if (!observer) { | 583 if (!observer) { |
| 646 return false; | 584 return false; |
| 647 } | 585 } |
| 648 observer_ = observer; | 586 observer_ = observer; |
| 649 | 587 |
| 650 port_allocator_ = allocator.Pass(); | 588 port_allocator_ = allocator.Pass(); |
| 651 | 589 |
| 652 std::vector<PortAllocatorFactoryInterface::StunConfiguration> stun_config; | 590 cricket::ServerAddresses stun_servers; |
| 653 std::vector<PortAllocatorFactoryInterface::TurnConfiguration> turn_config; | 591 std::vector<cricket::RelayServerConfig> turn_servers; |
| 654 if (!ParseIceServers(configuration.servers, &stun_config, &turn_config)) { | 592 if (!ParseIceServers(configuration.servers, &stun_servers, &turn_servers)) { |
| 655 return false; | 593 return false; |
| 656 } | 594 } |
| 657 | 595 port_allocator_->SetIceServers(stun_servers, turn_servers); |
| 658 cricket::ServerAddresses cricket_stuns; | |
| 659 std::vector<cricket::RelayServerConfig> cricket_turns; | |
| 660 ConvertToCricketIceServers(stun_config, turn_config, &cricket_stuns, | |
| 661 &cricket_turns); | |
| 662 port_allocator_->SetIceServers(cricket_stuns, cricket_turns); | |
| 663 | 596 |
| 664 // To handle both internal and externally created port allocator, we will | 597 // To handle both internal and externally created port allocator, we will |
| 665 // enable BUNDLE here. | 598 // enable BUNDLE here. |
| 666 int portallocator_flags = port_allocator_->flags(); | 599 int portallocator_flags = port_allocator_->flags(); |
| 667 portallocator_flags |= cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET | | 600 portallocator_flags |= cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET | |
| 668 cricket::PORTALLOCATOR_ENABLE_IPV6; | 601 cricket::PORTALLOCATOR_ENABLE_IPV6; |
| 669 bool value; | 602 bool value; |
| 670 // If IPv6 flag was specified, we'll not override it by experiment. | 603 // If IPv6 flag was specified, we'll not override it by experiment. |
| 671 if (FindConstraint(constraints, MediaConstraintsInterface::kEnableIPv6, | 604 if (FindConstraint(constraints, MediaConstraintsInterface::kEnableIPv6, |
| 672 &value, nullptr)) { | 605 &value, nullptr)) { |
| (...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1205 | 1138 |
| 1206 UpdateEndedRemoteMediaStreams(); | 1139 UpdateEndedRemoteMediaStreams(); |
| 1207 | 1140 |
| 1208 SetSessionDescriptionMsg* msg = new SetSessionDescriptionMsg(observer); | 1141 SetSessionDescriptionMsg* msg = new SetSessionDescriptionMsg(observer); |
| 1209 signaling_thread()->Post(this, MSG_SET_SESSIONDESCRIPTION_SUCCESS, msg); | 1142 signaling_thread()->Post(this, MSG_SET_SESSIONDESCRIPTION_SUCCESS, msg); |
| 1210 } | 1143 } |
| 1211 | 1144 |
| 1212 bool PeerConnection::SetConfiguration(const RTCConfiguration& config) { | 1145 bool PeerConnection::SetConfiguration(const RTCConfiguration& config) { |
| 1213 TRACE_EVENT0("webrtc", "PeerConnection::SetConfiguration"); | 1146 TRACE_EVENT0("webrtc", "PeerConnection::SetConfiguration"); |
| 1214 if (port_allocator_) { | 1147 if (port_allocator_) { |
| 1215 std::vector<PortAllocatorFactoryInterface::StunConfiguration> stuns; | 1148 cricket::ServerAddresses stun_servers; |
| 1216 std::vector<PortAllocatorFactoryInterface::TurnConfiguration> turns; | 1149 std::vector<cricket::RelayServerConfig> turn_servers; |
| 1217 if (!ParseIceServers(config.servers, &stuns, &turns)) { | 1150 if (!ParseIceServers(config.servers, &stun_servers, &turn_servers)) { |
| 1218 return false; | 1151 return false; |
| 1219 } | 1152 } |
| 1220 | 1153 port_allocator_->SetIceServers(stun_servers, turn_servers); |
| 1221 cricket::ServerAddresses cricket_stuns; | |
| 1222 std::vector<cricket::RelayServerConfig> cricket_turns; | |
| 1223 ConvertToCricketIceServers(stuns, turns, &cricket_stuns, &cricket_turns); | |
| 1224 port_allocator_->SetIceServers(cricket_stuns, cricket_turns); | |
| 1225 } | 1154 } |
| 1226 session_->SetIceConfig(session_->ParseIceConfig(config)); | 1155 session_->SetIceConfig(session_->ParseIceConfig(config)); |
| 1227 return session_->SetIceTransports(config.type); | 1156 return session_->SetIceTransports(config.type); |
| 1228 } | 1157 } |
| 1229 | 1158 |
| 1230 bool PeerConnection::AddIceCandidate( | 1159 bool PeerConnection::AddIceCandidate( |
| 1231 const IceCandidateInterface* ice_candidate) { | 1160 const IceCandidateInterface* ice_candidate) { |
| 1232 TRACE_EVENT0("webrtc", "PeerConnection::AddIceCandidate"); | 1161 TRACE_EVENT0("webrtc", "PeerConnection::AddIceCandidate"); |
| 1233 return session_->ProcessIceMessage(ice_candidate); | 1162 return session_->ProcessIceMessage(ice_candidate); |
| 1234 } | 1163 } |
| (...skipping 785 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2020 DataChannel* PeerConnection::FindDataChannelBySid(int sid) const { | 1949 DataChannel* PeerConnection::FindDataChannelBySid(int sid) const { |
| 2021 for (const auto& channel : sctp_data_channels_) { | 1950 for (const auto& channel : sctp_data_channels_) { |
| 2022 if (channel->id() == sid) { | 1951 if (channel->id() == sid) { |
| 2023 return channel; | 1952 return channel; |
| 2024 } | 1953 } |
| 2025 } | 1954 } |
| 2026 return nullptr; | 1955 return nullptr; |
| 2027 } | 1956 } |
| 2028 | 1957 |
| 2029 } // namespace webrtc | 1958 } // namespace webrtc |
| OLD | NEW |