forked from exeldro/obs-move-transition
-
Notifications
You must be signed in to change notification settings - Fork 0
/
move-transition-override-filter.c
227 lines (196 loc) · 7.73 KB
/
move-transition-override-filter.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
#include "move-transition.h"
#include <obs-module.h>
struct move_filter_info {
obs_source_t *source;
};
static void *move_filter_create(obs_data_t *settings, obs_source_t *source)
{
struct move_filter_info *move_filter =
bzalloc(sizeof(struct move_filter_info));
move_filter->source = source;
return move_filter;
}
static void move_filter_destroy(void *data)
{
struct move_filter_info *move_filter = data;
bfree(move_filter);
}
void prop_list_add_easings(obs_property_t *p);
void prop_list_add_easing_functions(obs_property_t *p);
void prop_list_add_positions(obs_property_t *p);
void prop_list_add_transitions(obs_property_t *p);
void prop_list_add_scales(obs_property_t *p);
bool prop_list_add_source(obs_scene_t *scene, obs_sceneitem_t *item, void *data)
{
obs_property_t *p = data;
const char *name = obs_source_get_name(obs_sceneitem_get_source(item));
obs_property_list_add_string(p, name, name);
return true;
}
static obs_properties_t *move_filter_properties(void *data)
{
struct move_filter_info *move_filter = data;
obs_properties_t *ppts = obs_properties_create();
obs_property_t *p;
obs_source_t *parent = obs_filter_get_parent(move_filter->source);
obs_scene_t *scene = obs_scene_from_source(parent);
if (scene) {
p = obs_properties_add_list(ppts, S_SOURCE,
obs_module_text("Source"),
OBS_COMBO_TYPE_LIST,
OBS_COMBO_FORMAT_STRING);
obs_scene_enum_items(scene, prop_list_add_source, p);
}
//Matched items
obs_properties_t *group = obs_properties_create();
p = obs_properties_add_list(group, S_EASING_MATCH,
obs_module_text("Easing"),
OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT);
obs_property_list_add_int(p, obs_module_text("NoOverride"),
NO_OVERRIDE);
prop_list_add_easings(p);
p = obs_properties_add_list(group, S_EASING_FUNCTION_MATCH,
obs_module_text("EasingFunction"),
OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT);
obs_property_list_add_int(p, obs_module_text("NoOverride"),
NO_OVERRIDE);
prop_list_add_easing_functions(p);
p = obs_properties_add_list(group, S_TRANSITION_MATCH,
obs_module_text("Transition"),
OBS_COMBO_TYPE_LIST,
OBS_COMBO_FORMAT_STRING);
prop_list_add_transitions(p);
p = obs_properties_add_list(group, S_TRANSITION_SCALE,
obs_module_text("TransitionScaleType"),
OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT);
obs_property_list_add_int(p, obs_module_text("NoOverride"),
NO_OVERRIDE);
prop_list_add_scales(p);
obs_properties_t *curve_group = obs_properties_create();
obs_properties_add_float_slider(curve_group, S_CURVE_MATCH,
obs_module_text("Curve"), -2.0, 2.0,
0.01);
obs_properties_add_group(group, S_CURVE_OVERRIDE_MATCH,
obs_module_text("CurveOverride"),
OBS_GROUP_CHECKABLE, curve_group);
obs_properties_add_group(ppts, S_MOVE_MATCH,
obs_module_text("MoveMatch"), OBS_GROUP_NORMAL,
group);
//Move in
group = obs_properties_create();
p = obs_properties_add_list(group, S_EASING_IN,
obs_module_text("Easing"),
OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT);
obs_property_list_add_int(p, obs_module_text("NoOverride"),
NO_OVERRIDE);
prop_list_add_easings(p);
p = obs_properties_add_list(group, S_EASING_FUNCTION_IN,
obs_module_text("EasingFunction"),
OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT);
obs_property_list_add_int(p, obs_module_text("NoOverride"),
NO_OVERRIDE);
prop_list_add_easing_functions(p);
p = obs_properties_add_list(group, S_ZOOM_IN, obs_module_text("Zoom"),
OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT);
obs_property_list_add_int(p, obs_module_text("NoOverride"),
NO_OVERRIDE);
obs_property_list_add_int(p, obs_module_text("No"), ZOOM_NO);
obs_property_list_add_int(p, obs_module_text("Yes"), ZOOM_YES);
p = obs_properties_add_list(group, S_POSITION_IN,
obs_module_text("Position"),
OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT);
obs_property_list_add_int(p, obs_module_text("NoOverride"),
NO_OVERRIDE);
prop_list_add_positions(p);
p = obs_properties_add_list(group, S_TRANSITION_IN,
obs_module_text("Transition"),
OBS_COMBO_TYPE_LIST,
OBS_COMBO_FORMAT_STRING);
prop_list_add_transitions(p);
curve_group = obs_properties_create();
obs_properties_add_float_slider(curve_group, S_CURVE_IN,
obs_module_text("Curve"), -2.0, 2.0,
0.01);
obs_properties_add_group(group, S_CURVE_OVERRIDE_IN,
obs_module_text("CurveOverride"),
OBS_GROUP_CHECKABLE, curve_group);
obs_properties_add_group(ppts, S_MOVE_IN, obs_module_text("MoveIn"),
OBS_GROUP_NORMAL, group);
//Move out
group = obs_properties_create();
p = obs_properties_add_list(group, S_EASING_OUT,
obs_module_text("Easing"),
OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT);
obs_property_list_add_int(p, obs_module_text("NoOverride"),
NO_OVERRIDE);
prop_list_add_easings(p);
p = obs_properties_add_list(group, S_EASING_FUNCTION_OUT,
obs_module_text("EasingFunction"),
OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT);
obs_property_list_add_int(p, obs_module_text("NoOverride"),
NO_OVERRIDE);
prop_list_add_easing_functions(p);
p = obs_properties_add_list(group, S_ZOOM_OUT, obs_module_text("Zoom"),
OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT);
obs_property_list_add_int(p, obs_module_text("NoOverride"),
NO_OVERRIDE);
obs_property_list_add_int(p, obs_module_text("No"), ZOOM_NO);
obs_property_list_add_int(p, obs_module_text("Yes"), ZOOM_YES);
p = obs_properties_add_list(group, S_POSITION_OUT,
obs_module_text("Position"),
OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT);
obs_property_list_add_int(p, obs_module_text("NoOverride"),
NO_OVERRIDE);
prop_list_add_positions(p);
p = obs_properties_add_list(group, S_TRANSITION_OUT,
obs_module_text("Transition"),
OBS_COMBO_TYPE_LIST,
OBS_COMBO_FORMAT_STRING);
prop_list_add_transitions(p);
curve_group = obs_properties_create();
obs_properties_add_float_slider(curve_group, S_CURVE_OUT,
obs_module_text("Curve"), -2.0, 2.0,
0.01);
obs_properties_add_group(group, S_CURVE_OVERRIDE_OUT,
obs_module_text("CurveOverride"),
OBS_GROUP_CHECKABLE, curve_group);
obs_properties_add_group(ppts, S_MOVE_OUT, obs_module_text("MoveOut"),
OBS_GROUP_NORMAL, group);
return ppts;
}
void move_filter_defaults(obs_data_t *settings)
{
obs_data_set_default_int(settings, S_EASING_MATCH, NO_OVERRIDE);
obs_data_set_default_int(settings, S_EASING_IN, NO_OVERRIDE);
obs_data_set_default_int(settings, S_EASING_OUT, NO_OVERRIDE);
obs_data_set_default_int(settings, S_EASING_FUNCTION_MATCH,
NO_OVERRIDE);
obs_data_set_default_int(settings, S_EASING_FUNCTION_IN, NO_OVERRIDE);
obs_data_set_default_int(settings, S_EASING_FUNCTION_OUT, NO_OVERRIDE);
obs_data_set_default_int(settings, S_POSITION_IN, NO_OVERRIDE);
obs_data_set_default_int(settings, S_ZOOM_IN, NO_OVERRIDE);
obs_data_set_default_int(settings, S_POSITION_OUT, NO_OVERRIDE);
obs_data_set_default_int(settings, S_ZOOM_OUT, NO_OVERRIDE);
obs_data_set_default_int(settings, S_TRANSITION_SCALE, NO_OVERRIDE);
}
void move_filter_video_render(void *data, gs_effect_t *effect)
{
UNUSED_PARAMETER(effect);
struct move_filter_info *filter = data;
obs_source_skip_video_filter(filter->source);
}
static const char *move_filter_get_name(void *type_data)
{
UNUSED_PARAMETER(type_data);
return obs_module_text("MoveTransitionOverrideFilter");
}
struct obs_source_info move_transition_override_filter = {
.id = "move_transition_override_filter",
.type = OBS_SOURCE_TYPE_FILTER,
.output_flags = OBS_SOURCE_VIDEO,
.get_name = move_filter_get_name,
.create = move_filter_create,
.destroy = move_filter_destroy,
.get_properties = move_filter_properties,
.get_defaults = move_filter_defaults,
.video_render = move_filter_video_render};