obs-tools: Add child_source helper class

This commit is contained in:
Michael Fabian 'Xaymar' Dirks 2020-02-13 05:41:47 +01:00
parent 03930b6b42
commit 40369bf72d
2 changed files with 28 additions and 0 deletions

View file

@ -179,3 +179,19 @@ bool obs::tools::obs_properties_remove_by_name(obs_properties_t* props, const ch
return false;
}
obs::tools::child_source::child_source(obs_source_t* parent, std::shared_ptr<obs_source_t> child)
: _parent(parent), _child(child)
{
obs_source_add_active_child(_parent, _child.get());
}
obs::tools::child_source::~child_source()
{
obs_source_remove_active_child(_parent, _child.get());
}
std::shared_ptr<obs_source_t> obs::tools::child_source::get()
{
return _child;
}

View file

@ -22,6 +22,7 @@
#pragma once
#include <cinttypes>
#include <memory>
#include <string>
// OBS
@ -39,6 +40,17 @@ namespace obs {
bool scene_contains_source(obs_scene_t* scene, obs_source_t* source);
bool obs_properties_remove_by_name(obs_properties_t* props, const char* name);
class child_source {
obs_source_t* _parent;
std::shared_ptr<obs_source_t> _child;
public:
child_source(obs_source_t* parent, std::shared_ptr<obs_source_t> child);
virtual ~child_source();
std::shared_ptr<obs_source_t> get();
};
} // namespace tools
static void obs_source_deleter(obs_source_t* v)