From 0811b8911b48ce5513eb41b93c360e1b92974a85 Mon Sep 17 00:00:00 2001 From: Karthikeyan S Date: Mon, 4 Dec 2023 17:41:16 +0530 Subject: [PATCH] fix: set cid before initWithInvite to handle getUserMedia exception correctly --- lib/src/voip/voip.dart | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/src/voip/voip.dart b/lib/src/voip/voip.dart index f9ee1d17..824cd508 100644 --- a/lib/src/voip/voip.dart +++ b/lib/src/voip/voip.dart @@ -258,11 +258,15 @@ class VoIP { await delegate.playRingtone(); } + // When getUserMedia throws an exception, we handle it by terminating the call, + // and all this happens inside initWithInvite. If we set currentCID after + // initWithInvite, we might set it to callId even after it was reset to null + // by terminate. + currentCID = callId; + await newCall.initWithInvite( callType, offer, sdpStreamMetadata, lifetime, confId != null); - currentCID = callId; - // Popup CallingPage for incoming call. if (confId == null && !newCall.callHasEnded) { await delegate.handleNewCall(newCall);