update API and implement preliminary ability to add sources to scenes
This commit is contained in:
@@ -147,13 +147,13 @@ int obs_load_module(const char *path)
|
||||
|
||||
mod.name = bstrdup(path);
|
||||
module_load_exports(&mod, &obs->input_types.da, "inputs",
|
||||
sizeof(struct source_info), get_source_info);
|
||||
sizeof(struct source_info), load_source_info);
|
||||
module_load_exports(&mod, &obs->filter_types.da, "filters",
|
||||
sizeof(struct source_info), get_source_info);
|
||||
sizeof(struct source_info), load_source_info);
|
||||
module_load_exports(&mod, &obs->transition_types.da, "transitions",
|
||||
sizeof(struct source_info), get_source_info);
|
||||
sizeof(struct source_info), load_source_info);
|
||||
module_load_exports(&mod, &obs->output_types.da, "outputs",
|
||||
sizeof(struct output_info), get_output_info);
|
||||
sizeof(struct output_info), load_output_info);
|
||||
|
||||
da_push_back(obs->modules, &mod);
|
||||
return MODULE_SUCCESS;
|
||||
|
@@ -18,7 +18,7 @@
|
||||
#include "obs.h"
|
||||
#include "obs-data.h"
|
||||
|
||||
bool get_output_info(void *module, const char *module_name,
|
||||
bool load_output_info(void *module, const char *module_name,
|
||||
const char *output_id, struct output_info *info)
|
||||
{
|
||||
info->getname = load_module_subfunc(module, module_name,
|
||||
|
@@ -119,5 +119,5 @@ struct obs_output {
|
||||
struct dstr settings;
|
||||
};
|
||||
|
||||
extern bool get_output_info(void *module, const char *module_name,
|
||||
extern bool load_output_info(void *module, const char *module_name,
|
||||
const char *output_name, struct output_info *info);
|
||||
|
@@ -119,10 +119,16 @@ obs_scene_t obs_scene_create(const char *name)
|
||||
return scene;
|
||||
}
|
||||
|
||||
void obs_scene_release(obs_scene_t scene)
|
||||
int obs_scene_addref(obs_scene_t scene)
|
||||
{
|
||||
return obs_source_addref(scene->source);
|
||||
}
|
||||
|
||||
int obs_scene_release(obs_scene_t scene)
|
||||
{
|
||||
if (scene)
|
||||
obs_source_release(scene->source);
|
||||
return obs_source_release(scene->source);
|
||||
return 0;
|
||||
}
|
||||
|
||||
obs_source_t obs_scene_getsource(obs_scene_t scene)
|
||||
@@ -154,15 +160,23 @@ obs_sceneitem_t obs_scene_add(obs_scene_t scene, obs_source_t source)
|
||||
return item;
|
||||
}
|
||||
|
||||
void obs_sceneitem_destroy(obs_sceneitem_t item)
|
||||
int obs_sceneitem_destroy(obs_sceneitem_t item)
|
||||
{
|
||||
int ref = 0;
|
||||
if (item) {
|
||||
if (item->source)
|
||||
obs_source_release(item->source);
|
||||
ref = obs_source_release(item->source);
|
||||
|
||||
da_erase_item(item->parent->items, item);
|
||||
bfree(item);
|
||||
}
|
||||
|
||||
return ref;
|
||||
}
|
||||
|
||||
obs_source_t obs_sceneitem_getsource(obs_sceneitem_t item)
|
||||
{
|
||||
return item->source;
|
||||
}
|
||||
|
||||
void obs_sceneitem_setpos(obs_sceneitem_t item, const struct vec2 *pos)
|
||||
|
@@ -25,7 +25,7 @@
|
||||
|
||||
static void obs_source_destroy(obs_source_t source);
|
||||
|
||||
bool get_source_info(void *module, const char *module_name,
|
||||
bool load_source_info(void *module, const char *module_name,
|
||||
const char *source_id, struct source_info *info)
|
||||
{
|
||||
info->getname = load_module_subfunc(module, module_name,
|
||||
@@ -85,6 +85,24 @@ static inline const struct source_info *find_source(struct darray *list,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static const struct source_info *get_source_info(enum source_type type,
|
||||
const char *id)
|
||||
{
|
||||
struct darray *list = NULL;
|
||||
|
||||
switch (type) {
|
||||
case SOURCE_INPUT: list = &obs->input_types.da; break;
|
||||
case SOURCE_FILTER: list = &obs->filter_types.da; break;
|
||||
case SOURCE_TRANSITION: list = &obs->transition_types.da; break;
|
||||
case SOURCE_SCENE:
|
||||
default:
|
||||
blog(LOG_WARNING, "get_source_info: invalid source type");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return find_source(list, id);
|
||||
}
|
||||
|
||||
static inline bool obs_source_init_handlers(struct obs_source *source)
|
||||
{
|
||||
source->signals = signal_handler_create();
|
||||
@@ -95,6 +113,13 @@ static inline bool obs_source_init_handlers(struct obs_source *source)
|
||||
return (source->procs != NULL);
|
||||
}
|
||||
|
||||
const char *obs_source_getdisplayname(enum obs_source_type type,
|
||||
const char *id, const char *locale)
|
||||
{
|
||||
const struct source_info *info = get_source_info(type, id);
|
||||
return (info != NULL) ? info->getname(locale) : NULL;
|
||||
}
|
||||
|
||||
/* internal initialization */
|
||||
bool obs_source_init(struct obs_source *source, const char *settings,
|
||||
const struct source_info *info)
|
||||
@@ -141,21 +166,9 @@ static inline void obs_source_dosignal(struct obs_source *source,
|
||||
obs_source_t obs_source_create(enum obs_source_type type, const char *id,
|
||||
const char *name, const char *settings)
|
||||
{
|
||||
const struct source_info *info = NULL;
|
||||
struct darray *list = NULL;
|
||||
struct obs_source *source;
|
||||
|
||||
switch (type) {
|
||||
case SOURCE_INPUT: list = &obs->input_types.da; break;
|
||||
case SOURCE_FILTER: list = &obs->filter_types.da; break;
|
||||
case SOURCE_TRANSITION: list = &obs->transition_types.da; break;
|
||||
case SOURCE_SCENE:
|
||||
default:
|
||||
blog(LOG_WARNING, "Tried to create invalid source type");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
info = find_source(list, id);
|
||||
const struct source_info *info = get_source_info(type, id);
|
||||
if (!info) {
|
||||
blog(LOG_WARNING, "Source '%s' not found", id);
|
||||
return NULL;
|
||||
|
@@ -249,7 +249,7 @@ struct obs_source {
|
||||
bool rendering_filter;
|
||||
};
|
||||
|
||||
extern bool get_source_info(void *module, const char *module_name,
|
||||
extern bool load_source_info(void *module, const char *module_name,
|
||||
const char *source_name, struct source_info *info);
|
||||
|
||||
extern bool obs_source_init(struct obs_source *source, const char *settings,
|
||||
|
12
libobs/obs.h
12
libobs/obs.h
@@ -445,7 +445,9 @@ EXPORT void obs_source_process_filter(obs_source_t filter,
|
||||
* display oriantations. Scenes can also be used like any other source.
|
||||
*/
|
||||
EXPORT obs_scene_t obs_scene_create(const char *name);
|
||||
EXPORT void obs_scene_release(obs_scene_t scene);
|
||||
|
||||
EXPORT int obs_scene_addref(obs_scene_t scene);
|
||||
EXPORT int obs_scene_release(obs_scene_t scene);
|
||||
|
||||
/** Gets the scene's source context */
|
||||
EXPORT obs_source_t obs_scene_getsource(obs_scene_t scene);
|
||||
@@ -456,8 +458,12 @@ EXPORT obs_scene_t obs_scene_fromsource(obs_source_t source);
|
||||
/** Adds/creates a new scene item for a source */
|
||||
EXPORT obs_sceneitem_t obs_scene_add(obs_scene_t scene, obs_source_t source);
|
||||
|
||||
/** Removes/destroys a scene item */
|
||||
EXPORT void obs_sceneitem_destroy(obs_sceneitem_t item);
|
||||
/** Removes/destroys a scene item. Returns the source reference counter
|
||||
* (if any) */
|
||||
EXPORT int obs_sceneitem_destroy(obs_sceneitem_t item);
|
||||
|
||||
/** Gets the source of a scene item */
|
||||
EXPORT obs_source_t obs_sceneitem_getsource(obs_sceneitem_t item);
|
||||
|
||||
/* Functions for gettings/setting specific oriantation of a scene item */
|
||||
EXPORT void obs_sceneitem_setpos(obs_sceneitem_t item, const struct vec2 *pos);
|
||||
|
Reference in New Issue
Block a user