pjsip-android icon indicating copy to clipboard operation
pjsip-android copied to clipboard

[ISSUE] Connect to PJSIP call while having other Voip call ongoing Android. Cannot hear in PJSIP call

Open mudassirzulfiqar opened this issue 1 year ago • 8 comments

Describe the bug If you are in other VOIP calls like Microsoft Team & WhatsApp. You cannot hear a person through PJSIP call. On the other hand, if you use Zoiper client, you cannot hear in other VOIP calls so Zoiper takes over the calling power.

Lib version Current latest

*Configuration NA

Changes NA

Smartphone (please complete the following information):

  • Device: Android latest PIxels, Latest Samsung Galaxy Device
  • OS: Latest OS

Additional context Is there any way to route Audio calls to different routes, as in iOS using Call Kit you can control this easily, by selecting different VoIP calls and make any call active. How Microsoft team is taking over my VOIP call, but I cant. How Zoiper is taking over Microsoft Team and Team doesnt. Anyone know any insights about it?

mudassirzulfiqar avatar Aug 24 '23 09:08 mudassirzulfiqar

I think what you are looking for is the "Request Audio Focus" feature. It is independent from the library and should be handled by the client app. Basically you have to request the audio focus and listen to its state and react accordingly (e.g. if you lose focus). You should read about the Android Audio Manager

aenonGit avatar Aug 28 '23 09:08 aenonGit

here is the complete explanation of the problem, I would appreciate you if you could look into it. https://stackoverflow.com/questions/77040240/pjsip-android-call-cannot-hear-while-having-other-voip-call?noredirect=1#comment135816998_77040240

mudassirzulfiqar avatar Sep 05 '23 10:09 mudassirzulfiqar

Based on the API level you should request the audio focus differently. I don't see any problem here. A simple if should be enough

aenonGit avatar Sep 05 '23 10:09 aenonGit

@aenonGit I see another issue, If I end the Microsoft Teams call, I'm able to talk again, but the Speaker stops working, I use a blow code to activate the speaker normally. AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); audioManager.setSpeakerphoneOn(true); The call doesn't go back to the speaker, although the earpiece works fine.

mudassirzulfiqar avatar Sep 05 '23 11:09 mudassirzulfiqar

I updated the link above, I mistakenly shared the wrong link.

mudassirzulfiqar avatar Sep 05 '23 11:09 mudassirzulfiqar

Same as before, without requesting audio focus and listening for its state audio will never work fine.

aenonGit avatar Sep 05 '23 12:09 aenonGit

Thanks for your answer @aenonGit I have discovered this library https://github.com/twilio/audioswitch. Maybe something is interesting for me. But still when I establish my call while having the team call using the below code. Microphone doesn't work. I have no idea how Microsoft is interrupting my call.

@SuppressLint("NewApi") fun buildRequest(audioFocusChangeListener: OnAudioFocusChangeListener): AudioFocusRequest { val playbackAttributes = AudioAttributes.Builder() .setUsage(AudioAttributes.USAGE_VOICE_COMMUNICATION) .setContentType(AudioAttributes.CONTENT_TYPE_SPEECH) .build() return AudioFocusRequest.Builder(AudioManager.AUDIOFOCUS_GAIN_TRANSIENT) .setAudioAttributes(playbackAttributes) .setAcceptsDelayedFocusGain(true) .setOnAudioFocusChangeListener(audioFocusChangeListener) .build() }

mudassirzulfiqar avatar Sep 05 '23 14:09 mudassirzulfiqar

I still think you are not handling the audiofocus correctly

aenonGit avatar Aug 05 '24 15:08 aenonGit