mirror of
https://github.com/Xaymar/obs-StreamFX
synced 2024-11-11 06:15:05 +00:00
source-mirror: Allow overriding audio layout
This commit is contained in:
parent
54856566d4
commit
2ca15bb28c
3 changed files with 47 additions and 6 deletions
|
@ -265,6 +265,15 @@ Source.Mirror.Source.Size="Source Size"
|
||||||
Source.Mirror.Source.Size.Description="The size of the source being mirrored. (Automatically updated)"
|
Source.Mirror.Source.Size.Description="The size of the source being mirrored. (Automatically updated)"
|
||||||
Source.Mirror.Source.Audio="Enable Audio"
|
Source.Mirror.Source.Audio="Enable Audio"
|
||||||
Source.Mirror.Source.Audio.Description="Enables audio mirroring from this source."
|
Source.Mirror.Source.Audio.Description="Enables audio mirroring from this source."
|
||||||
|
Source.Mirror.Audio.Layout="Audio Layout"
|
||||||
|
Source.Mirror.Audio.Layout.Unknown="Unknown"
|
||||||
|
Source.Mirror.Audio.Layout.Mono="Mono"
|
||||||
|
Source.Mirror.Audio.Layout.Stereo="Stereo"
|
||||||
|
Source.Mirror.Audio.Layout.StereoLFE="Stereo with LFE"
|
||||||
|
Source.Mirror.Audio.Layout.Quadraphonic="Quadraphonic"
|
||||||
|
Source.Mirror.Audio.Layout.QuadraphonicLFE="Quadraphonic With LFE"
|
||||||
|
Source.Mirror.Audio.Layout.Surround="Surround"
|
||||||
|
Source.Mirror.Audio.Layout.FullSurround="Full Surround"
|
||||||
Source.Mirror.Scaling="Rescale Source"
|
Source.Mirror.Scaling="Rescale Source"
|
||||||
Source.Mirror.Scaling.Description="Should the source be rescaled?"
|
Source.Mirror.Scaling.Description="Should the source be rescaled?"
|
||||||
Source.Mirror.Scaling.Method="Filter"
|
Source.Mirror.Scaling.Method="Filter"
|
||||||
|
|
|
@ -42,6 +42,8 @@
|
||||||
#define P_SOURCE "Source.Mirror.Source"
|
#define P_SOURCE "Source.Mirror.Source"
|
||||||
#define P_SOURCE_SIZE "Source.Mirror.Source.Size"
|
#define P_SOURCE_SIZE "Source.Mirror.Source.Size"
|
||||||
#define P_SOURCE_AUDIO "Source.Mirror.Source.Audio"
|
#define P_SOURCE_AUDIO "Source.Mirror.Source.Audio"
|
||||||
|
#define ST_AUDIO_LAYOUT S_SOURCE_MIRROR ".Audio.Layout"
|
||||||
|
#define ST_AUDIO_LAYOUT_(x) ST_AUDIO_LAYOUT "." D_VSTR(x)
|
||||||
#define P_SCALING "Source.Mirror.Scaling"
|
#define P_SCALING "Source.Mirror.Scaling"
|
||||||
#define P_SCALING_METHOD "Source.Mirror.Scaling.Method"
|
#define P_SCALING_METHOD "Source.Mirror.Scaling.Method"
|
||||||
#define P_SCALING_METHOD_POINT "Source.Mirror.Scaling.Method.Point"
|
#define P_SCALING_METHOD_POINT "Source.Mirror.Scaling.Method.Point"
|
||||||
|
@ -119,6 +121,7 @@ void source::mirror::mirror_factory::get_defaults(obs_data_t* data)
|
||||||
{
|
{
|
||||||
obs_data_set_default_string(data, P_SOURCE, "");
|
obs_data_set_default_string(data, P_SOURCE, "");
|
||||||
obs_data_set_default_bool(data, P_SOURCE_AUDIO, false);
|
obs_data_set_default_bool(data, P_SOURCE_AUDIO, false);
|
||||||
|
obs_data_set_default_int(data, ST_AUDIO_LAYOUT, static_cast<int64_t>(SPEAKERS_UNKNOWN));
|
||||||
obs_data_set_default_bool(data, P_SCALING, false);
|
obs_data_set_default_bool(data, P_SCALING, false);
|
||||||
obs_data_set_default_string(data, P_SCALING_SIZE, "100x100");
|
obs_data_set_default_string(data, P_SCALING_SIZE, "100x100");
|
||||||
obs_data_set_default_int(data, P_SCALING_METHOD, (int64_t)obs_scale_type::OBS_SCALE_BILINEAR);
|
obs_data_set_default_int(data, P_SCALING_METHOD, (int64_t)obs_scale_type::OBS_SCALE_BILINEAR);
|
||||||
|
@ -142,6 +145,12 @@ bool source::mirror::mirror_factory::modified_properties(obs_properties_t* pr, o
|
||||||
obs_source_release(target);
|
obs_source_release(target);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (obs_properties_get(pr, P_SOURCE_AUDIO) == p) {
|
||||||
|
bool show = obs_data_get_bool(data, P_SOURCE_AUDIO);
|
||||||
|
obs_property_set_visible(obs_properties_get(pr, ST_AUDIO_LAYOUT), show);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (obs_properties_get(pr, P_SCALING) == p) {
|
if (obs_properties_get(pr, P_SCALING) == p) {
|
||||||
bool show = obs_data_get_bool(data, P_SCALING);
|
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_METHOD), show);
|
||||||
|
@ -208,6 +217,19 @@ obs_properties_t* source::mirror::mirror_factory::get_properties(void*)
|
||||||
|
|
||||||
p = obs_properties_add_bool(pr, P_SOURCE_AUDIO, P_TRANSLATE(P_SOURCE_AUDIO));
|
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)));
|
obs_property_set_long_description(p, P_TRANSLATE(P_DESC(P_SOURCE_AUDIO)));
|
||||||
|
obs_property_set_modified_callback(p, modified_properties);
|
||||||
|
p = obs_properties_add_list(pr, ST_AUDIO_LAYOUT, P_TRANSLATE(ST_AUDIO_LAYOUT), OBS_COMBO_TYPE_LIST,
|
||||||
|
OBS_COMBO_FORMAT_INT);
|
||||||
|
obs_property_list_add_int(p, P_TRANSLATE(ST_AUDIO_LAYOUT_(Unknown)), static_cast<int64_t>(SPEAKERS_UNKNOWN));
|
||||||
|
obs_property_list_add_int(p, P_TRANSLATE(ST_AUDIO_LAYOUT_(Mono)), static_cast<int64_t>(SPEAKERS_MONO));
|
||||||
|
obs_property_list_add_int(p, P_TRANSLATE(ST_AUDIO_LAYOUT_(Stereo)), static_cast<int64_t>(SPEAKERS_STEREO));
|
||||||
|
obs_property_list_add_int(p, P_TRANSLATE(ST_AUDIO_LAYOUT_(StereoLFE)), static_cast<int64_t>(SPEAKERS_2POINT1));
|
||||||
|
obs_property_list_add_int(p, P_TRANSLATE(ST_AUDIO_LAYOUT_(Quadraphonic)), static_cast<int64_t>(SPEAKERS_4POINT0));
|
||||||
|
obs_property_list_add_int(p, P_TRANSLATE(ST_AUDIO_LAYOUT_(QuadraphonicLFE)),
|
||||||
|
static_cast<int64_t>(SPEAKERS_4POINT1));
|
||||||
|
obs_property_list_add_int(p, P_TRANSLATE(ST_AUDIO_LAYOUT_(Surround)), static_cast<int64_t>(SPEAKERS_5POINT1));
|
||||||
|
obs_property_list_add_int(p, P_TRANSLATE(ST_AUDIO_LAYOUT_(FullSurround)), static_cast<int64_t>(SPEAKERS_7POINT1));
|
||||||
|
obs_property_set_long_description(p, P_TRANSLATE(P_DESC(ST_AUDIO_LAYOUT)));
|
||||||
|
|
||||||
p = obs_properties_add_bool(pr, P_SCALING, P_TRANSLATE(P_SCALING));
|
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_long_description(p, P_TRANSLATE(P_DESC(P_SCALING)));
|
||||||
|
@ -472,6 +494,7 @@ void source::mirror::mirror_instance::update(obs_data_t* data)
|
||||||
|
|
||||||
// Audio
|
// Audio
|
||||||
this->m_audio_enabled = obs_data_get_bool(data, P_SOURCE_AUDIO);
|
this->m_audio_enabled = obs_data_get_bool(data, P_SOURCE_AUDIO);
|
||||||
|
this->m_audio_layout = static_cast<speaker_layout>(obs_data_get_int(data, ST_AUDIO_LAYOUT));
|
||||||
|
|
||||||
// Rescaling
|
// Rescaling
|
||||||
this->m_rescale_enabled = obs_data_get_bool(data, P_SCALING);
|
this->m_rescale_enabled = obs_data_get_bool(data, P_SCALING);
|
||||||
|
@ -505,11 +528,10 @@ void source::mirror::mirror_instance::update(obs_data_t* data)
|
||||||
}
|
}
|
||||||
|
|
||||||
this->m_rescale_keep_orig_size = obs_data_get_bool(data, P_SCALING_TRANSFORMKEEPORIGINAL);
|
this->m_rescale_keep_orig_size = obs_data_get_bool(data, P_SCALING_TRANSFORMKEEPORIGINAL);
|
||||||
this->m_rescale_type = (obs_scale_type)obs_data_get_int(data, P_SCALING_METHOD);
|
this->m_rescale_type = static_cast<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);
|
this->m_rescale_bounds = static_cast<obs_bounds_type>(obs_data_get_int(data, P_SCALING_BOUNDS));
|
||||||
this->m_rescale_alignment = obs_data_get_int(data, P_SCALING_ALIGNMENT);
|
this->m_rescale_alignment = static_cast<int32_t>(obs_data_get_int(data, P_SCALING_ALIGNMENT));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void source::mirror::mirror_instance::activate()
|
void source::mirror::mirror_instance::activate()
|
||||||
|
@ -587,6 +609,11 @@ void source::mirror::mirror_instance::video_render(gs_effect_t* effect)
|
||||||
render_height = m_rescale_height;
|
render_height = m_rescale_height;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!render_width || !render_height) {
|
||||||
|
// Don't render if width or height are 0.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
m_scene_texture = this->m_scene_texture_renderer->render(render_width, render_height);
|
m_scene_texture = this->m_scene_texture_renderer->render(render_width, render_height);
|
||||||
m_scene_rendered = true;
|
m_scene_rendered = true;
|
||||||
|
@ -719,8 +746,12 @@ void source::mirror::mirror_instance::on_audio_data(obs::source*, const audio_da
|
||||||
mad->audio.frames = audio->frames;
|
mad->audio.frames = audio->frames;
|
||||||
mad->audio.timestamp = audio->timestamp;
|
mad->audio.timestamp = audio->timestamp;
|
||||||
mad->audio.samples_per_sec = aoi->samples_per_sec;
|
mad->audio.samples_per_sec = aoi->samples_per_sec;
|
||||||
|
if (this->m_audio_layout != SPEAKERS_UNKNOWN) {
|
||||||
|
mad->audio.speakers = this->m_audio_layout;
|
||||||
|
} else {
|
||||||
mad->audio.speakers = aoi->speakers;
|
mad->audio.speakers = aoi->speakers;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
{ // Push used audio data element.
|
{ // Push used audio data element.
|
||||||
std::lock_guard<std::mutex> capture_lock(this->m_audio_lock_capturer);
|
std::lock_guard<std::mutex> capture_lock(this->m_audio_lock_capturer);
|
||||||
|
|
|
@ -110,6 +110,7 @@ namespace source {
|
||||||
std::mutex m_audio_lock_capturer;
|
std::mutex m_audio_lock_capturer;
|
||||||
std::queue<std::shared_ptr<mirror_audio_data>> m_audio_data_queue;
|
std::queue<std::shared_ptr<mirror_audio_data>> m_audio_data_queue;
|
||||||
std::queue<std::shared_ptr<mirror_audio_data>> m_audio_data_free_queue;
|
std::queue<std::shared_ptr<mirror_audio_data>> m_audio_data_free_queue;
|
||||||
|
speaker_layout m_audio_layout;
|
||||||
|
|
||||||
// Input
|
// Input
|
||||||
std::shared_ptr<obs::source> m_source;
|
std::shared_ptr<obs::source> m_source;
|
||||||
|
|
Loading…
Reference in a new issue