Skip to content

Commit

Permalink
move directshow enable move per property
Browse files Browse the repository at this point in the history
  • Loading branch information
exeldro committed Nov 23, 2022
1 parent 5d9f524 commit 8208c81
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 13 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ else()
cmake_minimum_required(VERSION 3.18)
endif()

project(move-transition VERSION 2.7.1)
project(move-transition VERSION 2.7.2)
set(PROJECT_FULL_NAME "Move Transition")

# Set new UUIDs when you start to create a new plugin.
Expand Down
2 changes: 1 addition & 1 deletion buildspec.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,5 @@
}
},
"name": "move-transition",
"version": "2.7.1"
"version": "2.7.2"
}
1 change: 1 addition & 0 deletions move-action-filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ static obs_properties_t *move_action_properties(void *data)
void move_action_defaults(obs_data_t *settings)
{
obs_data_set_default_bool(settings, S_ENABLED_MATCH_MOVING, true);
obs_data_set_default_int(settings, S_DURATION, 300);
}

void move_action_tick(void *data, float seconds)
Expand Down
70 changes: 59 additions & 11 deletions move-directshow-filter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ struct directshow_property {
long int_from;
long int_to;
long flags;
bool move_enabled;
};

struct move_directshow_info {
Expand Down Expand Up @@ -156,28 +157,39 @@ void LoadProperties(move_directshow_info *move_directshow, obs_data_t *settings,
snprintf(number, 4, "%i", i);
std::string prop_id = "camera_control_";
prop_id += number;
std::string prop_enabled = prop_id;
prop_enabled += "_enabled";
if (m ==
move_directshow->camControlProps->end()) {
struct directshow_property p;
p.int_from = val;
if (settings)
if (settings) {
p.int_to =
(long)obs_data_get_int(
settings,
prop_id.c_str());
else
p.move_enabled = obs_data_get_bool(
settings,
prop_enabled.c_str());
} else {
p.int_to = val;

}
move_directshow->camControlProps
->emplace(i, p);
} else {
if (overwrite)
m->second.int_from = val;
if (settings)
if (settings) {
m->second.int_to =
(long)obs_data_get_int(
settings,
prop_id.c_str());
m->second.move_enabled =
obs_data_get_bool(
settings,
prop_enabled
.c_str());
}
}
} else if (m !=
move_directshow->camControlProps->end()) {
Expand All @@ -196,29 +208,40 @@ void LoadProperties(move_directshow_info *move_directshow, obs_data_t *settings,
snprintf(number, 4, "%i", i);
std::string prop_id = "video_proc_amp_";
prop_id += number;

std::string prop_enabled = prop_id;
prop_enabled += "_enabled";
if (m == move_directshow->procAmpProps->end()) {
struct directshow_property p;
p.int_from = val;
if (settings)
if (settings) {
p.int_to =
(long)obs_data_get_int(
settings,
prop_id.c_str());
else
p.move_enabled = obs_data_get_bool(
settings,
prop_enabled.c_str());
} else {
p.int_to = val;
}

move_directshow->procAmpProps->emplace(
i, p);

} else {
if (overwrite)
m->second.int_from = val;
if (settings)
if (settings) {
m->second.int_to =
(long)obs_data_get_int(
settings,
prop_id.c_str());
m->second.move_enabled =
obs_data_get_bool(
settings,
prop_enabled
.c_str());
}
}
} else if (m != move_directshow->procAmpProps->end()) {
move_directshow->procAmpProps->erase(m);
Expand Down Expand Up @@ -510,10 +533,19 @@ static bool device_modified(void *priv, obs_properties_t *props,
p, min, max, delta);
}
} else {
std::string prop_enabled = prop_id;
prop_enabled += "_enabled";
obs_properties_t *prop_group =
obs_properties_create();
obs_properties_add_int_slider(
prop_group, prop_id.c_str(),
name.c_str(), min, max, delta);
obs_properties_add_group(
camcontrolGroup,
prop_id.c_str(), name.c_str(),
min, max, delta);
prop_enabled.c_str(),
name.c_str(),
OBS_GROUP_CHECKABLE,
prop_group);
}
}
}
Expand Down Expand Up @@ -571,9 +603,20 @@ static bool device_modified(void *priv, obs_properties_t *props,
p, min, max, delta);
}
} else {
std::string prop_enabled = prop_id;
prop_enabled += "_enabled";
obs_properties_t *prop_group =
obs_properties_create();
obs_properties_add_int_slider(
procAmpGroup, prop_id.c_str(),
prop_group, prop_id.c_str(),
name.c_str(), min, max, delta);

obs_properties_add_group(
procAmpGroup,
prop_enabled.c_str(),
name.c_str(),
OBS_GROUP_CHECKABLE,
prop_group);
}
}
}
Expand Down Expand Up @@ -833,6 +876,8 @@ void move_directshow_tick(void *data, float seconds)
move_directshow->camControlProps->begin();
prop != move_directshow->camControlProps->end();
++prop) {
if (!prop->second.move_enabled)
continue;
const long value_int =
(long long)((1.0f -
t) * (float)(prop->second
Expand All @@ -852,6 +897,8 @@ void move_directshow_tick(void *data, float seconds)
for (auto prop = move_directshow->procAmpProps->begin();
prop != move_directshow->procAmpProps->end();
++prop) {
if (!prop->second.move_enabled)
continue;
const long value_int =
(long long)((1.0f -
t) * (float)(prop->second
Expand All @@ -877,6 +924,7 @@ void move_directshow_tick(void *data, float seconds)
void move_directshow_defaults(obs_data_t *settings)
{
obs_data_set_default_bool(settings, S_ENABLED_MATCH_MOVING, true);
obs_data_set_default_int(settings, S_DURATION, 300);
}

extern "C" {
Expand Down

0 comments on commit 8208c81

Please sign in to comment.