You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
80 lines
1.4 KiB
80 lines
1.4 KiB
#include "obs-manager.hpp"
|
|
#include <obs/obs.h>
|
|
#include <glibmm/ustring.h>
|
|
#include <stdexcept>
|
|
|
|
using namespace Glib;
|
|
|
|
OBSManager::OBSManager()
|
|
{
|
|
plugins = {
|
|
"obs-ffmpeg.so",
|
|
"linux-v4l2.so",
|
|
"linux-capture.so",
|
|
};
|
|
}
|
|
|
|
OBSManager::~OBSManager()
|
|
{
|
|
if (display != nullptr)
|
|
obs_display_destroy(display);
|
|
}
|
|
|
|
ustring OBSManager::GetVersion()
|
|
{
|
|
return ustring(obs_get_version_string());
|
|
}
|
|
|
|
void OBSManager::Initialize()
|
|
{
|
|
if (isInitialized)
|
|
return;
|
|
|
|
if (!obs_startup("en-US", NULL, NULL))
|
|
throw std::runtime_error("Failed to initialize OBS");
|
|
|
|
struct gs_init_data info = {
|
|
.cx = 1280,
|
|
.cy = 720,
|
|
.format = GS_BGRA,
|
|
.zsformat = GS_ZS_NONE,
|
|
};
|
|
|
|
display = obs_display_create(&info, 0);
|
|
if (display == nullptr)
|
|
throw std::runtime_error("Failed to create display");
|
|
}
|
|
|
|
ustring OBSManager::GetPluginDir()
|
|
{
|
|
return pluginDir;
|
|
}
|
|
|
|
void OBSManager::loadPlugin(ustring name)
|
|
{
|
|
obs_module_t *module;
|
|
|
|
ustring path;
|
|
path.append(pluginDir);
|
|
path.append(name);
|
|
|
|
int res = obs_open_module(&module, path.c_str(), nullptr);
|
|
if (res != MODULE_SUCCESS)
|
|
throw std::runtime_error("Failed to open plugin");
|
|
|
|
obs_init_module(module);
|
|
}
|
|
|
|
|
|
void OBSManager::loadPlugins()
|
|
{
|
|
for (ustring plugin : plugins)
|
|
{
|
|
loadPlugin(plugin);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|