This repository has been archived by the owner on Feb 18, 2023. It is now read-only.
forked from adocilesloth/TS3StudioPlugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ts3plugin_settings.c
367 lines (288 loc) · 8.23 KB
/
ts3plugin_settings.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
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
/*******************************************
A Docile Sloth 2016 ([email protected])
*******************************************/
#include <obs-internal.h>
#include "ts3plugin.h"
#include "ts3plugin_settings.h"
#if _WIN32
char* adrs;
int iname;
bool bname;
bool bright;
bool btalker;
int italker;
char* cluid;
char* apikey;
char* prefix;
bool bsuffix;
bool ball;
int iMnD = 0;
char* nameList;
bool needToRun = false;
#else
#include <stdatomic.h>
_Atomic(char*) adrs;
_Atomic(int) iname;
_Atomic(bool) bname;
_Atomic(bool) bright;
_Atomic(bool) btalker;
_Atomic(int) italker;
_Atomic(char*) cluid;
_Atomic(char*) prefix;
_Atomic(bool) bsuffix;
_Atomic(bool) ball;
_Atomic(int) iMnD = 0;
_Atomic(char*) nameList;
_Atomic(bool) needToRun = false;
#endif
bool firstprop = true;
static const char *ts3_plugin_get_name(void *unused)
{
blog(LOG_WARNING, "ts3_plugin_get_name");
UNUSED_PARAMETER(unused);
return obs_module_text("TeamSpeak 3 Overlay");
}
static void *ts3_plugin_create(obs_data_t *settings, obs_source_t *source)
{
blog(LOG_WARNING, "ts3_plugin_create");
struct ts3_overlay *overlay = bzalloc(sizeof(struct ts3_overlay));
overlay->source = source;
const char *text_source_id = "text_ft2_source\0";
overlay->textSource = obs_source_create(text_source_id, text_source_id, settings, NULL);
obs_source_add_active_child(overlay->source, overlay->textSource);
//obs_source_update(overlay->textSource, settings);
//ts3_plugin_update(overlay, settings);
needToRun = true;
if(firstprop)
{
firstprop = false;
obs_properties_t *props = obs_source_properties(overlay->textSource);
//Needed TS3 Stuff
obs_properties_add_text(props, "ts3ip",
obs_module_text("IPV4"), OBS_TEXT_DEFAULT);
obs_data_set_default_string(overlay->textSource, "ts3ip", "127.0.0.1");
obs_properties_add_text(props, "cluid",
obs_module_text("UniqueID"), OBS_TEXT_PASSWORD);
obs_properties_add_text(props, "apikey",
obs_module_text("APIKey"), OBS_TEXT_PASSWORD);
//TS3 Overlay
obs_properties_add_int(props, "num_name",
obs_module_text("NamesToShow"), 0, 100, 1);
obs_data_set_default_int(overlay->textSource, "num_name", 10);
obs_properties_add_bool(props, "speaking_only",
obs_module_text("OnlyShowSpeakers"));
obs_properties_add_int(props, "hide_after",
obs_module_text("HideAfter"), 0, 2000, 1);
obs_properties_add_bool(props, "no_self",
obs_module_text("HideOwnName"));
obs_properties_add_bool(props, "right_of_name",
obs_module_text("SymbolRightOfNames"));
//TS3 Name Changing
obs_properties_add_text(props, "prefix",
obs_module_text("Modifier"), OBS_TEXT_DEFAULT);
obs_data_set_default_string(overlay->textSource, "prefix", "*R*");
obs_properties_add_bool(props, "suffix",
obs_module_text("ModifierAsSuffix"));
obs_properties_add_bool(props, "mute",
obs_module_text("MuteTS3"));
obs_properties_add_bool(props, "deafen",
obs_module_text("DeafenTS3"));
obs_properties_add_bool(props, "all_servers",
obs_module_text("ChangeAllServers"));
}
return overlay;
}
static void ts3_plugin_destroy(void *data)
{
blog(LOG_WARNING, "ts3_plugin_destroy");
needToRun = false;
struct ts3_overlay *overlay = data;
obs_source_remove(overlay->textSource);
obs_source_release(overlay->textSource);
overlay->textSource = NULL;
bfree(overlay->textSource);
overlay = NULL;
bfree(overlay);
}
static void ts3_plugin_update(void *data, obs_data_t *settings)
{
blog(LOG_WARNING, "ts3_plugin_update");
struct ts3_overlay *overlay = data;
obs_source_update(overlay->textSource, settings);
obs_data_set_bool(overlay->textSource, "from_file", false);
}
static uint32_t ts3_plugin_get_width(void *data)
{
struct ts3_overlay *overlay = data;
return obs_source_get_width(overlay->textSource);
}
static uint32_t ts3_plugin_get_height(void *data)
{
struct ts3_overlay *overlay = data;
return obs_source_get_height(overlay->textSource);
}
static void ts3_plugin_render(void *data, gs_effect_t *effect)
{
//blog(LOG_WARNING, "ts3_plugin_render");
struct ts3_overlay *overlay = data;
obs_source_video_render(overlay->textSource);
adrs = obs_data_get_string(overlay->textSource, "ts3ip");
iname = obs_data_get_int(overlay->textSource, "num_name");
bname = obs_data_get_bool(overlay->textSource, "no_self");
bright = obs_data_get_bool(overlay->textSource, "right_of_name");
italker = obs_data_get_int(overlay->textSource, "hide_after");
btalker = obs_data_get_bool(overlay->textSource, "speaking_only");
cluid = obs_data_get_string(overlay->textSource, "cluid");
apikey = obs_data_get_string(overlay->textSource, "apikey");
prefix = obs_data_get_string(overlay->textSource, "prefix");
bsuffix = obs_data_get_bool(overlay->textSource, "suffix");
ball = obs_data_get_bool(overlay->textSource, "all_servers");
bool bM = obs_data_get_bool(overlay->textSource, "mute");
bool bD = obs_data_get_bool(overlay->textSource, "deafen");
if(bM && !bD)
{
iMnD = 1;
}
else if(!bM && bD)
{
iMnD = 2;
}
else if(bM && bD)
{
iMnD = 3;
}
else
{
iMnD = 0;
}
}
static void ts3_plugin_video_tick(void *data, float seconds)
{
//blog(LOG_WARNING, "ts3_plugin_video_tick");
struct ts3_overlay *overlay = data;
if (!obs_source_showing(overlay->source))
{
return;
}
obs_data_set_string(overlay->textSource->context.settings, "text", nameList);
obs_source_update(overlay->textSource, overlay->textSource->context.settings);
}
static obs_properties_t *ts3_plugin_properties(void *data)
{
blog(LOG_WARNING, "ts3_plugin_properties");
struct ts3_overlay *overlay = data;
obs_properties_t *props = obs_source_properties(overlay->textSource);
//Needed TS3 Stuff
obs_properties_add_text(props, "ts3ip",
obs_module_text("IPV4"), OBS_TEXT_DEFAULT);
obs_data_set_default_string(overlay->textSource, "ts3ip", "127.0.0.1");
obs_properties_add_text(props, "cluid",
obs_module_text("UniqueID"), OBS_TEXT_PASSWORD);
obs_properties_add_text(props, "apikey",
obs_module_text("APIKey"), OBS_TEXT_PASSWORD);
//TS3 Overlay
obs_properties_add_int(props, "num_name",
obs_module_text("NamesToShow"), 0, 100, 1);
obs_data_set_default_int(overlay->textSource, "num_name", 10);
obs_properties_add_bool(props, "speaking_only",
obs_module_text("OnlyShowSpeakers"));
obs_properties_add_int(props, "hide_after",
obs_module_text("HideAfter"), 0, 2000, 1);
obs_properties_add_bool(props, "no_self",
obs_module_text("HideOwnName"));
obs_properties_add_bool(props, "right_of_name",
obs_module_text("SymbolRightOfNames"));
//TS3 Name Changing
obs_properties_add_text(props, "prefix",
obs_module_text("Modifier"), OBS_TEXT_DEFAULT);
obs_data_set_default_string(overlay->textSource, "prefix", "*R*");
obs_properties_add_bool(props, "suffix",
obs_module_text("ModifierAsSuffix"));
obs_properties_add_bool(props, "mute",
obs_module_text("MuteTS3"));
obs_properties_add_bool(props, "deafen",
obs_module_text("DeafenTS3"));
obs_properties_add_bool(props, "all_servers",
obs_module_text("ChangeAllServers"));
return props;
}
void enum_active_sources(void *data, obs_source_enum_proc_t enum_callback, void *param) {
struct ts3_overlay *context = data;
enum_callback(context->source, context->textSource, param);
}
struct obs_source_info getInfo()
{
struct obs_source_info ts3_plugin_info = {
.id = "ts3plugin",
.type = OBS_SOURCE_TYPE_INPUT,
.output_flags = OBS_SOURCE_VIDEO,
.get_name = ts3_plugin_get_name,
.create = ts3_plugin_create,
.destroy = ts3_plugin_destroy,
.update = ts3_plugin_update,
.get_width = ts3_plugin_get_width,
.get_height = ts3_plugin_get_height,
.video_render = ts3_plugin_render,
.video_tick = ts3_plugin_video_tick,
.get_properties = ts3_plugin_properties,
.enum_active_sources = enum_active_sources
};
return ts3_plugin_info;
}
bool getNeedToRun()
{
return needToRun;
}
char* getAddress()
{
return adrs;
}
int getNumberOfNames()
{
return iname;
}
bool getHideSelf()
{
return bname;
}
bool getRightOfSymbol()
{
return bright;
}
bool getOnlyShowTalker()
{
return btalker;
}
int getHideNameAfter()
{
return italker;
}
void sendOverlay(const char* names)
{
nameList = names;
return;
}
char* getCluid()
{
return cluid;
}
char* getAPIKey()
{
return apikey;
}
char* getPrefix()
{
return prefix;
}
bool getSuffix()
{
return bsuffix;
}
bool getAllServers()
{
return ball;
}
int getMuteAndDeafen()
{
return iMnD;
}