2020-05-01 17:51:12 +03:00
|
|
|
/* WirePlumber
|
|
|
|
|
*
|
|
|
|
|
* Copyright © 2020 Collabora Ltd.
|
|
|
|
|
* @author George Kiagiadakis <george.kiagiadakis@collabora.com>
|
|
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef __WIREPLUMBER_OBJECT_INTEREST_H__
|
|
|
|
|
#define __WIREPLUMBER_OBJECT_INTEREST_H__
|
|
|
|
|
|
|
|
|
|
#include <glib-object.h>
|
|
|
|
|
#include "defs.h"
|
|
|
|
|
#include "properties.h"
|
|
|
|
|
|
|
|
|
|
G_BEGIN_DECLS
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* WpConstraintType:
|
|
|
|
|
* @WP_CONSTRAINT_TYPE_NONE: invalid constraint type
|
|
|
|
|
* @WP_CONSTRAINT_TYPE_PW_GLOBAL_PROPERTY: constraint applies
|
|
|
|
|
* to a PipeWire global property of the object (the ones returned by
|
lib: refactor WpProxy
This is an attempt to unclutter the API of WpProxy and
split functionality into smaller pieces, making it easier
to work with.
In this new class layout, we have the following classes:
- WpObject: base class for everything; handles activating
| and deactivating "features"
|- WpProxy: base class for anything that wraps a pw_proxy;
| handles events from pw_proxy and nothing more
|- WpGlobalProxy: handles integration with the registry
All the other classes derive from WpGlobalProxy. The reason
for separating WpGlobalProxy from WpProxy, though, is that
classes such as WpImplNode / WpSpaDevice can also derive from
WpProxy now, without interfacing with the registry.
All objects that come with an "info" structure and have properties
and/or params also implement the WpPipewireObject interface. This
provides the API to query properties and get/set params. Essentially,
this is implemented by all classes except WpMetadata (pw_metadata
does not have info)
This interface is implemented on each object separately, using
a private "mixin", which is a set of vfunc implementations and helper
functions (and macros) to facilitate the implementation of this interface.
A notable difference to the old WpProxy is that now features can be
deactivated, so it is possible to enable something and later disable
it again.
This commit disables modules, tests, tools, etc, to avoid growing the
patch more, while ensuring that the project compiles.
2020-11-10 19:17:02 +02:00
|
|
|
* wp_global_proxy_get_global_properties())
|
2020-05-01 17:51:12 +03:00
|
|
|
* @WP_CONSTRAINT_TYPE_PW_PROPERTY: constraint applies
|
|
|
|
|
* to a PipeWire property of the object (the ones returned by
|
lib: refactor WpProxy
This is an attempt to unclutter the API of WpProxy and
split functionality into smaller pieces, making it easier
to work with.
In this new class layout, we have the following classes:
- WpObject: base class for everything; handles activating
| and deactivating "features"
|- WpProxy: base class for anything that wraps a pw_proxy;
| handles events from pw_proxy and nothing more
|- WpGlobalProxy: handles integration with the registry
All the other classes derive from WpGlobalProxy. The reason
for separating WpGlobalProxy from WpProxy, though, is that
classes such as WpImplNode / WpSpaDevice can also derive from
WpProxy now, without interfacing with the registry.
All objects that come with an "info" structure and have properties
and/or params also implement the WpPipewireObject interface. This
provides the API to query properties and get/set params. Essentially,
this is implemented by all classes except WpMetadata (pw_metadata
does not have info)
This interface is implemented on each object separately, using
a private "mixin", which is a set of vfunc implementations and helper
functions (and macros) to facilitate the implementation of this interface.
A notable difference to the old WpProxy is that now features can be
deactivated, so it is possible to enable something and later disable
it again.
This commit disables modules, tests, tools, etc, to avoid growing the
patch more, while ensuring that the project compiles.
2020-11-10 19:17:02 +02:00
|
|
|
* wp_pipewire_object_get_properties())
|
2020-05-01 17:51:12 +03:00
|
|
|
* @WP_CONSTRAINT_TYPE_G_PROPERTY: constraint applies to a #GObject
|
|
|
|
|
* property of the object
|
|
|
|
|
*/
|
|
|
|
|
typedef enum {
|
|
|
|
|
WP_CONSTRAINT_TYPE_NONE = 0,
|
|
|
|
|
WP_CONSTRAINT_TYPE_PW_GLOBAL_PROPERTY,
|
|
|
|
|
WP_CONSTRAINT_TYPE_PW_PROPERTY,
|
|
|
|
|
WP_CONSTRAINT_TYPE_G_PROPERTY,
|
|
|
|
|
} WpConstraintType;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* WpConstraintVerb:
|
|
|
|
|
* @WP_CONSTRAINT_VERB_EQUALS: `=` the subject's value must equal the
|
|
|
|
|
* constraint's value
|
2021-02-02 12:50:19 +02:00
|
|
|
* @WP_CONSTRAINT_VERB_NOT_EQUALS: `!` the subject's value must be different
|
|
|
|
|
* from the constraint's value
|
2020-05-01 17:51:12 +03:00
|
|
|
* @WP_CONSTRAINT_VERB_IN_LIST: `c` the subject's value must equal at least
|
|
|
|
|
* one of the values in the list given as the constraint's value
|
|
|
|
|
* @WP_CONSTRAINT_VERB_IN_RANGE: `~` the subject's value must be a number
|
|
|
|
|
* in the range defined by the constraint's value
|
|
|
|
|
* @WP_CONSTRAINT_VERB_MATCHES: `#` the subject's value must match the
|
|
|
|
|
* pattern specified in the constraint's value
|
|
|
|
|
* @WP_CONSTRAINT_VERB_IS_PRESENT: `+` the subject property must exist
|
|
|
|
|
* @WP_CONSTRAINT_VERB_IS_ABSENT: `-` the subject property must not exist
|
|
|
|
|
*/
|
|
|
|
|
typedef enum {
|
|
|
|
|
WP_CONSTRAINT_VERB_EQUALS = '=',
|
2021-02-02 12:50:19 +02:00
|
|
|
WP_CONSTRAINT_VERB_NOT_EQUALS = '!',
|
2020-05-01 17:51:12 +03:00
|
|
|
WP_CONSTRAINT_VERB_IN_LIST = 'c',
|
|
|
|
|
WP_CONSTRAINT_VERB_IN_RANGE = '~',
|
|
|
|
|
WP_CONSTRAINT_VERB_MATCHES = '#',
|
|
|
|
|
WP_CONSTRAINT_VERB_IS_PRESENT = '+',
|
|
|
|
|
WP_CONSTRAINT_VERB_IS_ABSENT = '-',
|
|
|
|
|
} WpConstraintVerb;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* WP_TYPE_OBJECT_INTEREST:
|
|
|
|
|
*
|
|
|
|
|
* The #WpObjectInterest #GType
|
|
|
|
|
*/
|
|
|
|
|
#define WP_TYPE_OBJECT_INTEREST (wp_object_interest_get_type ())
|
|
|
|
|
WP_API
|
|
|
|
|
GType wp_object_interest_get_type (void) G_GNUC_CONST;
|
|
|
|
|
|
|
|
|
|
typedef struct _WpObjectInterest WpObjectInterest;
|
|
|
|
|
|
|
|
|
|
WP_API
|
|
|
|
|
WpObjectInterest * wp_object_interest_new (GType gtype, ...) G_GNUC_NULL_TERMINATED;
|
|
|
|
|
|
|
|
|
|
WP_API
|
|
|
|
|
WpObjectInterest * wp_object_interest_new_valist (GType gtype, va_list * args);
|
|
|
|
|
|
|
|
|
|
WP_API
|
|
|
|
|
WpObjectInterest * wp_object_interest_new_type (GType gtype);
|
|
|
|
|
|
|
|
|
|
WP_API
|
|
|
|
|
void wp_object_interest_add_constraint (WpObjectInterest * self,
|
|
|
|
|
WpConstraintType type, const gchar * subject,
|
|
|
|
|
WpConstraintVerb verb, GVariant * value);
|
|
|
|
|
|
|
|
|
|
WP_API
|
|
|
|
|
WpObjectInterest * wp_object_interest_copy (WpObjectInterest * self);
|
|
|
|
|
|
|
|
|
|
WP_API
|
2021-01-19 10:52:50 -05:00
|
|
|
WpObjectInterest * wp_object_interest_ref (WpObjectInterest *self);
|
|
|
|
|
|
|
|
|
|
WP_API
|
|
|
|
|
void wp_object_interest_unref (WpObjectInterest * self);
|
2020-05-01 17:51:12 +03:00
|
|
|
|
|
|
|
|
WP_API
|
|
|
|
|
gboolean wp_object_interest_validate (WpObjectInterest * self, GError ** error);
|
|
|
|
|
|
|
|
|
|
WP_API
|
|
|
|
|
gboolean wp_object_interest_matches (WpObjectInterest * self, gpointer object);
|
|
|
|
|
|
|
|
|
|
WP_API
|
|
|
|
|
gboolean wp_object_interest_matches_full (WpObjectInterest * self,
|
|
|
|
|
GType object_type, gpointer object, WpProperties * pw_props,
|
|
|
|
|
WpProperties * pw_global_props);
|
|
|
|
|
|
2021-01-19 10:52:50 -05:00
|
|
|
G_DEFINE_AUTOPTR_CLEANUP_FUNC (WpObjectInterest, wp_object_interest_unref)
|
2020-05-01 17:51:12 +03:00
|
|
|
|
|
|
|
|
G_END_DECLS
|
|
|
|
|
|
|
|
|
|
#endif
|