mirror of
https://github.com/obsproject/obs-studio.git
synced 2024-09-20 04:42:18 +02:00
libobs: Add obs_source_get_filter_by_name function
This commit is contained in:
parent
9f82085243
commit
50a36f45cd
@ -2451,3 +2451,27 @@ void obs_source_enum_filters(obs_source_t *source,
|
||||
|
||||
pthread_mutex_unlock(&source->filter_mutex);
|
||||
}
|
||||
|
||||
obs_source_t *obs_source_get_filter_by_name(obs_source_t *source,
|
||||
const char *name)
|
||||
{
|
||||
obs_source_t *filter = NULL;
|
||||
|
||||
if (!source || !name)
|
||||
return NULL;
|
||||
|
||||
pthread_mutex_lock(&source->filter_mutex);
|
||||
|
||||
for (size_t i = 0; i < source->filters.num; i++) {
|
||||
struct obs_source *cur_filter = source->filters.array[i];
|
||||
if (strcmp(cur_filter->context.name, name) == 0) {
|
||||
filter = cur_filter;
|
||||
obs_source_addref(filter);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
pthread_mutex_unlock(&source->filter_mutex);
|
||||
|
||||
return filter;
|
||||
}
|
||||
|
@ -798,6 +798,10 @@ EXPORT void obs_source_dec_showing(obs_source_t *source);
|
||||
EXPORT void obs_source_enum_filters(obs_source_t *source,
|
||||
obs_source_enum_proc_t callback, void *param);
|
||||
|
||||
/** Gets a filter of a source by its display name. */
|
||||
EXPORT obs_source_t *obs_source_get_filter_by_name(obs_source_t *source,
|
||||
const char *name);
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* Functions used by sources */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user