Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
|
Audio frame. More...
#include <frame.h>
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_t * | raw_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... | |
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. |
roc::audio::Frame::Frame | ( | sample_t * | samples, |
size_t | num_samples | ||
) |
Construct frame from raw samples. Flags are set to zero.
roc::audio::Frame::Frame | ( | uint8_t * | bytes, |
size_t | num_bytes | ||
) |
Construct frame from bytes. Flags are set to zero.
uint8_t* roc::audio::Frame::bytes | ( | ) | const |
Get frame data as bytes.
core::nanoseconds_t roc::audio::Frame::capture_timestamp | ( | ) | const |
Get unix-epoch timestamp in ns of the 1st sample.
packet::stream_timestamp_t roc::audio::Frame::duration | ( | ) | const |
Get frame duration in terms of stream timestamps.
unsigned roc::audio::Frame::flags | ( | ) | const |
Get flags.
bool roc::audio::Frame::has_capture_timestamp | ( | ) | const |
Check if capture timestamp is set.
bool roc::audio::Frame::has_duration | ( | ) | const |
Check if duration was set.
bool roc::audio::Frame::is_raw | ( | ) | const |
Check frame data is raw samples. Returns true if FlagAltFormat is not set.
size_t roc::audio::Frame::num_bytes | ( | ) | const |
Get number of bytes in frame.
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().
void roc::audio::Frame::print | ( | ) | const |
Print frame to stderr.
sample_t* roc::audio::Frame::raw_samples | ( | ) | const |
void roc::audio::Frame::set_capture_timestamp | ( | core::nanoseconds_t | capture_ts | ) |
Set unix-epoch timestamp in ns of the 1st sample.
void roc::audio::Frame::set_duration | ( | packet::stream_timestamp_t | duration | ) |
Get frame duration in terms of stream timestamps.
void roc::audio::Frame::set_flags | ( | unsigned | flags | ) |
Set flags.