libobs: Add obs_source_get_filter_by_name function

This commit is contained in:
jp9000 2015-02-25 21:14:57 -08:00
parent 9f82085243
commit 50a36f45cd
2 changed files with 28 additions and 0 deletions

View file

@ -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;
}

View file

@ -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 */