fix: skip invalid candidate.

This commit is contained in:
cloudwebrtc 2023-02-27 20:59:38 +08:00
parent c5aa899038
commit 380051ab07
1 changed files with 15 additions and 0 deletions

View File

@ -44,6 +44,15 @@ class Timeouts {
static const delayBeforeOfferMs = 100;
}
extension RTCIceCandidateExt on RTCIceCandidate {
bool get isValid =>
sdpMLineIndex != null &&
sdpMid != null &&
candidate != null &&
sdpMid!.isNotEmpty &&
candidate!.isNotEmpty;
}
/// Wrapped MediaStream, used to adapt Widget to display
class WrappedMediaStream {
MediaStream? stream;
@ -716,6 +725,12 @@ class CallSession {
json['sdpMLineIndex']?.round() ?? 0,
);
if (!candidate.isValid) {
Logs().w(
'[VOIP] onCandidatesReceived => skip invalid candidate $candidate');
continue;
}
if (direction == CallDirection.kOutgoing &&
pc != null &&
await pc!.getRemoteDescription() == null) {