added support for jansson, added new output files, made some adjustments to the API, fixed a UI subclass issue
This commit is contained in:
@@ -21,6 +21,7 @@
|
||||
#define MODULE_ERROR -1
|
||||
#define MODULE_FILENOTFOUND -2
|
||||
#define MODULE_FUNCTIONNOTFOUND -3
|
||||
#define MODULE_INCOMPATIBLE_VER -4
|
||||
|
||||
#define SOURCE_VIDEO (1<<0)
|
||||
#define SOURCE_AUDIO (1<<1)
|
||||
|
@@ -78,23 +78,71 @@ complete:
|
||||
|
||||
extern char *find_plugin(const char *plugin);
|
||||
|
||||
/* checks API version of module and calls module_load if it exists.
|
||||
* if the API version used by the module is incompatible, fails. */
|
||||
static int call_module_load(void *module, const char *path)
|
||||
{
|
||||
uint32_t (*module_version)(uint32_t obs_ver) = NULL;
|
||||
bool (*module_load)(void) = NULL;
|
||||
uint32_t version, major, minor;
|
||||
|
||||
module_load = os_dlsym(module, "module_load");
|
||||
|
||||
module_version = os_dlsym(module, "module_version");
|
||||
if (!module_version) {
|
||||
blog(LOG_WARNING, "Module '%s' failed to load: "
|
||||
"module_version not found.", path);
|
||||
return MODULE_FUNCTIONNOTFOUND;
|
||||
}
|
||||
|
||||
version = module_version(LIBOBS_API_VER);
|
||||
major = (version >> 16);
|
||||
minor = (version & 0xFF);
|
||||
|
||||
if (major != LIBOBS_API_MAJOR_VER) {
|
||||
blog(LOG_WARNING, "Module '%s' failed to load: "
|
||||
"incompatible major version "
|
||||
"(current API: %u.%u, module version: %u.%u)",
|
||||
path,
|
||||
LIBOBS_API_MAJOR_VER, LIBOBS_API_MINOR_VER,
|
||||
major, minor);
|
||||
return MODULE_INCOMPATIBLE_VER;
|
||||
}
|
||||
|
||||
if (minor > LIBOBS_API_MINOR_VER) {
|
||||
blog(LOG_WARNING, "Module '%s' failed to load: "
|
||||
"incompatible minor version "
|
||||
"(current API: %u.%u, module version: %u.%u)",
|
||||
path,
|
||||
LIBOBS_API_MAJOR_VER, LIBOBS_API_MINOR_VER,
|
||||
major, minor);
|
||||
return MODULE_INCOMPATIBLE_VER;
|
||||
}
|
||||
|
||||
if (module_load && !module_load()) {
|
||||
blog(LOG_WARNING, "Module '%s' failed to load: "
|
||||
"module_load failed", path);
|
||||
return MODULE_ERROR;
|
||||
}
|
||||
|
||||
return MODULE_SUCCESS;
|
||||
}
|
||||
|
||||
int obs_load_module(const char *path)
|
||||
{
|
||||
struct obs_module mod;
|
||||
bool (*module_load)(void) = NULL;
|
||||
char *plugin_path = find_plugin(path);
|
||||
int errorcode;
|
||||
|
||||
mod.module = os_dlopen(plugin_path);
|
||||
bfree(plugin_path);
|
||||
if (!mod.module)
|
||||
return MODULE_FILENOTFOUND;
|
||||
|
||||
module_load = os_dlsym(mod.module, "module_load");
|
||||
if (module_load) {
|
||||
if (!module_load()) {
|
||||
os_dlclose(mod.module);
|
||||
return MODULE_ERROR;
|
||||
}
|
||||
errorcode = call_module_load(mod.module, path);
|
||||
if (errorcode != MODULE_SUCCESS) {
|
||||
os_dlclose(mod.module);
|
||||
return errorcode;
|
||||
}
|
||||
|
||||
mod.name = bstrdup(path);
|
||||
|
@@ -21,6 +21,8 @@
|
||||
bool get_output_info(void *module, const char *module_name,
|
||||
const char *output_name, struct output_info *info)
|
||||
{
|
||||
info->getname = load_module_subfunc(module, module_name,
|
||||
output_name, "getname", true);
|
||||
info->create = load_module_subfunc(module, module_name,
|
||||
output_name, "create", true);
|
||||
info->destroy = load_module_subfunc(module, module_name,
|
||||
@@ -30,7 +32,8 @@ bool get_output_info(void *module, const char *module_name,
|
||||
info->stop = load_module_subfunc(module, module_name,
|
||||
output_name, "stop", true);
|
||||
|
||||
if (!info->create || !info->destroy || !info->start || !info->stop)
|
||||
if (!info->getname || !info->create || !info->destroy ||
|
||||
!info->start || !info->stop)
|
||||
return false;
|
||||
|
||||
info->config = load_module_subfunc(module, module_name,
|
||||
|
@@ -33,6 +33,7 @@
|
||||
*
|
||||
* Each individual output is then exported by it's name. For example, an
|
||||
* output named "myoutput" would have the following exports:
|
||||
* + myoutput_getname
|
||||
* + myoutput_create
|
||||
* + myoutput_destroy
|
||||
* + myoutput_start
|
||||
@@ -52,7 +53,11 @@
|
||||
* ===========================================
|
||||
* Output Exports
|
||||
* ===========================================
|
||||
* void *[name]_create(const char *settings, output_t output);
|
||||
* const char *[name]_getname(const char *locale);
|
||||
* Returns the full translated name of the output type (seen by the user).
|
||||
*
|
||||
* ---------------------------------------------------------
|
||||
* void *[name]_create(const char *settings, obs_output_t output);
|
||||
* Creates an output.
|
||||
*
|
||||
* settings: Settings of the output.
|
||||
@@ -95,6 +100,8 @@ struct obs_output;
|
||||
struct output_info {
|
||||
const char *name;
|
||||
|
||||
const char *(*getname)(const char *locale);
|
||||
|
||||
void *(*create)(const char *settings, struct obs_output *output);
|
||||
void (*destroy)(void *data);
|
||||
|
||||
|
@@ -18,6 +18,12 @@
|
||||
#include "graphics/math-defs.h"
|
||||
#include "obs-scene.h"
|
||||
|
||||
static const char *scene_getname(const char *locale)
|
||||
{
|
||||
/* TODO: locale lookup of display name */
|
||||
return "Scene";
|
||||
}
|
||||
|
||||
static void *scene_create(const char *settings, struct obs_source *source)
|
||||
{
|
||||
struct obs_scene *scene = bmalloc(sizeof(struct obs_scene));
|
||||
@@ -84,6 +90,7 @@ static bool scene_enum_children(void *data, size_t idx, obs_source_t *child)
|
||||
static const struct source_info scene_info =
|
||||
{
|
||||
"scene",
|
||||
scene_getname,
|
||||
scene_create,
|
||||
scene_destroy,
|
||||
scene_get_output_flags, NULL, NULL, NULL, NULL,
|
||||
@@ -96,6 +103,7 @@ static const struct source_info scene_info =
|
||||
static const struct source_info scene_info =
|
||||
{
|
||||
.name = "scene",
|
||||
.getname = scene_getname,
|
||||
.create = scene_create,
|
||||
.destroy = scene_destroy,
|
||||
.get_output_flags = scene_get_output_flags,
|
||||
|
@@ -24,6 +24,8 @@
|
||||
bool get_source_info(void *module, const char *module_name,
|
||||
const char *source_name, struct source_info *info)
|
||||
{
|
||||
info->getname = load_module_subfunc(module, module_name,
|
||||
source_name, "getname", true);
|
||||
info->create = load_module_subfunc(module, module_name,
|
||||
source_name,"create", true);
|
||||
info->destroy = load_module_subfunc(module, module_name,
|
||||
@@ -31,7 +33,8 @@ bool get_source_info(void *module, const char *module_name,
|
||||
info->get_output_flags = load_module_subfunc(module, module_name,
|
||||
source_name, "get_output_flags", true);
|
||||
|
||||
if (!info->create || !info->destroy || !info->get_output_flags)
|
||||
if (!info->getname || !info->create || !info->destroy ||
|
||||
!info->get_output_flags)
|
||||
return false;
|
||||
|
||||
info->config = load_module_subfunc(module, module_name,
|
||||
|
@@ -36,6 +36,7 @@
|
||||
*
|
||||
* Each individual source is then exported by it's name. For example, a
|
||||
* source named "mysource" would have the following exports:
|
||||
* + mysource_getname
|
||||
* + mysource_create
|
||||
* + mysource_destroy
|
||||
* + mysource_getflags
|
||||
@@ -59,6 +60,10 @@
|
||||
* ===========================================
|
||||
* Source Exports
|
||||
* ===========================================
|
||||
* const char *[name]_getname(const char *locale);
|
||||
* Returns the full name of the source type (seen by the user).
|
||||
*
|
||||
* ---------------------------------------------------------
|
||||
* void *[name]_create(const char *settings, obs_source_t source);
|
||||
* Creates a source.
|
||||
*
|
||||
@@ -161,6 +166,8 @@ struct source_info {
|
||||
/* ----------------------------------------------------------------- */
|
||||
/* required implementations */
|
||||
|
||||
const char *(*getname)(const char *locale);
|
||||
|
||||
void *(*create)(const char *settings, obs_source_t source);
|
||||
void (*destroy)(void *data);
|
||||
|
||||
|
15
libobs/obs.h
15
libobs/obs.h
@@ -32,6 +32,13 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* LIBOBS_API_VER must be returned by module_version in each module */
|
||||
|
||||
#define LIBOBS_API_MAJOR_VER 0 /* increment if major breaking changes */
|
||||
#define LIBOBS_API_MINOR_VER 1 /* increment if minor non-breaking additions */
|
||||
#define LIBOBS_API_VER ((LIBOBS_API_MAJOR_VER << 16) | \
|
||||
LIBOBS_API_MINOR_VER)
|
||||
|
||||
enum obs_source_type {
|
||||
SOURCE_INPUT,
|
||||
SOURCE_FILTER,
|
||||
@@ -214,6 +221,12 @@ EXPORT obs_source_t obs_display_getsource(obs_display_t display);
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* Sources */
|
||||
|
||||
/**
|
||||
* Gets the translated display name of a source
|
||||
*/
|
||||
EXPORT const char *obs_source_getdisplayname(enum obs_source_type type,
|
||||
const char *name, const char *locale);
|
||||
|
||||
/**
|
||||
* Creates a source of the specified type with the specified settings.
|
||||
*
|
||||
@@ -221,7 +234,7 @@ EXPORT obs_source_t obs_display_getsource(obs_display_t display);
|
||||
* or modifying video/audio.
|
||||
*/
|
||||
EXPORT obs_source_t obs_source_create(enum obs_source_type type,
|
||||
const char *name, const char *settings);
|
||||
const char *name, const char *settings);
|
||||
EXPORT void obs_source_destroy(obs_source_t source);
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user