Open Broadcaster Software
Free, open source software for live streaming and recording
obs-module.h File Reference

This file is used by modules for module declaration and module exports. More...

Go to the source code of this file.

Macros

#define MODULE_EXPORT   EXPORT
 
#define MODULE_EXTERN   extern
 
#define OBS_DECLARE_MODULE()
 
#define OBS_MODULE_USE_DEFAULT_LOCALE(module_name, default_locale)
 
#define obs_module_file(file)   obs_find_module_file(obs_current_module(), file)
 
#define obs_module_config_path(file)   obs_module_get_config_path(obs_current_module(), file)
 
#define OBS_MODULE_AUTHOR(name)
 

Functions

MODULE_EXPORT bool obs_module_load (void)
 
MODULE_EXPORT void obs_module_unload (void)
 
MODULE_EXPORT void obs_module_post_load (void)
 
MODULE_EXPORT void obs_module_set_locale (const char *locale)
 
MODULE_EXPORT void obs_module_free_locale (void)
 
MODULE_EXTERN const char * obs_module_text (const char *lookup_string)
 
MODULE_EXTERN bool obs_module_get_string (const char *lookup_string, const char **translated_string)
 
MODULE_EXTERN obs_module_tobs_current_module (void)
 
MODULE_EXPORT const char * obs_module_name (void)
 
MODULE_EXPORT const char * obs_module_description (void)
 

Detailed Description

This file is used by modules for module declaration and module exports.

Macro Definition Documentation

◆ MODULE_EXPORT

#define MODULE_EXPORT   EXPORT

◆ MODULE_EXTERN

#define MODULE_EXTERN   extern

◆ OBS_DECLARE_MODULE

#define OBS_DECLARE_MODULE ( )
Value:
static obs_module_t *obs_module_pointer; \
MODULE_EXPORT void obs_module_set_pointer(obs_module_t *module); \
void obs_module_set_pointer(obs_module_t *module) \
{ \
obs_module_pointer = module; \
} \
obs_module_t *obs_current_module(void) {return obs_module_pointer;} \
MODULE_EXPORT uint32_t obs_module_ver(void); \
uint32_t obs_module_ver(void) {return LIBOBS_API_VER;}
unsigned uint32_t
Definition: vc_stdint.h:31
MODULE_EXTERN obs_module_t * obs_current_module(void)
Definition: obs-internal.h:75
#define LIBOBS_API_VER
Definition: obs-config.h:51

Required: Declares a libobs module.

◆ OBS_MODULE_AUTHOR

#define OBS_MODULE_AUTHOR (   name)
Value:
MODULE_EXPORT const char *obs_module_author(void); \
const char *obs_module_author(void) {return name;}
#define MODULE_EXPORT
Definition: obs-module.h:26

Optional: Declares the author(s) of the module

Parameters
nameAuthor name(s)

◆ obs_module_config_path

#define obs_module_config_path (   file)    obs_module_get_config_path(obs_current_module(), file)

Returns the location to a module config file associated with the current module. Free with bfree when complete. Will return NULL if configuration directory is not set. Equivalent to: obs_module_get_config_path(obs_current_module(), file);

◆ obs_module_file

#define obs_module_file (   file)    obs_find_module_file(obs_current_module(), file)

Returns the location to a module data file associated with the current module. Free with bfree when complete. Equivalent to: obs_find_module_file(obs_current_module(), file);

◆ OBS_MODULE_USE_DEFAULT_LOCALE

#define OBS_MODULE_USE_DEFAULT_LOCALE (   module_name,
  default_locale 
)
Value:
lookup_t *obs_module_lookup = NULL; \
const char *obs_module_text(const char *val) \
{ \
const char *out = val; \
text_lookup_getstr(obs_module_lookup, val, &out); \
return out; \
} \
bool obs_module_get_string(const char *val, const char **out) \
{ \
return text_lookup_getstr(obs_module_lookup, val, out); \
} \
void obs_module_set_locale(const char *locale) \
{ \
if (obs_module_lookup) text_lookup_destroy(obs_module_lookup); \
obs_module_lookup = obs_module_load_locale( \
default_locale, locale); \
} \
{ \
text_lookup_destroy(obs_module_lookup); \
}
MODULE_EXPORT void obs_module_free_locale(void)
EXPORT lookup_t * obs_module_load_locale(obs_module_t *module, const char *default_locale, const char *locale)
MODULE_EXTERN obs_module_t * obs_current_module(void)
EXPORT void text_lookup_destroy(lookup_t *lookup)
struct text_lookup lookup_t
Definition: text-lookup.h:35
MODULE_EXTERN bool obs_module_get_string(const char *lookup_string, const char **translated_string)
EXPORT bool text_lookup_getstr(lookup_t *lookup, const char *lookup_val, const char **out)
MODULE_EXPORT void obs_module_set_locale(const char *locale)
MODULE_EXTERN const char * obs_module_text(const char *lookup_string)

Optional: Use this macro in a module to use default locale handling.

Function Documentation

◆ obs_current_module()

MODULE_EXTERN obs_module_t* obs_current_module ( void  )

Helper function that returns the current module

◆ obs_module_description()

MODULE_EXPORT const char* obs_module_description ( void  )

Optional: Returns a description of the module

◆ obs_module_free_locale()

MODULE_EXPORT void obs_module_free_locale ( void  )

Called to free the current locale data for the module.

◆ obs_module_get_string()

MODULE_EXTERN bool obs_module_get_string ( const char *  lookup_string,
const char **  translated_string 
)

Helper function for looking up locale if default locale handler was used, returns true if text found, otherwise false

◆ obs_module_load()

MODULE_EXPORT bool obs_module_load ( void  )

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

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

◆ obs_module_name()

MODULE_EXPORT const char* obs_module_name ( void  )

Optional: Returns the full name of the module

◆ obs_module_post_load()

MODULE_EXPORT void obs_module_post_load ( void  )

Optional: Called when all modules have finished loading

◆ obs_module_set_locale()

MODULE_EXPORT void obs_module_set_locale ( const char *  locale)

Called to set the current locale data for the module.

◆ obs_module_text()

MODULE_EXTERN const char* obs_module_text ( const char *  lookup_string)

Helper function for looking up locale if default locale handler was used

◆ obs_module_unload()

MODULE_EXPORT void obs_module_unload ( void  )

Optional: Called when the module is unloaded.