plugin-main.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. //
  2. // plugin-main.h
  3. // mac-avcapture
  4. //
  5. // Created by Patrick Heyer on 2023-03-07.
  6. //
  7. #import <obs-module.h>
  8. #import <pthread.h>
  9. #import "OBSAVCapture.h"
  10. #import "plugin-properties.h"
  11. /// Get localized text for module string identifier
  12. /// - Parameters:
  13. /// - text_id: Localization string identifier
  14. /// - Returns: Pointer to localized text variant
  15. extern const char *av_capture_get_text(const char *text_id);
  16. /// Create a macOS ``OBSAVCapture`` source using asynchronous video frames
  17. /// - Parameters:
  18. /// - settings: Pointer to ``libobs`` data struct with possible user settings read from configuration file
  19. /// - source: Pointer to ``libobs`` source struct
  20. /// - Returns: Pointer to created ``OBSAVCaptureInfo`` struct
  21. static void *av_capture_create(obs_data_t *settings, obs_source_t *source);
  22. /// Create a macOS ``OBSAVCapture`` source rendering video frames directly.
  23. /// - Parameters:
  24. /// - settings: Pointer to ``libobs`` data struct with possible user settings read from configuration file
  25. /// - source: Pointer to ``libobs`` source struct
  26. /// - Returns: Pointer to created ``OBSAVCaptureInfo`` struct
  27. static void *av_fast_capture_create(obs_data_t *settings, obs_source_t *source);
  28. /// Get localized ``OBSAVCapture`` source name.
  29. ///
  30. /// The value returned by this function will be used to identify the ``OBSAVCapture`` source throughout the OBS Studio user interface.
  31. ///
  32. /// - Parameters:
  33. /// - data: Pointer to ``OBSAVCaptureInfo`` struct as returned by ``av_capture_create``
  34. /// - Returns: Pointer to localized source type name
  35. static const char *av_capture_get_name(void *capture_info);
  36. /// Get localized source name of the fast capture variant of the ``OBSAVCapture`` source.
  37. ///
  38. /// The value returned by this function will be used to identify the ``OBSAVCapture`` source throughout the OBS Studio user interface.
  39. ///
  40. /// - Parameters:
  41. /// - data: Pointer to ``OBSAVCaptureInfo`` struct as returned by ``av_capture_create``
  42. /// - Returns: Pointer to localized source type name
  43. static const char *av_fast_capture_get_name(void *capture_info);
  44. /// Set default values used by the ``OBSAVCapture`` source
  45. ///
  46. /// While this function sets default values for specific properties in the user settings, the function is also called to _get_ defaults by ``libobs``
  47. ///
  48. /// - Parameters:
  49. /// - settings: Pointer to obs settings struct
  50. static void av_capture_set_defaults(obs_data_t *settings);
  51. /// Set default values used by the fast capture variant of the ``OBSAVCapture`` source
  52. ///
  53. /// While this function sets default values for specific properties in the user settings, the function is also called to _get_ defaults by ``libobs``
  54. ///
  55. /// - Parameters:
  56. /// - settings: Pointer to obs settings struct
  57. static void av_fast_capture_set_defaults(obs_data_t *settings);
  58. /// Creates a new properties struct with all the properties used by the ``OBSAVCapture`` source.
  59. ///
  60. /// This function is commonly used to set up all the properties that a source type has and can be used by the internal API to discover which properties exist, but is also commonly used to set up the properties used for the OBS Studio user interface.
  61. ///
  62. /// If the source type was created successfully, the associated ``OBSAVCaptureInfo`` struct is passed to this function as well, which allows setting up property visibility and availability depending on the source state.
  63. ///
  64. /// - Parameters:
  65. /// - capture_info: Pointer to ``OBSAVCaptureInfo`` struct
  66. /// - Returns: Pointer to created OBS properties struct
  67. static obs_properties_t *av_capture_properties(void *capture_info);
  68. /// Update ``OBSAVCapture`` source
  69. /// - Parameters:
  70. /// - capture_info: Pointer to ``OBSAVCaptureInfo`` struct
  71. /// - settings: Pointer to settings struct
  72. static void av_capture_update(void *capture_info, obs_data_t *settings);
  73. /// Handle ``tick`` of ``libobs`` compositing engine.
  74. ///
  75. /// ``libobs`` sends a tick at an internal refresh rate to allow sources to prepare data for output. This function works in conjunction with the ``render`` which function which is called at a later point at the frame rate specified in the `Output` configuration of OBS Studio.
  76. ///
  77. /// ``OBSAVCapture`` keeps a reference to the ``IOSurface`` of the last two frames provided by ``CoreMediaIO`` and converts a valid ``IOSurface`` into a ``libobs``-recognized texture in this function.
  78. ///
  79. /// - Parameters:
  80. /// - capture_info: Pointer to ``OBSAVCaptureInfo`` struct
  81. /// - seconds: Delta since the last call to this function
  82. static void av_fast_capture_tick(void *capture_info, float seconds);
  83. /// Handle ``render`` of ``libobs`` compositing engine.
  84. ///
  85. /// ``libobs`` sends a render call at the frame rate specified in the `Output` configuration of OBS Studio, which requires the source to do the actual rendering work using the ``libobs`` graphics engine.Draw
  86. ///
  87. /// - Parameters:
  88. /// - capture_info: Pointer to ``OBSAVCaptureInfo`` struct
  89. /// - effect: Draw function used by ``libobs``
  90. static void av_fast_capture_render(void *capture_info, gs_effect_t *effect);
  91. /// Get width of texture currently managed by the ``OBSAVCapture`` source
  92. /// - Parameters:
  93. /// - capture_info: Pointer to ``OBSAVCaptureInfo`` struct
  94. static UInt32 av_fast_capture_get_width(void *capture_info);
  95. /// Get height of texture currently managed by the ``OBSAVCapture`` source
  96. /// - Parameters:
  97. /// - capture_info: Pointer to ``OBSAVCaptureInfo`` struct
  98. static UInt32 av_fast_capture_get_height(void *capture_info);
  99. /// Tear down ``OBSAVCapture`` source.
  100. ///
  101. /// This function implements all the necessary cleanup functions to ensure a clean exit of the program. Any resources or references held by the source need to be deleted or destroyed to avoid memory leaks. Any shutdown or cleanup functions required by resources used by the source also need to be called to ensure a clean shutdown.
  102. /// - Parameters:
  103. /// - capture_info: Pointer to ``OBSAVCaptureInfo`` struct
  104. static void av_capture_destroy(void *capture_info);