mirror of
https://github.com/Xaymar/obs-StreamFX
synced 2024-11-11 06:15:05 +00:00
obs/source-factory: Add function to register proxy objects
Proxies allow for older configurations to work fine on newer versions, without having to manually adjust the scene collection to match the new ids at all. Thanks to the migration system we can freely support any number of old versions, as long as we write migration code.
This commit is contained in:
parent
5530d2d416
commit
203581f30c
2 changed files with 21 additions and 2 deletions
|
@ -33,12 +33,15 @@
|
|||
// Common C++ includes
|
||||
#include <algorithm>
|
||||
#include <limits>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <set>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
// Common Plugin includes
|
||||
#include "strings.hpp"
|
||||
|
|
|
@ -25,7 +25,9 @@ namespace obs {
|
|||
template<class _factory, typename _instance>
|
||||
class source_factory {
|
||||
protected:
|
||||
obs_source_info _info = {};
|
||||
obs_source_info _info = {};
|
||||
std::map<std::string, std::shared_ptr<obs_source_info>> _proxies;
|
||||
std::set<std::string> _proxy_names;
|
||||
|
||||
public:
|
||||
source_factory()
|
||||
|
@ -166,6 +168,20 @@ namespace obs {
|
|||
obs_register_source(&_info);
|
||||
}
|
||||
|
||||
void register_proxy(std::string_view name)
|
||||
{
|
||||
auto iter = _proxy_names.emplace(name);
|
||||
|
||||
// Create proxy.
|
||||
std::shared_ptr<obs_source_info> proxy = std::make_shared<obs_source_info>();
|
||||
memcpy(proxy.get(), &_info, sizeof(obs_source_info));
|
||||
proxy->id = iter.first->c_str();
|
||||
proxy->output_flags |= OBS_SOURCE_DEPRECATED;
|
||||
obs_register_source(proxy.get());
|
||||
|
||||
_proxies.emplace(name, proxy);
|
||||
}
|
||||
|
||||
private /* Factory */:
|
||||
static const char* _get_name(void* type_data) noexcept
|
||||
try {
|
||||
|
@ -509,7 +525,7 @@ namespace obs {
|
|||
public:
|
||||
virtual const char* get_name()
|
||||
{
|
||||
return "Not Implemented Yet";
|
||||
return "Not Yet Implemented";
|
||||
}
|
||||
|
||||
virtual void* create(obs_data_t* settings, obs_source_t* source)
|
||||
|
|
Loading…
Reference in a new issue