diff options
author | Wim Taymans <wtaymans@redhat.com> | 2019-12-11 14:39:31 +0100 |
---|---|---|
committer | Wim Taymans <wtaymans@redhat.com> | 2019-12-11 14:44:59 +0100 |
commit | aa378417c2f931053704b8d13fa1ecb33da4c150 (patch) | |
tree | 360c4a8255da211464505d7f636bac805eb10f2b | |
parent | b75f2aaabd54cdbc7f9c055977379cb790bc01af (diff) |
interfaces: move proxy API into their own header files
26 files changed, 1039 insertions, 858 deletions
diff --git a/pipewire-pulseaudio/src/internal.h b/pipewire-pulseaudio/src/internal.h index 552d5f6d..4cf18599 100644 --- a/pipewire-pulseaudio/src/internal.h +++ b/pipewire-pulseaudio/src/internal.h @@ -33,10 +33,7 @@ #include <pulse/introspect.h> #include <pulse/version.h> -#include <pipewire/array.h> -#include <pipewire/utils.h> -#include <pipewire/interfaces.h> -#include <pipewire/log.h> +#include <pipewire/pipewire.h> #include <extensions/session-manager.h> /* Some PulseAudio API added const qualifiers in 13.0 */ diff --git a/src/modules/module-client-node/v0/client-node.c b/src/modules/module-client-node/v0/client-node.c index 3a96327c..e1bb105e 100644 --- a/src/modules/module-client-node/v0/client-node.c +++ b/src/modules/module-client-node/v0/client-node.c @@ -33,7 +33,6 @@ #include <spa/utils/keys.h> #include "pipewire/pipewire.h" -#include "pipewire/interfaces.h" #include "pipewire/private.h" #include "pipewire/context.h" diff --git a/src/modules/module-client-node/v0/protocol-native.c b/src/modules/module-client-node/v0/protocol-native.c index 89a46f8e..f0f6a138 100644 --- a/src/modules/module-client-node/v0/protocol-native.c +++ b/src/modules/module-client-node/v0/protocol-native.c @@ -21,10 +21,7 @@ #include <spa/pod/parser.h> -#include "pipewire/pipewire.h" -#include "pipewire/interfaces.h" -#include "pipewire/protocol.h" -#include "pipewire/impl-client.h" +#include "pipewire/impl.h" #include "pipewire/private.h" #include "extensions/protocol-native.h" diff --git a/src/modules/module-protocol-native/v0/interfaces.h b/src/modules/module-protocol-native/v0/interfaces.h index 5730fd02..1eb678c9 100644 --- a/src/modules/module-protocol-native/v0/interfaces.h +++ b/src/modules/module-protocol-native/v0/interfaces.h @@ -28,8 +28,7 @@ extern "C" { #include <spa/param/param.h> #include <spa/node/node.h> -#include <pipewire/introspect.h> -#include <pipewire/proxy.h> +#include <pipewire/pipewire.h> /** Core */ diff --git a/src/pipewire/client.h b/src/pipewire/client.h new file mode 100644 index 00000000..b84c39b9 --- /dev/null +++ b/src/pipewire/client.h @@ -0,0 +1,166 @@ +/* PipeWire + * + * Copyright © 2018 Wim Taymans + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#ifndef PIPEWIRE_CLIENT_H +#define PIPEWIRE_CLIENT_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include <spa/utils/defs.h> +#include <spa/param/param.h> + +#include <pipewire/proxy.h> +#include <pipewire/permission.h> + +/** The client information. Extra information can be added in later versions \memberof pw_introspect */ +struct pw_client_info { + uint32_t id; /**< id of the global */ +#define PW_CLIENT_CHANGE_MASK_PROPS (1 << 0) +#define PW_CLIENT_CHANGE_MASK_ALL ((1 << 1)-1) + uint64_t change_mask; /**< bitfield of changed fields since last call */ + struct spa_dict *props; /**< extra properties */ +}; + +/** Update and existing \ref pw_client_info with \a update \memberof pw_introspect */ +struct pw_client_info * +pw_client_info_update(struct pw_client_info *info, + const struct pw_client_info *update); + +/** Free a \ref pw_client_info \memberof pw_introspect */ +void pw_client_info_free(struct pw_client_info *info); + + +#define PW_VERSION_CLIENT_PROXY 3 +struct pw_client_proxy; + +#define PW_CLIENT_PROXY_EVENT_INFO 0 +#define PW_CLIENT_PROXY_EVENT_PERMISSIONS 1 +#define PW_CLIENT_PROXY_EVENT_NUM 2 + +/** Client events */ +struct pw_client_proxy_events { +#define PW_VERSION_CLIENT_PROXY_EVENTS 0 + uint32_t version; + /** + * Notify client info + * + * \param info info about the client + */ + void (*info) (void *object, const struct pw_client_info *info); + /** + * Notify a client permission + * + * Event emited as a result of the get_permissions method. + * + * \param default_permissions the default permissions + * \param index the index of the first permission entry + * \param n_permissions the number of permissions + * \param permissions the permissions + */ + void (*permissions) (void *object, + uint32_t index, + uint32_t n_permissions, + const struct pw_permission *permissions); +}; + + +#define PW_CLIENT_PROXY_METHOD_ADD_LISTENER 0 +#define PW_CLIENT_PROXY_METHOD_ERROR 1 +#define PW_CLIENT_PROXY_METHOD_UPDATE_PROPERTIES 2 +#define PW_CLIENT_PROXY_METHOD_GET_PERMISSIONS 3 +#define PW_CLIENT_PROXY_METHOD_UPDATE_PERMISSIONS 4 +#define PW_CLIENT_PROXY_METHOD_NUM 5 + +/** Client methods */ +struct pw_client_proxy_methods { +#define PW_VERSION_CLIENT_PROXY_METHODS 0 + uint32_t version; + + int (*add_listener) (void *object, + struct spa_hook *listener, + const struct pw_client_proxy_events *events, + void *data); + /** + * Send an error to a client + * + * \param id the global id to report the error on + * \param res an errno style error code + * \param message an error string + */ + int (*error) (void *object, uint32_t id, int res, const char *message); + /** + * Update client properties + * + * \param props new properties + */ + int (*update_properties) (void *object, const struct spa_dict *props); + + /** + * Get client permissions + * + * A permissions event will be emited with the permissions. + * + * \param index the first index to query, 0 for first + * \param num the maximum number of items to get + */ + int (*get_permissions) (void *object, uint32_t index, uint32_t num); + /** + * Manage the permissions of the global objects for this + * client + * + * Update the permissions of the global objects using the + * provided array with permissions + * + * Globals can use the default permissions or can have specific + * permissions assigned to them. + * + * \param n_permissions number of permissions + * \param permissions array of permissions + */ + int (*update_permissions) (void *object, uint32_t n_permissions, + const struct pw_permission *permissions); +}; + +#define pw_client_proxy_method(o,method,version,...) \ +({ \ + int _res = -ENOTSUP; \ + spa_interface_call_res((struct spa_interface*)o, \ + struct pw_client_proxy_methods, _res, \ + method, version, ##__VA_ARGS__); \ + _res; \ +}) + +#define pw_client_proxy_add_listener(c,...) pw_client_proxy_method(c,add_listener,0,__VA_ARGS__) +#define pw_client_proxy_error(c,...) pw_client_proxy_method(c,error,0,__VA_ARGS__) +#define pw_client_proxy_update_properties(c,...) pw_client_proxy_method(c,update_properties,0,__VA_ARGS__) +#define pw_client_proxy_get_permissions(c,...) pw_client_proxy_method(c,get_permissions,0,__VA_ARGS__) +#define pw_client_proxy_update_permissions(c,...) pw_client_proxy_method(c,update_permissions,0,__VA_ARGS__) + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* PIPEWIRE_CLIENT_H */ diff --git a/src/pipewire/context.h b/src/pipewire/context.h index 4e983c3c..b012b884 100644 --- a/src/pipewire/context.h +++ b/src/pipewire/context.h @@ -46,8 +46,6 @@ struct pw_global; struct pw_impl_client; struct pw_impl_factory; -#include <pipewire/introspect.h> -#include <pipewire/interfaces.h> #include <pipewire/core.h> #include <pipewire/loop.h> #include <pipewire/properties.h> diff --git a/src/pipewire/core.h b/src/pipewire/core.h index 9b856cdc..13b1047b 100644 --- a/src/pipewire/core.h +++ b/src/pipewire/core.h @@ -30,6 +30,7 @@ extern "C" { #endif #include <stdarg.h> +#include <errno.h> #include <spa/utils/hook.h> diff --git a/src/pipewire/device.h b/src/pipewire/device.h new file mode 100644 index 00000000..84287477 --- /dev/null +++ b/src/pipewire/device.h @@ -0,0 +1,147 @@ +/* PipeWire + * + * Copyright © 2018 Wim Taymans + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#ifndef PIPEWIRE_DEVICE_H +#define PIPEWIRE_DEVICE_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include <spa/utils/defs.h> +#include <spa/utils/hook.h> + +#include <pipewire/proxy.h> + +#define PW_VERSION_DEVICE_PROXY 3 +struct pw_device_proxy; + +/** The device information. Extra information can be added in later versions \memberof pw_introspect */ +struct pw_device_info { + uint32_t id; /**< id of the global */ +#define PW_DEVICE_CHANGE_MASK_PROPS (1 << 0) +#define PW_DEVICE_CHANGE_MASK_PARAMS (1 << 1) +#define PW_DEVICE_CHANGE_MASK_ALL ((1 << 2)-1) + uint64_t change_mask; /**< bitfield of changed fields since last call */ + struct spa_dict *props; /**< extra properties */ + struct spa_param_info *params; /**< parameters */ + uint32_t n_params; /**< number of items in \a params */ +}; + +/** Update and existing \ref pw_device_info with \a update \memberof pw_introspect */ +struct pw_device_info * +pw_device_info_update(struct pw_device_info *info, + const struct pw_device_info *update); + +/** Free a \ref pw_device_info \memberof pw_introspect */ +void pw_device_info_free(struct pw_device_info *info); + +#define PW_DEVICE_PROXY_EVENT_INFO 0 +#define PW_DEVICE_PROXY_EVENT_PARAM 1 +#define PW_DEVICE_PROXY_EVENT_NUM 2 + +/** Device events */ +struct pw_device_proxy_events { +#define PW_VERSION_DEVICE_PROXY_EVENTS 0 + uint32_t version; + /** + * Notify device info + * + * \param info info about the device + */ + void (*info) (void *object, const struct pw_device_info *info); + /** + * Notify a device param + * + * Event emited as a result of the enum_params method. + * + * \param seq the sequence number of the request + * \param id the param id + * \param index the param index + * \param next the param index of the next param + * \param param the parameter + */ + void (*param) (void *object, int seq, + uint32_t id, uint32_t index, uint32_t next, + const struct spa_pod *param); +}; + + +#define PW_DEVICE_PROXY_METHOD_ADD_LISTENER 0 +#define PW_DEVICE_PROXY_METHOD_ENUM_PARAMS 1 +#define PW_DEVICE_PROXY_METHOD_SET_PARAM 2 +#define PW_DEVICE_PROXY_METHOD_NUM 3 + +/** Device methods */ +struct pw_device_proxy_methods { +#define PW_VERSION_DEVICE_PROXY_METHODS 0 + uint32_t version; + + int (*add_listener) (void *object, + struct spa_hook *listener, + const struct pw_device_proxy_events *events, + void *data); + /** + * Enumerate device parameters + * + * Start enumeration of device parameters. For each param, a + * param event will be emited. + * + * \param seq a sequence number to place in the reply + * \param id the parameter id to enum or SPA_ID_INVALID for all + * \param start the start index or 0 for the first param + * \param num the maximum number of params to retrieve + * \param filter a param filter or NULL + */ + int (*enum_params) (void *object, int seq, uint32_t id, uint32_t start, uint32_t num, + const struct spa_pod *filter); + /** + * Set a parameter on the device + * + * \param id the parameter id to set + * \param flags extra parameter flags + * \param param the parameter to set + */ + int (*set_param) (void *object, uint32_t id, uint32_t flags, + const struct spa_pod *param); +}; + +#define pw_device_proxy_method(o,method,version,...) \ +({ \ + int _res = -ENOTSUP; \ + spa_interface_call_res((struct spa_interface*)o, \ + struct pw_device_proxy_methods, _res, \ + method, version, ##__VA_ARGS__); \ + _res; \ +}) + +#define pw_device_proxy_add_listener(c,...) pw_device_proxy_method(c,add_listener,0,__VA_ARGS__) +#define pw_device_proxy_enum_params(c,...) pw_device_proxy_method(c,enum_params,0,__VA_ARGS__) +#define pw_device_proxy_set_param(c,...) pw_device_proxy_method(c,set_param,0,__VA_ARGS__) + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* PIPEWIRE_DEVICE_H */ diff --git a/src/pipewire/factory.h b/src/pipewire/factory.h new file mode 100644 index 00000000..e8854eb2 --- /dev/null +++ b/src/pipewire/factory.h @@ -0,0 +1,107 @@ +/* PipeWire + * + * Copyright © 2018 Wim Taymans + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#ifndef PIPEWIRE_FACTORY_H +#define PIPEWIRE_FACTORY_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include <stdarg.h> +#include <errno.h> + +#include <spa/utils/defs.h> +#include <spa/utils/hook.h> + +#include <pipewire/proxy.h> + +#define PW_VERSION_FACTORY_PROXY 3 +struct pw_factory_proxy; + +/** The factory information. Extra information can be added in later versions \memberof pw_introspect */ +struct pw_factory_info { + uint32_t id; /**< id of the global */ + const char *name; /**< name the factory */ + uint32_t type; /**< type of the objects created by this factory */ + uint32_t version; /**< version of the objects */ +#define PW_FACTORY_CHANGE_MASK_PROPS (1 << 0) +#define PW_FACTORY_CHANGE_MASK_ALL ((1 << 1)-1) + uint64_t change_mask; /**< bitfield of changed fields since last call */ + struct spa_dict *props; /**< the properties of the factory */ +}; + +struct pw_factory_info * +pw_factory_info_update(struct pw_factory_info *info, + const struct pw_factory_info *update); + +void +pw_factory_info_free(struct pw_factory_info *info); + + +#define PW_FACTORY_PROXY_EVENT_INFO 0 +#define PW_FACTORY_PROXY_EVENT_NUM 1 + +/** Factory events */ +struct pw_factory_proxy_events { +#define PW_VERSION_FACTORY_PROXY_EVENTS 0 + uint32_t version; + /** + * Notify factory info + * + * \param info info about the factory + */ + void (*info) (void *object, const struct pw_factory_info *info); +}; + +#define PW_FACTORY_PROXY_METHOD_ADD_LISTENER 0 +#define PW_FACTORY_PROXY_METHOD_NUM 1 + +/** Factory methods */ +struct pw_factory_proxy_methods { +#define PW_VERSION_FACTORY_PROXY_METHODS 0 + uint32_t version; + + int (*add_listener) (void *object, + struct spa_hook *listener, + const struct pw_factory_proxy_events *events, + void *data); +}; + +#define pw_factory_proxy_method(o,method,version,...) \ +({ \ + int _res = -ENOTSUP; \ + spa_interface_call_res((struct spa_interface*)o, \ + struct pw_factory_proxy_methods, _res, \ + method, version, ##__VA_ARGS__); \ + _res; \ +}) + +#define pw_factory_proxy_add_listener(c,...) pw_factory_proxy_method(c,add_listener,0,__VA_ARGS__) + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* PIPEWIRE_FACTORY_H */ diff --git a/src/pipewire/global.c b/src/pipewire/global.c index 1bbf2bfe..9f8dc810 100644 --- a/src/pipewire/global.c +++ b/src/pipewire/global.c @@ -27,10 +27,8 @@ #include <time.h> #include <stdio.h> +#include <pipewire/impl.h> #include <pipewire/private.h> -#include <pipewire/global.h> -#include <pipewire/interfaces.h> -#include <pipewire/type.h> #include <spa/debug/types.h> diff --git a/src/pipewire/impl-client.c b/src/pipewire/impl-client.c index 628e948d..8253ef3c 100644 --- a/src/pipewire/impl-client.c +++ b/src/pipewire/impl-client.c @@ -25,12 +25,8 @@ #include <errno.h> #include <string.h> -#include "pipewire/interfaces.h" -#include "pipewire/impl-client.h" +#include "pipewire/impl.h" #include "pipewire/private.h" -#include "pipewire/resource.h" -#include "pipewire/type.h" -#include "pipewire/keys.h" #define NAME "client" diff --git a/src/pipewire/impl-client.h b/src/pipewire/impl-client.h index c3986728..d79996a4 100644 --- a/src/pipewire/impl-client.h +++ b/src/pipewire/impl-client.h @@ -45,7 +45,6 @@ struct pw_impl_client; #include <pipewire/context.h> #include <pipewire/global.h> -#include <pipewire/introspect.h> #include <pipewire/properties.h> #include <pipewire/resource.h> #include <pipewire/permission.h> diff --git a/src/pipewire/interfaces.h b/src/pipewire/interfaces.h deleted file mode 100644 index 3e106d97..00000000 --- a/src/pipewire/interfaces.h +++ /dev/null @@ -1,583 +0,0 @@ -/* PipeWire - * - * Copyright © 2018 Wim Taymans - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#ifndef PIPEWIRE_INTERFACES_H -#define PIPEWIRE_INTERFACES_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include <stdarg.h> -#include <errno.h> - -#include <spa/utils/defs.h> -#include <spa/utils/hook.h> -#include <spa/node/command.h> -#include <spa/param/param.h> - -#include <pipewire/introspect.h> -#include <pipewire/proxy.h> -#include <pipewire/permission.h> - -#define PW_VERSION_MODULE_PROXY 3 -struct pw_module_proxy; -#define PW_VERSION_DEVICE_PROXY 3 -struct pw_device_proxy; -#define PW_VERSION_NODE_PROXY 3 -struct pw_node_proxy; -#define PW_VERSION_PORT_PROXY 3 -struct pw_port_proxy; -#define PW_VERSION_FACTORY_PROXY 3 -struct pw_factory_proxy; -#define PW_VERSION_CLIENT_PROXY 3 -struct pw_client_proxy; -#define PW_VERSION_LINK_PROXY 3 -struct pw_link_proxy; - -/** - * \page page_pipewire_protocol The PipeWire protocol - * \section page_ifaces_pipewire Interfaces - * - \subpage page_iface_pw_core - core global object - * - \subpage page_iface_pw_registry - global registry object - */ - -/** - * \page page_iface_pw_core pw_core - * \section page_iface_pw_core_desc Description - * - * The core global object. This is a special singleton object. It - * is used for internal PipeWire protocol features. - * \section page_iface_pw_core API - */ - - -#define PW_MODULE_PROXY_EVENT_INFO 0 -#define PW_MODULE_PROXY_EVENT_NUM 1 - -/** Module events */ -struct pw_module_proxy_events { -#define PW_VERSION_MODULE_PROXY_EVENTS 0 - uint32_t version; - /** - * Notify module info - * - * \param info info about the module - */ - void (*info) (void *object, const struct pw_module_info *info); -}; - -#define PW_MODULE_PROXY_METHOD_ADD_LISTENER 0 -#define PW_MODULE_PROXY_METHOD_NUM 1 - -/** Module methods */ -struct pw_module_proxy_methods { -#define PW_VERSION_MODULE_PROXY_METHODS 0 - uint32_t version; - - int (*add_listener) (void *object, - struct spa_hook *listener, - const struct pw_module_proxy_events *events, - void *data); -}; - -#define pw_module_proxy_method(o,method,version,...) \ -({ \ - int _res = -ENOTSUP; \ - spa_interface_call_res((struct spa_interface*)o, \ - struct pw_module_proxy_methods, _res, \ - method, version, ##__VA_ARGS__); \ - _res; \ -}) - -#define pw_module_proxy_add_listener(c,...) pw_module_proxy_method(c,add_listener,0,__VA_ARGS__) - -#define PW_DEVICE_PROXY_EVENT_INFO 0 -#define PW_DEVICE_PROXY_EVENT_PARAM 1 -#define PW_DEVICE_PROXY_EVENT_NUM 2 - -/** Device events */ -struct pw_device_proxy_events { -#define PW_VERSION_DEVICE_PROXY_EVENTS 0 - uint32_t version; - /** - * Notify device info - * - * \param info info about the device - */ - void (*info) (void *object, const struct pw_device_info *info); - /** - * Notify a device param - * - * Event emited as a result of the enum_params method. - * - * \param seq the sequence number of the request - * \param id the param id - * \param index the param index - * \param next the param index of the next param - * \param param the parameter - */ - void (*param) (void *object, int seq, - uint32_t id, uint32_t index, uint32_t next, - const struct spa_pod *param); -}; - - -#define PW_DEVICE_PROXY_METHOD_ADD_LISTENER 0 -#define PW_DEVICE_PROXY_METHOD_ENUM_PARAMS 1 -#define PW_DEVICE_PROXY_METHOD_SET_PARAM 2 -#define PW_DEVICE_PROXY_METHOD_NUM 3 - -/** Device methods */ -struct pw_device_proxy_methods { -#define PW_VERSION_DEVICE_PROXY_METHODS 0 - uint32_t version; - - int (*add_listener) (void *object, - struct spa_hook *listener, - const struct pw_device_proxy_events *events, - void *data); - /** - * Enumerate device parameters - * - * Start enumeration of device parameters. For each param, a - * param event will be emited. - * - * \param seq a sequence number to place in the reply - * \param id the parameter id to enum or SPA_ID_INVALID for all - * \param start the start index or 0 for the first param - * \param num the maximum number of params to retrieve - * \param filter a param filter or NULL - */ - int (*enum_params) (void *object, int seq, uint32_t id, uint32_t start, uint32_t num, - const struct spa_pod *filter); - /** - * Set a parameter on the device - * - * \param id the parameter id to set - * \param flags extra parameter flags - * \param param the parameter to set - */ - int (*set_param) (void *object, uint32_t id, uint32_t flags, - const struct spa_pod *param); -}; - -#define pw_device_proxy_method(o,method,version,...) \ -({ \ - int _res = -ENOTSUP; \ - spa_interface_call_res((struct spa_interface*)o, \ - struct pw_device_proxy_methods, _res, \ - method, version, ##__VA_ARGS__); \ - _res; \ -}) - -#define pw_device_proxy_add_listener(c,...) pw_device_proxy_method(c,add_listener,0,__VA_ARGS__) -#define pw_device_proxy_enum_params(c,...) pw_device_proxy_method(c,enum_params,0,__VA_ARGS__) -#define pw_device_proxy_set_param(c,...) pw_device_proxy_method(c,set_param,0,__VA_ARGS__) - - -#define PW_NODE_PROXY_EVENT_INFO 0 -#define PW_NODE_PROXY_EVENT_PARAM 1 -#define PW_NODE_PROXY_EVENT_NUM 2 - -/** Node events */ -struct pw_node_proxy_events { -#define PW_VERSION_NODE_PROXY_EVENTS 0 - uint32_t version; - /** - * Notify node info - * - * \param info info about the node - */ - void (*info) (void *object, const struct pw_node_info *info); - /** - * Notify a node param - * - * Event emited as a result of the enum_params method. - * - * \param seq the sequence number of the request - * \param id the param id - * \param index the param index - * \param next the param index of the next param - * \param param the parameter - */ - void (*param) (void *object, int seq, - uint32_t id, uint32_t index, uint32_t next, - const struct spa_pod *param); -}; - -#define PW_NODE_PROXY_METHOD_ADD_LISTENER 0 -#define PW_NODE_PROXY_METHOD_SUBSCRIBE_PARAMS 1 -#define PW_NODE_PROXY_METHOD_ENUM_PARAMS 2 -#define PW_NODE_PROXY_METHOD_SET_PARAM 3 -#define PW_NODE_PROXY_METHOD_SEND_COMMAND 4 -#define PW_NODE_PROXY_METHOD_NUM 5 - -/** Node methods */ -struct pw_node_proxy_methods { -#define PW_VERSION_NODE_PROXY_METHODS 0 - uint32_t version; - - int (*add_listener) (void *object, - struct spa_hook *listener, - const struct pw_node_proxy_events *events, - void *data); - /** - * Subscribe to parameter changes - * - * Automatically emit param events for the given ids when - * they are changed. - * - * \param ids an array of param ids - * \param n_ids the number of ids in \a ids - */ - int (*subscribe_params) (void *object, uint32_t *ids, uint32_t n_ids); - - /** - * Enumerate node parameters - * - * Start enumeration of node parameters. For each param, a - * param event will be emited. - * - * \param seq a sequence number to place in the reply - * \param id the parameter id to enum or SPA_ID_INVALID for all - * \param start the start index or 0 for the first param - * \param num the maximum number of params to retrieve - * \param filter a param filter or NULL - */ - int (*enum_params) (void *object, int seq, uint32_t id, - uint32_t start, uint32_t num, - const struct spa_pod *filter); - - /** - * Set a parameter on the node - * - * \param id the parameter id to set - * \param flags extra parameter flags - * \param param the parameter to set - */ - int (*set_param) (void *object, uint32_t id, uint32_t flags, - const struct spa_pod *param); - - /** - * Send a command to the node - * - * \param command the command to send - */ - int (*send_command) (void *object, const struct spa_command *command); -}; - -#define pw_node_proxy_method(o,method,version,...) \ -({ \ - int _res = -ENOTSUP; \ - spa_interface_call_res((struct spa_interface*)o, \ - struct pw_node_proxy_methods, _res, \ - method, version, ##__VA_ARGS__); \ - _res; \ -}) - -/** Node */ -#define pw_node_proxy_add_listener(c,...) pw_node_proxy_method(c,add_listener,0,__VA_ARGS__) -#define pw_node_proxy_subscribe_params(c,...) pw_node_proxy_method(c,subscribe_params,0,__VA_ARGS__) -#define pw_node_proxy_enum_params(c,...) pw_node_proxy_method(c,enum_params,0,__VA_ARGS__) -#define pw_node_proxy_set_param(c,...) pw_node_proxy_method(c,set_param,0,__VA_ARGS__) -#define pw_node_proxy_send_command(c,...) pw_node_proxy_method(c,send_command,0,__VA_ARGS__) - - -#define PW_PORT_PROXY_EVENT_INFO 0 -#define PW_PORT_PROXY_EVENT_PARAM 1 -#define PW_PORT_PROXY_EVENT_NUM 2 - -/** Port events */ -struct pw_port_proxy_events { -#define PW_VERSION_PORT_PROXY_EVENTS 0 - uint32_t version; - /** - * Notify port info - * - * \param info info about the port - */ - void (*info) (void *object, const struct pw_port_info *info); - /** - * Notify a port param - * - * Event emited as a result of the enum_params method. - * - * \param seq the sequence number of the request - * \param id the param id - * \param index the param index - * \param next the param index of the next param - * \param param the parameter - */ - void (*param) (void *object, int seq, - uint32_t id, uint32_t index, uint32_t next, - const struct spa_pod *param); -}; - -#define PW_PORT_PROXY_METHOD_ADD_LISTENER 0 -#define PW_PORT_PROXY_METHOD_SUBSCRIBE_PARAMS 1 -#define PW_PORT_PROXY_METHOD_ENUM_PARAMS 2 -#define PW_PORT_PROXY_METHOD_NUM 3 - -/** Port methods */ -struct pw_port_proxy_methods { -#define PW_VERSION_PORT_PROXY_METHODS 0 - uint32_t version; - - int (*add_listener) (void *object, - struct spa_hook *listener, - const struct pw_port_proxy_events *events, - void *data); - /** - * Subscribe to parameter changes - * - * Automatically emit param events for the given ids when - * they are changed. - * - * \param ids an array of param ids - * \param n_ids the number of ids in \a ids - */ - int (*subscribe_params) (void *object, uint32_t *ids, uint32_t n_ids); - - /** - * Enumerate port parameters - * - * Start enumeration of port parameters. For each param, a - * param event will be emited. - * - * \param seq a sequence number returned in the reply - * \param id the parameter id to enumerate - * \param start the start index or 0 for the first param - * \param num the maximum number of params to retrieve - * \param filter a param filter or NULL - */ - int (*enum_params) (void *object, int seq, - uint32_t id, uint32_t start, uint32_t num, - const struct spa_pod *filter); -}; - -#define pw_port_proxy_method(o,method,version,...) \ -({ \ - int _res = -ENOTSUP; \ - spa_interface_call_res((struct spa_interface*)o, \ - struct pw_port_proxy_methods, _res, \ - method, version, ##__VA_ARGS__); \ - _res; \ -}) - -#define pw_port_proxy_add_listener(c,...) pw_port_proxy_method(c,add_listener,0,__VA_ARGS__) -#define pw_port_proxy_subscribe_params(c,...) pw_port_proxy_method(c,subscribe_params,0,__VA_ARGS__) -#define pw_port_proxy_enum_params(c,...) pw_port_proxy_method(c,enum_params,0,__VA_ARGS__) - - -#define PW_FACTORY_PROXY_EVENT_INFO 0 -#define PW_FACTORY_PROXY_EVENT_NUM 1 - -/** Factory events */ -struct pw_factory_proxy_events { -#define PW_VERSION_FACTORY_PROXY_EVENTS 0 - uint32_t version; - /** - * Notify factory info - * - * \param info info about the factory - */ - void (*info) (void *object, const struct pw_factory_info *info); -}; - -#define PW_FACTORY_PROXY_METHOD_ADD_LISTENER 0 -#define PW_FACTORY_PROXY_METHOD_NUM 1 - -/** Factory methods */ -struct pw_factory_proxy_methods { -#define PW_VERSION_FACTORY_PROXY_METHODS 0 - uint32_t version; - - int (*add_listener) (void *object, - struct spa_hook *listener, - const struct pw_factory_proxy_events *events, - void *data); -}; - -#define pw_factory_proxy_method(o,method,version,...) \ -({ \ - int _res = -ENOTSUP; \ - spa_interface_call_res((struct spa_interface*)o, \ - struct pw_factory_proxy_methods, _res, \ - method, version, ##__VA_ARGS__); \ - _res; \ -}) - -#define pw_factory_proxy_add_listener(c,...) pw_factory_proxy_method(c,add_listener,0,__VA_ARGS__) - - -#define PW_CLIENT_PROXY_EVENT_INFO 0 -#define PW_CLIENT_PROXY_EVENT_PERMISSIONS 1 -#define PW_CLIENT_PROXY_EVENT_NUM 2 - -/** Client events */ -struct pw_client_proxy_events { -#define PW_VERSION_CLIENT_PROXY_EVENTS 0 - uint32_t version; - /** - * Notify client info - * - * \param info info about the client - */ - void (*info) (void *object, const struct pw_client_info *info); - /** - * Notify a client permission - * - * Event emited as a result of the get_permissions method. - * - * \param default_permissions the default permissions - * \param index the index of the first permission entry - * \param n_permissions the number of permissions - * \param permissions the permissions - */ - void (*permissions) (void *object, - uint32_t index, - uint32_t n_permissions, - const struct pw_permission *permissions); -}; - - -#define PW_CLIENT_PROXY_METHOD_ADD_LISTENER 0 -#define PW_CLIENT_PROXY_METHOD_ERROR 1 -#define PW_CLIENT_PROXY_METHOD_UPDATE_PROPERTIES 2 -#define PW_CLIENT_PROXY_METHOD_GET_PERMISSIONS 3 -#define PW_CLIENT_PROXY_METHOD_UPDATE_PERMISSIONS 4 -#define PW_CLIENT_PROXY_METHOD_NUM 5 - -/** Client methods */ -struct pw_client_proxy_methods { -#define PW_VERSION_CLIENT_PROXY_METHODS 0 - uint32_t version; - - int (*add_listener) (void *object, - struct spa_hook *listener, - const struct pw_client_proxy_events *events, - void *data); - /** - * Send an error to a client - * - * \param id the global id to report the error on - * \param res an errno style error code - * \param message an error string - */ - int (*error) (void *object, uint32_t id, int res, const char *message); - /** - * Update client properties - * - * \param props new properties - */ - int (*update_properties) (void *object, const struct spa_dict *props); - - /** - * Get client permissions - * - * A permissions event will be emited with the permissions. - * - * \param index the first index to query, 0 for first - * \param num the maximum number of items to get - */ - int (*get_permissions) (void *object, uint32_t index, uint32_t num); - /** - * Manage the permissions of the global objects for this - * client - * - * Update the permissions of the global objects using the - * provided array with permissions - * - * Globals can use the default permissions or can have specific - * permissions assigned to them. - * - * \param n_permissions number of permissions - * \param permissions array of permissions - */ - int (*update_permissions) (void *object, uint32_t n_permissions, - const struct pw_permission *permissions); -}; - -#define pw_client_proxy_method(o,method,version,...) \ -({ \ - int _res = -ENOTSUP; \ - spa_interface_call_res((struct spa_interface*)o, \ - struct pw_client_proxy_methods, _res, \ - method, version, ##__VA_ARGS__); \ - _res; \ -}) - -#define pw_client_proxy_add_listener(c,...) pw_client_proxy_method(c,add_listener,0,__VA_ARGS__) -#define pw_client_proxy_error(c,...) pw_client_proxy_method(c,error,0,__VA_ARGS__) -#define pw_client_proxy_update_properties(c,...) pw_client_proxy_method(c,update_properties,0,__VA_ARGS__) -#define pw_client_proxy_get_permissions(c,...) pw_client_proxy_method(c,get_permissions,0,__VA_ARGS__) -#define pw_client_proxy_update_permissions(c,...) pw_client_proxy_method(c,update_permissions,0,__VA_ARGS__) - - -#define PW_LINK_PROXY_EVENT_INFO 0 -#define PW_LINK_PROXY_EVENT_NUM 1 - -/** Link events */ -struct pw_link_proxy_events { -#define PW_VERSION_LINK_PROXY_EVENTS 0 - uint32_t version; - /** - * Notify link info - * - * \param info info about the link - */ - void (*info) (void *object, const struct pw_link_info *info); -}; - -#define PW_LINK_PROXY_METHOD_ADD_LISTENER 0 -#define PW_LINK_PROXY_METHOD_NUM 1 - -/** Link methods */ -struct pw_link_proxy_methods { -#define PW_VERSION_LINK_PROXY_METHODS 0 - uint32_t version; - - int (*add_listener) (void *object, - struct spa_hook *listener, - const struct pw_link_proxy_events *events, - void *data); -}; - -#define pw_link_proxy_method(o,method,version,...) \ -({ \ - int _res = -ENOTSUP; \ - spa_interface_call_res((struct spa_interface*)o, \ - struct pw_link_proxy_methods, _res, \ - method, version, ##__VA_ARGS__); \ - _res; \ -}) - -#define pw_link_proxy_add_listener(c,...) pw_link_proxy_method(c,add_listener,0,__VA_ARGS__) - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif /* PIPEWIRE_INTERFACES_H */ diff --git a/src/pipewire/introspect.h b/src/pipewire/introspect.h deleted file mode 100644 index 3200193f..00000000 --- a/src/pipewire/introspect.h +++ /dev/null @@ -1,233 +0,0 @@ -/* PipeWire - * - * Copyright © 2018 Wim Taymans - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#ifndef PIPEWIRE_INTROSPECT_H -#define PIPEWIRE_INTROSPECT_H - -#include <spa/utils/defs.h> -#include <spa/param/param.h> - -#ifdef __cplusplus -extern "C" { -#endif - -#include <pipewire/properties.h> - -/** \enum pw_node_state The different node states \memberof pw_node */ -enum pw_node_state { - PW_NODE_STATE_ERROR = -1, /**< error state */ - PW_NODE_STATE_CREATING = 0, /**< the node is being created */ - PW_NODE_STATE_SUSPENDED = 1, /**< the node is suspended, the device might - * be closed */ - PW_NODE_STATE_IDLE = 2, /**< the node is running but there is no active - * port */ - PW_NODE_STATE_RUNNING = 3, /**< the node is running */ -}; - -/** Convert a \ref pw_node_state to a readable string \memberof pw_node */ -const char * pw_node_state_as_string(enum pw_node_state state); - -/** \enum pw_direction The direction of a port \memberof pw_introspect */ -enum pw_direction { - PW_DIRECTION_INPUT = SPA_DIRECTION_INPUT, /**< an input port direction */ - PW_DIRECTION_OUTPUT = SPA_DIRECTION_OUTPUT /**< an output port direction */ -}; - -/** Convert a \ref pw_direction to a readable string \memberof pw_introspect */ -const char * pw_direction_as_string(enum pw_direction direction); - -/** \enum pw_link_state The different link states \memberof pw_link */ -enum pw_link_state { - PW_LINK_STATE_ERROR = -2, /**< the link is in error */ - PW_LINK_STATE_UNLINKED = -1, /**< the link is unlinked */ - PW_LINK_STATE_INIT = 0, /**< the link is initialized */ - PW_LINK_STATE_NEGOTIATING = 1, /**< the link is negotiating formats */ - PW_LINK_STATE_ALLOCATING = 2, /**< the link is allocating buffers */ - PW_LINK_STATE_PAUSED = 3, /**< the link is paused */ -}; - -/** Convert a \ref pw_link_state to a readable string \memberof pw_link */ -const char * pw_link_state_as_string(enum pw_link_state state); - -/** \class pw_introspect - * - * The introspection methods and structures are used to get information - * about the object in the PipeWire server - */ - -/** The module information. Extra information can be added in later versions \memberof pw_introspect */ -struct pw_module_info { - uint32_t id; /**< id of the global */ - const char *name; /**< name of the module */ - const char *filename; /**< filename of the module */ - const char *args; /**< arguments passed to the module */ -#define PW_MODULE_CHANGE_MASK_PROPS (1 << 0) -#define PW_MODULE_CHANGE_MASK_ALL ((1 << 1)-1) - uint64_t change_mask; /**< bitfield of changed fields since last call */ - struct spa_dict *props; /**< extra properties */ -}; - -/** Update and existing \ref pw_module_info with \a update \memberof pw_introspect */ -struct pw_module_info * -pw_module_info_update(struct pw_module_info *info, - const struct pw_module_info *update); - -/** Free a \ref pw_module_info \memberof pw_introspect */ -void pw_module_info_free(struct pw_module_info *info); - - -/** The device information. Extra information can be added in later versions \memberof pw_introspect */ -struct pw_device_info { - uint32_t id; /**< id of the global */ -#define PW_DEVICE_CHANGE_MASK_PROPS (1 << 0) -#define PW_DEVICE_CHANGE_MASK_PARAMS (1 << 1) -#define PW_DEVICE_CHANGE_MASK_ALL ((1 << 2)-1) - uint64_t change_mask; /**< bitfield of changed fields since last call */ - struct spa_dict *props; /**< extra properties */ - struct spa_param_info *params; /**< parameters */ - uint32_t n_params; /**< number of items in \a params */ -}; - -/** Update and existing \ref pw_device_info with \a update \memberof pw_introspect */ -struct pw_device_info * -pw_device_info_update(struct pw_device_info *info, - const struct pw_device_info *update); - -/** Free a \ref pw_device_info \memberof pw_introspect */ -void pw_device_info_free(struct pw_device_info *info); - -/** The client information. Extra information can be added in later versions \memberof pw_introspect */ -struct pw_client_info { - uint32_t id; /**< id of the global */ -#define PW_CLIENT_CHANGE_MASK_PROPS (1 << 0) -#define PW_CLIENT_CHANGE_MASK_ALL ((1 << 1)-1) - uint64_t change_mask; /**< bitfield of changed fields since last call */ - struct spa_dict *props; /**< extra properties */ -}; - -/** Update and existing \ref pw_client_info with \a update \memberof pw_introspect */ -struct pw_client_info * -pw_client_info_update(struct pw_client_info *info, - const struct pw_client_info *update); - -/** Free a \ref pw_client_info \memberof pw_introspect */ -void pw_client_info_free(struct pw_client_info *info); - - -/** The node information. Extra information can be added in later versions \memberof pw_introspect */ -struct pw_node_info { - uint32_t id; /**< id of the global */ - uint32_t max_input_ports; /**< maximum number of inputs */ - uint32_t max_output_ports; /**< maximum number of outputs */ -#define PW_NODE_CHANGE_MASK_INPUT_PORTS (1 << 0) -#define PW_NODE_CHANGE_MASK_OUTPUT_PORTS (1 << 1) -#define PW_NODE_CHANGE_MASK_STATE (1 << 2) -#define PW_NODE_CHANGE_MASK_PROPS (1 << 3) -#define PW_NODE_CHANGE_MASK_PARAMS (1 << 4) -#define PW_NODE_CHANGE_MASK_ALL ((1 << 5)-1) - uint64_t change_mask; /**< bitfield of changed fields since last call */ - uint32_t n_input_ports; /**< number of inputs */ - uint32_t n_output_ports; /**< number of outputs */ - enum pw_node_state state; /**< the current state of the node */ - const char *error; /**< an error reason if \a state is error */ - struct spa_dict *props; /**< the properties of the node */ - struct spa_param_info *params; /**< parameters */ - uint32_t n_params; /**< number of items in \a params */ -}; - -struct pw_node_info * -pw_node_info_update(struct pw_node_info *info, - const struct pw_node_info *update); - -void -pw_node_info_free(struct pw_node_info *info); - -struct pw_port_info { - uint32_t id; /**< id of the global */ - enum pw_direction direction; /**< port direction */ -#define PW_PORT_CHANGE_MASK_PROPS (1 << 0) -#define PW_PORT_CHANGE_MASK_PARAMS (1 << 1) -#define PW_PORT_CHANGE_MASK_ALL ((1 << 2)-1) - uint64_t change_mask; /**< bitfield of changed fields since last call */ - struct spa_dict *props; /**< the properties of the port */ - struct spa_param_info *params; /**< parameters */ - uint32_t n_params; /**< number of items in \a params */ -}; - -struct pw_port_info * -pw_port_info_update(struct pw_port_info *info, - const struct pw_port_info *update); - -void -pw_port_info_free(struct pw_port_info *info); - -/** The factory information. Extra information can be added in later versions \memberof pw_introspect */ -struct pw_factory_info { - uint32_t id; /**< id of the global */ - const char *name; /**< name the factory */ - uint32_t type; /**< type of the objects created by this factory */ - uint32_t version; /**< version of the objects */ -#define PW_FACTORY_CHANGE_MASK_PROPS (1 << 0) -#define PW_FACTORY_CHANGE_MASK_ALL ((1 << 1)-1) - uint64_t change_mask; /**< bitfield of changed fields since last call */ - struct spa_dict *props; /**< the properties of the factory */ -}; - -struct pw_factory_info * -pw_factory_info_update(struct pw_factory_info *info, - const struct pw_factory_info *update); - -void -pw_factory_info_free(struct pw_factory_info *info); - -/** The link information. Extra information can be added in later versions \memberof pw_introspect */ -struct pw_link_info { - uint32_t id; /**< id of the global */ - uint32_t output_node_id; /**< server side output node id */ - uint32_t output_port_id; /**< output port id */ - uint32_t input_node_id; /**< server side input node id */ - uint32_t input_port_id; /**< input port id */ -#define PW_LINK_CHANGE_MASK_STATE (1 << 0) -#define PW_LINK_CHANGE_MASK_FORMAT (1 << 1) -#define PW_LINK_CHANGE_MASK_PROPS (1 << 2) -#define PW_LINK_CHANGE_MASK_ALL ((1 << 3)-1) - uint64_t change_mask; /**< bitfield of changed fields since last call */ - enum pw_link_state state; /**< the current state of the link */ - const char *error; /**< an error reason if \a state is error */ - struct spa_pod *format; /**< format over link */ - struct spa_dict *props; /**< the properties of the link */ -}; - -struct pw_link_info * -pw_link_info_update(struct pw_link_info *info, - const struct pw_link_info *update); - -void -pw_link_info_free(struct pw_link_info *info); - -#ifdef __cplusplus -} -#endif - -#endif /* PIPEWIRE_INTROSPECT_H */ diff --git a/src/pipewire/link.h b/src/pipewire/link.h new file mode 100644 index 00000000..64779a7a --- /dev/null +++ b/src/pipewire/link.h @@ -0,0 +1,122 @@ +/* PipeWire + * + * Copyright © 2018 Wim Taymans + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#ifndef PIPEWIRE_LINK_H +#define PIPEWIRE_LINK_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include <spa/utils/defs.h> +#include <spa/utils/hook.h> + +#include <pipewire/proxy.h> + +#define PW_VERSION_LINK_PROXY 3 +struct pw_link_proxy; + +/** \enum pw_link_state The different link states \memberof pw_link */ +enum pw_link_state { + PW_LINK_STATE_ERROR = -2, /**< the link is in error */ + PW_LINK_STATE_UNLINKED = -1, /**< the link is unlinked */ + PW_LINK_STATE_INIT = 0, /**< the link is initialized */ + PW_LINK_STATE_NEGOTIATING = 1, /**< the link is negotiating formats */ + PW_LINK_STATE_ALLOCATING = 2, /**< the link is allocating buffers */ + PW_LINK_STATE_PAUSED = 3, /**< the link is paused */ +}; + +/** Convert a \ref pw_link_state to a readable string \memberof pw_link */ +const char * pw_link_state_as_string(enum pw_link_state state); +/** The link information. Extra information can be added in later versions \memberof pw_introspect */ +struct pw_link_info { + uint32_t id; /**< id of the global */ + uint32_t output_node_id; /**< server side output node id */ + uint32_t output_port_id; /**< output port id */ + uint32_t input_node_id; /**< server side input node id */ + uint32_t input_port_id; /**< input port id */ +#define PW_LINK_CHANGE_MASK_STATE (1 << 0) +#define PW_LINK_CHANGE_MASK_FORMAT (1 << 1) +#define PW_LINK_CHANGE_MASK_PROPS (1 << 2) +#define PW_LINK_CHANGE_MASK_ALL ((1 << 3)-1) + uint64_t change_mask; /**< bitfield of changed fields since last call */ + enum pw_link_state state; /**< the current state of the link */ + const char *error; /**< an error reason if \a state is error */ + struct spa_pod *format; /**< format over link */ + struct spa_dict *props; /**< the properties of the link */ +}; + +struct pw_link_info * +pw_link_info_update(struct pw_link_info *info, + const struct pw_link_info *update); + +void +pw_link_info_free(struct pw_link_info *info); + + +#define PW_LINK_PROXY_EVENT_INFO 0 +#define PW_LINK_PROXY_EVENT_NUM 1 + +/** Link events */ +struct pw_link_proxy_events { +#define PW_VERSION_LINK_PROXY_EVENTS 0 + uint32_t version; + /** + * Notify link info + * + * \param info info about the link + */ + void (*info) (void *object, const struct pw_link_info *info); +}; + +#define PW_LINK_PROXY_METHOD_ADD_LISTENER 0 +#define PW_LINK_PROXY_METHOD_NUM 1 + +/** Link methods */ +struct pw_link_proxy_methods { +#define PW_VERSION_LINK_PROXY_METHODS 0 + uint32_t version; + + int (*add_listener) (void *object, + struct spa_hook *listener, + const struct pw_link_proxy_events *events, + void *data); +}; + +#define pw_link_proxy_method(o,method,version,...) \ +({ \ + int _res = -ENOTSUP; \ + spa_interface_call_res((struct spa_interface*)o, \ + struct pw_link_proxy_methods, _res, \ + method, version, ##__VA_ARGS__); \ + _res; \ +}) + +#define pw_link_proxy_add_listener(c,...) pw_link_proxy_method(c,add_listener,0,__VA_ARGS__) + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* PIPEWIRE_LINK_H */ diff --git a/src/pipewire/meson.build b/src/pipewire/meson.build index db28f377..0d4552d0 100644 --- a/src/pipewire/meson.build +++ b/src/pipewire/meson.build @@ -2,31 +2,36 @@ pipewire_headers = [ 'array.h', 'buffers.h', 'impl-client.h', - 'control.h', + 'client.h', 'context.h', - 'data-loop.h', + 'control.h', + 'core.h', + 'device.h', 'impl-device.h', + 'data-loop.h', + 'factory.h', + 'impl-factory.h', 'filter.h', 'global.h', - 'interfaces.h', - 'introspect.h', 'keys.h', 'impl-link.h', + 'link.h', 'log.h', 'loop.h', 'main-loop.h', 'map.h', 'mem.h', 'impl-module.h', + 'module.h', 'impl-node.h', - 'impl-factory.h', + 'node.h', 'permission.h', 'pipewire.h', 'impl-port.h', + 'port.h', 'properties.h', 'protocol.h', 'proxy.h', - 'core.h', 'resource.h', 'stream.h', 'thread-loop.h', @@ -38,8 +43,9 @@ pipewire_headers = [ pipewire_sources = [ 'buffers.c', 'impl-client.c', - 'control.c', 'context.c', + 'control.c', + 'core.c', 'data-loop.c', 'impl-device.c', 'filter.c', @@ -58,7 +64,6 @@ pipewire_sources = [ 'properties.c', 'protocol.c', 'proxy.c', - 'core.c', 'resource.c', 'stream.c', 'thread-loop.c', diff --git a/src/pipewire/module.h b/src/pipewire/module.h new file mode 100644 index 00000000..c2ca1009 --- /dev/null +++ b/src/pipewire/module.h @@ -0,0 +1,104 @@ +/* PipeWire + * + * Copyright © 2018 Wim Taymans + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#ifndef PIPEWIRE_MODULE_H +#define PIPEWIRE_MODULE_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include <spa/utils/defs.h> +#include <spa/utils/hook.h> + +#include <pipewire/proxy.h> + +#define PW_VERSION_MODULE_PROXY 3 +struct pw_module_proxy; + +/** The module information. Extra information can be added in later versions \memberof pw_introspect */ +struct pw_module_info { + uint32_t id; /**< id of the global */ + const char *name; /**< name of the module */ + const char *filename; /**< filename of the module */ + const char *args; /**< arguments passed to the module */ +#define PW_MODULE_CHANGE_MASK_PROPS (1 << 0) +#define PW_MODULE_CHANGE_MASK_ALL ((1 << 1)-1) + uint64_t change_mask; /**< bitfield of changed fields since last call */ + struct spa_dict *props; /**< extra properties */ +}; + +/** Update and existing \ref pw_module_info with \a update \memberof pw_introspect */ +struct pw_module_info * +pw_module_info_update(struct pw_module_info *info, + const struct pw_module_info *update); + +/** Free a \ref pw_module_info \memberof pw_introspect */ +void pw_module_info_free(struct pw_module_info *info); + +#define PW_MODULE_PROXY_EVENT_INFO 0 +#define PW_MODULE_PROXY_EVENT_NUM 1 + +/** Module events */ +struct pw_module_proxy_events { +#define PW_VERSION_MODULE_PROXY_EVENTS 0 + uint32_t version; + /** + * Notify module info + * + * \param info info about the module + */ + void (*info) (void *object, const struct pw_module_info *info); +}; + +#define PW_MODULE_PROXY_METHOD_ADD_LISTENER 0 +#define PW_MODULE_PROXY_METHOD_NUM 1 + +/** Module methods */ +struct pw_module_proxy_methods { +#define PW_VERSION_MODULE_PROXY_METHODS 0 + uint32_t version; + + int (*add_listener) (void *object, + struct spa_hook *listener, + const struct pw_module_proxy_events *events, + void *data); +}; + +#define pw_module_proxy_method(o,method,version,...) \ +({ \ + int _res = -ENOTSUP; \ + spa_interface_call_res((struct spa_interface*)o, \ + struct pw_module_proxy_methods, _res, \ + method, version, ##__VA_ARGS__); \ + _res; \ +}) + +#define pw_module_proxy_add_listener(c,...) pw_module_proxy_method(c,add_listener,0,__VA_ARGS__) + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* PIPEWIRE_MODULE_H */ diff --git a/src/pipewire/node.h b/src/pipewire/node.h new file mode 100644 index 00000000..2cf14f16 --- /dev/null +++ b/src/pipewire/node.h @@ -0,0 +1,198 @@ +/* PipeWire + * + * Copyright © 2018 Wim Taymans + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#ifndef PIPEWIRE_NODE_H +#define PIPEWIRE_NODE_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include <stdarg.h> +#include <errno.h> + +#include <spa/utils/defs.h> +#include <spa/utils/hook.h> +#include <spa/node/command.h> +#include <spa/param/param.h> + +#include <pipewire/proxy.h> + +#define PW_VERSION_NODE_PROXY 3 +struct pw_node_proxy; + +/** \enum pw_node_state The different node states \memberof pw_node */ +enum pw_node_state { + PW_NODE_STATE_ERROR = -1, /**< error state */ + PW_NODE_STATE_CREATING = 0, /**< the node is being created */ + PW_NODE_STATE_SUSPENDED = 1, /**< the node is suspended, the device might + * be closed */ + PW_NODE_STATE_IDLE = 2, /**< the node is running but there is no active + * port */ + PW_NODE_STATE_RUNNING = 3, /**< the node is running */ +}; + +/** Convert a \ref pw_node_state to a readable string \memberof pw_node */ +const char * pw_node_state_as_string(enum pw_node_state state); + +/** The node information. Extra information can be added in later versions \memberof pw_introspect */ +struct pw_node_info { + uint32_t id; /**< id of the global */ + uint32_t max_input_ports; /**< maximum number of inputs */ + uint32_t max_output_ports; /**< maximum number of outputs */ +#define PW_NODE_CHANGE_MASK_INPUT_PORTS (1 << 0) +#define PW_NODE_CHANGE_MASK_OUTPUT_PORTS (1 << 1) +#define PW_NODE_CHANGE_MASK_STATE (1 << 2) +#define PW_NODE_CHANGE_MASK_PROPS (1 << 3) +#define PW_NODE_CHANGE_MASK_PARAMS (1 << 4) +#define PW_NODE_CHANGE_MASK_ALL ((1 << 5)-1) + uint64_t change_mask; /**< bitfield of changed fields since last call */ + uint32_t n_input_ports; /**< number of inputs */ + uint32_t n_output_ports; /**< number of outputs */ + enum pw_node_state state; /**< the current state of the node */ + const char *error; /**< an error reason if \a state is error */ + struct spa_dict *props; /**< the properties of the node */ + struct spa_param_info *params; /**< parameters */ + uint32_t n_params; /**< number of items in \a params */ +}; + +struct pw_node_info * +pw_node_info_update(struct pw_node_info *info, + const struct pw_node_info *update); + +void +pw_node_info_free(struct pw_node_info *info); + +#define PW_NODE_PROXY_EVENT_INFO 0 +#define PW_NODE_PROXY_EVENT_PARAM 1 +#define PW_NODE_PROXY_EVENT_NUM 2 + +/** Node events */ +struct pw_node_proxy_events { +#define PW_VERSION_NODE_PROXY_EVENTS 0 + uint32_t version; + /** + * Notify node info + * + * \param info info about the node + */ + void (*info) (void *object, const struct pw_node_info *info); + /** + * Notify a node param + * + * Event emited as a result of the enum_params method. + * + * \param seq the sequence number of the request + * \param id the param id + * \param index the param index + * \param next the param index of the next param + * \param param the parameter + */ + void (*param) (void *object, int seq, + uint32_t id, uint32_t index, uint32_t next, + const struct spa_pod *param); +}; + +#define PW_NODE_PROXY_METHOD_ADD_LISTENER 0 +#define PW_NODE_PROXY_METHOD_SUBSCRIBE_PARAMS 1 +#define PW_NODE_PROXY_METHOD_ENUM_PARAMS 2 +#define PW_NODE_PROXY_METHOD_SET_PARAM 3 +#define PW_NODE_PROXY_METHOD_SEND_COMMAND 4 +#define PW_NODE_PROXY_METHOD_NUM 5 + +/** Node methods */ +struct pw_node_proxy_methods { +#define PW_VERSION_NODE_PROXY_METHODS 0 + uint32_t version; + + int (*add_listener) (void *object, + struct spa_hook *listener, + const struct pw_node_proxy_events *events, + void *data); + /** + * Subscribe to parameter changes + * + * Automatically emit param events for the given ids when + * they are changed. + * + * \param ids an array of param ids + * \param n_ids the number of ids in \a ids + */ + int (*subscribe_params) (void *object, uint32_t *ids, uint32_t n_ids); + + /** + * Enumerate node parameters + * + * Start enumeration of node parameters. For each param, a + * param event will be emited. + * + * \param seq a sequence number to place in the reply + * \param id the parameter id to enum or SPA_ID_INVALID for all + * \param start the start index or 0 for the first param + * \param num the maximum number of params to retrieve + * \param filter a param filter or NULL + */ + int (*enum_params) (void *object, int seq, uint32_t id, + uint32_t start, uint32_t num, + const struct spa_pod *filter); + + /** + * Set a parameter on the node + * + * \param id the parameter id to set + * \param flags extra parameter flags + * \param param the parameter to set + */ + int (*set_param) (void *object, uint32_t id, uint32_t flags, + const struct spa_pod *param); + + /** + * Send a command to the node + * + * \param command the command to send + */ + int (*send_command) (void *object, const struct spa_command *command); +}; + +#define pw_node_proxy_method(o,method,version,...) \ +({ \ + int _res = -ENOTSUP; \ + spa_interface_call_res((struct spa_interface*)o, \ + struct pw_node_proxy_methods, _res, \ + method, version, ##__VA_ARGS__); \ + _res; \ +}) + +/** Node */ +#define pw_node_proxy_add_listener(c,...) pw_node_proxy_method(c,add_listener,0,__VA_ARGS__) +#define pw_node_proxy_subscribe_params(c,...) pw_node_proxy_method(c,subscribe_params,0,__VA_ARGS__) +#define pw_node_proxy_enum_params(c,...) pw_node_proxy_method(c,enum_params,0,__VA_ARGS__) +#define pw_node_proxy_set_param(c,...) pw_node_proxy_method(c,set_param,0,__VA_ARGS__) +#define pw_node_proxy_send_command(c,...) pw_node_proxy_method(c,send_command,0,__VA_ARGS__) + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* PIPEWIRE_NODE_H */ diff --git a/src/pipewire/pipewire.h b/src/pipewire/pipewire.h index bbf387fa..1fd26581 100644 --- a/src/pipewire/pipewire.h +++ b/src/pipewire/pipewire.h @@ -32,21 +32,26 @@ extern "C" { #include <spa/support/plugin.h> #include <pipewire/array.h> +#include <pipewire/client.h> #include <pipewire/context.h> +#include <pipewire/device.h> #include <pipewire/buffers.h> #include <pipewire/core.h> -#include <pipewire/interfaces.h> -#include <pipewire/introspect.h> +#include <pipewire/factory.h> #include <pipewire/keys.h> #include <pipewire/log.h> #include <pipewire/loop.h> +#include <pipewire/link.h> #include <pipewire/main-loop.h> #include <pipewire/map.h> #include <pipewire/mem.h> +#include <pipewire/module.h> +#include <pipewire/node.h> #include <pipewire/properties.h> #include <pipewire/proxy.h> #include <pipewire/permission.h> #include <pipewire/protocol.h> +#include <pipewire/port.h> #include <pipewire/stream.h> #include <pipewire/filter.h> #include <pipewire/thread-loop.h> diff --git a/src/pipewire/port.h b/src/pipewire/port.h new file mode 100644 index 00000000..47dfa1d6 --- /dev/null +++ b/src/pipewire/port.h @@ -0,0 +1,168 @@ +/* PipeWire + * + * Copyright © 2018 Wim Taymans + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#ifndef PIPEWIRE_PORT_H +#define PIPEWIRE_PORT_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include <stdarg.h> +#include <errno.h> + +#include <spa/utils/defs.h> +#include <spa/utils/hook.h> +#include <spa/param/param.h> + +#include <pipewire/proxy.h> + +#define PW_VERSION_PORT_PROXY 3 +struct pw_port_proxy; + +/** \enum pw_direction The direction of a port \memberof pw_introspect */ +enum pw_direction { + PW_DIRECTION_INPUT = SPA_DIRECTION_INPUT, /**< an input port direction */ + PW_DIRECTION_OUTPUT = SPA_DIRECTION_OUTPUT /**< an output port direction */ +}; + +/** Convert a \ref pw_direction to a readable string \memberof pw_introspect */ +const char * pw_direction_as_string(enum pw_direction direction); + + +/** \class pw_introspect + * + * The introspection methods and structures are used to get information + * about the object in the PipeWire server + */ + +struct pw_port_info { + uint32_t id; /**< id of the global */ + enum pw_direction direction; /**< port direction */ +#define PW_PORT_CHANGE_MASK_PROPS (1 << 0) +#define PW_PORT_CHANGE_MASK_PARAMS (1 << 1) +#define PW_PORT_CHANGE_MASK_ALL ((1 << 2)-1) + uint64_t change_mask; /**< bitfield of changed fields since last call */ + struct spa_dict *props; /**< the properties of the port */ + struct spa_param_info *params; /**< parameters */ + uint32_t n_params; /**< number of items in \a params */ +}; + +struct pw_port_info * +pw_port_info_update(struct pw_port_info *info, + const struct pw_port_info *update); + +void +pw_port_info_free(struct pw_port_info *info); + +#define PW_PORT_PROXY_EVENT_INFO 0 +#define PW_PORT_PROXY_EVENT_PARAM 1 +#define PW_PORT_PROXY_EVENT_NUM 2 + +/** Port events */ +struct pw_port_proxy_events { +#define PW_VERSION_PORT_PROXY_EVENTS 0 + uint32_t version; + /** + * Notify port info + * + * \param info info about the port + */ + void (*info) (void *object, const struct pw_port_info *info); + /** + * Notify a port param + * + * Event emited as a result of the enum_params method. + * + * \param seq the sequence number of the request + * \param id the param id + * \param index the param index + * \param next the param index of the next param + * \param param the parameter + */ + void (*param) (void *object, int seq, + uint32_t id, uint32_t index, uint32_t next, + const struct spa_pod *param); +}; + +#define PW_PORT_PROXY_METHOD_ADD_LISTENER 0 +#define PW_PORT_PROXY_METHOD_SUBSCRIBE_PARAMS 1 +#define PW_PORT_PROXY_METHOD_ENUM_PARAMS 2 +#define PW_PORT_PROXY_METHOD_NUM 3 + +/** Port methods */ +struct pw_port_proxy_methods { +#define PW_VERSION_PORT_PROXY_METHODS 0 + uint32_t version; + + int (*add_listener) (void *object, + struct spa_hook *listener, + const struct pw_port_proxy_events *events, + void *data); + /** + * Subscribe to parameter changes + * + * Automatically emit param events for the given ids when + * they are changed. + * + * \param ids an array of param ids + * \param n_ids the number of ids in \a ids + */ + int (*subscribe_params) (void *object, uint32_t *ids, uint32_t n_ids); + + /** + * Enumerate port parameters + * + * Start enumeration of port parameters. For each param, a + * param event will be emited. + * + * \param seq a sequence number returned in the reply + * \param id the parameter id to enumerate + * \param start the start index or 0 for the first param + * \param num the maximum number of params to retrieve + * \param filter a param filter or NULL + */ + int (*enum_params) (void *object, int seq, + uint32_t id, uint32_t start, uint32_t num, + const struct spa_pod *filter); +}; + +#define pw_port_proxy_method(o,method,version,...) \ +({ \ + int _res = -ENOTSUP; \ + spa_interface_call_res((struct spa_interface*)o, \ + struct pw_port_proxy_methods, _res, \ + method, version, ##__VA_ARGS__); \ + _res; \ +}) + +#define pw_port_proxy_add_listener(c,...) pw_port_proxy_method(c,add_listener,0,__VA_ARGS__) +#define pw_port_proxy_subscribe_params(c,...) pw_port_proxy_method(c,subscribe_params,0,__VA_ARGS__) +#define pw_port_proxy_enum_params(c,...) pw_port_proxy_method(c,enum_params,0,__VA_ARGS__) + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* PIPEWIRE_PORT_H */ diff --git a/src/pipewire/proxy.c b/src/pipewire/proxy.c index 24df8f70..037fa658 100644 --- a/src/pipewire/proxy.c +++ b/src/pipewire/proxy.c @@ -27,7 +27,6 @@ #include <pipewire/core.h> #include <pipewire/private.h> #include <pipewire/type.h> -#include <pipewire/interfaces.h> #include <spa/debug/types.h> diff --git a/src/pipewire/resource.c b/src/pipewire/resource.c index 2e7d48f0..32f4bedb 100644 --- a/src/pipewire/resource.c +++ b/src/pipewire/resource.c @@ -24,7 +24,6 @@ #include <string.h> -#include "pipewire/interfaces.h" #include "pipewire/private.h" #include "pipewire/protocol.h" #include "pipewire/resource.h" diff --git a/src/pipewire/stream.h b/src/pipewire/stream.h index ec4e6d1f..25e08624 100644 --- a/src/pipewire/stream.h +++ b/src/pipewire/stream.h @@ -196,7 +196,7 @@ struct pw_time { * currently queued */ }; -#include <pipewire/core.h> +#include <pipewire/pipewire.h> /** Events for a stream. These events are always called from the mainloop * unless explicitly documented otherwise. */ diff --git a/src/tests/test-interfaces.c b/src/tests/test-interfaces.c index d955d119..2c08be64 100644 --- a/src/tests/test-interfaces.c +++ b/src/tests/test-interfaces.c @@ -23,7 +23,6 @@ */ #include <pipewire/pipewire.h> -#include <pipewire/interfaces.h> #define TEST_FUNC(a,b,func) \ do { \ diff --git a/src/tools/pipewire-dot.c b/src/tools/pipewire-dot.c index 048a18b7..1d5282bc 100644 --- a/src/tools/pipewire-dot.c +++ b/src/tools/pipewire-dot.c @@ -31,9 +31,6 @@ #include <spa/debug/format.h> #include <spa/debug/types.h> -#include <pipewire/interfaces.h> -#include <pipewire/type.h> -#include <pipewire/main-loop.h> #include <pipewire/pipewire.h> #define GLOBAL_ID_NONE UINT32_MAX diff --git a/src/tools/pipewire-monitor.c b/src/tools/pipewire-monitor.c index 955e034c..586a8bd8 100644 --- a/src/tools/pipewire-monitor.c +++ b/src/tools/pipewire-monitor.c @@ -30,9 +30,6 @@ #include <spa/debug/format.h> #include <spa/debug/types.h> -#include <pipewire/interfaces.h> -#include <pipewire/type.h> -#include <pipewire/main-loop.h> #include <pipewire/pipewire.h> struct proxy_data; |