更改WebRTC LegacyAudioDeviceModel后,IOS到android呼叫已连接...但无法接听

时间:2019-04-06 08:46:46

标签: java android webrtc

我正在使用WebRTC在我的应用中进行音频通话。我正面临以下问题

Android应用程序到Android应用程序->通话功能--->工作正常

iOS应用到iOS应用->通话功能--->工作正常

Android应用到iOS应用->调用功能--->不起作用

在下面提到的函数中,“ newState”总是返回CHECKING状态

@Override
    public void onIceConnectionState(PeerConnection.IceConnectionState newState) {
        Log.v(TAG, "ICE= " + newState);
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                if (newState == PeerConnection.IceConnectionState.CONNECTED) {
                    callType.setVisibility(View.GONE);
                    if (type.equals("audio")) {
                        callTime.setVisibility(View.VISIBLE);
                        startCountDown("answer");
                    } else {
                        updateVideoViews(true);
                    }
                } else if (newState == PeerConnectenter code hereion.IceConnectionState.DISCONNECTED) {
                    callType.setVisibility(View.VISIBLE);
                    callType.setText(getString(R.string.poor_connection_connecting));
                    callTime.setVisibility(View.GONE);
                } else if (newState == PeerConnection.IceConnectionState.CLOSED) {

                } else {
                    callType.setVisibility(View.VISIBLE);
                    callType.setText(getString(R.string.connecting));
                    callTime.setVisibility(View.GONE);
                }
            }
        });
    }

我正在使用的旧版文件在下面的链接中给出 链接:https://chromium.googlesource.com/external/webrtc/+/HEAD/sdk/android/api/org/webrtc/audio/LegacyAudioDeviceModule.java

1 个答案:

答案 0 :(得分:0)

这可能是由于编解码器引起的,请确保以正确的方式创建PeerConnectionFactory

final PeerConnectionFactory.Options options = new PeerConnectionFactory.Options();
final DefaultVideoEncoderFactory encoderFactory = new DefaultVideoEncoderFactory(eglBase.getEglBaseContext(), true, true);
final DefaultVideoDecoderFactory decoderFactory = new DefaultVideoDecoderFactory(eglBase.getEglBaseContext());
peerConnectionFactory = PeerConnectionFactory.builder().setOptions(options).
                setVideoDecoderFactory(decoderFactory).
                setVideoEncoderFactory(encoderFactory).
                createPeerConnectionFactory();