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

Audio frame. More...

#include <frame.h>

Inheritance diagram for roc::audio::Frame:
Collaboration diagram for roc::audio::Frame:

Public Types

enum  { FlagNotRaw = (1 << 0) , FlagNotBlank = (1 << 1) , FlagNotComplete = (1 << 2) , FlagPacketDrops = (1 << 3) }
 Frame flags. Flags are designed the way so that if you combine multiple frames into one, (concatenate or mix), bitwise OR of their flags will give flags for resulting frame. E.g., if at least one frame was non-blank, combined frame will be non-blank, if at least one frame was incomplete, combined frame will be incomplete, etc. More...
 

Public Member Functions

 Frame (sample_t *samples, size_t num_samples)
 Construct frame from raw samples. Flags are set to zero. More...
 
 Frame (uint8_t *bytes, size_t num_bytes)
 Construct frame from bytes. Flags are set to zero. More...
 
unsigned flags () const
 Get flags. More...
 
void set_flags (unsigned flags)
 Set flags. More...
 
bool is_raw () const
 Check frame data is raw samples. Returns true if FlagAltFormat is not set. More...
 
sample_traw_samples () const
 Get frame data as raw samples. May be used only if is_raw() is true, otherwise use bytes(). More...
 
size_t num_raw_samples () const
 Get number of raw samples in frame, May be used only if is_raw() is true, otherwise use num_bytes(). More...
 
uint8_t * bytes () const
 Get frame data as bytes. More...
 
size_t num_bytes () const
 Get number of bytes in frame. More...
 
bool has_duration () const
 Check if duration was set. More...
 
packet::stream_timestamp_t duration () const
 Get frame duration in terms of stream timestamps. More...
 
void set_duration (packet::stream_timestamp_t duration)
 Get frame duration in terms of stream timestamps. More...
 
bool has_capture_timestamp () const
 Check if capture timestamp is set. More...
 
core::nanoseconds_t capture_timestamp () const
 Get unix-epoch timestamp in ns of the 1st sample. More...
 
void set_capture_timestamp (core::nanoseconds_t capture_ts)
 Set unix-epoch timestamp in ns of the 1st sample. More...
 
void print () const
 Print frame to stderr. More...
 

Detailed Description

Audio frame.

Definition at line 25 of file frame.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

Frame flags. Flags are designed the way so that if you combine multiple frames into one, (concatenate or mix), bitwise OR of their flags will give flags for resulting frame. E.g., if at least one frame was non-blank, combined frame will be non-blank, if at least one frame was incomplete, combined frame will be incomplete, etc.

Enumerator
FlagNotRaw 

Set if the frame has format different from raw samples. If this flag is set, only bytes() can be used, and raw_samples() panics.

FlagNotBlank 

Set if the frame has at least some samples from packets. If this flag is clear, frame is completely zero because of lack of packets.

FlagNotComplete 

Set if the frame is not fully filled with samples from packets. If this flag is set, frame is partially zero because of lack of packets.

FlagPacketDrops 

Set if some late packets were dropped while the frame was being built. It's not necessarily that the frame itself is blank or incomplete.

Definition at line 41 of file frame.h.

Constructor & Destructor Documentation

◆ Frame() [1/2]

roc::audio::Frame::Frame ( sample_t samples,
size_t  num_samples 
)

Construct frame from raw samples. Flags are set to zero.

◆ Frame() [2/2]

roc::audio::Frame::Frame ( uint8_t *  bytes,
size_t  num_bytes 
)

Construct frame from bytes. Flags are set to zero.

Member Function Documentation

◆ bytes()

uint8_t* roc::audio::Frame::bytes ( ) const

Get frame data as bytes.

◆ capture_timestamp()

core::nanoseconds_t roc::audio::Frame::capture_timestamp ( ) const

Get unix-epoch timestamp in ns of the 1st sample.

◆ duration()

packet::stream_timestamp_t roc::audio::Frame::duration ( ) const

Get frame duration in terms of stream timestamps.

◆ flags()

unsigned roc::audio::Frame::flags ( ) const

Get flags.

◆ has_capture_timestamp()

bool roc::audio::Frame::has_capture_timestamp ( ) const

Check if capture timestamp is set.

◆ has_duration()

bool roc::audio::Frame::has_duration ( ) const

Check if duration was set.

◆ is_raw()

bool roc::audio::Frame::is_raw ( ) const

Check frame data is raw samples. Returns true if FlagAltFormat is not set.

◆ num_bytes()

size_t roc::audio::Frame::num_bytes ( ) const

Get number of bytes in frame.

◆ num_raw_samples()

size_t roc::audio::Frame::num_raw_samples ( ) const

Get number of raw samples in frame, May be used only if is_raw() is true, otherwise use num_bytes().

◆ print()

void roc::audio::Frame::print ( ) const

Print frame to stderr.

◆ raw_samples()

sample_t* roc::audio::Frame::raw_samples ( ) const

Get frame data as raw samples. May be used only if is_raw() is true, otherwise use bytes().

◆ set_capture_timestamp()

void roc::audio::Frame::set_capture_timestamp ( core::nanoseconds_t  capture_ts)

Set unix-epoch timestamp in ns of the 1st sample.

◆ set_duration()

void roc::audio::Frame::set_duration ( packet::stream_timestamp_t  duration)

Get frame duration in terms of stream timestamps.

◆ set_flags()

void roc::audio::Frame::set_flags ( unsigned  flags)

Set flags.


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