@@ -175,43 +175,24 @@ bool FlutterWebRTCBase::CreateIceServers(const EncodableList &iceServersArray,
175
175
for (size_t i = 0 ; i < size; i++) {
176
176
IceServer &ice_server = ice_servers[i];
177
177
EncodableMap iceServerMap = GetValue<EncodableMap>(iceServersArray[i]);
178
- bool hasUsernameAndCredential =
179
- iceServerMap.find (EncodableValue (" username" )) != iceServerMap.end () &&
180
- iceServerMap.find (EncodableValue (" credential" )) != iceServerMap.end ();
178
+
179
+ if (iceServerMap.find (EncodableValue (" username" )) != iceServerMap.end ()) {;
180
+ ice_server.username = GetValue<std::string>(
181
+ iceServerMap.find (EncodableValue (" username" ))->second );
182
+ }
183
+ if (iceServerMap.find (EncodableValue (" credential" )) != iceServerMap.end ()) {
184
+ ice_server.password = GetValue<std::string>(
185
+ iceServerMap.find (EncodableValue (" credential" ))->second );
186
+ }
187
+
181
188
auto it = iceServerMap.find (EncodableValue (" url" ));
182
189
if (it != iceServerMap.end () && TypeIs<std::string>(it->second )) {
183
- if (hasUsernameAndCredential) {
184
- std::string username =
185
- GetValue<std::string>(iceServerMap.find (EncodableValue (" username" ))->second );
186
- std::string credential =
187
- GetValue<std::string>(iceServerMap.find (EncodableValue (" credential" ))
188
- ->second );
189
- std::string uri = GetValue<std::string>(it->second );
190
- ice_server.username = username;
191
- ice_server.password = credential;
192
- ice_server.uri = uri;
193
- } else {
194
- std::string uri = GetValue<std::string>(it->second );
195
- ice_server.uri = uri;
196
- }
190
+ ice_server.uri = GetValue<std::string>(it->second );
197
191
}
198
192
it = iceServerMap.find (EncodableValue (" urls" ));
199
193
if (it != iceServerMap.end ()) {
200
194
if (TypeIs<std::string>(it->second )) {
201
- if (hasUsernameAndCredential) {
202
- std::string username = GetValue<std::string>(iceServerMap.find (EncodableValue (" username" ))
203
- ->second );
204
- std::string credential =
205
- GetValue<std::string>(iceServerMap.find (EncodableValue (" credential" ))
206
- ->second );
207
- std::string uri = GetValue<std::string>(it->second );
208
- ice_server.username = username;
209
- ice_server.password = credential;
210
- ice_server.uri = uri;
211
- } else {
212
- std::string uri = GetValue<std::string>(it->second );
213
- ice_server.uri = uri;
214
- }
195
+ ice_server.uri = GetValue<std::string>(it->second );
215
196
}
216
197
if (TypeIs<EncodableList>(it->second )) {
217
198
const EncodableList urls = GetValue<EncodableList>(it->second );
@@ -221,25 +202,10 @@ bool FlutterWebRTCBase::CreateIceServers(const EncodableList &iceServersArray,
221
202
std::string value;
222
203
auto it2 = map.find (EncodableValue (" url" ));
223
204
if (it2 != map.end ()) {
224
- value = GetValue<std::string>(it2->second );
225
- if (hasUsernameAndCredential) {
226
- std::string username =
227
- GetValue<std::string>(iceServerMap.find (EncodableValue (" username" ))
228
- ->second );
229
- std::string credential =
230
- GetValue<std::string>(iceServerMap.find (EncodableValue (" credential" ))
231
- ->second );
232
- ice_server.username = username;
233
- ice_server.password = credential;
234
- ice_server.uri = value;
235
- } else {
236
- ice_server.uri = value;
237
- }
205
+ ice_server.uri = GetValue<std::string>(it2->second );
238
206
}
239
- }
240
- else if (TypeIs<std::string>(url)) {
241
- std::string urlString = GetValue<std::string>(url);
242
- ice_server.uri = urlString;
207
+ } else if (TypeIs<std::string>(url)) {
208
+ ice_server.uri = GetValue<std::string>(url);
243
209
}
244
210
}
245
211
}
0 commit comments