public void run() {

		int frameLength, frameType;
		long now = System.nanoTime(), oldtime = now;
		byte[] header = new byte[AMR_HEADER_LENGTH];

		try {

			// Skip raw AMR header
			fill(header,0,AMR_HEADER_LENGTH);
			
			if (header[5] != '\n') {
				Log.e(TAG,"Bad header ! AMR not correcty supported by the phone !");
				return;
			}

			while (!Thread.interrupted()) {

				buffer = socket.requestBuffer();
				buffer[rtphl] = (byte) 0xF0;
				
				// First we read the frame header
				fill(buffer, rtphl+1,AMR_FRAME_HEADER_LENGTH);

				// Then we calculate the frame payload length
				frameType = (Math.abs(buffer[rtphl + 1]) >> 3) & 0x0f;
				frameLength = (sFrameBits[frameType]+7)/8;

				// And we read the payload
				fill(buffer, rtphl+2,frameLength);

				//Log.d(TAG,"Frame length: "+frameLength+" frameType: "+frameType);

				// RFC 3267 Page 14: "For AMR, the sampling frequency is 8 kHz"
				// FIXME: Is this really always the case ??
				ts += 160L*1000000000L/samplingRate; //stats.average();
				socket.updateTimestamp(ts);
				socket.markNextPacket();

				//Log.d(TAG,"expected: "+ expected + " measured: "+measured);
				
				send(rtphl+1+AMR_FRAME_HEADER_LENGTH+frameLength);
				
			}

		} catch (IOException e) { 
		} catch (InterruptedException e) {}

		Log.d(TAG,"AMR packetizer stopped !");

	}
RFC 3267.
  
  AMR Streaming over RTP.
  
  Must be fed with an InputStream containing raw AMR NB
  Stream must begin with a 6 bytes long header: "#!AMR\n", it will be skipped
src/net/majorkernelpanic/streaming/rtp/AMRNBPacketizer.java