Using android.net.rtp for VoIP

I am trying to use the android.net.rtp library to create a VoIP application. Its audio stream can be either sent or received correctly.

My problem: the phone speaker of the called phone is working fine, but the headset is turned off all the time (even if I turn off the speaker).

My code is:

 AudioManager Audio = (AudioManager) getSystemService(Context.AUDIO_SERVICE); Audio.setMode(AudioManager.MODE_IN_COMMUNICATION); Audio.setSpeakerphoneOn(true); Audio.setMicrophoneMute(false); sender = new RtpStreamSender(null, "169.0.199.19", AudioCodec.PCMU); 
+6
source share
1 answer

This code will help you.

 @SuppressWarnings("deprecation") boolean isWiredHeadsetOn = audioManager.isWiredHeadsetOn(); audioManager.setMode(isWiredHeadsetOn ? AudioManager.MODE_IN_CALL : AudioManager.MODE_IN_COMMUNICATION); audioManager.setSpeakerphoneOn(false); 
0
source

Source: https://habr.com/ru/post/951290/


All Articles