core: add wp_core_get_own_bound_id() method

This allows retrieving the bound-id of our own client
This commit is contained in:
George Kiagiadakis
2023-10-17 18:07:32 +03:00
parent e88fa840f2
commit a6bea40172
3 changed files with 33 additions and 0 deletions

View File

@@ -653,6 +653,26 @@ wp_core_is_connected (WpCore * self)
return self->pw_core != NULL; return self->pw_core != NULL;
} }
/*!
* \brief Gets the bound id of the client object that is created as a result
* of this core being connected to the PipeWire daemon
*
* \ingroup wpcore
* \since 0.4.16
* \param self the core
* \returns the bound id of this client
*/
guint32
wp_core_get_own_bound_id (WpCore * self)
{
struct pw_client *client;
g_return_val_if_fail (wp_core_is_connected (self), SPA_ID_INVALID);
client = pw_core_get_client (self->pw_core);
return pw_proxy_get_bound_id ((struct pw_proxy *) client);
}
/*! /*!
* \brief Gets the cookie of the core's connected PipeWire instance * \brief Gets the cookie of the core's connected PipeWire instance
* *

View File

@@ -64,6 +64,9 @@ gboolean wp_core_is_connected (WpCore * self);
/* Properties */ /* Properties */
WP_API
guint32 wp_core_get_own_bound_id (WpCore * self);
WP_API WP_API
guint32 wp_core_get_remote_cookie (WpCore * self); guint32 wp_core_get_remote_cookie (WpCore * self);

View File

@@ -174,6 +174,15 @@ core_get_vm_type (lua_State *L)
return 1; return 1;
} }
static int
core_get_own_bound_id (lua_State *L)
{
WpCore * core = get_wp_core (L);
guint32 id = wp_core_get_own_bound_id (core);
lua_pushinteger (L, id);
return 1;
}
static int static int
core_idle_add (lua_State *L) core_idle_add (lua_State *L)
{ {
@@ -270,6 +279,7 @@ core_require_api (lua_State *L)
static const luaL_Reg core_funcs[] = { static const luaL_Reg core_funcs[] = {
{ "get_info", core_get_info }, { "get_info", core_get_info },
{ "get_vm_type", core_get_vm_type }, { "get_vm_type", core_get_vm_type },
{ "get_own_bound_id", core_get_own_bound_id },
{ "idle_add", core_idle_add }, { "idle_add", core_idle_add },
{ "timeout_add", core_timeout_add }, { "timeout_add", core_timeout_add },
{ "sync", core_sync }, { "sync", core_sync },