您的位置:首页 > 理论基础 > 计算机网络

TCP/IP——RTCP视频传输协议开发过程中的问题以及解决方案

2019-05-05 08:37 232 查看

本文为本人开发RTCP协议demo时出现的问题

关于RTCP协议详情以及github源码请自行查找,本人测试demo为Ubantu与Windows之间的RTCP通道建立,以及控制端口的使用,使用eclipse开发。

目录

使用eclipse的时候helloworld编译不报错但是运行不了

std cout找不到

launch failed, binary not found.

Linux下Eclipse编译时,报recompile with -fPIC错误,解决方法

一直在makefile的输出echo出错

发现RTPSession里面貌似有自动调用RTCPschedule然后每隔五秒发送一次SR报文。并且找到了马上发送APP和UNKOWN报文的接口,但是貌似没有SR和RR的发送接口

附录:本人翻译的源码文档结构(以及一些问题)

使用eclipse的时候helloworld编译不报错但是运行不了

运行报错Exec_tty error:Cannot run program
解决方案:
先选中GNU ELF Parser然后再配置Run Configure,选中需要编译的项目,有的时候Elipse不会自动选择

std cout找不到

解决方法:MinGW从4.6.2及以后的版本中出现了这类问题。它的自动检测功能被去掉了,不能再自动地找到标准目录的东西了。为了解决这个问题,让编译器在build的时候用英文结果输出。具体的操作步骤是: "Window -> Preferences -> C/C++ -> Build -> Environment", 增加两个新的环境变量: "LANG" and "LC_ALL" 并把它们的值都设成是: "en_US". 如果还有错误提示,保存下工程,错误的提示就会消失了。这是我看别人提供的一个解决方案,亲试可以行。

launch failed, binary not found.

解决办法,工具栏run->run configuration;双击c/c++ application出现HelloWorldCPP debug,选中;Main标签下,c/c++ application:search project->选中HelloWorldCPP->OK;common标签下,勾选Debug和Run->apply->run;后续可以直接点击工具栏三角形进行运行了。

 

Linux下Eclipse编译时,报recompile with -fPIC错误,解决方法

libjrtp.a(rtcpapppacket.cpp.o): relocation R_X86_64_32 against symbol `_ZTVN7jrtplib13RTCPAPPPacketE' can not be used when making a PIE object; recompile with -fPIC
https://blog.csdn.net/shenchen8274/article/details/7822822

解决方法是:右键Eclipse工程,propertise->c/c++ build->settings->GCC C Compiler->Command:
gcc 后面加上-fPIC,重新编译,解决。 记得是紧跟的!!!

一直在makefile的输出echo出错

解决方案:
https://stackoverflow.com/questions/3485941/eclipse-cdt-error-make-src-test2-o-error-127?noredirect=1&lq=1
    Terminal: executed which make --> /usr/bin/make
    Terminal: executed which echo --> /bin/echo
    Eclipse: Under Project Properties > C/C++ Build > Environment, I made sure the contents of the PATH variable were /usr/bin:/bin, this is, the full path for make and echo, respectively.
可是还是不行
后来学长直接把库复制到usr/local/lib里面然后做了软连接

 

发现RTPSession里面貌似有自动调用RTCPschedule然后每隔五秒发送一次SR报文。并且找到了马上发送APP和UNKOWN报文的接口,但是貌似没有SR和RR的发送接口

网上说想要分析RTCP信息可以重载RTPSession里面的OnPollThreadStep()方法用于处理rtcp信息
http://www.myexception.cn/multimedia/255809.html

是用于开启自动处理rtcp包的线程用的,
客户端服务器都开启就可以了

然后服务器就发送数据,客户端只负责接收就可以了

如果想分析rtcp信息服务器程序还要做一件事情,就是重载RtpSession的OnPollThreadStep()方法,用于处理rtcp信息,在这里并不能获取rtcp包(我没找到获取的方法),但可以得到收到的rr包的信息,
if (GotoFirstSource())
{
    do
    {
        RTPSourceData *srcdat;
        srcdat = GetCurrentSourceInfo();
        //srcdat 可以获取到很多的信息,用来分析传输状况,可以查看手册
        if(srcdat->RR_HasInfo()) //如果有收到rr包
        {
            srcdat->RR_GetPacketsLost()//得到最近会话丢失的包数
        }
    } while (GotoNextSource());
}
------解决方案--------------------
重载 OnRTCPCompoundPacket函数 就行了啊,

RTCPPacket *rtcppack;
pack->GotoFirstPacket();
while ((rtcppack = pack->GetNextPacket()) != 0)
{
    if (rtcppack->IsKnownFormat())
    {
        switch (rtcppack->GetPacketType())
        {
            case RTCPPacket::SR:
                {
                RTCPSRPacket *p = (RTCPSRPacket *)rtcppack;
                uint32_t senderssrc = p->GetSenderSSRC();
                std::cout << " SR Info:" << std::endl;
                std::cout << " NTP timestamp: " << p->GetNTPTimestamp().GetMSW() << ":" << p->GetNTPTimestamp().GetLSW() << std::endl;
                std::cout << " RTP timestamp: " << p->GetRTPTimestamp() << std::endl;
                std::cout << " Packet count: " << p->GetSenderPacketCount() << std::endl;
                std::cout << " Octet count: " << p->GetSenderOctetCount() << std::endl;
                // std::cout << " Receive time: " << p->GetReceiveTime().GetSeconds() << std::endl;
                }
        break;
        }
    }
}

 

以下介绍对理解库很有帮助:

  1. https://blog.csdn.net/czh52911/article/details/7673209
  2. https://www.cnblogs.com/welen/articles/5032894.html

对于流媒体数据的接收端,首先需要调用 RTPSession 类的 Poll() 方法来接收发送过来的 RTP 或者RTCP 数据报。
由于同一个 RTP 会话中允许有多个参与者(源),你既可以通过调用 RTPSession 类的

GotoFirstSource() 和 GotoNextSource() 方法来遍历所有的源,也可以通过调用 RTPSession 类的

GotoFirstSourceWithData() 和 GotoNextSourceWithData() 方法来遍历那些携带有数据的源。在从 RTP 会

话中检测出有效的数据源之后,接下去就可以调用 RTPSession 类的 GetNextPacket() 方法从中抽取 RTP 数

据报,当接收到的 RTP 数据报处理完之后,一定要记得及时释放。

 

附录:本人翻译的源码文档结构(以及一些问题)

JRTPLIB 3.11.1
APP特殊应用包
 RTCPAPPPacket    Describes an RTCP APP packet
BYE断开RTCP包
 RTCPBYEPacket    Describes an RTCP BYE packet
所有RTCP包至少必须以两个包组合形式发送,这个代码和复合包有关
 RTCPCompoundPacket    Represents an RTCP compound packet
这个代码和复合包的建立有关
 RTCPCompoundPacketBuilder    This class can be used to construct an RTCP compound packet
RTCP的基本包
 RTCPPacket    Base class for specific types of RTCP packets
创建了一个类 用来建立复合的RTCP包,是RTCPCompoundPacketBuilder的高级封装?
 RTCPPacketBuilder    This class can be used to build RTCP compound packets, on a higher level than the RTCPCompoundPacketBuilder
接收端报告
 RTCPRRPacket    Describes an RTCP receiver report packet
这个代码决定了什么时候RTCP复合包应该被发送
 RTCPScheduler    This class determines when RTCP compound packets should be sent
这个代码描述了RTCP调度类的参数
 RTCPSchedulerParams    Describes parameters used by the RTCPScheduler class
RTCPSDES是用来描述源描述包的信息的容器
 RTCPSDESInfo    The class RTCPSDESInfo is a container for RTCP SDES information
源描述包
 RTCPSDESPacket    Describes an RTCP source description packet
发送端报告包
 RTCPSRPacket    Describes an RTCP sender report packet
未知报告包
 RTCPUnknownPacket    Describes an RTCP packet of unknown type
添加RTCP或者RTP包到库中的接口?
 RTPExternalPacketInjecter    Interface to inject incoming RTP and RTCP packets into 20000 the library
一种传输组件,它将使用用户指定的函数来传输数据,并且将公开函数以将接收到的RTP或RTCP数据注入到该组件中??
 RTPExternalTransmitter    A transmission component which will use user specified functions to transmit the data and which will expose functions to inject received RTP or RTCP data into this component
随机数生成器
 RTPRandomURandom    A random number generator which uses bytes delivered by the /dev/urandom device
原始数据保存容器
 RTPRawPacket    This class is used by the transmission component to store the incoming RTP and RTCP data in


RTCPcompoundpacketbuilder继承自RTCPCOMPOUNDPACKET 可能会有创建复合包的接口函数
所以rtcpcompoundpacketbuilder rtcpcompoundpacket这两个代码是复合包的创建代码比较重要的 貌似历程里面没有使用到(待查证)
更重要的是RTCPPacketBuilder和PTCPScheduler 代码
rtpexternaltransmitter.h 这个文件是定义额外传送的rtp?也就是说RTP是可以额外传送某些数据的?与RTCP无关吗

 

 

 

 

 

 

 

 

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: