android webRTC在对等连接上崩溃,dispose()

bihw5rsg  于 2022-12-25  发布在  Android
关注(0)|答案(2)|浏览(300)

我正在开发视频聊天应用程序使用本地WebRTC与我的Java信令服务器。
我已经成功地创建了连接,它工作得很好。
但是,当我试图断开通话时,应用程序崩溃,并显示以下错误消息:

D/ZCF: Closing audio source.
    Stopping capture.
I/org.webrtc.Logging: CameraCapturer: Stop capture
    CameraCapturer: Stop capture: Nulling session
I/org.webrtc.Logging: CameraCapturer: Stop capture done
    CameraCapturer: dispose
    CameraCapturer: Stop capture
    CameraCapturer: Stop capture: No session open
I/org.webrtc.Logging: Camera1Session: Stop camera1 session on camera 1
I/org.webrtc.Logging: CameraCapturer: Stop capture done
D/ZCF: Closing video source.
D/ZCF: Closing peer connection.
I/org.webrtc.Logging: Camera1Session: Stop internal
    SurfaceTextureHelper: stopListening()
I/ZCF: onIceConnectionChange CLOSED
I/org.webrtc.Logging: WebRtcAudioRecord: stopRecording
    WebRtcAudioRecord: stopThread
I/org.webrtc.Logging: WebRtcAudioEffects: release
I/org.webrtc.Logging: WebRtcAudioRecord: releaseAudioResources
I/org.webrtc.Logging: HardwareVideoEncoder: Releasing MediaCodec on output thread
I/org.webrtc.Logging: HardwareVideoEncoder: Release on output thread done
I/org.webrtc.Logging: AndroidVideoDecoder: release
I/org.webrtc.Logging: Camera1Session: Stop done
I/org.webrtc.Logging: Camera1Session: Bytebuffer frame captured but camera is no longer running.
I/org.webrtc.Logging: AndroidVideoDecoder: Releasing MediaCodec on output thread
D/SurfaceUtils: disconnecting from surface 0x713adfd010, reason disconnectFromSurface
I/org.webrtc.Logging: AndroidVideoDecoder: Release on output thread done
I/org.webrtc.Logging: SurfaceTextureHelper: stopListening()
I/org.webrtc.Logging: SurfaceTextureHelper: dispose()
I/org.webrtc.Logging: WebRtcAudioTrack: stopPlayout
    WebRtcAudioTrack: underrun count: 1
I/org.webrtc.Logging: WebRtcAudioTrack: stopThread
    WebRtcAudioTrack: Stopping the AudioTrackThread...
I/org.webrtc.Logging: WebRtcAudioTrack: Calling AudioTrack.stop...
D/AudioTrack: stop() called with 324000 frames delivered
I/org.webrtc.Logging: WebRtcAudioTrack: AudioTrack.stop is done.
I/org.webrtc.Logging: WebRtcAudioTrack: AudioTrackThread has now been stopped.
I/org.webrtc.Logging: WebRtcAudioTrack: releaseAudioResources
V/AudioTrack: ~AudioTrack, releasing session id 26833 from 19927 on behalf of 19927
I/org.webrtc.Logging: NetworkMonitor: Stop monitoring with native observer 486337727744
I/org.webrtc.Logging: NetworkMonitorAutoDetect: Unregister network callback
E/rtc: #
    # Fatal error in: ../../../../usr/local/google/home/sakal/code/webrtc-aar-release/src/pc/peerconnection.cc, line 6729
    # last system error: 0
    # Check failed: observer_
    # 
A/libc: Fatal signal 6 (SIGABRT), code -6 (SI_TKILL) in tid 20013 (signaling_threa), pid 19927 (i.myapplication)
Application terminated.

当我调用peerConnection.dispose()或peerConnection.close()时发生崩溃;
下面是我的代码断开呼叫:

private void callDisconnect() {
    if (peerConnectionFactory != null) {
        peerConnectionFactory.stopAecDump();
    }
    Log.d("ZCF", "Closing audio source.");
    if (audioSource != null) {
        audioSource.dispose();
        audioSource = null;
    }
    Log.d("ZCF", "Stopping capture.");
    if (videoCapturer != null) {
        try {
            videoCapturer.stopCapture();
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        videoCapturer.dispose();
        videoCapturer = null;
    }
    Log.d("ZCF", "Closing video source.");
    if (videoSource != null) {
        videoSource.dispose();
        videoSource = null;
    }

    Log.d("ZCF", "Closing peer connection.");
    if (peerConnection != null) {
        peerConnection.dispose();
        peerConnection = null;
    }

    Log.d("ZCF", "Closing peer connection factory.");
    if (peerConnectionFactory != null) {
        peerConnectionFactory.dispose();
        peerConnectionFactory = null;
    }

    rootEglBase.release();
    Log.d("ZCF", "Closing peer connection done.");
    PeerConnectionFactory.stopInternalTracingCapture();
    PeerConnectionFactory.shutdownInternalTracer();
}

我试过先调用peerConnection.dispose(),但它还是崩溃了。不管我试过什么,它总是崩溃,并显示以下内容:

I/org.webrtc.Logging: NetworkMonitorAutoDetect: Unregister network callback

我做错了什么?

4bbkushb

4bbkushb1#

我已经通过在peerConnection之前处理peerConnectionFactory修复了该问题。

@Override
public void disconnect() {

    if(executor == null) return;

    executor.execute(() -> {

        localVideoTrack.dispose();
        localVideoSource.dispose();
        localAudioTrack.dispose();
        localAudioSource.dispose();
        peerConnectionFactory.dispose();
        peerConnection.dispose();
    });

    executor.shutdown();
}
but5z9lq

but5z9lq2#

我在onResume()中添加了网络监视器.getInstance().startMonitoring(getActivity());没有找到这个崩溃

相关问题