注意,RTCP的包比较小,通常会将多个RTCP包,通过1个UDP包进行发送,那么就需要对多个RTCP包进行拆解,拆解的方法是通过length,获取不同包的首地址。
多个包的组成为:

C/C++解析的方法为:
bool RTPProcessor::checkRtcp(PacketBuffer* packet)
{
 bool ret =false;
 const int rtcpCount=5;
 int i=0;
 RTCP_Header* pHeader[rtcpCount];
 int length[rtcpCount]={0};
 int ssrc[rtcpCount]={0};
 int offset=0;
 for (i=0;i<rtcpCount;i++)
 {
  if (i > 0)
  {
   offset+=4*(length[i-1]+1);
  }
  if (offset >= packet->dataSize)
  {
   break;
  }
  pHeader[i] =  (RTCP_Header*)(packet->data+offset);
  length[i] = ntohs(pHeader[i]->length);
  ssrc[i] = ntohl(pHeader[i]->ssrc);
}
 return ret;
}
其中offset为每个包的偏移地址,rtcpCount=5为每个UDP包,预计不超过5个RTCP包。

