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

Unified Diff: webrtc/p2p/base/turnport.cc

Issue 2685053004: Add the URL attribute to cricket::Candiate. (Closed)
Patch Set: Add the Server URL to the Candiate. 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 side-by-side diff with in-line comments
Download patch
Index: webrtc/p2p/base/turnport.cc
diff --git a/webrtc/p2p/base/turnport.cc b/webrtc/p2p/base/turnport.cc
index 7e0e64d6edacaf97751c3cbc56d18ca9a6f88dad..91ab62d798c2862dffac51cd8303cfea40e95d84 100644
--- a/webrtc/p2p/base/turnport.cc
+++ b/webrtc/p2p/base/turnport.cc
@@ -745,7 +745,7 @@ void TurnPort::OnAllocateSuccess(const rtc::SocketAddress& address,
ProtoToString(server_address_.proto), // The first hop protocol.
"", // TCP canddiate type, empty for turn candidates.
RELAY_PORT_TYPE, GetRelayPreference(server_address_.proto),
- server_priority_, true);
+ server_priority_, ReconstructedServerUrl(), true);
}
void TurnPort::OnAllocateError() {
@@ -1073,6 +1073,28 @@ bool TurnPort::SetEntryChannelId(const rtc::SocketAddress& address,
return true;
}
+std::string TurnPort::ReconstructedServerUrl() {
+ // draft-petithuguenin-behave-turn-uris-01
+ // turnURI = scheme ":" turn-host [ ":" turn-port ]
+ // [ "?transport=" transport ]
+ // scheme = "turn" / "turns"
+ // transport = "udp" / "tcp" / transport-ext
+ // transport-ext = 1*unreserved
+ // turn-host = IP-literal / IPv4address / reg-name
+ // turn-port = *DIGIT
+ std::string scheme = "turn";
+ if (server_address_.proto == PROTO_SSLTCP ||
+ server_address_.proto == PROTO_TLS) {
+ scheme = "turns";
+ }
+ std::string transport = "tcp";
+ if (server_address_.proto == PROTO_UDP) {
+ transport = "udp";
+ }
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!
+ return scheme + ":" + server_address_.address.ToString() + "?transport=" +
+ transport;
+}
+
TurnAllocateRequest::TurnAllocateRequest(TurnPort* port)
: StunRequest(new TurnMessage()),
port_(port) {

Powered by Google App Engine
This is Rietveld 408576698