Debian Codegraph @

lib/wp/private/registry.h

raw
1 /* WirePlumber
2 *
3 * Copyright © 2019 Collabora Ltd.
4 * @author George Kiagiadakis <[email protected]>
5 *
6 * SPDX-License-Identifier: MIT
7 */
8
9 #ifndef __WIREPLUMBER_REGISTRY_H__
10 #define __WIREPLUMBER_REGISTRY_H__
11
12 #include "core.h"
13 #include "global-proxy.h"
14
15 #include <pipewire/pipewire.h>
16
17 G_BEGIN_DECLS
18
19 typedef struct _WpRegistry WpRegistry;
20 typedef struct _WpGlobal WpGlobal;
21
22 /* registry */
23
24 struct _WpRegistry
25 {
26 struct pw_registry *pw_registry;
27 struct spa_hook listener;
28
29 GPtrArray *globals; // elementy-type: WpGlobal*
30 GPtrArray *tmp_globals; // elementy-type: WpGlobal*
31 GPtrArray *objects; // element-type: GObject*
32 GPtrArray *object_managers; // element-type: WpObjectManager*
33 GPtrArray *features; // element-type: gchar*
34 };
35
36 void wp_registry_init (WpRegistry *self);
37 void wp_registry_clear (WpRegistry *self);
38 void wp_registry_attach (WpRegistry *self, struct pw_core *pw_core);
39 void wp_registry_detach (WpRegistry *self);
40
41 void wp_registry_prepare_new_global (WpRegistry * self, guint32 id,
42 guint32 permissions, guint32 flag, GType type,
43 WpGlobalProxy *proxy, const struct spa_dict *props,
44 WpGlobal ** new_global);
45
46 void wp_registry_notify_add_object (WpRegistry * self, gpointer object);
47 void wp_registry_notify_rm_object (WpRegistry * self, gpointer object);
48
49 void wp_registry_install_object_manager (WpRegistry * self,
50 WpObjectManager * om);
51
52 static inline void
53 wp_registry_mark_feature_provided (WpRegistry * reg, const gchar * feature)
54 {
55 g_ptr_array_add (reg->features, g_strdup (feature));
56 }
57
58 WpCore * wp_registry_get_core (WpRegistry * self) G_GNUC_CONST;
59
60 /* core */
61
62 WpRegistry * wp_core_get_registry (WpCore * self) G_GNUC_CONST;
63
64 /* global */
65
66 typedef enum {
67 WP_GLOBAL_FLAG_APPEARS_ON_REGISTRY = 0x1,
68 WP_GLOBAL_FLAG_OWNED_BY_PROXY = 0x2,
69 } WpGlobalFlags;
70
71 struct _WpGlobal
72 {
73 guint32 flags;
74 guint32 id;
75 GType type;
76 guint32 permissions;
77 WpProperties *properties;
78 WpGlobalProxy *proxy;
79 WpRegistry *registry;
80 };
81
82 #define WP_TYPE_GLOBAL (wp_global_get_type ())
83 GType wp_global_get_type (void);
84
85 static inline void
86 wp_global_clear (WpGlobal * self)
87 {
88 g_clear_pointer (&self->properties, wp_properties_unref);
89 }
90
91 static inline WpGlobal *
92 wp_global_ref (WpGlobal * self)
93 {
94 return g_rc_box_acquire (self);
95 }
96
97 static inline void
98 wp_global_unref (WpGlobal * self)
99 {
100 g_rc_box_release_full (self, (GDestroyNotify) wp_global_clear);
101 }
102
103 void wp_global_rm_flag (WpGlobal *global, guint rm_flag);
104 struct pw_proxy * wp_global_bind (WpGlobal * global);
105
106 G_DEFINE_AUTOPTR_CLEANUP_FUNC (WpGlobal, wp_global_unref)
107
108 G_END_DECLS
109
110 #endif