|
|
|
|
@ -58,7 +58,7 @@ class ChatCallProvider with ChangeNotifier, DiagnosticableTreeMixin {
|
|
|
|
|
chatHubConnection!.on("OnOfferAsync", onOfferAsync);
|
|
|
|
|
chatHubConnection!.on("OnAnswerOffer", onAnswerOffer);
|
|
|
|
|
chatHubConnection!.on("OnHangUpAsync", onHangUpAsync);
|
|
|
|
|
chatHubConnection!.on("OnCallDeclinedAsync", onCallDeclinedAsync);
|
|
|
|
|
// chatHubConnection!.on("OnCallDeclinedAsync", onCallDeclinedAsync);
|
|
|
|
|
// chatHubConnection!.on("OnIncomingCallAsync", OnIncomingCallAsync);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -85,6 +85,7 @@ class ChatCallProvider with ChangeNotifier, DiagnosticableTreeMixin {
|
|
|
|
|
chatProvModel = chatProvmodel;
|
|
|
|
|
outGoingCallData = callData;
|
|
|
|
|
await initStreams();
|
|
|
|
|
|
|
|
|
|
await startCall(callType: isVideoCall ? "Video" : "Audio", context: context);
|
|
|
|
|
_pc = await creatOfferWithCon();
|
|
|
|
|
connectOutgoing();
|
|
|
|
|
@ -147,11 +148,21 @@ class ChatCallProvider with ChangeNotifier, DiagnosticableTreeMixin {
|
|
|
|
|
if (isCallStarted) {
|
|
|
|
|
isIncomingCallLoader = false;
|
|
|
|
|
isOutGoingCall = true;
|
|
|
|
|
Navigator.pushReplacement(
|
|
|
|
|
providerContext,
|
|
|
|
|
MaterialPageRoute(
|
|
|
|
|
builder: (BuildContext context) => StartCallPage(),
|
|
|
|
|
));
|
|
|
|
|
if (Platform.isIOS) {
|
|
|
|
|
Future.delayed(Duration(seconds: 2), () {
|
|
|
|
|
Navigator.pushReplacement(
|
|
|
|
|
providerContext,
|
|
|
|
|
MaterialPageRoute(
|
|
|
|
|
builder: (BuildContext context) => StartCallPage(),
|
|
|
|
|
));
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
Navigator.pushReplacement(
|
|
|
|
|
providerContext,
|
|
|
|
|
MaterialPageRoute(
|
|
|
|
|
builder: (BuildContext context) => StartCallPage(),
|
|
|
|
|
));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -279,28 +290,77 @@ class ChatCallProvider with ChangeNotifier, DiagnosticableTreeMixin {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void onHangUpAsync(List<Object?>? params) {
|
|
|
|
|
print("--------------------- onHangUp ASYNC ---------------------------------------");
|
|
|
|
|
print("--------------------- onHangUp ASYNC ---------------------------------");
|
|
|
|
|
|
|
|
|
|
dynamic items = params!.toList();
|
|
|
|
|
if (kDebugMode) {
|
|
|
|
|
logger.i("res: " + items.toString());
|
|
|
|
|
}
|
|
|
|
|
endCall(isUserOnline: isUserOnline).then((bool value) {
|
|
|
|
|
if (isCallConnected && !AppState().isBackgroundCall) {
|
|
|
|
|
// Navigator.of(AppRoutes.navigatorKey.currentContext!).popUntil((route) => false);
|
|
|
|
|
Navigator.of(AppRoutes.navigatorKey.currentContext!).popUntil(ModalRoute.withName(AppRoutes.chatDetailed));
|
|
|
|
|
isCallConnected = false;
|
|
|
|
|
// if (kDebugMode) {
|
|
|
|
|
// logger.i("res: " + items.toString());
|
|
|
|
|
// }
|
|
|
|
|
if (items[0]["id"] != AppState().chatDetails!.response!.id) {
|
|
|
|
|
if (kDebugMode) {
|
|
|
|
|
print("Call Ended By Other User");
|
|
|
|
|
}
|
|
|
|
|
if (items[0]["id"] != AppState().chatDetails!.response!.id && !AppState().isBackgroundCall) {
|
|
|
|
|
if (kDebugMode) {
|
|
|
|
|
print("Popped Due to Another User");
|
|
|
|
|
if (isIncomingCall) {
|
|
|
|
|
endCall(isUserOnline: isUserOnline).then((bool value) {
|
|
|
|
|
if (isCallConnected && isUserOnline) {
|
|
|
|
|
isCallConnected = false;
|
|
|
|
|
if (!AppState().isLogged) {
|
|
|
|
|
Navigator.of(AppRoutes.navigatorKey.currentContext!).pop();
|
|
|
|
|
} else {
|
|
|
|
|
Navigator.of(AppRoutes.navigatorKey.currentContext!).popUntil(ModalRoute.withName(AppRoutes.dashboard));
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
Navigator.of(AppRoutes.navigatorKey.currentContext!).pop();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
if (isOutGoingCall) {
|
|
|
|
|
endCall(isUserOnline: isUserOnline).then((bool value) {
|
|
|
|
|
if (isCallConnected && isUserOnline) {
|
|
|
|
|
isCallConnected = false;
|
|
|
|
|
Navigator.of(AppRoutes.navigatorKey.currentContext!).popUntil(ModalRoute.withName(AppRoutes.dashboard));
|
|
|
|
|
} else {
|
|
|
|
|
Navigator.of(AppRoutes.navigatorKey.currentContext!).pop();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
Navigator.of(AppRoutes.navigatorKey.currentContext!).pop();
|
|
|
|
|
}
|
|
|
|
|
if (AppState().isBackgroundCall) {
|
|
|
|
|
Navigator.of(AppRoutes.navigatorKey.currentContext!).pop();
|
|
|
|
|
} else {
|
|
|
|
|
if (kDebugMode) {
|
|
|
|
|
print("Call Ended By Me");
|
|
|
|
|
}
|
|
|
|
|
isCallEnded = true;
|
|
|
|
|
});
|
|
|
|
|
if (isOutGoingCall) {
|
|
|
|
|
if (isCallConnected && isUserOnline) {
|
|
|
|
|
isCallConnected = false;
|
|
|
|
|
Navigator.of(AppRoutes.navigatorKey.currentContext!).popUntil(ModalRoute.withName(AppRoutes.chatDetailed));
|
|
|
|
|
} else {
|
|
|
|
|
Navigator.of(AppRoutes.navigatorKey.currentContext!).pop();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// endCall(isUserOnline: isUserOnline).then((bool value) {
|
|
|
|
|
// if (isCallConnected && isUserOnline) {
|
|
|
|
|
// Navigator.of(AppRoutes.navigatorKey.currentContext!).popUntil(ModalRoute.withName(AppRoutes.chatDetailed));
|
|
|
|
|
// isCallConnected = false;
|
|
|
|
|
// }
|
|
|
|
|
// if (items[0]["id"] != AppState().chatDetails!.response!.id && !AppState().isBackgroundCall) {
|
|
|
|
|
// if (kDebugMode) {
|
|
|
|
|
// print("Popped Due to Another User");
|
|
|
|
|
// }
|
|
|
|
|
// if (AppState().isBackgroundCall) {
|
|
|
|
|
// Navigator.of(AppRoutes.navigatorKey.currentContext!).pop();
|
|
|
|
|
// // Navigator.of(AppRoutes.navigatorKey.currentContext!).popUntil(ModalRoute.withName(AppRoutes.login));
|
|
|
|
|
// } else {
|
|
|
|
|
// Navigator.of(AppRoutes.navigatorKey.currentContext!).popUntil(ModalRoute.withName(AppRoutes.chat));
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// if (AppState().isBackgroundCall) {
|
|
|
|
|
// Navigator.of(AppRoutes.navigatorKey.currentContext!).pop();
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
notifyListeners();
|
|
|
|
|
isCallEnded = true;
|
|
|
|
|
// });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Future<void> OnIncomingCallAsync(List<Object?>? params) async {
|
|
|
|
|
@ -362,15 +422,15 @@ class ChatCallProvider with ChangeNotifier, DiagnosticableTreeMixin {
|
|
|
|
|
// notifyListeners();
|
|
|
|
|
// }
|
|
|
|
|
// });
|
|
|
|
|
if (params != null) {
|
|
|
|
|
endCall(isUserOnline: isUserOnline).then((bool value) {
|
|
|
|
|
// if (isCallConnected) {
|
|
|
|
|
Navigator.of(AppRoutes.navigatorKey.currentContext!).pop();
|
|
|
|
|
// isCallConnected = false;
|
|
|
|
|
// }
|
|
|
|
|
isCallEnded = true;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
// if (params != null) {
|
|
|
|
|
// endCall(isUserOnline: isUserOnline).then((bool value) {
|
|
|
|
|
// if (isCallConnected) {
|
|
|
|
|
// // Navigator.of(AppRoutes.navigatorKey.currentContext!).pop();
|
|
|
|
|
// isCallConnected = false;
|
|
|
|
|
// }
|
|
|
|
|
// isCallEnded = true;
|
|
|
|
|
// });
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//// Invoke Methods
|
|
|
|
|
@ -593,16 +653,18 @@ class ChatCallProvider with ChangeNotifier, DiagnosticableTreeMixin {
|
|
|
|
|
await localVideoRenderer!.initialize();
|
|
|
|
|
try {
|
|
|
|
|
_localStream = await navigator.mediaDevices.getUserMedia({
|
|
|
|
|
'audio': false,
|
|
|
|
|
'video': {
|
|
|
|
|
'mandatory': {
|
|
|
|
|
'minWidth': '640', // Provide your own width, height and frame rate here
|
|
|
|
|
'minHeight': '480',
|
|
|
|
|
'minFrameRate': '30',
|
|
|
|
|
},
|
|
|
|
|
'facingMode': 'user',
|
|
|
|
|
'optional': [],
|
|
|
|
|
}
|
|
|
|
|
'audio': true,
|
|
|
|
|
'video': isVideoCall
|
|
|
|
|
? {
|
|
|
|
|
'mandatory': {
|
|
|
|
|
'minWidth': '640', // Provide your own width, height and frame rate here
|
|
|
|
|
'minHeight': '480',
|
|
|
|
|
'minFrameRate': '30',
|
|
|
|
|
},
|
|
|
|
|
'facingMode': 'user',
|
|
|
|
|
'optional': [],
|
|
|
|
|
}
|
|
|
|
|
: false
|
|
|
|
|
});
|
|
|
|
|
if (kDebugMode) {
|
|
|
|
|
print(_localStream..toString());
|
|
|
|
|
|