sACN  2.0.1
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 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
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{
55
70inline etcpal::Error Init(const EtcPalLogParams* log_params = nullptr)
71{
72 return sacn_init(log_params, nullptr);
73}
74
90{
91 SacnNetintConfig netint_config = {sys_netints.data(), sys_netints.size()};
92 return sacn_init(log_params, &netint_config);
93}
94
110{
111 SacnNetintConfig netint_config = {sys_netints.data(), sys_netints.size()};
112 return sacn_init(nullptr, &netint_config);
113}
114
128inline etcpal::Error Init(const etcpal::Logger& logger)
129{
130 return sacn_init(&logger.log_params(), nullptr);
131}
132
147{
148 SacnNetintConfig netint_config = {sys_netints.data(), sys_netints.size()};
149 return sacn_init(&logger.log_params(), &netint_config);
150}
151
162inline void Deinit()
163{
164 return sacn_deinit();
165}
166
178{
179 return sacn_get_remote_source_handle(&source_cid.get());
180}
181
195{
196 EtcPalUuid cid;
197 etcpal_error_t error = sacn_get_remote_source_cid(source_handle, &cid);
198 etcpal::Uuid cid_to_return = cid;
199
200 if (error == kEtcPalErrOk)
201 return cid_to_return;
202
203 return error;
204}
205
206}; // namespace sacn
207
208#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:194
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:177
void Deinit()
Deinitialize the sACN library.
Definition common.h:162
etcpal::Error Init(const EtcPalLogParams *log_params=nullptr)
Initialize the sACN library.
Definition common.h:70
A namespace which contains all C++ language definitions in the sACN library.
Definition common.h:50
constexpr RemoteSourceHandle kInvalidRemoteSourceHandle
Definition common.h:54
sacn_remote_source_t RemoteSourceHandle
Definition common.h:52
T size(T... args)
Definition common.h:102