libivon 0.1.0
Voice-over-IP library
Loading...
Searching...
No Matches
ivon::IAudio Class Referenceabstract

Pure virtual interface for the libivon audio processor. More...

#include <ivon_audio_interface.hpp>

Inheritance diagram for ivon::IAudio:
ivon::AudioWrapper

Public Types

using SpeakingEventCallback = std::function< void(const ivon_speaking_event_t &event)>
 
using PreDspCallback = std::function< ivon_dsp_action_t(ivon_pre_dsp_context_t &ctx)>
 
using PostSpatialCallback = std::function< ivon_dsp_action_t(ivon_post_spatial_context_t &ctx)>
 
using PostMixCallback = std::function< ivon_dsp_action_t(ivon_post_mix_context_t &ctx)>
 

Public Member Functions

virtual ~IAudio ()=default
 
virtual void start ()=0
 Start the audio processor (tick coordinator + worker threads).
 
virtual void stop ()=0
 Stop the audio processor and all worker threads.
 
virtual bool is_running () const noexcept=0
 Check if the audio processor is currently running.
 
virtual bool submit_packet (uint64_t sender_id, const unsigned char *data, size_t len)=0
 Submit a received audio packet for decoding.
 
virtual bool submit_packet (uint64_t sender_id, uint64_t group_id, const unsigned char *data, size_t len)=0
 Submit a received audio packet with a group tag.
 
virtual AudioOutputFrame try_read_output (float *pcm_out, size_t max_samples)=0
 Try to read a mixed output frame (non-blocking, zero-copy path).
 
virtual void set_pcm_source (PcmSourceCallback cb)=0
 Set the PCM source callback for local audio capture.
 
virtual void start_speaking (ivon_speaking_mode_t mode=IVON_SPEAKING_MODE_PTT)=0
 Start speaking (PTT activated). The PCM source callback will begin firing.
 
virtual void stop_speaking ()=0
 Stop speaking. The PCM source callback will stop firing.
 
virtual bool is_speaking () const noexcept=0
 Check if currently speaking (transmitting audio).
 
virtual size_t try_read_packet (unsigned char *data_out, size_t max_len)=0
 Try to read an encoded packet for transmission (non-blocking).
 
virtual void on_speaking_event (SpeakingEventCallback cb)=0
 Set callback for remote speaking state changes (start/stop).
 
virtual void on_pre_dsp (PreDspCallback cb)=0
 Set pre-DSP callback invoked per sender before spatial processing.
 
virtual void on_post_spatial (PostSpatialCallback cb)=0
 Set post-spatial callback invoked per sender after spatial processing.
 
virtual void on_post_mix (PostMixCallback cb)=0
 Set post-mix callback invoked on the final mixed output frame.
 
virtual void set_sender_gain (uint64_t sender_id, float gain)=0
 Set per-sender gain (1.0 = unity, 0.0 = silence).
 
virtual void set_sender_muted (uint64_t sender_id, bool muted)=0
 Mute or unmute a sender. Muted senders are excluded from the mix.
 
virtual int pcm_frame_size () const noexcept=0
 Get the PCM frame size in samples per channel.
 
virtual int output_channels () const noexcept=0
 Get the number of output channels (e.g. 1 = mono, 2 = stereo).
 
virtual uint64_t current_tick () const noexcept=0
 Get the current tick counter (incremented once per audio frame).
 
virtual int64_t max_drift_us () const noexcept=0
 Get the maximum clock drift in microseconds since the last reset.
 
virtual uint64_t dropped_ticks () const noexcept=0
 Get the total number of dropped (late) ticks.
 
virtual ivon_audio_stats_t get_stats () const noexcept=0
 Get an aggregate statistics snapshot (decoder, encoder, pipeline counters).
 

Detailed Description

Pure virtual interface for the libivon audio processor.

Every method here must have a corresponding C ABI function in ivon_audio.h and a wrapper in ivon_audio_wrapper.hpp. Adding a new pure virtual here will cause a compile error in any class that inherits IAudio but hasn't implemented the new method, ensuring the C ABI stays synchronized with the C++ API.

Member Typedef Documentation

◆ PostMixCallback

◆ PostSpatialCallback

◆ PreDspCallback

◆ SpeakingEventCallback

using ivon::IAudio::SpeakingEventCallback = std::function<void(const ivon_speaking_event_t &event)>

Constructor & Destructor Documentation

◆ ~IAudio()

virtual ivon::IAudio::~IAudio ( )
virtualdefault

Member Function Documentation

◆ current_tick()

virtual uint64_t ivon::IAudio::current_tick ( ) const
pure virtualnoexcept

Get the current tick counter (incremented once per audio frame).

Implemented in ivon::AudioWrapper.

◆ dropped_ticks()

virtual uint64_t ivon::IAudio::dropped_ticks ( ) const
pure virtualnoexcept

Get the total number of dropped (late) ticks.

Implemented in ivon::AudioWrapper.

◆ get_stats()

virtual ivon_audio_stats_t ivon::IAudio::get_stats ( ) const
pure virtualnoexcept

Get an aggregate statistics snapshot (decoder, encoder, pipeline counters).

Implemented in ivon::AudioWrapper.

◆ is_running()

virtual bool ivon::IAudio::is_running ( ) const
pure virtualnoexcept

Check if the audio processor is currently running.

Implemented in ivon::AudioWrapper.

◆ is_speaking()

virtual bool ivon::IAudio::is_speaking ( ) const
pure virtualnoexcept

Check if currently speaking (transmitting audio).

Implemented in ivon::AudioWrapper.

◆ max_drift_us()

virtual int64_t ivon::IAudio::max_drift_us ( ) const
pure virtualnoexcept

Get the maximum clock drift in microseconds since the last reset.

Implemented in ivon::AudioWrapper.

◆ on_post_mix()

virtual void ivon::IAudio::on_post_mix ( PostMixCallback  cb)
pure virtual

Set post-mix callback invoked on the final mixed output frame.

Implemented in ivon::AudioWrapper.

◆ on_post_spatial()

virtual void ivon::IAudio::on_post_spatial ( PostSpatialCallback  cb)
pure virtual

Set post-spatial callback invoked per sender after spatial processing.

Implemented in ivon::AudioWrapper.

◆ on_pre_dsp()

virtual void ivon::IAudio::on_pre_dsp ( PreDspCallback  cb)
pure virtual

Set pre-DSP callback invoked per sender before spatial processing.

Implemented in ivon::AudioWrapper.

◆ on_speaking_event()

virtual void ivon::IAudio::on_speaking_event ( SpeakingEventCallback  cb)
pure virtual

Set callback for remote speaking state changes (start/stop).

Implemented in ivon::AudioWrapper.

◆ output_channels()

virtual int ivon::IAudio::output_channels ( ) const
pure virtualnoexcept

Get the number of output channels (e.g. 1 = mono, 2 = stereo).

Implemented in ivon::AudioWrapper.

◆ pcm_frame_size()

virtual int ivon::IAudio::pcm_frame_size ( ) const
pure virtualnoexcept

Get the PCM frame size in samples per channel.

Implemented in ivon::AudioWrapper.

◆ set_pcm_source()

virtual void ivon::IAudio::set_pcm_source ( PcmSourceCallback  cb)
pure virtual

Set the PCM source callback for local audio capture.

Implemented in ivon::AudioWrapper.

◆ set_sender_gain()

virtual void ivon::IAudio::set_sender_gain ( uint64_t  sender_id,
float  gain 
)
pure virtual

Set per-sender gain (1.0 = unity, 0.0 = silence).

Implemented in ivon::AudioWrapper.

◆ set_sender_muted()

virtual void ivon::IAudio::set_sender_muted ( uint64_t  sender_id,
bool  muted 
)
pure virtual

Mute or unmute a sender. Muted senders are excluded from the mix.

Implemented in ivon::AudioWrapper.

◆ start()

virtual void ivon::IAudio::start ( )
pure virtual

Start the audio processor (tick coordinator + worker threads).

Implemented in ivon::AudioWrapper.

◆ start_speaking()

virtual void ivon::IAudio::start_speaking ( ivon_speaking_mode_t  mode = IVON_SPEAKING_MODE_PTT)
pure virtual

Start speaking (PTT activated). The PCM source callback will begin firing.

Implemented in ivon::AudioWrapper.

◆ stop()

virtual void ivon::IAudio::stop ( )
pure virtual

Stop the audio processor and all worker threads.

Implemented in ivon::AudioWrapper.

◆ stop_speaking()

virtual void ivon::IAudio::stop_speaking ( )
pure virtual

Stop speaking. The PCM source callback will stop firing.

Implemented in ivon::AudioWrapper.

◆ submit_packet() [1/2]

virtual bool ivon::IAudio::submit_packet ( uint64_t  sender_id,
const unsigned char *  data,
size_t  len 
)
pure virtual

Submit a received audio packet for decoding.

Parameters
sender_idUnique identifier for the remote sender.
dataEncoded audio payload bytes.
lenLength of the payload in bytes.
Returns
true if the packet was accepted.

Implemented in ivon::AudioWrapper.

◆ submit_packet() [2/2]

virtual bool ivon::IAudio::submit_packet ( uint64_t  sender_id,
uint64_t  group_id,
const unsigned char *  data,
size_t  len 
)
pure virtual

Submit a received audio packet with a group tag.

Parameters
sender_idUnique identifier for the remote sender.
group_idGroup the packet belongs to (0 = untagged).
dataEncoded audio payload bytes.
lenLength of the payload in bytes.
Returns
true if the packet was accepted.

Implemented in ivon::AudioWrapper.

◆ try_read_output()

virtual AudioOutputFrame ivon::IAudio::try_read_output ( float *  pcm_out,
size_t  max_samples 
)
pure virtual

Try to read a mixed output frame (non-blocking, zero-copy path).

Parameters
pcm_outBuffer for interleaved float PCM samples.
max_samplesMaximum number of float samples the buffer can hold.
Returns
AudioOutputFrame descriptor — check .valid before using the data.

Implemented in ivon::AudioWrapper.

◆ try_read_packet()

virtual size_t ivon::IAudio::try_read_packet ( unsigned char *  data_out,
size_t  max_len 
)
pure virtual

Try to read an encoded packet for transmission (non-blocking).

Parameters
data_outBuffer for encoded bytes.
max_lenMaximum bytes the buffer can hold.
Returns
Number of bytes written, or 0 if no packet is available.

Implemented in ivon::AudioWrapper.


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