当第三方呼叫选择时,不保留我的CsipSimple Voip呼叫

时间:2019-06-08 13:10:30

标签: android pjsip csip-simple voip-android

我正在使用cSipSimple开发一个Voip应用程序。现在我想在第三方应用程序呼叫(whatsapp,instagram等)到来时显示忙音。现在的情况是我正在拨打我的voip电话,有一个正在拨打我的GSM号码,我正在接听我的voip电话通话会自动保持为保留状态,但下一个情况是,当第三方应用程序通话且我接听时,我的voip通话仍在继续并且第三方通话无法正常工作。 现在,我想在第三方应用程序呼叫且正在接听电话时将我的voip呼叫置于保留状态,并与第三方呼叫建立连接。是否有任何方法或接收方可以检测到第三方呼叫? ?

我正在尝试使用此How do I detect skype/telegram/whatsapp calls when my messenger app is in a call or wants to make a call?,但是没有用。

我正在使用此代码来检测GSM呼叫,并保留我的voip呼叫。

 public void onGSMStateChanged(int state, String incomingNumber) throws SameThreadException {
        // Avoid ringing if new GSM state is not idle
        if (state != TelephonyManager.CALL_STATE_IDLE && mediaManager != null) {
            mediaManager.stopRingAndUnfocus();
        }

        // If new call state is not idle
        if (state != TelephonyManager.CALL_STATE_IDLE && userAgentReceiver != null) {
            SipCallSession currentActiveCall = userAgentReceiver.getActiveCallOngoing();
            // If we have a sip call on our side
            if (currentActiveCall != null) {
                AudioManager am = (AudioManager) service.getSystemService(Context.AUDIO_SERVICE);
                if (state == TelephonyManager.CALL_STATE_OFFHOOK) {
                    // GSM is now off hook => hold current sip call
                    hasBeenHoldByGSM = currentActiveCall.getCallId();
                    callHold(hasBeenHoldByGSM);
                    pjsua.set_no_snd_dev();
                    am.setMode(AudioManager.MODE_IN_CALL);
                } else {
                    // We have a ringing incoming call.
                    // Avoid ringing
                    hasBeenChangedRingerMode = am.getRingerMode();
                    am.setRingerMode(AudioManager.RINGER_MODE_SILENT);
                    // And try to notify with tone
                    if (mediaManager != null) {
                        mediaManager.playInCallTone(MediaManager.TONE_CALL_WAITING);
                    }
                }
            }
        } else {
            // GSM is now back to an IDLE state, resume previously stopped SIP
            // calls
            if (hasBeenHoldByGSM != null && isCreated()) {
                pjsua.set_snd_dev(0, 0);
                callReinvite(hasBeenHoldByGSM, true);
                hasBeenHoldByGSM = null;
            }

            // GSM is now back to an IDLE state, reset ringerMode if was
            // changed.
            if (hasBeenChangedRingerMode != null) {
                AudioManager am = (AudioManager) service.getSystemService(Context.AUDIO_SERVICE);
                am.setRingerMode(hasBeenChangedRingerMode);
                hasBeenChangedRingerMode = null;
            }
        }
    }

提前感谢,将不胜感激!

0 个答案:

没有答案