问题描述
将PCM字节流转换为RTP之后,SIP客户端的音量很小,但在其他客户端(例如WebRTC,基于多播的设备以及媒体文件)中可以正常工作。有什么办法可以增加16位PCM字节流的容量?请检查我下面的代码示例:
var mulawData = Utils.LinearToMulaw(pcm,16,1); //pcm=320 byte array
public static Byte[] LinearToMulaw(Byte[] bytes,int bitsPerSample,int channels)
{
int blockAlign = channels * bitsPerSample / 8;
Byte[] result = new Byte[bytes.Length / blockAlign];
int resultIndex = 0;
for (int i = 0; i < result.Length; i++)
{
switch (bitsPerSample)
{
case 8:
switch (channels)
{
//8 Bit 1 Channel
case 1:
result[i] = linear2ulaw(bytes[resultIndex]);
resultIndex += 1;
break;
//8 Bit 2 Channel
case 2:
result[i] = linear2ulaw(bytes[resultIndex]);
resultIndex += 2;
break;
}
break;
case 16:
switch (channels)
{
//16 Bit 1 Channel
case 1:
result[i] = linear2ulaw(BitConverter.ToInt16(bytes,resultIndex));
resultIndex += 2;
break;
//16 Bit 2 Channels
case 2:
result[i] = linear2ulaw(BitConverter.ToInt16(bytes,resultIndex));
resultIndex += 4;
break;
}
break;
}
}
return result;
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)