2

我正在使用本机 WebRTC 和我的 Java Signaling Server 开发视频聊天应用程序。

我成功地创建了连接并且它工作得很好。

但是,当我尝试断开呼叫时,应用程序崩溃并显示以下错误消息:

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

我做错了什么?

4

1 回答 1

2

我通过在 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();
}
于 2020-09-07T10:37:54.023 回答