ExRTCP.Packet (ex_rtcp v0.4.1)

View Source

RTCP packet encoding and decoding functionalities.

Examples

  iex> packet = %ExRTCP.Packet.SenderReport{
  ...>   ssrc: 123_456,
  ...>   ntp_timestamp: 5_000_000,
  ...>   rtp_timestamp: 436_133,
  ...>   packet_count: 5,
  ...>   octet_count: 89
  ...> }
  iex> encoded = ExRTCP.Packet.encode(packet, padding: 8)
  iex> {:ok, ^packet} = ExRTCP.Packet.decode(encoded)

Summary

Functions

Decodes RTCP packet. Returns a struct representing the packet based on its type.

Encodes the packet and returns the resulting binary.

Types

decode_error()

@type decode_error() :: :invalid_packet | :unknown_type

Possible decode/1 errors.

  • :invalid_packet - this binary could not be parsed as a valid RTCP packet
  • :unknown_type - this type of RTCP packet is not supported or does not exist

int16()

@type int16() :: -32768..32767

int24()

@type int24() :: -8_388_608..8_388_607

packet()

uint8()

@type uint8() :: 0..255

uint13()

@type uint13() :: 0..8191

uint16()

@type uint16() :: 0..65535

uint24()

@type uint24() :: 0..16_777_216

uint32()

@type uint32() :: 0..4_294_967_295

uint64()

@type uint64() :: 0..18_446_744_073_709_551_615

Functions

decode(raw)

@spec decode(binary()) :: {:ok, packet()} | {:error, decode_error()}

Decodes RTCP packet. Returns a struct representing the packet based on its type.

encode(packet, opts \\ [])

@spec encode(packet(), [{:padding, uint8()}]) :: binary()

Encodes the packet and returns the resulting binary.

Options:

  • padding - number of padding bytes added to packet, no padding is added by default, must be multiple of 4, and smaller than 256