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.
Files changed (185) hide show
  1. package/COPYING +339 -0
  2. package/README.md +46 -0
  3. package/bin/64bit/obs.lib +0 -0
  4. package/binding.gyp +23 -0
  5. package/dist/bin/Qt6Core.dll +0 -0
  6. package/dist/bin/Qt6Gui.dll +0 -0
  7. package/dist/bin/Qt6Network.dll +0 -0
  8. package/dist/bin/Qt6Svg.dll +0 -0
  9. package/dist/bin/Qt6Widgets.dll +0 -0
  10. package/dist/bin/Qt6Xml.dll +0 -0
  11. package/dist/bin/avcodec-61.dll +0 -0
  12. package/dist/bin/avdevice-61.dll +0 -0
  13. package/dist/bin/avfilter-10.dll +0 -0
  14. package/dist/bin/avformat-61.dll +0 -0
  15. package/dist/bin/avutil-59.dll +0 -0
  16. package/dist/bin/datachannel.dll +0 -0
  17. package/dist/bin/libcurl.dll +0 -0
  18. package/dist/bin/libobs-d3d11.dll +0 -0
  19. package/dist/bin/libobs-opengl.dll +0 -0
  20. package/dist/bin/libobs-winrt.dll +0 -0
  21. package/dist/bin/librist.dll +0 -0
  22. package/dist/bin/libx264-164.dll +0 -0
  23. package/dist/bin/lua51.dll +0 -0
  24. package/dist/bin/obs-amf-test.exe +0 -0
  25. package/dist/bin/obs-ffmpeg-mux.exe +0 -0
  26. package/dist/bin/obs-frontend-api.dll +0 -0
  27. package/dist/bin/obs-scripting.dll +0 -0
  28. package/dist/bin/obs.dll +0 -0
  29. package/dist/bin/srt.dll +0 -0
  30. package/dist/bin/swresample-5.dll +0 -0
  31. package/dist/bin/swscale-8.dll +0 -0
  32. package/dist/bin/w32-pthreads.dll +0 -0
  33. package/dist/bin/zlib.dll +0 -0
  34. package/dist/effects/area.effect +250 -0
  35. package/dist/effects/bicubic_scale.effect +236 -0
  36. package/dist/effects/bilinear_lowres_scale.effect +123 -0
  37. package/dist/effects/color.effect +172 -0
  38. package/dist/effects/default.effect +254 -0
  39. package/dist/effects/default_rect.effect +84 -0
  40. package/dist/effects/deinterlace_base.effect +325 -0
  41. package/dist/effects/deinterlace_blend.effect +21 -0
  42. package/dist/effects/deinterlace_blend_2x.effect +21 -0
  43. package/dist/effects/deinterlace_discard.effect +21 -0
  44. package/dist/effects/deinterlace_discard_2x.effect +21 -0
  45. package/dist/effects/deinterlace_linear.effect +21 -0
  46. package/dist/effects/deinterlace_linear_2x.effect +21 -0
  47. package/dist/effects/deinterlace_yadif.effect +21 -0
  48. package/dist/effects/deinterlace_yadif_2x.effect +21 -0
  49. package/dist/effects/format_conversion.effect +1823 -0
  50. package/dist/effects/lanczos_scale.effect +292 -0
  51. package/dist/effects/opaque.effect +159 -0
  52. package/dist/effects/premultiplied_alpha.effect +38 -0
  53. package/dist/effects/repeat.effect +36 -0
  54. package/dist/effects/solid.effect +80 -0
  55. package/dist/noobs.node +0 -0
  56. package/dist/plugins/obs-ffmpeg.dll +0 -0
  57. package/dist/plugins/obs-x264.dll +0 -0
  58. package/dist/plugins/win-capture.dll +0 -0
  59. package/include/audio-monitoring/osx/mac-helpers.h +13 -0
  60. package/include/audio-monitoring/pulse/pulseaudio-wrapper.h +212 -0
  61. package/include/audio-monitoring/win32/wasapi-output.h +22 -0
  62. package/include/callback/calldata.h +195 -0
  63. package/include/callback/decl.h +61 -0
  64. package/include/callback/proc.h +52 -0
  65. package/include/callback/signal.h +73 -0
  66. package/include/graphics/axisang.h +65 -0
  67. package/include/graphics/bounds.h +108 -0
  68. package/include/graphics/device-exports.h +177 -0
  69. package/include/graphics/effect-parser.h +290 -0
  70. package/include/graphics/effect.h +190 -0
  71. package/include/graphics/graphics-internal.h +335 -0
  72. package/include/graphics/graphics.h +1024 -0
  73. package/include/graphics/half.h +100 -0
  74. package/include/graphics/image-file.h +124 -0
  75. package/include/graphics/input.h +34 -0
  76. package/include/graphics/libnsgif/libnsgif.h +142 -0
  77. package/include/graphics/math-defs.h +45 -0
  78. package/include/graphics/math-extra.h +61 -0
  79. package/include/graphics/matrix3.h +98 -0
  80. package/include/graphics/matrix4.h +102 -0
  81. package/include/graphics/plane.h +85 -0
  82. package/include/graphics/quat.h +170 -0
  83. package/include/graphics/shader-parser.h +273 -0
  84. package/include/graphics/srgb.h +177 -0
  85. package/include/graphics/vec2.h +148 -0
  86. package/include/graphics/vec3.h +224 -0
  87. package/include/graphics/vec4.h +241 -0
  88. package/include/media-io/audio-io.h +228 -0
  89. package/include/media-io/audio-math.h +43 -0
  90. package/include/media-io/audio-resampler.h +44 -0
  91. package/include/media-io/format-conversion.h +50 -0
  92. package/include/media-io/frame-rate.h +29 -0
  93. package/include/media-io/media-io-defs.h +20 -0
  94. package/include/media-io/media-remux.h +37 -0
  95. package/include/media-io/video-frame.h +64 -0
  96. package/include/media-io/video-io.h +338 -0
  97. package/include/media-io/video-scaler.h +43 -0
  98. package/include/obs-audio-controls.h +250 -0
  99. package/include/obs-av1.h +47 -0
  100. package/include/obs-avc.h +55 -0
  101. package/include/obs-config.h +52 -0
  102. package/include/obs-data.h +311 -0
  103. package/include/obs-defs.h +52 -0
  104. package/include/obs-encoder.h +361 -0
  105. package/include/obs-ffmpeg-compat.h +13 -0
  106. package/include/obs-hevc.h +81 -0
  107. package/include/obs-hotkey.h +271 -0
  108. package/include/obs-hotkeys.h +653 -0
  109. package/include/obs-interaction.h +56 -0
  110. package/include/obs-internal.h +1459 -0
  111. package/include/obs-missing-files.h +53 -0
  112. package/include/obs-module.h +181 -0
  113. package/include/obs-nal.h +37 -0
  114. package/include/obs-nix-platform.h +53 -0
  115. package/include/obs-nix-wayland.h +24 -0
  116. package/include/obs-nix-x11.h +22 -0
  117. package/include/obs-nix.h +42 -0
  118. package/include/obs-output.h +96 -0
  119. package/include/obs-properties.h +364 -0
  120. package/include/obs-scene.h +127 -0
  121. package/include/obs-service.h +115 -0
  122. package/include/obs-source.h +568 -0
  123. package/include/obs.h +2608 -0
  124. package/include/obsconfig.h +13 -0
  125. package/include/obsversion.h +5 -0
  126. package/include/util/apple/cfstring-utils.h +16 -0
  127. package/include/util/array-serializer.h +37 -0
  128. package/include/util/base.h +97 -0
  129. package/include/util/bitstream.h +28 -0
  130. package/include/util/bmem.h +94 -0
  131. package/include/util/buffered-file-serializer.h +32 -0
  132. package/include/util/c99defs.h +75 -0
  133. package/include/util/cf-lexer.h +199 -0
  134. package/include/util/cf-parser.h +281 -0
  135. package/include/util/circlebuf.h +319 -0
  136. package/include/util/config-file.h +103 -0
  137. package/include/util/crc32.h +29 -0
  138. package/include/util/curl/curl-helper.h +35 -0
  139. package/include/util/darray.h +606 -0
  140. package/include/util/deque.h +319 -0
  141. package/include/util/dstr.h +320 -0
  142. package/include/util/file-serializer.h +34 -0
  143. package/include/util/lexer.h +273 -0
  144. package/include/util/pipe.h +52 -0
  145. package/include/util/platform.h +223 -0
  146. package/include/util/profiler.h +97 -0
  147. package/include/util/serializer.h +158 -0
  148. package/include/util/simde/check.h +285 -0
  149. package/include/util/simde/debug-trap.h +117 -0
  150. package/include/util/simde/hedley.h +2123 -0
  151. package/include/util/simde/simde-align.h +481 -0
  152. package/include/util/simde/simde-arch.h +537 -0
  153. package/include/util/simde/simde-common.h +918 -0
  154. package/include/util/simde/simde-constify.h +925 -0
  155. package/include/util/simde/simde-detect-clang.h +114 -0
  156. package/include/util/simde/simde-diagnostic.h +447 -0
  157. package/include/util/simde/simde-features.h +550 -0
  158. package/include/util/simde/simde-math.h +1858 -0
  159. package/include/util/simde/x86/mmx.h +2456 -0
  160. package/include/util/simde/x86/sse.h +4479 -0
  161. package/include/util/simde/x86/sse2.h +7549 -0
  162. package/include/util/source-profiler.h +66 -0
  163. package/include/util/sse-intrin.h +32 -0
  164. package/include/util/task.h +22 -0
  165. package/include/util/text-lookup.h +45 -0
  166. package/include/util/threading-posix.h +77 -0
  167. package/include/util/threading-windows.h +142 -0
  168. package/include/util/threading.h +103 -0
  169. package/include/util/utf8.h +35 -0
  170. package/include/util/uthash.h +34 -0
  171. package/include/util/util_uint128.h +108 -0
  172. package/include/util/util_uint64.h +34 -0
  173. package/include/util/windows/device-enum.h +14 -0
  174. package/include/util/windows/obfuscate.h +16 -0
  175. package/include/util/windows/win-registry.h +37 -0
  176. package/include/util/windows/win-version.h +57 -0
  177. package/include/util/windows/window-helpers.h +47 -0
  178. package/index.d.ts +38 -0
  179. package/index.js +8 -0
  180. package/package.json +31 -0
  181. package/src/main.cpp +321 -0
  182. package/src/obs_interface.cpp +605 -0
  183. package/src/obs_interface.h +74 -0
  184. package/src/utils.cpp +80 -0
  185. package/src/utils.h +3 -0
@@ -0,0 +1,273 @@
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 "dstr.h"
21
+ #include "darray.h"
22
+
23
+ #ifdef __cplusplus
24
+ extern "C" {
25
+ #endif
26
+
27
+ /* ------------------------------------------------------------------------- */
28
+ /* string reference (string segment within an already existing array) */
29
+
30
+ struct strref {
31
+ const char *array;
32
+ size_t len;
33
+ };
34
+
35
+ static inline void strref_clear(struct strref *dst)
36
+ {
37
+ dst->array = NULL;
38
+ dst->len = 0;
39
+ }
40
+
41
+ static inline void strref_set(struct strref *dst, const char *array, size_t len)
42
+ {
43
+ dst->array = array;
44
+ dst->len = len;
45
+ }
46
+
47
+ static inline void strref_copy(struct strref *dst, const struct strref *src)
48
+ {
49
+ dst->array = src->array;
50
+ dst->len = src->len;
51
+ }
52
+
53
+ static inline void strref_add(struct strref *dst, const struct strref *t)
54
+ {
55
+ if (!dst->array)
56
+ strref_copy(dst, t);
57
+ else
58
+ dst->len += t->len;
59
+ }
60
+
61
+ static inline bool strref_is_empty(const struct strref *str)
62
+ {
63
+ return !str || !str->array || !str->len || !*str->array;
64
+ }
65
+
66
+ EXPORT int strref_cmp(const struct strref *str1, const char *str2);
67
+ EXPORT int strref_cmpi(const struct strref *str1, const char *str2);
68
+ EXPORT int strref_cmp_strref(const struct strref *str1, const struct strref *str2);
69
+ EXPORT int strref_cmpi_strref(const struct strref *str1, const struct strref *str2);
70
+
71
+ /* ------------------------------------------------------------------------- */
72
+
73
+ EXPORT bool valid_int_str(const char *str, size_t n);
74
+ EXPORT bool valid_float_str(const char *str, size_t n);
75
+
76
+ static inline bool valid_int_strref(const struct strref *str)
77
+ {
78
+ return valid_int_str(str->array, str->len);
79
+ }
80
+
81
+ static inline bool valid_float_strref(const struct strref *str)
82
+ {
83
+ return valid_float_str(str->array, str->len);
84
+ }
85
+
86
+ static inline bool is_whitespace(char ch)
87
+ {
88
+ return ch == ' ' || ch == '\r' || ch == '\t' || ch == '\n';
89
+ }
90
+
91
+ static inline bool is_newline(char ch)
92
+ {
93
+ return ch == '\r' || ch == '\n';
94
+ }
95
+
96
+ static inline bool is_space_or_tab(const char ch)
97
+ {
98
+ return ch == ' ' || ch == '\t';
99
+ }
100
+
101
+ static inline bool is_newline_pair(char ch1, char ch2)
102
+ {
103
+ return (ch1 == '\r' && ch2 == '\n') || (ch1 == '\n' && ch2 == '\r');
104
+ }
105
+
106
+ static inline int newline_size(const char *array)
107
+ {
108
+ if (strncmp(array, "\r\n", 2) == 0 || strncmp(array, "\n\r", 2) == 0)
109
+ return 2;
110
+ else if (*array == '\r' || *array == '\n')
111
+ return 1;
112
+
113
+ return 0;
114
+ }
115
+
116
+ /* ------------------------------------------------------------------------- */
117
+
118
+ /*
119
+ * A "base" token is one of four things:
120
+ * 1.) A sequence of alpha characters
121
+ * 2.) A sequence of numeric characters
122
+ * 3.) A single whitespace character if whitespace is not ignored
123
+ * 4.) A single character that does not fall into the above 3 categories
124
+ */
125
+
126
+ enum base_token_type {
127
+ BASETOKEN_NONE,
128
+ BASETOKEN_ALPHA,
129
+ BASETOKEN_DIGIT,
130
+ BASETOKEN_WHITESPACE,
131
+ BASETOKEN_OTHER,
132
+ };
133
+
134
+ struct base_token {
135
+ struct strref text;
136
+ enum base_token_type type;
137
+ bool passed_whitespace;
138
+ };
139
+
140
+ static inline void base_token_clear(struct base_token *t)
141
+ {
142
+ memset(t, 0, sizeof(struct base_token));
143
+ }
144
+
145
+ static inline void base_token_copy(struct base_token *dst, struct base_token *src)
146
+ {
147
+ memcpy(dst, src, sizeof(struct base_token));
148
+ }
149
+
150
+ /* ------------------------------------------------------------------------- */
151
+
152
+ #define LEX_ERROR 0
153
+ #define LEX_WARNING 1
154
+
155
+ struct error_item {
156
+ char *error;
157
+ const char *file;
158
+ uint32_t row, column;
159
+ int level;
160
+ };
161
+
162
+ static inline void error_item_init(struct error_item *ei)
163
+ {
164
+ memset(ei, 0, sizeof(struct error_item));
165
+ }
166
+
167
+ static inline void error_item_free(struct error_item *ei)
168
+ {
169
+ bfree(ei->error);
170
+ error_item_init(ei);
171
+ }
172
+
173
+ static inline void error_item_array_free(struct error_item *array, size_t num)
174
+ {
175
+ size_t i;
176
+ for (i = 0; i < num; i++)
177
+ error_item_free(array + i);
178
+ }
179
+
180
+ /* ------------------------------------------------------------------------- */
181
+
182
+ struct error_data {
183
+ DARRAY(struct error_item) errors;
184
+ };
185
+
186
+ static inline void error_data_init(struct error_data *data)
187
+ {
188
+ da_init(data->errors);
189
+ }
190
+
191
+ static inline void error_data_free(struct error_data *data)
192
+ {
193
+ error_item_array_free(data->errors.array, data->errors.num);
194
+ da_free(data->errors);
195
+ }
196
+
197
+ static inline const struct error_item *error_data_item(struct error_data *ed, size_t idx)
198
+ {
199
+ return ed->errors.array + idx;
200
+ }
201
+
202
+ EXPORT char *error_data_buildstring(struct error_data *ed);
203
+
204
+ EXPORT void error_data_add(struct error_data *ed, const char *file, uint32_t row, uint32_t column, const char *msg,
205
+ int level);
206
+
207
+ static inline size_t error_data_type_count(struct error_data *ed, int type)
208
+ {
209
+ size_t count = 0, i;
210
+ for (i = 0; i < ed->errors.num; i++) {
211
+ if (ed->errors.array[i].level == type)
212
+ count++;
213
+ }
214
+
215
+ return count;
216
+ }
217
+
218
+ static inline bool error_data_has_errors(struct error_data *ed)
219
+ {
220
+ size_t i;
221
+ for (i = 0; i < ed->errors.num; i++)
222
+ if (ed->errors.array[i].level == LEX_ERROR)
223
+ return true;
224
+
225
+ return false;
226
+ }
227
+
228
+ /* ------------------------------------------------------------------------- */
229
+
230
+ struct lexer {
231
+ char *text;
232
+ const char *offset;
233
+ };
234
+
235
+ static inline void lexer_init(struct lexer *lex)
236
+ {
237
+ memset(lex, 0, sizeof(struct lexer));
238
+ }
239
+
240
+ static inline void lexer_free(struct lexer *lex)
241
+ {
242
+ bfree(lex->text);
243
+ lexer_init(lex);
244
+ }
245
+
246
+ static inline void lexer_start(struct lexer *lex, const char *text)
247
+ {
248
+ lexer_free(lex);
249
+ lex->text = bstrdup(text);
250
+ lex->offset = lex->text;
251
+ }
252
+
253
+ static inline void lexer_start_move(struct lexer *lex, char *text)
254
+ {
255
+ lexer_free(lex);
256
+ lex->text = text;
257
+ lex->offset = lex->text;
258
+ }
259
+
260
+ static inline void lexer_reset(struct lexer *lex)
261
+ {
262
+ lex->offset = lex->text;
263
+ }
264
+
265
+ enum ignore_whitespace { PARSE_WHITESPACE, IGNORE_WHITESPACE };
266
+
267
+ EXPORT bool lexer_getbasetoken(struct lexer *lex, struct base_token *t, enum ignore_whitespace iws);
268
+
269
+ EXPORT void lexer_getstroffset(const struct lexer *lex, const char *str, uint32_t *row, uint32_t *col);
270
+
271
+ #ifdef __cplusplus
272
+ }
273
+ #endif
@@ -0,0 +1,52 @@
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
+ #ifdef __cplusplus
22
+ extern "C" {
23
+ #endif
24
+
25
+ struct os_process_pipe;
26
+ typedef struct os_process_pipe os_process_pipe_t;
27
+
28
+ struct os_process_args;
29
+ typedef struct os_process_args os_process_args_t;
30
+
31
+ EXPORT os_process_pipe_t *os_process_pipe_create(const char *cmd_line, const char *type);
32
+ EXPORT os_process_pipe_t *os_process_pipe_create2(const os_process_args_t *args, const char *type);
33
+ EXPORT int os_process_pipe_destroy(os_process_pipe_t *pp);
34
+
35
+ EXPORT size_t os_process_pipe_read(os_process_pipe_t *pp, uint8_t *data, size_t len);
36
+ EXPORT size_t os_process_pipe_read_err(os_process_pipe_t *pp, uint8_t *data, size_t len);
37
+ EXPORT size_t os_process_pipe_write(os_process_pipe_t *pp, const uint8_t *data, size_t len);
38
+
39
+ EXPORT struct os_process_args *os_process_args_create(const char *executable);
40
+ EXPORT void os_process_args_add_arg(struct os_process_args *args, const char *arg);
41
+ #ifndef _MSC_VER
42
+ __attribute__((__format__(__printf__, 2, 3)))
43
+ #endif
44
+ EXPORT void
45
+ os_process_args_add_argf(struct os_process_args *args, const char *format, ...);
46
+ EXPORT char **os_process_args_get_argv(const struct os_process_args *args);
47
+ EXPORT size_t os_process_args_get_argc(struct os_process_args *args);
48
+ EXPORT void os_process_args_destroy(struct os_process_args *args);
49
+
50
+ #ifdef __cplusplus
51
+ }
52
+ #endif
@@ -0,0 +1,223 @@
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 <stdio.h>
20
+ #include <wchar.h>
21
+ #include <sys/types.h>
22
+ #include "c99defs.h"
23
+
24
+ /*
25
+ * Platform-independent functions for Accessing files, encoding, DLLs,
26
+ * sleep, timer, and timing.
27
+ */
28
+
29
+ #ifdef __cplusplus
30
+ extern "C" {
31
+ #endif
32
+
33
+ EXPORT FILE *os_wfopen(const wchar_t *path, const char *mode);
34
+ EXPORT FILE *os_fopen(const char *path, const char *mode);
35
+ EXPORT int64_t os_fgetsize(FILE *file);
36
+
37
+ #ifdef _WIN32
38
+ EXPORT int os_stat(const char *file, struct stat *st);
39
+ #else
40
+ #define os_stat stat
41
+ #endif
42
+
43
+ EXPORT int os_fseeki64(FILE *file, int64_t offset, int origin);
44
+ EXPORT int64_t os_ftelli64(FILE *file);
45
+
46
+ EXPORT size_t os_fread_mbs(FILE *file, char **pstr);
47
+ EXPORT size_t os_fread_utf8(FILE *file, char **pstr);
48
+
49
+ /* functions purely for convenience */
50
+ EXPORT char *os_quick_read_utf8_file(const char *path);
51
+ EXPORT bool os_quick_write_utf8_file(const char *path, const char *str, size_t len, bool marker);
52
+ EXPORT bool os_quick_write_utf8_file_safe(const char *path, const char *str, size_t len, bool marker,
53
+ const char *temp_ext, const char *backup_ext);
54
+ EXPORT char *os_quick_read_mbs_file(const char *path);
55
+ EXPORT bool os_quick_write_mbs_file(const char *path, const char *str, size_t len);
56
+
57
+ EXPORT int64_t os_get_file_size(const char *path);
58
+ EXPORT int64_t os_get_free_space(const char *path);
59
+
60
+ EXPORT size_t os_mbs_to_wcs(const char *str, size_t str_len, wchar_t *dst, size_t dst_size);
61
+ EXPORT size_t os_utf8_to_wcs(const char *str, size_t len, wchar_t *dst, size_t dst_size);
62
+ EXPORT size_t os_wcs_to_mbs(const wchar_t *str, size_t len, char *dst, size_t dst_size);
63
+ EXPORT size_t os_wcs_to_utf8(const wchar_t *str, size_t len, char *dst, size_t dst_size);
64
+
65
+ EXPORT size_t os_mbs_to_wcs_ptr(const char *str, size_t len, wchar_t **pstr);
66
+ EXPORT size_t os_utf8_to_wcs_ptr(const char *str, size_t len, wchar_t **pstr);
67
+ EXPORT size_t os_wcs_to_mbs_ptr(const wchar_t *str, size_t len, char **pstr);
68
+ EXPORT size_t os_wcs_to_utf8_ptr(const wchar_t *str, size_t len, char **pstr);
69
+
70
+ EXPORT size_t os_utf8_to_mbs_ptr(const char *str, size_t len, char **pstr);
71
+ EXPORT size_t os_mbs_to_utf8_ptr(const char *str, size_t len, char **pstr);
72
+
73
+ EXPORT double os_strtod(const char *str);
74
+ EXPORT int os_dtostr(double value, char *dst, size_t size);
75
+
76
+ EXPORT void *os_dlopen(const char *path);
77
+ EXPORT void *os_dlsym(void *module, const char *func);
78
+ EXPORT void os_dlclose(void *module);
79
+ EXPORT bool os_is_obs_plugin(const char *path);
80
+
81
+ struct os_cpu_usage_info;
82
+ typedef struct os_cpu_usage_info os_cpu_usage_info_t;
83
+
84
+ EXPORT os_cpu_usage_info_t *os_cpu_usage_info_start(void);
85
+ EXPORT double os_cpu_usage_info_query(os_cpu_usage_info_t *info);
86
+ EXPORT void os_cpu_usage_info_destroy(os_cpu_usage_info_t *info);
87
+
88
+ typedef const void os_performance_token_t;
89
+ EXPORT os_performance_token_t *os_request_high_performance(const char *reason);
90
+ EXPORT void os_end_high_performance(os_performance_token_t *);
91
+
92
+ /**
93
+ * Sleeps to a specific time (in nanoseconds). Doesn't have to be super
94
+ * accurate in terms of actual slept time because the target time is ensured.
95
+ * Returns false if already at or past target time.
96
+ */
97
+ EXPORT bool os_sleepto_ns(uint64_t time_target);
98
+ EXPORT bool os_sleepto_ns_fast(uint64_t time_target);
99
+ EXPORT void os_sleep_ms(uint32_t duration);
100
+
101
+ EXPORT uint64_t os_gettime_ns(void);
102
+
103
+ EXPORT int os_get_config_path(char *dst, size_t size, const char *name);
104
+ EXPORT char *os_get_config_path_ptr(const char *name);
105
+
106
+ EXPORT int os_get_program_data_path(char *dst, size_t size, const char *name);
107
+ EXPORT char *os_get_program_data_path_ptr(const char *name);
108
+
109
+ EXPORT char *os_get_executable_path_ptr(const char *name);
110
+
111
+ EXPORT bool os_file_exists(const char *path);
112
+
113
+ EXPORT size_t os_get_abs_path(const char *path, char *abspath, size_t size);
114
+ EXPORT char *os_get_abs_path_ptr(const char *path);
115
+
116
+ EXPORT const char *os_get_path_extension(const char *path);
117
+
118
+ EXPORT bool os_get_emulation_status(void);
119
+
120
+ struct os_dir;
121
+ typedef struct os_dir os_dir_t;
122
+
123
+ struct os_dirent {
124
+ char d_name[256];
125
+ bool directory;
126
+ };
127
+
128
+ EXPORT os_dir_t *os_opendir(const char *path);
129
+ EXPORT struct os_dirent *os_readdir(os_dir_t *dir);
130
+ EXPORT void os_closedir(os_dir_t *dir);
131
+
132
+ struct os_globent {
133
+ char *path;
134
+ bool directory;
135
+ };
136
+
137
+ struct os_glob_info {
138
+ size_t gl_pathc;
139
+ struct os_globent *gl_pathv;
140
+ };
141
+
142
+ typedef struct os_glob_info os_glob_t;
143
+
144
+ /* currently no flags available */
145
+
146
+ EXPORT int os_glob(const char *pattern, int flags, os_glob_t **pglob);
147
+ EXPORT void os_globfree(os_glob_t *pglob);
148
+
149
+ EXPORT int os_unlink(const char *path);
150
+ EXPORT int os_rmdir(const char *path);
151
+
152
+ EXPORT char *os_getcwd(char *path, size_t size);
153
+ EXPORT int os_chdir(const char *path);
154
+
155
+ EXPORT uint64_t os_get_free_disk_space(const char *dir);
156
+
157
+ #define MKDIR_EXISTS 1
158
+ #define MKDIR_SUCCESS 0
159
+ #define MKDIR_ERROR -1
160
+
161
+ EXPORT int os_mkdir(const char *path);
162
+ EXPORT int os_mkdirs(const char *path);
163
+ EXPORT int os_rename(const char *old_path, const char *new_path);
164
+ EXPORT int os_copyfile(const char *file_in, const char *file_out);
165
+ EXPORT int os_safe_replace(const char *target_path, const char *from_path, const char *backup_path);
166
+
167
+ EXPORT char *os_generate_formatted_filename(const char *extension, bool space, const char *format);
168
+
169
+ struct os_inhibit_info;
170
+ typedef struct os_inhibit_info os_inhibit_t;
171
+
172
+ EXPORT os_inhibit_t *os_inhibit_sleep_create(const char *reason);
173
+ EXPORT bool os_inhibit_sleep_set_active(os_inhibit_t *info, bool active);
174
+ EXPORT void os_inhibit_sleep_destroy(os_inhibit_t *info);
175
+
176
+ EXPORT void os_breakpoint(void);
177
+
178
+ EXPORT int os_get_physical_cores(void);
179
+ EXPORT int os_get_logical_cores(void);
180
+
181
+ EXPORT uint64_t os_get_sys_free_size(void);
182
+ EXPORT uint64_t os_get_sys_total_size(void);
183
+
184
+ struct os_proc_memory_usage {
185
+ uint64_t resident_size;
186
+ uint64_t virtual_size;
187
+ };
188
+ typedef struct os_proc_memory_usage os_proc_memory_usage_t;
189
+
190
+ EXPORT bool os_get_proc_memory_usage(os_proc_memory_usage_t *usage);
191
+ EXPORT uint64_t os_get_proc_resident_size(void);
192
+ EXPORT uint64_t os_get_proc_virtual_size(void);
193
+
194
+ #define UUID_STR_LENGTH 36
195
+
196
+ EXPORT char *os_generate_uuid(void);
197
+
198
+ EXPORT
199
+ struct timespec *os_nstime_to_timespec(uint64_t timestamp, struct timespec *storage);
200
+
201
+ /* clang-format off */
202
+ #ifdef __APPLE__
203
+ # define ARCH_BITS 64
204
+ #else
205
+ # ifdef _WIN32
206
+ # ifdef _WIN64
207
+ # define ARCH_BITS 64
208
+ # else
209
+ # define ARCH_BITS 32
210
+ # endif
211
+ # else
212
+ # ifdef __LP64__
213
+ # define ARCH_BITS 64
214
+ # else
215
+ # define ARCH_BITS 32
216
+ # endif
217
+ # endif
218
+ #endif
219
+ /* clang-format on */
220
+
221
+ #ifdef __cplusplus
222
+ }
223
+ #endif
@@ -0,0 +1,97 @@
1
+ #pragma once
2
+
3
+ #include "base.h"
4
+ #include "darray.h"
5
+
6
+ #ifdef __cplusplus
7
+ extern "C" {
8
+ #endif
9
+
10
+ typedef struct profiler_snapshot profiler_snapshot_t;
11
+ typedef struct profiler_snapshot_entry profiler_snapshot_entry_t;
12
+ typedef struct profiler_time_entry profiler_time_entry_t;
13
+
14
+ /* ------------------------------------------------------------------------- */
15
+ /* Profiling */
16
+
17
+ EXPORT void profile_register_root(const char *name, uint64_t expected_time_between_calls);
18
+
19
+ EXPORT void profile_start(const char *name);
20
+ EXPORT void profile_end(const char *name);
21
+
22
+ EXPORT void profile_reenable_thread(void);
23
+
24
+ /* ------------------------------------------------------------------------- */
25
+ /* Profiler control */
26
+
27
+ EXPORT void profiler_start(void);
28
+ EXPORT void profiler_stop(void);
29
+
30
+ EXPORT void profiler_print(profiler_snapshot_t *snap);
31
+ EXPORT void profiler_print_time_between_calls(profiler_snapshot_t *snap);
32
+
33
+ EXPORT void profiler_free(void);
34
+
35
+ /* ------------------------------------------------------------------------- */
36
+ /* Profiler name storage */
37
+
38
+ typedef struct profiler_name_store profiler_name_store_t;
39
+
40
+ EXPORT profiler_name_store_t *profiler_name_store_create(void);
41
+ EXPORT void profiler_name_store_free(profiler_name_store_t *store);
42
+
43
+ #ifndef _MSC_VER
44
+ #define PRINTFATTR(f, a) __attribute__((__format__(__printf__, f, a)))
45
+ #else
46
+ #define PRINTFATTR(f, a)
47
+ #endif
48
+
49
+ PRINTFATTR(2, 3)
50
+ EXPORT const char *profile_store_name(profiler_name_store_t *store, const char *format, ...);
51
+
52
+ #undef PRINTFATTR
53
+
54
+ /* ------------------------------------------------------------------------- */
55
+ /* Profiler data access */
56
+
57
+ struct profiler_time_entry {
58
+ uint64_t time_delta;
59
+ uint64_t count;
60
+ };
61
+
62
+ typedef DARRAY(profiler_time_entry_t) profiler_time_entries_t;
63
+
64
+ typedef bool (*profiler_entry_enum_func)(void *context, profiler_snapshot_entry_t *entry);
65
+
66
+ EXPORT profiler_snapshot_t *profile_snapshot_create(void);
67
+ EXPORT void profile_snapshot_free(profiler_snapshot_t *snap);
68
+
69
+ EXPORT bool profiler_snapshot_dump_csv(const profiler_snapshot_t *snap, const char *filename);
70
+ EXPORT bool profiler_snapshot_dump_csv_gz(const profiler_snapshot_t *snap, const char *filename);
71
+
72
+ EXPORT size_t profiler_snapshot_num_roots(profiler_snapshot_t *snap);
73
+ EXPORT void profiler_snapshot_enumerate_roots(profiler_snapshot_t *snap, profiler_entry_enum_func func, void *context);
74
+
75
+ typedef bool (*profiler_name_filter_func)(void *data, const char *name, bool *remove);
76
+ EXPORT void profiler_snapshot_filter_roots(profiler_snapshot_t *snap, profiler_name_filter_func func, void *data);
77
+
78
+ EXPORT size_t profiler_snapshot_num_children(profiler_snapshot_entry_t *entry);
79
+ EXPORT void profiler_snapshot_enumerate_children(profiler_snapshot_entry_t *entry, profiler_entry_enum_func func,
80
+ void *context);
81
+
82
+ EXPORT const char *profiler_snapshot_entry_name(profiler_snapshot_entry_t *entry);
83
+
84
+ EXPORT profiler_time_entries_t *profiler_snapshot_entry_times(profiler_snapshot_entry_t *entry);
85
+ EXPORT uint64_t profiler_snapshot_entry_min_time(profiler_snapshot_entry_t *entry);
86
+ EXPORT uint64_t profiler_snapshot_entry_max_time(profiler_snapshot_entry_t *entry);
87
+ EXPORT uint64_t profiler_snapshot_entry_overall_count(profiler_snapshot_entry_t *entry);
88
+
89
+ EXPORT profiler_time_entries_t *profiler_snapshot_entry_times_between_calls(profiler_snapshot_entry_t *entry);
90
+ EXPORT uint64_t profiler_snapshot_entry_expected_time_between_calls(profiler_snapshot_entry_t *entry);
91
+ EXPORT uint64_t profiler_snapshot_entry_min_time_between_calls(profiler_snapshot_entry_t *entry);
92
+ EXPORT uint64_t profiler_snapshot_entry_max_time_between_calls(profiler_snapshot_entry_t *entry);
93
+ EXPORT uint64_t profiler_snapshot_entry_overall_between_calls_count(profiler_snapshot_entry_t *entry);
94
+
95
+ #ifdef __cplusplus
96
+ }
97
+ #endif