sACN  3.0.0
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
20#ifndef SACN_CPP_COMMON_H_
21#define SACN_CPP_COMMON_H_
22
28#include "etcpal/cpp/error.h"
29#include "etcpal/cpp/log.h"
30#include "etcpal/cpp/uuid.h"
31#include "sacn/common.h"
32
49namespace sacn
50{
52enum class McastMode
53{
54 kEnabledOnAllInterfaces,
55 kDisabledOnAllInterfaces
56};
57
62
79inline etcpal::Error Init(const EtcPalLogParams* log_params = nullptr,
80 McastMode mcast_mode = McastMode::kEnabledOnAllInterfaces)
81{
82 SacnNetintConfig netint_config = SACN_NETINT_CONFIG_DEFAULT_INIT;
83 if (mcast_mode == McastMode::kDisabledOnAllInterfaces)
84 netint_config.no_netints = true;
85
86 return sacn_init(log_params, &netint_config);
87}
88
104{
105 SacnNetintConfig netint_config = SACN_NETINT_CONFIG_DEFAULT_INIT;
106 netint_config.netints = sys_netints.data();
107 netint_config.num_netints = sys_netints.size();
108
109 return sacn_init(log_params, &netint_config);
110}
111
127{
128 SacnNetintConfig netint_config = SACN_NETINT_CONFIG_DEFAULT_INIT;
129 netint_config.netints = sys_netints.data();
130 netint_config.num_netints = sys_netints.size();
131
132 return sacn_init(nullptr, &netint_config);
133}
134
150inline etcpal::Error Init(const etcpal::Logger& logger, McastMode mcast_mode = McastMode::kEnabledOnAllInterfaces)
151{
152 SacnNetintConfig netint_config = SACN_NETINT_CONFIG_DEFAULT_INIT;
153 if (mcast_mode == McastMode::kDisabledOnAllInterfaces)
154 netint_config.no_netints = true;
155
156 return sacn_init(&logger.log_params(), &netint_config);
157}
158
173{
174 SacnNetintConfig netint_config = SACN_NETINT_CONFIG_DEFAULT_INIT;
175 netint_config.netints = sys_netints.data();
176 netint_config.num_netints = sys_netints.size();
177
178 return sacn_init(&logger.log_params(), &netint_config);
179}
180
191inline void Deinit()
192{
193 return sacn_deinit();
194}
195
207{
208 return sacn_get_remote_source_handle(&source_cid.get());
209}
210
224{
225 EtcPalUuid cid;
226 etcpal_error_t error = sacn_get_remote_source_cid(source_handle, &cid);
227 etcpal::Uuid cid_to_return = cid;
228
229 if (error == kEtcPalErrOk)
230 return cid_to_return;
231
232 return error;
233}
234
235}; // namespace sacn
236
237#endif // SACN_CPP_COMMON_H_
const EtcPalLogParams & log_params() const noexcept
constexpr const EtcPalUuid & get() const noexcept
Common definitions for sACN.
T data(T... args)
etcpal_error_t
kEtcPalErrOk
uint16_t sacn_remote_source_t
Definition common.h:58
#define SACN_REMOTE_SOURCE_INVALID
Definition common.h:60
etcpal_error_t sacn_init(const EtcPalLogParams *log_params, const SacnNetintConfig *sys_netint_config)
Initialize the sACN library.
Definition common.c:68
sacn_remote_source_t sacn_get_remote_source_handle(const EtcPalUuid *source_cid)
Converts a remote source CID to the corresponding handle, or SACN_REMOTE_SOURCE_INVALID if not found.
Definition common.c:289
void sacn_deinit(void)
Deinitialize the sACN library.
Definition common.c:234
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:314
etcpal::Expected< etcpal::Uuid > GetRemoteSourceCid(RemoteSourceHandle source_handle)
Converts a remote source handle to the corresponding source CID.
Definition common.h:223
RemoteSourceHandle GetRemoteSourceHandle(const etcpal::Uuid &source_cid)
Converts a remote source CID to the corresponding handle, or SACN_REMOTE_SOURCE_INVALID if not found.
Definition common.h:206
etcpal::Error Init(const EtcPalLogParams *log_params=nullptr, McastMode mcast_mode=McastMode::kEnabledOnAllInterfaces)
Initialize the sACN library.
Definition common.h:79
void Deinit()
Deinitialize the sACN library.
Definition common.h:191
A namespace which contains all C++ language definitions in the sACN library.
Definition common.h:50
constexpr RemoteSourceHandle kInvalidRemoteSourceHandle
Definition common.h:61
sacn_remote_source_t RemoteSourceHandle
Definition common.h:59
McastMode
Definition common.h:53
T size(T... args)
Definition common.h:102
bool no_netints
Definition common.h:110
size_t num_netints
Definition common.h:107
SacnMcastInterface * netints
Definition common.h:105