@@ -207,6 +207,9 @@ class CallSession {
207207 // outgoing call
208208 Future <void > initOutboundCall (CallType type) async {
209209 await _preparePeerConnection ();
210+ if (pc == null ) {
211+ return ;
212+ }
210213 setCallState (CallState .kCreateOffer);
211214 final stream = await _getUserMedia (type);
212215 if (stream != null ) {
@@ -262,6 +265,10 @@ class CallSession {
262265 }
263266
264267 await _preparePeerConnection ();
268+ if (pc == null ) {
269+ return ;
270+ }
271+
265272 if (metadata != null ) {
266273 _updateRemoteSDPStreamMetadata (metadata);
267274 }
@@ -357,6 +364,10 @@ class CallSession {
357364 // create the peer connection now so it can be gathering candidates while we get user
358365 // media (assuming a candidate pool size is configured)
359366 await _preparePeerConnection ();
367+ if (pc == null ) {
368+ return ;
369+ }
370+
360371 await gotCallFeedsForInvite (
361372 callFeeds,
362373 requestScreenSharing: requestScreenSharing,
@@ -1218,7 +1229,8 @@ class CallSession {
12181229 }
12191230 };
12201231 } catch (e) {
1221- Logs ().v ('[VOIP] prepareMediaStream error => ${e .toString ()}' );
1232+ Logs ().v ('[VOIP] preparePeerConnection error => ${e .toString ()}' );
1233+ await _createPeerConnectionFailed (e);
12221234 }
12231235 }
12241236
@@ -1454,10 +1466,19 @@ class CallSession {
14541466 }
14551467 }
14561468
1469+ Future <void > _createPeerConnectionFailed (dynamic err) async {
1470+ Logs ().e ('Failed to create peer connection object ${err .toString ()}' );
1471+ fireCallEvent (CallStateChange .kError);
1472+ await terminate (
1473+ CallParty .kLocal,
1474+ CallErrorCode .createPeerConnectionFailed,
1475+ true ,
1476+ );
1477+ }
1478+
14571479 Future <void > _getLocalOfferFailed (dynamic err) async {
14581480 Logs ().e ('Failed to get local offer ${err .toString ()}' );
14591481 fireCallEvent (CallStateChange .kError);
1460-
14611482 await terminate (CallParty .kLocal, CallErrorCode .localOfferFailed, true );
14621483 }
14631484
0 commit comments