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


C++ RtcpHeader类代码示例

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


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

示例1: if

void MediaStream::onTransportData(std::shared_ptr<DataPacket> incoming_packet, Transport *transport) {
  if ((audio_sink_ == nullptr && video_sink_ == nullptr && fb_sink_ == nullptr)) {
    return;
  }

  std::shared_ptr<DataPacket> packet = std::make_shared<DataPacket>(*incoming_packet);

  if (transport->mediaType == AUDIO_TYPE) {
    packet->type = AUDIO_PACKET;
  } else if (transport->mediaType == VIDEO_TYPE) {
    packet->type = VIDEO_PACKET;
  }
  auto stream_ptr = shared_from_this();

  worker_->task([stream_ptr, packet]{
    if (!stream_ptr->pipeline_initialized_) {
      ELOG_DEBUG("%s message: Pipeline not initialized yet.", stream_ptr->toLog());
      return;
    }

    char* buf = packet->data;
    RtpHeader *head = reinterpret_cast<RtpHeader*> (buf);
    RtcpHeader *chead = reinterpret_cast<RtcpHeader*> (buf);
    if (!chead->isRtcp()) {
      uint32_t recvSSRC = head->getSSRC();
      if (stream_ptr->isVideoSourceSSRC(recvSSRC)) {
        packet->type = VIDEO_PACKET;
      } else if (stream_ptr->isAudioSourceSSRC(recvSSRC)) {
        packet->type = AUDIO_PACKET;
      }
    }

    stream_ptr->pipeline_->read(std::move(packet));
  });
}
开发者ID:mccob,项目名称:licode,代码行数:35,代码来源:MediaStream.cpp

示例2: ELOG_DEBUG

 void WebRtcConnection::writeSsrc(char* buf, int len, unsigned int ssrc) {
   ELOG_DEBUG("LEN %d", len);
   RtpHeader *head = reinterpret_cast<RtpHeader*> (buf);
   RtcpHeader *chead = reinterpret_cast<RtcpHeader*> (buf);
   //if it is RTCP we check it it is a compound packet
   if (chead->isRtcp()) {      
     char* movingBuf = buf;
     int rtcpLength = 0;
     int totalLength = 0;
     do{
       movingBuf+=rtcpLength;
       RtcpHeader *chead= reinterpret_cast<RtcpHeader*>(movingBuf);
       rtcpLength= (ntohs(chead->length)+1)*4;      
       totalLength+= rtcpLength;
       ELOG_DEBUG("Is RTCP, prev SSRC %u, new %u, len %d ", chead->getSSRC(), ssrc, rtcpLength);
       chead->ssrc=htonl(ssrc);
       if (chead->packettype == RTCP_PS_Feedback_PT){
         FirHeader *thefir = reinterpret_cast<FirHeader*>(movingBuf);
         if (thefir->fmt == 4){ // It is a FIR Packet, we generate it
           this->sendPLI();
         }
       }
     } while(totalLength<len);
   } else {
     head->setSSRC(ssrc);
   }
 }
开发者ID:JiCiT,项目名称:licode,代码行数:27,代码来源:WebRtcConnection.cpp

示例3: handleSR

void RRGenerationHandler::handleSR(std::shared_ptr<dataPacket> packet) {
  RtcpHeader *chead = reinterpret_cast<RtcpHeader*>(packet->data);
  auto rr_packet_pair = rr_info_map_.find(chead->getSSRC());
  if (rr_packet_pair == rr_info_map_.end()) {
    ELOG_DEBUG("%s message: handleRtpPacket ssrc not found, ssrc: %u", connection_->toLog(), chead->getSSRC());
    return;
  }
  std::shared_ptr<RRPackets> selected_packet_info = rr_packet_pair->second;

  selected_packet_info->last_sr_mid_ntp = chead->get32MiddleNtp();
  selected_packet_info->last_sr_ts = packet->received_time_ms;
  uint32_t expected = selected_packet_info->extended_seq - selected_packet_info->base_seq + 1;
  selected_packet_info->lost = expected - selected_packet_info->packets_received;

  uint8_t fraction = 0;
  uint32_t expected_interval = expected - selected_packet_info->expected_prior;
  selected_packet_info->expected_prior = expected;
  uint32_t received_interval = selected_packet_info->packets_received - selected_packet_info->received_prior;

  selected_packet_info->received_prior = selected_packet_info->packets_received;
  uint32_t lost_interval = expected_interval - received_interval;
  if (expected_interval != 0 && lost_interval > 0) {
    fraction = (lost_interval << 8) / expected_interval;
  }

  selected_packet_info->frac_lost = fraction;
  if (!use_timing_) {
    sendRR(selected_packet_info);
  }
}
开发者ID:ytjjyy,项目名称:licode,代码行数:30,代码来源:RRGenerationHandler.cpp

示例4: memcpy

void SdesTransport::onNiceData(unsigned int component_id, char* data, int len, NiceConnection* nice) {
    //boost::mutex::scoped_lock lock(readMutex_);
    int length = len;
    SrtpChannel *srtp = srtp_;

    if (this->getTransportState() == TRANSPORT_READY) {
      memcpy(unprotectBuf_, data, len);

      if (component_id == 2) {
        srtp = srtcp_;
      }

      RtcpHeader *chead = reinterpret_cast<RtcpHeader*> (unprotectBuf_);
      if (chead->isRtcp()){
        if(srtp->unprotectRtcp(unprotectBuf_, &length)<0)
          return;
      } else {
        if(srtp->unprotectRtp(unprotectBuf_, &length)<0)
          return;
      }

      if (length <= 0)
          return;

      getTransportListener()->onTransportData(unprotectBuf_, length, this);
    }
}
开发者ID:Lethea,项目名称:licode,代码行数:27,代码来源:SdesTransport.cpp

示例5: read

void RRGenerationHandler::read(Context *ctx, std::shared_ptr<dataPacket> packet) {
  RtcpHeader *chead = reinterpret_cast<RtcpHeader*>(packet->data);
  if (!chead->isRtcp() && enabled_) {
    handleRtpPacket(packet);
  } else if (chead->packettype == RTCP_Sender_PT && enabled_) {
    handleSR(packet);
  }
  ctx->fireRead(packet);
}
开发者ID:ytjjyy,项目名称:licode,代码行数:9,代码来源:RRGenerationHandler.cpp

示例6: processRtcpHeaders

 void WebRtcConnection::writeSsrc(char* buf, int len, unsigned int ssrc) {
   RtpHeader *head = reinterpret_cast<RtpHeader*> (buf);
   RtcpHeader *chead = reinterpret_cast<RtcpHeader*> (buf);
   //if it is RTCP we check it it is a compound packet
   if (chead->isRtcp()) {
       processRtcpHeaders(buf,len,ssrc);
   } else {
     head->ssrc=htonl(ssrc);
   }
 }
开发者ID:Lethea,项目名称:licode,代码行数:10,代码来源:WebRtcConnection.cpp

示例7: write

void SenderBandwidthEstimationHandler::write(Context *ctx, std::shared_ptr<dataPacket> packet) {
  RtcpHeader *chead = reinterpret_cast<RtcpHeader*>(packet->data);
  if (!chead->isRtcp() && packet->type == VIDEO_PACKET) {
    period_packets_sent_++;
  } else if (chead->getPacketType() == RTCP_Sender_PT &&
      chead->getSSRC() == connection_->getVideoSinkSSRC()) {
    analyzeSr(chead);
  }
  ctx->fireWrite(packet);
}
开发者ID:ytjjyy,项目名称:licode,代码行数:10,代码来源:SenderBandwidthEstimantionHandler.cpp

示例8: handleSr

void RtcpRrGenerator::handleSr(std::shared_ptr<dataPacket> packet) {
  RtcpHeader* chead = reinterpret_cast<RtcpHeader*>(packet->data);
  if (ssrc_ != chead->getSSRC()) {
    ELOG_DEBUG("message: handleRtpPacket ssrc not found, ssrc: %u", chead->getSSRC());
    return;
  }

  rr_info_.last_sr_mid_ntp = chead->get32MiddleNtp();
  rr_info_.last_sr_ts = packet->received_time_ms;
}
开发者ID:shahrukh330,项目名称:licode,代码行数:10,代码来源:RtcpRrGenerator.cpp

示例9: read

void MediaStream::read(std::shared_ptr<DataPacket> packet) {
  char* buf = packet->data;
  int len = packet->length;
  // PROCESS RTCP
  RtpHeader *head = reinterpret_cast<RtpHeader*> (buf);
  RtcpHeader *chead = reinterpret_cast<RtcpHeader*> (buf);
  uint32_t recvSSRC = 0;
  if (!chead->isRtcp()) {
    recvSSRC = head->getSSRC();
  } else if (chead->packettype == RTCP_Sender_PT) {  // Sender Report
    recvSSRC = chead->getSSRC();
  }
  // DELIVER FEEDBACK (RR, FEEDBACK PACKETS)
  if (chead->isFeedback()) {
    if (fb_sink_ != nullptr && should_send_feedback_) {
      fb_sink_->deliverFeedback(std::move(packet));
    }
  } else {
    // RTP or RTCP Sender Report
    if (bundle_) {
      // Check incoming SSRC
      // Deliver data
      if (isVideoSourceSSRC(recvSSRC)) {
        parseIncomingPayloadType(buf, len, VIDEO_PACKET);
        video_sink_->deliverVideoData(std::move(packet));
      } else if (isAudioSourceSSRC(recvSSRC)) {
        parseIncomingPayloadType(buf, len, AUDIO_PACKET);
        audio_sink_->deliverAudioData(std::move(packet));
      } else {
        ELOG_DEBUG("%s read video unknownSSRC: %u, localVideoSSRC: %u, localAudioSSRC: %u",
                    toLog(), recvSSRC, this->getVideoSourceSSRC(), this->getAudioSourceSSRC());
      }
    } else {
      if (packet->type == AUDIO_PACKET && audio_sink_ != nullptr) {
        parseIncomingPayloadType(buf, len, AUDIO_PACKET);
        // Firefox does not send SSRC in SDP
        if (getAudioSourceSSRC() == 0) {
          ELOG_DEBUG("%s discoveredAudioSourceSSRC:%u", toLog(), recvSSRC);
          this->setAudioSourceSSRC(recvSSRC);
        }
        audio_sink_->deliverAudioData(std::move(packet));
      } else if (packet->type == VIDEO_PACKET && video_sink_ != nullptr) {
        parseIncomingPayloadType(buf, len, VIDEO_PACKET);
        // Firefox does not send SSRC in SDP
        if (getVideoSourceSSRC() == 0) {
          ELOG_DEBUG("%s discoveredVideoSourceSSRC:%u", toLog(), recvSSRC);
          this->setVideoSourceSSRC(recvSSRC);
        }
        // change ssrc for RTP packets, don't touch here if RTCP
        video_sink_->deliverVideoData(std::move(packet));
      }
    }  // if not bundle
  }  // if not Feedback
}
开发者ID:mkhahani,项目名称:licode,代码行数:54,代码来源:MediaStream.cpp

示例10: write

void RtcpProcessorHandler::write(Context *ctx, std::shared_ptr<dataPacket> packet) {
  RtcpHeader *chead = reinterpret_cast<RtcpHeader*>(packet->data);
  if (chead->isFeedback()) {
    int length = processor_->analyzeFeedback(packet->data, packet->length);
    if (length) {
      ctx->fireWrite(packet);
    }
    return;
  }
  ctx->fireWrite(packet);
}
开发者ID:fanchuanster,项目名称:licode,代码行数:11,代码来源:RtcpProcessorHandler.cpp

示例11: write

void SRPacketHandler::write(Context *ctx, std::shared_ptr<dataPacket> packet) {
  if (initialized_ && enabled_) {
    RtcpHeader *chead = reinterpret_cast<RtcpHeader*>(packet->data);
    if (!chead->isRtcp() && enabled_) {
      handleRtpPacket(packet);
    } else if (chead->packettype == RTCP_Sender_PT && enabled_) {
      handleSR(packet);
    }
  }
  ctx->fireWrite(packet);
}
开发者ID:fanchuanster,项目名称:licode,代码行数:11,代码来源:SRPacketHandler.cpp

示例12: ELOG_DEBUG

void DtlsTransport::onNiceData(packetPtr packet) {
  int len = packet->length;
  char *data = packet->data;
  unsigned int component_id = packet->comp;

  int length = len;
  SrtpChannel *srtp = srtp_.get();
  if (DtlsTransport::isDtlsPacket(data, len)) {
    ELOG_DEBUG("%s message: Received DTLS message, transportName: %s, componentId: %u",
               toLog(), transport_name.c_str(), component_id);
    if (component_id == 1) {
      if (rtp_resender_.get() != NULL) {
        rtp_resender_->cancel();
      }
      dtlsRtp->read(reinterpret_cast<unsigned char*>(data), len);
    } else {
      if (rtcp_resender_.get() != NULL) {
        rtcp_resender_->cancel();
      }
      dtlsRtcp->read(reinterpret_cast<unsigned char*>(data), len);
    }
    return;
  } else if (this->getTransportState() == TRANSPORT_READY) {
    unprotect_packet_->length = len;
    unprotect_packet_->received_time_ms = packet->received_time_ms;
    memcpy(unprotect_packet_->data, data, len);

    if (dtlsRtcp != NULL && component_id == 2) {
      srtp = srtcp_.get();
    }
    if (srtp != NULL) {
      RtcpHeader *chead = reinterpret_cast<RtcpHeader*>(unprotect_packet_->data);
      if (chead->isRtcp()) {
        if (srtp->unprotectRtcp(unprotect_packet_->data, &unprotect_packet_->length) < 0) {
          return;
        }
      } else {
        if (srtp->unprotectRtp(unprotect_packet_->data, &unprotect_packet_->length) < 0) {
          return;
        }
      }
    } else {
      return;
    }

    if (length <= 0) {
      return;
    }
    getTransportListener()->onTransportData(unprotect_packet_, this);
  }
}
开发者ID:shahrukh330,项目名称:licode,代码行数:51,代码来源:DtlsTransport.cpp

示例13: read

void RtcpProcessorHandler::read(Context *ctx, std::shared_ptr<dataPacket> packet) {
  RtcpHeader *chead = reinterpret_cast<RtcpHeader*> (packet->data);
  if (chead->isRtcp()) {
    if (chead->packettype == RTCP_Sender_PT) {  // Sender Report
      processor_->analyzeSr(chead);
    }
  } else {
    if (stats_->getNode()["total"].hasChild("bitrateCalculated")) {
       processor_->setPublisherBW(stats_->getNode()["total"]["bitrateCalculated"].value());
    }
  }
  processor_->checkRtcpFb();
  ctx->fireRead(packet);
}
开发者ID:fanchuanster,项目名称:licode,代码行数:14,代码来源:RtcpProcessorHandler.cpp

示例14: read

void PacketCodecParser::read(Context *ctx, std::shared_ptr<DataPacket> packet) {
  RtcpHeader *chead = reinterpret_cast<RtcpHeader*>(packet->data);
  if (!chead->isRtcp() && enabled_) {
    RtpHeader *rtp_header = reinterpret_cast<RtpHeader*>(packet->data);
    RtpMap *codec =
        stream_->getRemoteSdpInfo()->getCodecByExternalPayloadType(
            rtp_header->getPayloadType());
    if (codec) {
      packet->codec = codec->encoding_name;
      packet->clock_rate = codec->clock_rate;
      ELOG_DEBUG("Reading codec: %s, clock: %u", packet->codec.c_str(), packet->clock_rate);
    }
  }
  ctx->fireRead(std::move(packet));
}
开发者ID:ging,项目名称:licode,代码行数:15,代码来源:PacketCodecParser.cpp

示例15: deliverFeedback_

  int WebRtcConnection::deliverFeedback_(char* buf, int len){
    // Check where to send the feedback
    RtcpHeader *chead = reinterpret_cast<RtcpHeader*> (buf);
//    ELOG_DEBUG("received Feedback type %u ssrc %u, sourcessrc %u", chead->packettype, chead->getSSRC(), chead->getSourceSSRC());
    if (chead->getSourceSSRC() == this->getAudioSourceSSRC()) {
        writeSsrc(buf,len,this->getAudioSinkSSRC());
    } else {
        writeSsrc(buf,len,this->getVideoSinkSSRC());      
    }

    if (videoTransport_ != NULL) {
      this->queueData(0, buf, len, videoTransport_);
    }
    return len;
  }
开发者ID:Lethea,项目名称:licode,代码行数:15,代码来源:WebRtcConnection.cpp


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