UltraGrid
UltraGrid Low-Latency High-Resolution Transmission System
Loading...
Searching...
No Matches
lib_common.h
Go to the documentation of this file.
1
5/*
6 * Copyright (c) 2011-2023 CESNET, z. s. p. o.
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, is permitted provided that the following conditions
11 * are met:
12 *
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 *
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 *
20 * 3. Neither the name of CESNET nor the names of its contributors may be
21 * used to endorse or promote products derived from this software without
22 * specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS
25 * "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING,
26 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
27 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
28 * EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
29 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
30 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
31 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
34 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
35 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 */
37
38#ifndef LIB_COMMON_H
39#define LIB_COMMON_H
40
41#include "host.h" // UNIQUE_LABEL
42
44#define MK_STATIC(A) A, NULL
45#define MK_STATIC_REF(A) &A, NULL
46
47#ifdef BUILD_LIBRARIES
48#include <dlfcn.h>
51#define MK_NAME(A) NULL, #A
52#define MK_NAME_REF(A) NULL, #A
53
54#define NULL_IF_BUILD_LIBRARIES(x) NULL
55
56#else /* BUILD_LIBRARIES */
57
58#define MK_NAME(A) A, NULL
59#define MK_NAME_REF(A) &A, NULL
60
61#define NULL_IF_BUILD_LIBRARIES(x) x
62
63#endif /* BUILD_LIBRARIES */
64
65#ifdef __cplusplus
66#include <list>
67void open_all(const char *pattern, std::list<void *> &libs);
68#endif
69
70#ifdef __cplusplus
71extern "C" {
72#endif
87const void *load_library(const char *name, enum library_class, int abi_version);
88void register_library(const char *name, const void *info, enum library_class, int abi_version, int hidden);
89void list_modules(enum library_class, int abi_version, bool full);
90bool list_all_modules();
91#ifdef __cplusplus
92}
93#endif
94
95#ifdef __cplusplus
96#include <map>
97#include <string>
98std::map<std::string, const void *> get_libraries_for_class(enum library_class cls, int abi_version, bool include_hidden = true);
99#endif
100
112#define REGISTER_MODULE_FUNCNAME(name, info, lclass, abi, funcname, hidden) static void funcname(void) __attribute__((constructor));\
113\
114static void funcname(void)\
115{\
116 register_library(#name, info, lclass, abi, hidden);\
117}\
118struct NOT_DEFINED_STRUCT_THAT_SWALLOWS_SEMICOLON
119
120#define REGISTER_MODULE_FUNC_FUNCNAME(name, func, lclass, abi, funcname, hidden) static void funcname(void) __attribute__((constructor));\
121\
122static void funcname(void)\
123{\
124 const void *info = func();\
125 if (info) {\
126 register_library(#name, info, lclass, abi, hidden);\
127 }\
128}\
129struct NOT_DEFINED_STRUCT_THAT_SWALLOWS_SEMICOLON
130
144#define REGISTER_MODULE(name, info, lclass, abi) REGISTER_MODULE_FUNCNAME(name, info, lclass, abi, UNIQUE_LABEL, 0)
145
150#define REGISTER_MODULE_WITH_FUNC(name, func, lclass, abi) REGISTER_MODULE_FUNC_FUNCNAME(name, func, lclass, abi, UNIQUE_LABEL, 0)
151
156#define REGISTER_HIDDEN_MODULE(name, info, lclass, abi) REGISTER_MODULE_FUNCNAME(name, info, lclass, abi, UNIQUE_LABEL, 1)
157
158#endif // defined LIB_COMMON_H
159
pattern
Definition testcard.c:94
enum library_class cls
Definition host.cpp:749
std::map< std::string, const void * > get_libraries_for_class(enum library_class cls, int abi_version, bool include_hidden=true)
library_class
Definition lib_common.h:73
@ LIBRARY_CLASS_VIDEO_POSTPROCESS
Definition lib_common.h:83
@ LIBRARY_CLASS_VIDEO_DECOMPRESS
Definition lib_common.h:81
@ LIBRARY_CLASS_AUDIO_FILTER
Definition lib_common.h:85
@ LIBRARY_CLASS_VIDEO_CAPTURE
Definition lib_common.h:78
@ LIBRARY_CLASS_AUDIO_PLAYBACK
Definition lib_common.h:77
@ LIBRARY_CLASS_VIDEO_RXTX
Definition lib_common.h:84
@ LIBRARY_CLASS_AUDIO_CAPTURE
Definition lib_common.h:76
@ LIBRARY_CLASS_VIDEO_DISPLAY
Definition lib_common.h:79
@ LIBRARY_CLASS_UNDEFINED
Definition lib_common.h:74
@ LIBRARY_CLASS_CAPTURE_FILTER
Definition lib_common.h:75
@ LIBRARY_CLASS_AUDIO_COMPRESS
Definition lib_common.h:80
@ LIBRARY_CLASS_VIDEO_COMPRESS
Definition lib_common.h:82
void list_modules(enum library_class, int abi_version, bool full)
bool list_all_modules()
const void * load_library(const char *name, enum library_class, int abi_version)
void open_all(const char *pattern, std::list< void * > &libs)
void register_library(const char *name, const void *info, enum library_class, int abi_version, int hidden)
const char * name
Definition settings.cpp:193