Class: RTCP::BYE

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

Overview

BYE: Goodbye RTCP Packet Documentation: RFC 3550, 6.6

 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|    SC   |   PT=BYE=203  |             length            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                           SSRC/CSRC                           |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
:                              ...                              :
+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+

(opt) | length | reason for leaving …

+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Constant Summary collapse

PT_ID =
203

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.



20
21
22
# File 'lib/rtcp/bye.rb', line 20

def padding
  @padding
end

#reasonObject (readonly)

Returns the value of attribute reason.



20
21
22
# File 'lib/rtcp/bye.rb', line 20

def reason
  @reason
end

#ssrcsObject (readonly)

Returns the value of attribute ssrcs.



20
21
22
# File 'lib/rtcp/bye.rb', line 20

def ssrcs
  @ssrcs
end

#versionObject (readonly)

Returns the value of attribute version.



20
21
22
# File 'lib/rtcp/bye.rb', line 20

def version
  @version
end

Instance Method Details

#decode(packet_data) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/rtcp/bye.rb', line 22

def decode(packet_data) 
  vpsc, packet_type, length = packet_data.unpack('CCn')
  ensure_packet_type(packet_type)

  @length  = 4 * (length + 1)
  @version = vpsc >> 6
  count    = vpsc & 15

  bye_data = payload_data(packet_data, @length, 4)

  @ssrcs = bye_data.unpack("N#{count}")

  if (4 * count) < bye_data.length
    rlen, data = bye_data.unpack("x#{4 * count}Ca*")
    @reason = data[0..(rlen - 1)]

    # If the string fills the packet to the next 32-bit boundary,
    # the string is not null terminated.  If not, the BYE packet
    # MUST be padded with null octets to the next 32- bit boundary.
    # $TODO: Remove padding?

    # $TODO: Check for/extract packet padding
  end
  self
end