Search code examples
androidpjsip

(180 ringning)No ringing tone while connecting call android pjsip (pjsua2)


I have implemented a project for VOIP using PJSIP(PJSUA2).

Everything is fine, but I am not hearing ringing sound when I am calling some one. But other end, he is receiving call.

Here, We can not judge that call is connecting to other one.

Please help me. Thank you.


Solution

  • Generate tone by yourself. You can use android.media.ToneGenerator. Something like this:

    ToneGenerator toneGenerator = new ToneGenerator(AudioManager.STREAM_VOICE_CALL, 100);
    toneGenerator.startTone(ToneGenerator.TONE_CDMA_NETWORK_USA_RINGBACK, 1000);
    

    EDIT

    You can get CallInfo in notifyCallState.

    CallInfo ci = call.getInfo();
    if (ci.getState() == pjsip_inv_state.PJSIP_INV_STATE_EARLY 
        && ci.getRole() == pjsip_role_e.PJSIP_ROLE_UAC 
        && ci.getLastReason().equals("Ringing")) {
         toneGeneratorHelper.startRingBack();
    } else {
      toneGeneratorHelper.stopRingBack();
    }
    

    And for repeating tone you can use handler with postDelayed. Create helper class for this.