obs-module.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /******************************************************************************
  2. Copyright (C) 2014 by Hugh Bailey <[email protected]>
  3. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation, either version 2 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. ******************************************************************************/
  14. #pragma once
  15. #include "obs.h"
  16. #ifdef __cplusplus
  17. #define MODULE_EXPORT extern "C" EXPORT
  18. #else
  19. #define MODULE_EXPORT EXPORT
  20. #endif
  21. #define OBS_SIZE_FUNC(structure, func) \
  22. MODULE_EXPORT size_t func(void); \
  23. size_t func(void) {return sizeof(struct structure);}
  24. /**
  25. * @file
  26. *
  27. * This file is used by modules for module declaration and module exports.
  28. */
  29. /** Required: Declares a libobs module. */
  30. #define OBS_DECLARE_MODULE() \
  31. MODULE_EXPORT uint32_t obs_module_ver(void); \
  32. uint32_t obs_module_ver(void) {return LIBOBS_API_VER;} \
  33. OBS_SIZE_FUNC(obs_source_info, obs_module_source_info_size) \
  34. OBS_SIZE_FUNC(obs_output_info, obs_module_output_info_size) \
  35. OBS_SIZE_FUNC(obs_encoder_info, obs_module_encoder_info_size) \
  36. OBS_SIZE_FUNC(obs_encoder_info, obs_module_service_info_size) \
  37. OBS_SIZE_FUNC(obs_modal_ui, obs_module_modal_ui_size) \
  38. OBS_SIZE_FUNC(obs_modeless_ui, obs_module_modeless_ui_size)
  39. /**
  40. * Required: Called when the module is loaded. Use this function to load all
  41. * the sources/encoders/outputs/services for your module, or anything else that
  42. * may need loading.
  43. *
  44. * @param libobs_ver The version of libobs.
  45. * @return Return true to continue loading the module, otherwise
  46. * false to indcate failure and unload the module
  47. */
  48. MODULE_EXPORT bool obs_module_load(uint32_t libobs_version);
  49. /** Optional: Called when the module is unloaded. */
  50. MODULE_EXPORT void obs_module_unload(void);
  51. /**
  52. * Optional: Declares the author(s) of the module
  53. *
  54. * @param name Author name(s)
  55. */
  56. #define OBS_MODULE_AUTHOR(name) \
  57. MODULE_EXPORT const char *obs_module_author(void); \
  58. const char *obs_module_author(void) {return name;}
  59. /**
  60. * Optional: Declares the author of the module
  61. *
  62. * @param locale Locale to look up the description for.
  63. */
  64. MODULE_EXPORT const char *obs_module_description(const char *locale);