Skip to content
Iñaki Baz Castillo edited this page Sep 15, 2016 · 17 revisions

RTCP representation RTC::RTCP::Packet

Base class for RTCP packet representation.

Holds specific information for the given RTCP packet and a pointer to the next RTC::RTCP::Packet instance. which will be NULL for the last packet of the compound RTCP packet.

  • RTC::RtcpPacket::RecvReport
  • RTC::RtcpPacket::SendReport
  • RTC::RtcpPacket::Sdes
  • RTC::RtcpPacket::Byet
  • RTC::RtcpPacket::Fir
  • RTC::RtcpPacket::Nack
  • ...

RTCP generation

RTCP Receiver Reports

Upon RTP reception, RTC::RtpReceiver maintains the received RTP counters and statistics.

  • packet count
  • octet count
  • first sequence number (for packet lost calculation)
  • last sequence number (for later RTCP receiver report calculation)
  • last packet time now() (for later RTCP receiver report calculation)
  • packet lost. Calculated based on the sequence numbers. Consider whether the seq counter has wrapped.
  • jitter
  • optional: delta. Time elapsed since last received RTP packet min/max/avg

This information is updated on every incoming RTP packet and serves to generate the Receiver Reports.

RTCP Sender Reports

RTC::RtpSender maintains the sent RTP counters:

  • packet count
  • octet count

This information is updated on every outgoing RTP packet and serves to generate the Sender Reports.

Incoming RTCP processing

  • RTC::Peer:onRtcpPacket(RTC::RtcpPacket* packet)

Each RTC::RtcpPacket is inspected and processed independently depending on the packet type, as follows:

switch (packet->type)
{
  case RTC::RtcpPacket::Type::SenderReport:
    // Get the RtpReceiver which the RTCP packet refers to
    RTC::RtpReceiver* rtpReceiver = getRtpReceiver(packet);
    rtpReceiver->receiveRtcpPacket(packet);
   break;
   
  case RTC::RtcpPacket::Type::ReceiverReport:
  case RTC::RtcpPacket::Type::Fir:
  case RTC::RtcpPacket::Type::Nack:
    // Get the RtpSender which the RTCP packet refers to
    RTC::RtpSender* rtpSender = getRtpSender(packet);
    rtpSender->receiveRtcpPacket(packet);
    break;
   
  case RTC::RtcpPacket::Type::Sdes:
   // Source Description RTCP Packet
   // Set or update peer related infomation: email, telephone, bla bla
   break:
   
  case RTC::RtcpPacket::Type::Bye:
   // The given source is no longer active
   // Remove the correspoinding RtpReciver and related RtpSenders
   RTC::RtpReceiver* rtpReceiver = getRtpReceiver(packet);
   rtpReceiver->Close();
   break;
   
  case RTC::RtcpPacket::Type::App:
   this->listener->onPeerRtcpPacket(this, packet);
   break;
   
  deafult:
   MS_WARN("Wrong RTCP type received to 'RTC::Peer': %u", packet->type);
   break;
}
  • RTC::RtpReceiver::ReceiveRtcpPacket(RTC::RtcpPacket* packet)
switch (packet->type)
{
  case RTC::RtcpPacket::Type::SenderReport:
   // This information helps the `RTC::RtpReceiver` know the RTP that was sent by the remote peer.
   break;
   
  default:
   MS_WARN("Wrong RTCP type received to 'RTC::RtcpReceiver': %u", packet->type);
   break;
}
  • Rtc::RtpSender::receiveRtcpPacket(RTC::RtcpPacket* packet)
switch (packet->type)
{
  case RTC::RtcpPacket::Type::ReceiverReport:
    // Use this information to check the uplink health and addapt the sending rate based on it.
    break;
  
  case RTC::RtcpPacket::Type::Fir:
    // The receiver requires a full encoded image. Take it from the buffer and send it.
    // NOTE: Full encoded image received from the peer must be stored in a sliding window.
    break;
    
  case RTC::RtcpPacket::Type::Nack:
    // Re-send the requested RTP packets
    break;
    
  default:
    MS_WARN("Wrong RTCP type received to 'RTC::RtcpSender': %u", packet->type);
    break;
}
  • Rtc::Room::onPeerRtcpPacket(RTC::Peer* peer, RTC::RtpReceiver* rtpReceiver, RTC::RtcpPacket* packet)
switch (packet->type)
{
  case RTC::RtcpPacket::Type::App:
    // Maybe some control on the room, etc
    break;
   
  default:
    MS_WARN("Wrong RTCP type received to 'RTC::Room': %u", packet->type);
    break;
}
Clone this wiki locally