noobs 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/COPYING +339 -0
- package/README.md +46 -0
- package/bin/64bit/obs.lib +0 -0
- package/binding.gyp +23 -0
- package/dist/bin/Qt6Core.dll +0 -0
- package/dist/bin/Qt6Gui.dll +0 -0
- package/dist/bin/Qt6Network.dll +0 -0
- package/dist/bin/Qt6Svg.dll +0 -0
- package/dist/bin/Qt6Widgets.dll +0 -0
- package/dist/bin/Qt6Xml.dll +0 -0
- package/dist/bin/avcodec-61.dll +0 -0
- package/dist/bin/avdevice-61.dll +0 -0
- package/dist/bin/avfilter-10.dll +0 -0
- package/dist/bin/avformat-61.dll +0 -0
- package/dist/bin/avutil-59.dll +0 -0
- package/dist/bin/datachannel.dll +0 -0
- package/dist/bin/libcurl.dll +0 -0
- package/dist/bin/libobs-d3d11.dll +0 -0
- package/dist/bin/libobs-opengl.dll +0 -0
- package/dist/bin/libobs-winrt.dll +0 -0
- package/dist/bin/librist.dll +0 -0
- package/dist/bin/libx264-164.dll +0 -0
- package/dist/bin/lua51.dll +0 -0
- package/dist/bin/obs-amf-test.exe +0 -0
- package/dist/bin/obs-ffmpeg-mux.exe +0 -0
- package/dist/bin/obs-frontend-api.dll +0 -0
- package/dist/bin/obs-scripting.dll +0 -0
- package/dist/bin/obs.dll +0 -0
- package/dist/bin/srt.dll +0 -0
- package/dist/bin/swresample-5.dll +0 -0
- package/dist/bin/swscale-8.dll +0 -0
- package/dist/bin/w32-pthreads.dll +0 -0
- package/dist/bin/zlib.dll +0 -0
- package/dist/effects/area.effect +250 -0
- package/dist/effects/bicubic_scale.effect +236 -0
- package/dist/effects/bilinear_lowres_scale.effect +123 -0
- package/dist/effects/color.effect +172 -0
- package/dist/effects/default.effect +254 -0
- package/dist/effects/default_rect.effect +84 -0
- package/dist/effects/deinterlace_base.effect +325 -0
- package/dist/effects/deinterlace_blend.effect +21 -0
- package/dist/effects/deinterlace_blend_2x.effect +21 -0
- package/dist/effects/deinterlace_discard.effect +21 -0
- package/dist/effects/deinterlace_discard_2x.effect +21 -0
- package/dist/effects/deinterlace_linear.effect +21 -0
- package/dist/effects/deinterlace_linear_2x.effect +21 -0
- package/dist/effects/deinterlace_yadif.effect +21 -0
- package/dist/effects/deinterlace_yadif_2x.effect +21 -0
- package/dist/effects/format_conversion.effect +1823 -0
- package/dist/effects/lanczos_scale.effect +292 -0
- package/dist/effects/opaque.effect +159 -0
- package/dist/effects/premultiplied_alpha.effect +38 -0
- package/dist/effects/repeat.effect +36 -0
- package/dist/effects/solid.effect +80 -0
- package/dist/noobs.node +0 -0
- package/dist/plugins/obs-ffmpeg.dll +0 -0
- package/dist/plugins/obs-x264.dll +0 -0
- package/dist/plugins/win-capture.dll +0 -0
- package/include/audio-monitoring/osx/mac-helpers.h +13 -0
- package/include/audio-monitoring/pulse/pulseaudio-wrapper.h +212 -0
- package/include/audio-monitoring/win32/wasapi-output.h +22 -0
- package/include/callback/calldata.h +195 -0
- package/include/callback/decl.h +61 -0
- package/include/callback/proc.h +52 -0
- package/include/callback/signal.h +73 -0
- package/include/graphics/axisang.h +65 -0
- package/include/graphics/bounds.h +108 -0
- package/include/graphics/device-exports.h +177 -0
- package/include/graphics/effect-parser.h +290 -0
- package/include/graphics/effect.h +190 -0
- package/include/graphics/graphics-internal.h +335 -0
- package/include/graphics/graphics.h +1024 -0
- package/include/graphics/half.h +100 -0
- package/include/graphics/image-file.h +124 -0
- package/include/graphics/input.h +34 -0
- package/include/graphics/libnsgif/libnsgif.h +142 -0
- package/include/graphics/math-defs.h +45 -0
- package/include/graphics/math-extra.h +61 -0
- package/include/graphics/matrix3.h +98 -0
- package/include/graphics/matrix4.h +102 -0
- package/include/graphics/plane.h +85 -0
- package/include/graphics/quat.h +170 -0
- package/include/graphics/shader-parser.h +273 -0
- package/include/graphics/srgb.h +177 -0
- package/include/graphics/vec2.h +148 -0
- package/include/graphics/vec3.h +224 -0
- package/include/graphics/vec4.h +241 -0
- package/include/media-io/audio-io.h +228 -0
- package/include/media-io/audio-math.h +43 -0
- package/include/media-io/audio-resampler.h +44 -0
- package/include/media-io/format-conversion.h +50 -0
- package/include/media-io/frame-rate.h +29 -0
- package/include/media-io/media-io-defs.h +20 -0
- package/include/media-io/media-remux.h +37 -0
- package/include/media-io/video-frame.h +64 -0
- package/include/media-io/video-io.h +338 -0
- package/include/media-io/video-scaler.h +43 -0
- package/include/obs-audio-controls.h +250 -0
- package/include/obs-av1.h +47 -0
- package/include/obs-avc.h +55 -0
- package/include/obs-config.h +52 -0
- package/include/obs-data.h +311 -0
- package/include/obs-defs.h +52 -0
- package/include/obs-encoder.h +361 -0
- package/include/obs-ffmpeg-compat.h +13 -0
- package/include/obs-hevc.h +81 -0
- package/include/obs-hotkey.h +271 -0
- package/include/obs-hotkeys.h +653 -0
- package/include/obs-interaction.h +56 -0
- package/include/obs-internal.h +1459 -0
- package/include/obs-missing-files.h +53 -0
- package/include/obs-module.h +181 -0
- package/include/obs-nal.h +37 -0
- package/include/obs-nix-platform.h +53 -0
- package/include/obs-nix-wayland.h +24 -0
- package/include/obs-nix-x11.h +22 -0
- package/include/obs-nix.h +42 -0
- package/include/obs-output.h +96 -0
- package/include/obs-properties.h +364 -0
- package/include/obs-scene.h +127 -0
- package/include/obs-service.h +115 -0
- package/include/obs-source.h +568 -0
- package/include/obs.h +2608 -0
- package/include/obsconfig.h +13 -0
- package/include/obsversion.h +5 -0
- package/include/util/apple/cfstring-utils.h +16 -0
- package/include/util/array-serializer.h +37 -0
- package/include/util/base.h +97 -0
- package/include/util/bitstream.h +28 -0
- package/include/util/bmem.h +94 -0
- package/include/util/buffered-file-serializer.h +32 -0
- package/include/util/c99defs.h +75 -0
- package/include/util/cf-lexer.h +199 -0
- package/include/util/cf-parser.h +281 -0
- package/include/util/circlebuf.h +319 -0
- package/include/util/config-file.h +103 -0
- package/include/util/crc32.h +29 -0
- package/include/util/curl/curl-helper.h +35 -0
- package/include/util/darray.h +606 -0
- package/include/util/deque.h +319 -0
- package/include/util/dstr.h +320 -0
- package/include/util/file-serializer.h +34 -0
- package/include/util/lexer.h +273 -0
- package/include/util/pipe.h +52 -0
- package/include/util/platform.h +223 -0
- package/include/util/profiler.h +97 -0
- package/include/util/serializer.h +158 -0
- package/include/util/simde/check.h +285 -0
- package/include/util/simde/debug-trap.h +117 -0
- package/include/util/simde/hedley.h +2123 -0
- package/include/util/simde/simde-align.h +481 -0
- package/include/util/simde/simde-arch.h +537 -0
- package/include/util/simde/simde-common.h +918 -0
- package/include/util/simde/simde-constify.h +925 -0
- package/include/util/simde/simde-detect-clang.h +114 -0
- package/include/util/simde/simde-diagnostic.h +447 -0
- package/include/util/simde/simde-features.h +550 -0
- package/include/util/simde/simde-math.h +1858 -0
- package/include/util/simde/x86/mmx.h +2456 -0
- package/include/util/simde/x86/sse.h +4479 -0
- package/include/util/simde/x86/sse2.h +7549 -0
- package/include/util/source-profiler.h +66 -0
- package/include/util/sse-intrin.h +32 -0
- package/include/util/task.h +22 -0
- package/include/util/text-lookup.h +45 -0
- package/include/util/threading-posix.h +77 -0
- package/include/util/threading-windows.h +142 -0
- package/include/util/threading.h +103 -0
- package/include/util/utf8.h +35 -0
- package/include/util/uthash.h +34 -0
- package/include/util/util_uint128.h +108 -0
- package/include/util/util_uint64.h +34 -0
- package/include/util/windows/device-enum.h +14 -0
- package/include/util/windows/obfuscate.h +16 -0
- package/include/util/windows/win-registry.h +37 -0
- package/include/util/windows/win-version.h +57 -0
- package/include/util/windows/window-helpers.h +47 -0
- package/index.d.ts +38 -0
- package/index.js +8 -0
- package/package.json +31 -0
- package/src/main.cpp +321 -0
- package/src/obs_interface.cpp +605 -0
- package/src/obs_interface.h +74 -0
- package/src/utils.cpp +80 -0
- package/src/utils.h +3 -0
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2023 Lain Bailey <lain@obsproject.com>
|
|
3
|
+
*
|
|
4
|
+
* Permission to use, copy, modify, and distribute this software for any
|
|
5
|
+
* purpose with or without fee is hereby granted, provided that the above
|
|
6
|
+
* copyright notice and this permission notice appear in all copies.
|
|
7
|
+
*
|
|
8
|
+
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
9
|
+
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
10
|
+
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
11
|
+
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
12
|
+
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
13
|
+
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
14
|
+
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
#pragma once
|
|
18
|
+
|
|
19
|
+
#include "cf-lexer.h"
|
|
20
|
+
|
|
21
|
+
/*
|
|
22
|
+
* C-family parser
|
|
23
|
+
*
|
|
24
|
+
* Handles preprocessing/lexing/errors when parsing a file, and provides a
|
|
25
|
+
* set of parsing functions to be able to go through all the resulting tokens
|
|
26
|
+
* more easily.
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
#ifdef __cplusplus
|
|
30
|
+
extern "C" {
|
|
31
|
+
#endif
|
|
32
|
+
|
|
33
|
+
#define PARSE_SUCCESS 0
|
|
34
|
+
#define PARSE_CONTINUE -1
|
|
35
|
+
#define PARSE_BREAK -2
|
|
36
|
+
#define PARSE_UNEXPECTED_CONTINUE -3
|
|
37
|
+
#define PARSE_UNEXPECTED_BREAK -4
|
|
38
|
+
#define PARSE_EOF -5
|
|
39
|
+
|
|
40
|
+
struct cf_parser {
|
|
41
|
+
struct cf_lexer lex;
|
|
42
|
+
struct cf_preprocessor pp;
|
|
43
|
+
struct error_data error_list;
|
|
44
|
+
|
|
45
|
+
struct cf_token *cur_token;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
static inline void cf_parser_init(struct cf_parser *parser)
|
|
49
|
+
{
|
|
50
|
+
cf_lexer_init(&parser->lex);
|
|
51
|
+
cf_preprocessor_init(&parser->pp);
|
|
52
|
+
error_data_init(&parser->error_list);
|
|
53
|
+
|
|
54
|
+
parser->cur_token = NULL;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
static inline void cf_parser_free(struct cf_parser *parser)
|
|
58
|
+
{
|
|
59
|
+
cf_lexer_free(&parser->lex);
|
|
60
|
+
cf_preprocessor_free(&parser->pp);
|
|
61
|
+
error_data_free(&parser->error_list);
|
|
62
|
+
|
|
63
|
+
parser->cur_token = NULL;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
static inline bool cf_parser_parse(struct cf_parser *parser, const char *str, const char *file)
|
|
67
|
+
{
|
|
68
|
+
if (!cf_lexer_lex(&parser->lex, str, file))
|
|
69
|
+
return false;
|
|
70
|
+
|
|
71
|
+
if (!cf_preprocess(&parser->pp, &parser->lex, &parser->error_list))
|
|
72
|
+
return false;
|
|
73
|
+
|
|
74
|
+
parser->cur_token = cf_preprocessor_get_tokens(&parser->pp);
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
EXPORT void cf_adderror(struct cf_parser *parser, const char *error, int level, const char *val1, const char *val2,
|
|
79
|
+
const char *val3);
|
|
80
|
+
|
|
81
|
+
static inline void cf_adderror_expecting(struct cf_parser *p, const char *expected)
|
|
82
|
+
{
|
|
83
|
+
cf_adderror(p, "Expected '$1'", LEX_ERROR, expected, NULL, NULL);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
static inline void cf_adderror_unexpected_eof(struct cf_parser *p)
|
|
87
|
+
{
|
|
88
|
+
cf_adderror(p, "Unexpected EOF", LEX_ERROR, NULL, NULL, NULL);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
static inline void cf_adderror_syntax_error(struct cf_parser *p)
|
|
92
|
+
{
|
|
93
|
+
cf_adderror(p, "Syntax error", LEX_ERROR, NULL, NULL, NULL);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
static inline bool cf_next_token(struct cf_parser *p)
|
|
97
|
+
{
|
|
98
|
+
if (p->cur_token->type != CFTOKEN_SPACETAB && p->cur_token->type != CFTOKEN_NEWLINE &&
|
|
99
|
+
p->cur_token->type != CFTOKEN_NONE)
|
|
100
|
+
p->cur_token++;
|
|
101
|
+
|
|
102
|
+
while (p->cur_token->type == CFTOKEN_SPACETAB || p->cur_token->type == CFTOKEN_NEWLINE)
|
|
103
|
+
p->cur_token++;
|
|
104
|
+
|
|
105
|
+
return p->cur_token->type != CFTOKEN_NONE;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
static inline bool cf_next_valid_token(struct cf_parser *p)
|
|
109
|
+
{
|
|
110
|
+
if (!cf_next_token(p)) {
|
|
111
|
+
cf_adderror_unexpected_eof(p);
|
|
112
|
+
return false;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
return true;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
EXPORT bool cf_pass_pair(struct cf_parser *p, char in, char out);
|
|
119
|
+
|
|
120
|
+
static inline bool cf_go_to_token(struct cf_parser *p, const char *str1, const char *str2)
|
|
121
|
+
{
|
|
122
|
+
while (cf_next_token(p)) {
|
|
123
|
+
if (strref_cmp(&p->cur_token->str, str1) == 0) {
|
|
124
|
+
return true;
|
|
125
|
+
} else if (str2 && strref_cmp(&p->cur_token->str, str2) == 0) {
|
|
126
|
+
return true;
|
|
127
|
+
} else if (*p->cur_token->str.array == '{') {
|
|
128
|
+
if (!cf_pass_pair(p, '{', '}'))
|
|
129
|
+
break;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
return false;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
static inline bool cf_go_to_valid_token(struct cf_parser *p, const char *str1, const char *str2)
|
|
137
|
+
{
|
|
138
|
+
if (!cf_go_to_token(p, str1, str2)) {
|
|
139
|
+
cf_adderror_unexpected_eof(p);
|
|
140
|
+
return false;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
return true;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
static inline bool cf_go_to_token_type(struct cf_parser *p, enum cf_token_type type)
|
|
147
|
+
{
|
|
148
|
+
while (p->cur_token->type != CFTOKEN_NONE && p->cur_token->type != type)
|
|
149
|
+
p->cur_token++;
|
|
150
|
+
|
|
151
|
+
return p->cur_token->type != CFTOKEN_NONE;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
static inline int cf_token_should_be(struct cf_parser *p, const char *str, const char *goto1, const char *goto2)
|
|
155
|
+
{
|
|
156
|
+
if (strref_cmp(&p->cur_token->str, str) == 0)
|
|
157
|
+
return PARSE_SUCCESS;
|
|
158
|
+
|
|
159
|
+
if (goto1) {
|
|
160
|
+
if (!cf_go_to_token(p, goto1, goto2))
|
|
161
|
+
return PARSE_EOF;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
cf_adderror_expecting(p, str);
|
|
165
|
+
return PARSE_CONTINUE;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
static inline int cf_next_token_should_be(struct cf_parser *p, const char *str, const char *goto1, const char *goto2)
|
|
169
|
+
{
|
|
170
|
+
if (!cf_next_token(p)) {
|
|
171
|
+
cf_adderror_unexpected_eof(p);
|
|
172
|
+
return PARSE_EOF;
|
|
173
|
+
} else if (strref_cmp(&p->cur_token->str, str) == 0) {
|
|
174
|
+
return PARSE_SUCCESS;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
if (goto1) {
|
|
178
|
+
if (!cf_go_to_token(p, goto1, goto2))
|
|
179
|
+
return PARSE_EOF;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
cf_adderror_expecting(p, str);
|
|
183
|
+
return PARSE_CONTINUE;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
static inline bool cf_peek_token(struct cf_parser *p, struct cf_token *peek)
|
|
187
|
+
{
|
|
188
|
+
struct cf_token *cur_token = p->cur_token;
|
|
189
|
+
bool success = cf_next_token(p);
|
|
190
|
+
|
|
191
|
+
*peek = *p->cur_token;
|
|
192
|
+
p->cur_token = cur_token;
|
|
193
|
+
|
|
194
|
+
return success;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
static inline bool cf_peek_valid_token(struct cf_parser *p, struct cf_token *peek)
|
|
198
|
+
{
|
|
199
|
+
bool success = cf_peek_token(p, peek);
|
|
200
|
+
if (!success)
|
|
201
|
+
cf_adderror_unexpected_eof(p);
|
|
202
|
+
return success;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
static inline bool cf_token_is(struct cf_parser *p, const char *val)
|
|
206
|
+
{
|
|
207
|
+
return strref_cmp(&p->cur_token->str, val) == 0;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
static inline int cf_token_is_type(struct cf_parser *p, enum cf_token_type type, const char *type_expected,
|
|
211
|
+
const char *goto_token)
|
|
212
|
+
{
|
|
213
|
+
if (p->cur_token->type != type) {
|
|
214
|
+
cf_adderror_expecting(p, type_expected);
|
|
215
|
+
if (goto_token) {
|
|
216
|
+
if (!cf_go_to_valid_token(p, goto_token, NULL))
|
|
217
|
+
return PARSE_EOF;
|
|
218
|
+
}
|
|
219
|
+
return PARSE_CONTINUE;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
return PARSE_SUCCESS;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
static inline void cf_copy_token(struct cf_parser *p, char **dst)
|
|
226
|
+
{
|
|
227
|
+
*dst = bstrdup_n(p->cur_token->str.array, p->cur_token->str.len);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
static inline int cf_get_name(struct cf_parser *p, char **dst, const char *name, const char *goto_token)
|
|
231
|
+
{
|
|
232
|
+
int errcode;
|
|
233
|
+
|
|
234
|
+
errcode = cf_token_is_type(p, CFTOKEN_NAME, name, goto_token);
|
|
235
|
+
if (errcode != PARSE_SUCCESS)
|
|
236
|
+
return errcode;
|
|
237
|
+
|
|
238
|
+
*dst = bstrdup_n(p->cur_token->str.array, p->cur_token->str.len);
|
|
239
|
+
return PARSE_SUCCESS;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
static inline int cf_next_name(struct cf_parser *p, char **dst, const char *name, const char *goto_token)
|
|
243
|
+
{
|
|
244
|
+
if (!cf_next_valid_token(p))
|
|
245
|
+
return PARSE_EOF;
|
|
246
|
+
|
|
247
|
+
return cf_get_name(p, dst, name, goto_token);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
static inline int cf_next_token_copy(struct cf_parser *p, char **dst)
|
|
251
|
+
{
|
|
252
|
+
if (!cf_next_valid_token(p))
|
|
253
|
+
return PARSE_EOF;
|
|
254
|
+
|
|
255
|
+
cf_copy_token(p, dst);
|
|
256
|
+
return PARSE_SUCCESS;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
static inline int cf_get_name_ref(struct cf_parser *p, struct strref *dst, const char *name, const char *goto_token)
|
|
260
|
+
{
|
|
261
|
+
int errcode;
|
|
262
|
+
|
|
263
|
+
errcode = cf_token_is_type(p, CFTOKEN_NAME, name, goto_token);
|
|
264
|
+
if (errcode != PARSE_SUCCESS)
|
|
265
|
+
return errcode;
|
|
266
|
+
|
|
267
|
+
strref_copy(dst, &p->cur_token->str);
|
|
268
|
+
return PARSE_SUCCESS;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
static inline int cf_next_name_ref(struct cf_parser *p, struct strref *dst, const char *name, const char *goto_token)
|
|
272
|
+
{
|
|
273
|
+
if (!cf_next_valid_token(p))
|
|
274
|
+
return PARSE_EOF;
|
|
275
|
+
|
|
276
|
+
return cf_get_name_ref(p, dst, name, goto_token);
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
#ifdef __cplusplus
|
|
280
|
+
}
|
|
281
|
+
#endif
|
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2023 Lain Bailey <lain@obsproject.com>
|
|
3
|
+
*
|
|
4
|
+
* Permission to use, copy, modify, and distribute this software for any
|
|
5
|
+
* purpose with or without fee is hereby granted, provided that the above
|
|
6
|
+
* copyright notice and this permission notice appear in all copies.
|
|
7
|
+
*
|
|
8
|
+
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
9
|
+
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
10
|
+
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
11
|
+
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
12
|
+
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
13
|
+
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
14
|
+
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
#pragma once
|
|
18
|
+
|
|
19
|
+
#include "c99defs.h"
|
|
20
|
+
#include <string.h>
|
|
21
|
+
#include <stdlib.h>
|
|
22
|
+
#include <assert.h>
|
|
23
|
+
|
|
24
|
+
#include "bmem.h"
|
|
25
|
+
|
|
26
|
+
#ifdef __cplusplus
|
|
27
|
+
extern "C" {
|
|
28
|
+
#endif
|
|
29
|
+
|
|
30
|
+
/* Dynamic circular buffer */
|
|
31
|
+
|
|
32
|
+
OBS_DEPRECATED struct circlebuf {
|
|
33
|
+
void *data;
|
|
34
|
+
size_t size;
|
|
35
|
+
|
|
36
|
+
size_t start_pos;
|
|
37
|
+
size_t end_pos;
|
|
38
|
+
size_t capacity;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
OBS_DEPRECATED static inline void circlebuf_init(struct circlebuf *cb)
|
|
42
|
+
{
|
|
43
|
+
memset(cb, 0, sizeof(struct circlebuf));
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
OBS_DEPRECATED static inline void circlebuf_free(struct circlebuf *cb)
|
|
47
|
+
{
|
|
48
|
+
bfree(cb->data);
|
|
49
|
+
memset(cb, 0, sizeof(struct circlebuf));
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
OBS_DEPRECATED static inline void circlebuf_reorder_data(struct circlebuf *cb, size_t new_capacity)
|
|
53
|
+
{
|
|
54
|
+
size_t difference;
|
|
55
|
+
uint8_t *data;
|
|
56
|
+
|
|
57
|
+
if (!cb->size || !cb->start_pos || cb->end_pos > cb->start_pos)
|
|
58
|
+
return;
|
|
59
|
+
|
|
60
|
+
difference = new_capacity - cb->capacity;
|
|
61
|
+
data = (uint8_t *)cb->data + cb->start_pos;
|
|
62
|
+
memmove(data + difference, data, cb->capacity - cb->start_pos);
|
|
63
|
+
cb->start_pos += difference;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
OBS_DEPRECATED static inline void circlebuf_ensure_capacity(struct circlebuf *cb)
|
|
67
|
+
{
|
|
68
|
+
size_t new_capacity;
|
|
69
|
+
if (cb->size <= cb->capacity)
|
|
70
|
+
return;
|
|
71
|
+
|
|
72
|
+
new_capacity = cb->capacity * 2;
|
|
73
|
+
if (cb->size > new_capacity)
|
|
74
|
+
new_capacity = cb->size;
|
|
75
|
+
|
|
76
|
+
cb->data = brealloc(cb->data, new_capacity);
|
|
77
|
+
circlebuf_reorder_data(cb, new_capacity);
|
|
78
|
+
cb->capacity = new_capacity;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
OBS_DEPRECATED static inline void circlebuf_reserve(struct circlebuf *cb, size_t capacity)
|
|
82
|
+
{
|
|
83
|
+
if (capacity <= cb->capacity)
|
|
84
|
+
return;
|
|
85
|
+
|
|
86
|
+
cb->data = brealloc(cb->data, capacity);
|
|
87
|
+
circlebuf_reorder_data(cb, capacity);
|
|
88
|
+
cb->capacity = capacity;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
OBS_DEPRECATED static inline void circlebuf_upsize(struct circlebuf *cb, size_t size)
|
|
92
|
+
{
|
|
93
|
+
size_t add_size = size - cb->size;
|
|
94
|
+
size_t new_end_pos = cb->end_pos + add_size;
|
|
95
|
+
|
|
96
|
+
if (size <= cb->size)
|
|
97
|
+
return;
|
|
98
|
+
|
|
99
|
+
cb->size = size;
|
|
100
|
+
circlebuf_ensure_capacity(cb);
|
|
101
|
+
|
|
102
|
+
if (new_end_pos > cb->capacity) {
|
|
103
|
+
size_t back_size = cb->capacity - cb->end_pos;
|
|
104
|
+
size_t loop_size = add_size - back_size;
|
|
105
|
+
|
|
106
|
+
if (back_size)
|
|
107
|
+
memset((uint8_t *)cb->data + cb->end_pos, 0, back_size);
|
|
108
|
+
|
|
109
|
+
memset(cb->data, 0, loop_size);
|
|
110
|
+
new_end_pos -= cb->capacity;
|
|
111
|
+
} else {
|
|
112
|
+
memset((uint8_t *)cb->data + cb->end_pos, 0, add_size);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
cb->end_pos = new_end_pos;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/** Overwrites data at a specific point in the buffer (relative). */
|
|
119
|
+
OBS_DEPRECATED static inline void circlebuf_place(struct circlebuf *cb, size_t position, const void *data, size_t size)
|
|
120
|
+
{
|
|
121
|
+
size_t end_point = position + size;
|
|
122
|
+
size_t data_end_pos;
|
|
123
|
+
|
|
124
|
+
if (end_point > cb->size)
|
|
125
|
+
circlebuf_upsize(cb, end_point);
|
|
126
|
+
|
|
127
|
+
position += cb->start_pos;
|
|
128
|
+
if (position >= cb->capacity)
|
|
129
|
+
position -= cb->capacity;
|
|
130
|
+
|
|
131
|
+
data_end_pos = position + size;
|
|
132
|
+
if (data_end_pos > cb->capacity) {
|
|
133
|
+
size_t back_size = data_end_pos - cb->capacity;
|
|
134
|
+
size_t loop_size = size - back_size;
|
|
135
|
+
|
|
136
|
+
memcpy((uint8_t *)cb->data + position, data, loop_size);
|
|
137
|
+
memcpy(cb->data, (uint8_t *)data + loop_size, back_size);
|
|
138
|
+
} else {
|
|
139
|
+
memcpy((uint8_t *)cb->data + position, data, size);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
OBS_DEPRECATED static inline void circlebuf_push_back(struct circlebuf *cb, const void *data, size_t size)
|
|
144
|
+
{
|
|
145
|
+
size_t new_end_pos = cb->end_pos + size;
|
|
146
|
+
|
|
147
|
+
cb->size += size;
|
|
148
|
+
circlebuf_ensure_capacity(cb);
|
|
149
|
+
|
|
150
|
+
if (new_end_pos > cb->capacity) {
|
|
151
|
+
size_t back_size = cb->capacity - cb->end_pos;
|
|
152
|
+
size_t loop_size = size - back_size;
|
|
153
|
+
|
|
154
|
+
if (back_size)
|
|
155
|
+
memcpy((uint8_t *)cb->data + cb->end_pos, data, back_size);
|
|
156
|
+
memcpy(cb->data, (uint8_t *)data + back_size, loop_size);
|
|
157
|
+
|
|
158
|
+
new_end_pos -= cb->capacity;
|
|
159
|
+
} else {
|
|
160
|
+
memcpy((uint8_t *)cb->data + cb->end_pos, data, size);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
cb->end_pos = new_end_pos;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
OBS_DEPRECATED static inline void circlebuf_push_front(struct circlebuf *cb, const void *data, size_t size)
|
|
167
|
+
{
|
|
168
|
+
cb->size += size;
|
|
169
|
+
circlebuf_ensure_capacity(cb);
|
|
170
|
+
|
|
171
|
+
if (cb->size == size) {
|
|
172
|
+
cb->start_pos = 0;
|
|
173
|
+
cb->end_pos = size;
|
|
174
|
+
memcpy((uint8_t *)cb->data, data, size);
|
|
175
|
+
|
|
176
|
+
} else if (cb->start_pos < size) {
|
|
177
|
+
size_t back_size = size - cb->start_pos;
|
|
178
|
+
|
|
179
|
+
if (cb->start_pos)
|
|
180
|
+
memcpy(cb->data, (uint8_t *)data + back_size, cb->start_pos);
|
|
181
|
+
|
|
182
|
+
cb->start_pos = cb->capacity - back_size;
|
|
183
|
+
memcpy((uint8_t *)cb->data + cb->start_pos, data, back_size);
|
|
184
|
+
} else {
|
|
185
|
+
cb->start_pos -= size;
|
|
186
|
+
memcpy((uint8_t *)cb->data + cb->start_pos, data, size);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
OBS_DEPRECATED static inline void circlebuf_push_back_zero(struct circlebuf *cb, size_t size)
|
|
191
|
+
{
|
|
192
|
+
size_t new_end_pos = cb->end_pos + size;
|
|
193
|
+
|
|
194
|
+
cb->size += size;
|
|
195
|
+
circlebuf_ensure_capacity(cb);
|
|
196
|
+
|
|
197
|
+
if (new_end_pos > cb->capacity) {
|
|
198
|
+
size_t back_size = cb->capacity - cb->end_pos;
|
|
199
|
+
size_t loop_size = size - back_size;
|
|
200
|
+
|
|
201
|
+
if (back_size)
|
|
202
|
+
memset((uint8_t *)cb->data + cb->end_pos, 0, back_size);
|
|
203
|
+
memset(cb->data, 0, loop_size);
|
|
204
|
+
|
|
205
|
+
new_end_pos -= cb->capacity;
|
|
206
|
+
} else {
|
|
207
|
+
memset((uint8_t *)cb->data + cb->end_pos, 0, size);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
cb->end_pos = new_end_pos;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
OBS_DEPRECATED static inline void circlebuf_push_front_zero(struct circlebuf *cb, size_t size)
|
|
214
|
+
{
|
|
215
|
+
cb->size += size;
|
|
216
|
+
circlebuf_ensure_capacity(cb);
|
|
217
|
+
|
|
218
|
+
if (cb->size == size) {
|
|
219
|
+
cb->start_pos = 0;
|
|
220
|
+
cb->end_pos = size;
|
|
221
|
+
memset((uint8_t *)cb->data, 0, size);
|
|
222
|
+
|
|
223
|
+
} else if (cb->start_pos < size) {
|
|
224
|
+
size_t back_size = size - cb->start_pos;
|
|
225
|
+
|
|
226
|
+
if (cb->start_pos)
|
|
227
|
+
memset(cb->data, 0, cb->start_pos);
|
|
228
|
+
|
|
229
|
+
cb->start_pos = cb->capacity - back_size;
|
|
230
|
+
memset((uint8_t *)cb->data + cb->start_pos, 0, back_size);
|
|
231
|
+
} else {
|
|
232
|
+
cb->start_pos -= size;
|
|
233
|
+
memset((uint8_t *)cb->data + cb->start_pos, 0, size);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
OBS_DEPRECATED static inline void circlebuf_peek_front(struct circlebuf *cb, void *data, size_t size)
|
|
238
|
+
{
|
|
239
|
+
assert(size <= cb->size);
|
|
240
|
+
|
|
241
|
+
if (data) {
|
|
242
|
+
size_t start_size = cb->capacity - cb->start_pos;
|
|
243
|
+
|
|
244
|
+
if (start_size < size) {
|
|
245
|
+
memcpy(data, (uint8_t *)cb->data + cb->start_pos, start_size);
|
|
246
|
+
memcpy((uint8_t *)data + start_size, cb->data, size - start_size);
|
|
247
|
+
} else {
|
|
248
|
+
memcpy(data, (uint8_t *)cb->data + cb->start_pos, size);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
OBS_DEPRECATED static inline void circlebuf_peek_back(struct circlebuf *cb, void *data, size_t size)
|
|
254
|
+
{
|
|
255
|
+
assert(size <= cb->size);
|
|
256
|
+
|
|
257
|
+
if (data) {
|
|
258
|
+
size_t back_size = (cb->end_pos ? cb->end_pos : cb->capacity);
|
|
259
|
+
|
|
260
|
+
if (back_size < size) {
|
|
261
|
+
size_t front_size = size - back_size;
|
|
262
|
+
size_t new_end_pos = cb->capacity - front_size;
|
|
263
|
+
|
|
264
|
+
memcpy((uint8_t *)data + (size - back_size), cb->data, back_size);
|
|
265
|
+
memcpy(data, (uint8_t *)cb->data + new_end_pos, front_size);
|
|
266
|
+
} else {
|
|
267
|
+
memcpy(data, (uint8_t *)cb->data + cb->end_pos - size, size);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
OBS_DEPRECATED static inline void circlebuf_pop_front(struct circlebuf *cb, void *data, size_t size)
|
|
273
|
+
{
|
|
274
|
+
circlebuf_peek_front(cb, data, size);
|
|
275
|
+
|
|
276
|
+
cb->size -= size;
|
|
277
|
+
if (!cb->size) {
|
|
278
|
+
cb->start_pos = cb->end_pos = 0;
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
cb->start_pos += size;
|
|
283
|
+
if (cb->start_pos >= cb->capacity)
|
|
284
|
+
cb->start_pos -= cb->capacity;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
OBS_DEPRECATED static inline void circlebuf_pop_back(struct circlebuf *cb, void *data, size_t size)
|
|
288
|
+
{
|
|
289
|
+
circlebuf_peek_back(cb, data, size);
|
|
290
|
+
|
|
291
|
+
cb->size -= size;
|
|
292
|
+
if (!cb->size) {
|
|
293
|
+
cb->start_pos = cb->end_pos = 0;
|
|
294
|
+
return;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
if (cb->end_pos <= size)
|
|
298
|
+
cb->end_pos = cb->capacity - (size - cb->end_pos);
|
|
299
|
+
else
|
|
300
|
+
cb->end_pos -= size;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
OBS_DEPRECATED static inline void *circlebuf_data(struct circlebuf *cb, size_t idx)
|
|
304
|
+
{
|
|
305
|
+
uint8_t *ptr = (uint8_t *)cb->data;
|
|
306
|
+
size_t offset = cb->start_pos + idx;
|
|
307
|
+
|
|
308
|
+
if (idx >= cb->size)
|
|
309
|
+
return NULL;
|
|
310
|
+
|
|
311
|
+
if (offset >= cb->capacity)
|
|
312
|
+
offset -= cb->capacity;
|
|
313
|
+
|
|
314
|
+
return ptr + offset;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
#ifdef __cplusplus
|
|
318
|
+
}
|
|
319
|
+
#endif
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2023 Lain Bailey <lain@obsproject.com>
|
|
3
|
+
*
|
|
4
|
+
* Permission to use, copy, modify, and distribute this software for any
|
|
5
|
+
* purpose with or without fee is hereby granted, provided that the above
|
|
6
|
+
* copyright notice and this permission notice appear in all copies.
|
|
7
|
+
*
|
|
8
|
+
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
9
|
+
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
10
|
+
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
11
|
+
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
12
|
+
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
13
|
+
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
14
|
+
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
#pragma once
|
|
18
|
+
|
|
19
|
+
#include "c99defs.h"
|
|
20
|
+
|
|
21
|
+
/*
|
|
22
|
+
* Generic ini-style config file functions
|
|
23
|
+
*
|
|
24
|
+
* NOTE: It is highly recommended to use the default value functions (bottom of
|
|
25
|
+
* the file) before reading any variables from config files.
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
#ifdef __cplusplus
|
|
29
|
+
extern "C" {
|
|
30
|
+
#endif
|
|
31
|
+
|
|
32
|
+
struct config_data;
|
|
33
|
+
typedef struct config_data config_t;
|
|
34
|
+
|
|
35
|
+
#define CONFIG_SUCCESS 0
|
|
36
|
+
#define CONFIG_FILENOTFOUND -1
|
|
37
|
+
#define CONFIG_ERROR -2
|
|
38
|
+
|
|
39
|
+
enum config_open_type {
|
|
40
|
+
CONFIG_OPEN_EXISTING,
|
|
41
|
+
CONFIG_OPEN_ALWAYS,
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
EXPORT config_t *config_create(const char *file);
|
|
45
|
+
EXPORT int config_open(config_t **config, const char *file, enum config_open_type open_type);
|
|
46
|
+
EXPORT int config_open_string(config_t **config, const char *str);
|
|
47
|
+
EXPORT int config_save(config_t *config);
|
|
48
|
+
EXPORT int config_save_safe(config_t *config, const char *temp_ext, const char *backup_ext);
|
|
49
|
+
EXPORT void config_close(config_t *config);
|
|
50
|
+
|
|
51
|
+
EXPORT size_t config_num_sections(config_t *config);
|
|
52
|
+
EXPORT const char *config_get_section(config_t *config, size_t idx);
|
|
53
|
+
|
|
54
|
+
EXPORT void config_set_string(config_t *config, const char *section, const char *name, const char *value);
|
|
55
|
+
EXPORT void config_set_int(config_t *config, const char *section, const char *name, int64_t value);
|
|
56
|
+
EXPORT void config_set_uint(config_t *config, const char *section, const char *name, uint64_t value);
|
|
57
|
+
EXPORT void config_set_bool(config_t *config, const char *section, const char *name, bool value);
|
|
58
|
+
EXPORT void config_set_double(config_t *config, const char *section, const char *name, double value);
|
|
59
|
+
|
|
60
|
+
EXPORT const char *config_get_string(config_t *config, const char *section, const char *name);
|
|
61
|
+
EXPORT int64_t config_get_int(config_t *config, const char *section, const char *name);
|
|
62
|
+
EXPORT uint64_t config_get_uint(config_t *config, const char *section, const char *name);
|
|
63
|
+
EXPORT bool config_get_bool(config_t *config, const char *section, const char *name);
|
|
64
|
+
EXPORT double config_get_double(config_t *config, const char *section, const char *name);
|
|
65
|
+
|
|
66
|
+
EXPORT bool config_remove_value(config_t *config, const char *section, const char *name);
|
|
67
|
+
|
|
68
|
+
/*
|
|
69
|
+
* DEFAULT VALUES
|
|
70
|
+
*
|
|
71
|
+
* The following functions are used to set what values will return if they do
|
|
72
|
+
* not exist. Call these functions *once* for each known value before reading
|
|
73
|
+
* any of them anywhere else.
|
|
74
|
+
*
|
|
75
|
+
* These do *not* actually set any values, they only set what values will be
|
|
76
|
+
* returned for config_get_* if the specified variable does not exist.
|
|
77
|
+
*
|
|
78
|
+
* You can initialize the defaults programmatically using config_set_default_*
|
|
79
|
+
* functions (recommended for most cases), or you can initialize it via a file
|
|
80
|
+
* with config_open_defaults.
|
|
81
|
+
*/
|
|
82
|
+
EXPORT int config_open_defaults(config_t *config, const char *file);
|
|
83
|
+
|
|
84
|
+
EXPORT void config_set_default_string(config_t *config, const char *section, const char *name, const char *value);
|
|
85
|
+
EXPORT void config_set_default_int(config_t *config, const char *section, const char *name, int64_t value);
|
|
86
|
+
EXPORT void config_set_default_uint(config_t *config, const char *section, const char *name, uint64_t value);
|
|
87
|
+
EXPORT void config_set_default_bool(config_t *config, const char *section, const char *name, bool value);
|
|
88
|
+
EXPORT void config_set_default_double(config_t *config, const char *section, const char *name, double value);
|
|
89
|
+
|
|
90
|
+
/* These functions allow you to get the current default values rather than get
|
|
91
|
+
* the actual values. Probably almost never really needed */
|
|
92
|
+
EXPORT const char *config_get_default_string(config_t *config, const char *section, const char *name);
|
|
93
|
+
EXPORT int64_t config_get_default_int(config_t *config, const char *section, const char *name);
|
|
94
|
+
EXPORT uint64_t config_get_default_uint(config_t *config, const char *section, const char *name);
|
|
95
|
+
EXPORT bool config_get_default_bool(config_t *config, const char *section, const char *name);
|
|
96
|
+
EXPORT double config_get_default_double(config_t *config, const char *section, const char *name);
|
|
97
|
+
|
|
98
|
+
EXPORT bool config_has_user_value(config_t *config, const char *section, const char *name);
|
|
99
|
+
EXPORT bool config_has_default_value(config_t *config, const char *section, const char *name);
|
|
100
|
+
|
|
101
|
+
#ifdef __cplusplus
|
|
102
|
+
}
|
|
103
|
+
#endif
|