Reputation: 163
I have implemented appRTC in my app but changed its flow to multiple guests with one host (like a conference meeting etc.). But the issue I am facing is when I disconnects from host side the app got crashed. It also shows different weird exceptions on log related to SQLite and constraints. I have been working on this for a week but couldn't fount anything. This one I got this time.
2020-08-11 18:10:01.856 19916-19916/? E/SQLiteDatabase: Failed to open database '/data/user/0/com.facebook.appmanager/databases/androidx.work.workdb'. android.database.sqlite.SQLiteCantOpenDatabaseException: unknown error (code 14): Could not open database
The code I used to close Peer Connection is below:
private void disconnect() {
try{
if (appRtcClient != null) {
try{
appRtcClient.disconnectFromRoom();
appRtcClient = null;
}catch (Exception e){
e.printStackTrace();
}
}
if (FirebaseRTCClient.myId.equals("host")){
activityRunning = false;
if (appRtcClient != null) {
try{
appRtcClient.disconnectFromRoom();
appRtcClient = null;
}catch (Exception e){
e.printStackTrace();
}
}
try {
for (int i = 0; i<peerConnectionClientsList.size(); i++){
if (peerConnectionClientsList.get(i) != null) {
peerConnectionClientsList.get(i).close();
peerConnectionClient = null;
}
}
}catch (Exception e){
Toast.makeText(this, ""+e.getMessage(), Toast.LENGTH_SHORT).show();
}
if (localRender != null) {
localRender.release();
localRender = null;
}
if (videoFileRenderer != null) {
videoFileRenderer.release();
videoFileRenderer = null;
}
if (remoteRenderScreen != null) {
remoteRenderScreen.release();
remoteRenderScreen = null;
}
if (audioManager != null) {
audioManager.close();
audioManager = null;
}
if (iceConnected && !isError) {
setResult(RESULT_OK);
} else {
setResult(RESULT_CANCELED);
}
finish();
}
}catch (Exception e){
Toast.makeText(this, "Disconnect Error: "+e.getMessage(), Toast.LENGTH_SHORT).show();
}
}
and closeInternal() :
public void closeInternal() {
try{
if (factory != null && peerConnectionParameters.aecDump) {
factory.stopAecDump();
}
Log.d(TAG, "Closing peer connection.");
statsTimer.cancel();
try{
for (int i = 0; i<peerConnectionList.size(); i++){
if (peerConnectionList.get(i)!=null){
peerConnectionList.get(i).close();
peerConnection = null;
pcConstraints=null;
}
}
}catch (Exception e){
Toast.makeText(context, ""+e.getMessage(), Toast.LENGTH_SHORT).show();
}
Log.d(TAG, "Closing audio source.");
if (audioSource != null) {
audioSource.dispose();
audioSource = null;
}
Log.d(TAG, "Closing video source.");
if (videoSource != null) {
videoSource.dispose();
videoSource = null;
}
options = null;
Log.d(TAG, "Closing peer connection done.");
events.onPeerConnectionClosed();
PeerConnectionFactory.stopInternalTracingCapture();
PeerConnectionFactory.shutdownInternalTracer();
}catch (Exception e){
Toast.makeText(context, ""+e.getMessage(), Toast.LENGTH_SHORT).show();
}
}
Upvotes: 2
Views: 195