Search code examples
flashapache-flexaudiospeex

Process Flex/Flash SPEEX Audio Data on the Server Side


I'm implementing a very simple audio-only RTMP server.

I have my client code like this:

// get the default mic
var mic:Microphone= Microphone.getMicrophone();

// best quality (picks up all sounds, no transmission interruptions)
mic.setSilenceLevel(0);

// Using SPEEX codec with quality of 5
mic.codec = SoundCodec.SPEEX;
mic.encodeQuality = 5; // Required bit rate: 16.8 kbits/s, 

// Rate is automatically set to 16K Hz if SPEEX codec is set
//mic.rate = 16;

mic.framesPerPacket = 1;

// Attach the mic to the NetStream
ns.attachAudio(mic);

ns.publish("SpeexAudioData", "record");

Then on the server, I keep receiving audio packets with size of either 43 bytes or 11 bytes (no other sizes found yet).

My questions are:

  1. Why do I get size of either 43 bytes or 11 bytes (from SPEEX encoding?)?
  2. Is the 43 bytes = 1 head byte + 42 data bytes?
  3. What is the size of 11 bytes?
  4. How should I process or convert the SPEEX to raw data, so that my server side app can use this audio data? My current implementation:
    • I pick up all 43-byte packets (drop all 11-byte packets);
    • Skip the first 1 byte;
    • Decode the left 42 bytes using Speex library.
  5. How should I convert the raw data back to SPEEX audio data?

Thanks.


Solution

  • I think I figured it out myself.

    See:

    http://forums.adobe.com/message/3671858#3671858