diff --git a/lib/wp/proxy.c b/lib/wp/proxy.c index bed50720..d84a5f6c 100644 --- a/lib/wp/proxy.c +++ b/lib/wp/proxy.c @@ -186,6 +186,29 @@ wp_proxy_get_bound_id (WpProxy * self) return priv->pw_proxy ? pw_proxy_get_bound_id (priv->pw_proxy) : SPA_ID_INVALID; } +/** + * wp_proxy_get_interface_type: + * @self: the proxy + * @version: (out) (optional): the version of the interface + * + * Returns: the PipeWire type of the interface that is being proxied + */ +const gchar * +wp_proxy_get_interface_type (WpProxy * self, guint32 * version) +{ + g_return_val_if_fail (WP_IS_PROXY (self), NULL); + + WpProxyPrivate *priv = wp_proxy_get_instance_private (self); + if (priv->pw_proxy) + return pw_proxy_get_type (priv->pw_proxy, version); + else { + WpProxyClass *klass = WP_PROXY_GET_CLASS (self); + if (version) + *version = klass->pw_iface_version; + return klass->pw_iface_type; + } +} + /** * wp_proxy_get_pw_proxy: * diff --git a/lib/wp/proxy.h b/lib/wp/proxy.h index e9ed203b..f1672bd3 100644 --- a/lib/wp/proxy.h +++ b/lib/wp/proxy.h @@ -91,6 +91,9 @@ struct _WpProxyClass WP_API guint32 wp_proxy_get_bound_id (WpProxy * self); +WP_API +const gchar * wp_proxy_get_interface_type (WpProxy * self, guint32 * version); + WP_API struct pw_proxy * wp_proxy_get_pw_proxy (WpProxy * self); diff --git a/modules/module-lua-scripting/api.c b/modules/module-lua-scripting/api.c index d11307ef..cb6b940a 100644 --- a/modules/module-lua-scripting/api.c +++ b/modules/module-lua-scripting/api.c @@ -238,6 +238,24 @@ static const luaL_Reg object_methods[] = { { NULL, NULL } }; +/* WpProxy */ + +static int +proxy_get_interface_type (lua_State *L) +{ + WpProxy * p = wplua_checkobject (L, 1, WP_TYPE_PROXY); + guint32 version = 0; + const gchar *type = wp_proxy_get_interface_type (p, &version); + lua_pushstring (L, type); + lua_pushinteger (L, version); + return 2; +} + +static const luaL_Reg proxy_methods[] = { + { "get_interface_type", proxy_get_interface_type }, + { NULL, NULL } +}; + /* WpGlobalProxy */ static int @@ -937,6 +955,8 @@ wp_lua_scripting_api_init (lua_State *L) wplua_register_type_methods (L, WP_TYPE_OBJECT, NULL, object_methods); + wplua_register_type_methods (L, WP_TYPE_PROXY, + NULL, proxy_methods); wplua_register_type_methods (L, WP_TYPE_GLOBAL_PROXY, NULL, global_proxy_methods); wplua_register_type_methods (L, WP_TYPE_OBJECT_INTEREST,