Open Broadcaster Software
Free, open source software for live streaming and recording
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
obs-module.h
Go to the documentation of this file.
1 /******************************************************************************
2  Copyright (C) 2014 by Hugh Bailey <obs.jim@gmail.com>
3 
4  This program is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 2 of the License, or
7  (at your option) any later version.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program. If not, see <http://www.gnu.org/licenses/>.
16 ******************************************************************************/
17 
18 #pragma once
19 
20 #include "obs.h"
21 
22 #ifdef __cplusplus
23 #define MODULE_EXPORT extern "C" EXPORT
24 #define MODULE_EXTERN extern "C"
25 #else
26 #define MODULE_EXPORT EXPORT
27 #define MODULE_EXTERN extern
28 #endif
29 
76 #define OBS_DECLARE_MODULE() \
77  static obs_module_t *obs_module_pointer; \
78  MODULE_EXPORT void obs_module_set_pointer(obs_module_t *module); \
79  void obs_module_set_pointer(obs_module_t *module) \
80  { \
81  obs_module_pointer = module; \
82  } \
83  obs_module_t *obs_current_module(void) {return obs_module_pointer;} \
84  MODULE_EXPORT uint32_t obs_module_ver(void); \
85  uint32_t obs_module_ver(void) {return LIBOBS_API_VER;}
86 
96 
99 
101 MODULE_EXPORT void obs_module_set_locale(const char *locale);
102 
105 
107 #define OBS_MODULE_USE_DEFAULT_LOCALE(module_name, default_locale) \
108  lookup_t *obs_module_lookup = NULL; \
109  const char *obs_module_text(const char *val) \
110  { \
111  const char *out = val; \
112  text_lookup_getstr(obs_module_lookup, val, &out); \
113  return out; \
114  } \
115  bool obs_module_get_string(const char *val, const char **out) \
116  { \
117  return text_lookup_getstr(obs_module_lookup, val, out); \
118  } \
119  void obs_module_set_locale(const char *locale) \
120  { \
121  if (obs_module_lookup) text_lookup_destroy(obs_module_lookup); \
122  obs_module_lookup = obs_module_load_locale( \
123  obs_current_module(), \
124  default_locale, locale); \
125  } \
126  void obs_module_free_locale(void) \
127  { \
128  text_lookup_destroy(obs_module_lookup); \
129  }
130 
132 MODULE_EXTERN const char *obs_module_text(const char *lookup_string);
133 
136 MODULE_EXTERN bool obs_module_get_string(const char *lookup_string,
137  const char **translated_string);
138 
141 
147 #define obs_module_file(file) obs_find_module_file(obs_current_module(), file)
148 
155 #define obs_module_config_path(file) \
156  obs_module_get_config_path(obs_current_module(), file)
157 
163 #define OBS_MODULE_AUTHOR(name) \
164  MODULE_EXPORT const char *obs_module_author(void); \
165  const char *obs_module_author(void) {return name;}
166 
168 MODULE_EXPORT const char *obs_module_name(void);
169 
171 MODULE_EXPORT const char *obs_module_description(void);
MODULE_EXPORT void obs_module_free_locale(void)
MODULE_EXPORT void obs_module_unload(void)
MODULE_EXTERN obs_module_t * obs_current_module(void)
MODULE_EXPORT const char * obs_module_name(void)
MODULE_EXPORT const char * obs_module_description(void)
MODULE_EXPORT bool obs_module_load(void)
#define MODULE_EXTERN
Definition: obs-module.h:27
Definition: obs-internal.h:75
MODULE_EXTERN bool obs_module_get_string(const char *lookup_string, const char **translated_string)
Main libobs header used by applications.
#define MODULE_EXPORT
Definition: obs-module.h:26
MODULE_EXPORT void obs_module_set_locale(const char *locale)
MODULE_EXTERN const char * obs_module_text(const char *lookup_string)