Monday, July 20, 2009

Real Time Audio Streaming for Android - Some Developments

OK, so I've made some progress on this project.

  • I have figured out how the Audio Streaming APIs work on the 1.5 SDK.
  • I have obtained a G 711 speech codec in Java which runs on Android. This was taken from the 'sipdroid' VoIP client.
  • I have been able to stream a pre-recorded PCM voice file to the emulator via UDP and play it using AudioTrack.
  • I have figured out how to use the jLibRtp RTP stack in a Java program. There is a port of the same stack by HSC for Android. So I guess it should work there also, but, I must still test it out.
So, it looks like most of the pieces of the puzzle are in place. However, while using AudioRecord and UDP on the emulator, I have encountered the following problems.

  1. On the emulator, I instantiate AudioRecord with a sampling rate of 8000Hz and an encoding of 16BIT PCM. This works fine. However, when I try to run the same code on a device, the AudioRecord object does not get created. Looks like I will have to experiment with different sampling rates and buffer sizes. Strange, huh?
  2. To test the sending and receiving of PCM data, I built a small Java applet that streamed the PCM data to the emulator. I setup proper port redirections. I am able to receive the data in the emulator, but, when I try to send data OUT from the emulator, nothing happens.
Looks like once these problems are sorted out, we are good to go!!!


  1. interesting, but funny how could you have got that far (applet to emulator), but the emulator cannot send out? have you tried using a real device instead of emulator. what error messages, if any do you get? also, what does the ddms logger say? could you send me your email address?

  2. the fundamental problem is real-time, you're tests involve sending a pre-recorded file.

  3. in 1.5 sdk they hardcoded one sample rate 8000/16/1. Just look into android sources

  4. did you investigate audio latency? did you get some progress in this area?

  5. @kevin: this is my email ID:

    there are lots of problems with the audio APIs in 1.5 I am trying to work around these problems.

  6. I have three different phones, tell me if you want me to test some of this on any of them (ADP1, Google ION, HTC Hero).

  7. @Gunnar - thanks, I will send some APKs in some time :)

  8. One aspect of a comprehensive search engine optimization implementation is the use of optimized video content. Google having come up with new algorithms alongwith universal search features, now one will do best to optimize not only the said website but also all available digital assets, such as videos. Additionally one can, for example, embed on one’s site the videos placed on You Tube. (Google seems to give them most relevance!)

  9. Hello, nice work,can you post your code? or can you make a tutorial explaining how to do it?,
    I have managed to use AutdioTrack and AudioRecord but can't send the packets over JLibRTP. thanks maxsap