|
libivon 0.1.0
Voice-over-IP library
|
Macros | |
| #define | IVON_AUDIO_API_VERSION_MAJOR 1 |
| C ABI for the libivon audio processor. | |
| #define | IVON_AUDIO_API_VERSION_MINOR 0 |
| Minor version of the audio C ABI (bump on additive changes). | |
Log level constants (same values across all ivon subsystems). | |
| #define | IVON_LOG_LEVEL_TRACE 0 |
| #define | IVON_LOG_LEVEL_DEBUG 1 |
| #define | IVON_LOG_LEVEL_INFO 2 |
| #define | IVON_LOG_LEVEL_WARN 3 |
| #define | IVON_LOG_LEVEL_ERROR 4 |
| #define | IVON_LOG_LEVEL_CRITICAL 5 |
| #define | IVON_LOG_LEVEL_OFF 6 |
Functions | |
| int | ivon_audio_api_version_major (void) |
| Get the major version of the audio C ABI at runtime. | |
| int | ivon_audio_api_version_minor (void) |
| Get the minor version of the audio C ABI at runtime. | |
| ivon_audio_config_t | ivon_audio_config_create (void) |
| Create a new audio configuration with sane defaults. | |
| void | ivon_audio_config_destroy (ivon_audio_config_t config) |
| Destroy an audio configuration handle. NULL is a safe no-op. | |
| void | ivon_audio_config_set_frame_duration (ivon_audio_config_t config, ivon_frame_duration_t duration) |
| Set the codec frame duration. | |
| void | ivon_audio_config_set_codec_sample_rate (ivon_audio_config_t config, ivon_codec_sample_rate_t rate) |
| Set the codec sample rate. | |
| void | ivon_audio_config_set_packet_pool_chunks (ivon_audio_config_t config, uint32_t chunks) |
| Set packet pool chunk count (each chunk = 1024 buffers). | |
| void | ivon_audio_config_set_frame_pool_chunks (ivon_audio_config_t config, uint32_t chunks) |
| Set frame pool chunk count (each chunk = 256 frames). | |
| void | ivon_audio_config_set_decoder_workers (ivon_audio_config_t config, uint8_t workers) |
| Set the number of decoder worker threads. | |
| void | ivon_audio_config_set_pipeline_workers (ivon_audio_config_t config, uint8_t workers) |
| Set the number of pipeline worker threads. | |
| void | ivon_audio_config_set_output_channels (ivon_audio_config_t config, uint8_t channels) |
| Set output channel count: 1 = mono, 2 = stereo. | |
| void | ivon_audio_config_set_output_buffer_frames (ivon_audio_config_t config, uint32_t frames) |
| Set output ring buffer size in frames. | |
| void | ivon_audio_config_set_jitter_depth (ivon_audio_config_t config, uint32_t depth) |
| Set jitter buffer depth in frames (0 = bypass). | |
| void | ivon_audio_config_set_encoder_bitrate (ivon_audio_config_t config, uint32_t bitrate) |
| Set Opus encoder target bitrate in bits/sec. | |
| void | ivon_audio_config_set_encoder_fec (ivon_audio_config_t config, int fec) |
| Enable/disable Opus in-band FEC (1 = on, 0 = off). | |
| void | ivon_audio_config_set_encoder_fec_loss_percent (ivon_audio_config_t config, int percent) |
| Set expected packet loss percentage hint for FEC. | |
| void | ivon_audio_config_set_encoder_complexity (ivon_audio_config_t config, int complexity) |
| Set Opus encoder complexity 0–10. | |
| ivon_audio_t | ivon_audio_create (ivon_audio_config_t config) |
| Create a new audio processor instance. | |
| void | ivon_audio_destroy (ivon_audio_t audio) |
| Destroy an audio processor and free all resources. | |
| void | ivon_audio_start (ivon_audio_t audio) |
| Start the audio processor (tick coordinator + worker threads). | |
| void | ivon_audio_stop (ivon_audio_t audio) |
| Stop the audio processor. | |
| int | ivon_audio_is_running (ivon_audio_t audio) |
| Check if the processor is running. | |
| int | ivon_audio_frame_size (ivon_audio_t audio) |
| Get the PCM frame size (samples per channel per frame). | |
| int | ivon_audio_output_channels (ivon_audio_t audio) |
| Get the output channel count. | |
| int | ivon_audio_submit_packet (ivon_audio_t audio, uint64_t sender_id, const unsigned char *data, size_t data_len) |
| Submit a received audio packet for decoding (copy-in). | |
| int | ivon_audio_submit_packet_ex (ivon_audio_t audio, uint64_t sender_id, uint64_t group_id, const unsigned char *data, size_t data_len) |
| Submit a received audio packet with a group tag. | |
| ivon_audio_output_frame_t | ivon_audio_try_read_output (ivon_audio_t audio, float *pcm_out, size_t max_samples) |
| Try to read a mixed output frame (copy-out). | |
| ivon_packet_buffer_t | ivon_audio_acquire_packet_buffer (ivon_audio_t audio) |
| Acquire a packet buffer from the audio processor's pool. | |
| unsigned char * | ivon_packet_buffer_data (ivon_packet_buffer_t buf) |
| Get writable pointer to the packet buffer data. | |
| const unsigned char * | ivon_packet_buffer_data_const (ivon_packet_buffer_t buf) |
| Get read-only pointer to the packet buffer data. | |
| size_t | ivon_packet_buffer_capacity (ivon_packet_buffer_t buf) |
| Get the maximum capacity of a packet buffer in bytes. | |
| void | ivon_packet_buffer_set_length (ivon_packet_buffer_t buf, size_t length) |
| Set the number of valid bytes in the buffer. | |
| size_t | ivon_packet_buffer_length (ivon_packet_buffer_t buf) |
| Get the number of valid bytes in the buffer. | |
| void | ivon_packet_buffer_release (ivon_packet_buffer_t buf) |
| Release a packet buffer back to the pool. | |
| int | ivon_audio_submit_packet_zero_copy (ivon_audio_t audio, ivon_packet_buffer_t buf, uint64_t sender_id) |
| Submit a packet buffer for decoding (zero-copy). | |
| int | ivon_audio_submit_packet_zero_copy_ex (ivon_audio_t audio, ivon_packet_buffer_t buf, uint64_t sender_id, uint64_t group_id) |
| Submit a packet buffer with group tag (zero-copy). | |
| ivon_packet_buffer_t | ivon_audio_try_read_packet_zero_copy (ivon_audio_t audio) |
| Try to read an encoded packet for transmission (zero-copy). | |
| void | ivon_audio_set_pcm_source (ivon_audio_t audio, ivon_audio_pcm_source_fn callback, void *user_data) |
| Set the PCM source callback for local audio capture. | |
| void | ivon_audio_start_speaking (ivon_audio_t audio, ivon_speaking_mode_t mode) |
| Start speaking (PTT activated). | |
| void | ivon_audio_stop_speaking (ivon_audio_t audio) |
| Stop speaking (PTT released). | |
| int | ivon_audio_is_speaking (ivon_audio_t audio) |
| Check if currently speaking. | |
| size_t | ivon_audio_try_read_packet (ivon_audio_t audio, unsigned char *data_out, size_t max_len) |
| Try to read an encoded packet for transmission (copy-out). | |
| void | ivon_audio_set_on_speaking_event (ivon_audio_t audio, ivon_audio_speaking_event_fn callback, void *user_data) |
| Set the speaking event callback. | |
| void | ivon_audio_set_on_pre_dsp (ivon_audio_t audio, ivon_audio_pre_dsp_fn callback, void *user_data) |
| Set the pre-DSP callback (mono per-sender, after decode). | |
| void | ivon_audio_set_on_post_spatial (ivon_audio_t audio, ivon_audio_post_spatial_fn callback, void *user_data) |
| Set the post-spatial callback (expanded per-sender, after channel expansion). | |
| void | ivon_audio_set_on_post_mix (ivon_audio_t audio, ivon_audio_post_mix_fn callback, void *user_data) |
| Set the post-mix callback (final mixed output). | |
| void | ivon_audio_set_sender_gain (ivon_audio_t audio, uint64_t sender_id, float gain) |
| Set per-sender gain (linear scale). | |
| void | ivon_audio_set_sender_muted (ivon_audio_t audio, uint64_t sender_id, int muted) |
| Mute or unmute a sender. | |
| uint64_t | ivon_audio_current_tick (ivon_audio_t audio) |
| Get the current tick number. | |
| int64_t | ivon_audio_max_drift_us (ivon_audio_t audio) |
| Get the maximum clock drift in microseconds. | |
| uint64_t | ivon_audio_dropped_ticks (ivon_audio_t audio) |
| Get the number of dropped ticks. | |
| void | ivon_audio_get_stats (ivon_audio_t audio, ivon_audio_stats_t *out) |
| Get aggregate statistics snapshot. | |
| void | ivon_audio_set_log_level (ivon_audio_t audio, int level) |
| Set the audio processor's log level at runtime. | |
| int | ivon_audio_get_log_level (ivon_audio_t audio) |
| Get the audio processor's current log level. | |
| #define IVON_AUDIO_API_VERSION_MAJOR 1 |
C ABI for the libivon audio processor.
All functions use the opaque ivon_audio_t handle and plain C types. Symbols are exported via IDI_IVON_EXPORT when building the shared library.
The audio processor provides:
Major version of the audio C ABI (bump on breaking changes).
| #define IVON_AUDIO_API_VERSION_MINOR 0 |
Minor version of the audio C ABI (bump on additive changes).
| #define IVON_LOG_LEVEL_CRITICAL 5 |
| #define IVON_LOG_LEVEL_DEBUG 1 |
| #define IVON_LOG_LEVEL_ERROR 4 |
| #define IVON_LOG_LEVEL_INFO 2 |
| #define IVON_LOG_LEVEL_OFF 6 |
| #define IVON_LOG_LEVEL_TRACE 0 |
| #define IVON_LOG_LEVEL_WARN 3 |
| ivon_packet_buffer_t ivon_audio_acquire_packet_buffer | ( | ivon_audio_t | audio | ) |
Acquire a packet buffer from the audio processor's pool.
| audio | The audio handle. |
| int ivon_audio_api_version_major | ( | void | ) |
Get the major version of the audio C ABI at runtime.
| int ivon_audio_api_version_minor | ( | void | ) |
Get the minor version of the audio C ABI at runtime.
| ivon_audio_config_t ivon_audio_config_create | ( | void | ) |
Create a new audio configuration with sane defaults.
Defaults: 20 ms frames, 48 kHz, 2 decoder/pipeline workers, 2 output channels, jitter depth 2, 64 kbps Opus, FEC on.
Call ivon_audio_config_set_*() to customise, then pass to ivon_audio_create(). Destroy with ivon_audio_config_destroy() after creation (the processor copies what it needs).
| void ivon_audio_config_destroy | ( | ivon_audio_config_t | config | ) |
Destroy an audio configuration handle. NULL is a safe no-op.
| void ivon_audio_config_set_codec_sample_rate | ( | ivon_audio_config_t | config, |
| ivon_codec_sample_rate_t | rate | ||
| ) |
Set the codec sample rate.
| void ivon_audio_config_set_decoder_workers | ( | ivon_audio_config_t | config, |
| uint8_t | workers | ||
| ) |
Set the number of decoder worker threads.
| void ivon_audio_config_set_encoder_bitrate | ( | ivon_audio_config_t | config, |
| uint32_t | bitrate | ||
| ) |
Set Opus encoder target bitrate in bits/sec.
| void ivon_audio_config_set_encoder_complexity | ( | ivon_audio_config_t | config, |
| int | complexity | ||
| ) |
Set Opus encoder complexity 0–10.
| void ivon_audio_config_set_encoder_fec | ( | ivon_audio_config_t | config, |
| int | fec | ||
| ) |
Enable/disable Opus in-band FEC (1 = on, 0 = off).
| void ivon_audio_config_set_encoder_fec_loss_percent | ( | ivon_audio_config_t | config, |
| int | percent | ||
| ) |
Set expected packet loss percentage hint for FEC.
| void ivon_audio_config_set_frame_duration | ( | ivon_audio_config_t | config, |
| ivon_frame_duration_t | duration | ||
| ) |
Set the codec frame duration.
| void ivon_audio_config_set_frame_pool_chunks | ( | ivon_audio_config_t | config, |
| uint32_t | chunks | ||
| ) |
Set frame pool chunk count (each chunk = 256 frames).
| void ivon_audio_config_set_jitter_depth | ( | ivon_audio_config_t | config, |
| uint32_t | depth | ||
| ) |
Set jitter buffer depth in frames (0 = bypass).
| void ivon_audio_config_set_output_buffer_frames | ( | ivon_audio_config_t | config, |
| uint32_t | frames | ||
| ) |
Set output ring buffer size in frames.
| void ivon_audio_config_set_output_channels | ( | ivon_audio_config_t | config, |
| uint8_t | channels | ||
| ) |
Set output channel count: 1 = mono, 2 = stereo.
| void ivon_audio_config_set_packet_pool_chunks | ( | ivon_audio_config_t | config, |
| uint32_t | chunks | ||
| ) |
Set packet pool chunk count (each chunk = 1024 buffers).
| void ivon_audio_config_set_pipeline_workers | ( | ivon_audio_config_t | config, |
| uint8_t | workers | ||
| ) |
Set the number of pipeline worker threads.
| ivon_audio_t ivon_audio_create | ( | ivon_audio_config_t | config | ) |
Create a new audio processor instance.
| config | Audio configuration from ivon_audio_config_create(), or NULL for all-defaults. |
| uint64_t ivon_audio_current_tick | ( | ivon_audio_t | audio | ) |
Get the current tick number.
| void ivon_audio_destroy | ( | ivon_audio_t | audio | ) |
Destroy an audio processor and free all resources.
Stops the processor if still running, then frees all resources. Passing NULL is a safe no-op.
| uint64_t ivon_audio_dropped_ticks | ( | ivon_audio_t | audio | ) |
Get the number of dropped ticks.
| int ivon_audio_frame_size | ( | ivon_audio_t | audio | ) |
Get the PCM frame size (samples per channel per frame).
Returns the actual frame size after server property overrides have been applied. For example: 480 for 10 ms frames, 960 for 20 ms at 48 kHz. Returns 0 if audio is NULL.
| int ivon_audio_get_log_level | ( | ivon_audio_t | audio | ) |
Get the audio processor's current log level.
| audio | The audio handle. |
| void ivon_audio_get_stats | ( | ivon_audio_t | audio, |
| ivon_audio_stats_t * | out | ||
| ) |
Get aggregate statistics snapshot.
Fills the provided struct with current counters from the decoder, encoder, and pipeline. Values are approximate while running (worker threads update them without full synchronisation).
| audio | The audio processor handle. |
| out | Pointer to a stats struct to fill. Zeroed first. |
| int ivon_audio_is_running | ( | ivon_audio_t | audio | ) |
Check if the processor is running.
| int ivon_audio_is_speaking | ( | ivon_audio_t | audio | ) |
Check if currently speaking.
| int64_t ivon_audio_max_drift_us | ( | ivon_audio_t | audio | ) |
Get the maximum clock drift in microseconds.
| int ivon_audio_output_channels | ( | ivon_audio_t | audio | ) |
Get the output channel count.
Returns the number of interleaved output channels (e.g. 2 for stereo). Returns 0 if audio is NULL.
| void ivon_audio_set_log_level | ( | ivon_audio_t | audio, |
| int | level | ||
| ) |
Set the audio processor's log level at runtime.
| audio | The audio handle. |
| level | One of the IVON_LOG_LEVEL_* constants (0–6). |
| void ivon_audio_set_on_post_mix | ( | ivon_audio_t | audio, |
| ivon_audio_post_mix_fn | callback, | ||
| void * | user_data | ||
| ) |
Set the post-mix callback (final mixed output).
| void ivon_audio_set_on_post_spatial | ( | ivon_audio_t | audio, |
| ivon_audio_post_spatial_fn | callback, | ||
| void * | user_data | ||
| ) |
Set the post-spatial callback (expanded per-sender, after channel expansion).
| void ivon_audio_set_on_pre_dsp | ( | ivon_audio_t | audio, |
| ivon_audio_pre_dsp_fn | callback, | ||
| void * | user_data | ||
| ) |
Set the pre-DSP callback (mono per-sender, after decode).
| void ivon_audio_set_on_speaking_event | ( | ivon_audio_t | audio, |
| ivon_audio_speaking_event_fn | callback, | ||
| void * | user_data | ||
| ) |
Set the speaking event callback.
Fired from decoder worker threads when a remote sender starts or stops speaking. Must be thread-safe and non-blocking.
| void ivon_audio_set_pcm_source | ( | ivon_audio_t | audio, |
| ivon_audio_pcm_source_fn | callback, | ||
| void * | user_data | ||
| ) |
Set the PCM source callback for local audio capture.
Called every 20 ms while speaking. Must be set before start().
| audio | The audio handle. |
| callback | PCM source function, or NULL to clear. |
| user_data | Passed through to the callback. |
| void ivon_audio_set_sender_gain | ( | ivon_audio_t | audio, |
| uint64_t | sender_id, | ||
| float | gain | ||
| ) |
Set per-sender gain (linear scale).
Applied to mono PCM before DSP callbacks.
| audio | The audio handle. |
| sender_id | Sender to adjust. |
| gain | Linear gain factor (1.0 = unity, 0.0 = silence). |
| void ivon_audio_set_sender_muted | ( | ivon_audio_t | audio, |
| uint64_t | sender_id, | ||
| int | muted | ||
| ) |
Mute or unmute a sender.
Muted senders are not mixed into output.
| audio | The audio handle. |
| sender_id | Sender to mute/unmute. |
| muted | Non-zero to mute, zero to unmute. |
| void ivon_audio_start | ( | ivon_audio_t | audio | ) |
Start the audio processor (tick coordinator + worker threads).
Callbacks (PCM source, speaking event, DSP) must be set before calling.
| void ivon_audio_start_speaking | ( | ivon_audio_t | audio, |
| ivon_speaking_mode_t | mode | ||
| ) |
Start speaking (PTT activated).
| void ivon_audio_stop | ( | ivon_audio_t | audio | ) |
Stop the audio processor.
| void ivon_audio_stop_speaking | ( | ivon_audio_t | audio | ) |
Stop speaking (PTT released).
| int ivon_audio_submit_packet | ( | ivon_audio_t | audio, |
| uint64_t | sender_id, | ||
| const unsigned char * | data, | ||
| size_t | data_len | ||
| ) |
Submit a received audio packet for decoding (copy-in).
The data buffer should contain the raw audio payload (audio header + Opus data) as received from the fanout layer.
| audio | The audio handle. |
| sender_id | Sender ID from the fanout header. |
| data | Audio payload bytes. |
| data_len | Length of the payload in bytes. |
| int ivon_audio_submit_packet_ex | ( | ivon_audio_t | audio, |
| uint64_t | sender_id, | ||
| uint64_t | group_id, | ||
| const unsigned char * | data, | ||
| size_t | data_len | ||
| ) |
Submit a received audio packet with a group tag.
Identical to ivon_audio_submit_packet but carries a group_id that propagates through the DSP pipeline contexts.
| audio | Audio processor handle. |
| sender_id | Unique identifier for the sender. |
| group_id | Group the packet belongs to (0 = untagged). |
| data | Audio payload bytes. |
| data_len | Length of the payload in bytes. |
| int ivon_audio_submit_packet_zero_copy | ( | ivon_audio_t | audio, |
| ivon_packet_buffer_t | buf, | ||
| uint64_t | sender_id | ||
| ) |
Submit a packet buffer for decoding (zero-copy).
Always consumes buf — do NOT call ivon_packet_buffer_release() afterwards. If buf is NULL, this is a no-op returning zero.
| audio | The audio handle. |
| buf | Filled packet buffer (consumed). |
| sender_id | Sender ID from the fanout header. |
| int ivon_audio_submit_packet_zero_copy_ex | ( | ivon_audio_t | audio, |
| ivon_packet_buffer_t | buf, | ||
| uint64_t | sender_id, | ||
| uint64_t | group_id | ||
| ) |
Submit a packet buffer with group tag (zero-copy).
| ivon_audio_output_frame_t ivon_audio_try_read_output | ( | ivon_audio_t | audio, |
| float * | pcm_out, | ||
| size_t | max_samples | ||
| ) |
Try to read a mixed output frame (copy-out).
Copies PCM data into the caller's buffer. The buffer must hold at least IVON_AUDIO_FRAME_SIZE * channels floats.
| audio | The audio handle. |
| pcm_out | Destination buffer for interleaved float PCM. |
| max_samples | Maximum number of float samples the buffer can hold. |
| size_t ivon_audio_try_read_packet | ( | ivon_audio_t | audio, |
| unsigned char * | data_out, | ||
| size_t | max_len | ||
| ) |
Try to read an encoded packet for transmission (copy-out).
Copies the encoded audio data (audio header + Opus) into the caller's buffer. The buffer should be at least 2048 bytes.
| audio | The audio handle. |
| data_out | Destination buffer for encoded packet. |
| max_len | Maximum number of bytes the buffer can hold. |
| ivon_packet_buffer_t ivon_audio_try_read_packet_zero_copy | ( | ivon_audio_t | audio | ) |
Try to read an encoded packet for transmission (zero-copy).
Returns a packet buffer handle that the caller reads via ivon_packet_buffer_data_const() / ivon_packet_buffer_length(), then releases via ivon_packet_buffer_release().
| audio | The audio handle. |
| size_t ivon_packet_buffer_capacity | ( | ivon_packet_buffer_t | buf | ) |
Get the maximum capacity of a packet buffer in bytes.
| buf | The packet buffer handle. |
| unsigned char * ivon_packet_buffer_data | ( | ivon_packet_buffer_t | buf | ) |
Get writable pointer to the packet buffer data.
| buf | The packet buffer handle. |
| const unsigned char * ivon_packet_buffer_data_const | ( | ivon_packet_buffer_t | buf | ) |
Get read-only pointer to the packet buffer data.
| buf | The packet buffer handle. |
| size_t ivon_packet_buffer_length | ( | ivon_packet_buffer_t | buf | ) |
Get the number of valid bytes in the buffer.
| buf | The packet buffer handle. |
| void ivon_packet_buffer_release | ( | ivon_packet_buffer_t | buf | ) |
Release a packet buffer back to the pool.
The buffer is invalid after this call. NULL is a safe no-op.
| buf | The packet buffer handle (may be NULL). |
| void ivon_packet_buffer_set_length | ( | ivon_packet_buffer_t | buf, |
| size_t | length | ||
| ) |
Set the number of valid bytes in the buffer.
Call after filling the buffer and before submitting.
| buf | The packet buffer handle. |
| length | Number of valid bytes (clamped to capacity). |