renegotiateWithParticipant method
Future<void>
renegotiateWithParticipant(
{ - required String targetId,
- required String sdp,
})
override
Implementation
@override
Future<void> renegotiateWithParticipant({
required String targetId,
required String sdp,
}) async {
if (targetId.isEmpty && _remoteSubscribers.length != 1) {
return;
}
late String participantId;
if (targetId.isEmpty) {
participantId = _remoteSubscribers.keys.first;
await Future.delayed(1.seconds);
} else {
participantId = targetId;
}
if (_remoteSubscribers[participantId]?.peerConnection == null) return;
final RTCPeerConnection pc =
_remoteSubscribers[participantId]!.peerConnection;
final RTCSessionDescription remoteDescription = RTCSessionDescription(
sdp,
DescriptionType.offer.type,
);
await pc.setRemoteDescription(remoteDescription);
try {
final String sdpAnswer = await _createAnswerSdp(pc);
final RTCSessionDescription localDescription = RTCSessionDescription(
sdpAnswer,
DescriptionType.answer.type,
);
await pc.setLocalDescription(localDescription);
_wsEmitter.answerSubscription(
roomId: _currentRoomId!,
targetId: targetId,
sdp: sdpAnswer,
connectionType: _connectionType,
);
} catch (_) {}
}