sACN  2.0.2
Implementation of ANSI E1.31 (Streaming ACN)
View other versions:
receiver.h
Go to the documentation of this file.
1 /******************************************************************************
2  * Copyright 2022 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
54 extern "C" {
55 #endif
56 
58 typedef 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 
80 {
84 
88 typedef struct SacnRecvUniverseData
89 {
93  uint16_t universe_id;
97  uint8_t priority;
103  bool preview;
111  uint8_t start_code;
119  const uint8_t* values;
121 
123 typedef struct SacnRemoteSource
124 {
132 
134 typedef struct SacnLostSource
135 {
146 
153 #define SACN_RECEIVER_OPTS_FILTER_PREVIEW_DATA 0x1
185 typedef void (*SacnUniverseDataCallback)(sacn_receiver_t receiver_handle, const EtcPalSockAddr* source_addr,
186  const SacnRemoteSource* source_info, const SacnRecvUniverseData* universe_data,
187  void* context);
188 
202 typedef void (*SacnSourcesLostCallback)(sacn_receiver_t handle, uint16_t universe, const SacnLostSource* lost_sources,
203  size_t num_lost_sources, void* context);
204 
212 typedef void (*SacnSamplingPeriodStartedCallback)(sacn_receiver_t handle, uint16_t universe, void* context);
213 
221 typedef void (*SacnSamplingPeriodEndedCallback)(sacn_receiver_t handle, uint16_t universe, void* context);
222 
238 typedef void (*SacnSourcePapLostCallback)(sacn_receiver_t handle, uint16_t universe, const SacnRemoteSource* source,
239  void* context);
240 
260 typedef void (*SacnSourceLimitExceededCallback)(sacn_receiver_t handle, uint16_t universe, void* context);
261 
263 typedef struct SacnReceiverCallbacks
264 {
271  void* context;
273 
275 typedef struct SacnReceiverConfig
276 {
277  /********* Required values **********/
278 
280  uint16_t universe_id;
283 
284  /********* Optional values **********/
285 
288 
294  unsigned int flags;
295 
299 
301 #define SACN_RECEIVER_CONFIG_DEFAULT_INIT \
302  { \
303  0, {NULL, NULL, NULL, NULL, NULL, NULL}, {1, DMX_ADDRESS_COUNT}, SACN_RECEIVER_INFINITE_SOURCES, 0, \
304  kSacnIpV4AndIpV6 \
305  }
306 
309 {
312 
317  size_t num_netints;
319 
321 
323  const SacnNetintConfig* netint_config);
325 etcpal_error_t sacn_receiver_get_universe(sacn_receiver_t handle, uint16_t* universe_id);
327 etcpal_error_t sacn_receiver_change_universe(sacn_receiver_t handle, uint16_t new_universe_id);
330  const SacnRecvUniverseSubrange* new_footprint);
333  const SacnReceiverNetintList* per_receiver_netint_lists,
334  size_t num_per_receiver_netint_lists);
335 size_t sacn_receiver_get_network_interfaces(sacn_receiver_t handle, EtcPalMcastNetintId* netints, size_t netints_size);
336 
337 void sacn_receiver_set_expired_wait(uint32_t wait_ms);
339 
340 #ifdef __cplusplus
341 }
342 #endif
343 
348 #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:185
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:418
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:216
struct SacnRemoteSource SacnRemoteSource
etcpal_error_t sacn_receiver_destroy(sacn_receiver_t handle)
Destroy a sACN receiver instance.
Definition: receiver.c:139
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:345
void(* SacnSamplingPeriodStartedCallback)(sacn_receiver_t handle, uint16_t universe, void *context)
Notify that a receiver's sampling period has begun.
Definition: receiver.h:212
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:260
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:505
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:238
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:202
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:291
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:255
uint32_t sacn_receiver_get_expired_wait()
Get the current value of the expired notification wait time.
Definition: receiver.c:551
void sacn_receiver_set_expired_wait(uint32_t wait_ms)
Set the expired notification wait time.
Definition: receiver.c:530
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:221
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:173
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:311
int sacn_receiver_t
Definition: receiver.h:58
Definition: receiver.h:135
EtcPalUuid cid
Definition: receiver.h:139
char name[SACN_SOURCE_NAME_MAX_LEN]
Definition: receiver.h:141
sacn_remote_source_t handle
Definition: receiver.h:137
bool terminated
Definition: receiver.h:144
Definition: common.h:85
Definition: common.h:102
Definition: receiver.h:264
SacnSamplingPeriodEndedCallback sampling_period_ended
Definition: receiver.h:268
SacnSamplingPeriodStartedCallback sampling_period_started
Definition: receiver.h:267
SacnSourcesLostCallback sources_lost
Definition: receiver.h:266
SacnUniverseDataCallback universe_data
Definition: receiver.h:265
SacnSourceLimitExceededCallback source_limit_exceeded
Definition: receiver.h:270
void * context
Definition: receiver.h:271
SacnSourcePapLostCallback source_pap_lost
Definition: receiver.h:269
Definition: receiver.h:276
SacnRecvUniverseSubrange footprint
Definition: receiver.h:287
SacnReceiverCallbacks callbacks
Definition: receiver.h:282
uint16_t universe_id
Definition: receiver.h:280
int source_count_max
Definition: receiver.h:292
sacn_ip_support_t ip_supported
Definition: receiver.h:297
unsigned int flags
Definition: receiver.h:294
Definition: receiver.h:309
sacn_receiver_t handle
Definition: receiver.h:311
size_t num_netints
Definition: receiver.h:317
SacnMcastInterface * netints
Definition: receiver.h:315
Definition: receiver.h:89
uint8_t start_code
Definition: receiver.h:111
uint8_t priority
Definition: receiver.h:97
bool preview
Definition: receiver.h:103
bool is_sampling
Definition: receiver.h:107
uint16_t universe_id
Definition: receiver.h:93
const uint8_t * values
Definition: receiver.h:119
SacnRecvUniverseSubrange slot_range
Definition: receiver.h:115
Definition: receiver.h:80
int address_count
Definition: receiver.h:82
int start_address
Definition: receiver.h:81
Definition: receiver.h:124
EtcPalUuid cid
Definition: receiver.h:128
char name[SACN_SOURCE_NAME_MAX_LEN]
Definition: receiver.h:130
sacn_remote_source_t handle
Definition: receiver.h:126