|  |  |  | @ -22,8 +22,9 @@ class ChatCallProvider with ChangeNotifier, DiagnosticableTreeMixin { | 
		
	
		
			
				|  |  |  |  |   // Video Call | 
		
	
		
			
				|  |  |  |  |   late RTCPeerConnection _pc; | 
		
	
		
			
				|  |  |  |  |   late ChatProviderModel chatProvModel; | 
		
	
		
			
				|  |  |  |  |   RTCVideoRenderer localVideoRenderer = RTCVideoRenderer(); | 
		
	
		
			
				|  |  |  |  |   RTCVideoRenderer remoteRenderer = RTCVideoRenderer(); | 
		
	
		
			
				|  |  |  |  |   RTCVideoRenderer? localVideoRenderer; | 
		
	
		
			
				|  |  |  |  |   RTCVideoRenderer? remoteRenderer; | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |   final AudioPlayer player = AudioPlayer(); | 
		
	
		
			
				|  |  |  |  |   MediaStream? _localStream; | 
		
	
		
			
				|  |  |  |  |   late CallDataModel outGoingCallData; | 
		
	
	
		
			
				
					|  |  |  | @ -206,21 +207,21 @@ class ChatCallProvider with ChangeNotifier, DiagnosticableTreeMixin { | 
		
	
		
			
				|  |  |  |  |       isCamOff = false; | 
		
	
		
			
				|  |  |  |  |       isMicOff = false; | 
		
	
		
			
				|  |  |  |  |       isLoudSpeaker = false; | 
		
	
		
			
				|  |  |  |  |       localVideoRenderer.srcObject = null; | 
		
	
		
			
				|  |  |  |  |       remoteRenderer.srcObject = null; | 
		
	
		
			
				|  |  |  |  |       isIncomingCall = false; | 
		
	
		
			
				|  |  |  |  |       isOutGoingCall = false; | 
		
	
		
			
				|  |  |  |  |       if (_pc.connectionState == RTCPeerConnectionState.RTCPeerConnectionStateConnected) { | 
		
	
		
			
				|  |  |  |  |         print("------------------ PC Stopped ----------------------------"); | 
		
	
		
			
				|  |  |  |  |         _pc.close(); | 
		
	
		
			
				|  |  |  |  |         remoteRenderer.dispose(); | 
		
	
		
			
				|  |  |  |  |         localVideoRenderer.dispose(); | 
		
	
		
			
				|  |  |  |  |         if (_localStream != null) { | 
		
	
		
			
				|  |  |  |  |           _localStream!.dispose(); | 
		
	
		
			
				|  |  |  |  |           _localStream = null; | 
		
	
		
			
				|  |  |  |  |         } | 
		
	
		
			
				|  |  |  |  |         _pc.dispose(); | 
		
	
		
			
				|  |  |  |  |       } | 
		
	
		
			
				|  |  |  |  |       remoteRenderer!.dispose(); | 
		
	
		
			
				|  |  |  |  |       localVideoRenderer!.dispose(); | 
		
	
		
			
				|  |  |  |  |       localVideoRenderer = null; | 
		
	
		
			
				|  |  |  |  |       remoteRenderer = null; | 
		
	
		
			
				|  |  |  |  |       if (_localStream != null) { | 
		
	
		
			
				|  |  |  |  |         _localStream!.dispose(); | 
		
	
		
			
				|  |  |  |  |         _localStream = null; | 
		
	
		
			
				|  |  |  |  |       } | 
		
	
		
			
				|  |  |  |  |       if (chatHubConnection != null && !isUserOnline) { | 
		
	
		
			
				|  |  |  |  |         chatHubConnection.stop(); | 
		
	
		
			
				|  |  |  |  |       } | 
		
	
	
		
			
				
					|  |  |  | @ -240,18 +241,19 @@ class ChatCallProvider with ChangeNotifier, DiagnosticableTreeMixin { | 
		
	
		
			
				|  |  |  |  |       isCamOff = false; | 
		
	
		
			
				|  |  |  |  |       isMicOff = false; | 
		
	
		
			
				|  |  |  |  |       isLoudSpeaker = false; | 
		
	
		
			
				|  |  |  |  |       localVideoRenderer.srcObject = null; | 
		
	
		
			
				|  |  |  |  |       remoteRenderer.srcObject = null; | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |       if (_pc.connectionState == RTCPeerConnectionState.RTCPeerConnectionStateConnected) { | 
		
	
		
			
				|  |  |  |  |         _pc.close(); | 
		
	
		
			
				|  |  |  |  |         remoteRenderer.dispose(); | 
		
	
		
			
				|  |  |  |  |         localVideoRenderer.dispose(); | 
		
	
		
			
				|  |  |  |  |         if (_localStream != null) { | 
		
	
		
			
				|  |  |  |  |           _localStream!.dispose(); | 
		
	
		
			
				|  |  |  |  |           _localStream = null; | 
		
	
		
			
				|  |  |  |  |         } | 
		
	
		
			
				|  |  |  |  |         _pc.dispose(); | 
		
	
		
			
				|  |  |  |  |       } | 
		
	
		
			
				|  |  |  |  |       remoteRenderer!.dispose(); | 
		
	
		
			
				|  |  |  |  |       localVideoRenderer!.dispose(); | 
		
	
		
			
				|  |  |  |  |       localVideoRenderer = null; | 
		
	
		
			
				|  |  |  |  |       remoteRenderer = null; | 
		
	
		
			
				|  |  |  |  |       if (_localStream != null) { | 
		
	
		
			
				|  |  |  |  |         _localStream!.dispose(); | 
		
	
		
			
				|  |  |  |  |         _localStream = null; | 
		
	
		
			
				|  |  |  |  |       } | 
		
	
		
			
				|  |  |  |  |       isOutGoingCall = false; | 
		
	
		
			
				|  |  |  |  |       isIncomingCall = false; | 
		
	
		
			
				|  |  |  |  |       // await initStreams().whenComplete(() => notifyListeners()); | 
		
	
	
		
			
				
					|  |  |  | @ -428,7 +430,7 @@ class ChatCallProvider with ChangeNotifier, DiagnosticableTreeMixin { | 
		
	
		
			
				|  |  |  |  |     await pc!.addStream(_localStream!); | 
		
	
		
			
				|  |  |  |  |     pc?.onConnectionState = (RTCPeerConnectionState state) {}; | 
		
	
		
			
				|  |  |  |  |     pc?.onAddStream = (MediaStream stream) { | 
		
	
		
			
				|  |  |  |  |       remoteRenderer.srcObject = stream; | 
		
	
		
			
				|  |  |  |  |       remoteRenderer!.srcObject = stream; | 
		
	
		
			
				|  |  |  |  |       notifyListeners(); | 
		
	
		
			
				|  |  |  |  |     }; | 
		
	
		
			
				|  |  |  |  |     pc!.onIceCandidate = (RTCIceCandidate e) async { | 
		
	
	
		
			
				
					|  |  |  | @ -537,7 +539,7 @@ class ChatCallProvider with ChangeNotifier, DiagnosticableTreeMixin { | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |   void loudOn() { | 
		
	
		
			
				|  |  |  |  |     isLoudSpeaker = !isLoudSpeaker; | 
		
	
		
			
				|  |  |  |  |     remoteRenderer.srcObject?.getAudioTracks().forEach((track) { | 
		
	
		
			
				|  |  |  |  |     remoteRenderer!.srcObject?.getAudioTracks().forEach((track) { | 
		
	
		
			
				|  |  |  |  |       if (isLoudSpeaker) { | 
		
	
		
			
				|  |  |  |  |         track.enableSpeakerphone(true); | 
		
	
		
			
				|  |  |  |  |       } else { | 
		
	
	
		
			
				
					|  |  |  | @ -556,16 +558,12 @@ class ChatCallProvider with ChangeNotifier, DiagnosticableTreeMixin { | 
		
	
		
			
				|  |  |  |  |   ///////////////// Incoming Call /////////////////////////////// | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |   Future<void> initStreams() async { | 
		
	
		
			
				|  |  |  |  |     await localVideoRenderer.initialize(); | 
		
	
		
			
				|  |  |  |  |     if (_localStream == null) { | 
		
	
		
			
				|  |  |  |  |       MediaStream? m; | 
		
	
		
			
				|  |  |  |  |       _localStream = m; | 
		
	
		
			
				|  |  |  |  |       _localStream = await navigator.mediaDevices.getUserMedia(isVideoCall ? videoConstraints : audioConstraints); | 
		
	
		
			
				|  |  |  |  |     } else { | 
		
	
		
			
				|  |  |  |  |       _localStream = await navigator.mediaDevices.getUserMedia(isVideoCall ? videoConstraints : audioConstraints); | 
		
	
		
			
				|  |  |  |  |     } | 
		
	
		
			
				|  |  |  |  |     localVideoRenderer.srcObject = _localStream; | 
		
	
		
			
				|  |  |  |  |     await remoteRenderer.initialize(); | 
		
	
		
			
				|  |  |  |  |     localVideoRenderer = RTCVideoRenderer(); | 
		
	
		
			
				|  |  |  |  |     remoteRenderer = RTCVideoRenderer(); | 
		
	
		
			
				|  |  |  |  |     await localVideoRenderer!.initialize(); | 
		
	
		
			
				|  |  |  |  |     _localStream ??= await navigator.mediaDevices.getUserMedia(isVideoCall ? videoConstraints : audioConstraints); | 
		
	
		
			
				|  |  |  |  |     localVideoRenderer!.srcObject = _localStream; | 
		
	
		
			
				|  |  |  |  |     await remoteRenderer!.initialize(); | 
		
	
		
			
				|  |  |  |  |   } | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |   Future<void> startIncomingCallViaKit({bool isVCall = true, required var inCallData}) async { | 
		
	
	
		
			
				
					|  |  |  | 
 |