addIceCandidateToSubscriber method

  1. @override
Future<void> addIceCandidateToSubscriber(
  1. String targetId,
  2. RTCIceCandidate candidate
)
override

Implementation

@override
Future<void> addIceCandidateToSubscriber(
  String targetId,
  RTCIceCandidate candidate,
) async {
  if (targetId.isEmpty && _remoteSubscribers.length != 1) {
    return;
  }

  late String participantId;

  if (targetId.isEmpty) {
    participantId = _remoteSubscribers.keys.first;
  } else {
    participantId = targetId;
  }

  if (_remoteSubscribers[participantId] != null &&
      _remoteSubscribers[participantId]!.connectionType == _connectionType) {
    await _remoteSubscribers[participantId]?.addCandidate(candidate);
  } else {
    _iceCandidateQueueForSubscribers
        .putIfAbsent(participantId, () => [])
        .add(candidate);
  }
}