| 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 <pw-headers/spa/utils/defs.h> |
| 9 |
#include <pw-headers/spa/utils/hook.h> |
| 10 |
|
| 11 |
#include <errno.h> |
| 12 |
|
| 13 |
#ifdef __cplusplus |
| 14 |
extern "C" { |
| 15 |
#endif |
| 16 |
|
| 17 |
/** \defgroup pw_metadata Metadata |
| 18 |
* Metadata interface |
| 19 |
*/ |
| 20 |
|
| 21 |
/** |
| 22 |
* \addtogroup pw_metadata |
| 23 |
* \{ |
| 24 |
*/ |
| 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 |
|
| 42 |
/** \ref pw_metadata events */ |
| 43 |
struct 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 |
|
| 59 |
/** \ref pw_metadata methods */ |
| 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 |
|
| 69 |
/** |
| 70 |
* Set a metadata property |
| 71 |
* |
| 72 |
* Automatically emit property events for the subject and key |
| 73 |
* when they are changed. |
| 74 |
* |
| 75 |
* \param subject the id of the global to associate the metadata |
| 76 |
* with. |
| 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 |
|
| 91 |
/** |
| 92 |
* Clear all metadata |
| 93 |
* |
| 94 |
* This requires X and W permissions on the metadata. |
| 95 |
*/ |
| 96 |
int (*clear) (void *object); |
| 97 |
}; |
| 98 |
|
| 99 |
/** \copydoc pw_metadata_methods.add_listener |
| 100 |
* \sa pw_metadata_methods.add_listener */ |
| 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 |
} |
| 110 |
/** \copydoc pw_metadata_methods.set_property |
| 111 |
* \sa pw_metadata_methods.set_property */ |
| 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 |
} |
| 122 |
/** \copydoc pw_metadata_methods.clear |
| 123 |
* \sa pw_metadata_methods.clear */ |
| 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 |
|
| 133 |
/** |
| 134 |
* \} |
| 135 |
*/ |
| 136 |
|
| 137 |
#ifdef __cplusplus |
| 138 |
} /* extern "C" */ |
| 139 |
#endif |
| 140 |
|
| 141 |
#endif /* PIPEWIRE_EXT_METADATA_H */ |