2017-06-28 21:21:42 +00:00
|
|
|
/*
|
|
|
|
* Modern effects for a modern Streamer
|
|
|
|
* Copyright (C) 2017 Michael Fabian Dirks
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2019-01-14 10:23:21 +00:00
|
|
|
#include "plugin.hpp"
|
2020-04-05 16:52:06 +00:00
|
|
|
#include <fstream>
|
2019-09-04 00:59:04 +00:00
|
|
|
#include <stdexcept>
|
2020-04-22 20:58:33 +00:00
|
|
|
#include "configuration.hpp"
|
2020-01-13 21:40:15 +00:00
|
|
|
#include "obs/obs-source-tracker.hpp"
|
|
|
|
|
2020-03-27 19:06:27 +00:00
|
|
|
#ifdef ENABLE_ENCODER_FFMPEG
|
2020-01-14 00:55:31 +00:00
|
|
|
#include "encoders/ffmpeg-encoder.hpp"
|
2020-03-27 19:06:27 +00:00
|
|
|
#endif
|
2020-01-13 21:40:15 +00:00
|
|
|
|
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
|
|
|
|
#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
|
2020-03-25 17:31:22 +00:00
|
|
|
#ifdef ENABLE_FILTER_NVIDIA_FACE_TRACKING
|
|
|
|
#include "filters/filter-nv-face-tracking.hpp"
|
|
|
|
#endif
|
2020-03-16 19:37:31 +00:00
|
|
|
#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
|
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-04-05 16:52:06 +00:00
|
|
|
static std::shared_ptr<util::threadpool> _threadpool;
|
2020-03-03 00:49:26 +00:00
|
|
|
|
2019-12-21 16:04:38 +00:00
|
|
|
MODULE_EXPORT bool obs_module_load(void)
|
|
|
|
try {
|
2020-01-13 21:40:15 +00:00
|
|
|
LOG_INFO("Loading Version %s", STREAMFX_VERSION_STRING);
|
2019-09-05 16:42:28 +00:00
|
|
|
|
2020-04-05 16:52:06 +00:00
|
|
|
// Initialize global configuration.
|
2020-04-22 20:58:33 +00:00
|
|
|
streamfx::configuration::initialize();
|
|
|
|
|
2020-04-05 16:52:06 +00:00
|
|
|
// Initialize global Thread Pool.
|
|
|
|
_threadpool = std::make_shared<util::threadpool>();
|
|
|
|
|
2019-09-05 16:42:28 +00:00
|
|
|
// Initialize Source Tracker
|
2019-01-27 21:43:49 +00:00
|
|
|
obs::source_tracker::initialize();
|
2019-09-05 16:42:28 +00:00
|
|
|
|
2020-04-05 16:52:06 +00:00
|
|
|
// Encoders
|
|
|
|
{
|
2020-03-16 19:37:31 +00:00
|
|
|
#ifdef ENABLE_ENCODER_FFMPEG
|
2020-04-05 16:52:06 +00:00
|
|
|
using namespace streamfx::encoder::ffmpeg;
|
|
|
|
ffmpeg_manager::initialize();
|
2020-03-16 19:37:31 +00:00
|
|
|
#endif
|
2020-04-05 16:52:06 +00:00
|
|
|
}
|
2020-01-13 21:40:15 +00:00
|
|
|
|
2020-04-05 16:52:06 +00:00
|
|
|
// Filters
|
|
|
|
{
|
|
|
|
using namespace streamfx::filter;
|
2020-03-16 19:37:31 +00:00
|
|
|
#ifdef ENABLE_FILTER_BLUR
|
2020-04-05 16:52:06 +00:00
|
|
|
blur::blur_factory::initialize();
|
2020-03-16 19:37:31 +00:00
|
|
|
#endif
|
|
|
|
#ifdef ENABLE_FILTER_COLOR_GRADE
|
2020-04-05 16:52:06 +00:00
|
|
|
color_grade::color_grade_factory::initialize();
|
2020-03-16 19:37:31 +00:00
|
|
|
#endif
|
|
|
|
#ifdef ENABLE_FILTER_DISPLACEMENT
|
2020-04-05 16:52:06 +00:00
|
|
|
displacement::displacement_factory::initialize();
|
2020-03-16 19:37:31 +00:00
|
|
|
#endif
|
|
|
|
#ifdef ENABLE_FILTER_DYNAMIC_MASK
|
2020-04-05 16:52:06 +00:00
|
|
|
dynamic_mask::dynamic_mask_factory::initialize();
|
2020-03-16 19:37:31 +00:00
|
|
|
#endif
|
2020-03-25 17:31:22 +00:00
|
|
|
#ifdef ENABLE_FILTER_NVIDIA_FACE_TRACKING
|
2020-04-05 16:52:06 +00:00
|
|
|
streamfx::filter::nvidia::face_tracking_factory::initialize();
|
2020-03-25 17:31:22 +00:00
|
|
|
#endif
|
2020-03-16 19:37:31 +00:00
|
|
|
#ifdef ENABLE_FILTER_SDF_EFFECTS
|
2020-04-05 16:52:06 +00:00
|
|
|
sdf_effects::sdf_effects_factory::initialize();
|
2020-03-16 19:37:31 +00:00
|
|
|
#endif
|
|
|
|
#ifdef ENABLE_FILTER_SHADER
|
2020-04-05 16:52:06 +00:00
|
|
|
shader::shader_factory::initialize();
|
2020-03-16 19:37:31 +00:00
|
|
|
#endif
|
|
|
|
#ifdef ENABLE_FILTER_TRANSFORM
|
2020-04-05 16:52:06 +00:00
|
|
|
transform::transform_factory::initialize();
|
2020-03-16 19:37:31 +00:00
|
|
|
#endif
|
2020-04-05 16:52:06 +00:00
|
|
|
}
|
2019-09-05 16:42:28 +00:00
|
|
|
|
2020-04-05 16:52:06 +00:00
|
|
|
// Sources
|
|
|
|
{
|
|
|
|
using namespace streamfx::source;
|
2020-03-16 19:37:31 +00:00
|
|
|
#ifdef ENABLE_SOURCE_MIRROR
|
2020-04-05 16:52:06 +00:00
|
|
|
mirror::mirror_factory::initialize();
|
2020-03-16 19:37:31 +00:00
|
|
|
#endif
|
|
|
|
#ifdef ENABLE_SOURCE_SHADER
|
2020-04-05 16:52:06 +00:00
|
|
|
shader::shader_factory::initialize();
|
2020-03-16 19:37:31 +00:00
|
|
|
#endif
|
2020-04-05 16:52:06 +00:00
|
|
|
}
|
2019-09-05 16:42:28 +00:00
|
|
|
|
2020-04-05 16:52:06 +00:00
|
|
|
// Transitions
|
|
|
|
{
|
|
|
|
using namespace streamfx::transition;
|
2020-03-16 19:37:31 +00:00
|
|
|
#ifdef ENABLE_TRANSITION_SHADER
|
2020-04-05 16:52:06 +00:00
|
|
|
shader::shader_factory::initialize();
|
2020-03-16 19:37:31 +00:00
|
|
|
#endif
|
2020-04-05 16:52:06 +00:00
|
|
|
}
|
2020-01-13 21:40:15 +00:00
|
|
|
|
2020-04-05 16:52:06 +00:00
|
|
|
// Frontend
|
|
|
|
#ifdef ENABLE_FRONTEND
|
|
|
|
streamfx::ui::handler::initialize();
|
|
|
|
#endif
|
|
|
|
|
2020-04-05 16:52:06 +00:00
|
|
|
LOG_INFO("Loaded Version %s", STREAMFX_VERSION_STRING);
|
2017-06-28 21:21:42 +00:00
|
|
|
return true;
|
2019-09-05 16:42:28 +00:00
|
|
|
} catch (...) {
|
2020-01-13 21:40:15 +00:00
|
|
|
LOG_ERROR("Unexpected exception in function '%s'.", __FUNCTION_NAME__);
|
2019-09-05 16:42:28 +00:00
|
|
|
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)
|
|
|
|
try {
|
2020-01-13 21:40:15 +00:00
|
|
|
LOG_INFO("Unloading Version %s", STREAMFX_VERSION_STRING);
|
|
|
|
|
2020-04-05 16:52:06 +00:00
|
|
|
// Frontend
|
|
|
|
#ifdef ENABLE_FRONTEND
|
|
|
|
streamfx::ui::handler::finalize();
|
|
|
|
#endif
|
|
|
|
|
2020-01-13 21:40:15 +00:00
|
|
|
// Transitions
|
2020-04-05 16:52:06 +00:00
|
|
|
{
|
|
|
|
using namespace streamfx::transition;
|
2020-03-16 19:37:31 +00:00
|
|
|
#ifdef ENABLE_TRANSITION_SHADER
|
2020-04-05 16:52:06 +00:00
|
|
|
shader::shader_factory::finalize();
|
2020-03-16 19:37:31 +00:00
|
|
|
#endif
|
2020-04-05 16:52:06 +00:00
|
|
|
}
|
2019-09-05 16:42:28 +00:00
|
|
|
|
2020-04-05 16:52:06 +00:00
|
|
|
// Sources
|
|
|
|
{
|
|
|
|
using namespace streamfx::source;
|
2020-03-16 19:37:31 +00:00
|
|
|
#ifdef ENABLE_SOURCE_MIRROR
|
2020-04-05 16:52:06 +00:00
|
|
|
mirror::mirror_factory::finalize();
|
2020-03-16 19:37:31 +00:00
|
|
|
#endif
|
|
|
|
#ifdef ENABLE_SOURCE_SHADER
|
2020-04-05 16:52:06 +00:00
|
|
|
shader::shader_factory::finalize();
|
2020-03-16 19:37:31 +00:00
|
|
|
#endif
|
2020-04-05 16:52:06 +00:00
|
|
|
}
|
2019-09-05 16:42:28 +00:00
|
|
|
|
2020-04-05 16:52:06 +00:00
|
|
|
// Filters
|
|
|
|
{
|
|
|
|
using namespace streamfx::filter;
|
2020-03-16 19:37:31 +00:00
|
|
|
#ifdef ENABLE_FILTER_BLUR
|
2020-04-05 16:52:06 +00:00
|
|
|
blur::blur_factory::finalize();
|
2020-03-16 19:37:31 +00:00
|
|
|
#endif
|
|
|
|
#ifdef ENABLE_FILTER_COLOR_GRADE
|
2020-04-05 16:52:06 +00:00
|
|
|
color_grade::color_grade_factory::finalize();
|
2020-03-16 19:37:31 +00:00
|
|
|
#endif
|
|
|
|
#ifdef ENABLE_FILTER_DISPLACEMENT
|
2020-04-05 16:52:06 +00:00
|
|
|
displacement::displacement_factory::finalize();
|
2020-03-16 19:37:31 +00:00
|
|
|
#endif
|
|
|
|
#ifdef ENABLE_FILTER_DYNAMIC_MASK
|
2020-04-05 16:52:06 +00:00
|
|
|
dynamic_mask::dynamic_mask_factory::finalize();
|
2020-03-16 19:37:31 +00:00
|
|
|
#endif
|
2020-03-25 17:31:22 +00:00
|
|
|
#ifdef ENABLE_FILTER_NVIDIA_FACE_TRACKING
|
2020-04-05 16:52:06 +00:00
|
|
|
streamfx::filter::nvidia::face_tracking_factory::finalize();
|
2020-03-25 17:31:22 +00:00
|
|
|
#endif
|
2020-03-16 19:37:31 +00:00
|
|
|
#ifdef ENABLE_FILTER_SDF_EFFECTS
|
2020-04-05 16:52:06 +00:00
|
|
|
sdf_effects::sdf_effects_factory::finalize();
|
2020-03-16 19:37:31 +00:00
|
|
|
#endif
|
|
|
|
#ifdef ENABLE_FILTER_SHADER
|
2020-04-05 16:52:06 +00:00
|
|
|
shader::shader_factory::finalize();
|
2020-03-16 19:37:31 +00:00
|
|
|
#endif
|
|
|
|
#ifdef ENABLE_FILTER_TRANSFORM
|
2020-04-05 16:52:06 +00:00
|
|
|
transform::transform_factory::finalize();
|
2020-03-16 19:37:31 +00:00
|
|
|
#endif
|
2020-04-05 16:52:06 +00:00
|
|
|
}
|
2019-09-05 16:42:28 +00:00
|
|
|
|
2020-04-05 16:52:06 +00:00
|
|
|
// Encoders
|
|
|
|
{
|
2020-03-16 19:37:31 +00:00
|
|
|
#ifdef ENABLE_ENCODER_FFMPEG
|
2020-04-05 16:52:06 +00:00
|
|
|
using namespace streamfx::encoder::ffmpeg;
|
|
|
|
ffmpeg_manager::finalize();
|
2020-03-16 19:37:31 +00:00
|
|
|
#endif
|
2020-04-05 16:52:06 +00:00
|
|
|
}
|
2020-01-13 21:40:15 +00:00
|
|
|
|
|
|
|
// Finalize Source Tracker
|
2019-01-27 21:43:49 +00:00
|
|
|
obs::source_tracker::finalize();
|
2020-03-03 00:49:26 +00:00
|
|
|
|
2020-04-05 16:52:06 +00:00
|
|
|
// Finalize Thread Pool
|
|
|
|
_threadpool.reset();
|
|
|
|
|
2020-04-22 20:58:33 +00:00
|
|
|
// Finalize Configuration
|
|
|
|
streamfx::configuration::finalize();
|
|
|
|
|
2020-04-05 16:52:06 +00:00
|
|
|
LOG_INFO("Unloaded Version %s", STREAMFX_VERSION_STRING);
|
2019-09-05 16:42:28 +00:00
|
|
|
} catch (...) {
|
2020-01-13 21:40:15 +00:00
|
|
|
LOG_ERROR("Unexpected exception in function '%s'.", __FUNCTION_NAME__);
|
2017-06-28 21:21:42 +00:00
|
|
|
}
|
|
|
|
|
2020-04-05 16:52:06 +00:00
|
|
|
std::shared_ptr<util::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
|
|
|
}
|