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 
102 
104 MODULE_EXPORT void obs_module_set_locale(const char *locale);
105 
108 
110 #define OBS_MODULE_USE_DEFAULT_LOCALE(module_name, default_locale) \
111  lookup_t *obs_module_lookup = NULL; \
112  const char *obs_module_text(const char *val) \
113  { \
114  const char *out = val; \
115  text_lookup_getstr(obs_module_lookup, val, &out); \
116  return out; \
117  } \
118  bool obs_module_get_string(const char *val, const char **out) \
119  { \
120  return text_lookup_getstr(obs_module_lookup, val, out); \
121  } \
122  void obs_module_set_locale(const char *locale) \
123  { \
124  if (obs_module_lookup) text_lookup_destroy(obs_module_lookup); \
125  obs_module_lookup = obs_module_load_locale( \
126  obs_current_module(), \
127  default_locale, locale); \
128  } \
129  void obs_module_free_locale(void) \
130  { \
131  text_lookup_destroy(obs_module_lookup); \
132  }
133 
135 MODULE_EXTERN const char *obs_module_text(const char *lookup_string);
136 
139 MODULE_EXTERN bool obs_module_get_string(const char *lookup_string,
140  const char **translated_string);
141 
144 
150 #define obs_module_file(file) obs_find_module_file(obs_current_module(), file)
151 
158 #define obs_module_config_path(file) \
159  obs_module_get_config_path(obs_current_module(), file)
160 
166 #define OBS_MODULE_AUTHOR(name) \
167  MODULE_EXPORT const char *obs_module_author(void); \
168  const char *obs_module_author(void) {return name;}
169 
171 MODULE_EXPORT const char *obs_module_name(void);
172 
174 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:80
MODULE_EXTERN bool obs_module_get_string(const char *lookup_string, const char **translated_string)
MODULE_EXPORT void obs_module_post_load(void)
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)