libobs: Add obs_scene_find_source_recursive
Same as obs_scene_find_source but also searches groups within the scene.
This commit is contained in:
parent
818e3a364e
commit
3aa08c4e0f
@ -225,6 +225,16 @@ General Scene Functions
|
||||
|
||||
---------------------
|
||||
|
||||
.. function:: obs_sceneitem_t *obs_scene_find_source_recursive(obs_scene_t *scene, const char *name)
|
||||
|
||||
Same as obs_scene_find_source, but also searches groups within the
|
||||
scene.
|
||||
|
||||
:param name: The name of the source to find
|
||||
:return: The scene item if found, otherwise *NULL* if not found
|
||||
|
||||
---------------------
|
||||
|
||||
.. function:: obs_sceneitem_t *obs_scene_find_sceneitem_by_id(obs_scene_t *scene, int64_t id)
|
||||
|
||||
:param id: The unique numeric identifier of the scene item
|
||||
|
@ -1445,6 +1445,39 @@ obs_sceneitem_t *obs_scene_find_source(obs_scene_t *scene, const char *name)
|
||||
return item;
|
||||
}
|
||||
|
||||
obs_sceneitem_t *obs_scene_find_source_recursive(obs_scene_t *scene,
|
||||
const char *name)
|
||||
{
|
||||
struct obs_scene_item *item;
|
||||
|
||||
if (!scene)
|
||||
return NULL;
|
||||
|
||||
full_lock(scene);
|
||||
|
||||
item = scene->first_item;
|
||||
while (item) {
|
||||
if (strcmp(item->source->context.name, name) == 0)
|
||||
break;
|
||||
|
||||
if (item->is_group) {
|
||||
obs_scene_t *group = item->source->context.data;
|
||||
obs_sceneitem_t *child =
|
||||
obs_scene_find_source(group, name);
|
||||
if (child) {
|
||||
item = child;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
item = item->next;
|
||||
}
|
||||
|
||||
full_unlock(scene);
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
obs_sceneitem_t *obs_scene_find_sceneitem_by_id(obs_scene_t *scene, int64_t id)
|
||||
{
|
||||
struct obs_scene_item *item;
|
||||
|
@ -1450,6 +1450,9 @@ EXPORT obs_scene_t *obs_scene_from_source(const obs_source_t *source);
|
||||
EXPORT obs_sceneitem_t *obs_scene_find_source(obs_scene_t *scene,
|
||||
const char *name);
|
||||
|
||||
EXPORT obs_sceneitem_t *obs_scene_find_source_recursive(obs_scene_t *scene,
|
||||
const char *name);
|
||||
|
||||
EXPORT obs_sceneitem_t *obs_scene_find_sceneitem_by_id(obs_scene_t *scene,
|
||||
int64_t id);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user