message: Also search REMBs and RRs after SRs
diff: #include "./MediaDefinitions.h"
  #include "rtp/SenderBandwidthEstimationHandler.h"
  +#include "rtp/RtpUtils.h"
  +
  namespace erizo {
  DEFINE_LOGGER(SenderBandwidthEstimationHandler, "rtp.SenderBandwidthEstimationHandler");
  @@ -56,18 +58,7 @@ void SenderBandwidthEstimationHandler::notifyUpdate() {
  }
  void SenderBandwidthEstimationHandler::read(Context *ctx, std::shared_ptr<DataPacket> packet) {
  - RtcpHeader *chead = reinterpret_cast<RtcpHeader*>(packet->data);
  - if (chead->isFeedback()) {
  - char* packet_pointer = packet->data;
  - int rtcp_length = 0;
  - int total_length = 0;
  - int current_block = 0;
  -
  - do {
  - packet_pointer+=rtcp_length;
  - chead = reinterpret_cast<RtcpHeader*>(packet_pointer);
  - rtcp_length = (ntohs(chead->length) + 1) * 4;
  - total_length += rtcp_length;
  + RtpUtils::forEachRtcpBlock(packet, [this](RtcpHeader *chead) {
  ELOG_DEBUG("%s ssrc %u, sourceSSRC %u, PacketType %u", connection_->toLog(),
  chead->getSSRC(),
  chead->getSourceSSRC(),
  @@ -75,15 +66,6 @@ void SenderBandwidthEstimationHandler::read(Context *ctx, std::shared_ptr<DataPa
  switch (chead->packettype) {
  case RTCP_Receiver_PT:
  {
  - ELOG_DEBUG("%s, Analyzing Video RR: PacketLost %u, Ratio %u, current_block %d, blocks %d"
  - ", sourceSSRC %u, ssrc %u",
  - connection_->toLog(),
  - chead->getLostPackets(),
  - chead->getFractionLost(),
  - current_block,
  - chead->getBlockCount(),
  - chead->getSourceSSRC(),
  - chead->getSSRC());
  // calculate RTT + Update receiver block
  uint32_t delay_since_last_ms = (chead->getDelaySinceLastSr() * 1000) / 65536;
  int64_t now_ms = ClockUtils::timePointToMs(clock_->now());
  @@ -93,6 +75,17 @@ void SenderBandwidthEstimationHandler::read(Context *ctx, std::shared_ptr<DataPa
  [last_sr](const std::shared_ptr<SrDelayData> sr_info) {
  return sr_info->sr_ntp == last_sr;
  });
  + ELOG_DEBUG("%s, Analyzing Video RR: PacketLost %u, Ratio %u, blocks %d"
  + ", sourceSSRC %u, ssrc %u, last_sr %u, remb_received %d, found %d",
  + connection_->toLog(),
  + chead->getLostPackets(),
  + chead->getFractionLost(),
  + chead->getBlockCount(),
  + chead->getSourceSSRC(),
  + chead->getSSRC(),
  + chead->getLastSr(),
  + received_remb_,
  + value != sr_delay_data_.end());
  // TODO(pedro) Implement alternative when there are no REMBs
  if (received_remb_ && value != sr_delay_data_.end()) {
  uint32_t delay = now_ms - (*value)->sr_send_time - delay_since_last_ms;
  @@ -131,9 +124,7 @@ void SenderBandwidthEstimationHandler::read(Context *ctx, std::shared_ptr<DataPa
  default:
  break;
  }
  - current_block++;
  - } while (total_length < packet->length);
  - }
  + });
  ctx->fireRead(std::move(packet));
  }
  