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
28#ifndef SACN_SOURCE_H_
29#define SACN_SOURCE_H_
30
31#include <stdbool.h>
32#include <stddef.h>
33#include <stdint.h>
34#include "etcpal/error.h"
35#include "etcpal/inet.h"
36#include "etcpal/uuid.h"
37#include "sacn/common.h"
38
51#ifdef __cplusplus
52extern "C" {
53#endif
54
56typedef int sacn_source_t;
59
60enum
61{
73};
74
85
87typedef struct SacnSourceConfig
88{
89 /********* Required values **********/
90
94 const char* name;
95
96 /********* Optional values **********/
97
102
108
111
115
120
122#define SACN_SOURCE_CONFIG_DEFAULT_INIT \
123 {kEtcPalNullUuid, \
124 NULL, \
125 kSacnSourceInfiniteUniverses, \
126 false, \
127 kSacnIpV4AndIpV6, \
128 kSacnSourceKeepAliveIntervalDefault, \
129 kSacnSourcePapKeepAliveIntervalDefault}
130
132
135{
136 /********* Required values **********/
137
140 uint16_t universe;
141
142 /********* Optional values **********/
143
146 uint8_t priority;
147
150
153
159
163
165
167#define SACN_SOURCE_UNIVERSE_CONFIG_DEFAULT_INIT {0, 100, false, false, NULL, 0, 0}
168
170
187
190
191etcpal_error_t sacn_source_change_name(sacn_source_t handle, const char* new_name);
192
194 const SacnSourceUniverseConfig* config,
195 const SacnNetintConfig* netint_config);
196void sacn_source_remove_universe(sacn_source_t handle, uint16_t universe);
197size_t sacn_source_get_universes(sacn_source_t handle, uint16_t* universes, size_t universes_size);
198
200void sacn_source_remove_unicast_destination(sacn_source_t handle, uint16_t universe, const EtcPalIpAddr* dest);
202 uint16_t universe,
203 EtcPalIpAddr* destinations,
204 size_t destinations_size);
205
206etcpal_error_t sacn_source_change_priority(sacn_source_t handle, uint16_t universe, uint8_t new_priority);
207etcpal_error_t sacn_source_change_preview_flag(sacn_source_t handle, uint16_t universe, bool new_preview_flag);
209 uint16_t universe,
210 uint16_t new_sync_universe);
211
213 uint16_t universe,
214 uint8_t start_code,
215 const uint8_t* buffer,
216 size_t buflen);
218
220 uint16_t universe,
221 const uint8_t* new_levels,
222 size_t new_levels_size);
224 uint16_t universe,
225 const uint8_t* new_levels,
226 size_t new_levels_size,
227 const uint8_t* new_priorities,
228 size_t new_priorities_size);
230 uint16_t universe,
231 const uint8_t* new_levels,
232 size_t new_levels_size);
234 uint16_t universe,
235 const uint8_t* new_levels,
236 size_t new_levels_size,
237 const uint8_t* new_priorities,
238 size_t new_priorities_size);
239
241
244 const SacnSourceUniverseNetintList* per_universe_netint_lists,
245 size_t num_per_universe_netint_lists);
246
248 uint16_t universe,
249 EtcPalMcastNetintId* netints,
250 size_t netints_size);
251
252#ifdef __cplusplus
253}
254#endif
255
260#endif /* SACN_SOURCE_H_ */
Common definitions for sACN.
etcpal_error_t
sacn_ip_support_t
This enum defines how the API module will use IPv4 and IPv6 networking.
Definition common.h:75
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
struct SacnSourceUniverseNetintList SacnSourceUniverseNetintList
A set of network interfaces for a particular universe.
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
struct SacnSourceUniverseConfig SacnSourceUniverseConfig
A set of configuration information for a sACN universe.
void sacn_source_config_init(SacnSourceConfig *config)
Initialize an sACN Source Config struct to default values.
Definition source.c:55
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_universe_config_init(SacnSourceUniverseConfig *config)
Initialize an sACN Source Universe Config struct to default values.
Definition source.c:74
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
struct SacnSourceConfig SacnSourceConfig
A set of configuration information for a sACN source.
@ 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
On input, this structure is used to indicate a network interface to use.
Definition common.h:89
Network interface configuration information to give the sACN library.
Definition common.h:114
A set of configuration information for a sACN source.
Definition source.h:88
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:107
int pap_keep_alive_interval
The interval at which the source will send keep-alive per-address priority packets during transmissio...
Definition source.h:118
EtcPalUuid cid
The source's CID.
Definition source.h:92
int keep_alive_interval
The interval at which the source will send keep-alive NULL start code packets during transmission sup...
Definition source.h:114
sacn_ip_support_t ip_supported
What IP networking the source will support.
Definition source.h:110
size_t universe_count_max
The maximum number of universes this source will send to.
Definition source.h:101
const char * name
The source's name, a UTF-8 encoded string.
Definition source.h:94
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
uint8_t priority
The sACN universe priority that is sent in each packet.
Definition source.h:146
uint16_t sync_universe
If non-zero, this is the synchronization universe used to synchronize the sACN output.
Definition source.h:162
bool send_unicast_only
If true, this sACN source will only send unicast traffic on this universe.
Definition source.h:152
bool send_preview
If true, this sACN source will send preview data.
Definition source.h:149
uint16_t universe
The universe number.
Definition source.h:140
A set of network interfaces for a particular universe.
Definition source.h:173
sacn_source_t handle
The source's handle.
Definition source.h:175
SacnMcastInterface * netints
If non-NULL, this is the list of interfaces the application wants to use, and the status codes are fi...
Definition source.h:181
size_t num_netints
The size of netints, or 0 if netints is NULL.
Definition source.h:183
uint16_t universe
The ID of the universe.
Definition source.h:177
bool no_netints
If this is true, this universe will not use any network interfaces for multicast traffic.
Definition source.h:185