+ +
2da5fe7 OpenAVX v0.2.0 - High-performance open-standard IP audio and video transport suite
saifmukhtar · 2026-11-24
main
| 1 | /* Simple Plugin API */ |
| 2 | /* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */ |
| 3 | /* SPDX-License-Identifier: MIT */ |
| 4 | |
| 5 | #ifndef SPA_DBUS_H |
| 6 | #define SPA_DBUS_H |
| 7 | |
| 8 | #include <spa/support/loop.h> |
| 9 | |
| 10 | #ifdef __cplusplus |
| 11 | extern "C" { |
| 12 | #endif |
| 13 | |
| 14 | #ifndef SPA_API_DBUS |
| 15 | #ifdef SPA_API_IMPL |
| 16 | #define SPA_API_DBUS SPA_API_IMPL |
| 17 | #else |
| 18 | #define SPA_API_DBUS static inline |
| 19 | #endif |
| 20 | #endif |
| 21 | |
| 22 | /** \defgroup spa_dbus DBus |
| 23 | * DBus communication |
| 24 | */ |
| 25 | |
| 26 | /** |
| 27 | * \addtogroup spa_dbus |
| 28 | * \{ |
| 29 | */ |
| 30 | |
| 31 | #define SPA_TYPE_INTERFACE_DBus SPA_TYPE_INFO_INTERFACE_BASE "DBus" |
| 32 | |
| 33 | #define SPA_VERSION_DBUS 0 |
| 34 | struct spa_dbus { struct spa_interface iface; }; |
| 35 | |
| 36 | enum spa_dbus_type { |
| 37 | SPA_DBUS_TYPE_SESSION, /**< The login session bus */ |
| 38 | SPA_DBUS_TYPE_SYSTEM, /**< The systemwide bus */ |
| 39 | SPA_DBUS_TYPE_STARTER /**< The bus that started us, if any */ |
| 40 | }; |
| 41 | |
| 42 | #define SPA_DBUS_CONNECTION_EVENT_DESTROY 0 |
| 43 | #define SPA_DBUS_CONNECTION_EVENT_DISCONNECTED 1 |
| 44 | #define SPA_DBUS_CONNECTION_EVENT_NUM 2 |
| 45 | |
| 46 | struct spa_dbus_connection_events { |
| 47 | #define SPA_VERSION_DBUS_CONNECTION_EVENTS 0 |
| 48 | uint32_t version; |
| 49 | |
| 50 | /* a connection is destroyed */ |
| 51 | void (*destroy) (void *data); |
| 52 | |
| 53 | /* a connection disconnected */ |
| 54 | void (*disconnected) (void *data); |
| 55 | }; |
| 56 | |
| 57 | struct spa_dbus_connection { |
| 58 | #define SPA_VERSION_DBUS_CONNECTION 1 |
| 59 | uint32_t version; |
| 60 | /** |
| 61 | * Get the DBusConnection from a wrapper |
| 62 | * |
| 63 | * Note that the returned handle is closed and unref'd by spa_dbus |
| 64 | * immediately before emitting the asynchronous "disconnected" event. |
| 65 | * The caller must either deal with the invalidation, or keep an extra |
| 66 | * ref on the handle returned. |
| 67 | * |
| 68 | * \param conn the spa_dbus_connection wrapper |
| 69 | * \return a pointer of type DBusConnection |
| 70 | */ |
| 71 | void *(*get) (struct spa_dbus_connection *conn); |
| 72 | /** |
| 73 | * Destroy a dbus connection wrapper |
| 74 | * |
| 75 | * \param conn the wrapper to destroy |
| 76 | */ |
| 77 | void (*destroy) (struct spa_dbus_connection *conn); |
| 78 | |
| 79 | /** |
| 80 | * Add a listener for events |
| 81 | * |
| 82 | * Since version 1 |
| 83 | */ |
| 84 | void (*add_listener) (struct spa_dbus_connection *conn, |
| 85 | struct spa_hook *listener, |
| 86 | const struct spa_dbus_connection_events *events, |
| 87 | void *data); |
| 88 | }; |
| 89 | |
| 90 | /** \copydoc spa_dbus_connection.get |
| 91 | * \sa spa_dbus_connection.get */ |
| 92 | SPA_API_DBUS void *spa_dbus_connection_get(struct spa_dbus_connection *conn) |
| 93 | { |
| 94 | return spa_api_func_r(void *, NULL, conn, get, 0); |
| 95 | } |
| 96 | /** \copydoc spa_dbus_connection.destroy |
| 97 | * \sa spa_dbus_connection.destroy */ |
| 98 | SPA_API_DBUS void spa_dbus_connection_destroy(struct spa_dbus_connection *conn) |
| 99 | { |
| 100 | spa_api_func_v(conn, destroy, 0); |
| 101 | } |
| 102 | /** \copydoc spa_dbus_connection.add_listener |
| 103 | * \sa spa_dbus_connection.add_listener */ |
| 104 | SPA_API_DBUS void spa_dbus_connection_add_listener(struct spa_dbus_connection *conn, |
| 105 | struct spa_hook *listener, |
| 106 | const struct spa_dbus_connection_events *events, |
| 107 | void *data) |
| 108 | { |
| 109 | spa_api_func_v(conn, add_listener, 1, listener, events, data); |
| 110 | } |
| 111 | |
| 112 | struct spa_dbus_methods { |
| 113 | #define SPA_VERSION_DBUS_METHODS 0 |
| 114 | uint32_t version; |
| 115 | |
| 116 | /** |
| 117 | * Get a new connection wrapper for the given bus type. |
| 118 | * |
| 119 | * The connection wrapper is completely configured to operate |
| 120 | * in the main context of the handle that manages the spa_dbus |
| 121 | * interface. |
| 122 | * |
| 123 | * \param dbus the dbus manager |
| 124 | * \param type the bus type to wrap |
| 125 | * \param error location for the DBusError |
| 126 | * \return a new dbus connection wrapper or NULL on error |
| 127 | */ |
| 128 | struct spa_dbus_connection * (*get_connection) (void *object, |
| 129 | enum spa_dbus_type type); |
| 130 | }; |
| 131 | |
| 132 | /** \copydoc spa_dbus_methods.get_connection |
| 133 | * \sa spa_dbus_methods.get_connection |
| 134 | */ |
| 135 | SPA_API_DBUS struct spa_dbus_connection * |
| 136 | spa_dbus_get_connection(struct spa_dbus *dbus, enum spa_dbus_type type) |
| 137 | { |
| 138 | return spa_api_method_r(struct spa_dbus_connection *, NULL, |
| 139 | spa_dbus, &dbus->iface, get_connection, 0, type); |
| 140 | } |
| 141 | |
| 142 | /** |
| 143 | * \} |
| 144 | */ |
| 145 | |
| 146 | #ifdef __cplusplus |
| 147 | } /* extern "C" */ |
| 148 | #endif |
| 149 | |
| 150 | #endif /* SPA_DBUS_H */ |