sACN  3.0.0
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;
58#define SACN_SOURCE_INVALID -1
59
66#define SACN_SOURCE_INFINITE_UNIVERSES 0
67
69#define SACN_SOURCE_KEEP_ALIVE_INTERVAL_DEFAULT 800
70
72#define SACN_SOURCE_PAP_KEEP_ALIVE_INTERVAL_DEFAULT 1000
73
84
86typedef struct SacnSourceConfig
87{
88 /********* Required values **********/
89
93 const char* name;
94
95 /********* Optional values **********/
96
101
107
110
114
119
121#define SACN_SOURCE_CONFIG_DEFAULT_INIT \
122 { \
123 kEtcPalNullUuid, NULL, SACN_SOURCE_INFINITE_UNIVERSES, false, kSacnIpV4AndIpV6, \
124 SACN_SOURCE_KEEP_ALIVE_INTERVAL_DEFAULT, SACN_SOURCE_PAP_KEEP_ALIVE_INTERVAL_DEFAULT \
125 }
126
128
131{
132 /********* Required values **********/
133
136 uint16_t universe;
137
138 /********* Optional values **********/
139
142 uint8_t priority;
143
146
149
155
159
161
163#define SACN_SOURCE_UNIVERSE_CONFIG_DEFAULT_INIT \
164 { \
165 0, 100, false, false, NULL, 0, 0 \
166 }
167
169
186
189
190etcpal_error_t sacn_source_change_name(sacn_source_t handle, const char* new_name);
191
193 const SacnNetintConfig* netint_config);
194void sacn_source_remove_universe(sacn_source_t handle, uint16_t universe);
195size_t sacn_source_get_universes(sacn_source_t handle, uint16_t* universes, size_t universes_size);
196
198void sacn_source_remove_unicast_destination(sacn_source_t handle, uint16_t universe, const EtcPalIpAddr* dest);
199size_t sacn_source_get_unicast_destinations(sacn_source_t handle, uint16_t universe, EtcPalIpAddr* destinations,
200 size_t destinations_size);
201
202etcpal_error_t sacn_source_change_priority(sacn_source_t handle, uint16_t universe, uint8_t new_priority);
203etcpal_error_t sacn_source_change_preview_flag(sacn_source_t handle, uint16_t universe, bool new_preview_flag);
205 uint16_t new_sync_universe);
206
207etcpal_error_t sacn_source_send_now(sacn_source_t handle, uint16_t universe, uint8_t start_code, const uint8_t* buffer,
208 size_t buflen);
210
211void sacn_source_update_levels(sacn_source_t handle, uint16_t universe, const uint8_t* new_levels,
212 size_t new_levels_size);
213void sacn_source_update_levels_and_pap(sacn_source_t handle, uint16_t universe, const uint8_t* new_levels,
214 size_t new_levels_size, const uint8_t* new_priorities,
215 size_t new_priorities_size);
216void sacn_source_update_levels_and_force_sync(sacn_source_t handle, uint16_t universe, const uint8_t* new_levels,
217 size_t new_levels_size);
219 const uint8_t* new_levels, size_t new_levels_size,
220 const uint8_t* new_priorities, size_t new_priorities_size);
221
223
226 const SacnSourceUniverseNetintList* per_universe_netint_lists,
227 size_t num_per_universe_netint_lists);
228
229size_t sacn_source_get_network_interfaces(sacn_source_t handle, uint16_t universe, EtcPalMcastNetintId* netints,
230 size_t netints_size);
231
232#ifdef __cplusplus
233}
234#endif
235
240#endif /* SACN_SOURCE_H_ */
Common definitions for sACN.
etcpal_error_t
sacn_ip_support_t
Definition common.h:71
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
struct SacnSourceUniverseNetintList SacnSourceUniverseNetintList
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
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
struct SacnSourceUniverseConfig SacnSourceUniverseConfig
void sacn_source_config_init(SacnSourceConfig *config)
Initialize an sACN Source Config struct to default values.
Definition source.c:53
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_universe_config_init(SacnSourceUniverseConfig *config)
Initialize an sACN Source Universe Config struct to default values.
Definition source.c:72
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
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
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
struct SacnSourceConfig SacnSourceConfig
@ kSacnSourceTickModeProcessLevelsAndPap
Definition source.h:82
@ kSacnSourceTickModeProcessPapOnly
Definition source.h:80
@ kSacnSourceTickModeProcessLevelsOnly
Definition source.h:78
Definition common.h:85
Definition common.h:102
Definition source.h:87
bool manually_process_source
Definition source.h:106
EtcPalUuid cid
Definition source.h:91
const char * name
Definition source.h:93
int keep_alive_interval
Definition source.h:113
int pap_keep_alive_interval
Definition source.h:117
sacn_ip_support_t ip_supported
Definition source.h:109
size_t universe_count_max
Definition source.h:100
Definition source.h:131
uint8_t priority
Definition source.h:142
uint16_t universe
Definition source.h:136
const EtcPalIpAddr * unicast_destinations
Definition source.h:152
bool send_preview
Definition source.h:145
uint16_t sync_universe
Definition source.h:158
size_t num_unicast_destinations
Definition source.h:154
bool send_unicast_only
Definition source.h:148
Definition source.h:172
uint16_t universe
Definition source.h:176
bool no_netints
Definition source.h:184
size_t num_netints
Definition source.h:182
SacnMcastInterface * netints
Definition source.h:180
sacn_source_t handle
Definition source.h:174