remoteSessionReceived method
Called if you receive an "answer" sdp from the server
(e.g., bridging a call scenario).
sdp The SDP string of the remote description.
Implementation
void remoteSessionReceived(String sdp) async {
CallTimingBenchmark.start(isOutbound: true);
final session = _sessions[_selfId];
if (session != null) {
await session.peerConnection?.setRemoteDescription(
RTCSessionDescription(sdp, 'answer'),
);
CallTimingBenchmark.mark('remote_answer_sdp_set');
// Process any queued candidates after setting remote SDP
if (session.remoteCandidates.isNotEmpty) {
GlobalLogger().i(
'Web Peer :: Processing queued remote candidates after remote SDP',
);
for (var candidate in session.remoteCandidates) {
if (candidate.candidate != null) {
GlobalLogger().i(
'Web Peer :: Adding queued candidate: ${candidate.candidate}',
);
await session.peerConnection?.addCandidate(candidate);
}
}
session.remoteCandidates.clear();
GlobalLogger()
.i('Web Peer :: Cleared queued candidates after processing');
}
onCallStateChange?.call(session, CallState.active);
}
}