mirror of
https://github.com/Xaymar/obs-StreamFX
synced 2024-11-14 07:45:06 +00:00
project: Update to new classes
This commit is contained in:
parent
3667426f49
commit
8a31b986ab
6 changed files with 47 additions and 51 deletions
|
@ -376,10 +376,11 @@ void dynamic_mask_instance::enum_all_sources(obs_source_enum_proc_t enum_callbac
|
||||||
|
|
||||||
void streamfx::filter::dynamic_mask::dynamic_mask_instance::show()
|
void streamfx::filter::dynamic_mask::dynamic_mask_instance::show()
|
||||||
{
|
{
|
||||||
if (!_input || !obs_source_showing(obs_filter_get_parent(_self)))
|
if (!_input || !_self.showing() || !(_self.get_filter_parent().showing()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_input_vs = std::make_shared<obs::tools::visible_source>(_input.lock().get());
|
auto input = _input.lock();
|
||||||
|
_input_vs = ::streamfx::obs::source_showing_reference::add_showing_reference(input);
|
||||||
}
|
}
|
||||||
|
|
||||||
void streamfx::filter::dynamic_mask::dynamic_mask_instance::hide()
|
void streamfx::filter::dynamic_mask::dynamic_mask_instance::hide()
|
||||||
|
@ -389,10 +390,11 @@ void streamfx::filter::dynamic_mask::dynamic_mask_instance::hide()
|
||||||
|
|
||||||
void streamfx::filter::dynamic_mask::dynamic_mask_instance::activate()
|
void streamfx::filter::dynamic_mask::dynamic_mask_instance::activate()
|
||||||
{
|
{
|
||||||
if (!_input || !obs_source_active(obs_filter_get_parent(_self)))
|
if (!_input || !_self.active() || !(_self.get_filter_parent().active()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_input_ac = std::make_shared<obs::tools::active_source>(_input.lock().get());
|
auto input = _input.lock();
|
||||||
|
_input_ac = ::streamfx::obs::source_active_reference::add_active_reference(input);
|
||||||
}
|
}
|
||||||
|
|
||||||
void streamfx::filter::dynamic_mask::dynamic_mask_instance::deactivate()
|
void streamfx::filter::dynamic_mask::dynamic_mask_instance::deactivate()
|
||||||
|
|
|
@ -23,7 +23,9 @@
|
||||||
#include <map>
|
#include <map>
|
||||||
#include "gfx/gfx-source-texture.hpp"
|
#include "gfx/gfx-source-texture.hpp"
|
||||||
#include "obs/gs/gs-effect.hpp"
|
#include "obs/gs/gs-effect.hpp"
|
||||||
|
#include "obs/obs-source-active-reference.hpp"
|
||||||
#include "obs/obs-source-factory.hpp"
|
#include "obs/obs-source-factory.hpp"
|
||||||
|
#include "obs/obs-source-showing-reference.hpp"
|
||||||
#include "obs/obs-source-tracker.hpp"
|
#include "obs/obs-source-tracker.hpp"
|
||||||
#include "obs/obs-source.hpp"
|
#include "obs/obs-source.hpp"
|
||||||
#include "obs/obs-tools.hpp"
|
#include "obs/obs-tools.hpp"
|
||||||
|
@ -44,8 +46,8 @@ namespace streamfx::filter::dynamic_mask {
|
||||||
::streamfx::obs::weak_source _input;
|
::streamfx::obs::weak_source _input;
|
||||||
std::shared_ptr<streamfx::gfx::source_texture> _input_capture;
|
std::shared_ptr<streamfx::gfx::source_texture> _input_capture;
|
||||||
std::shared_ptr<streamfx::obs::gs::texture> _input_texture;
|
std::shared_ptr<streamfx::obs::gs::texture> _input_texture;
|
||||||
std::shared_ptr<obs::tools::visible_source> _input_vs;
|
std::shared_ptr<::streamfx::obs::source_showing_reference> _input_vs;
|
||||||
std::shared_ptr<obs::tools::active_source> _input_ac;
|
std::shared_ptr<::streamfx::obs::source_active_reference> _input_ac;
|
||||||
|
|
||||||
bool _have_final_texture;
|
bool _have_final_texture;
|
||||||
std::shared_ptr<streamfx::obs::gs::rendertarget> _final_rt;
|
std::shared_ptr<streamfx::obs::gs::rendertarget> _final_rt;
|
||||||
|
|
|
@ -283,7 +283,7 @@ void streamfx::gfx::shader::texture_parameter::assign()
|
||||||
// Reload or Reacquire everything necessary.
|
// Reload or Reacquire everything necessary.
|
||||||
try {
|
try {
|
||||||
// Remove now unused references.
|
// Remove now unused references.
|
||||||
_source.reset();
|
_source.release();
|
||||||
_source_child.reset();
|
_source_child.reset();
|
||||||
_source_active.reset();
|
_source_active.reset();
|
||||||
_source_visible.reset();
|
_source_visible.reset();
|
||||||
|
@ -298,23 +298,22 @@ void streamfx::gfx::shader::texture_parameter::assign()
|
||||||
}
|
}
|
||||||
} else if ((field_type() == texture_field_type::Input) && (_type == texture_type::Source)) {
|
} else if ((field_type() == texture_field_type::Input) && (_type == texture_type::Source)) {
|
||||||
// Try and grab the source itself.
|
// Try and grab the source itself.
|
||||||
auto source = std::shared_ptr<obs_source_t>(obs_get_source_by_name(_source_name.c_str()),
|
auto source = ::streamfx::obs::source(_source_name);
|
||||||
[](obs_source_t* v) { obs_source_release(v); });
|
|
||||||
if (!source) {
|
if (!source) {
|
||||||
throw std::runtime_error("Specified Source does not exist.");
|
throw std::runtime_error("Specified Source does not exist.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Attach the child to our parent.
|
// Attach the child to our parent.
|
||||||
auto child = std::make_shared<streamfx::obs::tools::child_source>(get_parent()->get(), source);
|
auto child = std::make_shared<::streamfx::obs::source_active_child>(source, get_parent()->get());
|
||||||
|
|
||||||
// Create necessary visible and active objects.
|
// Create necessary visible and active objects.
|
||||||
std::shared_ptr<streamfx::obs::tools::active_source> active;
|
decltype(_source_active) active;
|
||||||
std::shared_ptr<streamfx::obs::tools::visible_source> visible;
|
decltype(_source_visible) visible;
|
||||||
if (_active) {
|
if (_active) {
|
||||||
active = std::make_shared<streamfx::obs::tools::active_source>(source.get());
|
active = ::streamfx::obs::source_active_reference::add_active_reference(source);
|
||||||
}
|
}
|
||||||
if (_visible) {
|
if (_visible) {
|
||||||
visible = std::make_shared<streamfx::obs::tools::visible_source>(source.get());
|
visible = ::streamfx::obs::source_showing_reference::add_showing_reference(source);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the necessary render target to capture the source.
|
// Create the necessary render target to capture the source.
|
||||||
|
@ -391,7 +390,7 @@ void streamfx::gfx::shader::texture_parameter::visible(bool visible)
|
||||||
_visible = visible;
|
_visible = visible;
|
||||||
if (visible) {
|
if (visible) {
|
||||||
if (_source) {
|
if (_source) {
|
||||||
_source_visible = std::make_shared<streamfx::obs::tools::visible_source>(_source.get());
|
_source_visible = ::streamfx::obs::source_showing_reference::add_showing_reference(_source);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
_source_visible.reset();
|
_source_visible.reset();
|
||||||
|
@ -403,7 +402,7 @@ void streamfx::gfx::shader::texture_parameter::active(bool active)
|
||||||
_active = active;
|
_active = active;
|
||||||
if (active) {
|
if (active) {
|
||||||
if (_source) {
|
if (_source) {
|
||||||
_source_active = std::make_shared<streamfx::obs::tools::active_source>(_source.get());
|
_source_active = ::streamfx::obs::source_active_reference::add_active_reference(_source);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
_source_active.reset();
|
_source_active.reset();
|
||||||
|
|
|
@ -6,6 +6,10 @@
|
||||||
#include "gfx-shader-param.hpp"
|
#include "gfx-shader-param.hpp"
|
||||||
#include "obs/gs/gs-rendertarget.hpp"
|
#include "obs/gs/gs-rendertarget.hpp"
|
||||||
#include "obs/gs/gs-texture.hpp"
|
#include "obs/gs/gs-texture.hpp"
|
||||||
|
#include "obs/obs-source-active-child.hpp"
|
||||||
|
#include "obs/obs-source-active-reference.hpp"
|
||||||
|
#include "obs/obs-source-showing-reference.hpp"
|
||||||
|
#include "obs/obs-source.hpp"
|
||||||
#include "obs/obs-tools.hpp"
|
#include "obs/obs-tools.hpp"
|
||||||
|
|
||||||
namespace streamfx::gfx {
|
namespace streamfx::gfx {
|
||||||
|
@ -55,10 +59,10 @@ namespace streamfx::gfx {
|
||||||
|
|
||||||
// Data: Source
|
// Data: Source
|
||||||
std::string _source_name;
|
std::string _source_name;
|
||||||
std::shared_ptr<obs_source_t> _source;
|
::streamfx::obs::source _source;
|
||||||
std::shared_ptr<streamfx::obs::tools::child_source> _source_child;
|
std::shared_ptr<streamfx::obs::source_active_child> _source_child;
|
||||||
std::shared_ptr<streamfx::obs::tools::active_source> _source_active;
|
std::shared_ptr<streamfx::obs::source_active_reference> _source_active;
|
||||||
std::shared_ptr<streamfx::obs::tools::visible_source> _source_visible;
|
std::shared_ptr<streamfx::obs::source_showing_reference> _source_visible;
|
||||||
std::shared_ptr<streamfx::obs::gs::rendertarget> _source_rendertarget;
|
std::shared_ptr<streamfx::obs::gs::rendertarget> _source_rendertarget;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -188,22 +188,16 @@ try {
|
||||||
release();
|
release();
|
||||||
|
|
||||||
// Find source by name if possible.
|
// Find source by name if possible.
|
||||||
std::shared_ptr<obs_source_t> source =
|
decltype(_source) source{source_name};
|
||||||
std::shared_ptr<obs_source_t>{obs_get_source_by_name(source_name.c_str()), obs::obs_source_deleter};
|
if ((!source) || (source == _self)) { // If we failed, just exit early.
|
||||||
if ((!source) || (source.get() == _self)) { // If we failed, just exit early.
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Everything went well, store.
|
// Everything went well, store.
|
||||||
_source_child = std::make_shared<obs::tools::child_source>(_self, source);
|
_source_child = std::make_shared<::streamfx::obs::source_active_child>(_self, source);
|
||||||
_source = source;
|
_source = source;
|
||||||
_source_size.first = obs_source_get_width(_source.get());
|
_source_size.first = obs_source_get_width(_source);
|
||||||
_source_size.second = obs_source_get_height(_source.get());
|
_source_size.second = obs_source_get_height(_source);
|
||||||
|
|
||||||
// Listen to the rename event to update our own settings.
|
|
||||||
_signal_rename = std::make_shared<obs::source_signal_handler>("rename", _source);
|
|
||||||
_signal_rename->event.add(
|
|
||||||
std::bind(&mirror_instance::on_rename, this, std::placeholders::_1, std::placeholders::_2));
|
|
||||||
|
|
||||||
// Listen to any audio the source spews out.
|
// Listen to any audio the source spews out.
|
||||||
if (_audio_enabled) {
|
if (_audio_enabled) {
|
||||||
|
@ -220,15 +214,10 @@ void mirror_instance::release()
|
||||||
_signal_audio.reset();
|
_signal_audio.reset();
|
||||||
_signal_rename.reset();
|
_signal_rename.reset();
|
||||||
_source_child.reset();
|
_source_child.reset();
|
||||||
_source.reset();
|
_source.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
void mirror_instance::on_rename(std::shared_ptr<obs_source_t>, calldata*)
|
void mirror_instance::on_audio(::streamfx::obs::source, const audio_data* audio, bool)
|
||||||
{
|
|
||||||
obs_source_save(_self);
|
|
||||||
}
|
|
||||||
|
|
||||||
void mirror_instance::on_audio(std::shared_ptr<obs_source_t>, const audio_data* audio, bool)
|
|
||||||
{
|
{
|
||||||
// Immediately quit if there isn't any actual audio to send out.
|
// Immediately quit if there isn't any actual audio to send out.
|
||||||
if (!_audio_enabled) {
|
if (!_audio_enabled) {
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
#include "obs/gs/gs-rendertarget.hpp"
|
#include "obs/gs/gs-rendertarget.hpp"
|
||||||
#include "obs/gs/gs-sampler.hpp"
|
#include "obs/gs/gs-sampler.hpp"
|
||||||
#include "obs/obs-signal-handler.hpp"
|
#include "obs/obs-signal-handler.hpp"
|
||||||
|
#include "obs/obs-source-active-child.hpp"
|
||||||
#include "obs/obs-source-factory.hpp"
|
#include "obs/obs-source-factory.hpp"
|
||||||
#include "obs/obs-source.hpp"
|
#include "obs/obs-source.hpp"
|
||||||
#include "obs/obs-tools.hpp"
|
#include "obs/obs-tools.hpp"
|
||||||
|
@ -42,8 +43,8 @@ namespace streamfx::source::mirror {
|
||||||
|
|
||||||
class mirror_instance : public obs::source_instance {
|
class mirror_instance : public obs::source_instance {
|
||||||
// Source
|
// Source
|
||||||
std::shared_ptr<obs_source_t> _source;
|
::streamfx::obs::source _source;
|
||||||
std::shared_ptr<obs::tools::child_source> _source_child;
|
std::shared_ptr<::streamfx::obs::source_active_child> _source_child;
|
||||||
std::shared_ptr<obs::source_signal_handler> _signal_rename;
|
std::shared_ptr<obs::source_signal_handler> _signal_rename;
|
||||||
std::shared_ptr<obs::audio_signal_handler> _signal_audio;
|
std::shared_ptr<obs::audio_signal_handler> _signal_audio;
|
||||||
std::pair<uint32_t, uint32_t> _source_size;
|
std::pair<uint32_t, uint32_t> _source_size;
|
||||||
|
@ -76,8 +77,7 @@ namespace streamfx::source::mirror {
|
||||||
void acquire(std::string source_name);
|
void acquire(std::string source_name);
|
||||||
void release();
|
void release();
|
||||||
|
|
||||||
void on_rename(std::shared_ptr<obs_source_t>, calldata*);
|
void on_audio(::streamfx::obs::source, const struct audio_data*, bool);
|
||||||
void on_audio(std::shared_ptr<obs_source_t>, const struct audio_data*, bool);
|
|
||||||
|
|
||||||
void audio_output(std::shared_ptr<void> data);
|
void audio_output(std::shared_ptr<void> data);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue