Android WebRTC 崩溃

Android WebRTC crashes

我正尝试通过按后退按钮断开通话,但应用程序因此错误而崩溃。我在 Eclipse 上使用 Pierre Chabardes 的 AndroidRTC 应用程序。 https://github.com/pchab/AndroidRTC

我还通过linux机器构建了最新的WebRTC libjingle_peerconnection_so.so & libjingle_peerconnection.jar .

04-10 12:20:16.695: E/rtc(29060): #
04-10 12:20:16.695: E/rtc(29060): # Fatal error in ../../talk/app/webrtc/java/jni/peerconnection_jni.cc, line 926
04-10 12:20:16.695: E/rtc(29060): # Check failed: 0 == (reinterpret_cast<MediaSourceInterface*>(j_p))->Release() (0 vs. 1)
04-10 12:20:16.695: E/rtc(29060): # Unexpected refcount.
04-10 12:20:16.695: E/rtc(29060): #
04-10 12:20:16.695: A/libc(29060): Fatal signal 6 (SIGABRT), code -6 in tid 29060 

经过几个小时的测试,我发现最初创建的Socket在onDestroy()方法中没有正常关闭。

那里是这样的:

public void onDestroy() {
    for (Peer peer : peers.values()) {
        peer.pc.dispose();
    }
    videoSource.dispose();
    factory.dispose();
    client.disconnect();
    client.close();
}

需要这样关闭:

public void onDestroy() {
    for (Peer peer : peers.values()) {
        peer.pc.dispose();
    }
    videoSource.dispose();
    factory.dispose();
    client.off();<---- You need to turn OFF and then disconnect  and then close it.
    client.disconnect();
    client.close();
}