当前位置: 首页>>代码示例>>C++>>正文


C++ RtcpHeader::getJitter方法代码示例

本文整理汇总了C++中RtcpHeader::getJitter方法的典型用法代码示例。如果您正苦于以下问题:C++ RtcpHeader::getJitter方法的具体用法?C++ RtcpHeader::getJitter怎么用?C++ RtcpHeader::getJitter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在RtcpHeader的用法示例。


在下文中一共展示了RtcpHeader::getJitter方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: analyzeFeedback

  void RtcpProcessor::analyzeFeedback(char *buf, int len) {

    RtcpHeader *chead = reinterpret_cast<RtcpHeader*>(buf);
    if (chead->isFeedback()) {      
      uint32_t sourceSsrc = chead->getSourceSSRC();
      // We try to add it just in case it is not there yet (otherwise its noop)
      this->addSourceSsrc(sourceSsrc);

      boost::mutex::scoped_lock mlock(mapLock_);
      boost::shared_ptr<RtcpData> theData = rtcpData_[sourceSsrc];
      boost::mutex::scoped_lock lock(theData->dataLock);
      struct timeval now;
      gettimeofday(&now, NULL);
      char* movingBuf = buf;
      int rtcpLength = 0;
      int totalLength = 0;
      int partNum = 0;
      uint32_t calculatedlsr, delay, calculateLastSr;

      do {
        movingBuf+=rtcpLength;
        chead = reinterpret_cast<RtcpHeader*>(movingBuf);
        rtcpLength = (ntohs(chead->length)+1) * 4;
        totalLength += rtcpLength;
        switch(chead->packettype){
          case RTCP_SDES_PT:
            ELOG_DEBUG("SDES");
            break;
          case RTCP_BYE:
            ELOG_DEBUG("BYE");
            break;
          case RTCP_Receiver_PT:
            theData->rrsReceivedInPeriod++;
            if (chead->getSourceSSRC() == rtcpSource_->getVideoSourceSSRC()){
              ELOG_DEBUG("Analyzing Video RR: PacketLost %u, Ratio %u, partNum %d, blocks %d, sourceSSRC %u", chead->getLostPackets(), chead->getFractionLost(), partNum, chead->getBlockCount(), chead->getSourceSSRC());
            }else{
              ELOG_DEBUG("Analyzing Audio RR: PacketLost %u, Ratio %u, partNum %d, blocks %d, sourceSSRC %u", chead->getLostPackets(), chead->getFractionLost(), partNum, chead->getBlockCount(), chead->getSourceSSRC());
            }
            theData->ratioLost = theData->ratioLost > chead->getFractionLost()? theData->ratioLost: chead->getFractionLost();  
            theData->totalPacketsLost = theData->totalPacketsLost > chead->getLostPackets()? theData->totalPacketsLost : chead->getLostPackets();
            theData->highestSeqNumReceived = theData->highestSeqNumReceived > chead->getHighestSeqnum()? theData->highestSeqNumReceived : chead->getHighestSeqnum();
            theData->jitter = theData->jitter > chead->getJitter()? theData->jitter: chead->getJitter();
            calculateLastSr = chead->getLastSr();
            calculatedlsr = (chead->getDelaySinceLastSr()*1000)/65536;
            for (std::list<boost::shared_ptr<SrData>>::iterator it=theData->senderReports.begin(); it != theData->senderReports.end(); ++it){
              if ((*it)->srNtp == calculateLastSr){  
                uint64_t nowms = (now.tv_sec * 1000) + (now.tv_usec / 1000);
                uint64_t sentts = ((*it)->timestamp.tv_sec * 1000) + ((*it)->timestamp.tv_usec / 1000);
                delay = nowms - sentts - calculatedlsr;

              }
            }

            if (theData->lastSr==0||theData->lastDelay < delay){
              ELOG_DEBUG("Recording DLSR %u, lastSR %u last delay %u, calculated delay %u for SSRC %u", chead->getDelaySinceLastSr(), chead->getLastSr(), theData->lastDelay, delay, sourceSsrc);
              theData->lastSr = chead->getLastSr();
              theData->delaySinceLastSr = chead->getDelaySinceLastSr();
              theData->lastSrUpdated = now;
              theData->lastDelay = delay;
            }else{
              //              ELOG_DEBUG("Not recording delay %u, lastDelay %u", delay, theData->lastDelay);
            }
            break;
          case RTCP_RTP_Feedback_PT:
            ELOG_DEBUG("RTP FB: Usually NACKs: %u, partNum %d", chead->getBlockCount(), partNum);
            ELOG_DEBUG("PID %u BLP %u", chead->getNackPid(), chead->getNackBlp());
            theData->shouldSendNACK = true;
            theData->nackSeqnum = chead->getNackPid();
            theData->nackBlp = chead->getNackBlp();
            theData->requestRr = true;
            break;
          case RTCP_PS_Feedback_PT:
            //            ELOG_DEBUG("RTCP PS FB TYPE: %u", chead->getBlockCount() );
            switch(chead->getBlockCount()){
              case RTCP_PLI_FMT:
                ELOG_DEBUG("PLI Message, partNum %d", partNum);
                // 1: PLI, 4: FIR
                theData->shouldSendPli = true;
                break;
              case RTCP_SLI_FMT:
                ELOG_DEBUG("SLI Message");
                break;
              case RTCP_FIR_FMT:
                ELOG_DEBUG("FIR Message");
                break;
              case RTCP_AFB:
                {
                  char *uniqueId = (char*)&chead->report.rembPacket.uniqueid;
                  if (!strncmp(uniqueId,"REMB", 4)){
                    uint64_t bitrate = chead->getBrMantis() << chead->getBrExp();
                    ELOG_DEBUG("Received REMB %lu", bitrate);
                    if ((bitrate<theData->reportedBandwidth) || theData->reportedBandwidth==0){
                      ELOG_DEBUG("Should send Packet REMB, before BR %lu, will send with Br %lu", theData->reportedBandwidth, bitrate);
                      theData->reportedBandwidth = bitrate;  
                      theData->shouldSendREMB = true;
                    }
                  }
                  else{
                    ELOG_DEBUG("Unsupported AFB Packet not REMB")
                  }
//.........这里部分代码省略.........
开发者ID:zhbenhuang,项目名称:licode,代码行数:101,代码来源:RtcpProcessor.cpp

示例2: analyzeFeedback

int RtcpAggregator::analyzeFeedback(char *buf, int len) {
  RtcpHeader *chead = reinterpret_cast<RtcpHeader*>(buf);
  if (chead->isFeedback()) {
    if (chead->getBlockCount() == 0 && (chead->getLength()+1) * 4  == len) {
      ELOG_DEBUG("Ignoring empty RR");
      return 0;
    }
    uint32_t sourceSsrc = chead->getSourceSSRC();
    // We try to add it just in case it is not there yet (otherwise its noop)
    this->addSourceSsrc(sourceSsrc);

    boost::mutex::scoped_lock mlock(mapLock_);
    boost::shared_ptr<RtcpData> theData = rtcpData_[sourceSsrc];
    boost::mutex::scoped_lock lock(theData->dataLock);
    uint64_t nowms = ClockUtils::timePointToMs(clock::now());
    char* movingBuf = buf;
    int rtcpLength = 0;
    int totalLength = 0;
    int partNum = 0;
    uint16_t currentNackPos = 0;
    uint16_t blp = 0;
    uint32_t lostPacketSeq = 0;
    uint32_t delay = 0;
    uint32_t calculatedlsr, calculateLastSr, extendedSeqNo;

    do {
      movingBuf += rtcpLength;
      chead = reinterpret_cast<RtcpHeader*>(movingBuf);
      rtcpLength = (ntohs(chead->length) + 1) * 4;
      totalLength += rtcpLength;
      switch (chead->packettype) {
        case RTCP_SDES_PT:
          ELOG_DEBUG("SDES");
          break;
        case RTCP_BYE:
          ELOG_DEBUG("BYE");
          break;
        case RTCP_Receiver_PT:
          theData->rrsReceivedInPeriod++;
          if (rtcpSource_->isVideoSourceSSRC(chead->getSourceSSRC())) {
            ELOG_DEBUG("Analyzing Video RR: PacketLost %u, Ratio %u, partNum %d, blocks %d, sourceSSRC %u, ssrc %u",
                        chead->getLostPackets(), chead->getFractionLost(), partNum, chead->getBlockCount(),
                        chead->getSourceSSRC(), chead->getSSRC());
          } else {
            ELOG_DEBUG("Analyzing Audio RR: PacketLost %u, Ratio %u, partNum %d, blocks %d, sourceSSRC %u, ssrc %u",
                        chead->getLostPackets(), chead->getFractionLost(), partNum, chead->getBlockCount(),
                        chead->getSourceSSRC(), chead->getSSRC());
          }
          theData->ratioLost = theData->ratioLost > chead->getFractionLost() ?
                                            theData->ratioLost : chead->getFractionLost();
          theData->totalPacketsLost = theData->totalPacketsLost > chead->getLostPackets() ?
                                            theData->totalPacketsLost : chead->getLostPackets();
          extendedSeqNo = chead->getSeqnumCycles();
          extendedSeqNo = (extendedSeqNo << 16) + chead->getHighestSeqnum();
          if (extendedSeqNo > theData->extendedSeqNo) {
            theData->extendedSeqNo = extendedSeqNo;
            theData->highestSeqNumReceived = chead->getHighestSeqnum();
            theData->seqNumCycles = chead->getSeqnumCycles();
          }
          theData->jitter = theData->jitter > chead->getJitter()? theData->jitter: chead->getJitter();
          calculateLastSr = chead->getLastSr();
          calculatedlsr = (chead->getDelaySinceLastSr() * 1000) / 65536;
          for (std::list<boost::shared_ptr<SrDelayData>>::iterator it = theData->senderReports.begin();
                        it != theData->senderReports.end(); ++it) {
            if ((*it)->sr_ntp == calculateLastSr) {
              uint64_t sentts = (*it)->sr_send_time;
              delay = nowms - sentts - calculatedlsr;
            }
          }

          if (theData->lastSr == 0 || theData->lastDelay < delay) {
            ELOG_DEBUG("Recording DLSR %u, lastSR %u last delay %u, calculated delay %u for SSRC %u",
                        chead->getDelaySinceLastSr(), chead->getLastSr(), theData->lastDelay, delay, sourceSsrc);
            theData->lastSr = chead->getLastSr();
            theData->delaySinceLastSr = chead->getDelaySinceLastSr();
            theData->last_sr_updated = nowms;
            theData->lastDelay = delay;
          } else {
            // ELOG_DEBUG("Not recording delay %u, lastDelay %u", delay, theData->lastDelay);
          }
          break;
        case RTCP_RTP_Feedback_PT:
          {
            ELOG_DEBUG("RTP FB: Usually NACKs: %u, partNum %d", chead->getBlockCount(), partNum);
            ELOG_DEBUG("NACK PID %u BLP %u", chead->getNackPid(), chead->getNackBlp());
            // We analyze NACK to avoid sending repeated NACKs
            blp = chead->getNackBlp();
            theData->shouldSendNACK = false;
            std::pair<std::set<uint32_t>::iterator, bool> ret;
            ret = theData->nackedPackets_.insert(chead->getNackPid());
            if (ret.second) {
              ELOG_DEBUG("We received PID NACK for unacked packet %u", chead->getNackPid());
              theData->shouldSendNACK = true;
            } else {
              if (theData->nackedPackets_.size() >= MAP_NACK_SIZE) {
                while (theData->nackedPackets_.size() >= MAP_NACK_SIZE) {
                  theData->nackedPackets_.erase(theData->nackedPackets_.begin());
                }
              }
              ELOG_DEBUG("We received PID NACK for ALREADY acked packet %u", chead->getNackPid());
//.........这里部分代码省略.........
开发者ID:ging,项目名称:licode,代码行数:101,代码来源:RtcpAggregator.cpp


注:本文中的RtcpHeader::getJitter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。