我捕获了RTP数据包,并使用以下代码对其进行了解码:
public byte[] Decode(byte[] data)
{
MemoryStream src=new MemoryStream(data);
System.IO.BinaryReader brsrc=new BinaryReader(src);
MemoryStream dst=new MemoryStream();
System.IO.BinaryWriter bwdst=new BinaryWriter(dst);
int step=(int)(data.Length/10);
for(int i=0;i<step;i++)
{
byte[] d=new byte[160];
va_g729a_decoder(brsrc.ReadBytes(10),d,0);
bwdst.Write(d);
}
byte[] ret=dst.GetBuffer();
brsrc.Close();
bwdst.Close();
src.Close();
dst.Close();
return ret;
}
使用g729 dll。
现在我有一个充满解码RTP数据包的字节数组,如何播放或将其转换为WAV文件或其他类似文件?
na,
奥菲克
最佳答案
您可以使用 ffmpeg 将rtp数据转换为mp3格式的语音。这是reference。
关于c# - 播放解码的RTP数据包的音频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12819016/