handleUpdateMediaResponse method
Handles the updateMedia response from the server
Implementation
Future<void> handleUpdateMediaResponse(UpdateMediaResponse response) async {
try {
if (response.action != 'updateMedia') {
GlobalLogger()
.w('Peer :: Unexpected action in response: ${response.action}');
return;
}
if (response.sdp.isEmpty) {
GlobalLogger().e('Peer :: No SDP in updateMedia response');
return;
}
final callId = response.callID;
GlobalLogger()
.i('Peer :: Received updateMedia response for call: $callId');
final session = _sessions[_selfId];
if (session == null) {
GlobalLogger().e('Peer :: No session found for ID: $_selfId');
return;
}
// Set the remote description to complete renegotiation
final remoteDescription = RTCSessionDescription(response.sdp, 'answer');
await session.peerConnection?.setRemoteDescription(remoteDescription);
GlobalLogger().i(
'Peer :: ICE renegotiation completed successfully for call: $callId',
);
} catch (e) {
GlobalLogger().e('Peer :: Error handling updateMedia response: $e');
}
}