最近做一个语音转发的服务器,
收到客户端的语音包就发给网关,
但是根据SNIFFER抓包看到发给网关的数据包长度一直为1,感觉不对劲
下面的异常日志不知道什么意思,请大家帮忙看下,谢谢8d:23h:30m:58s (lgr_coders_list)(81331     ) ?? [WARNING] ACCodersList::IsMatch found match with different intervals g711Ulaw64k10 (10 != 20)Unknown RTP payload type =8 Cnt=1Invalid Payload len : -11

解决方案 »

  1.   


    RTP/RTCP协议主要起什么作用呢?
    是用来规范语音的PT类型,语音包大小,语音包发送频率等参数么?
      

  2.   

    JRTPLIB库是一个RTP协议的开源库,使用这套库文件,我们可以创建端到端的RTP连接,实现数据的实时传输。
    RTP是实时传输协议的简称。
    压缩包可以从这里获得:http://www.bairuitech.com/upimg/soft/jrtplib-3.7.1.rar
    下载jrtplib-3.7.1.rar后,首先将其解压到一个临时文件夹中,然后开始后续工作。
    首先需要强调的是,jrtplib是一个库而不是应用程序,编译后我们获得的是.lib文件。这个文件是用来实现RTP协议的,意义和我们在写WIN32程序时用到的kernel.lib一样。
    解压后的文件夹中包含两个目录,jrtplib-3.7.1和jthread-1.2.1,打开这两个目录后我们可以看到下面又有两个同名的目录,为了后面能顺利编译,我们把同名目录下的文件全部考到上一级目录中,就是说把c:\jrtplib-3.7.1\jrtplib-3.7.1\*.* 复制到c:\jrtplib-3.7.1\。同理,把c:\jthread-1.2.1\jthread-1.2.1\*.* 复制到c:\jthread-1.2.1\
    完成上述步骤后我们就可以开始编译库文件了。
    Windows平台下建议使用Visual C++6.0,我第一次用visual studio 2008 编译的时候产生的lib文件大的惊人,而且编译中总感觉出了问题。
    首先编译多线程库jthread,在vc6中直接打开工作区文件jthread.dsw,改变工程设置,一个个选中source file下的文件,确保code generation下Use run-time library 为debug mulitithreaded DLL或debug mulitithreaded。然后选build就可以了,和上面一样的方法完成jrtpthread的编译。这个底下的文件比jthread多一些。
    默认产生的文件是jthread.lib和jrtplib.Lib,这两个文件分别位于两个文件夹下的debug文件夹下,将它们复制到VC6的lib文件夹下。
    完成上述工作后我们就可以开始尝试编译jrtplib附带的examples。
    创建一个新的Win32 Console 应用程序项目,添加example文件到source files文件夹中,然后添加jrtplib工程下的所有.h头文件,这里我们可以用VC6提供的一个功能偷懒:)将jrtplib项目添加到本工作区,然后将Header Files下的所有文件复制到我们创建的工程的Header Files文件夹里面。
    (迎奥运,练英语,翻译一下上面这段,请达人看看翻的对不对,先谢过)
    (Create a new Win32 Console Application, then add the example file into the source files dictionary, add all the .h file into workspace from project jrtplib. Here we can insert the jrtplib project into workspace, copy all .h file from jrtplib/Header Files to our project/Header Files.)
    修改example.cpp文件,在文件开始添加
    #pragma comment(lib, "jrtplib.lib")
    #pragma comment(lib, "jthread.lib")
    #pragma comment(lib, "WS2_32.lib")
    检查code generationdebug mulitithreaded DLL或debug mulitithreaded,方法同上文中检查库文件的方法。
    最后就可以编译、连接、生成可执行文件了。
    Example1运行方法:
    Enter local portbase : 8888
    Enter the destination IP address:127.0.0.1
    Enter the destination port:8888
    Number of packets you wish to be send :60
    回车后可以看到程序运行:
    Sending packet 1/60
    Sending packet 2/60
    Got packet !
    运行成功。
    jrtplib的简单应用:
    1.  编译JTHREAD和JRTPLIB,把JTHREAD和JRTPLIB生成的.lib文件路径添加到tools->option->directories->Library files.
    2.  Project->Settings->Link中Object/library modules:添加jthread.lib jrtplib.lib
    3.  Link中添加ws2_32.lib
    4.  C/C++中添加定义DEBUG
    5.  在RTP接收类中头文件添加以下:
    #include <rtpsession.h>
    #include <rtppacket.h>
    #include <rtpudpv4transmitter.h>
    #include <rtpipv4address.h>
    #include <rtpsessionparams.h>
    #include <rtperrors.h>
    #include <rtpsourcedata.h>
    #include <rtpmemorymanager.h>
    ......
    类中添加
    RTPSession session;
    初始化:
     WSADATA dat;
     WSAStartup(MAKEWORD(2,2),&dat);
     RTPUDPv4TransmissionParams transparams;
     RTPSessionParams sessparams;
     m_nPort = port;
     streamMode = mode;
     sessparams.SetOwnTimestampUnit(TIMESTAMPUNIT);
     sessparams.SetAcceptOwnPackets(true);
     transparams.SetPortbase(m_nPort);
     int status=session.Create(sessparams,&transparams);
     std::string str=RTPGetErrorString(status);
     ASSERT(status>=0);
    取RTP包:
     RTPPacket *pack;
     int status;
     while()     //设置循环条件
     {
      session.BeginDataAccess();
      if(session.GotoFirstSourceWithData())
      {
       do 
       {
        while((pack=session.GetNextPacket())!=NULL)
        {
         //这里取得RTP payload: pack->GetPayloadData()
         //payload长度:  pack->GetPayloadLength()
         session.DeletePacket(pack);
        }
       } while(session.GotoNextSourceWithData());
      }
      session.EndDataAccess();
    #ifndef RTP_SUPPORT_THREAD
      status = session.Poll();
      ASSERT(status);
    #endif // RTP_SUPPORT_THREAD
      RTPTime::Wait(RTPTime(1,0));
     }
     session.BYEDestroy(RTPTime(10,0),0,0);