我正在实现一个非常简单的纯音频 RTMP 服务器。
我有这样的客户代码:
// 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 字节的音频数据包(尚未找到其他大小)。
我的问题是:
- 为什么我得到 43 字节或 11 字节的大小(来自 SPEEX 编码?)?
- 是 43 个字节 = 1 个头字节 + 42 个数据字节吗?
- 11字节的大小是多少?
- 我应该如何处理或将 SPEEX 转换为原始数据,以便我的服务器端应用程序可以使用这些音频数据?我目前的实现:
- 我拾取所有 43 字节数据包(丢弃所有 11 字节数据包);
- 跳过前 1 个字节;
- 使用 Speex 库解码剩下的 42 个字节。
- 我应该如何将原始数据转换回 SPEEX 音频数据?
谢谢。