Class: RTCP::XR

Inherits:
RTCP
  • Object
show all
Defined in:
lib/rtcp/xr.rb

Overview

XR: Extended Report RTCP Packet Documentation: RFC 3611, 2.

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|V=2|P|reserved |   PT=XR=207   |             length            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                              SSRC                             |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
:                         report blocks                         :
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

An extended report block has the following format:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|      BT       | type-specific |         block length          |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
:             type-specific block contents                      :
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

The Statistics Summary Report Block has the following format:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|     BT=6      |L|D|J|ToH|rsvd.|       block length = 9        |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                        SSRC of source                         |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|          begin_seq            |             end_seq           |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                        lost_packets                           |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                        dup_packets                            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                         min_jitter                            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                         max_jitter                            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                         mean_jitter                           |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                         dev_jitter                            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| min_ttl_or_hl | max_ttl_or_hl |mean_ttl_or_hl | dev_ttl_or_hl |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Constant Summary collapse

PT_ID =
207

Constants inherited from RTCP

VERSION

Instance Attribute Summary collapse

Attributes inherited from RTCP

#length, #type_id

Instance Method Summary collapse

Methods inherited from RTCP

decode, decode_all, #to_s

Instance Attribute Details

#paddingObject (readonly)

Returns the value of attribute padding.



54
55
56
# File 'lib/rtcp/xr.rb', line 54

def padding
  @padding
end

#report_blocksObject (readonly)

Returns the value of attribute report_blocks.



54
55
56
# File 'lib/rtcp/xr.rb', line 54

def report_blocks
  @report_blocks
end

#ssrcObject (readonly)

Returns the value of attribute ssrc.



54
55
56
# File 'lib/rtcp/xr.rb', line 54

def ssrc
  @ssrc
end

#versionObject (readonly)

Returns the value of attribute version.



54
55
56
# File 'lib/rtcp/xr.rb', line 54

def version
  @version
end

Instance Method Details

#decode(packet_data) ⇒ Object



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/rtcp/xr.rb', line 56

def decode(packet_data)
  vprc, packet_type, length, @ssrc = packet_data.unpack('CCnN')
  ensure_packet_type(packet_type)

  @version = vprc >> 6
  @length  = 4 * (length + 1)
  @report_blocks = []

  report_block_data = payload_data(packet_data, @length, 8)

  while report_block_data && report_block_data.length >= 4
    bt, length = report_block_data.unpack('Cxn')
    length = 4 * (length + 1)
    @report_blocks.push case bt
    when 1 # Loss RLE Report Block
      decode_loss_rle(report_block_data)
    when 6 # Statistics Summary Report
      decode_ssr(report_block_data)
    else
      {
        type:   bt,
        length: length,
        data:   report_block_data.slice(4..(length-1))
      }
    end

    report_block_data = report_block_data.slice(length..-1)
  end

  # Padding
  if (vprc & 16 == 16)
    @padding = report_block_data
  elsif (report_block_data != '')
    raise(RTCP::DecodeError, "Packet has undeclared padding")
  end

  self
end