20#ifndef SACN_CPP_SOURCE_H_
21#define SACN_CPP_SOURCE_H_
206 etcpal::Error SendNow(uint16_t universe, uint8_t start_code,
const uint8_t* buffer,
size_t buflen);
209 void UpdateLevels(uint16_t universe,
const uint8_t* new_levels,
size_t new_levels_size);
210 void UpdateLevelsAndPap(uint16_t universe,
const uint8_t* new_levels,
size_t new_levels_size,
211 const uint8_t* new_priorities,
size_t new_priorities_size);
214 const uint8_t* new_priorities,
size_t new_priorities_size);
228 class TranslatedUniverseConfig
250 : cid(new_cid), name(new_name)
259 return !cid.IsNull();
276 return ((universe != 0) && (universe < 64000));
285 McastMode mcast_mode = McastMode::kEnabledOnAllInterfaces)
286 :
handle(source_handle), universe(universe_id), no_netints(mcast_mode ==
McastMode::kDisabledOnAllInterfaces)
298 :
handle(source_handle), universe(universe_id), netints(network_interfaces)
389 McastMode mcast_mode = McastMode::kEnabledOnAllInterfaces)
391 TranslatedUniverseConfig config(settings);
394 if (mcast_mode == McastMode::kDisabledOnAllInterfaces)
427 TranslatedUniverseConfig config(settings);
464 size_t size_guess = 4u;
465 size_t num_universes = 0u;
469 universes.
resize(size_guess);
471 size_guess = num_universes + 4u;
472 }
while (num_universes > universes.
size());
474 universes.
resize(num_universes);
522 size_t size_guess = 4u;
523 size_t num_destinations = 0u;
527 destinations.
resize(size_guess);
530 size_guess = num_destinations + 4u;
531 }
while (num_destinations > destinations.
size());
533 destinations.
resize(num_destinations);
537 if (!destinations.
empty())
541 [](
const EtcPalIpAddr& dest) { return etcpal::IpAddr(dest); });
699 const uint8_t* new_priorities,
size_t new_priorities_size)
702 new_priorities_size);
753 const uint8_t* new_priorities,
size_t new_priorities_size)
756 new_priorities, new_priorities_size);
809 if (mcast_mode == McastMode::kDisabledOnAllInterfaces)
841 if (sys_netints.
empty())
884 netint_lists_c.
reserve(per_universe_netint_lists.
size());
888 SacnSourceUniverseNetintList c_list = {
901 sys_netint_config.netints = sys_netints.data();
902 sys_netint_config.num_netints = sys_netints.size();
917 size_t size_guess = 4u;
918 size_t num_netints = 0u;
922 netints.
resize(size_guess);
924 size_guess = num_netints + 4u;
925 }
while (num_netints > netints.
size());
927 netints.
resize(num_netints);
946 settings.name.c_str(),
947 settings.universe_count_max,
948 settings.manually_process_source,
949 settings.ip_supported,
950 settings.keep_alive_interval,
951 settings.pap_keep_alive_interval
960 if (!unicast_destinations_.
empty())
970inline Source::TranslatedUniverseConfig::TranslatedUniverseConfig(
const UniverseSettings& settings)
974 settings.send_preview,
975 settings.send_unicast_only,
978 settings.sync_universe
983 if (!settings.unicast_destinations.empty())
985 unicast_destinations_.reserve(settings.unicast_destinations.size());
986 std::transform(settings.unicast_destinations.begin(), settings.unicast_destinations.end(),
T back_inserter(T... args)
constexpr const EtcPalIpAddr & get() const noexcept
ETCPAL_CONSTEXPR_14 void Clear()
ETCPAL_CONSTEXPR_14 void SetValue(const ValueType &new_value)
constexpr ValueType value() const
An instance of sACN Source functionality; see Using the sACN Source API.
Definition source.h:61
Source & operator=(Source &&other)=default
void RemoveUnicastDestination(uint16_t universe, const etcpal::IpAddr &dest)
Remove a unicast destination on a universe.
Definition source.h:507
etcpal::Error SendNow(uint16_t universe, uint8_t start_code, const uint8_t *buffer, size_t buflen)
Immediately sends the provided sACN start code & data.
Definition source.h:633
etcpal::Error ChangePriority(uint16_t universe, uint8_t new_priority)
Change the priority of a universe.
Definition source.h:562
void UpdateLevelsAndPap(uint16_t universe, const uint8_t *new_levels, size_t new_levels_size, const uint8_t *new_priorities, size_t new_priorities_size)
Copies the universe's DMX levels and per-address priorities into packets that are sent on the next th...
Definition source.h:698
etcpal::Error ChangePreviewFlag(uint16_t universe, bool new_preview_flag)
Change the send_preview option on a universe.
Definition source.h:585
constexpr Handle handle() const
Get the current handle to the underlying C source.
Definition source.h:936
etcpal::Error AddUnicastDestination(uint16_t universe, const etcpal::IpAddr &dest)
Add a unicast destination for a universe.
Definition source.h:493
etcpal::Error AddUniverse(const UniverseSettings &settings, McastMode mcast_mode)
Add a universe to an sACN source.
Definition source.h:388
etcpal::Error ChangeSynchronizationUniverse(uint16_t universe, uint16_t new_sync_universe)
Changes the synchronization universe for a universe.
Definition source.h:609
std::vector< etcpal::IpAddr > GetUnicastDestinations(uint16_t universe)
Obtain a vector of a universe's unicast destinations.
Definition source.h:518
static int ProcessManual(TickMode tick_mode)
Trigger the transmission of sACN packets for all universes of sources that were created with manually...
Definition source.h:776
void RemoveUniverse(uint16_t universe)
Remove a universe from a source.
Definition source.h:450
etcpal::Error ChangeName(const std::string &new_name)
Change the name of an sACN source.
Definition source.h:358
static etcpal::Error ResetNetworking(McastMode mcast_mode)
Resets the underlying network sockets for all universes of all sources.
Definition source.h:806
etcpal::Error Startup(const Settings &settings)
Create a new sACN source to send sACN data.
Definition source.h:318
Source(Source &&other)=default
void UpdateLevelsAndForceSync(uint16_t universe, const uint8_t *new_levels, size_t new_levels_size)
Like UpdateLevels(), but also sets the force_sync flag on the packet.
Definition source.h:721
std::vector< EtcPalMcastNetintId > GetNetworkInterfaces(uint16_t universe)
Obtain a vector of a universe's network interfaces.
Definition source.h:913
void Shutdown()
Destroy an sACN source instance.
Definition source.h:334
void UpdateLevels(uint16_t universe, const uint8_t *new_levels, size_t new_levels_size)
Copies the universe's DMX levels into the packet to be sent on the next threaded or manual update.
Definition source.h:671
std::vector< uint16_t > GetUniverses()
Obtain a vector of this source's universes (sorted lowest to highest).
Definition source.h:460
void UpdateLevelsAndPapAndForceSync(uint16_t universe, const uint8_t *new_levels, size_t new_levels_size, const uint8_t *new_priorities, size_t new_priorities_size)
Like UpdateLevelsAndPap(), but also sets the force_sync flag on the packet.
Definition source.h:752
etcpal::Error SendSynchronization(uint16_t universe)
Indicate that a new synchronization packet should be sent on the given synchronization universe.
Definition source.h:653
TickMode
Definition source.h:68
C++ wrapper for the sACN init/deinit functions.
sacn_ip_support_t
Definition common.h:71
@ kSacnIpV4AndIpV6
Definition common.h:77
etcpal_error_t sacn_source_change_name(sacn_source_t handle, const char *new_name)
Change the name of an sACN source.
Definition source.c:170
etcpal_error_t sacn_source_send_synchronization(sacn_source_t handle, uint16_t universe)
Indicate that a new synchronization packet should be sent on the given synchronization universe.
Definition source.c:788
etcpal_error_t sacn_source_change_priority(sacn_source_t handle, uint16_t universe, uint8_t new_priority)
Change the priority of a universe on a sACN source.
Definition source.c:556
size_t sacn_source_get_unicast_destinations(sacn_source_t handle, uint16_t universe, EtcPalIpAddr *destinations, size_t destinations_size)
Obtain a list of a universe's unicast destinations.
Definition source.c:518
#define SACN_SOURCE_INFINITE_UNIVERSES
Constant for "infinite" when sending sACN universes.
Definition source.h:66
etcpal_error_t sacn_source_add_universe(sacn_source_t handle, const SacnSourceUniverseConfig *config, const SacnNetintConfig *netint_config)
Add a universe to an sACN source.
Definition source.c:263
void sacn_source_update_levels(sacn_source_t handle, uint16_t universe, const uint8_t *new_levels, size_t new_levels_size)
Copies the universe's DMX levels into the packet to be sent on the next threaded or manual update.
Definition source.c:812
etcpal_error_t sacn_source_add_unicast_destination(sacn_source_t handle, uint16_t universe, const EtcPalIpAddr *dest)
Add a unicast destination for a source's universe.
Definition source.c:408
etcpal_error_t sacn_source_reset_networking(const SacnNetintConfig *sys_netint_config)
Resets the underlying network sockets for all universes of all sources.
Definition source.c:1029
etcpal_error_t sacn_source_create(const SacnSourceConfig *config, sacn_source_t *handle)
Create a new sACN source to send sACN data.
Definition source.c:104
#define SACN_SOURCE_INVALID
Definition source.h:58
void sacn_source_remove_unicast_destination(sacn_source_t handle, uint16_t universe, const EtcPalIpAddr *dest)
Remove a unicast destination on a source's universe.
Definition source.c:483
void sacn_source_update_levels_and_force_sync(sacn_source_t handle, uint16_t universe, const uint8_t *new_levels, size_t new_levels_size)
Like sacn_source_update_levels(), but also sets the force_sync flag on the packet.
Definition source.c:903
void sacn_source_update_levels_and_pap(sacn_source_t handle, uint16_t universe, const uint8_t *new_levels, size_t new_levels_size, const uint8_t *new_priorities, size_t new_priorities_size)
Copies the universe's DMX levels and per-address priorities into packets that are sent on the next th...
Definition source.c:860
etcpal_error_t sacn_source_send_now(sacn_source_t handle, uint16_t universe, uint8_t start_code, const uint8_t *buffer, size_t buflen)
Immediately sends the provided sACN start code & data.
Definition source.c:710
void sacn_source_remove_universe(sacn_source_t handle, uint16_t universe)
Remove a universe from a source.
Definition source.c:351
size_t sacn_source_get_universes(sacn_source_t handle, uint16_t *universes, size_t universes_size)
Obtain a list of a source's universes (sorted lowest to highest).
Definition source.c:375
etcpal_error_t sacn_source_change_preview_flag(sacn_source_t handle, uint16_t universe, bool new_preview_flag)
Change the send_preview option on a universe of a sACN source.
Definition source.c:617
int sacn_source_process_manual(sacn_source_tick_mode_t tick_mode)
Trigger the transmission of sACN packets for all universes of sources that were created with manually...
Definition source.c:999
sacn_source_tick_mode_t
Definition source.h:76
#define SACN_SOURCE_KEEP_ALIVE_INTERVAL_DEFAULT
Definition source.h:69
void sacn_source_update_levels_and_pap_and_force_sync(sacn_source_t handle, uint16_t universe, const uint8_t *new_levels, size_t new_levels_size, const uint8_t *new_priorities, size_t new_priorities_size)
Like sacn_source_update_levels_and_pap(), but also sets the force_sync flag on the packet.
Definition source.c:956
etcpal_error_t sacn_source_change_synchronization_universe(sacn_source_t handle, uint16_t universe, uint16_t new_sync_universe)
Changes the synchronization universe for a universe of a sACN source.
Definition source.c:679
etcpal_error_t sacn_source_reset_networking_per_universe(const SacnNetintConfig *sys_netint_config, const SacnSourceUniverseNetintList *per_universe_netint_lists, size_t num_per_universe_netint_lists)
Resets the underlying network sockets and determines network interfaces for each universe of each sou...
Definition source.c:1100
int sacn_source_t
Definition source.h:56
#define SACN_SOURCE_PAP_KEEP_ALIVE_INTERVAL_DEFAULT
Definition source.h:72
size_t sacn_source_get_network_interfaces(sacn_source_t handle, uint16_t universe, EtcPalMcastNetintId *netints, size_t netints_size)
Obtain a list of a universe's network interfaces.
Definition source.c:1208
void sacn_source_destroy(sacn_source_t handle)
Destroy an sACN source instance.
Definition source.c:220
@ kSacnSourceTickModeProcessLevelsAndPap
Definition source.h:82
@ kSacnSourceTickModeProcessPapOnly
Definition source.h:80
@ kSacnSourceTickModeProcessLevelsOnly
Definition source.h:78
A namespace which contains all C++ language definitions in the sACN library.
Definition common.h:50
McastMode
Definition common.h:53
sACN Source API definitions
bool no_netints
Definition common.h:110
size_t num_netints
Definition common.h:107
SacnMcastInterface * netints
Definition common.h:105
EtcPalUuid cid
Definition source.h:91
const EtcPalIpAddr * unicast_destinations
Definition source.h:152
size_t num_unicast_destinations
Definition source.h:154
A set of configuration settings that a source needs to initialize.
Definition source.h:82
bool manually_process_source
Definition source.h:98
int keep_alive_interval
Definition source.h:105
std::string name
Definition source.h:88
int pap_keep_alive_interval
Definition source.h:109
sacn_ip_support_t ip_supported
Definition source.h:101
etcpal::Uuid cid
Definition source.h:86
bool IsValid() const
Definition source.h:257
size_t universe_count_max
Definition source.h:93
A set of network interfaces for a particular universe.
Definition source.h:162
uint16_t universe
Definition source.h:166
std::vector< SacnMcastInterface > netints
Definition source.h:170
bool no_netints
Definition source.h:173
UniverseNetintList()=default
sacn_source_t handle
Definition source.h:164
A set of configuration settings for a new universe on a source.
Definition source.h:123
uint8_t priority
Definition source.h:134
uint16_t universe
Definition source.h:128
bool send_preview
Definition source.h:137
std::vector< etcpal::IpAddr > unicast_destinations
Definition source.h:144
uint16_t sync_universe
Definition source.h:148
bool IsValid() const
Definition source.h:274
bool send_unicast_only
Definition source.h:140
UniverseSettings()=default