Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions libobs/obs-scene.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "obs-scene.h"

const struct obs_source_info group_info;
const struct obs_source_info dsk_info;

static void resize_group(obs_sceneitem_t *group);
static void resize_scene(obs_scene_t *scene);
Expand Down Expand Up @@ -81,6 +82,12 @@ static const char *group_getname(void *unused)
return "Group";
}

static const char *dsk_getname(void *unused)
{
UNUSED_PARAMETER(unused);
return "DSK";
}

static void *scene_create(obs_data_t *settings, struct obs_source *source)
{
pthread_mutexattr_t attr;
Expand All @@ -92,6 +99,8 @@ static void *scene_create(obs_data_t *settings, struct obs_source *source)
scene->custom_size = true;
scene->cx = 0;
scene->cy = 0;
} else if (strcmp(source->info.id, dsk_info.id) == 0) {
scene->is_dsk = true;
}

signal_handler_add_array(obs_source_get_signal_handler(source),
Expand Down Expand Up @@ -1199,6 +1208,24 @@ const struct obs_source_info group_info = {
.enum_active_sources = scene_enum_active_sources,
.enum_all_sources = scene_enum_all_sources};

const struct obs_source_info dsk_info = {
.id = "dsk",
.type = OBS_SOURCE_TYPE_SCENE,
.output_flags = OBS_SOURCE_VIDEO | OBS_SOURCE_CUSTOM_DRAW |
OBS_SOURCE_COMPOSITE,
.get_name = dsk_getname,
.create = scene_create,
.destroy = scene_destroy,
.video_tick = scene_video_tick,
.video_render = scene_video_render,
.audio_render = scene_audio_render,
.get_width = scene_getwidth,
.get_height = scene_getheight,
.load = scene_load,
.save = scene_save,
.enum_active_sources = scene_enum_active_sources,
.enum_all_sources = scene_enum_all_sources};

static inline obs_scene_t *create_id(const char *id, const char *name)
{
struct obs_source *source = obs_source_create(id, name, NULL, NULL);
Expand All @@ -1221,6 +1248,11 @@ obs_scene_t *obs_scene_create_private(const char *name)
return create_private_id("scene", name);
}

obs_scene_t *obs_dsk_create(const char *name)
{
return create_id("dsk", name);
}

static obs_source_t *get_child_at_idx(obs_scene_t *scene, size_t idx)
{
struct obs_scene_item *item = scene->first_item;
Expand Down Expand Up @@ -1425,6 +1457,14 @@ obs_scene_t *obs_group_from_source(const obs_source_t *source)
return source->context.data;
}

obs_scene_t *obs_dsk_from_source(const obs_source_t *source)
{
if (!source || strcmp(source->info.id, dsk_info.id) != 0)
return NULL;

return source->context.data;
}

obs_sceneitem_t *obs_scene_find_source(obs_scene_t *scene, const char *name)
{
struct obs_scene_item *item;
Expand Down Expand Up @@ -2995,6 +3035,16 @@ bool obs_scene_is_group(const obs_scene_t *scene)
return scene ? scene->is_group : false;
}

bool obs_source_is_dsk(const obs_source_t *source)
{
return source && strcmp(source->info.id, dsk_info.id) == 0;
}

bool obs_scene_is_dsk(const obs_scene_t *scene)
{
return scene ? scene->is_dsk : false;
}

void obs_sceneitem_group_enum_items(obs_sceneitem_t *group,
bool (*callback)(obs_scene_t *,
obs_sceneitem_t *, void *),
Expand Down
2 changes: 2 additions & 0 deletions libobs/obs-scene.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,6 @@ struct obs_scene {
pthread_mutex_t video_mutex;
pthread_mutex_t audio_mutex;
struct obs_scene_item *first_item;

bool is_dsk;
};
2 changes: 2 additions & 0 deletions libobs/obs-source.c
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,8 @@ obs_source_t *obs_source_duplicate(obs_source_t *source, const char *new_name,
}
if (!scene)
scene = obs_group_from_source(source);
if (!scene)
scene = obs_dsk_from_source(source);
if (!scene)
return NULL;

Expand Down
2 changes: 2 additions & 0 deletions libobs/obs.c
Original file line number Diff line number Diff line change
Expand Up @@ -828,6 +828,7 @@ static inline void obs_free_hotkeys(void)

extern const struct obs_source_info scene_info;
extern const struct obs_source_info group_info;
extern const struct obs_source_info dsk_info;

static const char *submix_name(void *unused)
{
Expand Down Expand Up @@ -875,6 +876,7 @@ static bool obs_init(const char *locale, const char *module_config_path,
obs->locale = bstrdup(locale);
obs_register_source(&scene_info);
obs_register_source(&group_info);
obs_register_source(&dsk_info);
obs_register_source(&audio_line_info);
add_default_module_paths();
return true;
Expand Down
8 changes: 8 additions & 0 deletions libobs/obs.h
Original file line number Diff line number Diff line change
Expand Up @@ -1499,6 +1499,8 @@ EXPORT void obs_transition_swap_end(obs_source_t *tr_dest,
*/
EXPORT obs_scene_t *obs_scene_create(const char *name);

EXPORT obs_scene_t *obs_dsk_create(const char *name);

EXPORT obs_scene_t *obs_scene_create_private(const char *name);

enum obs_scene_duplicate_type {
Expand Down Expand Up @@ -1702,6 +1704,12 @@ EXPORT obs_scene_t *obs_group_from_source(const obs_source_t *source);
EXPORT void obs_sceneitem_defer_group_resize_begin(obs_sceneitem_t *item);
EXPORT void obs_sceneitem_defer_group_resize_end(obs_sceneitem_t *item);

/** Gets the dsk from its source, or NULL if not a dsk */
EXPORT obs_scene_t *obs_dsk_from_source(const obs_source_t *source);

EXPORT bool obs_source_is_dsk(const obs_source_t *source);
EXPORT bool obs_scene_is_dsk(const obs_scene_t *scene);

/* ------------------------------------------------------------------------- */
/* Outputs */

Expand Down