source-mirror: Add support for scenes and fix last commit
This commit is contained in:
parent
c084a0bfd0
commit
b5339b4429
|
|
@ -25,6 +25,7 @@
|
||||||
#include <bitset>
|
#include <bitset>
|
||||||
#include <media-io/audio-io.h>
|
#include <media-io/audio-io.h>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
#include "obs-tools.hpp"
|
||||||
|
|
||||||
#define S_SOURCE_MIRROR "Source.Mirror"
|
#define S_SOURCE_MIRROR "Source.Mirror"
|
||||||
#define P_SOURCE "Source.Mirror.Source"
|
#define P_SOURCE "Source.Mirror.Source"
|
||||||
|
|
@ -128,6 +129,7 @@ static bool UpdateSourceListCB(void *ptr, obs_source_t* src) {
|
||||||
static void UpdateSourceList(obs_property_t* p) {
|
static void UpdateSourceList(obs_property_t* p) {
|
||||||
obs_property_list_clear(p);
|
obs_property_list_clear(p);
|
||||||
obs_enum_sources(UpdateSourceListCB, p);
|
obs_enum_sources(UpdateSourceListCB, p);
|
||||||
|
obs_enum_scenes(UpdateSourceListCB, p);
|
||||||
}
|
}
|
||||||
|
|
||||||
obs_properties_t * Source::MirrorAddon::get_properties(void *) {
|
obs_properties_t * Source::MirrorAddon::get_properties(void *) {
|
||||||
|
|
@ -305,13 +307,21 @@ void Source::Mirror::update(obs_data_t* data) {
|
||||||
}
|
}
|
||||||
obs_source_t* source = obs_get_source_by_name(sourceName);
|
obs_source_t* source = obs_get_source_by_name(sourceName);
|
||||||
if (source) {
|
if (source) {
|
||||||
m_sceneitem = obs_scene_add(m_scene, source);
|
bool allow = true;
|
||||||
try {
|
if (strcmp(obs_source_get_id(source), "scene") == 0) {
|
||||||
m_audioCapture = std::make_unique<obs::audio_capture>(source);
|
if (obs::tools::scene_contains_source(obs_scene_from_source(source), m_source)) {
|
||||||
m_audioCapture->set_callback(std::bind(&Source::Mirror::audio_capture_cb, this,
|
allow = false;
|
||||||
std::placeholders::_1, std::placeholders::_2,
|
}
|
||||||
std::placeholders::_3));
|
}
|
||||||
} catch(...) {
|
if (allow) {
|
||||||
|
m_sceneitem = obs_scene_add(m_scene, source);
|
||||||
|
try {
|
||||||
|
m_audioCapture = std::make_unique<obs::audio_capture>(source);
|
||||||
|
m_audioCapture->set_callback(std::bind(&Source::Mirror::audio_capture_cb, this,
|
||||||
|
std::placeholders::_1, std::placeholders::_2,
|
||||||
|
std::placeholders::_3));
|
||||||
|
} catch(...) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
obs_source_release(source);
|
obs_source_release(source);
|
||||||
}
|
}
|
||||||
|
|
@ -381,7 +391,7 @@ void Source::Mirror::update(obs_data_t* data) {
|
||||||
|
|
||||||
void Source::Mirror::activate() {
|
void Source::Mirror::activate() {
|
||||||
m_active = true;
|
m_active = true;
|
||||||
if (!m_mirrorSource) {
|
if (!m_sceneitem) {
|
||||||
obs_data_t* ref = obs_source_get_settings(m_source);
|
obs_data_t* ref = obs_source_get_settings(m_source);
|
||||||
update(ref);
|
update(ref);
|
||||||
obs_data_release(ref);
|
obs_data_release(ref);
|
||||||
|
|
@ -405,8 +415,8 @@ static inline void mix_audio(float *p_out, float *p_in,
|
||||||
void Source::Mirror::video_tick(float time) {
|
void Source::Mirror::video_tick(float time) {
|
||||||
m_tick += time;
|
m_tick += time;
|
||||||
|
|
||||||
if (m_mirrorSource) {
|
if (m_sceneitem) {
|
||||||
m_mirrorName = obs_source_get_name(m_mirrorSource->get_object());
|
m_mirrorName = obs_source_get_name(obs_sceneitem_get_source(m_sceneitem));
|
||||||
} else {
|
} else {
|
||||||
if (m_tick > 0.1f) {
|
if (m_tick > 0.1f) {
|
||||||
obs_data_t* ref = obs_source_get_settings(m_source);
|
obs_data_t* ref = obs_source_get_settings(m_source);
|
||||||
|
|
@ -439,7 +449,7 @@ void Source::Mirror::video_render(gs_effect_t*) {
|
||||||
// Store original Source Texture
|
// Store original Source Texture
|
||||||
std::shared_ptr<gs::texture> tex;
|
std::shared_ptr<gs::texture> tex;
|
||||||
try {
|
try {
|
||||||
tex = m_mirrorSource->render(sw, sh);
|
tex = m_source_texture->render(sw, sh);
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -478,7 +488,7 @@ void Source::Mirror::video_render(gs_effect_t*) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
obs_source_video_render(m_mirrorSource->get_object());
|
obs_source_video_render(m_source_texture->get_object());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -526,7 +536,7 @@ void Source::Mirror::audio_output_cb() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Source::Mirror::enum_active_sources(obs_source_enum_proc_t enum_callback, void *param) {
|
void Source::Mirror::enum_active_sources(obs_source_enum_proc_t enum_callback, void *param) {
|
||||||
if (m_mirrorSource) {
|
if (m_sceneitem) {
|
||||||
enum_callback(m_source, m_mirrorSource->get_object(), param);
|
enum_callback(m_source, obs_sceneitem_get_source(m_sceneitem), param);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue