Skip to content

Commit eb1fb68

Browse files
committed
fix: Fix UpdateIceServers parameters parsing for all possible cases
1 parent b4aa644 commit eb1fb68

1 file changed

Lines changed: 16 additions & 3 deletions

File tree

src/Handler.cpp

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,23 @@ namespace mediasoupclient
108108

109109
for (const auto& iceServerDescription : iceServersDescription)
110110
{
111+
if (!iceServerDescription.contains("urls")) {
112+
continue;
113+
}
111114
webrtc::PeerConnectionInterface::IceServer iceServer;
112-
iceServer.urls = iceServerDescription.at("urls").get<std::vector<std::string>>();
113-
iceServer.username = iceServerDescription.at("username").get<std::string>();
114-
iceServer.password = iceServerDescription.at("credential").get<std::string>();
115+
if (iceServerDescription["urls"].is_string()) {
116+
iceServer.urls = { iceServerDescription["urls"].get<std::string>() };
117+
} else if (iceServerDescription["urls"].is_array()) {
118+
iceServer.urls = iceServerDescription["urls"].get<std::vector<std::string>>();
119+
} else {
120+
continue;
121+
}
122+
if (iceServerDescription.contains("username")) {
123+
iceServer.username = iceServerDescription["username"].get<std::string>();
124+
}
125+
if (iceServerDescription.contains("credential")) {
126+
iceServer.password = iceServerDescription["credential"].get<std::string>();
127+
}
115128
configuration.servers.push_back(iceServer);
116129
}
117130

0 commit comments

Comments
 (0)