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...
 
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  IWriter
 Packet writer interface. More...
 
class  Packet
 Packet. More...
 
class  PacketFactory
 Packet factory. More...
 
class  Queue
 Packet queue. More...
 
class  Router
 Route packets to 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 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  { 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...
 
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...
 
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 96 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 91 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 33 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 69 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 64 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
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 99 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 109 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 104 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)

◆ 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 72 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 82 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 77 of file units.h.

◆ 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).