sACN  HEAD (unstable)
Implementation of ANSI E1.31 (Streaming ACN)
View other versions:
Loading...
Searching...
No Matches
source.h
Go to the documentation of this file.
1/******************************************************************************
2 * Copyright 2024 ETC Inc.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 ******************************************************************************
16 * This file is a part of sACN. For more information, go to:
17 * https://github.com/ETCLabs/sACN
18 *****************************************************************************/
19
20#ifndef SACN_CPP_SOURCE_H_
21#define SACN_CPP_SOURCE_H_
22
28#include "sacn/cpp/common.h"
29
30#include <cstring>
31#include "sacn/source.h"
32#include "etcpal/cpp/uuid.h"
33#include "etcpal/cpp/inet.h"
35
42namespace sacn
43{
44
45namespace detail
46{
48{
49};
50}; // namespace detail
51
60class Source
61{
62public:
65
76
81 struct Settings
82 {
83 /********* Required values **********/
84
88 std::string name;
89
90 /********* Optional values **********/
91
94
99
102
106
110
112 Settings() = default;
113 Settings(etcpal::Uuid new_cid, std::string new_name);
114
115 bool IsValid() const;
116 };
117
123 {
124 /********* Required values **********/
125
128 uint16_t universe{0};
129
130 /********* Optional values **********/
131
134 uint8_t priority{100};
135
137 bool send_preview{false};
138
140 bool send_unicast_only{false};
141
144 std::vector<etcpal::IpAddr> unicast_destinations;
145
148 uint16_t sync_universe{0};
149
151 UniverseSettings() = default;
152 UniverseSettings(uint16_t universe_id);
153
154 bool IsValid() const;
155 };
156
162 {
166 uint16_t universe{0};
167
170 std::vector<SacnMcastInterface> netints;
171
173 bool no_netints{false};
174
177 UniverseNetintList(sacn_source_t source_handle, uint16_t universe_id, McastMode mcast_mode);
178 UniverseNetintList(sacn_source_t source_handle,
179 uint16_t universe_id,
180 const std::vector<SacnMcastInterface>& network_interfaces);
181 };
182
183 Source() = default;
184 virtual ~Source() = default;
185
186 Source(const Source& other) = delete;
187 Source& operator=(const Source& other) = delete;
188 Source(Source&& other) = default;
189 Source& operator=(Source&& other) = default;
191 etcpal::Error Startup(const Settings& settings);
192 void Shutdown();
193
194 etcpal::Error ChangeName(const std::string& new_name);
195
196 etcpal::Error AddUniverse(const UniverseSettings& settings, McastMode mcast_mode);
197 etcpal::Error AddUniverse(const UniverseSettings& settings, std::vector<SacnMcastInterface>& netints);
198 void RemoveUniverse(uint16_t universe);
199 std::vector<uint16_t> GetUniverses();
200
201 etcpal::Error AddUnicastDestination(uint16_t universe, const etcpal::IpAddr& dest);
202 void RemoveUnicastDestination(uint16_t universe, const etcpal::IpAddr& dest);
203 std::vector<etcpal::IpAddr> GetUnicastDestinations(uint16_t universe);
204
205 etcpal::Error ChangePriority(uint16_t universe, uint8_t new_priority);
206 etcpal::Error ChangePreviewFlag(uint16_t universe, bool new_preview_flag);
207 etcpal::Error ChangeSynchronizationUniverse(uint16_t universe, uint16_t new_sync_universe);
208
209 etcpal::Error SendNow(uint16_t universe, uint8_t start_code, const uint8_t* buffer, size_t buflen);
210 etcpal::Error SendSynchronization(uint16_t universe);
211
212 void UpdateLevels(uint16_t universe, const uint8_t* new_levels, size_t new_levels_size);
213 void UpdateLevelsAndPap(uint16_t universe,
214 const uint8_t* new_levels,
215 size_t new_levels_size,
216 const uint8_t* new_priorities,
217 size_t new_priorities_size);
218 void UpdateLevelsAndForceSync(uint16_t universe, const uint8_t* new_levels, size_t new_levels_size);
219 void UpdateLevelsAndPapAndForceSync(uint16_t universe,
220 const uint8_t* new_levels,
221 size_t new_levels_size,
222 const uint8_t* new_priorities,
223 size_t new_priorities_size);
224
225 std::vector<EtcPalMcastNetintId> GetNetworkInterfaces(uint16_t universe);
226
227 constexpr Handle handle() const;
228
229 static int ProcessManual(TickMode tick_mode);
230
231 static etcpal::Error ResetNetworking(McastMode mcast_mode, const SacnSendSocketConfig& send_socket_config);
232 static etcpal::Error ResetNetworking(std::vector<SacnMcastInterface>& netints,
233 const SacnSendSocketConfig& send_socket_config);
234 static etcpal::Error ResetNetworking(std::vector<SacnMcastInterface>& sys_netints,
235 std::vector<UniverseNetintList>& netint_lists,
236 const SacnSendSocketConfig& send_socket_config);
237
238private:
239 class TranslatedUniverseConfig
240 {
241 public:
242 explicit TranslatedUniverseConfig(const UniverseSettings& settings);
243 const SacnSourceUniverseConfig& get() noexcept;
244
245 private:
246 std::vector<EtcPalIpAddr> unicast_destinations_;
248 };
249
250 static SacnSourceConfig TranslateConfig(const Settings& settings);
251
252 Handle handle_;
253};
254
260inline Source::Settings::Settings(etcpal::Uuid new_cid, std::string new_name)
261 : cid(std::move(new_cid)), name(std::move(new_name))
262{
263}
264
268inline bool Source::Settings::IsValid() const
269{
270 return !cid.IsNull();
271}
272
278inline Source::UniverseSettings::UniverseSettings(uint16_t universe_id) : universe(universe_id)
279{
280}
281
286{
287 return ((universe >= sacn::kMinimumUniverse) && (universe <= sacn::kMaximumUniverse));
288}
289
296 uint16_t universe_id,
297 McastMode mcast_mode = McastMode::kEnabledOnAllInterfaces)
298 : handle(source_handle), universe(universe_id), no_netints(mcast_mode == McastMode::kDisabledOnAllInterfaces)
299{
300}
301
309 uint16_t universe_id,
310 const std::vector<SacnMcastInterface>& network_interfaces)
311 : handle(source_handle), universe(universe_id), netints(network_interfaces)
312{
313}
314
332{
333 SacnSourceConfig config = TranslateConfig(settings);
335 etcpal::Error result = sacn_source_create(&config, &c_handle);
336 handle_.SetValue(c_handle);
337 return result;
338}
339
347inline void Source::Shutdown()
348{
349 sacn_source_destroy(handle_.value());
350 handle_.Clear();
351}
352
371inline etcpal::Error Source::ChangeName(const std::string& new_name)
372{
373 return sacn_source_change_name(handle_.value(), new_name.c_str());
374}
375
402 McastMode mcast_mode = McastMode::kEnabledOnAllInterfaces)
403{
404 TranslatedUniverseConfig config(settings);
405
407 if (mcast_mode == McastMode::kDisabledOnAllInterfaces)
408 netint_config.no_netints = true;
409
410 return sacn_source_add_universe(handle_.value(), &config.get(), &netint_config);
411}
412
438inline etcpal::Error Source::AddUniverse(const UniverseSettings& settings, std::vector<SacnMcastInterface>& netints)
439{
440 TranslatedUniverseConfig config(settings);
441
442 if (netints.empty())
443 return sacn_source_add_universe(handle_.value(), &config.get(), nullptr);
444
446 netint_config.netints = netints.data();
447 netint_config.num_netints = netints.size();
448
449 return sacn_source_add_universe(handle_.value(), &config.get(), &netint_config);
450}
451
463inline void Source::RemoveUniverse(uint16_t universe)
464{
465 sacn_source_remove_universe(handle_.value(), universe);
466}
467
473inline std::vector<uint16_t> Source::GetUniverses()
474{
475 // This uses a guessing algorithm with a while loop to avoid race conditions.
476 size_t size_guess = 4u;
477 std::vector<uint16_t> universes(size_guess);
478 size_t num_universes = sacn_source_get_universes(handle_.value(), universes.data(), universes.size());
479
480 while (num_universes > universes.size())
481 {
482 size_guess = num_universes + 4u;
483 universes.resize(size_guess);
484 num_universes = sacn_source_get_universes(handle_.value(), universes.data(), universes.size());
485 }
486
487 universes.resize(num_universes);
488 return universes;
489}
490
506inline etcpal::Error Source::AddUnicastDestination(uint16_t universe, const etcpal::IpAddr& dest)
507{
508 return sacn_source_add_unicast_destination(handle_.value(), universe, &dest.get());
509}
510
520inline void Source::RemoveUnicastDestination(uint16_t universe, const etcpal::IpAddr& dest)
521{
522 sacn_source_remove_unicast_destination(handle_.value(), universe, &dest.get());
523}
524
531inline std::vector<etcpal::IpAddr> Source::GetUnicastDestinations(uint16_t universe)
532{
533 // This uses a guessing algorithm with a while loop to avoid race conditions.
534 size_t size_guess = 4u;
535 std::vector<EtcPalIpAddr> destinations(size_guess);
536 size_t num_destinations =
537 sacn_source_get_unicast_destinations(handle_.value(), universe, destinations.data(), destinations.size());
538
539 while (num_destinations > destinations.size())
540 {
541 size_guess = num_destinations + 4u;
542 destinations.resize(size_guess);
543 num_destinations =
544 sacn_source_get_unicast_destinations(handle_.value(), universe, destinations.data(), destinations.size());
545 }
546
547 destinations.resize(num_destinations);
548
549 // Convert vector<EtcPalIpAddr> to vector<etcpal::IpAddr>.
550 std::vector<etcpal::IpAddr> result;
551 if (!destinations.empty())
552 {
553 result.reserve(destinations.size());
554 std::transform(destinations.begin(), destinations.end(), std::back_inserter(result),
555 [](const EtcPalIpAddr& dest) { return etcpal::IpAddr(dest); });
556 }
557
558 return result;
559}
560
576inline etcpal::Error Source::ChangePriority(uint16_t universe, uint8_t new_priority)
577{
578 return sacn_source_change_priority(handle_.value(), universe, new_priority);
579}
580
599inline etcpal::Error Source::ChangePreviewFlag(uint16_t universe, bool new_preview_flag)
600{
601 return sacn_source_change_preview_flag(handle_.value(), universe, new_preview_flag);
602}
603
623inline etcpal::Error Source::ChangeSynchronizationUniverse(uint16_t universe, uint16_t new_sync_universe)
624{
625 return sacn_source_change_synchronization_universe(handle_.value(), universe, new_sync_universe);
626}
627
647inline etcpal::Error Source::SendNow(uint16_t universe, uint8_t start_code, const uint8_t* buffer, size_t buflen)
648{
649 return sacn_source_send_now(handle_.value(), universe, start_code, buffer, buflen);
650}
651
667inline etcpal::Error Source::SendSynchronization(uint16_t sync_universe)
668{
669 return sacn_source_send_synchronization(handle_.value(), sync_universe);
670}
671
685inline void Source::UpdateLevels(uint16_t universe, const uint8_t* new_levels, size_t new_levels_size)
686{
687 sacn_source_update_levels(handle_.value(), universe, new_levels, new_levels_size);
688}
689
712inline void Source::UpdateLevelsAndPap(uint16_t universe,
713 const uint8_t* new_levels,
714 size_t new_levels_size,
715 const uint8_t* new_priorities,
716 size_t new_priorities_size)
717{
718 sacn_source_update_levels_and_pap(handle_.value(), universe, new_levels, new_levels_size, new_priorities,
719 new_priorities_size);
720}
721
738inline void Source::UpdateLevelsAndForceSync(uint16_t universe, const uint8_t* new_levels, size_t new_levels_size)
739{
740 sacn_source_update_levels_and_force_sync(handle_.value(), universe, new_levels, new_levels_size);
741}
742
769inline void Source::UpdateLevelsAndPapAndForceSync(uint16_t universe,
770 const uint8_t* new_levels,
771 size_t new_levels_size,
772 const uint8_t* new_priorities,
773 size_t new_priorities_size)
774{
775 sacn_source_update_levels_and_pap_and_force_sync(handle_.value(), universe, new_levels, new_levels_size,
776 new_priorities, new_priorities_size);
777}
778
797{
798 return sacn_source_process_manual(static_cast<sacn_source_tick_mode_t>(tick_mode));
799}
800
828 McastMode mcast_mode = McastMode::kEnabledOnAllInterfaces,
830{
832 if (mcast_mode == McastMode::kDisabledOnAllInterfaces)
833 netint_config.no_netints = true;
834
835 netint_config.send_socket_config = send_socket_config;
836
837 return sacn_source_reset_networking(&netint_config);
838}
839
866 std::vector<SacnMcastInterface>& sys_netints,
868{
870 netint_config.send_socket_config = send_socket_config;
871
872 if (!sys_netints.empty())
873 {
874 netint_config.netints = sys_netints.data();
875 netint_config.num_netints = sys_netints.size();
876 }
877
878 return sacn_source_reset_networking(&netint_config);
879}
880
912 std::vector<SacnMcastInterface>& sys_netints,
913 std::vector<UniverseNetintList>& per_universe_netint_lists,
915{
916 std::vector<SacnSourceUniverseNetintList> netint_lists_c;
917 netint_lists_c.reserve(per_universe_netint_lists.size());
918 std::transform(per_universe_netint_lists.begin(), per_universe_netint_lists.end(), std::back_inserter(netint_lists_c),
919 [](UniverseNetintList& list) {
920 // clang-format off
921 SacnSourceUniverseNetintList c_list = {
922 list.handle,
923 list.universe,
924 list.netints.data(),
925 list.netints.size(),
926 list.no_netints
927 };
928 // clang-format on
929
930 return c_list;
931 });
932
934 sys_netint_config.netints = sys_netints.data();
935 sys_netint_config.num_netints = sys_netints.size();
936 sys_netint_config.send_socket_config = send_socket_config;
937 return sacn_source_reset_networking_per_universe(&sys_netint_config, netint_lists_c.data(), netint_lists_c.size());
938}
939
946inline std::vector<EtcPalMcastNetintId> Source::GetNetworkInterfaces(uint16_t universe)
947{
948 // This uses a guessing algorithm with a while loop to avoid race conditions.
949 size_t size_guess = 4u;
950 std::vector<EtcPalMcastNetintId> netints(size_guess);
951 size_t num_netints = sacn_source_get_network_interfaces(handle_.value(), universe, netints.data(), netints.size());
952
953 while (num_netints > netints.size())
954 {
955 size_guess = num_netints + 4u;
956 netints.resize(size_guess);
957 num_netints = sacn_source_get_network_interfaces(handle_.value(), universe, netints.data(), netints.size());
958 }
959
960 netints.resize(num_netints);
961 return netints;
962}
963
970{
971 return handle_;
972}
973
974inline SacnSourceConfig Source::TranslateConfig(const Settings& settings)
975{
976 // clang-format off
977 SacnSourceConfig config = {
978 settings.cid.get(),
979 settings.name.c_str(),
980 settings.universe_count_max,
981 settings.manually_process_source,
982 settings.ip_supported,
983 settings.keep_alive_interval,
984 settings.pap_keep_alive_interval
985 };
986 // clang-format on
987
988 return config;
989}
990
991inline const SacnSourceUniverseConfig& Source::TranslatedUniverseConfig::get() noexcept
992{
993 if (!unicast_destinations_.empty())
994 {
995 config_.unicast_destinations = unicast_destinations_.data();
996 config_.num_unicast_destinations = unicast_destinations_.size();
997 }
998
999 return config_;
1000}
1001
1002// clang-format off
1003inline Source::TranslatedUniverseConfig::TranslatedUniverseConfig(const UniverseSettings& settings)
1004 : config_{
1005 settings.universe,
1006 settings.priority,
1007 settings.send_preview,
1008 settings.send_unicast_only,
1009 nullptr,
1010 0,
1011 settings.sync_universe
1012 }
1013{
1014 // clang-format on
1015
1016 if (!settings.unicast_destinations.empty())
1017 {
1018 unicast_destinations_.reserve(settings.unicast_destinations.size());
1019 std::transform(settings.unicast_destinations.begin(), settings.unicast_destinations.end(),
1020 std::back_inserter(unicast_destinations_), [](const etcpal::IpAddr& dest) { return dest.get(); });
1021 }
1022}
1023
1024}; // namespace sacn
1025
1026#endif // SACN_CPP_SOURCE_H_
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
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:769
void RemoveUniverse(uint16_t universe)
Remove a universe from a source.
Definition source.h:463
etcpal::Error AddUniverse(const UniverseSettings &settings, McastMode mcast_mode)
Add a universe to an sACN source.
Definition source.h:401
etcpal::Error ChangeName(const std::string &new_name)
Change the name of an sACN source.
Definition source.h:371
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:796
static etcpal::Error ResetNetworking(McastMode mcast_mode, const SacnSendSocketConfig &send_socket_config)
Resets the underlying network sockets for all universes of all sources.
Definition source.h:827
Source & operator=(Source &&other)=default
Move a source instance.
Source(Source &&other)=default
Move a source instance.
etcpal::Error ChangeSynchronizationUniverse(uint16_t universe, uint16_t new_sync_universe)
Changes the synchronization universe for a universe.
Definition source.h:623
etcpal::Error Startup(const Settings &settings)
Create a new sACN source to send sACN data.
Definition source.h:331
etcpal::Error SendSynchronization(uint16_t universe)
Indicate that a new synchronization packet should be sent on the given synchronization universe.
Definition source.h:667
std::vector< etcpal::IpAddr > GetUnicastDestinations(uint16_t universe)
Obtain a vector of a universe's unicast destinations.
Definition source.h:531
etcpal::Error AddUnicastDestination(uint16_t universe, const etcpal::IpAddr &dest)
Add a unicast destination for a universe.
Definition source.h:506
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:647
constexpr Handle handle() const
Get the current handle to the underlying C source.
Definition source.h:969
void RemoveUnicastDestination(uint16_t universe, const etcpal::IpAddr &dest)
Remove a unicast destination on a universe.
Definition source.h:520
std::vector< uint16_t > GetUniverses()
Obtain a vector of this source's universes (sorted lowest to highest).
Definition source.h:473
std::vector< EtcPalMcastNetintId > GetNetworkInterfaces(uint16_t universe)
Obtain a vector of a universe's network interfaces.
Definition source.h:946
void Shutdown()
Destroy an sACN source instance.
Definition source.h:347
etcpal::Error ChangePreviewFlag(uint16_t universe, bool new_preview_flag)
Change the send_preview option on a universe.
Definition source.h:599
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:685
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:738
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:712
etcpal::Error ChangePriority(uint16_t universe, uint8_t new_priority)
Change the priority of a universe.
Definition source.h:576
TickMode
This enum determines the type of start code (levels and/or PAP) to process/transmit in a source tick.
Definition source.h:68
@ kProcessLevelsAndPap
Process/send everything (both levels and PAP + termination).
@ kProcessPapOnly
Process/send PAP only (excludes termination).
@ kProcessLevelsOnly
Process/send levels only (includes termination).
Definition source.h:48
C++ wrapper for the sACN init/deinit functions.
sacn_ip_support_t
This enum defines how the API module will use IPv4 and IPv6 networking.
Definition common.h:75
#define SACN_SEND_SOCKET_CONFIG_DEFAULT_INIT
Initializes the members of a SacnSendSocketConfig to defaults.
Definition common.h:182
#define SACN_NETINT_CONFIG_DEFAULT_INIT
Initializes the members of a SacnNetintConfig to defaults.
Definition common.h:187
@ kSacnIpV4AndIpV6
Use both IPv4 and IPv6.
Definition common.h:81
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:172
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:800
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:561
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:521
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:265
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:824
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:411
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:1051
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:106
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:486
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:920
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:874
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:716
void sacn_source_remove_universe(sacn_source_t handle, uint16_t universe)
Remove a universe from a source.
Definition source.c:354
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:378
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:622
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:1021
sacn_source_tick_mode_t
This enum determines the type of start code (levels and/or PAP) to process/transmit in a source tick.
Definition source.h:77
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:975
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:684
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:1122
int sacn_source_t
A handle to a sACN source.
Definition source.h:56
static const sacn_source_t kSacnSourceInvalid
An invalid sACN source handle value.
Definition source.h:58
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:1230
void sacn_source_destroy(sacn_source_t handle)
Destroy an sACN source instance.
Definition source.c:222
@ kSacnSourceTickModeProcessLevelsAndPap
Process/send everything (both levels and PAP + termination).
Definition source.h:83
@ kSacnSourceTickModeProcessPapOnly
Process/send PAP only (excludes termination).
Definition source.h:81
@ kSacnSourceTickModeProcessLevelsOnly
Process/send levels only (includes termination).
Definition source.h:79
@ kSacnSourceKeepAliveIntervalDefault
The default NULL start code keep-alive interval for sources, in milliseconds.
Definition source.h:70
@ kSacnSourcePapKeepAliveIntervalDefault
The default per-address priority keep-alive interval for sources, in milliseconds.
Definition source.h:72
@ kSacnSourceInfiniteUniverses
Constant for "infinite" when sending sACN universes.
Definition source.h:68
A namespace which contains all C++ language definitions in the sACN library.
Definition common.h:50
constexpr uint16_t kMinimumUniverse
The lowest sACN universe number supported.
Definition common.h:64
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
sACN Source API definitions
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
A set of configuration information for a sACN source.
Definition source.h:88
EtcPalUuid cid
The source's CID.
Definition source.h:92
A set of configuration information for a sACN universe.
Definition source.h:135
const EtcPalIpAddr * unicast_destinations
The initial set of unicast destinations for this universe.
Definition source.h:156
size_t num_unicast_destinations
The size of unicast_destinations.
Definition source.h:158
A set of configuration settings that a source needs to initialize.
Definition source.h:82
size_t universe_count_max
The maximum number of universes this source will send to when using dynamic memory.
Definition source.h:93
bool IsValid() const
Determine whether a Source Settings instance contains valid data for sACN operation.
Definition source.h:268
etcpal::Uuid cid
The source's CID.
Definition source.h:86
int keep_alive_interval
The interval at which the source will send NULL start code keep-alive packets during transmission sup...
Definition source.h:105
std::string name
The source's name, a UTF-8 encoded string.
Definition source.h:88
sacn_ip_support_t ip_supported
What IP networking the source will support.
Definition source.h:101
bool manually_process_source
If false (default), this source will be added to a background thread that will send sACN updates at a...
Definition source.h:98
Settings()=default
Create an empty, invalid data structure by default.
int pap_keep_alive_interval
The interval at which the source will send per-address priority keep-alive packets during transmissio...
Definition source.h:109
A set of network interfaces for a particular universe.
Definition source.h:162
uint16_t universe
The ID of the universe.
Definition source.h:166
bool no_netints
If this is true, this universe will not use any network interfaces for multicast traffic.
Definition source.h:173
sacn_source_t handle
The source's handle.
Definition source.h:164
std::vector< SacnMcastInterface > netints
If !empty, this is the list of interfaces the application wants to use, and the status codes are fill...
Definition source.h:170
UniverseNetintList()=default
Create an empty, invalid data structure by default.
A set of configuration settings for a new universe on a source.
Definition source.h:123
bool send_unicast_only
If true, this sACN source will only send unicast traffic on this universe.
Definition source.h:140
bool send_preview
If true, this sACN source will send preview data.
Definition source.h:137
bool IsValid() const
Determine whether a Universe Settings instance contains valid data for sACN operation.
Definition source.h:285
uint16_t universe
The universe number.
Definition source.h:128
uint8_t priority
The sACN universe priority that is sent in each packet.
Definition source.h:134
UniverseSettings()=default
Create an empty, invalid data structure by default.
std::vector< etcpal::IpAddr > unicast_destinations
The initial set of unicast destinations for this universe.
Definition source.h:144
uint16_t sync_universe
If non-zero, this is the synchronization universe used to synchronize the sACN output.
Definition source.h:148