libobs: Add ability to disable source types

Because it would be troublesome to add the ability to remove source
types (in case for example a script fails to reload), instead make it so
source types can be temporarily disabled while the program is running.
master
jp9000 2017-12-25 12:20:54 -08:00
parent c8a0f661fb
commit a730f9d6ce
3 changed files with 20 additions and 2 deletions

View File

@ -691,7 +691,7 @@ struct obs_source {
obs_data_t *private_settings;
};
extern const struct obs_source_info *get_source_info(const char *id);
extern struct obs_source_info *get_source_info(const char *id);
extern bool obs_source_init_context(struct obs_source *source,
obs_data_t *settings, const char *name,
obs_data_t *hotkey_data, bool private);

View File

@ -39,7 +39,7 @@ static inline bool deinterlacing_enabled(const struct obs_source *source)
return source->deinterlace_mode != OBS_DEINTERLACE_MODE_DISABLE;
}
const struct obs_source_info *get_source_info(const char *id)
struct obs_source_info *get_source_info(const char *id)
{
for (size_t i = 0; i < obs->source_types.num; i++) {
struct obs_source_info *info = &obs->source_types.array[i];
@ -4115,3 +4115,16 @@ bool obs_source_async_decoupled(const obs_source_t *source)
return obs_source_valid(source, "obs_source_async_decoupled") ?
source->async_decoupled : false;
}
/* hidden/undocumented export to allow source type redefinition for scripts */
EXPORT void obs_enable_source_type(const char *name, bool enable)
{
struct obs_source_info *info = get_source_info(name);
if (!info)
return;
if (enable)
info->output_flags &= ~OBS_SOURCE_CAP_DISABLED;
else
info->output_flags |= OBS_SOURCE_CAP_DISABLED;
}

View File

@ -130,6 +130,11 @@ enum obs_source_type {
*/
#define OBS_SOURCE_DO_NOT_SELF_MONITOR (1<<9)
/**
* Source type is currently disabled and should not be shown to the user
*/
#define OBS_SOURCE_CAP_DISABLED (1<<10)
/** @} */
typedef void (*obs_source_enum_proc_t)(obs_source_t *parent,