sACN  3.0.0
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;
60#define SACN_RECEIVER_INVALID -1
61
68#define SACN_RECEIVER_INFINITE_SOURCES 0
69
76#define SACN_DEFAULT_EXPIRED_WAIT_MS 1000u
77
84
124
135
149
156#define SACN_RECEIVER_OPTS_FILTER_PREVIEW_DATA 0x1
188typedef void (*SacnUniverseDataCallback)(sacn_receiver_t receiver_handle, const EtcPalSockAddr* source_addr,
189 const SacnRemoteSource* source_info, const SacnRecvUniverseData* universe_data,
190 void* context);
191
207typedef void (*SacnSourcesLostCallback)(sacn_receiver_t handle, uint16_t universe, const SacnLostSource* lost_sources,
208 size_t num_lost_sources, void* context);
209
220typedef void (*SacnSamplingPeriodStartedCallback)(sacn_receiver_t handle, uint16_t universe, void* context);
221
233typedef void (*SacnSamplingPeriodEndedCallback)(sacn_receiver_t handle, uint16_t universe, void* context);
234
250typedef void (*SacnSourcePapLostCallback)(sacn_receiver_t handle, uint16_t universe, const SacnRemoteSource* source,
251 void* context);
252
272typedef void (*SacnSourceLimitExceededCallback)(sacn_receiver_t handle, uint16_t universe, void* context);
273
285
287typedef struct SacnReceiverConfig
288{
289 /********* Required values **********/
290
292 uint16_t universe_id;
295
296 /********* Optional values **********/
297
300
306 unsigned int flags;
307
311
313#define SACN_RECEIVER_CONFIG_DEFAULT_INIT \
314 { \
315 0, {NULL, NULL, NULL, NULL, NULL, NULL}, {1, DMX_ADDRESS_COUNT}, SACN_RECEIVER_INFINITE_SOURCES, 0, \
316 kSacnIpV4AndIpV6 \
317 }
318
333
335
337 const SacnNetintConfig* netint_config);
339etcpal_error_t sacn_receiver_get_universe(sacn_receiver_t handle, uint16_t* universe_id);
341etcpal_error_t sacn_receiver_change_universe(sacn_receiver_t handle, uint16_t new_universe_id);
344 const SacnRecvUniverseSubrange* new_footprint);
347 const SacnReceiverNetintList* per_receiver_netint_lists,
348 size_t num_per_receiver_netint_lists);
349size_t sacn_receiver_get_network_interfaces(sacn_receiver_t handle, EtcPalMcastNetintId* netints, size_t netints_size);
350
351void sacn_receiver_set_expired_wait(uint32_t wait_ms);
353
354#ifdef __cplusplus
355}
356#endif
357
362#endif /* SACN_RECEIVER_H_ */
Common definitions for sACN.
etcpal_error_t
sacn_ip_support_t
Definition common.h:71
#define SACN_SOURCE_NAME_MAX_LEN
The maximum length of an sACN source name, including the null-terminator.
Definition common.h:50
uint16_t sacn_remote_source_t
Definition common.h:58
struct SacnReceiverCallbacks SacnReceiverCallbacks
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:188
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:424
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:219
struct SacnRemoteSource SacnRemoteSource
etcpal_error_t sacn_receiver_destroy(sacn_receiver_t handle)
Destroy a sACN receiver instance.
Definition receiver.c:140
struct SacnReceiverNetintList SacnReceiverNetintList
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:348
void(* SacnSamplingPeriodStartedCallback)(sacn_receiver_t handle, uint16_t universe, void *context)
Notify that a receiver's sampling period has begun.
Definition receiver.h:220
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:272
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:522
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:250
struct SacnLostSource SacnLostSource
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:207
void sacn_receiver_config_init(SacnReceiverConfig *config)
Initialize an sACN Receiver Config struct to default values.
Definition receiver.c:55
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. TODO: Not yet implem...
Definition receiver.c:294
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:258
uint32_t sacn_receiver_get_expired_wait()
Get the current value of the expired notification wait time.
Definition receiver.c:568
void sacn_receiver_set_expired_wait(uint32_t wait_ms)
Set the expired notification wait time.
Definition receiver.c:547
struct SacnRecvUniverseData SacnRecvUniverseData
struct SacnReceiverConfig SacnReceiverConfig
void(* SacnSamplingPeriodEndedCallback)(sacn_receiver_t handle, uint16_t universe, void *context)
Notify that a receiver's sampling period has ended.
Definition receiver.h:233
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
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:176
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. TODO: Not yet implemented.
Definition receiver.c:314
int sacn_receiver_t
Definition receiver.h:58
Definition receiver.h:138
EtcPalUuid cid
Definition receiver.h:142
char name[SACN_SOURCE_NAME_MAX_LEN]
Definition receiver.h:144
sacn_remote_source_t handle
Definition receiver.h:140
bool terminated
Definition receiver.h:147
Definition common.h:85
Definition common.h:102
Definition receiver.h:276
SacnSamplingPeriodEndedCallback sampling_period_ended
Definition receiver.h:280
SacnSamplingPeriodStartedCallback sampling_period_started
Definition receiver.h:279
SacnSourcesLostCallback sources_lost
Definition receiver.h:278
SacnUniverseDataCallback universe_data
Definition receiver.h:277
SacnSourceLimitExceededCallback source_limit_exceeded
Definition receiver.h:282
void * context
Definition receiver.h:283
SacnSourcePapLostCallback source_pap_lost
Definition receiver.h:281
Definition receiver.h:288
SacnRecvUniverseSubrange footprint
Definition receiver.h:299
SacnReceiverCallbacks callbacks
Definition receiver.h:294
uint16_t universe_id
Definition receiver.h:292
int source_count_max
Definition receiver.h:304
sacn_ip_support_t ip_supported
Definition receiver.h:309
unsigned int flags
Definition receiver.h:306
Definition receiver.h:321
sacn_receiver_t handle
Definition receiver.h:323
bool no_netints
Definition receiver.h:331
size_t num_netints
Definition receiver.h:329
SacnMcastInterface * netints
Definition receiver.h:327
Definition receiver.h:89
uint8_t start_code
Definition receiver.h:114
uint8_t priority
Definition receiver.h:97
bool preview
Definition receiver.h:103
bool is_sampling
Definition receiver.h:110
uint16_t universe_id
Definition receiver.h:93
const uint8_t * values
Definition receiver.h:122
SacnRecvUniverseSubrange slot_range
Definition receiver.h:118
Definition receiver.h:80
int address_count
Definition receiver.h:82
int start_address
Definition receiver.h:81
Definition receiver.h:127
EtcPalUuid cid
Definition receiver.h:131
char name[SACN_SOURCE_NAME_MAX_LEN]
Definition receiver.h:133
sacn_remote_source_t handle
Definition receiver.h:129