Skip to content

Commit dd9e6b4

Browse files
committed
Ignore invalid ICE candidates
This resolves an issue with Firefox.
1 parent 10e07b8 commit dd9e6b4

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

webrtc_ros/src/ice_candidate_message.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "webrtc_ros/ice_candidate_message.h"
2+
#include <ros/console.h>
23

34
namespace webrtc_ros
45
{
@@ -37,7 +38,10 @@ bool IceCandidateMessage::fromIceCandidate(const webrtc::IceCandidateInterface&
3738

3839
webrtc::IceCandidateInterface* IceCandidateMessage::createIceCandidate()
3940
{
40-
return webrtc::CreateIceCandidate(sdp_mid, sdp_mline_index, candidate, 0);
41+
webrtc::SdpParseError err;
42+
webrtc::IceCandidateInterface* result = webrtc::CreateIceCandidate(sdp_mid, sdp_mline_index, candidate, &err);
43+
if (!result) ROS_WARN("SDP Parse Error: %s", err.description.c_str());
44+
return result;
4145
}
4246

4347
std::string IceCandidateMessage::toJson()

webrtc_ros/src/webrtc_client.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,6 @@ void WebrtcClient::handle_message(MessageHandler::Type type, const std::string&
226226
if (!message.fromJson(message_json))
227227
{
228228
ROS_WARN("Can't parse received configure message.");
229-
invalidate();
230229
return;
231230
}
232231

@@ -372,15 +371,13 @@ void WebrtcClient::handle_message(MessageHandler::Type type, const std::string&
372371
if (!message.fromJson(message_json))
373372
{
374373
ROS_WARN("Can't parse received session description message.");
375-
invalidate();
376374
return;
377375
}
378376

379377
webrtc::SessionDescriptionInterface* session_description(message.createSessionDescription());
380378
if (!session_description)
381379
{
382380
ROS_WARN("Can't create session description");
383-
invalidate();
384381
return;
385382
}
386383

@@ -393,21 +390,18 @@ void WebrtcClient::handle_message(MessageHandler::Type type, const std::string&
393390
if (!message.fromJson(message_json))
394391
{
395392
ROS_WARN("Can't parse received ice candidate message.");
396-
invalidate();
397393
return;
398394
}
399395

400396
std::unique_ptr<webrtc::IceCandidateInterface> candidate(message.createIceCandidate());
401397
if (!candidate.get())
402398
{
403399
ROS_WARN("Can't parse received candidate message.");
404-
invalidate();
405400
return;
406401
}
407402
if (!peer_connection_->AddIceCandidate(candidate.get()))
408403
{
409404
ROS_WARN("Failed to apply the received candidate");
410-
invalidate();
411405
return;
412406
}
413407
ROS_DEBUG_STREAM("Received remote candidate :" << message.toJson());

0 commit comments

Comments
 (0)