2

我已经在我的应用程序中实现了 appRTC,但将其流程更改为一位主持人的多位客人(如会议等)。但是我面临的问题是,当我从主机端断开连接时,应用程序崩溃了。它还在与 SQLite 和约束相关的日志上显示了不同的奇怪异常。我已经为此工作了一周,但找不到任何东西。这次我得到了这个。

2020-08-11 18:10:01.856 19916-19916/? E/SQLiteDatabase:无法打开数据库“/data/user/0/com.facebook.appmanager/databases/androidx.work.workdb”。android.database.sqlite.SQLiteCantOpenDatabaseException:未知错误(代码 14):无法打开数据库

我用来关闭对等连接的代码如下:

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();
    }
}

和 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();
}
  }
4

0 回答 0