title: How to receive RTP audio stream Android?
body: <p>I am using Java to stream rtp audio from the microphone to my android phone app, but I am not hearing any sound. There are no errors when settings up the AudioGroup and AudioStream so I assume everything is going correctly. Here is the code on the app side:</p>
  
  <pre><code>    AudioStream audioStream;
      AudioGroup audioGroup;
      AudioCodec codec = AudioCodec.PCMU;
      StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitNetwork().build();
      StrictMode.setThreadPolicy(policy);
      AudioManager audio = (AudioManager)getSystemService(AUDIO_SERVICE);
      audio.setMode(AudioManager.MODE_IN_COMMUNICATION);
      audioGroup = new AudioGroup();
      audioGroup.setMode(AudioGroup.MODE_NORMAL);
      InetAddress inetAddress;
      try {
          inetAddress = InetAddress.getByName("163.11.62.208");
          audioStream = new AudioStream(inetAddress);
          audioStream.setMode(RtpStream.MODE_RECEIVE_ONLY);
          audioStream.setCodec(codec);
  
  
          InetAddress inetAddressRemote = InetAddress.getByName("163.11.169.206");
          audioStream.associate(inetAddressRemote, 5004);
          audioStream.join(audioGroup);
      }
  </code></pre>
  
  <p>The ffmpeg stream test I use (which works on vlc Android player) is </p>
  
  <pre><code>ffmpeg -f lavfi -i aevalsrc="sin(400*2*PI*t)" -ar 8000 -vcodec pcm_u8 -f rtp rtp://163.11.62.208:5004
  </code></pre>
  
  <p>Again.. This works in VLC android player but not in my app. No errors.. Just no audio.</p>
  
  <p>Ok I just noticed in LogCat that I am getting messages telling me that it is working. Here are some of the logs. </p>
  
  <pre><code>stream[59] is configured as RAW 8kHz 32ms mode 0
  D/AudioGroup﹕ stream[59] joins group[56]
  group[56] switches from mode 0 to 1
  stream[54] joins group[56]
  getOutputSamplingRate() reading from output desc
  V/AudioSystem﹕ getSamplingRate() streamType 0, output 2, sampling rate 48000
  V/AudioSystem﹕ getFrameCount() streamType 0, output 2, frameCount 960
  V/AudioSystem﹕ getLatency() streamType 0, output 2, latency 160
  V/AudioTrack﹕ getMinFrameCount=1280: afFrameCount=960, minBufCount=8, afSampleRate=48000, afLatency=160
  D/AudioGroup﹕ reported frame count: output 1280, input 320
  D/AudioGroup﹕ adjusted frame count: output 1280, input 512
  V/AudioTrack﹕ sampleRate 8000, channelMask 0x1, format 1
  V/AudioTrack﹕ streamType 0
  V/AudioTrack﹕ set() streamType 0, sampleRate 8000, format 1, frameCount 1280, flags 0000
  V/AudioSystem﹕ getLatency() streamType 0, output 2, latency 160
  V/AudioSystem﹕ getFrameCount() streamType 0, output 2, frameCount 960
  V/AudioSystem﹕ getOutputSamplingRate() reading from output desc
  V/AudioSystem﹕ getSamplingRate() streamType 0, output 2, sampling rate 48000
  V/AudioTrack﹕ createTrack_l() output 2 afLatency 160
  V/AudioTrack﹕ afFrameCount=960, minBufCount=8, afSampleRate=48000, afLatency=160
  V/AudioTrack﹕ minFrameCount: 1280, afFrameCount=960, minBufCount=8, sampleRate=8000, afSampleRate=48000, afLatency=160
  V/AudioRecord﹕ sampleRate 8000, channelMask 0x10, format 1
  V/AudioRecord﹕ inputSource 7
  V/AudioRecord﹕ set(): sampleRate 8000, channelMask 0x10, frameCount 512
  D/AudioRecord﹕ set(): voiceActivationState 0
  D/AudioRecord﹕ Keep input Source type.
  V/AudioRecord﹕ AudioRecord::set() minFrameCount = 320
  V/AudioRecord﹕ set(): mSessionId 1827
  V/AudioSystem﹕ ioConfigChanged() event 3, ioHandle 1828
  </code></pre>
  
  <p>BUT: I also just noticed that I get no system volume at all when running my app. When I change system volume it usually makes an indicator noise to show how loud/quiet that is but I'm hearing nothing. I'm not sure why that is.</p>