Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/195.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android:VideoCaptureThread上的webRtc崩溃_Android_Webrtc - Fatal编程技术网

Android:VideoCaptureThread上的webRtc崩溃

Android:VideoCaptureThread上的webRtc崩溃,android,webrtc,Android,Webrtc,我在安卓系统中使用webrtc实现了视频通话,但我有这样的想法。它不是所有时候都产生的,只有在应用程序中有多个用户会话时才会产生 FATAL EXCEPTION: VideoCapturerThread Process: fapp.id, PID: 4870 java.lang.RuntimeExcep

我在安卓系统中使用
webrtc
实现了视频通话,但我有这样的想法。它不是所有时候都产生的,只有在应用程序中有多个用户会话时才会产生

FATAL EXCEPTION: VideoCapturerThread
                                                 Process: fapp.id, PID: 4870
                                                 java.lang.RuntimeException: Not on camera thread.
                                                     at org.webrtc.CameraCapturer.checkIsOnCameraThread(CameraCapturer.java:559)
                                                     at org.webrtc.CameraCapturer.access$000(CameraCapturer.java:20)
                                                     at org.webrtc.CameraCapturer$1.onDone(CameraCapturer.java:47)
                                                     at org.webrtc.Camera2Session$CaptureSessionCallback.onConfigured(Camera2Session.java:233)
                                                     at java.lang.reflect.Method.invoke(Native Method)
                                                     at android.hardware.camera2.dispatch.InvokeDispatcher.dispatch(InvokeDispatcher.java:39)
                                                     at android.hardware.camera2.dispatch.HandlerDispatcher$1.run(HandlerDispatcher.java:65)
                                                     at android.os.Handler.handleCallback(Handler.java:751)
                                                     at android.os.Handler.dispatchMessage(Handler.java:95)
                                                     at android.os.Looper.loop(Looper.java:154)
                                                     at android.os.HandlerThread.run(HandlerThread.java:61)
这是我的密码

 private VideoCapturer createCameraCapturer(CameraEnumerator enumerator) {
        final String[] deviceNames = enumerator.getDeviceNames();
        // First, try to find front facing camera
        Logging.d(TAG, "Looking for front facing cameras.");
        for (String deviceName : deviceNames) {
            if (enumerator.isFrontFacing(deviceName)) {
                Logging.d(TAG, "Creating front facing camera capturer.");

                VideoCapturer videoCapturer = enumerator.createCapturer(deviceName, null);
                if (videoCapturer != null) {
                    return videoCapturer;
                }
            }
        }
        // Front facing camera not found, try something else
        Logging.d(TAG, "Looking for other cameras.");
        for (String deviceName : deviceNames) {
            if (!enumerator.isFrontFacing(deviceName)) {
                Logging.d(TAG, "Creating other camera capturer.");
                VideoCapturer videoCapturer = enumerator.createCapturer(deviceName, null);
                if (videoCapturer != null) {
                    return videoCapturer;
                }
            }
        }
        return null;
    }

如何修复此问题?

当会话中的用户数发生变化时,尝试重新创建视频源。在创建
videoSource=peerConnectionFactory.createVideoSource(videoCapturerAndroid)之前添加以下代码


希望有帮助。

您是否在主线程以外的其他线程上调用此代码?
if(videoCapturerAndroid!=null) {
                    try {
                        videoCapturerAndroid.stopCapture();
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }catch (Exception e) {
                        e.printStackTrace();
                    }
                    videoCapturerAndroid = createVideoCapturer(isFrontCamera);

                }