Some seconds delay on starting sending Voip with Android.net.rtp


I implemented an Android app that uses Voip by Android.net.rtp library. It simply gets voice from device microphone and sends it in Voip (to another Android or to a PC receiver). The problem is that on some devices the voip trasmission start after 2–3 seconds. I don't mean that there is a delay of 2–3 seconds in delivering packets, I mean that the first 2–3 seconds of voice are not sended. After those 2–3 seconds everything works properly. The strange thing is that it happens only on some android device, and it is not a problem of device performance or Android version. For example it happens on a very old device and in a new one, while it doesn't happen in another very old device and in another new one… I thought to some Android service/functionality that delays mic capture, but I didn't find out anything at the moment…

In the following, the code I use to send Voip, it is a classical code:

myAudioStream = new AudioStream(myIPAddress); myAudioStream.setCodec(AudioCodec.PCMU); myAudioGroup = new AudioGroup(); myAudioManager = (AudioManager) myContext.getSystemService(Context.AUDIO_SERVICE); myAudioGroup.setMode(RtpStream.MODE_SEND_ONLY); myAudioStream.join(null); myAudioStream.setMode(RtpStream.MODE_SEND_ONLY); myAudioStream.associate(ipAddress_Receiver, port_Receiver); myAudioStream.join(myAudioGroup); myAudioManager.setMode(AudioManager.MODE_IN_COMMUNICATION); myAudioManager.setSpeakerphoneOn(false); myAudioManager.setMicrophoneMute(false);


Check if you can disable ICE and/or STUN in Android.net.rtp. These are usually responsible for the delay at media setup.


after some debugging I discovered that the AudioManager is introducing the delay in the setMode call:


The strange thing is that it depends from the device. With some devices it can introduce also 2-3 seconds, with other devices no delay is introduced.

See similar answer in: <a href="https://stackoverflow.com/questions/18393805/is-there-any-significant-delay-in-initializing-audiotrack-on-android" rel="nofollow">Is there any significant delay in initializing AudioTrack on Android?</a>

Finally I found out this solution, setting:


in the costructor of my class, then only once. I invoke the costructor on starting of my App, when I didn't start the voice TX yet. In this way, when I have to speak I don't have to loose those seconds...

Hope to be usefull for somobedy else.


  • high order bessel function computation with large variables
  • android mediarecorder error (MediaRecorder start failed : -19)
  • How to push data to variety of different client types in near real time?
  • AVCaptureDevice returning nil
  • ASP.NET: how to make onClientClick finish work before postback?
  • How to change sample rate properly in Avfoundation
  • Is Android capable of managing microphone/input volume?
  • iPhone: 5 seconds video capture
  • Printing out Japanese (Chinese) characters
  • ggplot2 polygon world map centred with limits gives funny edges
  • HTTP Module intercept requests and breaks custom errors configuration
  • Lua: Line breaks in strings
  • How can I tell a form not to dispose a particular control when it closes?
  • Hash Code in SQL Server?
  • How to make R's read_csv2() recognise the text characters properly
  • Is there a way to save the selected text and highlight it again once the page is refreshed?
  • as3-flash: any way to access all the instances placed in different frames from document class?
  • Intel-64 and ia32 atomic operations acquire-release semantics and GCC 5+
  • Read text file that is not in the main package in a runnable jar
  • Jenkins: FATAL: Could not initialize class hudson.util.ProcessTree$UnixReflection
  • Android application: how to use the camera and grab the image bytes?
  • Specifying Castle WCF Integration Facility Endpoint Behavior per Endpoint
  • How to use carriage return with multiple line?
  • D3 nodes and links from JSON with nested arrays of children
  • Cancel a live stream “fast motion” catch-up in Flash
  • Disable Enter in editText android
  • How to avoid particles glitching together in an elastic particle collision simulator?
  • Cannot resolve symbol 'MyApi'
  • If I include Java 8 in my Android app does that affect which devices it will work on?
  • CSS Linear-gradient formatting issue accross different browsers
  • Update CALayer sublayers immediately
  • QLineEdit password safety
  • Ajax jQuery multiple calls at the same time - long wait for answer and not able to cancel
  • Is there a amazon webstore API for customers?
  • Release, debug version and Authorization Google?
  • Circular dependency while pushing http interceptor
  • How to format a variable of double type
  • Angular 2 constructor injection vs direct access
  • -fvisibility=hidden not passed by compiler for Debug builds
  • coudnt use logback because of log4j