首页 > 解决方案 > 将 OPUS 流转换为 PCM 或 RTP

问题描述

目前,我正在开发一个VOIP系统。在将RTP流转换为PCM后,我可以将SIP流发送到mumble服务器,并且mumble客户端的语音质量很好。但是,到 SIP 的 Mumble 流 (OPUS) 不起作用,总是有噪音。我正在将 Mumble 频道的流 (OPUS) 转换为 RTP 并将其发送到 SIP 客户端。是否有任何库或源代码来找出 RTP 问题,而不是通过 SIP 接收?

注意:将接收流转换为.wav文件后,语音质量可以,但在SIP客户端中不起作用。

OPUS 解码代码:

public byte[] SendDecodeMumbleDataToMulticast(byte[] encodedData, int uid, int cid)
{
    var _decoder = new OpusDecoder(8000, 1) { EnableForwardErrorCorrection = true };
    if (encodedData == null)
    {
        //_decoder.Decode(null, 0, 0, new byte[_sampleRate / _frameSize], 0);
        return null;
    }

    int samples = OpusDecoder.GetSamples(encodedData, 0, encodedData.Length, 8000);
    if (samples < 1)
    {
        return null;
    }

    byte[] dst = new byte[samples * sizeof(ushort)];
    int length = _decoder.Decode(encodedData, 0, encodedData.Length, dst, 0);
    if (dst.Length != length)
    {
        Array.Resize(ref dst, length);
    }   


    RTPPacket rtp = ToRTPPacket(dst, 16, 1);
    OnRTPReceived?.Invoke(rtp);

    return dst;
}

标签: voiprtppcmopus

解决方案


推荐阅读