20#ifndef SACN_CPP_SOURCE_H_
21#define SACN_CPP_SOURCE_H_
188 etcpal::Error SendNow(uint16_t universe, uint8_t start_code,
const uint8_t* buffer,
size_t buflen);
191 void UpdateLevels(uint16_t universe,
const uint8_t* new_levels,
size_t new_levels_size);
192 void UpdateLevelsAndPap(uint16_t universe,
const uint8_t* new_levels,
size_t new_levels_size,
193 const uint8_t* new_priorities,
size_t new_priorities_size);
196 const uint8_t* new_priorities,
size_t new_priorities_size);
210 class TranslatedUniverseConfig
232 : cid(new_cid), name(new_name)
241 return !cid.IsNull();
258 return ((universe != 0) && (universe < 64000));
267 :
handle(source_handle), universe(universe_id)
279 :
handle(source_handle), universe(universe_id), netints(network_interfaces)
368 TranslatedUniverseConfig config(settings);
398 TranslatedUniverseConfig config(settings);
432 size_t size_guess = 4u;
433 size_t num_universes = 0u;
437 universes.
resize(size_guess);
439 size_guess = num_universes + 4u;
440 }
while (num_universes > universes.
size());
442 universes.
resize(num_universes);
490 size_t size_guess = 4u;
491 size_t num_destinations = 0u;
495 destinations.
resize(size_guess);
498 size_guess = num_destinations + 4u;
499 }
while (num_destinations > destinations.
size());
501 destinations.
resize(num_destinations);
505 if (!destinations.
empty())
509 [](
const EtcPalIpAddr& dest) { return etcpal::IpAddr(dest); });
666 const uint8_t* new_priorities,
size_t new_priorities_size)
669 new_priorities_size);
720 const uint8_t* new_priorities,
size_t new_priorities_size)
723 new_priorities, new_priorities_size);
803 if (sys_netints.
empty())
843 netint_lists_c.
reserve(per_universe_netint_lists.
size());
848 SacnSourceUniverseNetintList c_list = {
859 SacnNetintConfig sys_netint_config = {sys_netints.data(), sys_netints.size()};
873 size_t size_guess = 4u;
874 size_t num_netints = 0u;
878 netints.
resize(size_guess);
880 size_guess = num_netints + 4u;
881 }
while (num_netints > netints.
size());
883 netints.
resize(num_netints);
902 settings.name.c_str(),
903 settings.universe_count_max,
904 settings.manually_process_source,
905 settings.ip_supported,
906 settings.keep_alive_interval
915 if (!unicast_destinations_.
empty())
925inline Source::TranslatedUniverseConfig::TranslatedUniverseConfig(
const UniverseSettings& settings)
929 settings.send_preview,
930 settings.send_unicast_only,
933 settings.sync_universe
938 if (!settings.unicast_destinations.empty())
940 unicast_destinations_.reserve(settings.unicast_destinations.size());
941 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
static etcpal::Error ResetNetworking()
Resets the underlying network sockets for all universes of all sources.
Definition source.h:771
Source & operator=(Source &&other)=default
void RemoveUnicastDestination(uint16_t universe, const etcpal::IpAddr &dest)
Remove a unicast destination on a universe.
Definition source.h:475
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:600
etcpal::Error ChangePriority(uint16_t universe, uint8_t new_priority)
Change the priority of a universe.
Definition source.h:530
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:665
etcpal::Error ChangePreviewFlag(uint16_t universe, bool new_preview_flag)
Change the send_preview option on a universe.
Definition source.h:553
constexpr Handle handle() const
Get the current handle to the underlying C source.
Definition source.h:892
etcpal::Error AddUnicastDestination(uint16_t universe, const etcpal::IpAddr &dest)
Add a unicast destination for a universe.
Definition source.h:461
etcpal::Error ChangeSynchronizationUniverse(uint16_t universe, uint16_t new_sync_universe)
Changes the synchronization universe for a universe.
Definition source.h:577
std::vector< etcpal::IpAddr > GetUnicastDestinations(uint16_t universe)
Obtain a vector of a universe's unicast destinations.
Definition source.h:486
void RemoveUniverse(uint16_t universe)
Remove a universe from a source.
Definition source.h:418
etcpal::Error ChangeName(const std::string &new_name)
Change the name of an sACN source.
Definition source.h:339
etcpal::Error Startup(const Settings &settings)
Create a new sACN source to send sACN data.
Definition source.h:299
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:688
std::vector< EtcPalMcastNetintId > GetNetworkInterfaces(uint16_t universe)
Obtain a vector of a universe's network interfaces.
Definition source.h:869
void Shutdown()
Destroy an sACN source instance.
Definition source.h:315
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:638
static int ProcessManual()
Trigger the transmission of sACN packets for all universes of sources that were created with manually...
Definition source.h:742
etcpal::Error AddUniverse(const UniverseSettings &settings)
Add a universe to an sACN source, which will use all network interfaces.
Definition source.h:366
std::vector< uint16_t > GetUniverses()
Obtain a vector of this source's universes.
Definition source.h:428
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:719
etcpal::Error SendSynchronization(uint16_t universe)
Indicate that a new synchronization packet should be sent on the given synchronization universe.
Definition source.h:620
C++ wrapper for the sACN init/deinit functions.
sacn_ip_support_t
Definition common.h:71
@ kSacnIpV4AndIpV6
Definition common.h:77
int sacn_source_process_manual(void)
Trigger the transmission of sACN packets for all universes of sources that were created with manually...
Definition source.c:990
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:168
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:780
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:554
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:516
#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:261
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:804
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:406
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:1020
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:103
#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:481
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:895
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:852
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:707
void sacn_source_remove_universe(sacn_source_t handle, uint16_t universe)
Remove a universe from a source.
Definition source.c:349
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.
Definition source.c:373
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:615
#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:948
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:677
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:1084
int sacn_source_t
Definition source.h:56
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:1176
void sacn_source_destroy(sacn_source_t handle)
Destroy an sACN source instance.
Definition source.c:218
A namespace which contains all C++ language definitions in the sACN library.
Definition common.h:50
sACN Source API definitions
EtcPalUuid cid
Definition source.h:77
const EtcPalIpAddr * unicast_destinations
Definition source.h:133
size_t num_unicast_destinations
Definition source.h:135
A set of configuration settings that a source needs to initialize.
Definition source.h:71
bool manually_process_source
Definition source.h:87
int keep_alive_interval
Definition source.h:94
std::string name
Definition source.h:77
sacn_ip_support_t ip_supported
Definition source.h:90
etcpal::Uuid cid
Definition source.h:75
bool IsValid() const
Definition source.h:239
size_t universe_count_max
Definition source.h:82
A set of network interfaces for a particular universe.
Definition source.h:147
uint16_t universe
Definition source.h:151
std::vector< SacnMcastInterface > netints
Definition source.h:155
UniverseNetintList()=default
sacn_source_t handle
Definition source.h:149
A set of configuration settings for a new universe on a source.
Definition source.h:108
uint8_t priority
Definition source.h:119
uint16_t universe
Definition source.h:113
bool send_preview
Definition source.h:122
uint16_t sync_universe
Definition source.h:133
const std::vector< etcpal::IpAddr > unicast_destinations
Definition source.h:129
bool IsValid() const
Definition source.h:256
bool send_unicast_only
Definition source.h:125
UniverseSettings()=default