PipeWire: pipewire/extensions/metadata.h Source File

PipeWire 1.6.4

Loading...
Searching...
No Matches
metadata.h
Go to the documentation of this file.
1/* PipeWire */
2/* SPDX-FileCopyrightText: Copyright © 2019 Wim Taymans */
3/* SPDX-License-Identifier: MIT */
4
5#ifndef PIPEWIRE_EXT_METADATA_H
6#define PIPEWIRE_EXT_METADATA_H
7
8#include <spa/utils/defs.h>
9#include <spa/utils/hook.h>
10
11#include <errno.h>
12
13#ifdef __cplusplus
14extern "C" {
15#endif
16
20
25#define PW_TYPE_INTERFACE_Metadata PW_TYPE_INFO_INTERFACE_BASE "Metadata"
26
27#define PW_METADATA_PERM_MASK PW_PERM_RWX
28
29#define PW_VERSION_METADATA 3
30 struct pw_metadata;
31
32#ifndef PW_API_METADATA_IMPL
33#define PW_API_METADATA_IMPL static inline
34#endif
35
36#define PW_EXTENSION_MODULE_METADATA PIPEWIRE_MODULE_PREFIX "module-metadata"
37
38#define PW_METADATA_EVENT_PROPERTY 0
39#define PW_METADATA_EVENT_NUM 1
40
41
43struct pw_metadata_events {
44#define PW_VERSION_METADATA_EVENTS 0
45 uint32_t version;
46
47 int (*property) (void *data,
48 uint32_t subject,
49 const char *key,
50 const char *type,
51 const char *value);
52};
53
54#define PW_METADATA_METHOD_ADD_LISTENER 0
55#define PW_METADATA_METHOD_SET_PROPERTY 1
56#define PW_METADATA_METHOD_CLEAR 2
57#define PW_METADATA_METHOD_NUM 3
58
60 struct pw_metadata_methods {
61#define PW_VERSION_METADATA_METHODS 0
62 uint32_t version;
63
64 int (*add_listener) (void *object,
65 struct spa_hook *listener,
66 const struct pw_metadata_events *events,
67 void *data);
68
77 * \param key the key of the metadata, NULL clears all metadata for
78 * the subject.
79 * \param type the type of the metadata, this can be blank
80 * \param value the metadata value. NULL clears the metadata.
81 *
82 * This requires X and W permissions on the metadata. It also
83 * requires M permissions on the subject global.
84 */
85 int (*set_property) (void *object,
86 uint32_t subject,
87 const char *key,
88 const char *type,
89 const char *value);
90
96 int (*clear) (void *object);
97};
98
101 PW_API_METADATA_IMPL int pw_metadata_add_listener(struct pw_metadata *object,
102 struct spa_hook *listener,
103 const struct pw_metadata_events *events,
104 void *data)
105{
106 return spa_api_method_r(int, -ENOTSUP,
107 pw_metadata, (struct spa_interface*)object, add_listener, 0,
108 listener, events, data);
109}
112 PW_API_METADATA_IMPL int pw_metadata_set_property(struct pw_metadata *object,
113 uint32_t subject,
114 const char *key,
115 const char *type,
116 const char *value)
117{
118 return spa_api_method_r(int, -ENOTSUP,
119 pw_metadata, (struct spa_interface*)object, set_property, 0,
120 subject, key, type, value);
121}
124 PW_API_METADATA_IMPL int pw_metadata_clear(struct pw_metadata *object)
125{
126 return spa_api_method_r(int, -ENOTSUP,
127 pw_metadata, (struct spa_interface*)object, clear, 0);
128}
129
130#define PW_KEY_METADATA_NAME "metadata.name"
131#define PW_KEY_METADATA_VALUES "metadata.values"
132
136
137#ifdef __cplusplus
138} /* extern "C" */
139#endif
140
141#endif /* PIPEWIRE_EXT_METADATA_H */
defs.h
spa/utils/defs.h
pw_metadata_set_property
PW_API_METADATA_IMPL int pw_metadata_set_property(struct pw_metadata *object, uint32_t subject, const char *key, const char *type, const char *value)
Set a metadata property.
Definition metadata.h:130
PW_API_METADATA_IMPL
#define PW_API_METADATA_IMPL
Definition metadata.h:42
pw_metadata_clear
PW_API_METADATA_IMPL int pw_metadata_clear(struct pw_metadata *object)
Clear all metadata.
Definition metadata.h:142
pw_metadata_add_listener
PW_API_METADATA_IMPL int pw_metadata_add_listener(struct pw_metadata *object, struct spa_hook *listener, const struct pw_metadata_events *events, void *data)
Definition metadata.h:119
spa_api_method_r
#define spa_api_method_r(rtype, def, type, o, method, version,...)
Definition hook.h:291
hook.h
spa/utils/hook.h
pw_metadata_events
Metadata events
Definition metadata.h:55
pw_metadata_events::version
uint32_t version
Definition metadata.h:58
pw_metadata_events::property
int(* property)(void *data, uint32_t subject, const char *key, const char *type, const char *value)
Definition metadata.h:60
pw_metadata_methods
Metadata methods
Definition metadata.h:77
pw_metadata_methods::clear
int(* clear)(void *object)
Clear all metadata.
Definition metadata.h:114
pw_metadata_methods::add_listener
int(* add_listener)(void *object, struct spa_hook *listener, const struct pw_metadata_events *events, void *data)
Definition metadata.h:82
pw_metadata_methods::set_property
int(* set_property)(void *object, uint32_t subject, const char *key, const char *type, const char *value)
Set a metadata property.
Definition metadata.h:103
pw_metadata
spa_hook
A hook, contains the structure with functions and the data passed to the functions.
Definition hook.h:427
spa_interface
Definition hook.h:148