sACN  HEAD (unstable)
Implementation of ANSI E1.31 (Streaming ACN)
View other versions:
Loading...
Searching...
No Matches
common.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
25#ifndef SACN_COMMON_H_
26#define SACN_COMMON_H_
27
28#include <stdbool.h>
29#include <stdint.h>
30#include "etcpal/error.h"
31#include "etcpal/inet.h"
32#include "etcpal/log.h"
33#include "etcpal/socket.h"
34#include "etcpal/uuid.h"
35
42#ifdef __cplusplus
43extern "C" {
44#endif
45
47typedef uint16_t sacn_remote_source_t;
50
51enum
52{
69};
70
83
100
108
128
145
154typedef void (*SacnUnicastSendErrorCallback)(const SacnSocketErrorInfo* err_info, void* context);
155
164typedef void (*SacnMulticastSendErrorCallback)(const SacnSocketErrorInfo* err_info, void* context);
165
173
177#define SACN_SEND_SOCKET_CONFIG_DEFAULT_VALUES 0, 0, kSacnIpV4AndIpV6
178
182#define SACN_SEND_SOCKET_CONFIG_DEFAULT_INIT {SACN_SEND_SOCKET_CONFIG_DEFAULT_VALUES}
183
187#define SACN_NETINT_CONFIG_DEFAULT_INIT {NULL, 0, false, SACN_SEND_SOCKET_CONFIG_DEFAULT_INIT}
188
190typedef uint32_t sacn_features_t;
191
205#define SACN_FEATURE_DMX_MERGER ((sacn_features_t)(1u << 0))
207// NOLINTNEXTLINE(cppcoreguidelines-macro-to-enum,modernize-macro-to-enum)
208#define SACN_FEATURES_ALL 0xffffffffu
214etcpal_error_t sacn_init(const EtcPalLogParams* log_params, const SacnNetintConfig* sys_netint_config);
216 const SacnNetintConfig* sys_netint_config,
217 const SacnCommonCallbacks* callbacks);
219 const SacnNetintConfig* sys_netint_config,
220 sacn_features_t features);
222 const SacnNetintConfig* sys_netint_config,
223 sacn_features_t features,
224 const SacnCommonCallbacks* callbacks);
225void sacn_deinit(void);
227
230
231#ifdef __cplusplus
232}
233#endif
234
239#endif /* SACN_COMMON_H_ */
etcpal_error_t
PLATFORM_DEFINED etcpal_socket_t
sacn_ip_support_t
This enum defines how the API module will use IPv4 and IPv6 networking.
Definition common.h:75
void(* SacnUnicastSendErrorCallback)(const SacnSocketErrorInfo *err_info, void *context)
Notify that an error just occurred sending unicast on a socket.
Definition common.h:154
struct SacnSendSocketConfig SacnSendSocketConfig
Configuration for send sockets (e.g.
struct SacnSocketErrorInfo SacnSocketErrorInfo
Information about a socket error that occurred.
uint16_t sacn_remote_source_t
A source discovered on an sACN network that has a CID - used by Receiver and Merge Receiver.
Definition common.h:47
struct SacnNetintConfig SacnNetintConfig
Network interface configuration information to give the sACN library.
etcpal_error_t sacn_init_features_with_cb(const EtcPalLogParams *log_params, const SacnNetintConfig *sys_netint_config, sacn_features_t features, const SacnCommonCallbacks *callbacks)
Initialize specific features of the sACN library.
Definition common.c:153
etcpal_error_t sacn_init(const EtcPalLogParams *log_params, const SacnNetintConfig *sys_netint_config)
Initialize all features of the sACN library.
Definition common.c:75
sacn_remote_source_t sacn_get_remote_source_handle(const EtcPalUuid *source_cid)
Converts a remote source CID to the corresponding handle, or kSacnRemoteSourceInvalid if not found.
Definition common.c:580
void sacn_deinit_features(sacn_features_t features)
Deinitialize specific features of the sACN library.
Definition common.c:496
void sacn_deinit(void)
Deinitialize all features of the sACN library.
Definition common.c:479
etcpal_error_t sacn_get_remote_source_cid(sacn_remote_source_t source_handle, EtcPalUuid *source_cid)
Converts a remote source handle to the corresponding source CID.
Definition common.c:605
etcpal_error_t sacn_init_with_cb(const EtcPalLogParams *log_params, const SacnNetintConfig *sys_netint_config, const SacnCommonCallbacks *callbacks)
Initialize all features of the sACN library.
Definition common.c:99
struct SacnMcastInterface SacnMcastInterface
On input, this structure is used to indicate a network interface to use.
uint32_t sacn_features_t
A mask of desired sACN features.
Definition common.h:190
struct SacnCommonCallbacks SacnCommonCallbacks
A set of callback functions that the library uses to notify the application about sACN events.
void(* SacnMulticastSendErrorCallback)(const SacnSocketErrorInfo *err_info, void *context)
Notify that an error just occurred sending multicast on a socket.
Definition common.h:164
etcpal_error_t sacn_init_features(const EtcPalLogParams *log_params, const SacnNetintConfig *sys_netint_config, sacn_features_t features)
Initialize specific features of the sACN library.
Definition common.c:124
static const sacn_remote_source_t kSacnRemoteSourceInvalid
An invalid remote source handle value.
Definition common.h:49
@ kSacnIpV4Only
Use IPv4 only.
Definition common.h:77
@ kSacnIpV4AndIpV6
Use both IPv4 and IPv6.
Definition common.h:81
@ kSacnIpV6Only
Use IPv6 only.
Definition common.h:79
@ kSacnMinimumUniverse
The lowest sACN universe number supported.
Definition common.h:66
@ kSacnStartcodePriority
The per-address priority start code.
Definition common.h:64
@ kSacnSourceNameMaxLen
The maximum length of an sACN source name, including the null-terminator.
Definition common.h:58
@ kSacnMaximumUniverse
The highest sACN universe number supported.
Definition common.h:68
@ kSacnDmxAddressCount
The number of addresses in a DMX universe.
Definition common.h:60
@ kSacnStartcodeDmx
The DMX start code.
Definition common.h:62
A set of callback functions that the library uses to notify the application about sACN events.
Definition common.h:168
SacnUnicastSendErrorCallback unicast_send_error
Optional.
Definition common.h:169
SacnMulticastSendErrorCallback multicast_send_error
Optional.
Definition common.h:170
void * context
(optional) Pointer to opaque data passed back with each callback.
Definition common.h:171
On input, this structure is used to indicate a network interface to use.
Definition common.h:89
EtcPalMcastNetintId iface
The multicast interface to use.
Definition common.h:93
etcpal_error_t status
The status of the multicast interface.
Definition common.h:98
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
int multicast_sndtimeo_ms
Multicast send socket timeout in milliseconds (0 if disabled).
Definition common.h:105
sacn_ip_support_t unicast_ip_support
Whether to create unicast send sockets for IPv4, IPv6, or both.
Definition common.h:106
int unicast_sndtimeo_ms
Unicast send socket timeout in milliseconds (0 if disabled).
Definition common.h:104
Information about a socket error that occurred.
Definition common.h:131
int flags
Flags used in the send operation.
Definition common.h:141
etcpal_socket_t socket
The socket the error occurred on.
Definition common.h:135
size_t length
The length of the message.
Definition common.h:139
const EtcPalSockAddr * dest_addr
The destination address the message was being sent to.
Definition common.h:143
etcpal_error_t error
The EtcPal error returned by etcpal_sendto().
Definition common.h:133
const void * message
The message that was being sent when the error occurred.
Definition common.h:137