2023-02-28 01:15:26 +00:00
|
|
|
// AUTOGENERATED COPYRIGHT HEADER START
|
|
|
|
// Copyright (C) 2017-2023 Michael Fabian 'Xaymar' Dirks <info@xaymar.com>
|
|
|
|
// AUTOGENERATED COPYRIGHT HEADER END
|
2017-06-28 21:21:42 +00:00
|
|
|
|
2019-01-14 10:23:21 +00:00
|
|
|
#include "plugin.hpp"
|
2020-04-22 20:58:33 +00:00
|
|
|
#include "configuration.hpp"
|
2021-11-09 10:33:07 +00:00
|
|
|
#include "gfx/gfx-opengl.hpp"
|
|
|
|
#include "obs/gs/gs-helper.hpp"
|
2020-07-26 19:44:13 +00:00
|
|
|
#include "obs/gs/gs-vertexbuffer.hpp"
|
2020-07-12 16:41:50 +00:00
|
|
|
#include "obs/obs-source-tracker.hpp"
|
2020-01-13 21:40:15 +00:00
|
|
|
|
2021-06-17 11:28:13 +00:00
|
|
|
#ifdef ENABLE_NVIDIA_CUDA
|
|
|
|
#include "nvidia/cuda/nvidia-cuda-obs.hpp"
|
|
|
|
#endif
|
|
|
|
|
2021-08-28 12:36:42 +00:00
|
|
|
#ifdef ENABLE_ENCODER_AOM_AV1
|
|
|
|
#include "encoders/encoder-aom-av1.hpp"
|
|
|
|
#endif
|
2020-03-27 19:06:27 +00:00
|
|
|
#ifdef ENABLE_ENCODER_FFMPEG
|
2020-06-14 20:22:44 +00:00
|
|
|
#include "encoders/encoder-ffmpeg.hpp"
|
2020-03-27 19:06:27 +00:00
|
|
|
#endif
|
2020-01-13 21:40:15 +00:00
|
|
|
|
2021-10-25 18:40:55 +00:00
|
|
|
#ifdef ENABLE_FILTER_AUTOFRAMING
|
|
|
|
#include "filters/filter-autoframing.hpp"
|
|
|
|
#endif
|
2020-03-16 19:37:31 +00:00
|
|
|
#ifdef ENABLE_FILTER_BLUR
|
2019-09-04 00:47:27 +00:00
|
|
|
#include "filters/filter-blur.hpp"
|
2020-03-16 19:37:31 +00:00
|
|
|
#endif
|
|
|
|
#ifdef ENABLE_FILTER_COLOR_GRADE
|
2019-09-04 00:47:27 +00:00
|
|
|
#include "filters/filter-color-grade.hpp"
|
2020-03-16 19:37:31 +00:00
|
|
|
#endif
|
2021-05-01 16:31:13 +00:00
|
|
|
#ifdef ENABLE_FILTER_DENOISING
|
|
|
|
#include "filters/filter-denoising.hpp"
|
|
|
|
#endif
|
2020-03-16 19:37:31 +00:00
|
|
|
#ifdef ENABLE_FILTER_DISPLACEMENT
|
2019-09-04 00:47:27 +00:00
|
|
|
#include "filters/filter-displacement.hpp"
|
2020-03-16 19:37:31 +00:00
|
|
|
#endif
|
|
|
|
#ifdef ENABLE_FILTER_DYNAMIC_MASK
|
2019-09-04 00:47:27 +00:00
|
|
|
#include "filters/filter-dynamic-mask.hpp"
|
2020-03-16 19:37:31 +00:00
|
|
|
#endif
|
|
|
|
#ifdef ENABLE_FILTER_SDF_EFFECTS
|
2019-09-04 00:47:27 +00:00
|
|
|
#include "filters/filter-sdf-effects.hpp"
|
2020-03-16 19:37:31 +00:00
|
|
|
#endif
|
|
|
|
#ifdef ENABLE_FILTER_SHADER
|
2020-03-28 17:54:56 +00:00
|
|
|
#include "filters/filter-shader.hpp"
|
2020-03-16 19:37:31 +00:00
|
|
|
#endif
|
|
|
|
#ifdef ENABLE_FILTER_TRANSFORM
|
|
|
|
#include "filters/filter-transform.hpp"
|
|
|
|
#endif
|
2021-09-27 22:16:21 +00:00
|
|
|
#ifdef ENABLE_FILTER_UPSCALING
|
|
|
|
#include "filters/filter-upscaling.hpp"
|
2021-06-02 21:37:18 +00:00
|
|
|
#endif
|
2021-10-23 18:05:36 +00:00
|
|
|
#ifdef ENABLE_FILTER_VIRTUAL_GREENSCREEN
|
|
|
|
#include "filters/filter-virtual-greenscreen.hpp"
|
|
|
|
#endif
|
2020-03-27 19:06:27 +00:00
|
|
|
|
2020-03-16 19:37:31 +00:00
|
|
|
#ifdef ENABLE_SOURCE_MIRROR
|
2019-09-04 00:47:27 +00:00
|
|
|
#include "sources/source-mirror.hpp"
|
2020-03-16 19:37:31 +00:00
|
|
|
#endif
|
|
|
|
#ifdef ENABLE_SOURCE_SHADER
|
2019-09-04 00:47:27 +00:00
|
|
|
#include "sources/source-shader.hpp"
|
2020-03-16 19:37:31 +00:00
|
|
|
#endif
|
2020-03-27 19:06:27 +00:00
|
|
|
|
2020-03-16 19:37:31 +00:00
|
|
|
#ifdef ENABLE_TRANSITION_SHADER
|
2020-03-28 17:38:45 +00:00
|
|
|
#include "transitions/transition-shader.hpp"
|
2020-03-16 19:37:31 +00:00
|
|
|
#endif
|
2017-06-28 21:21:42 +00:00
|
|
|
|
2020-04-05 16:52:06 +00:00
|
|
|
#ifdef ENABLE_FRONTEND
|
|
|
|
#include "ui/ui.hpp"
|
|
|
|
#endif
|
|
|
|
|
2020-09-09 03:06:15 +00:00
|
|
|
#ifdef ENABLE_UPDATER
|
|
|
|
#include "updater.hpp"
|
|
|
|
//static std::shared_ptr<streamfx::updater> _updater;
|
|
|
|
#endif
|
|
|
|
|
2022-08-29 10:29:44 +00:00
|
|
|
#include "warning-disable.hpp"
|
|
|
|
#include <fstream>
|
|
|
|
#include <stdexcept>
|
|
|
|
#include "warning-enable.hpp"
|
|
|
|
|
2022-09-18 16:30:15 +00:00
|
|
|
static std::shared_ptr<streamfx::util::threadpool::threadpool> _threadpool;
|
|
|
|
static std::shared_ptr<streamfx::gfx::opengl> _streamfx_gfx_opengl;
|
|
|
|
static std::shared_ptr<streamfx::obs::source_tracker> _source_tracker;
|
2020-03-03 00:49:26 +00:00
|
|
|
|
2019-12-21 16:04:38 +00:00
|
|
|
MODULE_EXPORT bool obs_module_load(void)
|
2022-08-27 11:17:47 +00:00
|
|
|
{
|
|
|
|
try {
|
|
|
|
DLOG_INFO("Loading Version %s", STREAMFX_VERSION_STRING);
|
2019-09-05 16:42:28 +00:00
|
|
|
|
2022-08-27 11:17:47 +00:00
|
|
|
// Initialize global configuration.
|
|
|
|
streamfx::configuration::initialize();
|
2020-04-22 20:58:33 +00:00
|
|
|
|
2022-08-27 11:17:47 +00:00
|
|
|
// Initialize global Thread Pool.
|
2022-09-18 16:30:15 +00:00
|
|
|
_threadpool = std::make_shared<streamfx::util::threadpool::threadpool>();
|
2020-04-05 16:52:06 +00:00
|
|
|
|
2022-08-27 11:17:47 +00:00
|
|
|
// Initialize Source Tracker
|
|
|
|
_source_tracker = streamfx::obs::source_tracker::get();
|
2019-09-05 16:42:28 +00:00
|
|
|
|
2022-08-27 11:17:47 +00:00
|
|
|
// Initialize GLAD (OpenGL)
|
|
|
|
{
|
|
|
|
streamfx::obs::gs::context gctx{};
|
2022-11-28 06:43:46 +00:00
|
|
|
if (gs_get_device_type() == GS_DEVICE_OPENGL) {
|
|
|
|
_streamfx_gfx_opengl = streamfx::gfx::opengl::get();
|
|
|
|
}
|
2022-08-27 11:17:47 +00:00
|
|
|
}
|
2021-11-09 10:33:07 +00:00
|
|
|
|
2021-06-17 11:28:13 +00:00
|
|
|
#ifdef ENABLE_NVIDIA_CUDA
|
2022-08-27 11:17:47 +00:00
|
|
|
// Initialize CUDA if features requested it.
|
|
|
|
std::shared_ptr<::streamfx::nvidia::cuda::obs> cuda;
|
|
|
|
try {
|
|
|
|
cuda = ::streamfx::nvidia::cuda::obs::get();
|
|
|
|
} catch (...) {
|
|
|
|
// If CUDA failed to load, it is considered safe to ignore.
|
|
|
|
}
|
2021-06-17 11:28:13 +00:00
|
|
|
#endif
|
|
|
|
|
2022-08-27 11:17:47 +00:00
|
|
|
// Encoders
|
|
|
|
{
|
2021-08-28 12:36:42 +00:00
|
|
|
#ifdef ENABLE_ENCODER_AOM_AV1
|
2022-08-27 11:17:47 +00:00
|
|
|
streamfx::encoder::aom::av1::aom_av1_factory::initialize();
|
2021-08-28 12:36:42 +00:00
|
|
|
#endif
|
2020-03-16 19:37:31 +00:00
|
|
|
#ifdef ENABLE_ENCODER_FFMPEG
|
2022-08-27 11:17:47 +00:00
|
|
|
using namespace streamfx::encoder::ffmpeg;
|
|
|
|
ffmpeg_manager::initialize();
|
2020-03-16 19:37:31 +00:00
|
|
|
#endif
|
2022-08-27 11:17:47 +00:00
|
|
|
}
|
2020-01-13 21:40:15 +00:00
|
|
|
|
2022-08-27 11:17:47 +00:00
|
|
|
// Filters
|
|
|
|
{
|
2021-10-25 18:40:55 +00:00
|
|
|
#ifdef ENABLE_FILTER_AUTOFRAMING
|
2022-08-27 11:17:47 +00:00
|
|
|
streamfx::filter::autoframing::autoframing_factory::initialize();
|
2021-10-25 18:40:55 +00:00
|
|
|
#endif
|
2020-03-16 19:37:31 +00:00
|
|
|
#ifdef ENABLE_FILTER_BLUR
|
2022-08-27 11:17:47 +00:00
|
|
|
streamfx::filter::blur::blur_factory::initialize();
|
2020-03-16 19:37:31 +00:00
|
|
|
#endif
|
|
|
|
#ifdef ENABLE_FILTER_COLOR_GRADE
|
2022-08-27 11:17:47 +00:00
|
|
|
streamfx::filter::color_grade::color_grade_factory::initialize();
|
2020-03-16 19:37:31 +00:00
|
|
|
#endif
|
2021-05-01 16:31:13 +00:00
|
|
|
#ifdef ENABLE_FILTER_DENOISING
|
2022-08-27 11:17:47 +00:00
|
|
|
streamfx::filter::denoising::denoising_factory::initialize();
|
2021-05-01 16:31:13 +00:00
|
|
|
#endif
|
2020-03-16 19:37:31 +00:00
|
|
|
#ifdef ENABLE_FILTER_DISPLACEMENT
|
2022-08-27 11:17:47 +00:00
|
|
|
streamfx::filter::displacement::displacement_factory::initialize();
|
2020-03-16 19:37:31 +00:00
|
|
|
#endif
|
|
|
|
#ifdef ENABLE_FILTER_DYNAMIC_MASK
|
2022-08-27 11:17:47 +00:00
|
|
|
streamfx::filter::dynamic_mask::dynamic_mask_factory::initialize();
|
2020-03-16 19:37:31 +00:00
|
|
|
#endif
|
|
|
|
#ifdef ENABLE_FILTER_SDF_EFFECTS
|
2022-08-27 11:17:47 +00:00
|
|
|
streamfx::filter::sdf_effects::sdf_effects_factory::initialize();
|
2020-03-16 19:37:31 +00:00
|
|
|
#endif
|
|
|
|
#ifdef ENABLE_FILTER_SHADER
|
2022-08-27 11:17:47 +00:00
|
|
|
streamfx::filter::shader::shader_factory::initialize();
|
2020-03-16 19:37:31 +00:00
|
|
|
#endif
|
|
|
|
#ifdef ENABLE_FILTER_TRANSFORM
|
2022-08-27 11:17:47 +00:00
|
|
|
streamfx::filter::transform::transform_factory::initialize();
|
2021-06-02 21:37:18 +00:00
|
|
|
#endif
|
2021-09-27 22:16:21 +00:00
|
|
|
#ifdef ENABLE_FILTER_UPSCALING
|
2022-08-27 11:17:47 +00:00
|
|
|
streamfx::filter::upscaling::upscaling_factory::initialize();
|
2021-10-23 18:05:36 +00:00
|
|
|
#endif
|
|
|
|
#ifdef ENABLE_FILTER_VIRTUAL_GREENSCREEN
|
2022-08-27 11:17:47 +00:00
|
|
|
streamfx::filter::virtual_greenscreen::virtual_greenscreen_factory::initialize();
|
2020-03-16 19:37:31 +00:00
|
|
|
#endif
|
2022-08-27 11:17:47 +00:00
|
|
|
}
|
2019-09-05 16:42:28 +00:00
|
|
|
|
2022-08-27 11:17:47 +00:00
|
|
|
// Sources
|
|
|
|
{
|
2020-03-16 19:37:31 +00:00
|
|
|
#ifdef ENABLE_SOURCE_MIRROR
|
2022-08-27 11:17:47 +00:00
|
|
|
streamfx::source::mirror::mirror_factory::initialize();
|
2020-03-16 19:37:31 +00:00
|
|
|
#endif
|
|
|
|
#ifdef ENABLE_SOURCE_SHADER
|
2022-08-27 11:17:47 +00:00
|
|
|
streamfx::source::shader::shader_factory::initialize();
|
2020-03-16 19:37:31 +00:00
|
|
|
#endif
|
2022-08-27 11:17:47 +00:00
|
|
|
}
|
2019-09-05 16:42:28 +00:00
|
|
|
|
2022-08-27 11:17:47 +00:00
|
|
|
// Transitions
|
|
|
|
{
|
2020-03-16 19:37:31 +00:00
|
|
|
#ifdef ENABLE_TRANSITION_SHADER
|
2022-08-27 11:17:47 +00:00
|
|
|
streamfx::transition::shader::shader_factory::initialize();
|
2020-03-16 19:37:31 +00:00
|
|
|
#endif
|
2022-08-27 11:17:47 +00:00
|
|
|
}
|
2020-01-13 21:40:15 +00:00
|
|
|
|
2020-05-02 16:36:57 +00:00
|
|
|
// Frontend
|
2020-04-05 16:52:06 +00:00
|
|
|
#ifdef ENABLE_FRONTEND
|
2022-08-27 11:17:47 +00:00
|
|
|
streamfx::ui::handler::initialize();
|
2020-04-05 16:52:06 +00:00
|
|
|
#endif
|
|
|
|
|
2022-08-27 11:17:47 +00:00
|
|
|
DLOG_INFO("Loaded Version %s", STREAMFX_VERSION_STRING);
|
|
|
|
return true;
|
|
|
|
} catch (std::exception const& ex) {
|
|
|
|
DLOG_ERROR("Unexpected exception in function '%s': %s", __FUNCTION_NAME__, ex.what());
|
|
|
|
return false;
|
|
|
|
} catch (...) {
|
|
|
|
DLOG_ERROR("Unexpected exception in function '%s'.", __FUNCTION_NAME__);
|
|
|
|
return false;
|
|
|
|
}
|
2017-06-28 21:21:42 +00:00
|
|
|
}
|
|
|
|
|
2019-12-21 16:04:38 +00:00
|
|
|
MODULE_EXPORT void obs_module_unload(void)
|
2022-08-27 11:17:47 +00:00
|
|
|
{
|
|
|
|
try {
|
|
|
|
DLOG_INFO("Unloading Version %s", STREAMFX_VERSION_STRING);
|
2020-01-13 21:40:15 +00:00
|
|
|
|
2022-08-27 11:17:47 +00:00
|
|
|
// Frontend
|
2020-04-05 16:52:06 +00:00
|
|
|
#ifdef ENABLE_FRONTEND
|
2022-08-27 11:17:47 +00:00
|
|
|
streamfx::ui::handler::finalize();
|
2020-04-05 16:52:06 +00:00
|
|
|
#endif
|
|
|
|
|
2022-08-27 11:17:47 +00:00
|
|
|
// Transitions
|
|
|
|
{
|
2020-03-16 19:37:31 +00:00
|
|
|
#ifdef ENABLE_TRANSITION_SHADER
|
2022-08-27 11:17:47 +00:00
|
|
|
streamfx::transition::shader::shader_factory::finalize();
|
2020-03-16 19:37:31 +00:00
|
|
|
#endif
|
2022-08-27 11:17:47 +00:00
|
|
|
}
|
2019-09-05 16:42:28 +00:00
|
|
|
|
2022-08-27 11:17:47 +00:00
|
|
|
// Sources
|
|
|
|
{
|
2020-03-16 19:37:31 +00:00
|
|
|
#ifdef ENABLE_SOURCE_MIRROR
|
2022-08-27 11:17:47 +00:00
|
|
|
streamfx::source::mirror::mirror_factory::finalize();
|
2020-03-16 19:37:31 +00:00
|
|
|
#endif
|
|
|
|
#ifdef ENABLE_SOURCE_SHADER
|
2022-08-27 11:17:47 +00:00
|
|
|
streamfx::source::shader::shader_factory::finalize();
|
2020-03-16 19:37:31 +00:00
|
|
|
#endif
|
2022-08-27 11:17:47 +00:00
|
|
|
}
|
2019-09-05 16:42:28 +00:00
|
|
|
|
2022-08-27 11:17:47 +00:00
|
|
|
// Filters
|
|
|
|
{
|
2021-10-25 18:40:55 +00:00
|
|
|
#ifdef ENABLE_FILTER_AUTOFRAMING
|
2022-08-27 11:17:47 +00:00
|
|
|
streamfx::filter::autoframing::autoframing_factory::finalize();
|
2021-10-25 18:40:55 +00:00
|
|
|
#endif
|
2020-03-16 19:37:31 +00:00
|
|
|
#ifdef ENABLE_FILTER_BLUR
|
2022-08-27 11:17:47 +00:00
|
|
|
streamfx::filter::blur::blur_factory::finalize();
|
2020-03-16 19:37:31 +00:00
|
|
|
#endif
|
|
|
|
#ifdef ENABLE_FILTER_COLOR_GRADE
|
2022-08-27 11:17:47 +00:00
|
|
|
streamfx::filter::color_grade::color_grade_factory::finalize();
|
2020-03-16 19:37:31 +00:00
|
|
|
#endif
|
2021-05-01 16:31:13 +00:00
|
|
|
#ifdef ENABLE_FILTER_DENOISING
|
2022-08-27 11:17:47 +00:00
|
|
|
streamfx::filter::denoising::denoising_factory::finalize();
|
2021-05-01 16:31:13 +00:00
|
|
|
#endif
|
2020-03-16 19:37:31 +00:00
|
|
|
#ifdef ENABLE_FILTER_DISPLACEMENT
|
2022-08-27 11:17:47 +00:00
|
|
|
streamfx::filter::displacement::displacement_factory::finalize();
|
2020-03-16 19:37:31 +00:00
|
|
|
#endif
|
|
|
|
#ifdef ENABLE_FILTER_DYNAMIC_MASK
|
2022-08-27 11:17:47 +00:00
|
|
|
streamfx::filter::dynamic_mask::dynamic_mask_factory::finalize();
|
2020-03-16 19:37:31 +00:00
|
|
|
#endif
|
|
|
|
#ifdef ENABLE_FILTER_SDF_EFFECTS
|
2022-08-27 11:17:47 +00:00
|
|
|
streamfx::filter::sdf_effects::sdf_effects_factory::finalize();
|
2020-03-16 19:37:31 +00:00
|
|
|
#endif
|
|
|
|
#ifdef ENABLE_FILTER_SHADER
|
2022-08-27 11:17:47 +00:00
|
|
|
streamfx::filter::shader::shader_factory::finalize();
|
2020-03-16 19:37:31 +00:00
|
|
|
#endif
|
|
|
|
#ifdef ENABLE_FILTER_TRANSFORM
|
2022-08-27 11:17:47 +00:00
|
|
|
streamfx::filter::transform::transform_factory::finalize();
|
2021-06-02 21:37:18 +00:00
|
|
|
#endif
|
2021-09-27 22:16:21 +00:00
|
|
|
#ifdef ENABLE_FILTER_UPSCALING
|
2022-08-27 11:17:47 +00:00
|
|
|
streamfx::filter::upscaling::upscaling_factory::finalize();
|
2021-10-23 18:05:36 +00:00
|
|
|
#endif
|
|
|
|
#ifdef ENABLE_FILTER_VIRTUAL_GREENSCREEN
|
2022-08-27 11:17:47 +00:00
|
|
|
streamfx::filter::virtual_greenscreen::virtual_greenscreen_factory::finalize();
|
2020-03-16 19:37:31 +00:00
|
|
|
#endif
|
2022-08-27 11:17:47 +00:00
|
|
|
}
|
2019-09-05 16:42:28 +00:00
|
|
|
|
2022-08-27 11:17:47 +00:00
|
|
|
// Encoders
|
|
|
|
{
|
2020-03-16 19:37:31 +00:00
|
|
|
#ifdef ENABLE_ENCODER_FFMPEG
|
2022-08-27 11:17:47 +00:00
|
|
|
streamfx::encoder::ffmpeg::ffmpeg_manager::finalize();
|
2021-08-28 12:36:42 +00:00
|
|
|
#endif
|
|
|
|
#ifdef ENABLE_ENCODER_AOM_AV1
|
2022-08-27 11:17:47 +00:00
|
|
|
streamfx::encoder::aom::av1::aom_av1_factory::finalize();
|
2020-03-16 19:37:31 +00:00
|
|
|
#endif
|
2022-08-27 11:17:47 +00:00
|
|
|
}
|
2020-01-13 21:40:15 +00:00
|
|
|
|
2022-08-27 11:17:47 +00:00
|
|
|
// Finalize GLAD (OpenGL)
|
|
|
|
{
|
|
|
|
streamfx::obs::gs::context gctx{};
|
|
|
|
_streamfx_gfx_opengl.reset();
|
|
|
|
}
|
2021-11-09 10:33:07 +00:00
|
|
|
|
2022-08-27 11:17:47 +00:00
|
|
|
// Finalize Source Tracker
|
|
|
|
_source_tracker.reset();
|
2020-03-03 00:49:26 +00:00
|
|
|
|
2022-08-27 11:17:47 +00:00
|
|
|
// // Auto-Updater
|
|
|
|
//#ifdef ENABLE_UPDATER
|
|
|
|
// _updater.reset();
|
|
|
|
//#endif
|
2020-09-09 03:06:15 +00:00
|
|
|
|
2022-08-27 11:17:47 +00:00
|
|
|
// Finalize Configuration
|
|
|
|
streamfx::configuration::finalize();
|
2020-04-22 20:58:33 +00:00
|
|
|
|
2022-09-18 17:51:59 +00:00
|
|
|
// Finalize Thread Pool
|
|
|
|
_threadpool.reset();
|
|
|
|
|
2022-08-27 11:17:47 +00:00
|
|
|
DLOG_INFO("Unloaded Version %s", STREAMFX_VERSION_STRING);
|
|
|
|
} catch (std::exception const& ex) {
|
|
|
|
DLOG_ERROR("Unexpected exception in function '%s': %s", __FUNCTION_NAME__, ex.what());
|
|
|
|
} catch (...) {
|
|
|
|
DLOG_ERROR("Unexpected exception in function '%s'.", __FUNCTION_NAME__);
|
|
|
|
}
|
2017-06-28 21:21:42 +00:00
|
|
|
}
|
|
|
|
|
2022-09-18 16:30:15 +00:00
|
|
|
std::shared_ptr<streamfx::util::threadpool::threadpool> streamfx::threadpool()
|
2020-03-03 00:49:26 +00:00
|
|
|
{
|
2020-04-05 16:52:06 +00:00
|
|
|
return _threadpool;
|
2020-03-03 00:49:26 +00:00
|
|
|
}
|
2020-05-02 16:36:57 +00:00
|
|
|
|
2020-11-28 14:38:56 +00:00
|
|
|
std::filesystem::path streamfx::data_file_path(std::string_view file)
|
|
|
|
{
|
|
|
|
const char* root_path = obs_get_module_data_path(obs_current_module());
|
|
|
|
if (root_path) {
|
|
|
|
auto ret = std::filesystem::u8path(root_path);
|
|
|
|
ret.append(file.data());
|
|
|
|
return ret;
|
|
|
|
} else {
|
|
|
|
throw std::runtime_error("obs_get_module_data_path returned nullptr");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
std::filesystem::path streamfx::config_file_path(std::string_view file)
|
|
|
|
{
|
|
|
|
char* root_path = obs_module_get_config_path(obs_current_module(), file.data());
|
|
|
|
if (root_path) {
|
|
|
|
auto ret = std::filesystem::u8path(root_path);
|
|
|
|
bfree(root_path);
|
|
|
|
return ret;
|
|
|
|
} else {
|
|
|
|
throw std::runtime_error("obs_module_get_config_path returned nullptr");
|
|
|
|
}
|
|
|
|
}
|
2021-04-16 23:42:54 +00:00
|
|
|
|
|
|
|
#ifdef ENABLE_FRONTEND
|
|
|
|
bool streamfx::open_url(std::string_view url)
|
|
|
|
{
|
|
|
|
QUrl qurl = QString::fromUtf8(url.data());
|
|
|
|
return QDesktopServices::openUrl(qurl);
|
|
|
|
}
|
|
|
|
#endif
|