yolobs-studio/test/test-input/test-filter.c

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

73 lines
1.4 KiB
C
Raw Normal View History

2016-02-23 23:16:51 +00:00
#include <obs-module.h>
struct test_filter {
obs_source_t *source;
gs_effect_t *whatever;
};
2016-08-28 12:07:43 +00:00
static const char *filter_getname(void *unused)
2016-02-23 23:16:51 +00:00
{
2016-08-28 12:07:43 +00:00
UNUSED_PARAMETER(unused);
2016-02-23 23:16:51 +00:00
return "Test";
}
static void filter_destroy(void *data)
{
struct test_filter *tf = data;
if (tf) {
obs_enter_graphics();
gs_effect_destroy(tf->whatever);
bfree(tf);
obs_leave_graphics();
}
}
static void *filter_create(obs_data_t *settings, obs_source_t *source)
{
struct test_filter *tf = bzalloc(sizeof(struct test_filter));
char *effect_file;
obs_enter_graphics();
effect_file = obs_module_file("test.effect");
tf->source = source;
tf->whatever = gs_effect_create_from_file(effect_file, NULL);
bfree(effect_file);
if (!tf->whatever) {
filter_destroy(tf);
tf = NULL;
}
obs_leave_graphics();
UNUSED_PARAMETER(settings);
return tf;
}
static void filter_render(void *data, gs_effect_t *effect)
{
struct test_filter *tf = data;
2016-05-24 19:53:01 +00:00
if (!obs_source_process_filter_begin(tf->source, GS_RGBA,
2019-09-22 21:19:10 +00:00
OBS_ALLOW_DIRECT_RENDERING))
2016-05-24 19:53:01 +00:00
return;
2016-02-23 23:16:51 +00:00
obs_source_process_filter_end(tf->source, tf->whatever, 0, 0);
UNUSED_PARAMETER(effect);
}
struct obs_source_info test_filter = {
2019-09-22 21:19:10 +00:00
.id = "test_filter",
.type = OBS_SOURCE_TYPE_FILTER,
2016-02-23 23:16:51 +00:00
.output_flags = OBS_SOURCE_VIDEO,
2019-09-22 21:19:10 +00:00
.get_name = filter_getname,
.create = filter_create,
.destroy = filter_destroy,
.video_render = filter_render,
2016-02-23 23:16:51 +00:00
};