|
|
|
|
@ -14,7 +14,6 @@ import 'package:mohem_flutter_app/models/chat/get_single_user_chat_list_model.da
|
|
|
|
|
import 'package:mohem_flutter_app/models/chat/webrtc_payloads.dart';
|
|
|
|
|
import 'package:mohem_flutter_app/provider/chat_provider_model.dart';
|
|
|
|
|
import 'package:mohem_flutter_app/ui/chat/call/chat_incoming_call_screen.dart';
|
|
|
|
|
import 'package:mohem_flutter_app/ui/landing/dashboard_screen.dart';
|
|
|
|
|
import 'package:signalr_netcore/hub_connection.dart';
|
|
|
|
|
|
|
|
|
|
class ChatCallProvider with ChangeNotifier, DiagnosticableTreeMixin {
|
|
|
|
|
@ -210,10 +209,13 @@ class ChatCallProvider with ChangeNotifier, DiagnosticableTreeMixin {
|
|
|
|
|
isLoudSpeaker = false;
|
|
|
|
|
isIncomingCall = false;
|
|
|
|
|
isOutGoingCall = false;
|
|
|
|
|
if (_pc.connectionState == RTCPeerConnectionState.RTCPeerConnectionStateConnected) {
|
|
|
|
|
print("------------------ PC Stopped ----------------------------");
|
|
|
|
|
_pc.close();
|
|
|
|
|
_pc.dispose();
|
|
|
|
|
isAudioCall = false;
|
|
|
|
|
if (isCallConnected) {
|
|
|
|
|
if (_pc.connectionState == RTCPeerConnectionState.RTCPeerConnectionStateConnected) {
|
|
|
|
|
print("------------------ PC Stopped ----------------------------");
|
|
|
|
|
_pc.close();
|
|
|
|
|
_pc.dispose();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
remoteRenderer!.dispose();
|
|
|
|
|
localVideoRenderer!.dispose();
|
|
|
|
|
@ -240,10 +242,11 @@ class ChatCallProvider with ChangeNotifier, DiagnosticableTreeMixin {
|
|
|
|
|
isCamOff = false;
|
|
|
|
|
isMicOff = false;
|
|
|
|
|
isLoudSpeaker = false;
|
|
|
|
|
|
|
|
|
|
if (_pc.connectionState == RTCPeerConnectionState.RTCPeerConnectionStateConnected) {
|
|
|
|
|
_pc.close();
|
|
|
|
|
_pc.dispose();
|
|
|
|
|
if (isCallConnected) {
|
|
|
|
|
if (_pc.connectionState == RTCPeerConnectionState.RTCPeerConnectionStateConnected) {
|
|
|
|
|
_pc.close();
|
|
|
|
|
_pc.dispose();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
remoteRenderer!.dispose();
|
|
|
|
|
localVideoRenderer!.dispose();
|
|
|
|
|
@ -255,6 +258,7 @@ class ChatCallProvider with ChangeNotifier, DiagnosticableTreeMixin {
|
|
|
|
|
}
|
|
|
|
|
isOutGoingCall = false;
|
|
|
|
|
isIncomingCall = false;
|
|
|
|
|
isAudioCall = false;
|
|
|
|
|
// await initStreams().whenComplete(() => notifyListeners());
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
@ -569,18 +573,24 @@ class ChatCallProvider with ChangeNotifier, DiagnosticableTreeMixin {
|
|
|
|
|
|
|
|
|
|
Future<void> startIncomingCallViaKit({bool isVCall = true, required var inCallData}) async {
|
|
|
|
|
Utils.saveStringFromPrefs("isIncomingCall", "false");
|
|
|
|
|
isVideoCall = isVCall;
|
|
|
|
|
if(isVCall) {
|
|
|
|
|
isVideoCall = isVCall;
|
|
|
|
|
}else{
|
|
|
|
|
isAudioCall = true;
|
|
|
|
|
}
|
|
|
|
|
await initStreams();
|
|
|
|
|
isIncomingCall = true;
|
|
|
|
|
incomingCallData = SingleUserChatModel.fromJson(inCallData);
|
|
|
|
|
loudOn();
|
|
|
|
|
// notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void connectIncomingCall() {
|
|
|
|
|
invoke(invokeMethod: "answerCallAsync", currentUserID: AppState().getchatUserDetails!.response!.id!, targetUserID: incomingCallData.targetUserId!);
|
|
|
|
|
isIncomingCallLoader = false;
|
|
|
|
|
isIncomingCall = true;
|
|
|
|
|
isVideoCall = true;
|
|
|
|
|
// isVideoCall = true;
|
|
|
|
|
|
|
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|