Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
roc::packet Namespace Reference

Network packets and packet processing. More...

Classes

class  ConcurrentQueue
 Concurrent blocking packet queue. More...
 
class  DelayedReader
 Delayed reader. More...
 
struct  FEC
 FECFRAME packet. More...
 
class  IComposer
 Packet composer interface. More...
 
struct  LinkMetrics
 Link metrics. More...
 
class  ILinkMeter
 Link meter interface. More...
 
class  Interleaver
 Interleaves packets to transmit them in pseudo random order. More...
 
class  IParser
 Packet parser interface. More...
 
class  IReader
 Packet reader interface. More...
 
class  ISequencer
 Packet sequencer. Fills protocol-specific packet headers to form a continous sequence. For example, RTP sequencer fills packet seqnums and timestamps. More...
 
class  IWriter
 Packet writer interface. More...
 
class  Packet
 Packet. More...
 
class  PacketFactory
 Packet factory. More...
 
class  packet_flags_to_str
 Format packet flags to string. More...
 
class  Queue
 Packet queue. More...
 
class  Router
 Route packets to packet writers. More...
 
struct  RTCP
 RTCP compound packet. More...
 
struct  RTP
 RTP packet. More...
 
class  Shipper
 Prepare a packet for being sent. More...
 
class  SortedQueue
 Sorted packet queue. More...
 
struct  UDP
 UDP packet. More...
 

Typedefs

typedef uint64_t ntp_timestamp_t
 NTP timestamp. More...
 
typedef core::SharedPtr< PacketPacketPtr
 Packet smart pointer. More...
 
typedef uint32_t stream_source_t
 Packet stream identifier. More...
 
typedef uint32_t stream_timestamp_t
 Packet stream timestamp. More...
 
typedef int32_t stream_timestamp_diff_t
 Packet stream timestamp delta. More...
 
typedef uint16_t seqnum_t
 Packet sequence number. More...
 
typedef int16_t seqnum_diff_t
 Packet sequence number delta. More...
 
typedef uint32_t ext_seqnum_t
 Extended sequence number. More...
 
typedef int32_t ext_seqnum_diff_t
 Extended sequence number delta. More...
 
typedef uint16_t blknum_t
 FEC packet block number. More...
 
typedef int16_t blknum_diff_t
 FEC packet block number delta. More...
 

Enumerations

enum  FecScheme { FEC_None , FEC_ReedSolomon_M8 , FEC_LDPC_Staircase }
 FECFRAME scheme. More...
 
enum  { PrintHeaders = 0 , PrintPayload = (1 << 0) }
 Print flags. More...
 

Functions

const char * fec_scheme_to_str (FecScheme)
 FEC scheme to string. More...
 
ntp_timestamp_t unix_2_ntp (core::nanoseconds_t unix_time)
 Convert Unix absolute time to NTP absolute time. More...
 
core::nanoseconds_t ntp_2_unix (ntp_timestamp_t ntp_time)
 Convert NTP absolute time to Unix absolute time. More...
 
ntp_timestamp_t nanoseconds_2_ntp (core::nanoseconds_t ns_delta)
 Convert nanoseconds delta to NTP delta. More...
 
core::nanoseconds_t ntp_2_nanoseconds (ntp_timestamp_t ntp_delta)
 Converts NTP delta to nanoseconds delta. More...
 
void print_packet (const Packet &packet, int flags)
 Print packet to stderr. More...
 
stream_timestamp_diff_t stream_timestamp_diff (const stream_timestamp_t a, const stream_timestamp_t b)
 Compute difference between two timestamps. More...
 
bool stream_timestamp_lt (const stream_timestamp_t a, const stream_timestamp_t b)
 Check if a is before b, taking possible wrap into account. More...
 
bool stream_timestamp_le (const stream_timestamp_t a, const stream_timestamp_t b)
 Check if a is before or equal to b, taking possible wrap into account. More...
 
stream_timestamp_t ns_2_stream_timestamp (core::nanoseconds_t ns, size_t sample_rate)
 Convert nanoseconds to stream timestamp. More...
 
core::nanoseconds_t stream_timestamp_2_ns (stream_timestamp_t ts, size_t sample_rate)
 Convert stream timestamp.to nanoseconds. More...
 
stream_timestamp_diff_t ns_2_stream_timestamp_delta (core::nanoseconds_t ns, size_t sample_rate)
 Convert nanoseconds to stream timestamp delta. More...
 
core::nanoseconds_t stream_timestamp_delta_2_ns (stream_timestamp_diff_t ts, size_t sample_rate)
 Convert stream timestamp.delta to nanoseconds. More...
 
seqnum_diff_t seqnum_diff (const seqnum_t a, const seqnum_t b)
 Compute difference between two seqnums. More...
 
bool seqnum_lt (const seqnum_t a, const seqnum_t b)
 Check if a is before b, taking possible wrap into account. More...
 
bool seqnum_le (const seqnum_t a, const seqnum_t b)
 Check if a is before or equal to b, taking possible wrap into account. More...
 
ext_seqnum_diff_t ext_seqnum_diff (const ext_seqnum_t a, const ext_seqnum_t b)
 Compute difference between two extended seqnums. More...
 
bool ext_seqnum_lt (const ext_seqnum_t a, const ext_seqnum_t b)
 Check if a is before b, taking possible wrap into account. More...
 
bool ext_seqnum_le (const ext_seqnum_t a, const ext_seqnum_t b)
 Check if a is before or equal to b, taking possible wrap into account. More...
 
blknum_diff_t blknum_diff (const blknum_t a, const blknum_t b)
 Compute difference between two FEC packet block numbers. More...
 
bool blknum_lt (const blknum_t a, const blknum_t b)
 Check if a is before b, taking possible wrap into account. More...
 
bool blknum_le (const blknum_t a, const blknum_t b)
 Check if a is before or equal to b, taking possible wrap into account. More...
 

Detailed Description

Network packets and packet processing.

Typedef Documentation

◆ blknum_diff_t

typedef int16_t roc::packet::blknum_diff_t

FEC packet block number delta.

Remarks
Signed version of blknum_t.

Definition at line 135 of file units.h.

◆ blknum_t

typedef uint16_t roc::packet::blknum_t

FEC packet block number.

Remarks
Defines position of FEC packet block within stream. Starts from unspecified value and can wrap. Incremented by one each block.

Definition at line 130 of file units.h.

◆ ext_seqnum_diff_t

Extended sequence number delta.

Remarks
Signed version of ext_seqnum_t.

Definition at line 108 of file units.h.

◆ ext_seqnum_t

typedef uint32_t roc::packet::ext_seqnum_t

Extended sequence number.

Remarks
Sequence number extended to 32 bits.

Definition at line 103 of file units.h.

◆ ntp_timestamp_t

typedef uint64_t roc::packet::ntp_timestamp_t

NTP timestamp.

Format:

  • highest 32 bits - seconds since NTP epoch
  • lowest 32 bits - fractions of a second

Epoch:

  • for dates in years 1968-2036, epoch starts from 1 Jan 1900 00:00:00
  • for dates in years 2036-2104, epoch starts from 7 Feb 2036 06:28:16

See RFC 5905 and RFC 2030.

See also:

Definition at line 35 of file ntp.h.

◆ PacketPtr

Packet smart pointer.

Definition at line 34 of file packet.h.

◆ seqnum_diff_t

typedef int16_t roc::packet::seqnum_diff_t

Packet sequence number delta.

Remarks
Signed version of seqnum_t.

Definition at line 83 of file units.h.

◆ seqnum_t

typedef uint16_t roc::packet::seqnum_t

Packet sequence number.

Remarks
Defines position of packet within stream. Starts from unspecified value and can wrap. Incremented by one each packet.

Definition at line 78 of file units.h.

◆ stream_source_t

typedef uint32_t roc::packet::stream_source_t

Packet stream identifier.

Remarks
Identifies packet stream within session. Unique only within one session. For example, audio packet stream and repair (FEC) packet stream usually have different source identifiers.

Definition at line 27 of file units.h.

◆ stream_timestamp_diff_t

Packet stream timestamp delta.

Remarks
Signed version of stream_timestamp_t.

Definition at line 41 of file units.h.

◆ stream_timestamp_t

Packet stream timestamp.

Remarks
Defines position of packet contents (e.g. audio chunk) within stream. Starts from unspecified value and can wrap. Measured in sender's clock domain and clock rate. For PCM audio, stream timestamp is incremented by one every N samples, where N is the number of channels.

Definition at line 36 of file units.h.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

Print flags.

Enumerator
PrintHeaders 

Print packet header.

PrintPayload 

Print packet payload.

Definition at line 21 of file print_packet.h.

◆ FecScheme

FECFRAME scheme.

Enumerator
FEC_None 

No FEC.

FEC_ReedSolomon_M8 

Reed-Solomon (m=8).

FEC_LDPC_Staircase 

LDPC-Staircase.

Definition at line 23 of file fec.h.

Function Documentation

◆ blknum_diff()

blknum_diff_t roc::packet::blknum_diff ( const blknum_t  a,
const blknum_t  b 
)
inline

Compute difference between two FEC packet block numbers.

Definition at line 138 of file units.h.

◆ blknum_le()

bool roc::packet::blknum_le ( const blknum_t  a,
const blknum_t  b 
)
inline

Check if a is before or equal to b, taking possible wrap into account.

Definition at line 148 of file units.h.

◆ blknum_lt()

bool roc::packet::blknum_lt ( const blknum_t  a,
const blknum_t  b 
)
inline

Check if a is before b, taking possible wrap into account.

Definition at line 143 of file units.h.

◆ ext_seqnum_diff()

ext_seqnum_diff_t roc::packet::ext_seqnum_diff ( const ext_seqnum_t  a,
const ext_seqnum_t  b 
)
inline

Compute difference between two extended seqnums.

Definition at line 111 of file units.h.

◆ ext_seqnum_le()

bool roc::packet::ext_seqnum_le ( const ext_seqnum_t  a,
const ext_seqnum_t  b 
)
inline

Check if a is before or equal to b, taking possible wrap into account.

Definition at line 121 of file units.h.

◆ ext_seqnum_lt()

bool roc::packet::ext_seqnum_lt ( const ext_seqnum_t  a,
const ext_seqnum_t  b 
)
inline

Check if a is before b, taking possible wrap into account.

Definition at line 116 of file units.h.

◆ fec_scheme_to_str()

const char* roc::packet::fec_scheme_to_str ( FecScheme  )

FEC scheme to string.

◆ nanoseconds_2_ntp()

ntp_timestamp_t roc::packet::nanoseconds_2_ntp ( core::nanoseconds_t  ns_delta)

Convert nanoseconds delta to NTP delta.

Remarks
ns_delta defines nanoseconds delta (should be positive)

◆ ns_2_stream_timestamp()

stream_timestamp_t roc::packet::ns_2_stream_timestamp ( core::nanoseconds_t  ns,
size_t  sample_rate 
)

Convert nanoseconds to stream timestamp.

◆ ns_2_stream_timestamp_delta()

stream_timestamp_diff_t roc::packet::ns_2_stream_timestamp_delta ( core::nanoseconds_t  ns,
size_t  sample_rate 
)

Convert nanoseconds to stream timestamp delta.

◆ ntp_2_nanoseconds()

core::nanoseconds_t roc::packet::ntp_2_nanoseconds ( ntp_timestamp_t  ntp_delta)

Converts NTP delta to nanoseconds delta.

◆ ntp_2_unix()

core::nanoseconds_t roc::packet::ntp_2_unix ( ntp_timestamp_t  ntp_time)

Convert NTP absolute time to Unix absolute time.

◆ print_packet()

void roc::packet::print_packet ( const Packet packet,
int  flags 
)

Print packet to stderr.

◆ seqnum_diff()

seqnum_diff_t roc::packet::seqnum_diff ( const seqnum_t  a,
const seqnum_t  b 
)
inline

Compute difference between two seqnums.

Definition at line 86 of file units.h.

◆ seqnum_le()

bool roc::packet::seqnum_le ( const seqnum_t  a,
const seqnum_t  b 
)
inline

Check if a is before or equal to b, taking possible wrap into account.

Definition at line 96 of file units.h.

◆ seqnum_lt()

bool roc::packet::seqnum_lt ( const seqnum_t  a,
const seqnum_t  b 
)
inline

Check if a is before b, taking possible wrap into account.

Definition at line 91 of file units.h.

◆ stream_timestamp_2_ns()

core::nanoseconds_t roc::packet::stream_timestamp_2_ns ( stream_timestamp_t  ts,
size_t  sample_rate 
)

Convert stream timestamp.to nanoseconds.

◆ stream_timestamp_delta_2_ns()

core::nanoseconds_t roc::packet::stream_timestamp_delta_2_ns ( stream_timestamp_diff_t  ts,
size_t  sample_rate 
)

Convert stream timestamp.delta to nanoseconds.

◆ stream_timestamp_diff()

stream_timestamp_diff_t roc::packet::stream_timestamp_diff ( const stream_timestamp_t  a,
const stream_timestamp_t  b 
)
inline

Compute difference between two timestamps.

Definition at line 44 of file units.h.

◆ stream_timestamp_le()

bool roc::packet::stream_timestamp_le ( const stream_timestamp_t  a,
const stream_timestamp_t  b 
)
inline

Check if a is before or equal to b, taking possible wrap into account.

Definition at line 55 of file units.h.

◆ stream_timestamp_lt()

bool roc::packet::stream_timestamp_lt ( const stream_timestamp_t  a,
const stream_timestamp_t  b 
)
inline

Check if a is before b, taking possible wrap into account.

Definition at line 50 of file units.h.

◆ unix_2_ntp()

ntp_timestamp_t roc::packet::unix_2_ntp ( core::nanoseconds_t  unix_time)

Convert Unix absolute time to NTP absolute time.

Remarks
unix_time defines nanoseconds since Unix epoch (should belong to years 1968-2104).