File: reference-modules.rst

package info (click to toggle)
obs-studio 29.0.2%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 35,920 kB
  • sloc: ansic: 182,921; cpp: 98,959; sh: 1,591; python: 945; makefile: 858; javascript: 19
file content (371 lines) | stat: -rw-r--r-- 10,522 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
Module API Reference
====================

Modules add custom functionality to libobs: typically
:ref:`plugins_sources`, :ref:`plugins_outputs`, :ref:`plugins_encoders`,
and :ref:`plugins_services`.

.. type:: obs_module_t

   A module object (not reference counted).

.. code:: cpp

   #include <obs-module.h>


Module Macros
-------------

These macros are used within custom plugin modules.

.. macro:: OBS_DECLARE_MODULE()

   Declares a libobs module.  Exports important core module functions
   related to the module itself, OBS version, etc.

---------------------

.. macro:: OBS_MODULE_USE_DEFAULT_LOCALE(module_name, default_locale)

   Helper macro that uses the standard ini file format for localization.
   Automatically initializes and destroys localization data, and
   automatically provides module externs such as
   :c:func:`obs_module_text()` to be able to get a localized string with
   little effort.

---------------------

Module Exports
--------------

These are functions that plugin modules can optionally export in order
to communicate with libobs and front-ends.

.. function:: bool obs_module_load(void)

   Required: Called when the module is loaded.  Implement this function
   to load all the sources/encoders/outputs/services for your module, or
   anything else that may need loading.

   :return:          Return true to continue loading the module, otherwise
                     false to indicate failure and unload the module

---------------------

.. function:: void obs_module_unload(void)

   Optional: Called when the module is unloaded.

---------------------

.. function:: void obs_module_post_load(void)

   Optional: Called when all modules have finished loading.

---------------------

.. function:: void obs_module_set_locale(const char *locale)

   Called to set the locale language and load the locale data for the
   module.

---------------------

.. function:: void obs_module_free_locale(void)

   Called on module destruction to free locale data.

---------------------

.. function:: const char *obs_module_name(void)

   (Optional)

   :return: The full name of the module

---------------------

.. function:: const char *obs_module_description(void)

   (Optional)

   :return: A description of the module

---------------------


Module Externs
--------------

These functions are externs that are usable throughout the module.

.. function:: const char *obs_module_text(const char *lookup_string)

   :return: A localized string

---------------------

.. function:: bool obs_module_get_string(const char *lookup_string, const char **translated_string)

   Helper function for looking up locale.

   :return: *true* if text found, otherwise *false*

---------------------

.. function:: obs_module_t *obs_current_module(void)

   :return: The current module

---------------------

.. function:: char *obs_module_file(const char *file)

   Returns the location to a module data file associated with the
   current module.  Free with :c:func:`bfree()` when complete.

   Equivalent to:

.. code:: cpp

      obs_find_module_file(obs_current_module(), file);

---------------------

.. function:: char *obs_module_config_path(const char *file)

   Returns the location to a module config file associated with the
   current module.  Free with :c:func:`bfree()` when complete.  Will
   return NULL if configuration directory is not set.

   Equivalent to:

.. code:: cpp

      obs_module_get_config_path(obs_current_module(), file);

---------------------


Frontend Module Functions
--------------------------

These are functions used by frontends to load and get information about
plugin modules.

.. function:: int obs_open_module(obs_module_t **module, const char *path, const char *data_path)

   Opens a plugin module directly from a specific path.

   If the module already exists then the function will return successful, and
   the module parameter will be given the pointer to the existing
   module.

   This does not initialize the module, it only loads the module image.  To
   initialize the module, call :c:func:`obs_init_module()`.

   :param  module:    The pointer to the created module
   :param  path:      Specifies the path to the module library file.  If the
                      extension is not specified, it will use the extension
                      appropriate to the operating system
   :param  data_path: Specifies the path to the directory where the module's
                      data files are stored (or *NULL* if none)
   :returns:          | MODULE_SUCCESS          - Successful
                      | MODULE_ERROR            - A generic error occurred
                      | MODULE_FILE_NOT_FOUND   - The module was not found
                      | MODULE_MISSING_EXPORTS  - Required exports are missing
                      | MODULE_INCOMPATIBLE_VER - Incompatible version
                      | MODULE_HARDCODED_SKIP   - Skipped by harcoded rules
                                                  (e.g. obsolete obs-browser macOS plugin)

---------------------

.. function:: bool obs_init_module(obs_module_t *module)

   Initializes the module, which calls its obs_module_load export.

   :return: *true* if the module was loaded successfully

---------------------

.. function:: void obs_log_loaded_modules(void)

   Logs loaded modules.

---------------------

.. function:: const char *obs_get_module_file_name(obs_module_t *module)

   :return: The module file name

---------------------

.. function:: const char *obs_get_module_name(obs_module_t *module)

   :return: The module full name (or *NULL* if none)

---------------------

.. function:: void obs_get_module_author(obs_module_t *module)

   :return: The module author(s)

---------------------

.. function:: const char *obs_get_module_description(obs_module_t *module)

   :return: The module description

---------------------

.. function:: const char *obs_get_module_binary_path(obs_module_t *module)

   :return: The module binary path

---------------------

.. function:: const char *obs_get_module_data_path(obs_module_t *module)

   :return: The module data path

---------------------

.. function:: void obs_add_module_path(const char *bin, const char *data)

   Adds a module search path to be used with obs_find_modules.  If the search
   path strings contain %module%, that text will be replaced with the module
   name when used.

   :param  bin:  Specifies the module's binary directory search path
   :param  data: Specifies the module's data directory search path

---------------------

.. function:: void obs_load_all_modules(void)

   Automatically loads all modules from module paths (convenience function).

---------------------

.. function:: void obs_load_all_modules2(struct obs_module_failure_info *mfi)

   Automatically loads all modules from module paths (convenience function).
   Additionally gives you information about modules that fail to load.

   :param mfi: Provides module failure information. The *failed_modules*
               member is a string list via a pointer to pointers of
               strings of modules that failed to load. Can be freed
               either with :c:func:`obs_module_failure_info_free()` or
               by simply calling :c:func:`bfree()` on the
               *failed_modules* member variable.

   Relevant data types used with this function:

.. code:: cpp

   struct obs_module_failure_info {
           char **failed_modules;
           size_t count;
   };

---------------------

.. function:: void obs_module_failure_info_free(struct obs_module_failure_info *mfi)

   Frees data allocated data used in the *mfi* parameter (calls
   :c:func:`bfree()` on the *failed_modules* member variable).

---------------------

.. function:: void obs_post_load_modules(void)

   Notifies modules that all modules have been loaded.

---------------------

.. function:: void obs_find_modules(obs_find_module_callback_t callback, void *param)

   Finds all modules within the search paths added by
   :c:func:`obs_add_module_path()`.

   Relevant data types used with this function:

.. code:: cpp

   struct obs_module_info {
           const char *bin_path;
           const char *data_path;
   };

   typedef void (*obs_find_module_callback_t)(void *param,
                   const struct obs_module_info *info);

---------------------

.. function:: void obs_find_modules2(obs_find_module_callback_t callback, void *param)

   Finds all modules within the search paths added by
   :c:func:`obs_add_module_path()`.

   Relevant data types used with this function:

.. code:: cpp

   struct obs_module_info2 {
           const char *bin_path;
           const char *data_path;
           const char *name;
   };

   typedef void (*obs_find_module_callback2_t)(void *param,
                   const struct obs_module_info2 *info);

---------------------

.. function:: void obs_enum_modules(obs_enum_module_callback_t callback, void *param)

   Enumerates all loaded modules.

   Relevant data types used with this function:

.. code:: cpp

   typedef void (*obs_enum_module_callback_t)(void *param, obs_module_t *module);

---------------------

.. function:: char *obs_find_module_file(obs_module_t *module, const char *file)

   Returns the location of a plugin module data file.

   Note:   Modules should use obs_module_file function defined in obs-module.h
           as a more elegant means of getting their files without having to
           specify the module parameter.

   :param  module: The module associated with the file to locate
   :param  file:   The file to locate
   :return:        Path string, or NULL if not found.  Use bfree to free string

---------------------

.. function:: char *obs_module_get_config_path(obs_module_t *module, const char *file)

   Returns the path of a plugin module config file (whether it exists or not).

   Note:   Modules should use obs_module_config_path function defined in
           obs-module.h as a more elegant means of getting their files without
           having to specify the module parameter.

   :param  module: The module associated with the path
   :param  file:   The file to get a path to
   :return:        Path string, or NULL if not found.  Use bfree to free string

---------------------

.. function:: void *obs_get_module_lib(obs_module_t *module)

   Returns library file of specified module.

   :param  module: The module where to find library file.
   :return:        Pointer to module library.