2017-12-14 07:06:09 +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 "source-mirror.hpp"
|
2018-04-27 21:38:49 +00:00
|
|
|
#include <bitset>
|
2018-11-07 14:24:25 +00:00
|
|
|
#include <cstring>
|
2018-04-27 21:38:49 +00:00
|
|
|
#include <functional>
|
2018-11-07 14:24:25 +00:00
|
|
|
#include <memory>
|
|
|
|
#include <vector>
|
2018-11-07 13:38:31 +00:00
|
|
|
#include "obs-tools.hpp"
|
2019-01-14 10:23:21 +00:00
|
|
|
#include "strings.hpp"
|
2017-12-14 07:06:09 +00:00
|
|
|
|
2019-01-14 10:23:21 +00:00
|
|
|
// OBS
|
|
|
|
#ifdef _MSC_VER
|
|
|
|
#pragma warning(push)
|
|
|
|
#pragma warning(disable : 4201)
|
|
|
|
#endif
|
2018-11-08 07:08:38 +00:00
|
|
|
#include <media-io/audio-io.h>
|
|
|
|
#include <obs-config.h>
|
2019-01-14 10:23:21 +00:00
|
|
|
#ifdef _MSC_VER
|
|
|
|
#pragma warning(pop)
|
|
|
|
#endif
|
2018-11-08 07:08:38 +00:00
|
|
|
|
2018-11-07 14:24:25 +00:00
|
|
|
#define S_SOURCE_MIRROR "Source.Mirror"
|
|
|
|
#define P_SOURCE "Source.Mirror.Source"
|
|
|
|
#define P_SOURCE_SIZE "Source.Mirror.Source.Size"
|
|
|
|
#define P_SOURCE_AUDIO "Source.Mirror.Source.Audio"
|
|
|
|
#define P_SCALING "Source.Mirror.Scaling"
|
|
|
|
#define P_SCALING_METHOD "Source.Mirror.Scaling.Method"
|
|
|
|
#define P_SCALING_METHOD_POINT "Source.Mirror.Scaling.Method.Point"
|
|
|
|
#define P_SCALING_METHOD_BILINEAR "Source.Mirror.Scaling.Method.Bilinear"
|
|
|
|
#define P_SCALING_METHOD_BICUBIC "Source.Mirror.Scaling.Method.Bicubic"
|
|
|
|
#define P_SCALING_METHOD_LANCZOS "Source.Mirror.Scaling.Method.Lanczos"
|
|
|
|
#define P_SCALING_SIZE "Source.Mirror.Scaling.Size"
|
|
|
|
#define P_SCALING_TRANSFORMKEEPORIGINAL "Source.Mirror.Scaling.TransformKeepOriginal"
|
2019-01-24 03:27:04 +00:00
|
|
|
#define P_SCALING_BOUNDS "Source.Mirror.Scaling.Bounds"
|
|
|
|
#define P_SCALING_BOUNDS_STRETCH "Source.Mirror.Scaling.Bounds.Stretch"
|
|
|
|
#define P_SCALING_BOUNDS_FIT "Source.Mirror.Scaling.Bounds.Fit"
|
|
|
|
#define P_SCALING_BOUNDS_FILL "Source.Mirror.Scaling.Bounds.Fill"
|
|
|
|
#define P_SCALING_BOUNDS_FILLWIDTH "Source.Mirror.Scaling.Bounds.FillWidth"
|
|
|
|
#define P_SCALING_BOUNDS_FILLHEIGHT "Source.Mirror.Scaling.Bounds.FillHeight"
|
2017-12-14 07:06:09 +00:00
|
|
|
|
2018-01-16 10:47:24 +00:00
|
|
|
// Initializer & Finalizer
|
2018-11-07 14:24:25 +00:00
|
|
|
INITIALIZER(SourceMirrorInit)
|
|
|
|
{
|
2019-01-27 22:33:12 +00:00
|
|
|
initializerFunctions.push_back([] { source::mirror::mirror_factory::initialize(); });
|
|
|
|
finalizerFunctions.push_back([] { source::mirror::mirror_factory::finalize(); });
|
2017-12-14 07:06:09 +00:00
|
|
|
}
|
|
|
|
|
2019-01-27 22:33:12 +00:00
|
|
|
static std::shared_ptr<source::mirror::mirror_factory> factory_instance = nullptr;
|
2019-01-25 16:54:18 +00:00
|
|
|
|
2019-01-27 22:33:12 +00:00
|
|
|
void source::mirror::mirror_factory::initialize()
|
2019-01-25 16:54:18 +00:00
|
|
|
{
|
2019-01-27 22:33:12 +00:00
|
|
|
factory_instance = std::make_shared<source::mirror::mirror_factory>();
|
2019-01-25 16:54:18 +00:00
|
|
|
}
|
|
|
|
|
2019-01-27 22:33:12 +00:00
|
|
|
void source::mirror::mirror_factory::finalize()
|
2019-01-25 16:54:18 +00:00
|
|
|
{
|
|
|
|
factory_instance.reset();
|
|
|
|
}
|
|
|
|
|
2019-01-27 22:33:12 +00:00
|
|
|
std::shared_ptr<source::mirror::mirror_factory> source::mirror::mirror_factory::get()
|
2019-01-25 16:54:18 +00:00
|
|
|
{
|
|
|
|
return factory_instance;
|
|
|
|
}
|
|
|
|
|
2019-01-27 22:33:12 +00:00
|
|
|
source::mirror::mirror_factory::mirror_factory()
|
2018-11-07 14:24:25 +00:00
|
|
|
{
|
2017-12-14 07:06:09 +00:00
|
|
|
memset(&osi, 0, sizeof(obs_source_info));
|
2018-11-07 14:24:25 +00:00
|
|
|
osi.id = "obs-stream-effects-source-mirror";
|
|
|
|
osi.type = OBS_SOURCE_TYPE_INPUT;
|
2018-04-27 21:38:49 +00:00
|
|
|
osi.output_flags = OBS_SOURCE_VIDEO | OBS_SOURCE_AUDIO | OBS_SOURCE_CUSTOM_DRAW;
|
2017-12-14 07:06:09 +00:00
|
|
|
|
2018-11-07 14:24:25 +00:00
|
|
|
osi.get_name = get_name;
|
|
|
|
osi.get_defaults = get_defaults;
|
|
|
|
osi.get_properties = get_properties;
|
|
|
|
osi.get_width = get_width;
|
|
|
|
osi.get_height = get_height;
|
|
|
|
osi.create = create;
|
|
|
|
osi.destroy = destroy;
|
|
|
|
osi.update = update;
|
|
|
|
osi.activate = activate;
|
|
|
|
osi.deactivate = deactivate;
|
|
|
|
osi.video_tick = video_tick;
|
|
|
|
osi.video_render = video_render;
|
2018-04-24 11:48:42 +00:00
|
|
|
osi.enum_active_sources = enum_active_sources;
|
2018-11-08 07:08:38 +00:00
|
|
|
osi.load = load;
|
|
|
|
osi.save = save;
|
2017-12-14 07:06:09 +00:00
|
|
|
|
|
|
|
obs_register_source(&osi);
|
|
|
|
}
|
|
|
|
|
2019-01-27 22:33:12 +00:00
|
|
|
source::mirror::mirror_factory::~mirror_factory() {}
|
2017-12-14 07:06:09 +00:00
|
|
|
|
2019-01-27 22:33:12 +00:00
|
|
|
const char* source::mirror::mirror_factory::get_name(void*)
|
2018-11-07 14:24:25 +00:00
|
|
|
{
|
2017-12-14 07:06:09 +00:00
|
|
|
return P_TRANSLATE(S_SOURCE_MIRROR);
|
|
|
|
}
|
|
|
|
|
2019-01-27 22:33:12 +00:00
|
|
|
void source::mirror::mirror_factory::get_defaults(obs_data_t* data)
|
2018-11-07 14:24:25 +00:00
|
|
|
{
|
2017-12-14 07:06:09 +00:00
|
|
|
obs_data_set_default_string(data, P_SOURCE, "");
|
2018-04-27 21:38:49 +00:00
|
|
|
obs_data_set_default_bool(data, P_SOURCE_AUDIO, false);
|
2017-12-14 07:06:09 +00:00
|
|
|
obs_data_set_default_bool(data, P_SCALING, false);
|
|
|
|
obs_data_set_default_string(data, P_SCALING_SIZE, "100x100");
|
2019-01-24 03:27:04 +00:00
|
|
|
obs_data_set_default_int(data, P_SCALING_METHOD, (int64_t)obs_scale_type::OBS_SCALE_BILINEAR);
|
|
|
|
obs_data_set_default_bool(data, P_SCALING_TRANSFORMKEEPORIGINAL, false);
|
|
|
|
obs_data_set_default_int(data, P_SCALING_BOUNDS, (int64_t)obs_bounds_type::OBS_BOUNDS_STRETCH);
|
2017-12-14 07:06:09 +00:00
|
|
|
}
|
|
|
|
|
2019-01-27 22:33:12 +00:00
|
|
|
bool source::mirror::mirror_factory::modified_properties(obs_properties_t* pr, obs_property_t* p, obs_data_t* data)
|
2018-11-07 14:24:25 +00:00
|
|
|
{
|
2017-12-14 07:06:09 +00:00
|
|
|
if (obs_properties_get(pr, P_SOURCE) == p) {
|
|
|
|
obs_source_t* target = obs_get_source_by_name(obs_data_get_string(data, P_SOURCE));
|
|
|
|
if (target) {
|
|
|
|
std::vector<char> buf(256);
|
2019-01-14 22:52:12 +00:00
|
|
|
snprintf(buf.data(), buf.size(), "%" PRIu32 "x%" PRIu32, obs_source_get_width(target),
|
|
|
|
obs_source_get_height(target));
|
2017-12-14 07:06:09 +00:00
|
|
|
obs_data_set_string(data, P_SOURCE_SIZE, buf.data());
|
|
|
|
} else {
|
|
|
|
obs_data_set_string(data, P_SOURCE_SIZE, "0x0");
|
|
|
|
}
|
2019-01-23 22:23:49 +00:00
|
|
|
obs_source_release(target);
|
2017-12-14 07:06:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (obs_properties_get(pr, P_SCALING) == p) {
|
|
|
|
bool show = obs_data_get_bool(data, P_SCALING);
|
|
|
|
obs_property_set_visible(obs_properties_get(pr, P_SCALING_METHOD), show);
|
|
|
|
obs_property_set_visible(obs_properties_get(pr, P_SCALING_SIZE), show);
|
2019-01-24 03:27:04 +00:00
|
|
|
obs_property_set_visible(obs_properties_get(pr, P_SCALING_BOUNDS), show);
|
2017-12-14 07:06:09 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-11-07 14:24:25 +00:00
|
|
|
static bool UpdateSourceListCB(void* ptr, obs_source_t* src)
|
|
|
|
{
|
2017-12-14 07:06:09 +00:00
|
|
|
obs_property_t* p = (obs_property_t*)ptr;
|
|
|
|
obs_property_list_add_string(p, obs_source_get_name(src), obs_source_get_name(src));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2018-11-07 14:24:25 +00:00
|
|
|
static void UpdateSourceList(obs_property_t* p)
|
|
|
|
{
|
2017-12-14 07:06:09 +00:00
|
|
|
obs_property_list_clear(p);
|
2019-01-23 21:04:25 +00:00
|
|
|
obs_property_list_add_string(p, "", "");
|
2017-12-14 07:06:09 +00:00
|
|
|
obs_enum_sources(UpdateSourceListCB, p);
|
2018-11-08 07:08:38 +00:00
|
|
|
#if LIBOBS_API_MAJOR_VER >= 23
|
2018-11-07 13:38:31 +00:00
|
|
|
obs_enum_scenes(UpdateSourceListCB, p);
|
2018-11-08 07:08:38 +00:00
|
|
|
#endif
|
2017-12-14 07:06:09 +00:00
|
|
|
}
|
|
|
|
|
2019-01-27 22:33:12 +00:00
|
|
|
obs_properties_t* source::mirror::mirror_factory::get_properties(void*)
|
2018-11-07 14:24:25 +00:00
|
|
|
{
|
2017-12-14 07:06:09 +00:00
|
|
|
obs_properties_t* pr = obs_properties_create();
|
2018-11-07 14:24:25 +00:00
|
|
|
obs_property_t* p = nullptr;
|
2017-12-14 07:06:09 +00:00
|
|
|
|
2018-11-07 14:24:25 +00:00
|
|
|
p = obs_properties_add_list(pr, P_SOURCE, P_TRANSLATE(P_SOURCE), OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_STRING);
|
2017-12-14 07:06:09 +00:00
|
|
|
obs_property_set_long_description(p, P_TRANSLATE(P_DESC(P_SOURCE)));
|
|
|
|
obs_property_set_modified_callback(p, modified_properties);
|
|
|
|
UpdateSourceList(p);
|
|
|
|
|
|
|
|
p = obs_properties_add_text(pr, P_SOURCE_SIZE, P_TRANSLATE(P_SOURCE_SIZE), OBS_TEXT_DEFAULT);
|
|
|
|
obs_property_set_long_description(p, P_TRANSLATE(P_DESC(P_SOURCE_SIZE)));
|
|
|
|
obs_property_set_enabled(p, false);
|
|
|
|
|
2018-04-27 21:38:49 +00:00
|
|
|
p = obs_properties_add_bool(pr, P_SOURCE_AUDIO, P_TRANSLATE(P_SOURCE_AUDIO));
|
|
|
|
obs_property_set_long_description(p, P_TRANSLATE(P_DESC(P_SOURCE_AUDIO)));
|
|
|
|
|
2017-12-14 07:06:09 +00:00
|
|
|
p = obs_properties_add_bool(pr, P_SCALING, P_TRANSLATE(P_SCALING));
|
|
|
|
obs_property_set_long_description(p, P_TRANSLATE(P_DESC(P_SCALING)));
|
|
|
|
obs_property_set_modified_callback(p, modified_properties);
|
|
|
|
|
2018-11-07 14:24:25 +00:00
|
|
|
p = obs_properties_add_list(pr, P_SCALING_METHOD, P_TRANSLATE(P_SCALING_METHOD), OBS_COMBO_TYPE_LIST,
|
|
|
|
OBS_COMBO_FORMAT_INT);
|
2017-12-14 07:06:09 +00:00
|
|
|
obs_property_set_long_description(p, P_TRANSLATE(P_DESC(P_SCALING_METHOD)));
|
2019-01-24 03:27:04 +00:00
|
|
|
obs_property_list_add_int(p, P_TRANSLATE(P_SCALING_METHOD_POINT), (int64_t)obs_scale_type::OBS_SCALE_POINT);
|
|
|
|
obs_property_list_add_int(p, P_TRANSLATE(P_SCALING_METHOD_BILINEAR), (int64_t)obs_scale_type::OBS_SCALE_BILINEAR);
|
|
|
|
obs_property_list_add_int(p, P_TRANSLATE(P_SCALING_METHOD_BICUBIC), (int64_t)obs_scale_type::OBS_SCALE_BICUBIC);
|
|
|
|
obs_property_list_add_int(p, P_TRANSLATE(P_SCALING_METHOD_LANCZOS), (int64_t)obs_scale_type::OBS_SCALE_LANCZOS);
|
2017-12-14 07:06:09 +00:00
|
|
|
|
2018-11-07 14:24:25 +00:00
|
|
|
p = obs_properties_add_text(pr, P_SCALING_SIZE, P_TRANSLATE(P_SCALING_SIZE), OBS_TEXT_DEFAULT);
|
2017-12-14 07:06:09 +00:00
|
|
|
obs_property_set_long_description(p, P_TRANSLATE(P_DESC(P_SCALING_SIZE)));
|
|
|
|
|
2018-01-19 03:13:32 +00:00
|
|
|
p = obs_properties_add_bool(pr, P_SCALING_TRANSFORMKEEPORIGINAL, P_TRANSLATE(P_SCALING_TRANSFORMKEEPORIGINAL));
|
|
|
|
obs_property_set_long_description(p, P_TRANSLATE(P_DESC(P_SCALING_TRANSFORMKEEPORIGINAL)));
|
|
|
|
|
2019-01-24 03:27:04 +00:00
|
|
|
p = obs_properties_add_list(pr, P_SCALING_BOUNDS, P_TRANSLATE(P_SCALING_BOUNDS), OBS_COMBO_TYPE_LIST,
|
|
|
|
OBS_COMBO_FORMAT_INT);
|
|
|
|
obs_property_set_long_description(p, P_TRANSLATE(P_DESC(P_SCALING_BOUNDS)));
|
|
|
|
obs_property_list_add_int(p, P_TRANSLATE(P_SCALING_BOUNDS_STRETCH), (int64_t)obs_bounds_type::OBS_BOUNDS_STRETCH);
|
|
|
|
obs_property_list_add_int(p, P_TRANSLATE(P_SCALING_BOUNDS_FIT), (int64_t)obs_bounds_type::OBS_BOUNDS_SCALE_INNER);
|
|
|
|
obs_property_list_add_int(p, P_TRANSLATE(P_SCALING_BOUNDS_FILL), (int64_t)obs_bounds_type::OBS_BOUNDS_SCALE_OUTER);
|
|
|
|
obs_property_list_add_int(p, P_TRANSLATE(P_SCALING_BOUNDS_FILLWIDTH),
|
|
|
|
(int64_t)obs_bounds_type::OBS_BOUNDS_SCALE_TO_WIDTH);
|
|
|
|
obs_property_list_add_int(p, P_TRANSLATE(P_SCALING_BOUNDS_FILLHEIGHT),
|
|
|
|
(int64_t)obs_bounds_type::OBS_BOUNDS_SCALE_TO_HEIGHT);
|
|
|
|
|
2017-12-14 07:06:09 +00:00
|
|
|
return pr;
|
|
|
|
}
|
|
|
|
|
2019-01-27 22:33:12 +00:00
|
|
|
void* source::mirror::mirror_factory::create(obs_data_t* data, obs_source_t* source)
|
2018-11-07 14:24:25 +00:00
|
|
|
{
|
2019-01-27 22:33:12 +00:00
|
|
|
return new source::mirror::mirror_instance(data, source);
|
2017-12-14 07:06:09 +00:00
|
|
|
}
|
|
|
|
|
2019-01-27 22:33:12 +00:00
|
|
|
void source::mirror::mirror_factory::destroy(void* p)
|
2018-11-07 14:24:25 +00:00
|
|
|
{
|
2018-04-27 21:38:49 +00:00
|
|
|
if (p) {
|
2019-01-27 22:33:12 +00:00
|
|
|
delete static_cast<source::mirror::mirror_instance*>(p);
|
2018-04-27 21:38:49 +00:00
|
|
|
}
|
2017-12-14 07:06:09 +00:00
|
|
|
}
|
|
|
|
|
2019-01-27 22:33:12 +00:00
|
|
|
uint32_t source::mirror::mirror_factory::get_width(void* p)
|
2018-11-07 14:24:25 +00:00
|
|
|
{
|
2018-04-27 21:38:49 +00:00
|
|
|
if (p) {
|
2019-01-27 22:33:12 +00:00
|
|
|
return static_cast<source::mirror::mirror_instance*>(p)->get_width();
|
2018-04-27 21:38:49 +00:00
|
|
|
}
|
|
|
|
return 0;
|
2017-12-14 07:06:09 +00:00
|
|
|
}
|
|
|
|
|
2019-01-27 22:33:12 +00:00
|
|
|
uint32_t source::mirror::mirror_factory::get_height(void* p)
|
2018-11-07 14:24:25 +00:00
|
|
|
{
|
2018-04-27 21:38:49 +00:00
|
|
|
if (p) {
|
2019-01-27 22:33:12 +00:00
|
|
|
return static_cast<source::mirror::mirror_instance*>(p)->get_height();
|
2018-04-27 21:38:49 +00:00
|
|
|
}
|
|
|
|
return 0;
|
2017-12-14 07:06:09 +00:00
|
|
|
}
|
|
|
|
|
2019-01-27 22:33:12 +00:00
|
|
|
void source::mirror::mirror_factory::update(void* p, obs_data_t* data)
|
2018-11-07 14:24:25 +00:00
|
|
|
{
|
2018-04-27 21:38:49 +00:00
|
|
|
if (p) {
|
2019-01-27 22:33:12 +00:00
|
|
|
static_cast<source::mirror::mirror_instance*>(p)->update(data);
|
2018-04-27 21:38:49 +00:00
|
|
|
}
|
2017-12-14 07:06:09 +00:00
|
|
|
}
|
|
|
|
|
2019-01-27 22:33:12 +00:00
|
|
|
void source::mirror::mirror_factory::activate(void* p)
|
2018-11-07 14:24:25 +00:00
|
|
|
{
|
2018-04-27 21:38:49 +00:00
|
|
|
if (p) {
|
2019-01-27 22:33:12 +00:00
|
|
|
static_cast<source::mirror::mirror_instance*>(p)->activate();
|
2018-04-27 21:38:49 +00:00
|
|
|
}
|
2017-12-14 07:06:09 +00:00
|
|
|
}
|
|
|
|
|
2019-01-27 22:33:12 +00:00
|
|
|
void source::mirror::mirror_factory::deactivate(void* p)
|
2018-11-07 14:24:25 +00:00
|
|
|
{
|
2018-04-27 21:38:49 +00:00
|
|
|
if (p) {
|
2019-01-27 22:33:12 +00:00
|
|
|
static_cast<source::mirror::mirror_instance*>(p)->deactivate();
|
2018-04-27 21:38:49 +00:00
|
|
|
}
|
2017-12-14 07:06:09 +00:00
|
|
|
}
|
|
|
|
|
2019-01-27 22:33:12 +00:00
|
|
|
void source::mirror::mirror_factory::video_tick(void* p, float t)
|
2018-11-07 14:24:25 +00:00
|
|
|
{
|
2018-04-27 21:38:49 +00:00
|
|
|
if (p) {
|
2019-01-27 22:33:12 +00:00
|
|
|
static_cast<source::mirror::mirror_instance*>(p)->video_tick(t);
|
2018-04-27 21:38:49 +00:00
|
|
|
}
|
2017-12-14 07:06:09 +00:00
|
|
|
}
|
|
|
|
|
2019-01-27 22:33:12 +00:00
|
|
|
void source::mirror::mirror_factory::video_render(void* p, gs_effect_t* ef)
|
2018-11-07 14:24:25 +00:00
|
|
|
{
|
2018-04-27 21:38:49 +00:00
|
|
|
if (p) {
|
2019-01-27 22:33:12 +00:00
|
|
|
static_cast<source::mirror::mirror_instance*>(p)->video_render(ef);
|
2018-04-27 21:38:49 +00:00
|
|
|
}
|
2017-12-14 07:06:09 +00:00
|
|
|
}
|
|
|
|
|
2019-01-27 22:33:12 +00:00
|
|
|
void source::mirror::mirror_factory::enum_active_sources(void* p, obs_source_enum_proc_t enum_callback, void* param)
|
2018-11-07 14:24:25 +00:00
|
|
|
{
|
2018-04-27 21:38:49 +00:00
|
|
|
if (p) {
|
2019-01-27 22:33:12 +00:00
|
|
|
static_cast<source::mirror::mirror_instance*>(p)->enum_active_sources(enum_callback, param);
|
2018-04-27 21:38:49 +00:00
|
|
|
}
|
2018-04-24 11:48:42 +00:00
|
|
|
}
|
|
|
|
|
2019-01-27 22:33:12 +00:00
|
|
|
void source::mirror::mirror_factory::load(void* p, obs_data_t* d)
|
2018-11-08 07:08:38 +00:00
|
|
|
{
|
|
|
|
if (p) {
|
2019-01-27 22:33:12 +00:00
|
|
|
static_cast<source::mirror::mirror_instance*>(p)->load(d);
|
2018-11-08 07:08:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-27 22:33:12 +00:00
|
|
|
void source::mirror::mirror_factory::save(void* p, obs_data_t* d)
|
2018-11-08 07:08:38 +00:00
|
|
|
{
|
|
|
|
if (p) {
|
2019-01-27 22:33:12 +00:00
|
|
|
static_cast<source::mirror::mirror_instance*>(p)->save(d);
|
2018-11-08 07:08:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-27 22:33:12 +00:00
|
|
|
void source::mirror::mirror_instance::release_input()
|
2019-01-23 20:05:10 +00:00
|
|
|
{
|
|
|
|
// Clear any references to the previous source.
|
|
|
|
if (this->m_source_item) {
|
2019-01-23 21:03:47 +00:00
|
|
|
obs_sceneitem_remove(this->m_source_item);
|
|
|
|
this->m_source_item = nullptr;
|
2019-01-23 20:05:10 +00:00
|
|
|
}
|
2019-01-23 21:03:47 +00:00
|
|
|
{
|
|
|
|
std::unique_lock<std::mutex> audio_lock(this->m_audio_lock);
|
|
|
|
this->m_source_audio.reset();
|
|
|
|
}
|
|
|
|
this->m_source.reset();
|
2019-01-23 20:05:10 +00:00
|
|
|
}
|
|
|
|
|
2019-01-27 22:33:12 +00:00
|
|
|
void source::mirror::mirror_instance::acquire_input(std::string source_name)
|
2019-01-23 20:05:10 +00:00
|
|
|
{
|
|
|
|
// Acquire new reference to current source.
|
|
|
|
obs_source_t* ref_source = obs_get_source_by_name(source_name.c_str());
|
|
|
|
if (!ref_source) {
|
|
|
|
// Early-Exit: Unable to find a source with this name, likely has been released.
|
|
|
|
#ifdef _DEBUG
|
|
|
|
P_LOG_DEBUG("<Source Mirror:%s> Unable to find target source '%s'.", obs_source_get_name(this->m_self),
|
|
|
|
source_name.c_str());
|
|
|
|
#endif
|
|
|
|
return;
|
2019-01-23 22:23:49 +00:00
|
|
|
} else if (ref_source == this->m_self) {
|
2019-01-23 20:05:10 +00:00
|
|
|
// Early-Exit: Attempted self-mirror (recursion).
|
|
|
|
#ifdef _DEBUG
|
|
|
|
P_LOG_DEBUG("<Source Mirror:%s> Attempted to mirror self.", obs_source_get_name(this->m_self));
|
|
|
|
#endif
|
2019-01-23 22:23:49 +00:00
|
|
|
obs_source_release(ref_source);
|
2019-01-23 20:05:10 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-01-23 22:23:49 +00:00
|
|
|
std::shared_ptr<obs::source> new_source = std::make_shared<obs::source>(ref_source, true, false);
|
|
|
|
|
2019-01-23 20:05:10 +00:00
|
|
|
// It looks like everything is in order, so continue now.
|
|
|
|
this->m_source_item = obs_scene_add(obs_scene_from_source(this->m_scene->get()), new_source->get());
|
|
|
|
if (!this->m_source_item) {
|
|
|
|
// Late-Exit: OBS detected something bad, so no further action will be taken.
|
|
|
|
#ifdef _DEBUG
|
|
|
|
P_LOG_DEBUG("<Source Mirror:%s> Attempted recursion with scene '%s'.", obs_source_get_name(this->m_self),
|
|
|
|
source_name.c_str());
|
|
|
|
#endif
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// If everything worked fine, we now set everything up.
|
2019-01-23 22:23:49 +00:00
|
|
|
this->m_source = std::move(new_source);
|
2019-01-27 22:33:12 +00:00
|
|
|
this->m_source->events.rename += std::bind(&source::mirror::mirror_instance::on_source_rename, this, std::placeholders::_1,
|
2019-01-23 20:05:10 +00:00
|
|
|
std::placeholders::_2, std::placeholders::_3);
|
|
|
|
try {
|
|
|
|
// Audio
|
|
|
|
this->m_source_audio = std::make_shared<obs::audio_capture>(this->m_source);
|
2019-01-27 22:33:12 +00:00
|
|
|
this->m_source_audio->on.data += std::bind(&source::mirror::mirror_instance::audio_capture_cb, this, std::placeholders::_1,
|
2019-01-23 22:23:49 +00:00
|
|
|
std::placeholders::_2, std::placeholders::_3);
|
2019-01-23 20:05:10 +00:00
|
|
|
} catch (...) {
|
|
|
|
P_LOG_ERROR("<Source Mirror:%s> Unexpected error during registering audio callback for '%s'.",
|
|
|
|
source_name.c_str());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-27 22:33:12 +00:00
|
|
|
source::mirror::mirror_instance::mirror_instance(obs_data_t* data, obs_source_t* src)
|
2019-01-24 03:27:04 +00:00
|
|
|
: m_self(src), m_active(true), m_tick(0), m_scene_rendered(false), m_rescale_enabled(false),
|
|
|
|
m_rescale_keep_orig_size(false), m_rescale_width(1), m_rescale_height(1),
|
|
|
|
m_rescale_type(obs_scale_type::OBS_SCALE_BICUBIC), m_rescale_bounds(obs_bounds_type::OBS_BOUNDS_STRETCH),
|
|
|
|
m_audio_enabled(false), m_audio_kill_thread(false), m_audio_have_output(false), m_source_item(nullptr)
|
2018-11-07 14:24:25 +00:00
|
|
|
{
|
2019-01-24 00:12:48 +00:00
|
|
|
// Initialize Video Rendering
|
|
|
|
this->m_scene =
|
|
|
|
std::make_shared<obs::source>(obs_scene_get_source(obs_scene_create_private("Source Mirror Internal Scene")));
|
|
|
|
this->m_scene_texture_renderer =
|
|
|
|
std::make_shared<gfx::source_texture>(this->m_scene, std::make_shared<obs::source>(this->m_self, false, false));
|
|
|
|
|
|
|
|
// Initialize Audio Rendering
|
|
|
|
this->m_audio_data.resize(MAX_AUDIO_CHANNELS);
|
|
|
|
for (size_t idx = 0; idx < this->m_audio_data.size(); idx++) {
|
|
|
|
this->m_audio_data[idx].resize(AUDIO_OUTPUT_FRAMES);
|
|
|
|
}
|
2019-01-27 22:33:12 +00:00
|
|
|
this->m_audio_thread = std::thread(std::bind(&source::mirror::mirror_instance::audio_output_cb, this));
|
2017-12-14 07:06:09 +00:00
|
|
|
}
|
|
|
|
|
2019-01-27 22:33:12 +00:00
|
|
|
source::mirror::mirror_instance::~mirror_instance()
|
2018-11-07 14:24:25 +00:00
|
|
|
{
|
2019-01-23 20:05:10 +00:00
|
|
|
release_input();
|
|
|
|
|
|
|
|
// Finalize Audio Rendering
|
|
|
|
this->m_audio_kill_thread = true;
|
2018-11-07 14:29:24 +00:00
|
|
|
this->m_audio_notify.notify_all();
|
|
|
|
if (this->m_audio_thread.joinable()) {
|
|
|
|
this->m_audio_thread.join();
|
|
|
|
}
|
|
|
|
|
2019-01-23 20:05:10 +00:00
|
|
|
// Finalize Video Rendering
|
2019-01-24 00:12:48 +00:00
|
|
|
this->m_scene_texture_renderer.reset();
|
2019-01-23 20:05:10 +00:00
|
|
|
this->m_scene.reset();
|
2018-04-27 21:38:49 +00:00
|
|
|
}
|
2017-12-14 07:06:09 +00:00
|
|
|
|
2019-01-27 22:33:12 +00:00
|
|
|
uint32_t source::mirror::mirror_instance::get_width()
|
2018-11-07 14:24:25 +00:00
|
|
|
{
|
2019-01-24 00:12:48 +00:00
|
|
|
if (this->m_rescale_enabled && this->m_rescale_width > 0 && !this->m_rescale_keep_orig_size) {
|
|
|
|
return this->m_rescale_width;
|
2018-04-24 11:48:42 +00:00
|
|
|
}
|
2019-01-23 20:05:10 +00:00
|
|
|
obs_source_t* source = obs_sceneitem_get_source(this->m_source_item);
|
2018-11-07 13:11:38 +00:00
|
|
|
if (source) {
|
|
|
|
return obs_source_get_width(source);
|
2018-04-24 11:48:42 +00:00
|
|
|
}
|
2017-12-14 07:06:09 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2019-01-27 22:33:12 +00:00
|
|
|
uint32_t source::mirror::mirror_instance::get_height()
|
2018-11-07 14:24:25 +00:00
|
|
|
{
|
2019-01-24 00:12:48 +00:00
|
|
|
if (this->m_rescale_enabled && this->m_rescale_height > 0 && !this->m_rescale_keep_orig_size)
|
|
|
|
return this->m_rescale_height;
|
2019-01-23 20:05:10 +00:00
|
|
|
obs_source_t* source = obs_sceneitem_get_source(this->m_source_item);
|
2018-11-07 13:11:38 +00:00
|
|
|
if (source) {
|
|
|
|
return obs_source_get_height(source);
|
|
|
|
}
|
2017-12-14 07:06:09 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2019-01-27 22:33:12 +00:00
|
|
|
void source::mirror::mirror_instance::update(obs_data_t* data)
|
2018-11-07 14:24:25 +00:00
|
|
|
{
|
2019-01-23 20:05:10 +00:00
|
|
|
{ // User changed the source we are tracking.
|
|
|
|
release_input();
|
|
|
|
this->m_source_name = obs_data_get_string(data, P_SOURCE);
|
|
|
|
if (this->m_source_name.length() > 0) {
|
|
|
|
acquire_input(this->m_source_name);
|
2018-03-05 15:50:19 +00:00
|
|
|
}
|
|
|
|
}
|
2019-01-23 20:05:10 +00:00
|
|
|
|
|
|
|
// Audio
|
|
|
|
this->m_audio_enabled = obs_data_get_bool(data, P_SOURCE_AUDIO);
|
2017-12-14 07:06:09 +00:00
|
|
|
|
|
|
|
// Rescaling
|
2019-01-23 20:05:10 +00:00
|
|
|
this->m_rescale_enabled = obs_data_get_bool(data, P_SCALING);
|
|
|
|
if (this->m_rescale_enabled) { // Parse rescaling settings.
|
2017-12-14 07:06:09 +00:00
|
|
|
uint32_t width, height;
|
|
|
|
|
|
|
|
// Read value.
|
|
|
|
const char* size = obs_data_get_string(data, P_SCALING_SIZE);
|
|
|
|
const char* xpos = strchr(size, 'x');
|
|
|
|
if (xpos != nullptr) {
|
|
|
|
// Width
|
|
|
|
width = strtoul(size, nullptr, 10);
|
|
|
|
if (errno == ERANGE || width == 0) {
|
2019-01-23 20:05:10 +00:00
|
|
|
this->m_rescale_enabled = false;
|
2019-01-24 00:12:48 +00:00
|
|
|
this->m_rescale_width = 1;
|
2017-12-14 07:06:09 +00:00
|
|
|
} else {
|
2019-01-24 00:12:48 +00:00
|
|
|
this->m_rescale_width = width;
|
2017-12-14 07:06:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
height = strtoul(xpos + 1, nullptr, 10);
|
|
|
|
if (errno == ERANGE || height == 0) {
|
2019-01-23 20:05:10 +00:00
|
|
|
this->m_rescale_enabled = false;
|
2019-01-24 00:12:48 +00:00
|
|
|
this->m_rescale_height = 1;
|
2017-12-14 07:06:09 +00:00
|
|
|
} else {
|
2019-01-24 00:12:48 +00:00
|
|
|
this->m_rescale_height = height;
|
2017-12-14 07:06:09 +00:00
|
|
|
}
|
|
|
|
} else {
|
2019-01-23 20:05:10 +00:00
|
|
|
this->m_rescale_enabled = false;
|
2019-01-24 00:12:48 +00:00
|
|
|
this->m_rescale_width = 1;
|
|
|
|
this->m_rescale_height = 1;
|
2017-12-14 07:06:09 +00:00
|
|
|
}
|
|
|
|
|
2019-01-23 20:05:10 +00:00
|
|
|
this->m_rescale_keep_orig_size = obs_data_get_bool(data, P_SCALING_TRANSFORMKEEPORIGINAL);
|
2019-01-24 03:27:04 +00:00
|
|
|
this->m_rescale_type = (obs_scale_type)obs_data_get_int(data, P_SCALING_METHOD);
|
|
|
|
this->m_rescale_bounds = (obs_bounds_type)obs_data_get_int(data, P_SCALING_BOUNDS);
|
2017-12-14 07:06:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-27 22:33:12 +00:00
|
|
|
void source::mirror::mirror_instance::activate()
|
2018-11-07 14:24:25 +00:00
|
|
|
{
|
|
|
|
this->m_active = true;
|
2019-01-23 20:05:10 +00:00
|
|
|
|
|
|
|
// No source, delayed acquire.
|
|
|
|
if (!this->m_source_item) {
|
|
|
|
this->acquire_input(this->m_source_name.c_str());
|
2018-04-24 13:31:51 +00:00
|
|
|
}
|
2017-12-14 07:06:09 +00:00
|
|
|
}
|
|
|
|
|
2019-01-27 22:33:12 +00:00
|
|
|
void source::mirror::mirror_instance::deactivate()
|
2018-11-07 14:24:25 +00:00
|
|
|
{
|
|
|
|
this->m_active = false;
|
2017-12-14 07:06:09 +00:00
|
|
|
}
|
|
|
|
|
2018-11-07 14:24:25 +00:00
|
|
|
static inline void mix_audio(float* p_out, float* p_in, size_t pos, size_t count)
|
|
|
|
{
|
2019-01-14 22:04:05 +00:00
|
|
|
float* out = p_out;
|
|
|
|
float* in = p_in + pos;
|
|
|
|
float* end = in + count;
|
2018-04-27 21:38:49 +00:00
|
|
|
|
|
|
|
while (in < end)
|
|
|
|
*(out++) += *(in++);
|
|
|
|
}
|
|
|
|
|
2019-01-27 22:33:12 +00:00
|
|
|
void source::mirror::mirror_instance::video_tick(float time)
|
2018-11-07 14:24:25 +00:00
|
|
|
{
|
|
|
|
this->m_tick += time;
|
2019-01-23 20:05:10 +00:00
|
|
|
if (this->m_tick > 0.1f) {
|
|
|
|
this->m_tick -= 0.1f;
|
2018-04-24 15:02:30 +00:00
|
|
|
|
2019-01-23 20:05:10 +00:00
|
|
|
// No source, delayed acquire.
|
|
|
|
if (!this->m_source_item) {
|
|
|
|
this->acquire_input(this->m_source_name.c_str());
|
2018-04-24 15:02:30 +00:00
|
|
|
}
|
2018-04-24 13:31:51 +00:00
|
|
|
}
|
2019-01-24 03:27:04 +00:00
|
|
|
|
|
|
|
// Update Scene Item Boundaries
|
|
|
|
if (this->m_source_item) {
|
|
|
|
obs_transform_info info;
|
|
|
|
obs_sceneitem_get_info(this->m_source_item, &info);
|
|
|
|
|
|
|
|
info.pos.x = 0;
|
|
|
|
info.pos.y = 0;
|
|
|
|
info.rot = 0;
|
|
|
|
info.scale.x = 1.f;
|
|
|
|
info.scale.y = 1.f;
|
|
|
|
info.bounds.x = float_t(this->m_source->width());
|
|
|
|
info.bounds.y = float_t(this->m_source->height());
|
|
|
|
info.bounds_type = obs_bounds_type::OBS_BOUNDS_STRETCH;
|
|
|
|
|
|
|
|
if (this->m_rescale_enabled) {
|
|
|
|
info.bounds.x = float_t(this->m_rescale_width);
|
|
|
|
info.bounds.y = float_t(this->m_rescale_height);
|
|
|
|
info.bounds_type = this->m_rescale_bounds;
|
|
|
|
}
|
|
|
|
obs_sceneitem_set_info(this->m_source_item, &info);
|
|
|
|
obs_sceneitem_force_update_transform(this->m_source_item);
|
|
|
|
|
|
|
|
obs_sceneitem_set_scale_filter(this->m_source_item, this->m_rescale_enabled ? this->m_rescale_type
|
|
|
|
: obs_scale_type::OBS_SCALE_POINT);
|
|
|
|
}
|
|
|
|
|
|
|
|
m_scene_rendered = false;
|
2017-12-14 07:06:09 +00:00
|
|
|
}
|
|
|
|
|
2019-01-27 22:33:12 +00:00
|
|
|
void source::mirror::mirror_instance::video_render(gs_effect_t* effect)
|
2018-11-07 14:24:25 +00:00
|
|
|
{
|
2019-01-24 00:12:48 +00:00
|
|
|
if ((this->m_rescale_width == 0) || (this->m_rescale_height == 0) || !this->m_source_item
|
|
|
|
|| !this->m_scene_texture_renderer) {
|
2017-12-14 07:06:09 +00:00
|
|
|
return;
|
2018-03-05 15:50:19 +00:00
|
|
|
}
|
2017-12-14 07:06:09 +00:00
|
|
|
|
2019-01-24 03:27:04 +00:00
|
|
|
// Only re-render the scene if there was a video_tick, saves GPU cycles.
|
|
|
|
if (!m_scene_rendered) {
|
|
|
|
// Override render size if rescaling is enabled.
|
|
|
|
uint32_t render_width = this->m_source->width();
|
|
|
|
uint32_t render_height = this->m_source->height();
|
|
|
|
if (m_rescale_enabled) {
|
|
|
|
render_width = m_rescale_width;
|
|
|
|
render_height = m_rescale_height;
|
2018-04-09 11:23:57 +00:00
|
|
|
}
|
2017-12-14 07:06:09 +00:00
|
|
|
|
2019-01-24 03:27:04 +00:00
|
|
|
m_scene_texture = this->m_scene_texture_renderer->render(render_width, render_height);
|
|
|
|
m_scene_rendered = true;
|
|
|
|
}
|
2018-11-08 07:08:38 +00:00
|
|
|
|
2019-01-24 03:27:04 +00:00
|
|
|
// Use default effect unless we are provided a different effect.
|
|
|
|
if (!effect) {
|
|
|
|
effect = obs_get_base_effect(OBS_EFFECT_DEFAULT);
|
|
|
|
}
|
2018-11-08 07:08:38 +00:00
|
|
|
|
2019-01-24 03:27:04 +00:00
|
|
|
// Render the cached scene texture.
|
|
|
|
gs_effect_set_texture(gs_effect_get_param_by_name(effect, "image"), m_scene_texture->get_object());
|
|
|
|
while (gs_effect_loop(effect, "Draw")) {
|
|
|
|
gs_draw_sprite(m_scene_texture->get_object(), 0, this->get_width(), this->get_height());
|
2017-12-14 07:06:09 +00:00
|
|
|
}
|
|
|
|
}
|
2018-04-24 11:48:42 +00:00
|
|
|
|
2019-01-27 22:33:12 +00:00
|
|
|
void source::mirror::mirror_instance::audio_capture_cb(std::shared_ptr<obs::source> source, audio_data const* const audio, bool)
|
2018-11-07 14:24:25 +00:00
|
|
|
{
|
|
|
|
std::unique_lock<std::mutex> ulock(this->m_audio_lock);
|
2019-01-23 20:05:10 +00:00
|
|
|
if (!this->m_audio_enabled) {
|
2018-04-27 21:38:49 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
audio_t* aud = obs_get_audio();
|
2018-11-07 13:43:43 +00:00
|
|
|
if (!aud) {
|
|
|
|
return;
|
|
|
|
}
|
2018-04-27 21:38:49 +00:00
|
|
|
audio_output_info const* aoi = audio_output_get_info(aud);
|
2018-11-07 13:43:43 +00:00
|
|
|
if (!aoi) {
|
|
|
|
return;
|
|
|
|
}
|
2018-04-27 21:38:49 +00:00
|
|
|
|
|
|
|
std::bitset<8> layout;
|
|
|
|
for (size_t plane = 0; plane < MAX_AV_PLANES; plane++) {
|
2018-11-07 14:24:25 +00:00
|
|
|
float* samples = (float*)audio->data[plane];
|
2018-04-27 21:38:49 +00:00
|
|
|
if (!samples) {
|
2018-11-07 14:24:25 +00:00
|
|
|
this->m_audio_output.data[plane] = nullptr;
|
2018-04-27 21:38:49 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
layout.set(plane);
|
|
|
|
|
2018-11-07 14:24:25 +00:00
|
|
|
memcpy(this->m_audio_data[plane].data(), audio->data[plane], audio->frames * sizeof(float_t));
|
|
|
|
this->m_audio_output.data[plane] = reinterpret_cast<uint8_t*>(this->m_audio_data[plane].data());
|
2018-04-27 21:38:49 +00:00
|
|
|
}
|
2018-11-07 14:24:25 +00:00
|
|
|
this->m_audio_output.format = aoi->format;
|
|
|
|
this->m_audio_output.frames = audio->frames;
|
|
|
|
this->m_audio_output.timestamp = audio->timestamp;
|
|
|
|
this->m_audio_output.samples_per_sec = aoi->samples_per_sec;
|
|
|
|
this->m_audio_output.speakers = aoi->speakers;
|
|
|
|
|
2019-01-23 20:05:10 +00:00
|
|
|
this->m_audio_have_output = true;
|
2018-11-07 14:24:25 +00:00
|
|
|
this->m_audio_notify.notify_all();
|
2018-04-27 21:38:49 +00:00
|
|
|
}
|
|
|
|
|
2019-01-27 22:33:12 +00:00
|
|
|
void source::mirror::mirror_instance::audio_output_cb()
|
2018-11-07 14:24:25 +00:00
|
|
|
{
|
|
|
|
std::unique_lock<std::mutex> ulock(this->m_audio_lock);
|
2018-04-27 21:38:49 +00:00
|
|
|
|
2019-01-23 20:05:10 +00:00
|
|
|
while (!this->m_audio_kill_thread) {
|
|
|
|
if (this->m_audio_have_output) {
|
|
|
|
std::unique_lock<std::mutex> ulock(this->m_audio_lock);
|
|
|
|
obs_source_output_audio(this->m_self, &this->m_audio_output);
|
|
|
|
this->m_audio_have_output = false;
|
2018-04-27 21:38:49 +00:00
|
|
|
}
|
2019-01-23 20:05:10 +00:00
|
|
|
this->m_audio_notify.wait(ulock, [this]() { return this->m_audio_have_output || this->m_audio_kill_thread; });
|
2018-04-27 21:38:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-27 22:33:12 +00:00
|
|
|
void source::mirror::mirror_instance::enum_active_sources(obs_source_enum_proc_t enum_callback, void* param)
|
2018-11-07 14:24:25 +00:00
|
|
|
{
|
2018-11-08 07:08:38 +00:00
|
|
|
if (this->m_scene) {
|
2019-01-23 20:05:10 +00:00
|
|
|
enum_callback(this->m_self, this->m_scene->get(), param);
|
2018-11-08 07:08:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-27 22:33:12 +00:00
|
|
|
void source::mirror::mirror_instance::load(obs_data_t* data)
|
2019-01-23 22:23:49 +00:00
|
|
|
{
|
2019-01-23 21:25:48 +00:00
|
|
|
this->update(data);
|
|
|
|
}
|
2018-11-08 07:08:38 +00:00
|
|
|
|
2019-01-27 22:33:12 +00:00
|
|
|
void source::mirror::mirror_instance::save(obs_data_t* data)
|
2018-11-08 07:08:38 +00:00
|
|
|
{
|
2019-01-23 20:05:10 +00:00
|
|
|
if (this->m_source_item) {
|
|
|
|
obs_data_set_string(data, P_SOURCE, obs_source_get_name(m_source->get()));
|
2018-11-08 07:08:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-27 22:33:12 +00:00
|
|
|
void source::mirror::mirror_instance::on_source_rename(obs::source* source, std::string, std::string)
|
2019-01-14 22:52:12 +00:00
|
|
|
{
|
2019-01-23 20:05:10 +00:00
|
|
|
obs_data_t* ref = obs_source_get_settings(this->m_self);
|
2018-11-08 07:08:38 +00:00
|
|
|
obs_data_set_string(ref, P_SOURCE, obs_source_get_name(source->get()));
|
2019-01-23 20:05:10 +00:00
|
|
|
obs_source_update(this->m_self, ref);
|
2018-11-08 07:08:38 +00:00
|
|
|
obs_data_release(ref);
|
2018-04-24 11:48:42 +00:00
|
|
|
}
|