Public Member Functions | Private Member Functions | Private Attributes

RTCP_SR_Packet Class Reference

The Sender Report packet is sent by all members of a session that are sending data. It contains statistics on the data being sent out. It also contains a list of RR_Block to represent each source this party is receiving data from. More...

#include <RTCP_Packet.h>

Inheritance diagram for RTCP_SR_Packet:
Inheritance graph
[legend]
Collaboration diagram for RTCP_SR_Packet:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 RTCP_SR_Packet (char *buffer, int *len)
 Constructor for incoming SR packets.
 RTCP_SR_Packet (ACE_UINT32 ssrcVal, ACE_UINT32 ntpMSByte, ACE_UINT32 ntpLSByte, ACE_UINT32 timestamp, ACE_UINT32 pktsSent, ACE_UINT32 octetsSent, RR_Block *rrBlocks)
 Constructor for outgoing SR packets.
virtual ~RTCP_SR_Packet (void)
 Destructor.
unsigned int packet_size (void)
 Returns the size of the packet in bytes.
ACE_UINT32 ssrc (void)
 Returns the synchronization source id for the sender of this packet.
ACE_UINT32 ntp_ts_msw (void)
 Returns the most significant word of the NTP timestamp.
ACE_UINT32 ntp_ts_lsw (void)
 Returns the least significant word of the NTP timestamp.
void dump (void)
 Prints the contents of the packet.

Private Member Functions

void build_packet (void)
 Used to create the byte representation of the RTCP packet.

Private Attributes

ACE_UINT32 ssrc_
 The synchronization source id of the sender generating this report.
ACE_UINT32 ntp_ts_msw_
 The most significant word of the NTP timestamp.
ACE_UINT32 ntp_ts_lsw_
 The least significant word of the NTP timestamp.
ACE_UINT32 rtp_ts_
 The RTP timestamp.
ACE_UINT32 psent_
 The total number of packets sent.
ACE_UINT32 osent_
 The total number of octets sent.
RR_Blockrr_
 A linked list of receiver report blocks.

Detailed Description

The Sender Report packet is sent by all members of a session that are sending data. It contains statistics on the data being sent out. It also contains a list of RR_Block to represent each source this party is receiving data from.

Definition at line 343 of file RTCP_Packet.h.


Constructor & Destructor Documentation

RTCP_SR_Packet::RTCP_SR_Packet ( char *  buffer,
int *  len 
)

Constructor for incoming SR packets.

Definition at line 1027 of file RTCP_Packet.cpp.

                : RTCP_Packet (buffer)
{
  unsigned int i = 0;
  RR_Block *local_block_ptr = 0;

  this->rr_ = 0;

  // The common part of the header is initialized in the parent.
  i=4;
  this->ssrc_ = ACE_NTOHL(*(ACE_UINT32*)&buffer[i]);
  i+=4;
  this->ntp_ts_msw_ = ACE_NTOHL(*(ACE_UINT32*)&buffer[i]);
  i+=4;
  this->ntp_ts_lsw_ = ACE_NTOHL(*(ACE_UINT32*)&buffer[i]);
  i+=4;
  this->rtp_ts_ = ACE_NTOHL(*(ACE_UINT32*)&buffer[i]);
  i+=4;
  this->psent_ = ACE_NTOHL(*(ACE_UINT32*)&buffer[i]);
  i+=4;
  this->osent_ = ACE_NTOHL(*(ACE_UINT32*)&buffer[i]);
  i+=4;
  for (unsigned int j=0; j<this->chd_.count_; j++)
    {
      if (j==0)
        {
          ACE_NEW (local_block_ptr,
                   RR_Block);
          this->rr_ = local_block_ptr;
        }
      else
        {
          ACE_NEW (local_block_ptr->next_,
                   RR_Block);
          local_block_ptr = local_block_ptr->next_;
        }

      local_block_ptr->next_ = 0;
      local_block_ptr->ssrc_ = ACE_NTOHL(*(ACE_UINT32*)&buffer[i]);
      i+=4;
      ACE_UINT32 temp = ACE_NTOHL(*(ACE_UINT32*)&buffer[i]);
      local_block_ptr->fraction_ = (temp&0xff000000) >> 24;
      local_block_ptr->lost_ = temp & 0x00ffffff;
      i+=4;
      local_block_ptr->last_seq_ = ACE_NTOHL(*(ACE_UINT32*)&buffer[i]);
      i+=4;
      local_block_ptr->jitter_ = ACE_NTOHL(*(ACE_UINT32*)&buffer[i]);
      i+=4;
      local_block_ptr->lsr_ = ACE_NTOHL(*(ACE_UINT32*)&buffer[i]);
      i+=4;
      local_block_ptr->dlsr_ = ACE_NTOHL(*(ACE_UINT32*)&buffer[i]);
      i+=4;
    }

  *len-=(this->chd_.length_+1)*4;

  this->packet_data_ = 0;
}

RTCP_SR_Packet::RTCP_SR_Packet ( ACE_UINT32  ssrcVal,
ACE_UINT32  ntpMSByte,
ACE_UINT32  ntpLSByte,
ACE_UINT32  timestamp,
ACE_UINT32  pktsSent,
ACE_UINT32  octetsSent,
RR_Block rrBlocks 
)

Constructor for outgoing SR packets.

Definition at line 983 of file RTCP_Packet.cpp.

{
  RR_Block *block_ptr= 0;
  chd_.count_ = 0;
  chd_.ver_ = 2;
  chd_.pt_ = RTCP_PT_SR;

  this->ssrc_ = ssrc;
  this->ntp_ts_msw_ = ntp_ts_msw;
  this->ntp_ts_lsw_ = ntp_ts_lsw;
  this->rtp_ts_ = timestamp;
  this->psent_ = packets_sent;
  this->osent_ = octets_sent;
  this->rr_ = blocks;

  block_ptr = blocks;

  while (block_ptr)
    {
      chd_.count_++;

      // Can only have 31 receiver reports
      if (this->chd_.count_ == 31)
        {
          block_ptr->next_ = 0;
          break;
        }

      block_ptr = block_ptr->next_;
    }

  this->chd_.length_ = static_cast<ACE_UINT16> (6 + 6*(chd_.count_)); //+profile specific extensions ??

  this->packet_data_ = 0;
}

RTCP_SR_Packet::~RTCP_SR_Packet ( void   )  [virtual]

Destructor.

Definition at line 1089 of file RTCP_Packet.cpp.

{
  RR_Block *prev;

  if (this->rr_)
    {
      while (this->rr_)
        {
          prev = this->rr_;
          this->rr_ = this->rr_->next_;
          delete prev;
        }
    }

  if (this->packet_data_)
    delete []this->packet_data_;
}


Member Function Documentation

void RTCP_SR_Packet::build_packet ( void   )  [private, virtual]

Used to create the byte representation of the RTCP packet.

Implements RTCP_Packet.

Definition at line 1119 of file RTCP_Packet.cpp.

{
  int index = 0;
  RR_Block *local_block_ptr;

  if (this->packet_data_)
    delete []this->packet_data_;

  ACE_NEW (this->packet_data_,
           char[this->packet_size()]);

  this->packet_data_[index] = static_cast<char> ((this->chd_.ver_ << 6) |
                                                 (this->chd_.pad_ << 5) |
                                                  this->chd_.count_);
  index++;
  this->packet_data_[index] = this->chd_.pt_;
  index++;
  *((ACE_UINT16*)&this->packet_data_[index]) = ACE_HTONS(this->chd_.length_);
  index+=2;
  *((ACE_UINT32*)&this->packet_data_[index]) = ACE_HTONL(this->ssrc_);
  index+=4;
  *((ACE_UINT32*)&this->packet_data_[index]) = ACE_HTONL(this->ntp_ts_msw_);
  index+=4;
  *((ACE_UINT32*)&this->packet_data_[index]) = ACE_HTONL(this->ntp_ts_lsw_);
  index+=4;
  *((ACE_UINT32*)&this->packet_data_[index]) = ACE_HTONL(this->rtp_ts_);
  index+=4;
  *((ACE_UINT32*)&this->packet_data_[index]) = ACE_HTONL(this->psent_);
  index+=4;
  *((ACE_UINT32*)&this->packet_data_[index]) = ACE_HTONL(this->osent_);
  index+=4;

  local_block_ptr = this->rr_;
  while (local_block_ptr)
    {
      *((ACE_UINT32*)&this->packet_data_[index]) = ACE_HTONL(local_block_ptr->ssrc_);
      index+=4;
      ACE_UINT32 temp = ACE_HTONL((local_block_ptr->fraction_&0xff) << 24) &
                              local_block_ptr->lost_;
      *((ACE_UINT32*)&this->packet_data_[index]) = temp;
      index+=4;
      *((ACE_UINT32*)&this->packet_data_[index]) = ACE_HTONL(local_block_ptr->last_seq_);
      index+=4;
      *((ACE_UINT32*)&this->packet_data_[index]) = ACE_HTONL(local_block_ptr->jitter_);
      index+=4;
      *((ACE_UINT32*)&this->packet_data_[index]) = ACE_HTONL(local_block_ptr->lsr_);
      index+=4;
      *((ACE_UINT32*)&this->packet_data_[index]) = ACE_HTONL(local_block_ptr->dlsr_);
      index+=4;
      local_block_ptr = local_block_ptr->next_;
    }
}

void RTCP_SR_Packet::dump ( void   ) 

Prints the contents of the packet.

Definition at line 1173 of file RTCP_Packet.cpp.

{
  RR_Block *b = this->rr_;
  int count = 1;

  ACE_DEBUG ((LM_DEBUG,
              "\nRTCP_SR_Packet:: from %u - %d rr blocks follow.\n",
              this->ssrc_,
              this->chd_.count_));
  ACE_DEBUG ((LM_DEBUG,
              "    NTP(sec) %u.%u; RTP ts %u\n",
              this->ntp_ts_msw_,
              this->ntp_ts_lsw_,
              this->rtp_ts_));
  ACE_DEBUG ((LM_DEBUG,
              "    packets sent %u; octets sent %u\n",
              this->psent_,
              this->osent_));

  while (b)
    {
      ACE_DEBUG ((LM_DEBUG,
                  "  Block %d: ssrc %u; frac %u; lost %u; last seq %u\n",
                  count,
                  b->ssrc_,
                  b->fraction_,
                  b->lost_,
                  b->last_seq_));
      ACE_DEBUG ((LM_DEBUG,
                  "           jitter %u; lsr %u; dlsr %u;\n",
                  b->jitter_,
                  b->lsr_,
                  b->dlsr_));

      b = b->next_;
      ++count;
    }
}

ACE_UINT32 RTCP_SR_Packet::ntp_ts_lsw ( void   )  [inline]

Returns the least significant word of the NTP timestamp.

Definition at line 371 of file RTCP_Packet.h.

{ return this->ntp_ts_lsw_; }

ACE_UINT32 RTCP_SR_Packet::ntp_ts_msw ( void   )  [inline]

Returns the most significant word of the NTP timestamp.

Definition at line 368 of file RTCP_Packet.h.

{ return this->ntp_ts_msw_; }

unsigned int RTCP_SR_Packet::packet_size ( void   )  [virtual]

Returns the size of the packet in bytes.

Implements RTCP_Packet.

Definition at line 1109 of file RTCP_Packet.cpp.

{
  ACE_UINT16 size  = static_cast<ACE_UINT16> ((2+chd_.count_*6) * 4); // + profile specific extensions ?
  size += 20; // the first line is the same as RR; 20 more bytes for SR

  return size;
}

ACE_UINT32 RTCP_SR_Packet::ssrc ( void   )  [inline]

Returns the synchronization source id for the sender of this packet.

Definition at line 365 of file RTCP_Packet.h.

{ return this->ssrc_; }


Member Data Documentation

ACE_UINT32 RTCP_SR_Packet::ntp_ts_lsw_ [private]

The least significant word of the NTP timestamp.

Definition at line 387 of file RTCP_Packet.h.

ACE_UINT32 RTCP_SR_Packet::ntp_ts_msw_ [private]

The most significant word of the NTP timestamp.

Definition at line 384 of file RTCP_Packet.h.

ACE_UINT32 RTCP_SR_Packet::osent_ [private]

The total number of octets sent.

Definition at line 396 of file RTCP_Packet.h.

ACE_UINT32 RTCP_SR_Packet::psent_ [private]

The total number of packets sent.

Definition at line 393 of file RTCP_Packet.h.

A linked list of receiver report blocks.

Definition at line 399 of file RTCP_Packet.h.

ACE_UINT32 RTCP_SR_Packet::rtp_ts_ [private]

The RTP timestamp.

Definition at line 390 of file RTCP_Packet.h.

ACE_UINT32 RTCP_SR_Packet::ssrc_ [private]

The synchronization source id of the sender generating this report.

Definition at line 381 of file RTCP_Packet.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines