libobs: Add obs_get_transition_by_name

This commit is contained in:
gxalpha 2021-11-07 12:51:41 +01:00 committed by Jim
parent a7e0affd36
commit c36a5ae92b
3 changed files with 33 additions and 0 deletions

View File

@ -262,6 +262,15 @@ Libobs Objects
---------------------
.. function:: obs_source_t *obs_get_transition_by_name(const char *name)
Gets a transition by its name.
Increments the source reference counter, use
:c:func:`obs_source_release()` to release it when complete.
---------------------
.. function:: obs_output_t *obs_get_output_by_name(const char *name)
Gets an output by its name.

View File

@ -1593,6 +1593,27 @@ obs_source_t *obs_get_source_by_name(const char *name)
obs_source_addref_safe_);
}
obs_source_t *obs_get_transition_by_name(const char *name)
{
struct obs_source **first = &obs->data.first_source;
struct obs_source *source;
pthread_mutex_lock(&obs->data.sources_mutex);
source = *first;
while (source) {
if (source->info.type == OBS_SOURCE_TYPE_TRANSITION &&
strcmp(source->context.name, name) == 0) {
source = obs_source_addref_safe_(source);
break;
}
source = (void *)source->context.next;
}
pthread_mutex_unlock(&obs->data.sources_mutex);
return source;
}
obs_output_t *obs_get_output_by_name(const char *name)
{
return get_context_by_name(&obs->data.first_output, name,

View File

@ -636,6 +636,9 @@ EXPORT void obs_enum_services(bool (*enum_proc)(void *, obs_service_t *),
*/
EXPORT obs_source_t *obs_get_source_by_name(const char *name);
/** Get a transition source by its name. */
EXPORT obs_source_t *obs_get_transition_by_name(const char *name);
/** Gets an output by its name. */
EXPORT obs_output_t *obs_get_output_by_name(const char *name);