diff --git a/source/filters/filter-dynamic-mask.cpp b/source/filters/filter-dynamic-mask.cpp index d7d6dd55..63910796 100644 --- a/source/filters/filter-dynamic-mask.cpp +++ b/source/filters/filter-dynamic-mask.cpp @@ -76,7 +76,7 @@ void filter::dynamic_mask::dynamic_mask_instance::update(obs_data_t* settings) { // Update source. try { - _input = std::make_shared(obs_data_get_string(settings, ST_INPUT)); + _input = std::make_shared(obs_data_get_string(settings, ST_INPUT)); _input_capture = std::make_shared(_input, _self); _input->events.rename += std::bind(&filter::dynamic_mask::dynamic_mask_instance::input_renamed, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3); @@ -169,7 +169,7 @@ void filter::dynamic_mask::dynamic_mask_instance::save(obs_data_t* settings) } } -void filter::dynamic_mask::dynamic_mask_instance::input_renamed(obs::source*, std::string old_name, +void filter::dynamic_mask::dynamic_mask_instance::input_renamed(obs::deprecated_source*, std::string old_name, std::string new_name) { obs_data_t* settings = obs_source_get_settings(_self); diff --git a/source/filters/filter-dynamic-mask.hpp b/source/filters/filter-dynamic-mask.hpp index 81a9d135..04b91b22 100644 --- a/source/filters/filter-dynamic-mask.hpp +++ b/source/filters/filter-dynamic-mask.hpp @@ -53,10 +53,10 @@ namespace filter { std::shared_ptr _filter_rt; std::shared_ptr _filter_texture; - bool _have_input_texture; - std::shared_ptr _input; - std::shared_ptr _input_capture; - std::shared_ptr _input_texture; + bool _have_input_texture; + std::shared_ptr _input; + std::shared_ptr _input_capture; + std::shared_ptr _input_texture; bool _have_final_texture; std::shared_ptr _final_rt; @@ -83,7 +83,7 @@ namespace filter { virtual void load(obs_data_t* settings) override; virtual void save(obs_data_t* settings) override; - void input_renamed(obs::source* src, std::string old_name, std::string new_name); + void input_renamed(obs::deprecated_source* src, std::string old_name, std::string new_name); static bool modified(void* self, obs_properties_t* properties, obs_property_t* property, obs_data_t* settings) noexcept; diff --git a/source/gfx/gfx-source-texture.cpp b/source/gfx/gfx-source-texture.cpp index 7b958bf6..64efeb9b 100644 --- a/source/gfx/gfx-source-texture.cpp +++ b/source/gfx/gfx-source-texture.cpp @@ -33,7 +33,7 @@ gfx::source_texture::source_texture(obs_source_t* parent) if (!parent) { throw std::invalid_argument("_parent must not be null"); } - _parent = std::make_shared(parent, false, false); + _parent = std::make_shared(parent, false, false); _rt = std::make_shared(GS_RGBA, GS_ZS_NONE); } @@ -45,7 +45,7 @@ gfx::source_texture::source_texture(obs_source_t* _source, obs_source_t* _parent if (!obs_source_add_active_child(_parent, _source)) { throw std::runtime_error("_parent is contained in _child"); } - _child = std::make_shared(_source, true, true); + _child = std::make_shared(_source, true, true); } gfx::source_texture::source_texture(const char* _name, obs_source_t* _parent) : source_texture(_parent) @@ -53,7 +53,7 @@ gfx::source_texture::source_texture(const char* _name, obs_source_t* _parent) : if (!_name) { throw std::invalid_argument("name must not be null"); } - _child = std::make_shared(_name, true, true); + _child = std::make_shared(_name, true, true); if (!obs_source_add_active_child(_parent, _child->get())) { throw std::runtime_error("_parent is contained in _child"); } @@ -62,7 +62,8 @@ gfx::source_texture::source_texture(const char* _name, obs_source_t* _parent) : gfx::source_texture::source_texture(std::string _name, obs_source_t* _parent) : source_texture(_name.c_str(), _parent) {} -gfx::source_texture::source_texture(std::shared_ptr pchild, std::shared_ptr pparent) +gfx::source_texture::source_texture(std::shared_ptr pchild, + std::shared_ptr pparent) { if (!pchild) { throw std::invalid_argument("_child must not be null"); @@ -78,8 +79,8 @@ gfx::source_texture::source_texture(std::shared_ptr pchild, std::sh this->_rt = std::make_shared(GS_RGBA, GS_ZS_NONE); } -gfx::source_texture::source_texture(std::shared_ptr _child, obs_source_t* _parent) - : source_texture(_child, std::make_shared(_parent, false, false)) +gfx::source_texture::source_texture(std::shared_ptr _child, obs_source_t* _parent) + : source_texture(_child, std::make_shared(_parent, false, false)) {} obs_source_t* gfx::source_texture::get_object() diff --git a/source/gfx/gfx-source-texture.hpp b/source/gfx/gfx-source-texture.hpp index 2589b169..c280edf0 100644 --- a/source/gfx/gfx-source-texture.hpp +++ b/source/gfx/gfx-source-texture.hpp @@ -16,6 +16,7 @@ // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA #pragma once +#include #include #include #include "obs/gs/gs-rendertarget.hpp" @@ -34,8 +35,8 @@ namespace gfx { class source_texture { - std::shared_ptr _parent; - std::shared_ptr _child; + std::shared_ptr _parent; + std::shared_ptr _child; std::shared_ptr _rt; @@ -47,8 +48,8 @@ namespace gfx { source_texture(const char* name, obs_source_t* parent); source_texture(std::string name, obs_source_t* parent); - source_texture(std::shared_ptr child, std::shared_ptr parent); - source_texture(std::shared_ptr child, obs_source_t* parent); + source_texture(std::shared_ptr child, std::shared_ptr parent); + source_texture(std::shared_ptr child, obs_source_t* parent); public /*copy*/: source_texture(source_texture const& other) = delete; @@ -67,4 +68,38 @@ namespace gfx { obs_source_t* get_object(); obs_source_t* get_parent(); }; + + class source_texture_factory { + friend class source_texture; + + std::map, std::weak_ptr> _cache; + + public: + source_texture_factory(); + ~source_texture_factory(); + + std::shared_ptr get_source_texture(std::shared_ptr source); + + protected: + void free_source_texture(std::shared_ptr source); + + private: // Singleton + static std::shared_ptr factory_instance; + + public: // Singleton + static void initialize() + { + factory_instance = std::make_shared(); + } + + static void finalize() + { + factory_instance.reset(); + } + + static std::shared_ptr get() + { + return factory_instance; + } + }; } // namespace gfx diff --git a/source/obs/obs-source.cpp b/source/obs/obs-source.cpp index 6b2baf11..2125ede7 100644 --- a/source/obs/obs-source.cpp +++ b/source/obs/obs-source.cpp @@ -21,8 +21,9 @@ #include #include "plugin.hpp" -void obs::source::handle_destroy(void* p, calldata_t* calldata) noexcept try { - obs::source* self = reinterpret_cast(p); +void obs::deprecated_source::handle_destroy(void* p, calldata_t* calldata) noexcept +try { + obs::deprecated_source* self = reinterpret_cast(p); obs_source_t* source; if (!calldata_get_ptr(calldata, "source", &source)) { @@ -43,8 +44,9 @@ void obs::source::handle_destroy(void* p, calldata_t* calldata) noexcept try { P_LOG_ERROR("Unexpected exception in function '%s'.", __FUNCTION_NAME__); } -void obs::source::handle_remove(void* p, calldata_t*) noexcept try { - obs::source* self = reinterpret_cast(p); +void obs::deprecated_source::handle_remove(void* p, calldata_t*) noexcept +try { + obs::deprecated_source* self = reinterpret_cast(p); if (!self->events.remove) { return; } @@ -55,8 +57,9 @@ void obs::source::handle_remove(void* p, calldata_t*) noexcept try { P_LOG_ERROR("Unexpected exception in function '%s'.", __FUNCTION_NAME__); } -void obs::source::handle_save(void* p, calldata_t*) noexcept try { - obs::source* self = reinterpret_cast(p); +void obs::deprecated_source::handle_save(void* p, calldata_t*) noexcept +try { + obs::deprecated_source* self = reinterpret_cast(p); if (!self->events.save) { return; } @@ -67,8 +70,9 @@ void obs::source::handle_save(void* p, calldata_t*) noexcept try { P_LOG_ERROR("Unexpected exception in function '%s'.", __FUNCTION_NAME__); } -void obs::source::handle_load(void* p, calldata_t*) noexcept try { - obs::source* self = reinterpret_cast(p); +void obs::deprecated_source::handle_load(void* p, calldata_t*) noexcept +try { + obs::deprecated_source* self = reinterpret_cast(p); if (!self->events.load) { return; } @@ -79,8 +83,9 @@ void obs::source::handle_load(void* p, calldata_t*) noexcept try { P_LOG_ERROR("Unexpected exception in function '%s'.", __FUNCTION_NAME__); } -void obs::source::handle_activate(void* p, calldata_t*) noexcept try { - obs::source* self = reinterpret_cast(p); +void obs::deprecated_source::handle_activate(void* p, calldata_t*) noexcept +try { + obs::deprecated_source* self = reinterpret_cast(p); if (!self->events.activate) { return; } @@ -91,8 +96,9 @@ void obs::source::handle_activate(void* p, calldata_t*) noexcept try { P_LOG_ERROR("Unexpected exception in function '%s'.", __FUNCTION_NAME__); } -void obs::source::handle_deactivate(void* p, calldata_t*) noexcept try { - obs::source* self = reinterpret_cast(p); +void obs::deprecated_source::handle_deactivate(void* p, calldata_t*) noexcept +try { + obs::deprecated_source* self = reinterpret_cast(p); if (!self->events.deactivate) { return; } @@ -103,8 +109,9 @@ void obs::source::handle_deactivate(void* p, calldata_t*) noexcept try { P_LOG_ERROR("Unexpected exception in function '%s'.", __FUNCTION_NAME__); } -void obs::source::handle_show(void* p, calldata_t*) noexcept try { - obs::source* self = reinterpret_cast(p); +void obs::deprecated_source::handle_show(void* p, calldata_t*) noexcept +try { + obs::deprecated_source* self = reinterpret_cast(p); if (!self->events.show) { return; } @@ -115,8 +122,9 @@ void obs::source::handle_show(void* p, calldata_t*) noexcept try { P_LOG_ERROR("Unexpected exception in function '%s'.", __FUNCTION_NAME__); } -void obs::source::handle_hide(void* p, calldata_t*) noexcept try { - obs::source* self = reinterpret_cast(p); +void obs::deprecated_source::handle_hide(void* p, calldata_t*) noexcept +try { + obs::deprecated_source* self = reinterpret_cast(p); if (!self->events.hide) { return; } @@ -127,8 +135,9 @@ void obs::source::handle_hide(void* p, calldata_t*) noexcept try { P_LOG_ERROR("Unexpected exception in function '%s'.", __FUNCTION_NAME__); } -void obs::source::handle_enable(void* p, calldata_t* calldata) noexcept try { - obs::source* self = reinterpret_cast(p); +void obs::deprecated_source::handle_enable(void* p, calldata_t* calldata) noexcept +try { + obs::deprecated_source* self = reinterpret_cast(p); if (!self->events.enable) { return; } @@ -145,8 +154,9 @@ void obs::source::handle_enable(void* p, calldata_t* calldata) noexcept try { P_LOG_ERROR("Unexpected exception in function '%s'.", __FUNCTION_NAME__); } -void obs::source::handle_push_to_mute_changed(void* p, calldata_t* calldata) noexcept try { - obs::source* self = reinterpret_cast(p); +void obs::deprecated_source::handle_push_to_mute_changed(void* p, calldata_t* calldata) noexcept +try { + obs::deprecated_source* self = reinterpret_cast(p); if (!self->events.push_to_mute_changed) { return; } @@ -163,8 +173,9 @@ void obs::source::handle_push_to_mute_changed(void* p, calldata_t* calldata) noe P_LOG_ERROR("Unexpected exception in function '%s'.", __FUNCTION_NAME__); } -void obs::source::handle_push_to_mute_delay(void* p, calldata_t* calldata) noexcept try { - obs::source* self = reinterpret_cast(p); +void obs::deprecated_source::handle_push_to_mute_delay(void* p, calldata_t* calldata) noexcept +try { + obs::deprecated_source* self = reinterpret_cast(p); if (!self->events.push_to_mute_delay) { return; } @@ -181,8 +192,9 @@ void obs::source::handle_push_to_mute_delay(void* p, calldata_t* calldata) noexc P_LOG_ERROR("Unexpected exception in function '%s'.", __FUNCTION_NAME__); } -void obs::source::handle_push_to_talk_changed(void* p, calldata_t* calldata) noexcept try { - obs::source* self = reinterpret_cast(p); +void obs::deprecated_source::handle_push_to_talk_changed(void* p, calldata_t* calldata) noexcept +try { + obs::deprecated_source* self = reinterpret_cast(p); if (!self->events.push_to_talk_changed) { return; } @@ -199,8 +211,9 @@ void obs::source::handle_push_to_talk_changed(void* p, calldata_t* calldata) noe P_LOG_ERROR("Unexpected exception in function '%s'.", __FUNCTION_NAME__); } -void obs::source::handle_push_to_talk_delay(void* p, calldata_t* calldata) noexcept try { - obs::source* self = reinterpret_cast(p); +void obs::deprecated_source::handle_push_to_talk_delay(void* p, calldata_t* calldata) noexcept +try { + obs::deprecated_source* self = reinterpret_cast(p); if (!self->events.push_to_talk_delay) { return; } @@ -217,8 +230,9 @@ void obs::source::handle_push_to_talk_delay(void* p, calldata_t* calldata) noexc P_LOG_ERROR("Unexpected exception in function '%s'.", __FUNCTION_NAME__); } -void obs::source::handle_rename(void* p, calldata_t* calldata) noexcept try { - obs::source* self = reinterpret_cast(p); +void obs::deprecated_source::handle_rename(void* p, calldata_t* calldata) noexcept +try { + obs::deprecated_source* self = reinterpret_cast(p); if (!self->events.enable) { return; } @@ -240,8 +254,9 @@ void obs::source::handle_rename(void* p, calldata_t* calldata) noexcept try { P_LOG_ERROR("Unexpected exception in function '%s'.", __FUNCTION_NAME__); } -void obs::source::handle_update_properties(void* p, calldata_t*) noexcept try { - obs::source* self = reinterpret_cast(p); +void obs::deprecated_source::handle_update_properties(void* p, calldata_t*) noexcept +try { + obs::deprecated_source* self = reinterpret_cast(p); if (!self->events.update_properties) { return; } @@ -252,8 +267,9 @@ void obs::source::handle_update_properties(void* p, calldata_t*) noexcept try { P_LOG_ERROR("Unexpected exception in function '%s'.", __FUNCTION_NAME__); } -void obs::source::handle_update_flags(void* p, calldata_t* calldata) noexcept try { - obs::source* self = reinterpret_cast(p); +void obs::deprecated_source::handle_update_flags(void* p, calldata_t* calldata) noexcept +try { + obs::deprecated_source* self = reinterpret_cast(p); if (!self->events.update_flags) { return; } @@ -270,8 +286,9 @@ void obs::source::handle_update_flags(void* p, calldata_t* calldata) noexcept tr P_LOG_ERROR("Unexpected exception in function '%s'.", __FUNCTION_NAME__); } -void obs::source::handle_mute(void* p, calldata_t* calldata) noexcept try { - obs::source* self = reinterpret_cast(p); +void obs::deprecated_source::handle_mute(void* p, calldata_t* calldata) noexcept +try { + obs::deprecated_source* self = reinterpret_cast(p); if (!self->events.mute) { return; } @@ -288,8 +305,9 @@ void obs::source::handle_mute(void* p, calldata_t* calldata) noexcept try { P_LOG_ERROR("Unexpected exception in function '%s'.", __FUNCTION_NAME__); } -void obs::source::handle_volume(void* p, calldata_t* calldata) noexcept try { - obs::source* self = reinterpret_cast(p); +void obs::deprecated_source::handle_volume(void* p, calldata_t* calldata) noexcept +try { + obs::deprecated_source* self = reinterpret_cast(p); if (!self->events.volume) { return; } @@ -308,8 +326,9 @@ void obs::source::handle_volume(void* p, calldata_t* calldata) noexcept try { P_LOG_ERROR("Unexpected exception in function '%s'.", __FUNCTION_NAME__); } -void obs::source::handle_audio_sync(void* p, calldata_t* calldata) noexcept try { - obs::source* self = reinterpret_cast(p); +void obs::deprecated_source::handle_audio_sync(void* p, calldata_t* calldata) noexcept +try { + obs::deprecated_source* self = reinterpret_cast(p); if (!self->events.audio_sync) { return; } @@ -328,8 +347,9 @@ void obs::source::handle_audio_sync(void* p, calldata_t* calldata) noexcept try P_LOG_ERROR("Unexpected exception in function '%s'.", __FUNCTION_NAME__); } -void obs::source::handle_audio_mixers(void* p, calldata_t* calldata) noexcept try { - obs::source* self = reinterpret_cast(p); +void obs::deprecated_source::handle_audio_mixers(void* p, calldata_t* calldata) noexcept +try { + obs::deprecated_source* self = reinterpret_cast(p); if (!self->events.audio_mixers) { return; } @@ -348,8 +368,9 @@ void obs::source::handle_audio_mixers(void* p, calldata_t* calldata) noexcept tr P_LOG_ERROR("Unexpected exception in function '%s'.", __FUNCTION_NAME__); } -void obs::source::handle_audio_data(void* p, obs_source_t*, const audio_data* audio, bool muted) noexcept try { - obs::source* self = reinterpret_cast(p); +void obs::deprecated_source::handle_audio_data(void* p, obs_source_t*, const audio_data* audio, bool muted) noexcept +try { + obs::deprecated_source* self = reinterpret_cast(p); if (!self->events.audio_data) { return; } @@ -361,8 +382,9 @@ void obs::source::handle_audio_data(void* p, obs_source_t*, const audio_data* au P_LOG_ERROR("Unexpected exception in function '%s'.", __FUNCTION_NAME__); } -void obs::source::handle_filter_add(void* p, calldata_t* calldata) noexcept try { - obs::source* self = reinterpret_cast(p); +void obs::deprecated_source::handle_filter_add(void* p, calldata_t* calldata) noexcept +try { + obs::deprecated_source* self = reinterpret_cast(p); if (!self->events.filter_add) { return; } @@ -379,8 +401,9 @@ void obs::source::handle_filter_add(void* p, calldata_t* calldata) noexcept try P_LOG_ERROR("Unexpected exception in function '%s'.", __FUNCTION_NAME__); } -void obs::source::handle_filter_remove(void* p, calldata_t* calldata) noexcept try { - obs::source* self = reinterpret_cast(p); +void obs::deprecated_source::handle_filter_remove(void* p, calldata_t* calldata) noexcept +try { + obs::deprecated_source* self = reinterpret_cast(p); if (!self->events.filter_remove) { return; } @@ -397,8 +420,9 @@ void obs::source::handle_filter_remove(void* p, calldata_t* calldata) noexcept t P_LOG_ERROR("Unexpected exception in function '%s'.", __FUNCTION_NAME__); } -void obs::source::handle_reorder_filters(void* p, calldata_t*) noexcept try { - obs::source* self = reinterpret_cast(p); +void obs::deprecated_source::handle_reorder_filters(void* p, calldata_t*) noexcept +try { + obs::deprecated_source* self = reinterpret_cast(p); if (!self->events.reorder_filters) { return; } @@ -409,8 +433,9 @@ void obs::source::handle_reorder_filters(void* p, calldata_t*) noexcept try { P_LOG_ERROR("Unexpected exception in function '%s'.", __FUNCTION_NAME__); } -void obs::source::handle_transition_start(void* p, calldata_t*) noexcept try { - obs::source* self = reinterpret_cast(p); +void obs::deprecated_source::handle_transition_start(void* p, calldata_t*) noexcept +try { + obs::deprecated_source* self = reinterpret_cast(p); if (!self->events.transition_start) { return; } @@ -421,8 +446,9 @@ void obs::source::handle_transition_start(void* p, calldata_t*) noexcept try { P_LOG_ERROR("Unexpected exception in function '%s'.", __FUNCTION_NAME__); } -void obs::source::handle_transition_video_stop(void* p, calldata_t*) noexcept try { - obs::source* self = reinterpret_cast(p); +void obs::deprecated_source::handle_transition_video_stop(void* p, calldata_t*) noexcept +try { + obs::deprecated_source* self = reinterpret_cast(p); if (!self->events.transition_video_stop) { return; } @@ -433,8 +459,9 @@ void obs::source::handle_transition_video_stop(void* p, calldata_t*) noexcept tr P_LOG_ERROR("Unexpected exception in function '%s'.", __FUNCTION_NAME__); } -void obs::source::handle_transition_stop(void* p, calldata_t*) noexcept try { - obs::source* self = reinterpret_cast(p); +void obs::deprecated_source::handle_transition_stop(void* p, calldata_t*) noexcept +try { + obs::deprecated_source* self = reinterpret_cast(p); if (!self->events.transition_stop) { return; } @@ -445,7 +472,7 @@ void obs::source::handle_transition_stop(void* p, calldata_t*) noexcept try { P_LOG_ERROR("Unexpected exception in function '%s'.", __FUNCTION_NAME__); } -obs::source::~source() +obs::deprecated_source::~deprecated_source() { #ifdef auto_signal_d #undef auto_signal_d @@ -486,29 +513,29 @@ obs::source::~source() this->_self = nullptr; } -obs::source::source() +obs::deprecated_source::deprecated_source() { #ifdef auto_signal_c #undef auto_signal_c #endif -#define auto_signal_c(SIGNAL) \ - { \ - this->events.SIGNAL.set_listen_callback([this]() noexcept { \ - if (!this->_self) \ - return; \ - auto sh = obs_source_get_signal_handler(this->_self); \ - if (sh) { \ - signal_handler_connect(sh, "" #SIGNAL, obs::source::handle_##SIGNAL, this); \ - } \ - }); \ - this->events.SIGNAL.set_silence_callback([this]() noexcept { \ - if (!this->_self) \ - return; \ - auto sh = obs_source_get_signal_handler(this->_self); \ - if (sh) { \ - signal_handler_disconnect(sh, "" #SIGNAL, obs::source::handle_##SIGNAL, this); \ - } \ - }); \ +#define auto_signal_c(SIGNAL) \ + { \ + this->events.SIGNAL.set_listen_callback([this]() noexcept { \ + if (!this->_self) \ + return; \ + auto sh = obs_source_get_signal_handler(this->_self); \ + if (sh) { \ + signal_handler_connect(sh, "" #SIGNAL, obs::deprecated_source::handle_##SIGNAL, this); \ + } \ + }); \ + this->events.SIGNAL.set_silence_callback([this]() noexcept { \ + if (!this->_self) \ + return; \ + auto sh = obs_source_get_signal_handler(this->_self); \ + if (sh) { \ + signal_handler_disconnect(sh, "" #SIGNAL, obs::deprecated_source::handle_##SIGNAL, this); \ + } \ + }); \ } auto_signal_c(destroy) auto_signal_c(remove) auto_signal_c(save) auto_signal_c(load) auto_signal_c(activate) auto_signal_c(deactivate) auto_signal_c(show) auto_signal_c(hide) auto_signal_c(mute) @@ -526,17 +553,18 @@ obs::source::source() this->events.audio_data.set_listen_callback([this]() noexcept { if (!this->_self) return; - obs_source_add_audio_capture_callback(this->_self, obs::source::handle_audio_data, this); + obs_source_add_audio_capture_callback(this->_self, obs::deprecated_source::handle_audio_data, this); }); this->events.audio_data.set_silence_callback([this]() noexcept { if (!this->_self) return; - obs_source_remove_audio_capture_callback(this->_self, obs::source::handle_audio_data, this); + obs_source_remove_audio_capture_callback(this->_self, obs::deprecated_source::handle_audio_data, this); }); } } -obs::source::source(std::string name, bool ptrack_ownership, bool add_reference) : ::obs::source::source() +obs::deprecated_source::deprecated_source(std::string name, bool ptrack_ownership, bool add_reference) + : ::obs::deprecated_source::deprecated_source() { this->_self = obs_get_source_by_name(name.c_str()); if (!this->_self) { @@ -549,7 +577,8 @@ obs::source::source(std::string name, bool ptrack_ownership, bool add_reference) } } -obs::source::source(obs_source_t* source, bool ptrack_ownership, bool add_reference) : ::obs::source::source() +obs::deprecated_source::deprecated_source(obs_source_t* source, bool ptrack_ownership, bool add_reference) + : ::obs::deprecated_source::deprecated_source() { this->_self = source; if (!this->_self) { @@ -562,7 +591,7 @@ obs::source::source(obs_source_t* source, bool ptrack_ownership, bool add_refere } } -obs::source::source(source const& other) +obs::deprecated_source::deprecated_source(deprecated_source const& other) { this->_self = other._self; this->_track_ownership = other._track_ownership; @@ -605,7 +634,7 @@ obs::source::source(source const& other) #undef auto_signal_c } -obs::source& obs::source::operator=(source const& other) +obs::deprecated_source& obs::deprecated_source::operator=(deprecated_source const& other) { if (this == &other) { return *this; @@ -659,7 +688,8 @@ obs::source& obs::source::operator=(source const& other) return *this; } -obs::source::source(source&& other) : _self(std::move(other._self)), _track_ownership(std::move(other._track_ownership)) +obs::deprecated_source::deprecated_source(deprecated_source&& other) + : _self(std::move(other._self)), _track_ownership(std::move(other._track_ownership)) { // Clean out other source other._self = nullptr; @@ -699,7 +729,7 @@ obs::source::source(source&& other) : _self(std::move(other._self)), _track_owne #undef auto_signal_c } -obs::source& obs::source::operator=(source&& other) +obs::deprecated_source& obs::deprecated_source::operator=(deprecated_source&& other) { if (this != &other) { return *this; @@ -751,7 +781,7 @@ obs::source& obs::source::operator=(source&& other) return *this; } -obs_source_type obs::source::type() +obs_source_type obs::deprecated_source::type() { if (!_self) { return (obs_source_type)-1; @@ -759,7 +789,7 @@ obs_source_type obs::source::type() return obs_source_get_type(_self); } -void* obs::source::type_data() +void* obs::deprecated_source::type_data() { if (!_self) { return nullptr; @@ -767,7 +797,7 @@ void* obs::source::type_data() return obs_source_get_type_data(_self); } -uint32_t obs::source::width() +uint32_t obs::deprecated_source::width() { if (!_self) { return 0; @@ -775,7 +805,7 @@ uint32_t obs::source::width() return obs_source_get_width(_self); } -uint32_t obs::source::height() +uint32_t obs::deprecated_source::height() { if (!_self) { return 0; @@ -783,17 +813,17 @@ uint32_t obs::source::height() return obs_source_get_height(_self); } -bool obs::source::destroyed() +bool obs::deprecated_source::destroyed() { return _self == nullptr; } -void obs::source::clear() +void obs::deprecated_source::clear() { _self = nullptr; } -obs_source_t* obs::source::get() +obs_source_t* obs::deprecated_source::get() { return _self; } diff --git a/source/obs/obs-source.hpp b/source/obs/obs-source.hpp index 678eff9b..adf0ef21 100644 --- a/source/obs/obs-source.hpp +++ b/source/obs/obs-source.hpp @@ -36,7 +36,7 @@ #endif namespace obs { - class source { + class deprecated_source { obs_source_t* _self; bool _track_ownership = false; @@ -69,21 +69,21 @@ namespace obs { static void handle_transition_stop(void* p, calldata_t* calldata) noexcept; public: - virtual ~source(); + virtual ~deprecated_source(); - source(); + deprecated_source(); - source(std::string name, bool track_ownership = true, bool add_reference = true); + deprecated_source(std::string name, bool track_ownership = true, bool add_reference = true); - source(obs_source_t* source, bool track_ownership = true, bool add_reference = false); + deprecated_source(obs_source_t* source, bool track_ownership = true, bool add_reference = false); public /*copy*/: - source(source const& other); - source& operator=(source const& other); + deprecated_source(deprecated_source const& other); + deprecated_source& operator=(deprecated_source const& other); public /*move*/: - source(source&& other); - source& operator=(source&& other); + deprecated_source(deprecated_source&& other); + deprecated_source& operator=(deprecated_source&& other); public: obs_source_type type(); @@ -103,49 +103,49 @@ namespace obs { public: // Events struct { // Destroy and Remove - util::event destroy; - util::event remove; + util::event destroy; + util::event remove; // Saving, Loading and Update - util::event save; - util::event load; - util::event update_properties; + util::event save; + util::event load; + util::event update_properties; // Activate, Deactivate - util::event activate; - util::event deactivate; + util::event activate; + util::event deactivate; // Show Hide - util::event show; - util::event hide; + util::event show; + util::event hide; // Other - util::event enable; - util::event rename; - util::event update_flags; + util::event enable; + util::event rename; + util::event update_flags; // Hotkeys (PtM, PtT) - util::event push_to_mute_changed; - util::event push_to_mute_delay; - util::event push_to_talk_changed; - util::event push_to_talk_delay; + util::event push_to_mute_changed; + util::event push_to_mute_delay; + util::event push_to_talk_changed; + util::event push_to_talk_delay; // Audio - util::event mute; - util::event volume; - util::event audio_sync; - util::event audio_mixers; - util::event audio_data; + util::event mute; + util::event volume; + util::event audio_sync; + util::event audio_mixers; + util::event audio_data; // Filters - util::event filter_add; - util::event filter_remove; - util::event reorder_filters; + util::event filter_add; + util::event filter_remove; + util::event reorder_filters; // Transition - util::event transition_start; - util::event transition_video_stop; - util::event transition_stop; + util::event transition_start; + util::event transition_video_stop; + util::event transition_stop; } events; }; } // namespace obs diff --git a/source/sources/source-mirror.cpp b/source/sources/source-mirror.cpp index d55d5f5e..44f49172 100644 --- a/source/sources/source-mirror.cpp +++ b/source/sources/source-mirror.cpp @@ -94,7 +94,7 @@ void source::mirror::mirror_instance::acquire(std::string source_name) } // It seems everything has worked out, so let's update our state. - _source = std::make_shared(source.get(), true, true); + _source = std::make_shared(source.get(), true, true); _source_name = obs_source_get_name(source.get()); _source_item = std::shared_ptr(item, [](obs_sceneitem_t* ref) { obs_sceneitem_remove(ref); }); @@ -372,12 +372,12 @@ void source::mirror::mirror_instance::enum_all_sources(obs_source_enum_proc_t en } } -void source::mirror::mirror_instance::on_source_rename(obs::source* source, std::string, std::string) +void source::mirror::mirror_instance::on_source_rename(obs::deprecated_source* source, std::string, std::string) { obs_source_save(_self); } -void source::mirror::mirror_instance::on_audio_data(obs::source*, const audio_data* audio, bool) +void source::mirror::mirror_instance::on_audio_data(obs::deprecated_source*, const audio_data* audio, bool) { if (!this->_audio_enabled) { return; diff --git a/source/sources/source-mirror.hpp b/source/sources/source-mirror.hpp index 5ae3842a..5356969f 100644 --- a/source/sources/source-mirror.hpp +++ b/source/sources/source-mirror.hpp @@ -50,8 +50,8 @@ namespace source { class mirror_instance : public obs::source_instance { // Source - std::shared_ptr _source; - std::string _source_name; + std::shared_ptr _source; + std::string _source_name; // Cached Data std::pair _source_size; @@ -110,8 +110,8 @@ namespace source { void audio_output_cb() noexcept; - void on_source_rename(obs::source* source, std::string new_name, std::string old_name); - void on_audio_data(obs::source* source, const audio_data* audio, bool muted); + void on_source_rename(obs::deprecated_source* source, std::string new_name, std::string old_name); + void on_audio_data(obs::deprecated_source* source, const audio_data* audio, bool muted); }; class mirror_factory