PipeWire  0.3.33
impl-metadata.h
Go to the documentation of this file.
1 /* PipeWire
2  *
3  * Copyright © 2021 Wim Taymans
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a
6  * copy of this software and associated documentation files (the "Software"),
7  * to deal in the Software without restriction, including without limitation
8  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9  * and/or sell copies of the Software, and to permit persons to whom the
10  * Software is furnished to do so, subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice (including the next
13  * paragraph) shall be included in all copies or substantial portions of the
14  * Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22  * DEALINGS IN THE SOFTWARE.
23  */
24 
25 #ifndef PIPEWIRE_IMPL_METADATA_H
26 #define PIPEWIRE_IMPL_METADATA_H
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
41 struct pw_impl_metadata;
42 
43 #include <pipewire/context.h>
44 #include <pipewire/impl-client.h>
45 #include <pipewire/global.h>
46 #include <pipewire/properties.h>
47 #include <pipewire/resource.h>
48 
49 #include "pipewire/extensions/metadata.h"
50 
53 #define PW_VERSION_IMPL_METADATA_EVENTS 0
54  uint32_t version;
55 
57  void (*destroy) (void *data);
59  void (*free) (void *data);
60 
62  int (*property) (void *data,
63  uint32_t subject,
64  const char *key,
65  const char *type,
66  const char *value);
67 };
68 
69 struct pw_impl_metadata *pw_context_create_metadata(struct pw_context *context,
70  const char *name, struct pw_properties *properties,
71  size_t user_data_size);
72 
74 const struct pw_properties *pw_impl_metadata_get_properties(struct pw_impl_metadata *metadata);
75 
76 int pw_impl_metadata_register(struct pw_impl_metadata *metadata,
77  struct pw_properties *properties);
78 
79 void pw_impl_metadata_destroy(struct pw_impl_metadata *metadata);
80 
81 void *pw_impl_metadata_get_user_data(struct pw_impl_metadata *metadata);
82 
83 int pw_impl_metadata_set_implementation(struct pw_impl_metadata *metadata,
84  struct pw_metadata *impl);
85 
86 struct pw_metadata *pw_impl_metadata_get_implementation(struct pw_impl_metadata *metadata);
87 
89 struct pw_global *pw_impl_metadata_get_global(struct pw_impl_metadata *metadata);
90 
92 void pw_impl_metadata_add_listener(struct pw_impl_metadata *metadata,
93  struct spa_hook *listener,
94  const struct pw_impl_metadata_events *events,
95  void *data);
96 
98 int pw_impl_metadata_set_property(struct pw_impl_metadata *metadata,
99  uint32_t subject, const char *key, const char *type,
100  const char *value);
101 
102 int pw_impl_metadata_set_propertyf(struct pw_impl_metadata *metadata,
103  uint32_t subject, const char *key, const char *type,
104  const char *fmt, ...) SPA_PRINTF_FUNC(5,6);
105 
110 #ifdef __cplusplus
111 }
112 #endif
113 
114 #endif /* PIPEWIRE_IMPL_METADATA_H */
spa_interface
Definition: hook.h:146
global.h
spa_hook_list_join
void spa_hook_list_join(struct spa_hook_list *list, struct spa_hook_list *save)
Definition: hook.h:366
spa_return_val_if_fail
#define spa_return_val_if_fail(expr, val)
Definition: defs.h:251
pw_impl_metadata_add_listener
void pw_impl_metadata_add_listener(struct pw_impl_metadata *metadata, struct spa_hook *listener, const struct pw_impl_metadata_events *events, void *data)
Add an event listener.
Definition: impl-metadata.c:559
metadata
Definition: impl-metadata.c:43
spa_zero
#define spa_zero(x)
Definition: defs.h:303
pw_global_register
int pw_global_register(struct pw_global *global)
Register a global object to the context registry.
Definition: global.c:125
types.h
PW_KEY_MODULE_ID
#define PW_KEY_MODULE_ID
module properties
Definition: src/pipewire/keys.h:249
resource_data
Definition: impl-core.c:74
name
const char * name
Definition: media-session.c:2379
string.h
pw_impl_metadata_events::version
uint32_t version
Definition: impl-metadata.h:54
pw_metadata_resource_property
#define pw_metadata_resource_property(r,...)
Definition: impl-metadata.c:376
data
user data to add to an object
Definition: filter.c:75
pw_global_new
struct pw_global * pw_global_new(struct pw_context *context, const char *type, uint32_t version, struct pw_properties *properties, pw_global_bind_func_t func, void *object)
Create a new global object.
Definition: global.c:66
pw_global_add_resource
int pw_global_add_resource(struct pw_global *global, struct pw_resource *resource)
Add a resource to a global.
Definition: global.c:230
spa_streq
bool spa_streq(const char *s1, const char *s2)
Definition: string.h:50
resource_data::resource_listener
struct spa_hook resource_listener
Definition: impl-core.c:76
SPA_EXPORT
#define SPA_EXPORT
Definition: defs.h:208
metadata::iface
struct spa_interface iface
Definition: impl-metadata.c:44
pw_global_events
Global events, use pw_global_add_listener.
Definition: global.h:68
pw_array_consume
#define pw_array_consume(pos, array)
Definition: array.h:77
PW_PERM_R
#define PW_PERM_R
object can be seen and events can be received
Definition: permission.h:47
pw_metadata_emit_property
#define pw_metadata_emit_property(hooks,...)
Definition: impl-metadata.c:41
impl
Definition: control.c:33
spa_hook_list_append
void spa_hook_list_append(struct spa_hook_list *list, struct spa_hook *hook, const void *funcs, void *data)
Append a hook.
Definition: hook.h:316
resource_data::metadata_listener
struct spa_hook metadata_listener
Definition: impl-metadata.c:258
SPA_PTROFF
#define SPA_PTROFF(ptr_, offset_, type_)
Return the address (buffer + offset) as pointer of type.
Definition: defs.h:159
pw_array_for_each
#define pw_array_for_each(pos, array)
Definition: array.h:72
pw_impl_metadata_get_user_data
void * pw_impl_metadata_get_user_data(struct pw_impl_metadata *metadata)
Definition: impl-metadata.c:547
SPA_PRINTF_FUNC
#define SPA_PRINTF_FUNC(fmt, arg1)
Definition: defs.h:205
pw_array_remove
#define pw_array_remove(a, p)
Definition: array.h:82
metadata::hooks
struct spa_hook_list hooks
event listeners
Definition: impl-metadata.c:46
SPA_INTERFACE_INIT
#define SPA_INTERFACE_INIT(_type, _version, _funcs, _data)
Initialize a spa_interface.
Definition: hook.h:165
impl.h
metadata::metadata
struct pw_metadata * metadata
Definition: metadata.c:41
SPA_CONTAINER_OF
#define SPA_CONTAINER_OF(p, t, m)
Definition: defs.h:170
pw_array
Definition: array.h:48
impl-client.h
spa_hook_list_isolate
void spa_hook_list_isolate(struct spa_hook_list *list, struct spa_hook_list *save, struct spa_hook *hook, const void *funcs, void *data)
Definition: hook.h:352
item
Definition: impl-metadata.c:49
pw_impl_metadata_set_property
int pw_impl_metadata_set_property(struct pw_impl_metadata *metadata, uint32_t subject, const char *key, const char *type, const char *value)
Set a property.
Definition: impl-metadata.c:568
pw_global_add_listener
void pw_global_add_listener(struct pw_global *global, struct spa_hook *listener, const struct pw_global_events *events, void *data)
Add an event listener on the global.
Definition: global.c:255
pw_context_create_metadata
struct pw_impl_metadata * pw_context_create_metadata(struct pw_context *context, const char *name, struct pw_properties *properties, size_t user_data_size)
Definition: impl-metadata.c:276
spa_list_remove
void spa_list_remove(struct spa_list *elem)
Definition: list.h:69
pw_resource_add_object_listener
void pw_resource_add_object_listener(struct pw_resource *resource, struct spa_hook *listener, const void *funcs, void *data)
Set the resource implementation.
Definition: resource.c:174
resource_data::object_listener
struct spa_hook object_listener
Definition: impl-core.c:77
impl::def
struct metadata def
Definition: impl-metadata.c:249
spa_hook
A hook, contains the structure with functions and the data passed to the functions.
Definition: hook.h:295
pw_resource_errorf
void pw_resource_errorf(struct pw_resource *resource, int res, const char *error,...) 1(3
PW_VERSION_RESOURCE_EVENTS
#define PW_VERSION_RESOURCE_EVENTS
Definition: resource.h:61
resource.h
pw_resource_add_listener
void pw_resource_add_listener(struct pw_resource *resource, struct spa_hook *listener, const struct pw_resource_events *events, void *data)
Add an event listener.
Definition: resource.c:165
pw_impl_metadata_register
int pw_impl_metadata_register(struct pw_impl_metadata *metadata, struct pw_properties *properties)
Definition: impl-metadata.c:508
pw_impl_metadata_set_propertyf
int pw_impl_metadata_set_propertyf(struct pw_impl_metadata *metadata, uint32_t subject, const char *key, const char *type, const char *fmt,...) 1(5
item::key
char * key
Definition: impl-metadata.c:51
pw_impl_metadata_events::property
int(* property)(void *data, uint32_t subject, const char *key, const char *type, const char *value)
a property changed
Definition: impl-metadata.h:62
pw_global_update_keys
int pw_global_update_keys(struct pw_global *global, const struct spa_dict *dict, const char *const keys[])
Update the global properties, must be done when unregistered.
Definition: global.c:209
pw_impl_metadata_get_global
struct pw_global * pw_impl_metadata_get_global(struct pw_impl_metadata *metadata)
Get the global of this metadata.
Definition: impl-metadata.c:553
pw_impl_metadata_set_propertyf
int pw_impl_metadata_set_propertyf(struct pw_impl_metadata *metadata, uint32_t subject, const char *key, const char *type, const char *fmt,...)
Definition: impl-metadata.c:576
spa_strerror
#define spa_strerror(err)
Definition: result.h:51
pw_resource_new
struct pw_resource * pw_resource_new(struct pw_impl_client *client, uint32_t id, uint32_t permissions, const char *type, uint32_t version, size_t user_data_size)
Make a new resource for client.
Definition: resource.c:43
pw_resource_get_client
struct pw_impl_client * pw_resource_get_client(struct pw_resource *resource)
Get the client owning this resource.
Definition: resource.c:127
pw_log_debug
#define pw_log_debug(...)
Definition: src/pipewire/log.h:89
client
Definition: module-protocol-native.c:103
pw_global_destroy
void pw_global_destroy(struct pw_global *global)
Destroy a global.
Definition: global.c:369
pw_impl_metadata_set_implementation
int pw_impl_metadata_set_implementation(struct pw_impl_metadata *metadata, struct pw_metadata *meta)
Definition: impl-metadata.c:320
PW_VERSION_GLOBAL_EVENTS
#define PW_VERSION_GLOBAL_EVENTS
Definition: global.h:69
pw_impl_client_check_permissions
int pw_impl_client_check_permissions(struct pw_impl_client *client, uint32_t global_id, uint32_t permissions)
check if a client has permissions for global_id, Since 0.3.9
Definition: impl-client.c:726
pw_properties_set
int pw_properties_set(struct pw_properties *properties, const char *key, const char *value)
Set a property value.
Definition: properties.c:435
resource_data::data
struct result_device_params_data data
Definition: impl-device.c:76
spa_hook_list
A list of hooks.
Definition: hook.h:284
metadata::storage
struct pw_array storage
Definition: impl-metadata.c:45
item::subject
uint32_t subject
Definition: impl-metadata.c:50
item::value
char * value
Definition: impl-metadata.c:53
resource_data::impl
struct pw_impl_metadata * impl
Definition: impl-metadata.c:253
pw_impl_metadata_events
Metadata events, listen to them with pw_impl_metadata_add_listener.
Definition: impl-metadata.h:52
context.h
impl::this
struct pw_control this
Definition: control.c:34
spa_hook_remove
void spa_hook_remove(struct spa_hook *hook)
Remove a hook.
Definition: hook.h:336
pw_impl_metadata_destroy
void pw_impl_metadata_destroy(struct pw_impl_metadata *metadata)
Definition: impl-metadata.c:346
pw_resource_get_user_data
void * pw_resource_get_user_data(struct pw_resource *resource)
Get the user data for the resource, the size was given in pw_resource_new.
Definition: resource.c:159
pw_log_info
#define pw_log_info(...)
Definition: src/pipewire/log.h:88
resource_data::resource
struct pw_resource * resource
Definition: impl-core.c:75
spa_hook_list_init
void spa_hook_list_init(struct spa_hook_list *list)
Initialize a hook list to the empty list.
Definition: hook.h:305
properties.h
pw_impl_metadata_get_properties
const struct pw_properties * pw_impl_metadata_get_properties(struct pw_impl_metadata *metadata)
Get the metadata properties.
pw_impl_metadata_events::free
void(* free)(void *data)
the metadata is freed
Definition: impl-metadata.h:59
NAME
#define NAME
Definition: impl-metadata.c:35
pw_properties_new
struct pw_properties * pw_properties_new(const char *key,...) 1
Make a new properties object.
Definition: properties.c:98
pw_resource_events
Resource events.
Definition: resource.h:60
item::type
char * type
Definition: impl-metadata.c:52
pw_impl_metadata_events::destroy
void(* destroy)(void *data)
the metadata is destroyed
Definition: impl-metadata.h:57
pw_resource_events::version
uint32_t version
Definition: resource.h:62
impl::metadata
struct pw_impl_metadata * metadata
Definition: settings.c:44
pw_impl_metadata_get_implementation
struct pw_metadata * pw_impl_metadata_get_implementation(struct pw_impl_metadata *metadata)
Definition: impl-metadata.c:340
pw_properties
Definition: properties.h:49
spa_hook_list_clean
void spa_hook_list_clean(struct spa_hook_list *list)
Remove all hooks from the list.
Definition: hook.h:344
pw_properties_free
void pw_properties_free(struct pw_properties *properties)
Free a properties object.
Definition: properties.c:364
pw_log_error
#define pw_log_error(...)
Definition: src/pipewire/log.h:86
spa_list_append
#define spa_list_append(list, item)
Definition: list.h:81