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


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

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


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

示例1: checkRtcpFb

void RtcpAggregator::checkRtcpFb() {
  boost::mutex::scoped_lock mlock(mapLock_);
  std::map<uint32_t, boost::shared_ptr<RtcpData>>::iterator it;
  for (it = rtcpData_.begin(); it != rtcpData_.end(); it++) {
    boost::shared_ptr<RtcpData> rtcpData = it->second;
    boost::mutex::scoped_lock lock(rtcpData->dataLock);
    uint32_t sourceSsrc = it->first;
    uint32_t sinkSsrc;
    uint64_t now = ClockUtils::timePointToMs(clock::now());

    unsigned int dt = now - rtcpData->last_rr_sent;
    unsigned int edlsr = now - rtcpData->last_sr_updated;
    unsigned int dt_scheduled = now - rtcpData->last_rr_was_scheduled;

    // Generate Full RTCP Packet
    if ((rtcpData->requestRr || dt >= rtcpData->nextPacketInMs ||rtcpData->shouldSendREMB) && rtcpData->lastSr > 0) {
      rtcpData->requestRr = false;
      RtcpHeader rtcpHead;
      rtcpHead.setPacketType(RTCP_Receiver_PT);
      if (sourceSsrc == rtcpSource_->getAudioSourceSSRC()) {
        sinkSsrc = rtcpSink_->getAudioSinkSSRC();
        ELOG_DEBUG("Sending Audio RR: PacketLost %u, Ratio %u, DLSR %u"
                   ", lastSR %u, DLSR Adjusted %u dt %u, rrsSinceLast %u highestSeqNum %u",
                  rtcpData->totalPacketsLost,
                  rtcpData->ratioLost,
                  rtcpData->delaySinceLastSr,
                  rtcpData->lastSr,
                  (rtcpData->delaySinceLastSr+edlsr),
                  dt,
                  rtcpData->rrsReceivedInPeriod,
                  rtcpData->highestSeqNumReceived);
        rtcpHead.setSSRC(rtcpSink_->getAudioSinkSSRC());
        rtcpHead.setSourceSSRC(rtcpSource_->getAudioSourceSSRC());
      } else {
        sinkSsrc = rtcpSink_->getVideoSinkSSRC();
        ELOG_DEBUG("Sending Video RR: SOurcessrc %u sinkSsrc %u PacketLost %u, Ratio %u, DLSR %u, lastSR %u"
                   ", DLSR Adjusted %u dt %u, rrsSinceLast %u highestSeqNum %u jitter %u",
                   sourceSsrc,
                   rtcpSink_->getVideoSinkSSRC(),
                   rtcpData->totalPacketsLost,
                   rtcpData->ratioLost,
                   rtcpData->delaySinceLastSr,
                   rtcpData->lastSr,
                   (rtcpData->delaySinceLastSr+edlsr),
                   dt, rtcpData->rrsReceivedInPeriod,
                   rtcpData->highestSeqNumReceived,
                   rtcpData->jitter);
        rtcpHead.setSSRC(rtcpSink_->getVideoSinkSSRC());
        rtcpHead.setSourceSSRC(rtcpSource_->getVideoSourceSSRC());
      }

      // rtcpHead.setFractionLost(rtcpData->ratioLost);
      // Calculate ratioLost
      uint32_t packetsReceivedinInterval = rtcpData->extendedSeqNo - rtcpData->prevExtendedSeqNo;
      uint32_t packetsLostInInterval = rtcpData->totalPacketsLost - rtcpData->prevTotalPacketsLost;
      double ratio = static_cast<double>(packetsLostInInterval/packetsReceivedinInterval);
      rtcpHead.setFractionLost(ratio*256);
      rtcpData->prevTotalPacketsLost = rtcpData->totalPacketsLost;
      rtcpData->prevExtendedSeqNo = rtcpData->extendedSeqNo;

      rtcpHead.setHighestSeqnum(rtcpData->highestSeqNumReceived);
      rtcpHead.setSeqnumCycles(rtcpData->seqNumCycles);
      rtcpHead.setLostPackets(rtcpData->totalPacketsLost);
      rtcpHead.setJitter(rtcpData->jitter);
      rtcpHead.setLastSr(rtcpData->lastSr);
      rtcpHead.setDelaySinceLastSr(rtcpData->delaySinceLastSr + ((edlsr*65536)/1000));
      rtcpHead.setLength(7);
      rtcpHead.setBlockCount(1);
      int length = (rtcpHead.getLength()+1)*4;
      memcpy(packet_, reinterpret_cast<uint8_t*>(&rtcpHead), length);
      if (rtcpData->shouldSendNACK) {
        ELOG_DEBUG("SEND NACK, SENDING with Seqno: %u", rtcpData->nackSeqnum);
        int theLen = this->addNACK(reinterpret_cast<char*>(packet_), length, rtcpData->nackSeqnum,
                        rtcpData->nackBlp, sourceSsrc, sinkSsrc);
        rtcpData->shouldSendNACK = false;
        rtcpData->nackSeqnum = 0;
        rtcpData->nackBlp = 0;
        length = theLen;
      }
      if (rtcpData->mediaType == VIDEO_TYPE) {
        unsigned int sincelastREMB = now - rtcpData->last_remb_sent;
        if (sincelastREMB > REMB_TIMEOUT) {
          // We dont have any more RRs, we follow what the publisher is doing to avoid congestion
          rtcpData->shouldSendREMB = true;
        }

        if (rtcpData->shouldSendREMB) {
          ELOG_DEBUG("Sending REMB, since last %u ms, sending with BW: %lu",
                      sincelastREMB, rtcpData->reportedBandwidth);
          int theLen = this->addREMB(reinterpret_cast<char*>(packet_), length, rtcpData->reportedBandwidth);
          rtcpData->shouldSendREMB = false;
          rtcpData->last_remb_sent = now;
          length = theLen;
        }
      }
      if  (rtcpSource_->isVideoSourceSSRC(sourceSsrc)) {
        rtcpSink_->deliverVideoData(std::make_shared<DataPacket>(0, reinterpret_cast<char*>(packet_),
              length, VIDEO_PACKET));
      } else {
        rtcpSink_->deliverAudioData(std::make_shared<DataPacket>(0, reinterpret_cast<char*>(packet_),
//.........这里部分代码省略.........
开发者ID:ging,项目名称:licode,代码行数:101,代码来源:RtcpAggregator.cpp


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