Android SIP不录制语音

时间:2014-12-09 14:49:39

标签: android sip voip

我的SIP安卓问题。呼叫建立时,我什么都听不到。我的代码:

发起电话:

SipAudioCall.Listener listener = new SipAudioCall.Listener() {

            @Override
            public void onCallEstablished(SipAudioCall call) {
                RefreshView listener = new ConnectingNumberActivity();
                listener.refreshOnCallEstablished();
                call.startAudio();
                call.setSpeakerMode(true);
                if (call.isMuted()) {
                    call.toggleMute();
                }
            }

            @Override
            public void onCallEnded(SipAudioCall call) {
                stopRigtone();
                endCall();
            }
        };

        sipAudioCall = sipManager.makeAudioCall(sipProfile.getUriString(), sipAddress + "@" + domain , listener, 30);
        playRingtone("calling_tone.wav");
        sipAudioCall.toggleMute();

来电:

SipAudioCall.Listener listener = new SipAudioCall.Listener() {

            @Override
            public void onRinging(SipAudioCall call, SipProfile caller) {
                try {
                    call.answerCall(30);
                } catch (Exception e) {
                    Log.e(RINGING_ACTIVITY_TAG, e.toString());
                }
            }

            @Override
            public void onCallEnded(SipAudioCall call) {
                super.onCallEnded(call);
                closeIncomingCall();
                PhoneSipManager.stopRigtone();
                finish();
            }

            @Override
            public void onCallEstablished(SipAudioCall call) {
                super.onCallEstablished(call);

                try {
                    incomingCall.answerCall(30);
                    incomingCall.startAudio();
                    incomingCall.setSpeakerMode(true);
                    if (incomingCall.isMuted()) {
                        incomingCall.toggleMute();
                    }

                    PhoneSipManager.sipAudioCall = incomingCall;
                } catch (SipException e) {
                    e.printStackTrace();
                }

            }
        };

和单击“应答”按钮后调用的方法:

private void answerCall() {

    try {
        refreshView();
        incomingCall.answerCall(30);
        incomingCall.startAudio();
        incomingCall.setSpeakerMode(true);
        if (incomingCall.isMuted()) {
            incomingCall.toggleMute();
        }

        PhoneSipManager.sipAudioCall = incomingCall;

        Log.i(RINGING_ACTIVITY_TAG, "Ringing");
    } catch (Exception e) {
        Log.e(RINGING_ACTIVITY_TAG, e.toString());

        if (incomingCall != null) {
            incomingCall.close();
        }
    }
}

此代码基于WalkieTalkie Android示例。有人在第一台设备上录制呼叫时遇到同样的问题而在另一台设备上没有听到任何声音吗?

1 个答案:

答案 0 :(得分:1)

您可能想要检查您的权限。 我遇到了类似的问题但是当我设置以下权限和功能时它们就消失了:

<uses-permission android:name="android.permission.USE_SIP" />
<uses-permission android:name="android.permission.CONFIGURE_SIP" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.WAKE_LOCK"/> 

<uses-feature android:name="android.software.sip" android:required="true" />
<uses-feature android:name="android.software.sip.voip" android:required="true" />   
<uses-feature android:name="android.hardware.wifi" android:required="true" />
<uses-feature android:name="android.hardware.microphone" android:required="true" />
祝你好运。