Skip to content
Open
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
27 changes: 27 additions & 0 deletions docs/sphinx/scripting.rst
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,15 @@ modules/namespaces).
:param name: Name of the parameter.
:return: A borrowed reference to an obs_source_t object.

.. py:function:: calldata_scene(calldata, name)

Casts a pointer parameter of a calldata_t object to an obs_scene_t
object.

:param calldata: A calldata_t object.
:param name: Name of the parameter.
:return: A borrowed reference to an obs_scene_t object.

.. py:function:: calldata_sceneitem(calldata, name)

Casts a pointer parameter of a calldata_t object to an
Expand All @@ -334,3 +343,21 @@ modules/namespaces).
:param calldata: A calldata_t object.
:param name: Name of the parameter.
:return: A borrowed reference to an obs_sceneitem_t object.

.. py:function:: calldata_output(calldata, name)

Casts a pointer parameter of a calldata_t object to an obs_output_t
object.

:param calldata: A calldata_t object.
:param name: Name of the parameter.
:return: A borrowed reference to an obs_output_t object.

.. py:function:: calldata_canvas(calldata, name)

Casts a pointer parameter of a calldata_t object to an obs_canvas_t
object.

:param calldata: A calldata_t object.
:param name: Name of the parameter.
:return: A borrowed reference to an obs_canvas_t object.
63 changes: 63 additions & 0 deletions shared/obs-scripting/obs-scripting-lua.c
Original file line number Diff line number Diff line change
Expand Up @@ -871,6 +871,26 @@ static int calldata_source(lua_State *script)
return ret;
}

static int calldata_scene(lua_State *script)
{
calldata_t *cd;
const char *str;
int ret = 0;

if (!ls_get_libobs_obj(calldata_t, 1, &cd))
goto fail;
str = lua_tostring(script, 2);
if (!str)
goto fail;

obs_scene_t *scene = calldata_ptr(cd, str);
if (ls_push_libobs_obj(obs_scene_t, scene, false))
++ret;

fail:
return ret;
}

static int calldata_sceneitem(lua_State *script)
{
calldata_t *cd;
Expand All @@ -891,6 +911,46 @@ static int calldata_sceneitem(lua_State *script)
return ret;
}

static int calldata_output(lua_State *script)
{
calldata_t *cd;
const char *str;
int ret = 0;

if (!ls_get_libobs_obj(calldata_t, 1, &cd))
goto fail;
str = lua_tostring(script, 2);
if (!str)
goto fail;

obs_output_t *output = calldata_ptr(cd, str);
if (ls_push_libobs_obj(obs_output_t, output, false))
++ret;

fail:
return ret;
}

static int calldata_canvas(lua_State *script)
{
calldata_t *cd;
const char *str;
int ret = 0;

if (!ls_get_libobs_obj(calldata_t, 1, &cd))
goto fail;
str = lua_tostring(script, 2);
if (!str)
goto fail;

obs_canvas_t *canvas = calldata_ptr(cd, str);
if (ls_push_libobs_obj(obs_canvas_t, canvas, false))
++ret;

fail:
return ret;
}

/* -------------------------------------------- */

static int source_list_release(lua_State *script)
Expand Down Expand Up @@ -1015,7 +1075,10 @@ static void add_hook_functions(lua_State *script)
add_func("source_list_release", source_list_release);
add_func("sceneitem_list_release", sceneitem_list_release);
add_func("calldata_source", calldata_source);
add_func("calldata_scene", calldata_scene);
add_func("calldata_sceneitem", calldata_sceneitem);
add_func("calldata_output", calldata_output);
add_func("calldata_canvas", calldata_canvas);
add_func("obs_add_main_render_callback", obs_lua_add_main_render_callback);
add_func("obs_remove_main_render_callback", obs_lua_remove_main_render_callback);
add_func("obs_add_tick_callback", obs_lua_add_tick_callback);
Expand Down
69 changes: 69 additions & 0 deletions shared/obs-scripting/obs-scripting-python.c
Original file line number Diff line number Diff line change
Expand Up @@ -985,6 +985,28 @@ static PyObject *calldata_source(PyObject *self, PyObject *args)
return py_ret;
}

static PyObject *calldata_scene(PyObject *self, PyObject *args)
{
PyObject *py_ret = NULL;
PyObject *py_cd = NULL;

calldata_t *cd;
const char *name;

UNUSED_PARAMETER(self);

if (!parse_args(args, "Os", &py_cd, &name))
goto fail;
if (!py_to_libobs(calldata_t, py_cd, &cd))
goto fail;

obs_scene_t *scene = calldata_ptr(cd, name);
libobs_to_py(obs_scene_t, scene, false, &py_ret);

fail:
return py_ret;
}

static PyObject *calldata_sceneitem(PyObject *self, PyObject *args)
{
PyObject *py_ret = NULL;
Expand All @@ -1007,6 +1029,50 @@ static PyObject *calldata_sceneitem(PyObject *self, PyObject *args)
return py_ret;
}

static PyObject *calldata_output(PyObject *self, PyObject *args)
{
PyObject *py_ret = NULL;
PyObject *py_cd = NULL;

calldata_t *cd;
const char *name;

UNUSED_PARAMETER(self);

if (!parse_args(args, "Os", &py_cd, &name))
goto fail;
if (!py_to_libobs(calldata_t, py_cd, &cd))
goto fail;

obs_output_t *output = calldata_ptr(cd, name);
libobs_to_py(obs_output_t, output, false, &py_ret);

fail:
return py_ret;
}

static PyObject *calldata_canvas(PyObject *self, PyObject *args)
{
PyObject *py_ret = NULL;
PyObject *py_cd = NULL;

calldata_t *cd;
const char *name;

UNUSED_PARAMETER(self);

if (!parse_args(args, "Os", &py_cd, &name))
goto fail;
if (!py_to_libobs(calldata_t, py_cd, &cd))
goto fail;

obs_canvas_t *canvas = calldata_ptr(cd, name);
libobs_to_py(obs_canvas_t, canvas, false, &py_ret);

fail:
return py_ret;
}

/* -------------------------------------------- */

static bool enum_sources_proc(void *param, obs_source_t *source)
Expand Down Expand Up @@ -1203,7 +1269,10 @@ static void add_hook_functions(PyObject *module)
DEF_FUNC("timer_remove", timer_remove),
DEF_FUNC("timer_add", timer_add),
DEF_FUNC("calldata_source", calldata_source),
DEF_FUNC("calldata_scene", calldata_scene),
DEF_FUNC("calldata_sceneitem", calldata_sceneitem),
DEF_FUNC("calldata_output", calldata_output),
DEF_FUNC("calldata_canvas", calldata_canvas),
DEF_FUNC("source_list_release", source_list_release),
DEF_FUNC("sceneitem_list_release", sceneitem_list_release),
DEF_FUNC("obs_enum_sources", enum_sources),
Expand Down
Loading