| 1 |
/* WirePlumber |
| 2 |
* |
| 3 |
* Copyright © 2021 Collabora Ltd. |
| 4 |
* @author Ashok Sidipotu <[email protected]> |
| 5 |
* |
| 6 |
* SPDX-License-Identifier: MIT |
| 7 |
*/ |
| 8 |
|
| 9 |
#include "factory.h" |
| 10 |
#include "log.h" |
| 11 |
#include "private/pipewire-object-mixin.h" |
| 12 |
|
| 13 |
WP_DEFINE_LOCAL_LOG_TOPIC ("wp-factory") |
| 14 |
|
| 15 |
/*! \defgroup wpfactory WpFactory */ |
| 16 |
/*! |
| 17 |
* \struct WpFactory |
| 18 |
* |
| 19 |
* The WpFactory class allows accessing the properties and methods of |
| 20 |
* PipeWire Factory objects (`struct pw_factory`). |
| 21 |
* |
| 22 |
* A WpFactory is constructed internally by wireplumber, when the pipewire |
| 23 |
* constructed factory objects are reported in by PipeWire registry |
| 24 |
* and it is made available for wireplumber clients through the |
| 25 |
* WpObjectManager API. |
| 26 |
* |
| 27 |
* \since 0.4.5 |
| 28 |
*/ |
| 29 |
|
| 30 |
struct _WpFactory |
| 31 |
{ |
| 32 |
WpGlobalProxy parent; |
| 33 |
}; |
| 34 |
|
| 35 |
static void wp_factory_pw_object_mixin_priv_interface_init ( |
| 36 |
WpPwObjectMixinPrivInterface * iface); |
| 37 |
|
| 38 |
|
| 39 |
G_DEFINE_TYPE_WITH_CODE (WpFactory, wp_factory, WP_TYPE_GLOBAL_PROXY, |
| 40 |
G_IMPLEMENT_INTERFACE (WP_TYPE_PIPEWIRE_OBJECT, |
| 41 |
wp_pw_object_mixin_object_interface_init) |
| 42 |
G_IMPLEMENT_INTERFACE (WP_TYPE_PW_OBJECT_MIXIN_PRIV, |
| 43 |
wp_factory_pw_object_mixin_priv_interface_init)) |
| 44 |
|
| 45 |
static void wp_factory_init (WpFactory * self) |
| 46 |
{ |
| 47 |
} |
| 48 |
|
| 49 |
static void |
| 50 |
wp_factory_activate_execute_step (WpObject * object, |
| 51 |
WpFeatureActivationTransition * transition, guint step, |
| 52 |
WpObjectFeatures missing) |
| 53 |
{ |
| 54 |
switch (step) { |
| 55 |
case WP_PW_OBJECT_MIXIN_STEP_BIND: |
| 56 |
case WP_TRANSITION_STEP_ERROR: |
| 57 |
/* base class can handle BIND and ERROR */ |
| 58 |
WP_OBJECT_CLASS (wp_factory_parent_class)-> |
| 59 |
activate_execute_step (object, transition, step, missing); |
| 60 |
break; |
| 61 |
case WP_PW_OBJECT_MIXIN_STEP_WAIT_INFO: |
| 62 |
/* just wait, info will be emitted anyway after binding */ |
| 63 |
break; |
| 64 |
default: |
| 65 |
g_assert_not_reached (); |
| 66 |
} |
| 67 |
} |
| 68 |
|
| 69 |
static const struct pw_factory_events factory_events = { |
| 70 |
PW_VERSION_FACTORY_EVENTS, |
| 71 |
.info = (HandleEventInfoFunc(factory)) wp_pw_object_mixin_handle_event_info, |
| 72 |
}; |
| 73 |
|
| 74 |
static void |
| 75 |
wp_factory_pw_proxy_created (WpProxy * proxy, struct pw_proxy * pw_proxy) |
| 76 |
{ |
| 77 |
wp_pw_object_mixin_handle_pw_proxy_created (proxy, pw_proxy, |
| 78 |
factory, &factory_events); |
| 79 |
} |
| 80 |
|
| 81 |
static void |
| 82 |
wp_factory_pw_proxy_destroyed (WpProxy * proxy) |
| 83 |
{ |
| 84 |
wp_pw_object_mixin_handle_pw_proxy_destroyed (proxy); |
| 85 |
|
| 86 |
WP_PROXY_CLASS (wp_factory_parent_class)->pw_proxy_destroyed (proxy); |
| 87 |
} |
| 88 |
|
| 89 |
static void |
| 90 |
wp_factory_class_init (WpFactoryClass * klass) |
| 91 |
{ |
| 92 |
GObjectClass *object_class = (GObjectClass *) klass; |
| 93 |
WpObjectClass *wpobject_class = (WpObjectClass *) klass; |
| 94 |
WpProxyClass *proxy_class = (WpProxyClass *) klass; |
| 95 |
|
| 96 |
object_class->get_property = wp_pw_object_mixin_get_property; |
| 97 |
|
| 98 |
wpobject_class->get_supported_features = |
| 99 |
wp_pw_object_mixin_get_supported_features; |
| 100 |
wpobject_class->activate_get_next_step = |
| 101 |
wp_pw_object_mixin_activate_get_next_step; |
| 102 |
wpobject_class->activate_execute_step = wp_factory_activate_execute_step; |
| 103 |
|
| 104 |
proxy_class->pw_iface_type = PW_TYPE_INTERFACE_Factory; |
| 105 |
proxy_class->pw_iface_version = PW_VERSION_FACTORY; |
| 106 |
proxy_class->pw_proxy_created = wp_factory_pw_proxy_created; |
| 107 |
proxy_class->pw_proxy_destroyed = wp_factory_pw_proxy_destroyed; |
| 108 |
|
| 109 |
wp_pw_object_mixin_class_override_properties (object_class); |
| 110 |
} |
| 111 |
|
| 112 |
static void |
| 113 |
wp_factory_pw_object_mixin_priv_interface_init ( |
| 114 |
WpPwObjectMixinPrivInterface * iface) |
| 115 |
{ |
| 116 |
wp_pw_object_mixin_priv_interface_info_init_no_params (iface, factory, FACTORY); |
| 117 |
} |