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


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

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


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

示例1: addREMB

  int RtcpForwarder::addREMB(char* buf, int len, uint32_t bitrate){
    buf+=len;
    RtcpHeader theREMB;
    theREMB.setPacketType(RTCP_PS_Feedback_PT);
    theREMB.setBlockCount(RTCP_AFB);
    memcpy(&theREMB.report.rembPacket.uniqueid, "REMB", 4);

    theREMB.setSSRC(rtcpSink_->getVideoSinkSSRC());
    theREMB.setSourceSSRC(rtcpSource_->getVideoSourceSSRC());
    theREMB.setLength(5);
    theREMB.setREMBBitRate(bitrate);
    theREMB.setREMBNumSSRC(1);
    theREMB.setREMBFeedSSRC(rtcpSource_->getVideoSourceSSRC());
    int rembLength = (theREMB.getLength()+1)*4;

    memcpy(buf, (uint8_t*)&theREMB, rembLength);
    return (len+rembLength); 
  }
开发者ID:MadhuPeopleLink,项目名称:licode,代码行数:18,代码来源:RtcpForwarder.cpp

示例2: analyzeFeedback

  int RtcpForwarder::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);

      struct timeval now;
      gettimeofday(&now, NULL);
      char* movingBuf = buf;
      int rtcpLength = 0;
      int totalLength = 0;
      int currentBlock = 0;

      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:
            if (chead->getSourceSSRC() == rtcpSource_->getVideoSourceSSRC()){
              ELOG_DEBUG("Analyzing Video RR: PacketLost %u, Ratio %u, currentBlock %d, blocks %d, sourceSSRC %u, ssrc %u changed to %u", 
                  chead->getLostPackets(), 
                  chead->getFractionLost(), 
                  currentBlock, 
                  chead->getBlockCount(), 
                  chead->getSourceSSRC(), 
                  chead->getSSRC(),
                  rtcpSink_->getVideoSinkSSRC());
              chead->setSSRC(rtcpSink_->getVideoSinkSSRC());
            }else{
              ELOG_DEBUG("Analyzing Audio RR: PacketLost %u, Ratio %u, currentBlock %d, blocks %d, sourceSSRC %u, ssrc %u changed to %u", 
                  chead->getLostPackets(), 
                  chead->getFractionLost(), 
                  currentBlock, 
                  chead->getBlockCount(), 
                  chead->getSourceSSRC(), 
                  chead->getSSRC(),
                  rtcpSink_->getAudioSinkSSRC());
              chead->setSSRC(rtcpSink_->getAudioSinkSSRC());
            }
            break;
          case RTCP_RTP_Feedback_PT:
            ELOG_DEBUG("RTP FB: Usually NACKs: %u, currentBlock %d", chead->getBlockCount(), currentBlock);
            ELOG_DEBUG("NACK PID %u BLP %u", chead->getNackPid(), chead->getNackBlp());
            // We analyze NACK to avoid sending repeated NACKs
            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, currentBlock %d", currentBlock);
                // 1: PLI, 4: FIR
                break;
              case RTCP_SLI_FMT:
                ELOG_WARN("SLI Message");
                break;
              case RTCP_FIR_FMT:
                ELOG_WARN("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();
                    uint64_t cappedBitrate = 0;
                    cappedBitrate = bitrate < maxVideoBw_? bitrate: maxVideoBw_;
                    if (bitrate < maxVideoBw_){
                      cappedBitrate = bitrate;
                    }else{
                      cappedBitrate = maxVideoBw_;
                    }
                    ELOG_DEBUG("Received REMB %lu, partnum %u, cappedBitrate %lu", bitrate, currentBlock, cappedBitrate);
                    chead->setREMBBitRate(cappedBitrate);
                  }
                  else{
                    ELOG_WARN("Unsupported AFB Packet not REMB")
                  }
                  break;
                }
              default:
                ELOG_WARN("Unsupported RTCP_PS FB TYPE %u",chead->getBlockCount());
                break;
            }
            break;
          default:
            ELOG_WARN("Unknown RTCP Packet, %d", chead->packettype);
            break;
        }
        currentBlock++;
      } while (totalLength < len);
      return len;
    }
开发者ID:jinghao666,项目名称:licode,代码行数:100,代码来源:RtcpForwarder.cpp


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