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

Packet. More...

#include <packet.h>

Inheritance diagram for roc::packet::Packet:
Collaboration diagram for roc::packet::Packet:

Public Types

enum  Flag {
  FlagUDP = (1 << 0) , FlagRTP = (1 << 1) , FlagFEC = (1 << 2) , FlagRTCP = (1 << 3) ,
  FlagAudio = (1 << 4) , FlagRepair = (1 << 5) , FlagControl = (1 << 6) , FlagPrepared = (1 << 7) ,
  FlagComposed = (1 << 8) , FlagRestored = (1 << 9)
}
 Packet flags. More...
 

Public Member Functions

 Packet (core::IPool &packet_pool)
 Constructor. More...
 
void add_flags (unsigned flags)
 Add flags. More...
 
bool has_flags (unsigned flags) const
 Check specific flag. More...
 
unsigned flags () const
 Get flags. More...
 
const UDPudp () const
 UDP packet. More...
 
UDPudp ()
 UDP packet. More...
 
const RTPrtp () const
 RTP packet. More...
 
RTPrtp ()
 RTP packet. More...
 
const FECfec () const
 FEC packet. More...
 
FECfec ()
 FEC packet. More...
 
const RTCPrtcp () const
 RTCP packet. More...
 
RTCPrtcp ()
 RTCP packet. More...
 
const core::Slice< uint8_t > & buffer () const
 Get packet buffer. More...
 
void set_buffer (const core::Slice< uint8_t > &data)
 Set packet buffer. More...
 
const core::Slice< uint8_t > & payload () const
 Get protocol-dependent packet payload. More...
 
bool has_source_id () const
 Check if packet has stream identifier. More...
 
stream_source_t source_id () const
 Get packet stream identifier. More...
 
stream_timestamp_t stream_timestamp () const
 Get stream timestamp (STS) of the packet. More...
 
stream_timestamp_t duration () const
 Get duration of the packet. More...
 
core::nanoseconds_t capture_timestamp () const
 Get capture timestamp (CTS) of the packet. More...
 
core::nanoseconds_t receive_timestamp () const
 Get receive timestamp (RTS) of the packet. More...
 
int compare (const Packet &other) const
 Determine packet ordering. More...
 
void print (int flags) const
 Print packet to stderr. More...
 
- Public Member Functions inherited from roc::core::RefCounted< Packet, core::PoolAllocation >
 RefCounted ()
 Initialize. More...
 
 RefCounted (const core::PoolAllocation &policy)
 Initialize. More...
 
int getref () const
 Get reference counter. More...
 
void incref () const
 Increment reference counter. More...
 
void decref () const
 Decrement reference counter. More...
 
- Public Member Functions inherited from roc::core::ListNode< Tag >
ListDatalist_data () const
 Get pointer to internal data. More...
 
- Public Member Functions inherited from roc::core::MpscQueueNode< Tag >
MpscQueueDatampsc_queue_data () const
 Get pointer to internal data. More...
 

Static Public Member Functions

static Packetcontainer_of (UDP *udp)
 Get pointer to packet from a pointer to its UDP part. More...
 
static size_t approx_size (size_t n_samples)
 Estimate number of bytes per packet for given number of samples. This is only an approximation, don't rely on it. More...
 
- Static Public Member Functions inherited from roc::core::ListNode< Tag >
static ListNodelist_node (ListData *data)
 Get pointer to parent node from pointer to internal data. More...
 
- Static Public Member Functions inherited from roc::core::MpscQueueNode< Tag >
static MpscQueueNodempsc_queue_node (MpscQueueData *data)
 Get pointer to parent node from pointer to internal data. More...
 

Additional Inherited Members

- Protected Member Functions inherited from roc::core::PoolAllocation
IPoolpool () const
 Get pool. More...
 
 PoolAllocation (IPool &pool)
 Initialize. More...
 
template<class T >
void destroy (T &object)
 Destroy object and return memory to pool. More...
 

Detailed Description

Packet.

Definition at line 37 of file packet.h.

Member Enumeration Documentation

◆ Flag

Packet flags.

Enumerator
FlagUDP 

Packet contains UDP header.

FlagRTP 

Packet contains RTP header.

FlagFEC 

Packet contains FEC header.

FlagRTCP 

Packet contains RTCP compound packet.

FlagAudio 

Packet contains audio samples.

FlagRepair 

Packet contains repair FEC symbols.

FlagControl 

Packet contains control message.

FlagPrepared 

Packet was prepared for composing.

FlagComposed 

Packet was composed.

FlagRestored 

Packet was restored using FEC decoder.

Definition at line 45 of file packet.h.

Constructor & Destructor Documentation

◆ Packet()

roc::packet::Packet::Packet ( core::IPool packet_pool)
explicit

Constructor.

Member Function Documentation

◆ add_flags()

void roc::packet::Packet::add_flags ( unsigned  flags)

Add flags.

◆ approx_size()

static size_t roc::packet::Packet::approx_size ( size_t  n_samples)
static

Estimate number of bytes per packet for given number of samples. This is only an approximation, don't rely on it.

◆ buffer()

const core::Slice<uint8_t>& roc::packet::Packet::buffer ( ) const

Get packet buffer.

Remarks
Returns slice with entire packet with all headers and footers.

◆ capture_timestamp()

core::nanoseconds_t roc::packet::Packet::capture_timestamp ( ) const

Get capture timestamp (CTS) of the packet.

Remarks
Returns number of nanoseconds since Unix epoch.

◆ compare()

int roc::packet::Packet::compare ( const Packet other) const

Determine packet ordering.

Returns
  • -1 if this packet precedes other packet
  • 0 if this packet has the same position as other packet
  • +1 if this packet succeeds other packet

◆ container_of()

static Packet* roc::packet::Packet::container_of ( UDP udp)
inlinestatic

Get pointer to packet from a pointer to its UDP part.

Definition at line 152 of file packet.h.

◆ duration()

stream_timestamp_t roc::packet::Packet::duration ( ) const

Get duration of the packet.

Remarks
Units are the same as for stream_timestamp().

◆ fec() [1/2]

FEC* roc::packet::Packet::fec ( )

FEC packet.

◆ fec() [2/2]

const FEC* roc::packet::Packet::fec ( ) const

FEC packet.

◆ flags()

unsigned roc::packet::Packet::flags ( ) const

Get flags.

◆ has_flags()

bool roc::packet::Packet::has_flags ( unsigned  flags) const

Check specific flag.

◆ has_source_id()

bool roc::packet::Packet::has_source_id ( ) const

Check if packet has stream identifier.

Remarks
The returning value depends on packet type. If this method returns true, then source_id() returns stream identifier.

◆ payload()

const core::Slice<uint8_t>& roc::packet::Packet::payload ( ) const

Get protocol-dependent packet payload.

Remarks
Returns sub-slice with inner-most packet data. E.g. for RTP nested into FECFRAME, returns payload of RTP packet (where samples are stored).

◆ print()

void roc::packet::Packet::print ( int  flags) const
inline

Print packet to stderr.

Definition at line 147 of file packet.h.

◆ receive_timestamp()

core::nanoseconds_t roc::packet::Packet::receive_timestamp ( ) const

Get receive timestamp (RTS) of the packet.

Remarks
Returns number of nanoseconds since Unix epoch.

◆ rtcp() [1/2]

RTCP* roc::packet::Packet::rtcp ( )

RTCP packet.

◆ rtcp() [2/2]

const RTCP* roc::packet::Packet::rtcp ( ) const

RTCP packet.

◆ rtp() [1/2]

RTP* roc::packet::Packet::rtp ( )

RTP packet.

◆ rtp() [2/2]

const RTP* roc::packet::Packet::rtp ( ) const

RTP packet.

◆ set_buffer()

void roc::packet::Packet::set_buffer ( const core::Slice< uint8_t > &  data)

Set packet buffer.

◆ source_id()

stream_source_t roc::packet::Packet::source_id ( ) const

Get packet stream identifier.

Remarks
The returning value depends on packet type. For some packet types, may be always zero.

◆ stream_timestamp()

stream_timestamp_t roc::packet::Packet::stream_timestamp ( ) const

Get stream timestamp (STS) of the packet.

Remarks
Timestamp units depend on packet type. For some packet types, may be always zero.

◆ udp() [1/2]

UDP* roc::packet::Packet::udp ( )

UDP packet.

◆ udp() [2/2]

const UDP* roc::packet::Packet::udp ( ) const

UDP packet.


The documentation for this class was generated from the following file: