Commit 9317b19a authored by Ashok Sidipotu's avatar Ashok Sidipotu
Browse files

wp-factory: enumerate pw_factory objects

pw_factory objects allow permissions to be set on its clients,
wp-factory exposes this funtionality to wireplumber clients.
parent 05334c1e
Pipeline #415313 failed with stages
in 1 minute and 8 seconds
/* WirePlumber
*
* Copyright © 2021 Collabora Ltd.
* @author Ashok Sidipotu <ashok.sidipotuc@ollabora.com>
*
* SPDX-License-Identifier: MIT
*/
#define G_LOG_DOMAIN "wp-factory"
#include "factory.h"
#include "private/pipewire-object-mixin.h"
#include "log.h"
/*! \defgroup wpfactory WpFactory */
/*!
* \struct WpFactory
*
* The WpFactory class allows accessing the properties and methods of
* PipeWire Facyory objects (`struct pw_factory`).
*
* A WpFactory is constructed internally by wireplumber, when the pipewire
* constructed factory objects are reported in by PipeWire registry
* and it is made available for wireplumber clients through the
* WpObjectManager API.
*/
struct _WpFactory
{
WpGlobalProxy parent;
};
static void wp_factory_pw_object_mixin_priv_interface_init (
WpPwObjectMixinPrivInterface * iface);
G_DEFINE_TYPE_WITH_CODE (WpFactory, wp_factory, WP_TYPE_GLOBAL_PROXY,
G_IMPLEMENT_INTERFACE (WP_TYPE_PIPEWIRE_OBJECT,
wp_pw_object_mixin_object_interface_init)
G_IMPLEMENT_INTERFACE (WP_TYPE_PW_OBJECT_MIXIN_PRIV,
wp_factory_pw_object_mixin_priv_interface_init))
static void wp_factory_init (WpFactory * self)
{
}
static void
wp_factory_activate_execute_step (WpObject * object,
WpFeatureActivationTransition * transition, guint step,
WpObjectFeatures missing)
{
switch (step) {
case WP_PW_OBJECT_MIXIN_STEP_BIND:
case WP_TRANSITION_STEP_ERROR:
/* base class can handle BIND and ERROR */
WP_OBJECT_CLASS (wp_factory_parent_class)->
activate_execute_step (object, transition, step, missing);
break;
case WP_PW_OBJECT_MIXIN_STEP_WAIT_INFO:
/* just wait, info will be emitted anyway after binding */
break;
default:
g_assert_not_reached ();
}
}
static const struct pw_factory_events factory_events = {
PW_VERSION_FACTORY_EVENTS,
.info = (HandleEventInfoFunc(factory)) wp_pw_object_mixin_handle_event_info,
};
static void
wp_factory_pw_proxy_created (WpProxy * proxy, struct pw_proxy * pw_proxy)
{
wp_pw_object_mixin_handle_pw_proxy_created (proxy, pw_proxy,
factory, &factory_events);
}
static void
wp_factory_pw_proxy_destroyed (WpProxy * proxy)
{
wp_pw_object_mixin_handle_pw_proxy_destroyed (proxy);
WP_PROXY_CLASS (wp_factory_parent_class)->pw_proxy_destroyed (proxy);
}
static void
wp_factory_class_init (WpFactoryClass * klass)
{
GObjectClass *object_class = (GObjectClass *) klass;
WpObjectClass *wpobject_class = (WpObjectClass *) klass;
WpProxyClass *proxy_class = (WpProxyClass *) klass;
object_class->get_property = wp_pw_object_mixin_get_property;
wpobject_class->get_supported_features =
wp_pw_object_mixin_get_supported_features;
wpobject_class->activate_get_next_step =
wp_pw_object_mixin_activate_get_next_step;
wpobject_class->activate_execute_step = wp_factory_activate_execute_step;
proxy_class->pw_iface_type = PW_TYPE_INTERFACE_Factory;
proxy_class->pw_iface_version = PW_VERSION_FACTORY;
proxy_class->pw_proxy_created = wp_factory_pw_proxy_created;
proxy_class->pw_proxy_destroyed = wp_factory_pw_proxy_destroyed;
wp_pw_object_mixin_class_override_properties (object_class);
}
static void
wp_factory_pw_object_mixin_priv_interface_init (
WpPwObjectMixinPrivInterface * iface)
{
wp_pw_object_mixin_priv_interface_info_init_no_params (iface, factory, FACTORY);
}
/* WirePlumber
*
* Copyright © 2021 Collabora Ltd.
* @author Ashok Sidipotu <ashok.sidipotuc@ollabora.com>
*
* SPDX-License-Identifier: MIT
*/
#ifndef __WIREPLUMBER_FACTORY_H__
#define __WIREPLUMBER_FACTORY_H__
#include "global-proxy.h"
G_BEGIN_DECLS
struct pw_factory;
/*!
* \brief The WpFactory GType
* \ingroup wpfactory
*/
#define WP_TYPE_FACTORY (wp_factory_get_type ())
WP_API
G_DECLARE_FINAL_TYPE (WpFactory, wp_factory, WP, FACTORY, WpGlobalProxy)
struct _WpFactoryClass
{
WpGlobalProxyClass parent_class;
/*< private >*/
WP_PADDING(4)
};
G_END_DECLS
#endif
......@@ -5,6 +5,7 @@ wp_lib_sources = files(
'device.c',
'endpoint.c',
'error.c',
'factory.c',
'global-proxy.c',
'iterator.c',
'link.c',
......
......@@ -59,6 +59,7 @@ wp_init (WpInitFlags flags)
g_type_ensure (WP_TYPE_METADATA);
g_type_ensure (WP_TYPE_NODE);
g_type_ensure (WP_TYPE_PORT);
g_type_ensure (WP_TYPE_FACTORY);
}
/*!
......
......@@ -39,6 +39,7 @@
#include "transition.h"
#include "wpenums.h"
#include "wpversion.h"
#include "factory.h"
G_BEGIN_DECLS
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment