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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 53 // 'actpass': The endpoint is willing to accept an incoming | 53 // 'actpass': The endpoint is willing to accept an incoming |
| 54 // connection or to initiate an outgoing connection. | 54 // connection or to initiate an outgoing connection. |
| 55 enum ConnectionRole { | 55 enum ConnectionRole { |
| 56 CONNECTIONROLE_NONE = 0, | 56 CONNECTIONROLE_NONE = 0, |
| 57 CONNECTIONROLE_ACTIVE, | 57 CONNECTIONROLE_ACTIVE, |
| 58 CONNECTIONROLE_PASSIVE, | 58 CONNECTIONROLE_PASSIVE, |
| 59 CONNECTIONROLE_ACTPASS, | 59 CONNECTIONROLE_ACTPASS, |
| 60 CONNECTIONROLE_HOLDCONN, | 60 CONNECTIONROLE_HOLDCONN, |
| 61 }; | 61 }; |
| 62 | 62 |
| 63 struct IceParameters { | |
| 64 std::string ufrag; | |
| 65 std::string pwd; | |
| 66 bool renomination; | |
|
Taylor Brandstetter
2016/08/08 22:28:16
Why not have "renomination = false" here and then
honghaiz3
2016/08/11 04:57:57
Done. Thanks!
| |
| 67 IceParameters() : renomination(false) {} | |
| 68 IceParameters(const std::string& ice_ufrag, | |
| 69 const std::string& ice_pwd, | |
| 70 bool ice_renomination) | |
| 71 : ufrag(ice_ufrag), pwd(ice_pwd), renomination(ice_renomination) {} | |
|
Taylor Brandstetter
2016/08/08 22:28:16
nit: The "ice_" prefix in the names seems redundan
honghaiz3
2016/08/11 04:57:57
I generally prefer that the parameter names are di
Taylor Brandstetter
2016/08/11 22:36:50
Acknowledged; that's a fair point.
honghaiz3
2016/08/12 18:26:40
Acknowledged.
| |
| 72 | |
| 73 bool operator==(const IceParameters& other) { | |
| 74 return ufrag == other.ufrag && pwd == other.pwd && | |
| 75 renomination == other.renomination; | |
| 76 } | |
| 77 bool operator!=(const IceParameters& other) { return !(*this == other); } | |
| 78 }; | |
| 79 | |
| 63 extern const char CONNECTIONROLE_ACTIVE_STR[]; | 80 extern const char CONNECTIONROLE_ACTIVE_STR[]; |
| 64 extern const char CONNECTIONROLE_PASSIVE_STR[]; | 81 extern const char CONNECTIONROLE_PASSIVE_STR[]; |
| 65 extern const char CONNECTIONROLE_ACTPASS_STR[]; | 82 extern const char CONNECTIONROLE_ACTPASS_STR[]; |
| 66 extern const char CONNECTIONROLE_HOLDCONN_STR[]; | 83 extern const char CONNECTIONROLE_HOLDCONN_STR[]; |
| 67 | 84 |
| 85 constexpr auto ICE_RENOMINATION_STR = "renomination"; | |
| 86 | |
| 68 bool StringToConnectionRole(const std::string& role_str, ConnectionRole* role); | 87 bool StringToConnectionRole(const std::string& role_str, ConnectionRole* role); |
| 69 bool ConnectionRoleToString(const ConnectionRole& role, std::string* role_str); | 88 bool ConnectionRoleToString(const ConnectionRole& role, std::string* role_str); |
| 70 | 89 |
| 71 struct TransportDescription { | 90 struct TransportDescription { |
| 72 TransportDescription() | 91 TransportDescription() |
| 73 : ice_mode(ICEMODE_FULL), | 92 : ice_mode(ICEMODE_FULL), |
| 74 connection_role(CONNECTIONROLE_NONE) {} | 93 connection_role(CONNECTIONROLE_NONE) {} |
| 75 | 94 |
| 76 TransportDescription(const std::vector<std::string>& transport_options, | 95 TransportDescription(const std::vector<std::string>& transport_options, |
| 77 const std::string& ice_ufrag, | 96 const std::string& ice_ufrag, |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 118 | 137 |
| 119 bool HasOption(const std::string& option) const { | 138 bool HasOption(const std::string& option) const { |
| 120 return (std::find(transport_options.begin(), transport_options.end(), | 139 return (std::find(transport_options.begin(), transport_options.end(), |
| 121 option) != transport_options.end()); | 140 option) != transport_options.end()); |
| 122 } | 141 } |
| 123 void AddOption(const std::string& option) { | 142 void AddOption(const std::string& option) { |
| 124 transport_options.push_back(option); | 143 transport_options.push_back(option); |
| 125 } | 144 } |
| 126 bool secure() const { return identity_fingerprint != NULL; } | 145 bool secure() const { return identity_fingerprint != NULL; } |
| 127 | 146 |
| 147 IceParameters GetIceParameters() { | |
| 148 return IceParameters(ice_ufrag, ice_pwd, HasOption(ICE_RENOMINATION_STR)); | |
| 149 } | |
| 150 | |
| 128 static rtc::SSLFingerprint* CopyFingerprint( | 151 static rtc::SSLFingerprint* CopyFingerprint( |
| 129 const rtc::SSLFingerprint* from) { | 152 const rtc::SSLFingerprint* from) { |
| 130 if (!from) | 153 if (!from) |
| 131 return NULL; | 154 return NULL; |
| 132 | 155 |
| 133 return new rtc::SSLFingerprint(*from); | 156 return new rtc::SSLFingerprint(*from); |
| 134 } | 157 } |
| 135 | 158 |
| 136 std::vector<std::string> transport_options; | 159 std::vector<std::string> transport_options; |
| 137 std::string ice_ufrag; | 160 std::string ice_ufrag; |
| 138 std::string ice_pwd; | 161 std::string ice_pwd; |
| 139 IceMode ice_mode; | 162 IceMode ice_mode; |
| 140 ConnectionRole connection_role; | 163 ConnectionRole connection_role; |
| 141 | 164 |
| 142 std::unique_ptr<rtc::SSLFingerprint> identity_fingerprint; | 165 std::unique_ptr<rtc::SSLFingerprint> identity_fingerprint; |
| 143 }; | 166 }; |
| 144 | 167 |
| 145 } // namespace cricket | 168 } // namespace cricket |
| 146 | 169 |
| 147 #endif // WEBRTC_P2P_BASE_TRANSPORTDESCRIPTION_H_ | 170 #endif // WEBRTC_P2P_BASE_TRANSPORTDESCRIPTION_H_ |
| OLD | NEW |