Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(75)

Side by Side Diff: webrtc/p2p/base/turnport.cc

Issue 2685053004: Add the URL attribute to cricket::Candiate. (Closed)
Patch Set: CR comments. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/p2p/base/turnport.h ('k') | webrtc/p2p/base/turnport_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 std::string transport = "tcp";
1087 switch (server_address_.proto) {
1088 case PROTO_SSLTCP:
1089 case PROTO_TLS:
1090 scheme = "turns";
1091 break;
1092 case PROTO_UDP:
1093 transport = "udp";
1094 break;
1095 case PROTO_TCP:
1096 break;
1097 default:
Taylor Brandstetter 2017/02/10 16:59:50 nit: Actually, you don't need the default case her
Zhi Huang 2017/02/10 18:57:14 Oh I see. Good to know that! Thanks. Done.
1098 RTC_NOTREACHED() << "The protocol of the ICE server is unknown.";
1099 }
1100 std::ostringstream url;
1101 url << scheme << ":" << server_address_.address.ipaddr().ToString() << ":"
1102 << server_address_.address.port() << "?transport=" << transport;
1103 return url.str();
1104 }
1105
1076 TurnAllocateRequest::TurnAllocateRequest(TurnPort* port) 1106 TurnAllocateRequest::TurnAllocateRequest(TurnPort* port)
1077 : StunRequest(new TurnMessage()), 1107 : StunRequest(new TurnMessage()),
1078 port_(port) { 1108 port_(port) {
1079 } 1109 }
1080 1110
1081 void TurnAllocateRequest::Prepare(StunMessage* request) { 1111 void TurnAllocateRequest::Prepare(StunMessage* request) {
1082 // Create the request as indicated in RFC 5766, Section 6.1. 1112 // Create the request as indicated in RFC 5766, Section 6.1.
1083 request->SetType(TURN_ALLOCATE_REQUEST); 1113 request->SetType(TURN_ALLOCATE_REQUEST);
1084 StunUInt32Attribute* transport_attr = StunAttribute::CreateUInt32( 1114 StunUInt32Attribute* transport_attr = StunAttribute::CreateUInt32(
1085 STUN_ATTR_REQUESTED_TRANSPORT); 1115 STUN_ATTR_REQUESTED_TRANSPORT);
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after
1552 } else { 1582 } else {
1553 state_ = STATE_UNBOUND; 1583 state_ = STATE_UNBOUND;
1554 port_->FailAndPruneConnection(ext_addr_); 1584 port_->FailAndPruneConnection(ext_addr_);
1555 } 1585 }
1556 } 1586 }
1557 void TurnEntry::OnChannelBindTimeout() { 1587 void TurnEntry::OnChannelBindTimeout() {
1558 state_ = STATE_UNBOUND; 1588 state_ = STATE_UNBOUND;
1559 port_->FailAndPruneConnection(ext_addr_); 1589 port_->FailAndPruneConnection(ext_addr_);
1560 } 1590 }
1561 } // namespace cricket 1591 } // namespace cricket
OLDNEW
« no previous file with comments | « webrtc/p2p/base/turnport.h ('k') | webrtc/p2p/base/turnport_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698