20#ifndef SACN_CPP_COMMON_H_
21#define SACN_CPP_COMMON_H_
54 kEnabledOnAllInterfaces,
55 kDisabledOnAllInterfaces
139extern "C" inline void CommonCbUnicastSendError(
const SacnSocketErrorInfo* err_info,
void* context)
141 if (err_info && context)
142 static_cast<NotifyHandler*
>(context)->HandleUnicastSendError(*err_info);
145extern "C" inline void CommonCbMulticastSendError(
const SacnSocketErrorInfo* err_info,
void* context)
147 if (err_info && context)
148 static_cast<NotifyHandler*
>(context)->HandleMulticastSendError(*err_info);
153 SacnCommonCallbacks callbacks = {internal::CommonCbUnicastSendError, internal::CommonCbMulticastSendError,
188 auto callbacks = internal::GetCommonCallbacks(settings.notify_handler);
220 auto callbacks = internal::GetCommonCallbacks(settings.notify_handler);
222 settings.notify_handler ? &callbacks : nullptr);
254 if (mcast_mode == McastMode::kDisabledOnAllInterfaces)
257 auto callbacks = internal::GetCommonCallbacks(settings.notify_handler);
259 settings.notify_handler ? &callbacks : nullptr);
282 std::vector<SacnMcastInterface>& sys_netints,
287 netint_config.
netints = sys_netints.data();
291 auto callbacks = internal::GetCommonCallbacks(settings.notify_handler);
293 settings.notify_handler ? &callbacks : nullptr);
320 netint_config.
netints = sys_netints.data();
324 auto callbacks = internal::GetCommonCallbacks(settings.notify_handler);
349 McastMode mcast_mode = McastMode::kEnabledOnAllInterfaces,
356 if (mcast_mode == McastMode::kDisabledOnAllInterfaces)
359 auto callbacks = internal::GetCommonCallbacks(settings.notify_handler);
361 settings.notify_handler ? &callbacks : nullptr);
389 auto callbacks = internal::GetCommonCallbacks(settings.notify_handler);
391 settings.notify_handler ? &callbacks : nullptr);
413 std::vector<SacnMcastInterface>& sys_netints,
418 netint_config.
netints = sys_netints.data();
422 auto callbacks = internal::GetCommonCallbacks(settings.notify_handler);
424 settings.notify_handler ? &callbacks : nullptr);
477 return cid_to_return;
const EtcPalLogParams & log_params() const noexcept
constexpr const EtcPalUuid & get() const noexcept
A base class for a class that receives common notification callbacks from sACN.
Definition common.h:73
NotifyHandler(const NotifyHandler &other)=default
Defaulted copy constructor.
NotifyHandler & operator=(NotifyHandler &&other)=default
Defaulted move assignment operator.
virtual void HandleMulticastSendError(const SacnSocketErrorInfo &err_info)
Notify that an error just occurred sending multicast on a socket.
Definition common.h:114
NotifyHandler & operator=(const NotifyHandler &other)=default
Defaulted copy assignment operator.
NotifyHandler(NotifyHandler &&other)=default
Defaulted move constructor.
virtual void HandleUnicastSendError(const SacnSocketErrorInfo &err_info)
Notify that an error just occurred sending unicast on a socket.
Definition common.h:108
Common definitions for sACN.
uint16_t sacn_remote_source_t
A source discovered on an sACN network that has a CID - used by Receiver and Merge Receiver.
Definition common.h:47
#define SACN_NETINT_CONFIG_DEFAULT_INIT
Initializes the members of a SacnNetintConfig to defaults.
Definition common.h:187
etcpal_error_t sacn_init_features_with_cb(const EtcPalLogParams *log_params, const SacnNetintConfig *sys_netint_config, sacn_features_t features, const SacnCommonCallbacks *callbacks)
Initialize specific features of the sACN library.
Definition common.c:153
#define SACN_SEND_SOCKET_CONFIG_DEFAULT_VALUES
Default values for initializing a SacnSendSocketConfig.
Definition common.h:177
sacn_remote_source_t sacn_get_remote_source_handle(const EtcPalUuid *source_cid)
Converts a remote source CID to the corresponding handle, or kSacnRemoteSourceInvalid if not found.
Definition common.c:580
void sacn_deinit_features(sacn_features_t features)
Deinitialize specific features of the sACN library.
Definition common.c:496
etcpal_error_t sacn_get_remote_source_cid(sacn_remote_source_t source_handle, EtcPalUuid *source_cid)
Converts a remote source handle to the corresponding source CID.
Definition common.c:605
uint32_t sacn_features_t
A mask of desired sACN features.
Definition common.h:190
#define SACN_FEATURES_ALL
Use every available module.
Definition common.h:208
static const sacn_remote_source_t kSacnRemoteSourceInvalid
An invalid remote source handle value.
Definition common.h:49
@ kSacnMinimumUniverse
The lowest sACN universe number supported.
Definition common.h:66
@ kSacnMaximumUniverse
The highest sACN universe number supported.
Definition common.h:68
etcpal::Error Init(sacn_features_t features=SACN_FEATURES_ALL, const LibrarySettings &settings={})
Initialize the sACN library.
Definition common.h:183
RemoteSourceHandle GetRemoteSourceHandle(const etcpal::Uuid &source_cid)
Converts a remote source CID to the corresponding handle, or kSacnRemoteSourceInvalid if not found.
Definition common.h:453
etcpal::Expected< etcpal::Uuid > GetRemoteSourceCid(RemoteSourceHandle source_handle)
Converts a remote source handle to the corresponding source CID.
Definition common.h:470
A namespace which contains all C++ language definitions in the sACN library.
Definition common.h:50
constexpr RemoteSourceHandle kInvalidRemoteSourceHandle
An invalid RemoteSourceHandle value.
Definition common.h:61
constexpr uint16_t kMinimumUniverse
The lowest sACN universe number supported.
Definition common.h:64
void Deinit(sacn_features_t features=SACN_FEATURES_ALL)
Deinitialize features of the sACN library.
Definition common.h:438
sacn_remote_source_t RemoteSourceHandle
A source discovered on an sACN network that has a CID - used by Receiver and Merge Receiver.
Definition common.h:59
McastMode
Determines whether multicast traffic is allowed through all interfaces or none.
Definition common.h:53
constexpr uint16_t kMaximumUniverse
The highest sACN universe number supported.
Definition common.h:66
A set of callback functions that the library uses to notify the application about sACN events.
Definition common.h:168
Network interface configuration information to give the sACN library.
Definition common.h:114
SacnMcastInterface * netints
An array of network interface IDs to which to restrict multicast traffic.
Definition common.h:117
size_t num_netints
Size of netints array.
Definition common.h:119
bool no_netints
If this is true, no network interfaces will be used for multicast.
Definition common.h:122
SacnSendSocketConfig send_socket_config
Configuration for send sockets (e.g.
Definition common.h:126
Configuration for send sockets (e.g.
Definition common.h:103
Information about a socket error that occurred.
Definition common.h:131
Settings for the sACN library beyond the sacn::Init overrides.
Definition common.h:122
NotifyHandler * notify_handler
Callback handler for common notifications from the library.
Definition common.h:124
LibrarySettings()=default
Sets default settings.
SacnSendSocketConfig send_socket_config
Configuration for send sockets (e.g.
Definition common.h:127