Open Broadcaster Software
Free, open source software for live streaming and recording
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) \
125  text_lookup_destroy(obs_module_lookup); \
126  obs_module_lookup = obs_module_load_locale( \
127  obs_current_module(), default_locale, locale); \
128  } \
129  void obs_module_free_locale(void) \
130  { \
131  text_lookup_destroy(obs_module_lookup); \
132  obs_module_lookup = NULL; \
133  }
134 
136 MODULE_EXTERN const char *obs_module_text(const char *lookup_string);
137 
140 MODULE_EXTERN bool obs_module_get_string(const char *lookup_string,
141  const char **translated_string);
142 
145 
151 #define obs_module_file(file) obs_find_module_file(obs_current_module(), file)
152 
159 #define obs_module_config_path(file) \
160  obs_module_get_config_path(obs_current_module(), file)
161 
167 #define OBS_MODULE_AUTHOR(name) \
168  MODULE_EXPORT const char *obs_module_author(void); \
169  const char *obs_module_author(void) { return name; }
170 
172 MODULE_EXPORT const char *obs_module_name(void);
173 
175 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:83
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)