Merge pull request #2285 from cg2121/source-defaults
obs-plugins: Change defaults of various plugins
This commit is contained in:
commit
8c7a6518a4
@ -99,22 +99,49 @@ static uint32_t color_source_getheight(void *data)
|
||||
return context->height;
|
||||
}
|
||||
|
||||
static void color_source_defaults(obs_data_t *settings)
|
||||
static void color_source_defaults_v1(obs_data_t *settings)
|
||||
{
|
||||
obs_data_set_default_int(settings, "color", 0xFFFFFFFF);
|
||||
obs_data_set_default_int(settings, "width", 400);
|
||||
obs_data_set_default_int(settings, "height", 400);
|
||||
}
|
||||
|
||||
struct obs_source_info color_source_info = {
|
||||
static void color_source_defaults_v2(obs_data_t *settings)
|
||||
{
|
||||
struct obs_video_info ovi;
|
||||
obs_get_video_info(&ovi);
|
||||
|
||||
obs_data_set_default_int(settings, "color", 0xFFFFFFFF);
|
||||
obs_data_set_default_int(settings, "width", ovi.base_width);
|
||||
obs_data_set_default_int(settings, "height", ovi.base_width);
|
||||
}
|
||||
|
||||
struct obs_source_info color_source_info_v1 = {
|
||||
.id = "color_source",
|
||||
.type = OBS_SOURCE_TYPE_INPUT,
|
||||
.output_flags = OBS_SOURCE_VIDEO | OBS_SOURCE_CUSTOM_DRAW,
|
||||
.output_flags = OBS_SOURCE_VIDEO | OBS_SOURCE_CUSTOM_DRAW |
|
||||
OBS_SOURCE_CAP_OBSOLETE,
|
||||
.create = color_source_create,
|
||||
.destroy = color_source_destroy,
|
||||
.update = color_source_update,
|
||||
.get_name = color_source_get_name,
|
||||
.get_defaults = color_source_defaults,
|
||||
.get_defaults = color_source_defaults_v1,
|
||||
.get_width = color_source_getwidth,
|
||||
.get_height = color_source_getheight,
|
||||
.video_render = color_source_render,
|
||||
.get_properties = color_source_properties,
|
||||
.icon_type = OBS_ICON_TYPE_COLOR,
|
||||
};
|
||||
|
||||
struct obs_source_info color_source_info_v2 = {
|
||||
.id = "color_source_v2",
|
||||
.type = OBS_SOURCE_TYPE_INPUT,
|
||||
.output_flags = OBS_SOURCE_VIDEO | OBS_SOURCE_CUSTOM_DRAW,
|
||||
.create = color_source_create,
|
||||
.destroy = color_source_destroy,
|
||||
.update = color_source_update,
|
||||
.get_name = color_source_get_name,
|
||||
.get_defaults = color_source_defaults_v2,
|
||||
.get_width = color_source_getwidth,
|
||||
.get_height = color_source_getheight,
|
||||
.video_render = color_source_render,
|
||||
|
@ -277,12 +277,14 @@ MODULE_EXPORT const char *obs_module_description(void)
|
||||
}
|
||||
|
||||
extern struct obs_source_info slideshow_info;
|
||||
extern struct obs_source_info color_source_info;
|
||||
extern struct obs_source_info color_source_info_v1;
|
||||
extern struct obs_source_info color_source_info_v2;
|
||||
|
||||
bool obs_module_load(void)
|
||||
{
|
||||
obs_register_source(&image_source_info);
|
||||
obs_register_source(&color_source_info);
|
||||
obs_register_source(&color_source_info_v1);
|
||||
obs_register_source(&color_source_info_v2);
|
||||
obs_register_source(&slideshow_info);
|
||||
return true;
|
||||
}
|
||||
|
@ -1035,32 +1035,11 @@ static obs_properties_t *get_properties(void *data)
|
||||
return props;
|
||||
}
|
||||
|
||||
bool obs_module_load(void)
|
||||
static void defaults(obs_data_t *settings, int ver)
|
||||
{
|
||||
obs_source_info si = {};
|
||||
si.id = "text_gdiplus";
|
||||
si.type = OBS_SOURCE_TYPE_INPUT;
|
||||
si.output_flags = OBS_SOURCE_VIDEO | OBS_SOURCE_CUSTOM_DRAW;
|
||||
si.get_properties = get_properties;
|
||||
si.icon_type = OBS_ICON_TYPE_TEXT;
|
||||
|
||||
si.get_name = [](void *) { return obs_module_text("TextGDIPlus"); };
|
||||
si.create = [](obs_data_t *settings, obs_source_t *source) {
|
||||
return (void *)new TextSource(source, settings);
|
||||
};
|
||||
si.destroy = [](void *data) {
|
||||
delete reinterpret_cast<TextSource *>(data);
|
||||
};
|
||||
si.get_width = [](void *data) {
|
||||
return reinterpret_cast<TextSource *>(data)->cx;
|
||||
};
|
||||
si.get_height = [](void *data) {
|
||||
return reinterpret_cast<TextSource *>(data)->cy;
|
||||
};
|
||||
si.get_defaults = [](obs_data_t *settings) {
|
||||
obs_data_t *font_obj = obs_data_create();
|
||||
obs_data_set_default_string(font_obj, "face", "Arial");
|
||||
obs_data_set_default_int(font_obj, "size", 36);
|
||||
obs_data_set_default_int(font_obj, "size", ver == 1 ? 36 : 256);
|
||||
|
||||
obs_data_set_default_obj(settings, S_FONT, font_obj);
|
||||
obs_data_set_default_string(settings, S_ALIGN, S_ALIGN_LEFT);
|
||||
@ -1079,11 +1058,35 @@ bool obs_module_load(void)
|
||||
obs_data_set_default_bool(settings, S_EXTENTS_WRAP, true);
|
||||
obs_data_set_default_int(settings, S_EXTENTS_CX, 100);
|
||||
obs_data_set_default_int(settings, S_EXTENTS_CY, 100);
|
||||
obs_data_set_default_int(settings, S_TRANSFORM,
|
||||
S_TRANSFORM_NONE);
|
||||
obs_data_set_default_int(settings, S_TRANSFORM, S_TRANSFORM_NONE);
|
||||
|
||||
obs_data_release(font_obj);
|
||||
};
|
||||
|
||||
bool obs_module_load(void)
|
||||
{
|
||||
obs_source_info si = {};
|
||||
si.id = "text_gdiplus";
|
||||
si.type = OBS_SOURCE_TYPE_INPUT;
|
||||
si.output_flags = OBS_SOURCE_VIDEO | OBS_SOURCE_CUSTOM_DRAW |
|
||||
OBS_SOURCE_CAP_OBSOLETE;
|
||||
si.get_properties = get_properties;
|
||||
si.icon_type = OBS_ICON_TYPE_TEXT;
|
||||
|
||||
si.get_name = [](void *) { return obs_module_text("TextGDIPlus"); };
|
||||
si.create = [](obs_data_t *settings, obs_source_t *source) {
|
||||
return (void *)new TextSource(source, settings);
|
||||
};
|
||||
si.destroy = [](void *data) {
|
||||
delete reinterpret_cast<TextSource *>(data);
|
||||
};
|
||||
si.get_width = [](void *data) {
|
||||
return reinterpret_cast<TextSource *>(data)->cx;
|
||||
};
|
||||
si.get_height = [](void *data) {
|
||||
return reinterpret_cast<TextSource *>(data)->cy;
|
||||
};
|
||||
si.get_defaults = [](obs_data_t *settings) { defaults(settings, 1); };
|
||||
si.update = [](void *data, obs_data_t *settings) {
|
||||
reinterpret_cast<TextSource *>(data)->Update(settings);
|
||||
};
|
||||
@ -1094,7 +1097,15 @@ bool obs_module_load(void)
|
||||
reinterpret_cast<TextSource *>(data)->Render();
|
||||
};
|
||||
|
||||
obs_source_info si_v2 = si;
|
||||
si_v2.id = "text_gdiplus_v2";
|
||||
si_v2.output_flags &= ~OBS_SOURCE_CAP_OBSOLETE;
|
||||
si_v2.get_defaults = [](obs_data_t *settings) {
|
||||
defaults(settings, 2);
|
||||
};
|
||||
|
||||
obs_register_source(&si);
|
||||
obs_register_source(&si_v2);
|
||||
|
||||
const GdiplusStartupInput gdip_input;
|
||||
GdiplusStartup(&gdip_token, &gdip_input, nullptr);
|
||||
|
@ -35,16 +35,33 @@ MODULE_EXPORT const char *obs_module_description(void)
|
||||
|
||||
uint32_t texbuf_w = 2048, texbuf_h = 2048;
|
||||
|
||||
static struct obs_source_info freetype2_source_info = {
|
||||
static struct obs_source_info freetype2_source_info_v1 = {
|
||||
.id = "text_ft2_source",
|
||||
.type = OBS_SOURCE_TYPE_INPUT,
|
||||
.output_flags = OBS_SOURCE_VIDEO | OBS_SOURCE_CAP_OBSOLETE |
|
||||
OBS_SOURCE_CUSTOM_DRAW,
|
||||
.get_name = ft2_source_get_name,
|
||||
.create = ft2_source_create_v1,
|
||||
.destroy = ft2_source_destroy,
|
||||
.update = ft2_source_update,
|
||||
.get_width = ft2_source_get_width,
|
||||
.get_height = ft2_source_get_height,
|
||||
.video_render = ft2_source_render,
|
||||
.video_tick = ft2_video_tick,
|
||||
.get_properties = ft2_source_properties,
|
||||
.icon_type = OBS_ICON_TYPE_TEXT,
|
||||
};
|
||||
|
||||
static struct obs_source_info freetype2_source_info_v2 = {
|
||||
.id = "text_ft2_source_v2",
|
||||
.type = OBS_SOURCE_TYPE_INPUT,
|
||||
.output_flags = OBS_SOURCE_VIDEO |
|
||||
#ifdef _WIN32
|
||||
OBS_SOURCE_DEPRECATED |
|
||||
#endif
|
||||
OBS_SOURCE_CUSTOM_DRAW,
|
||||
.get_name = ft2_source_get_name,
|
||||
.create = ft2_source_create,
|
||||
.create = ft2_source_create_v2,
|
||||
.destroy = ft2_source_destroy,
|
||||
.update = ft2_source_update,
|
||||
.get_width = ft2_source_get_width,
|
||||
@ -83,7 +100,8 @@ bool obs_module_load()
|
||||
bfree(config_dir);
|
||||
}
|
||||
|
||||
obs_register_source(&freetype2_source_info);
|
||||
obs_register_source(&freetype2_source_info_v1);
|
||||
obs_register_source(&freetype2_source_info_v2);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -469,7 +487,8 @@ error:
|
||||
#define DEFAULT_FACE "Sans Serif"
|
||||
#endif
|
||||
|
||||
static void *ft2_source_create(obs_data_t *settings, obs_source_t *source)
|
||||
static void *ft2_source_create(obs_data_t *settings, obs_source_t *source,
|
||||
int ver)
|
||||
{
|
||||
struct ft2_source *srcdata = bzalloc(sizeof(struct ft2_source));
|
||||
obs_data_t *font_obj = obs_data_create();
|
||||
@ -477,10 +496,12 @@ static void *ft2_source_create(obs_data_t *settings, obs_source_t *source)
|
||||
|
||||
init_plugin();
|
||||
|
||||
srcdata->font_size = 32;
|
||||
const uint16_t font_size = ver == 1 ? 32 : 256;
|
||||
|
||||
srcdata->font_size = font_size;
|
||||
|
||||
obs_data_set_default_string(font_obj, "face", DEFAULT_FACE);
|
||||
obs_data_set_default_int(font_obj, "size", 32);
|
||||
obs_data_set_default_int(font_obj, "size", font_size);
|
||||
obs_data_set_default_obj(settings, "font", font_obj);
|
||||
|
||||
obs_data_set_default_int(settings, "log_lines", 6);
|
||||
@ -494,3 +515,13 @@ static void *ft2_source_create(obs_data_t *settings, obs_source_t *source)
|
||||
|
||||
return srcdata;
|
||||
}
|
||||
|
||||
static void *ft2_source_create_v1(obs_data_t *settings, obs_source_t *source)
|
||||
{
|
||||
return ft2_source_create(settings, source, 1);
|
||||
}
|
||||
|
||||
static void *ft2_source_create_v2(obs_data_t *settings, obs_source_t *source)
|
||||
{
|
||||
return ft2_source_create(settings, source, 2);
|
||||
}
|
||||
|
@ -69,7 +69,8 @@ struct ft2_source {
|
||||
|
||||
extern FT_Library ft2_lib;
|
||||
|
||||
static void *ft2_source_create(obs_data_t *settings, obs_source_t *source);
|
||||
static void *ft2_source_create_v1(obs_data_t *settings, obs_source_t *source);
|
||||
static void *ft2_source_create_v2(obs_data_t *settings, obs_source_t *source);
|
||||
static void ft2_source_destroy(void *data);
|
||||
static void ft2_source_update(void *data, obs_data_t *settings);
|
||||
static void ft2_source_render(void *data, gs_effect_t *effect);
|
||||
|
Loading…
x
Reference in New Issue
Block a user