2011-05-04 73 views
1

我正在實現一個非常簡單的僅音頻RTMP服務器。在服務器端處理Flex/Flash SPEEX音頻數據

我有我的客戶端代碼:

// 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"); 

然後在服務器上,我不斷收到與任43個字節或11個字節大小的音頻數據包(還沒有發現其他大小)。

我的問題是:

  1. 爲什麼我得到無論是43個字節或11個字節的大小(從SPEEX編碼?)?
  2. 是43字節= 1個字節+ 42個數據字節嗎?
  3. 11個字節的大小是多少?
  4. 我應該如何處理或將SPEEX轉換爲原始數據,以便我的服務器端應用程序可以使用此音頻數據?我目前的實現:
    • 我拿起所有43字節的數據包(丟棄所有11字節數據包);
    • 跳過第1個字節;
    • 使用Speex庫解碼左邊的42個字節。
  5. 我應該如何將原始數據轉換回SPEEX音頻數據?

謝謝。

回答