Commit Graph

24 Commits (b7ab8cf838a9913ba55251b620217ab38ccea70f)

Author SHA1 Message Date
jp9000 d45017370b libobs: Add functions to get locale text from modules
Useful for sharing translated text from modules with the frontend.  This
is technically already done via properties, but it would be nice to just
be able to explicitly look up locale text directly rather than have to
go through properties.
2020-08-10 12:24:01 -07:00
jp9000 bda28b242c libobs: Fix formatting 2019-07-12 11:48:41 -07:00
wang-bin 5b6ee6e66b libobs: Clear module variable in case module reloaded
Closes obsproject/obs-studio#1957
2019-07-09 08:37:43 -07:00
jp9000 f53df7da64 clang-format: Apply formatting
Code submissions have continually suffered from formatting
inconsistencies that constantly have to be addressed.  Using
clang-format simplifies this by making code formatting more consistent,
and allows automation of the code formatting so that maintainers can
focus more on the code itself instead of code formatting.
2019-06-23 23:49:10 -07:00
SammyJames 4fd66d4d1e libobs: Add post-load module callback
This allows the ability for certain types of modules (particularly
scripting-related modules) to initialize extra data when all other
modules have loaded.  Because front-ends may wish to have custom
handling for loading modules, the front-end must manually call
obs_post_load_modules after it has completed loading all plug-in
modules.

Closes jp9000/obs-studio#965
2017-07-21 08:27:31 -07:00
Ryan Foster be98cee2a0 Fix various typos across multiple modules 2017-04-25 22:39:42 -04:00
jp9000 988bbc6080 libobs: Add obs_module_get_string helper function
Allows getting a translated string for the current module, returning
false if no string available.
2016-09-06 22:01:49 -07:00
Kurt Kartaltepe 7ef690d4e1 libobs: Fix obs-module.h typo
Fixes a small typo in the obs-module.h comments.

Closes jp9000/obs-studio#557
2016-06-27 18:14:42 -07:00
jp9000 0d30d1229f libobs: Add API func to get module config path
Allows the ability to get a module-specific configuration file/path
2015-08-19 12:16:21 -07:00
fryshorts 2eadd445d2 Some documentation improvements in obs-module.h 2014-10-19 15:00:07 +02:00
jp9000 c9df41c1e2 (API Change) Remove pointers from all typedefs
Typedef pointers are unsafe.  If you do:
typedef struct bla *bla_t;
then you cannot use it as a constant, such as: const bla_t, because
that constant will be to the pointer itself rather than to the
underlying data.  I admit this was a fundamental mistake that must
be corrected.

All typedefs that were pointer types will now have their pointers
removed from the type itself, and the pointers will be used when they
are actually used as variables/parameters/returns instead.

This does not break ABI though, which is pretty nice.
2014-09-25 21:48:11 -07:00
jp9000 e610fd77ce Use C externs for obs-module.h
This allows inter-sharing of functions such as obs_module_text among
both C and C++ files
2014-08-29 11:20:28 -07:00
jp9000 892fdea83e Remove macro to free locale
This functionality can now be handled automatically because locale can
now be freed seaparately from obs_module_unload with
obs_module_free_locale, which is called automatically when the module is
being freed.
2014-07-27 17:29:10 -07:00
jp9000 f0ac19abba Remove version parameter from obs_module_load
Replaced by obs_get_version() API
2014-07-27 17:29:10 -07:00
jp9000 59ea3becf2 (API Change) Refactor module handling
Changed API:
- char *obs_find_plugin_file(const char *sub_path);

  Changed to: char *obs_module_file(const char *file);

  Cahnge it so you no longer need to specify a sub-path such as:
  obs_find_plugin_file("module_name/file.ext")

  Instead, now automatically handle the module data path so all you need
  to do is:
  obs_module_file("file.ext")

- int obs_load_module(const char *name);

  Changed to: int obs_open_module(obs_module_t *module,
                                  const char *path,
                                  const char *data_path);
              bool obs_init_module(obs_module_t module);

  Change the module loading API so that if the front-end chooses, it can
  load modules directly from a specified path, and associate a data
  directory with it on the spot.

  The module will not be initialized immediately; obs_init_module must
  be called on the module pointer in order to fully initialize the
  module.  This is done so a module can be disabled by the front-end if
  the it so chooses.

New API:
- void obs_add_module_path(const char *bin, const char *data);

  These functions allow you to specify new module search paths to add,
  and allow you to search through them, or optionally just load all
  modules from them.  If the string %module% is included, it will
  replace it with the module's name when that string is used as a
  lookup.  Data paths are now directly added to the module's internal
  storage structure, and when obs_find_module_file is used, it will look
  up the pointer to the obs_module structure and get its data directory
  that way.

  Example:
  obs_add_module_path("/opt/obs/my-modules/%module%/bin",
                      "/opt/obs/my-modules/%module%/data");

  This would cause it to additionally look for the binary of a
  hypthetical module named "foo" at /opt/obs/my-modules/foo/bin/foo.so
  (or libfoo.so), and then look for the data in
  /opt/obs/my-modules/foo/data.

  This gives the front-end more flexibility for handling third-party
  plugin modules, or handling all plugin modules in a custom way.

- void obs_find_modules(obs_find_module_callback_t callback, void
                        *param);

  This searches the existing paths for modules and calls the callback
  function when any are found.  Useful for plugin management and custom
  handling of the paths by the front-end if desired.

- void obs_load_all_modules(void);

  Search through the paths and both loads and initializes all modules
  automatically without custom handling.

- void obs_enum_modules(obs_enum_module_callback_t callback,
                        void *param);

  Enumerates currently opened modules.
2014-07-27 17:29:10 -07:00
jp9000 aed8f54f1a libobs: Add macro for default module locale
These macros are used as easy helper functions to load/unload module
locale that's based upon the text_lookup system.  You simple place the
OBS_MODULE_USE_DEFAULT_LOCALE macro once in the module, call
OBS_MODULE_FREE_DEFAULT LOCALE in obs_module_unload, and then
call obs_module_text anywhere in your module where you need to look up
text.

By default, it will look for a locale directory in your module's data
directory, and look for language files within it (INI locale format)
2014-07-11 17:26:24 -07:00
jp9000 1abf91577e Add module callbacks for loading locale data
The module callback obs_module_set_locale will be called after loading
the module, and any time the locale is manually changed via core API.

When this function is called, the module is expected to load new text
lookup values for all the text it uses based upon the current locale.
2014-06-25 12:37:06 -07:00
jp9000 22aec1c391 Well, that was embarassing. (Remove size macro)
...I think I need sleep.  That last commit before this one shows it
quite clearly.
2014-04-05 01:49:21 -07:00
jp9000 ac43d9bb89 And fix another bug that I just made
Accidentally removed a function from the main module declaration macro.
2014-04-05 01:47:08 -07:00
jp9000 bd331c8ffe Remove the weird size stuff from OBS_DECLARE_MODULE
Instead of doing this, just use macros to handle this situation.

Also, fix a minor bug in AAC encoder
2014-04-05 01:45:53 -07:00
jp9000 8e81d8be56 Revamp API and start using doxygen
The API used to be designed in such a way to where it would expect
exports for each individual source/output/encoder/etc.  You would export
functions for each and it would automatically load those functions based
on a specific naming scheme from the module.

The idea behind this was that I wanted to limit the usage of structures
in the API so only functions could be used.  It was an interesting idea
in theory, but this idea turned out to be flawed in a number of ways:

 1.) Requiring exports to create sources/outputs/encoders/etc meant that
     you could not create them by any other means, which meant that
     things like faruton's .net plugin would become difficult.

 2.) Export function declarations could not be checked, therefore if you
     created a function with the wrong parameters and parameter types,
     the compiler wouldn't know how to check for that.

 3.) Required overly complex load functions in libobs just to handle it.
     It makes much more sense to just have a load function that you call
     manually.  Complexity is the bane of all good programs.

 4.) It required that you have functions of specific names, which looked
     and felt somewhat unsightly.

So, to fix these issues, I replaced it with a more commonly used API
scheme, seen commonly in places like kernels and typical C libraries
with abstraction.  You simply create a structure that contains the
callback definitions, and you pass it to a function to register that
definition (such as obs_register_source), which you call in the
obs_module_load of the module.

It will also automatically check the structure size and ensure that it
only loads the required values if the structure happened to add new
values in an API change.

The "main" source file for each module must include obs-module.h, and
must use OBS_DECLARE_MODULE() within that source file.

Also, started writing some doxygen documentation in to the main library
headers.  Will add more detailed documentation as I go.
2014-02-12 08:04:50 -07:00
jp9000 8298fa4dc7 With the permission of my fellow contributors, I'm switching obs-studio back to GPL v2+ to prevent issues between this project and the original OBS project, and for personal reasons to avoid legal ambiguity (not political reasons, I admittedly would prefer GPL v3+) 2013-12-02 22:24:38 -07:00
Peter SZTANOJEV 0301b24ace modernize header guards to #pragma once 2013-10-14 13:21:15 +02:00
jp9000 f255ae1922 first commit 2013-09-30 19:37:13 -07:00