sACN  HEAD (unstable)
Implementation of ANSI E1.31 (Streaming ACN)
View other versions:
Loading...
Searching...
No Matches
receiver.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_RECEIVER_H_
29#define SACN_RECEIVER_H_
30
31#include <stdbool.h>
32#include <stdint.h>
33#include "etcpal/error.h"
34#include "etcpal/inet.h"
35#include "etcpal/log.h"
36#include "etcpal/netint.h"
37#include "etcpal/uuid.h"
38#include "sacn/common.h"
39
53#ifdef __cplusplus
54extern "C" {
55#endif
56
58typedef int sacn_receiver_t;
61
62enum
63{
71
79};
80
87
139
150
164
170enum
171{
206typedef void (*SacnUniverseDataCallback)(sacn_receiver_t receiver_handle,
207 const EtcPalSockAddr* source_addr,
208 const SacnRemoteSource* source_info,
209 const SacnRecvUniverseData* universe_data,
210 void* context);
211
228 uint16_t universe,
229 const SacnLostSource* lost_sources,
230 size_t num_lost_sources,
231 void* context);
232
243typedef void (*SacnSamplingPeriodStartedCallback)(sacn_receiver_t handle, uint16_t universe, void* context);
244
256typedef void (*SacnSamplingPeriodEndedCallback)(sacn_receiver_t handle, uint16_t universe, void* context);
257
274 uint16_t universe,
275 const SacnRemoteSource* source,
276 void* context);
277
297typedef void (*SacnSourceLimitExceededCallback)(sacn_receiver_t handle, uint16_t universe, void* context);
298
310
312typedef struct SacnReceiverConfig
313{
314 /********* Required values **********/
315
317 uint16_t universe_id;
320
321 /********* Optional values **********/
322
325
331 unsigned int flags;
332
336
338#define SACN_RECEIVER_CONFIG_DEFAULT_INIT \
339 {0, \
340 {NULL, NULL, NULL, NULL, NULL, NULL}, \
341 {1, kSacnDmxAddressCount}, \
342 kSacnReceiverInfiniteSources, \
343 0, \
344 kSacnIpV4AndIpV6}
345
360
362
364 sacn_receiver_t* handle,
365 const SacnNetintConfig* netint_config);
367etcpal_error_t sacn_receiver_get_universe(sacn_receiver_t handle, uint16_t* universe_id);
369etcpal_error_t sacn_receiver_change_universe(sacn_receiver_t handle, uint16_t new_universe_id);
372 uint16_t new_universe_id,
373 const SacnRecvUniverseSubrange* new_footprint);
376 const SacnReceiverNetintList* per_receiver_netint_lists,
377 size_t num_per_receiver_netint_lists);
378size_t sacn_receiver_get_network_interfaces(sacn_receiver_t handle, EtcPalMcastNetintId* netints, size_t netints_size);
379
380void sacn_receiver_set_expired_wait(uint32_t wait_ms);
382
383#ifdef __cplusplus
384}
385#endif
386
391#endif /* SACN_RECEIVER_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
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
@ kSacnSourceNameMaxLen
The maximum length of an sACN source name, including the null-terminator.
Definition common.h:58
struct SacnReceiverCallbacks SacnReceiverCallbacks
A set of callback functions that the library uses to notify the application about sACN events.
void(* SacnUniverseDataCallback)(sacn_receiver_t receiver_handle, const EtcPalSockAddr *source_addr, const SacnRemoteSource *source_info, const SacnRecvUniverseData *universe_data, void *context)
Notify that new universe data within the configured footprint has been received.
Definition receiver.h:206
etcpal_error_t sacn_receiver_reset_networking_per_receiver(const SacnNetintConfig *sys_netint_config, const SacnReceiverNetintList *per_receiver_netint_lists, size_t num_per_receiver_netint_lists)
Resets underlying network sockets and packet receipt state, determines network interfaces for each re...
Definition receiver.c:439
etcpal_error_t sacn_receiver_get_footprint(sacn_receiver_t handle, SacnRecvUniverseSubrange *footprint)
Get the footprint within the universe on which a sACN receiver is currently listening.
Definition receiver.c:233
struct SacnRemoteSource SacnRemoteSource
Information about a remote sACN source being tracked by a receiver.
etcpal_error_t sacn_receiver_destroy(sacn_receiver_t handle)
Destroy a sACN receiver instance.
Definition receiver.c:145
struct SacnReceiverNetintList SacnReceiverNetintList
A set of network interfaces for a particular receiver.
etcpal_error_t sacn_receiver_reset_networking(const SacnNetintConfig *sys_netint_config)
Resets underlying network sockets and packet receipt state, determines network interfaces for all rec...
Definition receiver.c:363
void(* SacnSamplingPeriodStartedCallback)(sacn_receiver_t handle, uint16_t universe, void *context)
Notify that a receiver's sampling period has begun.
Definition receiver.h:243
void(* SacnSourceLimitExceededCallback)(sacn_receiver_t handle, uint16_t universe, void *context)
Notify that more than the configured maximum number of sources are currently sending on the universe ...
Definition receiver.h:297
size_t sacn_receiver_get_network_interfaces(sacn_receiver_t handle, EtcPalMcastNetintId *netints, size_t netints_size)
Obtain a list of a receiver's network interfaces.
Definition receiver.c:537
void(* SacnSourcePapLostCallback)(sacn_receiver_t handle, uint16_t universe, const SacnRemoteSource *source, void *context)
Notify that a source has stopped transmission of per-address priority packets.
Definition receiver.h:273
struct SacnLostSource SacnLostSource
Information about a sACN source that was lost.
void(* SacnSourcesLostCallback)(sacn_receiver_t handle, uint16_t universe, const SacnLostSource *lost_sources, size_t num_lost_sources, void *context)
Notify that one or more sources have entered a source loss state.
Definition receiver.h:227
void sacn_receiver_config_init(SacnReceiverConfig *config)
Initialize an sACN Receiver Config struct to default values.
Definition receiver.c:55
static const sacn_receiver_t kSacnReceiverInvalid
An invalid sACN receiver handle value.
Definition receiver.h:60
etcpal_error_t sacn_receiver_change_footprint(sacn_receiver_t handle, const SacnRecvUniverseSubrange *new_footprint)
Change the footprint within the universe on which an sACN receiver is listening.
Definition receiver.c:308
etcpal_error_t sacn_receiver_change_universe(sacn_receiver_t handle, uint16_t new_universe_id)
Change the universe on which an sACN receiver is listening.
Definition receiver.c:272
uint32_t sacn_receiver_get_expired_wait()
Get the current value of the expired notification wait time.
Definition receiver.c:583
void sacn_receiver_set_expired_wait(uint32_t wait_ms)
Set the expired notification wait time.
Definition receiver.c:562
struct SacnRecvUniverseData SacnRecvUniverseData
A complete description of newly received universe data within the configured footprint.
struct SacnReceiverConfig SacnReceiverConfig
A set of configuration information for an sACN receiver.
void(* SacnSamplingPeriodEndedCallback)(sacn_receiver_t handle, uint16_t universe, void *context)
Notify that a receiver's sampling period has ended.
Definition receiver.h:256
etcpal_error_t sacn_receiver_create(const SacnReceiverConfig *config, sacn_receiver_t *handle, const SacnNetintConfig *netint_config)
Create a new sACN receiver to listen for sACN data on a universe.
Definition receiver.c:92
struct SacnRecvUniverseSubrange SacnRecvUniverseSubrange
Defines a range of addresses within a sACN universe.
etcpal_error_t sacn_receiver_get_universe(sacn_receiver_t handle, uint16_t *universe_id)
Get the universe on which a sACN receiver is currently listening.
Definition receiver.c:190
etcpal_error_t sacn_receiver_change_universe_and_footprint(sacn_receiver_t handle, uint16_t new_universe_id, const SacnRecvUniverseSubrange *new_footprint)
Change the universe and footprint on which an sACN receiver is listening.
Definition receiver.c:328
int sacn_receiver_t
A handle to an sACN receiver.
Definition receiver.h:58
@ kSacnReceiverOptsFilterPreviewData
Filter preview data.
Definition receiver.h:173
@ kSacnReceiverInfiniteSources
Constant for "infinite" when listening or merging sACN universes.
Definition receiver.h:70
@ kSacnDefaultExpiredWaitMs
The default expired notification wait time.
Definition receiver.h:78
Information about a sACN source that was lost.
Definition receiver.h:153
char name[kSacnSourceNameMaxLen]
The name of the source.
Definition receiver.h:159
bool terminated
If true, the source was determined to be lost due to the Stream_Terminated bit being set in the sACN ...
Definition receiver.h:162
EtcPalUuid cid
The Component Identifier (CID) of the source.
Definition receiver.h:157
sacn_remote_source_t handle
The handle of the source.
Definition receiver.h:155
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 callback functions that the library uses to notify the application about sACN events.
Definition receiver.h:301
void * context
(optional) Pointer to opaque data passed back with each callback.
Definition receiver.h:308
SacnUniverseDataCallback universe_data
Required.
Definition receiver.h:302
SacnSamplingPeriodEndedCallback sampling_period_ended
Optional.
Definition receiver.h:305
SacnSourcesLostCallback sources_lost
Required.
Definition receiver.h:303
SacnSamplingPeriodStartedCallback sampling_period_started
Optional.
Definition receiver.h:304
SacnSourceLimitExceededCallback source_limit_exceeded
Optional.
Definition receiver.h:307
SacnSourcePapLostCallback source_pap_lost
Optional.
Definition receiver.h:306
A set of configuration information for an sACN receiver.
Definition receiver.h:313
sacn_ip_support_t ip_supported
What IP networking the receiver will support.
Definition receiver.h:334
unsigned int flags
A set of option flags.
Definition receiver.h:331
SacnRecvUniverseSubrange footprint
The footprint within the universe to monitor.
Definition receiver.h:324
SacnReceiverCallbacks callbacks
The callbacks this receiver will use to notify the application of events.
Definition receiver.h:319
int source_count_max
The maximum number of sources this universe will listen to.
Definition receiver.h:329
uint16_t universe_id
Universe number on which to listen for sACN.
Definition receiver.h:317
A set of network interfaces for a particular receiver.
Definition receiver.h:348
bool no_netints
If this is true, this receiver will not use any network interfaces for multicast traffic.
Definition receiver.h:358
SacnMcastInterface * netints
If non-NULL, this is the list of interfaces the application wants to use, and the status codes are fi...
Definition receiver.h:354
sacn_receiver_t handle
The receiver's handle.
Definition receiver.h:350
size_t num_netints
The size of netints, or 0 if netints is NULL.
Definition receiver.h:356
A complete description of newly received universe data within the configured footprint.
Definition receiver.h:92
uint16_t sync_universe
The sync universe (TODO NOTE: sync is not fully implemented in the library).
Definition receiver.h:117
uint8_t start_code
The start code of the DMX data.
Definition receiver.h:129
uint8_t priority
The priority of the sACN data.
Definition receiver.h:100
uint8_t sequence
The sequence number field directly from the packet.
Definition receiver.h:121
bool is_sampling
True if this data is part of a sampling period, false otherwise.
Definition receiver.h:113
SacnRecvUniverseSubrange slot_range
The range of slots represented by this data (the intersection of the received data with the configure...
Definition receiver.h:133
const uint8_t * values
Pointer to the slot values at the location indicated by slot_range.
Definition receiver.h:137
uint16_t universe_id
The sACN Universe identifier.
Definition receiver.h:96
bool preview
Whether the Preview_Data bit is set for the sACN data.
Definition receiver.h:106
uint8_t options
The options field directly from the packet.
Definition receiver.h:125
Defines a range of addresses within a sACN universe.
Definition receiver.h:83
int start_address
The first address in the range (any value between 1 and 512 inclusive).
Definition receiver.h:84
int address_count
The number of addresses in the range.
Definition receiver.h:85
Information about a remote sACN source being tracked by a receiver.
Definition receiver.h:142
EtcPalUuid cid
The Component Identifier (CID) of the source.
Definition receiver.h:146
sacn_remote_source_t handle
The handle of the source.
Definition receiver.h:144
char name[kSacnSourceNameMaxLen]
The name of the source.
Definition receiver.h:148