|
libivon 0.1.0
Voice-over-IP library
|
Consumer-facing C++ wrapper around the voice session C ABI. More...
#include <ivon_voice_session_wrapper.hpp>
Classes | |
| struct | Config |
| Combined configuration for the voice session. More... | |
| struct | SpeakingInfo |
| Speaking state change with client ID mapping. More... | |
Public Types | |
| using | OutputFrame = AudioOutputFrame |
| Structured output frame info returned by try_read_output(). | |
| using | PcmSourceCallback = ::ivon::PcmSourceCallback |
| Set the PCM source callback for local audio capture. | |
| using | VoiceJoinedCallback = std::function< void(const std::string &group_id, bool success, const std::string &error_message)> |
| using | SpeakingCallback = std::function< void(const SpeakingInfo &info)> |
| using | VoiceErrorCallback = std::function< void(const std::string &group_id, const std::string &error_message)> |
| using | MemberJoinedCallback = std::function< void(const std::string &group_id, uint64_t sender_id, const std::string &client_id)> |
| using | MemberLeftCallback = std::function< void(const std::string &group_id, uint64_t sender_id, const std::string &client_id)> |
Public Member Functions | |
| VoiceSessionWrapper (const Config &cfg) | |
| Construct a wrapper and create the underlying voice session. | |
| ~VoiceSessionWrapper () | |
| VoiceSessionWrapper (const VoiceSessionWrapper &)=delete | |
| VoiceSessionWrapper & | operator= (const VoiceSessionWrapper &)=delete |
| VoiceSessionWrapper (VoiceSessionWrapper &&)=delete | |
| VoiceSessionWrapper & | operator= (VoiceSessionWrapper &&)=delete |
| expected_void< NegotiationError > | connect () |
| Connect to the server (blocking). | |
| void | disconnect () |
| Disconnect from the server and stop audio processing. | |
| void | start_audio () |
| Start the audio processor (tick coordinator + worker threads). | |
| void | stop_audio () |
| Stop the audio processor. | |
| void | set_pcm_source (PcmSourceCallback cb) |
| void | start_speaking (ivon_speaking_mode_t mode=IVON_SPEAKING_MODE_PTT) |
| Start speaking. The PCM source callback will begin firing. | |
| void | enable_transmit (const std::string &group_id={}) |
| Enable audio transmission. | |
| void | disable_transmit (const std::string &group_id={}) |
| Disable audio transmission. | |
| bool | join_voice_group (const std::string &group_id) |
| Manually join a voice group. | |
| bool | leave_voice_group (const std::string &group_id) |
| Leave a voice group. Returns false if not connected. | |
| bool | is_voice_group_joined (const std::string &group_id={}) const noexcept |
| Check if a voice group has been successfully joined. | |
| ClientWrapper & | client () noexcept |
| Get a reference to the non-owning ClientWrapper. | |
| const ClientWrapper & | client () const noexcept |
| ivon_client_t | client_handle () const noexcept |
| Get the underlying client handle (non-owning). | |
| AudioWrapper & | audio () noexcept |
| Get a reference to the non-owning AudioWrapper. | |
| const AudioWrapper & | audio () const noexcept |
| ivon_audio_t | audio_handle () const noexcept |
| Get the underlying audio processor handle (non-owning). | |
| uint64_t | local_sender_id () const noexcept |
| Get the local fanout sender ID (0 if not yet connected). | |
| void | on_tofu_verify (TofuVerifyCallback cb) |
| Forward to client().on_tofu_verify(). | |
| void | on_password_required (PasswordCallback cb) |
| Forward to client().on_password_required(). | |
| void | on_client_message (ClientMessageCallback cb) |
| Forward to client().on_client_message(). | |
| void | on_client_joined (ClientJoinedCallback cb) |
| Forward to client().on_client_joined(). | |
| void | on_client_left (ClientLeftCallback cb) |
| Forward to client().on_client_left(). | |
| void | on_kicked (KickedCallback cb) |
| Forward to client().on_kicked(). | |
| void | on_disconnected (DisconnectedCallback cb) |
| Forward to client().on_disconnected(). | |
| void | on_connection_state_changed (ConnectionStateCallback cb) |
| Forward to client().on_connection_state_changed(). | |
| void | on_group_left (GroupLeaveCallback cb) |
| Forward to client().on_group_left(). | |
| void | on_group_kicked (GroupKickedCallback cb) |
| Forward to client().on_group_kicked(). | |
| void | on_group_list (GroupListCallback cb) |
| Forward to client().on_group_list(). | |
| void | on_server_properties (ServerPropertiesCallback cb) |
| Forward to client().on_server_properties(). | |
| void | on_server_property_update (ServerPropertyUpdateCallback cb) |
| Forward to client().on_server_property_update(). | |
| void | on_group_property_update (GroupPropertyUpdateCallback cb) |
| Forward to client().on_group_property_update(). | |
| bool | send_client_message (const std::string &client_id, const std::string &type, const std::vector< uint8_t > &buffer) |
| Send a typed message to a specific remote client. | |
| bool | send_broadcast_message (const std::string &type, const std::vector< uint8_t > &buffer) |
| Broadcast a typed message to all connected clients. | |
| bool | send_group_message (const std::string &group_id, const std::string &type, const std::vector< uint8_t > &buffer) |
| Send a typed message to all members of a group. | |
| size_t | get_remote_client_count () const noexcept |
| Get the count of remote clients in the session. | |
| bool | has_remote_client (const std::string &client_id) const noexcept |
| Check if a remote client with the given ID exists. | |
| std::vector< std::string > | get_remote_client_ids () const |
| Get all remote client IDs as a vector. | |
| bool | set_mute (const std::string &group_id, const std::string &target_client_id, bool muted) |
| Mute or unmute a target client in a specific group. | |
| bool | request_group_list () |
| Request the list of available groups from the server. | |
| std::vector< std::string > | get_group_ids () const |
| Get all group IDs this client is a member of. | |
| void | on_voice_joined (VoiceJoinedCallback cb) |
| Set callback for voice group join result. | |
| void | on_speaking (SpeakingCallback cb) |
| Set callback for remote speaking state changes. | |
| void | on_voice_error (VoiceErrorCallback cb) |
| Set callback for voice group runtime errors. | |
| void | on_member_joined (MemberJoinedCallback cb) |
| Set callback for when a member joins the voice group. | |
| void | on_member_left (MemberLeftCallback cb) |
| Set callback for when a member leaves the voice group. | |
| std::set< uint64_t > | get_speaking_senders () const |
| Get the sender IDs of currently speaking remote senders. | |
| ivon_audio_stats_t | get_audio_stats () const noexcept |
| Get aggregate audio statistics snapshot. | |
| void | set_log_level (int level) |
| Set the runtime log level for the session's internal loggers. | |
| int | get_log_level () const |
| Get the current log level. | |
| ivon_voice_session_t | handle () const noexcept |
| Get the underlying opaque C handle. | |
Consumer-facing C++ wrapper around the voice session C ABI.
RAII handle: the constructor creates the session, the destructor destroys it. Non-copyable, non-moveable; use std::unique_ptr for deferred initialization or ownership transfer.
| using ivon::VoiceSessionWrapper::MemberJoinedCallback = std::function<void(const std::string &group_id, uint64_t sender_id, const std::string &client_id)> |
| using ivon::VoiceSessionWrapper::MemberLeftCallback = std::function<void(const std::string &group_id, uint64_t sender_id, const std::string &client_id)> |
Structured output frame info returned by try_read_output().
Set the PCM source callback for local audio capture.
Called every 20 ms while speaking. Fill the provided buffer with mono float PCM samples.
| using ivon::VoiceSessionWrapper::SpeakingCallback = std::function<void(const SpeakingInfo &info)> |
| using ivon::VoiceSessionWrapper::VoiceErrorCallback = std::function<void(const std::string &group_id, const std::string &error_message)> |
| using ivon::VoiceSessionWrapper::VoiceJoinedCallback = std::function<void(const std::string &group_id, bool success, const std::string &error_message)> |
|
inlineexplicit |
Construct a wrapper and create the underlying voice session.
| std::runtime_error | if creation fails. |
|
inline |
|
delete |
|
delete |
|
inlinenoexcept |
|
inlinenoexcept |
Get a reference to the non-owning AudioWrapper.
Use for calling audio methods (is_speaking, stop_speaking, try_read_output, set_sender_muted, etc.) with C++ ergonomics.
|
inlinenoexcept |
Get the underlying audio processor handle (non-owning).
Prefer audio() for ergonomic C++ access. This raw handle is useful when mixing wrapper code with direct C ABI calls.
|
inlinenoexcept |
|
inlinenoexcept |
Get a reference to the non-owning ClientWrapper.
Use for registering non-audio callbacks (chat, presence, TOFU) and calling client methods like send_client_message().
|
inlinenoexcept |
Get the underlying client handle (non-owning).
Prefer client() for ergonomic C++ access. This raw handle is useful when mixing wrapper code with direct C ABI calls.
|
inline |
Connect to the server (blocking).
If voice_group_id was set in the config, the session will automatically join that group after connection. Additional groups from voice_group_ids are joined afterwards.
|
inline |
Disable audio transmission.
| group_id | Group to disable (empty = all groups). |
|
inline |
Disconnect from the server and stop audio processing.
|
inline |
Enable audio transmission.
Automatically called on successful auto-join. Only needed when managing group membership manually.
| group_id | Group to enable (empty = all groups). |
|
inlinenoexcept |
Get aggregate audio statistics snapshot.
Returns decoder, encoder, and pipeline counters. Values are approximate while the session is running.
|
inline |
Get all group IDs this client is a member of.
|
inline |
Get the current log level.
|
inlinenoexcept |
Get the count of remote clients in the session.
|
inline |
Get all remote client IDs as a vector.
|
inline |
Get the sender IDs of currently speaking remote senders.
|
inlinenoexcept |
Get the underlying opaque C handle.
|
inlinenoexcept |
Check if a remote client with the given ID exists.
|
inlinenoexcept |
Check if a voice group has been successfully joined.
| group_id | The group to check (empty = any group). |
|
inline |
Manually join a voice group.
Use when voice_group_id was empty in the config. Returns false if not connected.
|
inline |
Leave a voice group. Returns false if not connected.
| group_id | The group to leave. |
|
inlinenoexcept |
Get the local fanout sender ID (0 if not yet connected).
|
inline |
Forward to client().on_client_joined().
|
inline |
Forward to client().on_client_left().
|
inline |
Forward to client().on_client_message().
|
inline |
Forward to client().on_connection_state_changed().
|
inline |
Forward to client().on_disconnected().
|
inline |
Forward to client().on_group_kicked().
|
inline |
Forward to client().on_group_left().
|
inline |
Forward to client().on_group_list().
|
inline |
Forward to client().on_group_property_update().
|
inline |
Forward to client().on_kicked().
|
inline |
Set callback for when a member joins the voice group.
|
inline |
Set callback for when a member leaves the voice group.
|
inline |
Forward to client().on_password_required().
|
inline |
Forward to client().on_server_properties().
|
inline |
Forward to client().on_server_property_update().
|
inline |
Set callback for remote speaking state changes.
|
inline |
Forward to client().on_tofu_verify().
|
inline |
Set callback for voice group runtime errors.
|
inline |
Set callback for voice group join result.
|
delete |
|
delete |
|
inline |
Request the list of available groups from the server.
|
inline |
Broadcast a typed message to all connected clients.
|
inline |
Send a typed message to a specific remote client.
|
inline |
Send a typed message to all members of a group.
|
inline |
Set the runtime log level for the session's internal loggers.
| level | One of the IVON_LOG_LEVEL_* constants (0=trace .. 6=off). |
|
inline |
Mute or unmute a target client in a specific group.
|
inline |
|
inline |
Start the audio processor (tick coordinator + worker threads).
|
inline |
Start speaking. The PCM source callback will begin firing.
|
inline |
Stop the audio processor.