Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright 2012 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2012 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 727 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 738 rtc::SocketAddress related_address = stun_address; | 738 rtc::SocketAddress related_address = stun_address; |
| 739 | 739 |
| 740 // For relayed candidate, Base is the candidate itself. | 740 // For relayed candidate, Base is the candidate itself. |
| 741 AddAddress(address, // Candidate address. | 741 AddAddress(address, // Candidate address. |
| 742 address, // Base address. | 742 address, // Base address. |
| 743 related_address, // Related address. | 743 related_address, // Related address. |
| 744 UDP_PROTOCOL_NAME, | 744 UDP_PROTOCOL_NAME, |
| 745 ProtoToString(server_address_.proto), // The first hop protocol. | 745 ProtoToString(server_address_.proto), // The first hop protocol. |
| 746 "", // TCP canddiate type, empty for turn candidates. | 746 "", // TCP canddiate type, empty for turn candidates. |
| 747 RELAY_PORT_TYPE, GetRelayPreference(server_address_.proto), | 747 RELAY_PORT_TYPE, GetRelayPreference(server_address_.proto), |
| 748 server_priority_, true); | 748 server_priority_, ReconstructedServerUrl(), true); |
| 749 } | 749 } |
| 750 | 750 |
| 751 void TurnPort::OnAllocateError() { | 751 void TurnPort::OnAllocateError() { |
| 752 // We will send SignalPortError asynchronously as this can be sent during | 752 // We will send SignalPortError asynchronously as this can be sent during |
| 753 // port initialization. This way it will not be blocking other port | 753 // port initialization. This way it will not be blocking other port |
| 754 // creation. | 754 // creation. |
| 755 thread()->Post(RTC_FROM_HERE, this, MSG_ALLOCATE_ERROR); | 755 thread()->Post(RTC_FROM_HERE, this, MSG_ALLOCATE_ERROR); |
| 756 } | 756 } |
| 757 | 757 |
| 758 void TurnPort::OnRefreshError() { | 758 void TurnPort::OnRefreshError() { |
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1066 bool TurnPort::SetEntryChannelId(const rtc::SocketAddress& address, | 1066 bool TurnPort::SetEntryChannelId(const rtc::SocketAddress& address, |
| 1067 int channel_id) { | 1067 int channel_id) { |
| 1068 TurnEntry* entry = FindEntry(address); | 1068 TurnEntry* entry = FindEntry(address); |
| 1069 if (!entry) { | 1069 if (!entry) { |
| 1070 return false; | 1070 return false; |
| 1071 } | 1071 } |
| 1072 entry->set_channel_id(channel_id); | 1072 entry->set_channel_id(channel_id); |
| 1073 return true; | 1073 return true; |
| 1074 } | 1074 } |
| 1075 | 1075 |
| 1076 std::string TurnPort::ReconstructedServerUrl() { | |
| 1077 // draft-petithuguenin-behave-turn-uris-01 | |
| 1078 // turnURI = scheme ":" turn-host [ ":" turn-port ] | |
| 1079 // [ "?transport=" transport ] | |
| 1080 // scheme = "turn" / "turns" | |
| 1081 // transport = "udp" / "tcp" / transport-ext | |
| 1082 // transport-ext = 1*unreserved | |
| 1083 // turn-host = IP-literal / IPv4address / reg-name | |
| 1084 // turn-port = *DIGIT | |
| 1085 std::string scheme = "turn"; | |
| 1086 if (server_address_.proto == PROTO_SSLTCP || | |
| 1087 server_address_.proto == PROTO_TLS) { | |
| 1088 scheme = "turns"; | |
| 1089 } | |
| 1090 std::string transport = "tcp"; | |
| 1091 if (server_address_.proto == PROTO_UDP) { | |
| 1092 transport = "udp"; | |
| 1093 } | |
|
Taylor Brandstetter
2017/02/10 01:58:46
nit: A switch statement would be better here, so t
Zhi Huang
2017/02/10 06:45:50
Agreed. This would be better!
| |
| 1094 return scheme + ":" + server_address_.address.ToString() + "?transport=" + | |
| 1095 transport; | |
| 1096 } | |
| 1097 | |
| 1076 TurnAllocateRequest::TurnAllocateRequest(TurnPort* port) | 1098 TurnAllocateRequest::TurnAllocateRequest(TurnPort* port) |
| 1077 : StunRequest(new TurnMessage()), | 1099 : StunRequest(new TurnMessage()), |
| 1078 port_(port) { | 1100 port_(port) { |
| 1079 } | 1101 } |
| 1080 | 1102 |
| 1081 void TurnAllocateRequest::Prepare(StunMessage* request) { | 1103 void TurnAllocateRequest::Prepare(StunMessage* request) { |
| 1082 // Create the request as indicated in RFC 5766, Section 6.1. | 1104 // Create the request as indicated in RFC 5766, Section 6.1. |
| 1083 request->SetType(TURN_ALLOCATE_REQUEST); | 1105 request->SetType(TURN_ALLOCATE_REQUEST); |
| 1084 StunUInt32Attribute* transport_attr = StunAttribute::CreateUInt32( | 1106 StunUInt32Attribute* transport_attr = StunAttribute::CreateUInt32( |
| 1085 STUN_ATTR_REQUESTED_TRANSPORT); | 1107 STUN_ATTR_REQUESTED_TRANSPORT); |
| (...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1552 } else { | 1574 } else { |
| 1553 state_ = STATE_UNBOUND; | 1575 state_ = STATE_UNBOUND; |
| 1554 port_->FailAndPruneConnection(ext_addr_); | 1576 port_->FailAndPruneConnection(ext_addr_); |
| 1555 } | 1577 } |
| 1556 } | 1578 } |
| 1557 void TurnEntry::OnChannelBindTimeout() { | 1579 void TurnEntry::OnChannelBindTimeout() { |
| 1558 state_ = STATE_UNBOUND; | 1580 state_ = STATE_UNBOUND; |
| 1559 port_->FailAndPruneConnection(ext_addr_); | 1581 port_->FailAndPruneConnection(ext_addr_); |
| 1560 } | 1582 } |
| 1561 } // namespace cricket | 1583 } // namespace cricket |
| OLD | NEW |