sACN  3.0.0
Implementation of ANSI E1.31 (Streaming ACN)
View other versions:
Loading...
Searching...
No Matches
opts.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
27#ifndef SACN_PRIVATE_OPTS_H_
28#define SACN_PRIVATE_OPTS_H_
29
40#if SACN_HAVE_CONFIG_H
41/* User configuration options. Any non-defined ones will get their defaults in this file. */
42#include "sacn_config.h"
43#endif
44
45#include "etcpal/thread.h"
46
47/* Some option hints based on well-known compile definitions */
48
51/* Are we being compiled for a full-featured OS? */
52#if defined(_WIN32) || defined(__APPLE__) || defined(__linux__) || defined(__unix__) || defined(_POSIX_VERSION)
53#define SACN_FULL_OS_AVAILABLE_HINT 1
54#else
55#define SACN_FULL_OS_AVAILABLE_HINT 0
56#endif
57
60/*************************** sACN Global Options *****************************/
61
77#ifndef SACN_DYNAMIC_MEM
78#define SACN_DYNAMIC_MEM SACN_FULL_OS_AVAILABLE_HINT
79#endif
80
87#ifndef SACN_LOGGING_ENABLED
88#define SACN_LOGGING_ENABLED 1
89#endif
90
94#ifndef SACN_LOG_MSG_PREFIX
95#define SACN_LOG_MSG_PREFIX "sACN: "
96#endif
97
98/* Assertion failure handler */
99bool sacn_assert_verify_fail(const char* exp, const char* file, const char* func, const int line);
100
107#ifndef SACN_ASSERT_VERIFY
108#define SACN_ASSERT_VERIFY(exp) ((exp) ? true : sacn_assert_verify_fail(#exp, __FILE__, __func__, __LINE__))
109#endif
110
120#ifndef SACN_ASSERT
121#include <assert.h>
122#define SACN_ASSERT(expr) assert(expr)
123#endif
124
132#ifndef SACN_ETC_PRIORITY_EXTENSION
133#define SACN_ETC_PRIORITY_EXTENSION 1
134#endif
135
142#ifndef SACN_LOOPBACK
143#define SACN_LOOPBACK 1
144#endif
145
151#ifndef SACN_MAX_NETINTS
152#define SACN_MAX_NETINTS 2
153#endif
154
159/*************************** sACN Receive Options ****************************/
160
174#ifndef SACN_RECEIVER_THREAD_PRIORITY
175#define SACN_RECEIVER_THREAD_PRIORITY ETCPAL_THREAD_DEFAULT_PRIORITY
176#endif
177
183#ifndef SACN_RECEIVER_THREAD_STACK
184#define SACN_RECEIVER_THREAD_STACK ETCPAL_THREAD_DEFAULT_STACK
185#endif
186
192#ifndef SACN_RECEIVER_THREAD_NAME
193#define SACN_RECEIVER_THREAD_NAME "sACN Receive Thread"
194#endif
195
196/* Infinite read blocks are not supported due to the potential for hangs on shutdown. */
197#if defined(SACN_RECEIVER_READ_TIMEOUT_MS) && SACN_RECEIVER_READ_TIMEOUT_MS < 0
198#undef SACN_RECEIVER_READ_TIMEOUT_MS /* It will get the default value below */
199#endif
200
207#ifndef SACN_RECEIVER_READ_TIMEOUT_MS
208#define SACN_RECEIVER_READ_TIMEOUT_MS 100
209#endif
210
219#ifndef SACN_RECEIVER_MAX_UNIVERSES
220#define SACN_RECEIVER_MAX_UNIVERSES 1
221#endif
222
233#ifndef SACN_RECEIVER_MAX_SOURCES_PER_UNIVERSE
234#define SACN_RECEIVER_MAX_SOURCES_PER_UNIVERSE 4
235#endif
236
250#ifndef SACN_RECEIVER_TOTAL_MAX_SOURCES
251#define SACN_RECEIVER_TOTAL_MAX_SOURCES (SACN_RECEIVER_MAX_UNIVERSES * SACN_RECEIVER_MAX_SOURCES_PER_UNIVERSE)
252#endif
253
269#ifndef SACN_RECEIVER_LIMIT_BIND
270#define SACN_RECEIVER_LIMIT_BIND (!_WIN32 && !__APPLE__)
271#endif
272
287#ifdef SACN_RECEIVER_SOCKET_PER_NIC
288#if !SACN_RECEIVER_SOCKET_PER_NIC && _WIN32
289#error "Error: SACN_RECEIVER_SOCKET_PER_NIC was set to 0 on Windows, which is not supported due to performance issues."
290#endif
291#else
292#define SACN_RECEIVER_SOCKET_PER_NIC (_WIN32)
293#endif
294
302#ifndef SACN_RECEIVER_MAX_SUBS_PER_SOCKET
303#define SACN_RECEIVER_MAX_SUBS_PER_SOCKET 20
304#endif
305
307/* TODO investigate. Windows value was 110592 */
308#ifndef SACN_RECEIVER_SOCKET_RCVBUF_SIZE
309#define SACN_RECEIVER_SOCKET_RCVBUF_SIZE 32768
310#endif
320#ifndef SACN_RECEIVER_ENABLE_SO_REUSEPORT
321#define SACN_RECEIVER_ENABLE_SO_REUSEPORT 1
322#endif
323
331#ifndef SACN_RECEIVER_ENABLE_SO_RCVBUF
332#define SACN_RECEIVER_ENABLE_SO_RCVBUF 1
333#endif
334
338#undef SACN_RECEIVER_MAX_THREADS
339#define SACN_RECEIVER_MAX_THREADS 1
340
344#undef SACN_RECEIVER_MAX_FOOTPRINT
345#define SACN_RECEIVER_MAX_FOOTPRINT 512
346
351/***************************** sACN Send Options *****************************/
352
366#ifndef SACN_SOURCE_THREAD_PRIORITY
367#define SACN_SOURCE_THREAD_PRIORITY ETCPAL_THREAD_DEFAULT_PRIORITY
368#endif
369
375#ifndef SACN_SOURCE_THREAD_STACK
376#define SACN_SOURCE_THREAD_STACK ETCPAL_THREAD_DEFAULT_STACK
377#endif
378
384#ifndef SACN_SOURCE_THREAD_NAME
385#define SACN_SOURCE_THREAD_NAME "sACN Source Thread"
386#endif
387
389/* TODO investigate. Windows value was 20 */
390#ifndef SACN_SOURCE_MULTICAST_TTL
391#define SACN_SOURCE_MULTICAST_TTL 64
392#endif
405#ifndef SACN_SOURCE_SOCKET_SNDBUF_SIZE
406#define SACN_SOURCE_SOCKET_SNDBUF_SIZE 115000
407#endif
408
416#ifndef SACN_SOURCE_MAX_SOURCES
417#define SACN_SOURCE_MAX_SOURCES 1
418#endif
419
427#ifndef SACN_SOURCE_MAX_UNIVERSES_PER_SOURCE
428#define SACN_SOURCE_MAX_UNIVERSES_PER_SOURCE 4
429#endif
430
436#ifndef SACN_MAX_UNICAST_DESTINATIONS_PER_UNIVERSE
437#define SACN_MAX_UNICAST_DESTINATIONS_PER_UNIVERSE 4
438#endif
439
444/***************************** sACN DMX Merger Options *****************************/
445
461#ifdef SACN_DMX_MERGER_MAX_MERGERS
462#define SACN_DMX_MERGER_DEFAULT_MAX_MERGERS 0
463#else
464#define SACN_DMX_MERGER_MAX_MERGERS SACN_RECEIVER_MAX_UNIVERSES
465#define SACN_DMX_MERGER_DEFAULT_MAX_MERGERS 1
466#endif
467
475#ifndef SACN_DMX_MERGER_MAX_SOURCES_PER_MERGER
476#define SACN_DMX_MERGER_MAX_SOURCES_PER_MERGER SACN_RECEIVER_MAX_SOURCES_PER_UNIVERSE
477#endif
478
482#undef SACN_DMX_MERGER_MAX_SLOTS
483#define SACN_DMX_MERGER_MAX_SLOTS 512
484
491#ifndef SACN_DMX_MERGER_DISABLE_INTERNAL_PAP_BUFFER
492#define SACN_DMX_MERGER_DISABLE_INTERNAL_PAP_BUFFER 0
493#endif
494
501#ifndef SACN_DMX_MERGER_DISABLE_INTERNAL_OWNER_BUFFER
502#define SACN_DMX_MERGER_DISABLE_INTERNAL_OWNER_BUFFER 0
503#endif
504
509/***************************** sACN Merge Receiver Options *****************************/
510
527#ifndef SACN_MERGE_RECEIVER_ENABLE_IN_STATIC_MEMORY_MODE
528#define SACN_MERGE_RECEIVER_ENABLE_IN_STATIC_MEMORY_MODE \
529 ((SACN_RECEIVER_MAX_UNIVERSES > 0) && (SACN_RECEIVER_MAX_SOURCES_PER_UNIVERSE > 0) && \
530 (SACN_RECEIVER_TOTAL_MAX_SOURCES > 0) && (SACN_DMX_MERGER_MAX_MERGERS > 0) && \
531 (SACN_DMX_MERGER_MAX_SOURCES_PER_MERGER > 0))
532#endif
533
534#if !SACN_DYNAMIC_MEM && SACN_MERGE_RECEIVER_ENABLE_IN_STATIC_MEMORY_MODE && \
535 ((SACN_RECEIVER_MAX_UNIVERSES <= 0) || (SACN_RECEIVER_MAX_SOURCES_PER_UNIVERSE <= 0) || \
536 (SACN_RECEIVER_TOTAL_MAX_SOURCES <= 0))
537#error "Error: SACN_MERGE_RECEIVER_ENABLE_IN_STATIC_MEMORY_MODE was set to 1, but the sACN Receiver API is disabled!"
538#endif
539
540#if !SACN_DYNAMIC_MEM && SACN_MERGE_RECEIVER_ENABLE_IN_STATIC_MEMORY_MODE && \
541 ((SACN_DMX_MERGER_MAX_MERGERS <= 0) || (SACN_DMX_MERGER_MAX_SOURCES_PER_MERGER <= 0))
542#error "Error: SACN_MERGE_RECEIVER_ENABLE_IN_STATIC_MEMORY_MODE was set to 1, but the sACN DMX Merger API is disabled!"
543#endif
544
553#ifndef SACN_MERGE_RECEIVER_ENABLE_SAMPLING_MERGER
554#define SACN_MERGE_RECEIVER_ENABLE_SAMPLING_MERGER 1
555#endif
556
557#if SACN_MERGE_RECEIVER_ENABLE_SAMPLING_MERGER && SACN_DMX_MERGER_DEFAULT_MAX_MERGERS
558#undef SACN_DMX_MERGER_MAX_MERGERS
559#define SACN_DMX_MERGER_MAX_MERGERS (SACN_RECEIVER_MAX_UNIVERSES * 2)
560#endif
561
566/***************************** sACN Source Detector Options *****************************/
567
586#ifndef SACN_SOURCE_DETECTOR_MAX_SOURCES
587#define SACN_SOURCE_DETECTOR_MAX_SOURCES 5
588#endif
589
600#ifndef SACN_SOURCE_DETECTOR_MAX_UNIVERSES_PER_SOURCE
601#define SACN_SOURCE_DETECTOR_MAX_UNIVERSES_PER_SOURCE 5
602#endif
603
608#endif /* SACN_PRIVATE_OPTS_H_ */