mirror of
https://gitlab.freedesktop.org/pipewire/wireplumber.git
synced 2026-05-05 08:58:01 +02:00
proxy-link: add new API
This commit is contained in:
parent
d20633b831
commit
1231001961
4 changed files with 157 additions and 0 deletions
|
|
@ -8,6 +8,7 @@ wp_lib_sources = [
|
|||
'proxy.c',
|
||||
'proxy-node.c',
|
||||
'proxy-port.c',
|
||||
'proxy-link.c',
|
||||
'remote.c',
|
||||
'remote-pipewire.c',
|
||||
]
|
||||
|
|
@ -22,6 +23,7 @@ wp_lib_headers = [
|
|||
'proxy.h',
|
||||
'proxy-node.h',
|
||||
'proxy-port.h',
|
||||
'proxy-link.h',
|
||||
'remote.h',
|
||||
'remote-pipewire.h',
|
||||
'wp.h',
|
||||
|
|
|
|||
125
lib/wp/proxy-link.c
Normal file
125
lib/wp/proxy-link.c
Normal file
|
|
@ -0,0 +1,125 @@
|
|||
/* WirePlumber
|
||||
*
|
||||
* Copyright © 2019 Collabora Ltd.
|
||||
* @author Julian Bouzas <julian.bouzas@collabora.com>
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#include "proxy-link.h"
|
||||
#include <pipewire/pipewire.h>
|
||||
|
||||
struct _WpProxyLink
|
||||
{
|
||||
WpProxy parent;
|
||||
|
||||
/* The link proxy listener */
|
||||
struct spa_hook listener;
|
||||
|
||||
/* The link info */
|
||||
struct pw_link_info *info;
|
||||
};
|
||||
|
||||
static GAsyncInitableIface *proxy_link_parent_interface = NULL;
|
||||
static void wp_proxy_link_async_initable_init (gpointer iface,
|
||||
gpointer iface_data);
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (WpProxyLink, wp_proxy_link, WP_TYPE_PROXY,
|
||||
G_IMPLEMENT_INTERFACE (G_TYPE_ASYNC_INITABLE,
|
||||
wp_proxy_link_async_initable_init))
|
||||
|
||||
static void
|
||||
link_event_info(void *data, const struct pw_link_info *info)
|
||||
{
|
||||
WpProxyLink *self = data;
|
||||
|
||||
/* Update the link info */
|
||||
self->info = pw_link_info_update(self->info, info);
|
||||
}
|
||||
|
||||
static const struct pw_link_proxy_events link_events = {
|
||||
PW_VERSION_LINK_PROXY_EVENTS,
|
||||
.info = link_event_info,
|
||||
};
|
||||
|
||||
static void
|
||||
wp_proxy_link_finalize (GObject * object)
|
||||
{
|
||||
WpProxyLink *self = WP_PROXY_LINK(object);
|
||||
|
||||
/* Clear the info */
|
||||
if (self->info) {
|
||||
pw_link_info_free(self->info);
|
||||
self->info = NULL;
|
||||
}
|
||||
|
||||
G_OBJECT_CLASS (wp_proxy_link_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
wp_proxy_link_init_async (GAsyncInitable *initable, int io_priority,
|
||||
GCancellable *cancellable, GAsyncReadyCallback callback, gpointer data)
|
||||
{
|
||||
WpProxyLink *self = WP_PROXY_LINK(initable);
|
||||
WpProxy *wp_proxy = WP_PROXY(initable);
|
||||
struct pw_link_proxy *proxy = NULL;
|
||||
|
||||
/* Get the proxy from the base class */
|
||||
proxy = wp_proxy_get_pw_proxy(wp_proxy);
|
||||
|
||||
/* Add the link proxy listener */
|
||||
pw_link_proxy_add_listener(proxy, &self->listener, &link_events, self);
|
||||
|
||||
/* Call the parent interface */
|
||||
proxy_link_parent_interface->init_async (initable, io_priority, cancellable,
|
||||
callback, data);
|
||||
}
|
||||
|
||||
static void
|
||||
wp_proxy_link_async_initable_init (gpointer iface, gpointer iface_data)
|
||||
{
|
||||
GAsyncInitableIface *ai_iface = iface;
|
||||
|
||||
/* Set the parent interface */
|
||||
proxy_link_parent_interface = g_type_interface_peek_parent (iface);
|
||||
|
||||
/* Only set the init_async */
|
||||
ai_iface->init_async = wp_proxy_link_init_async;
|
||||
}
|
||||
|
||||
static void
|
||||
wp_proxy_link_init (WpProxyLink * self)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
wp_proxy_link_class_init (WpProxyLinkClass * klass)
|
||||
{
|
||||
GObjectClass *object_class = (GObjectClass *) klass;
|
||||
|
||||
object_class->finalize = wp_proxy_link_finalize;
|
||||
}
|
||||
|
||||
void
|
||||
wp_proxy_link_new (guint global_id, gpointer proxy,
|
||||
GAsyncReadyCallback callback, gpointer user_data)
|
||||
{
|
||||
g_async_initable_new_async (
|
||||
WP_TYPE_PROXY_LINK, G_PRIORITY_DEFAULT, NULL, callback, user_data,
|
||||
"global-id", global_id,
|
||||
"pw-proxy", proxy,
|
||||
NULL);
|
||||
}
|
||||
|
||||
WpProxyLink *
|
||||
wp_proxy_link_new_finish(GObject *initable, GAsyncResult *res, GError **error)
|
||||
{
|
||||
GAsyncInitable *ai = G_ASYNC_INITABLE(initable);
|
||||
return WP_PROXY_LINK(g_async_initable_new_finish(ai, res, error));
|
||||
}
|
||||
|
||||
const struct pw_link_info *
|
||||
wp_proxy_link_get_info (WpProxyLink * self)
|
||||
{
|
||||
return self->info;
|
||||
}
|
||||
29
lib/wp/proxy-link.h
Normal file
29
lib/wp/proxy-link.h
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
/* WirePlumber
|
||||
*
|
||||
* Copyright © 2019 Collabora Ltd.
|
||||
* @author Julian Bouzas <julian.bouzas@collabora.com>
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#ifndef __WIREPLUMBER_PROXY_LINK_H__
|
||||
#define __WIREPLUMBER_PROXY_LINK_H__
|
||||
|
||||
#include "core.h"
|
||||
#include "proxy.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define WP_TYPE_PROXY_LINK (wp_proxy_link_get_type ())
|
||||
G_DECLARE_FINAL_TYPE (WpProxyLink, wp_proxy_link, WP, PROXY_LINK, WpProxy)
|
||||
|
||||
void wp_proxy_link_new (guint global_id, gpointer proxy,
|
||||
GAsyncReadyCallback callback, gpointer user_data);
|
||||
WpProxyLink *wp_proxy_link_new_finish(GObject *initable, GAsyncResult *res,
|
||||
GError **error);
|
||||
|
||||
const struct pw_link_info *wp_proxy_link_get_info (WpProxyLink * self);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif
|
||||
|
|
@ -13,6 +13,7 @@
|
|||
#include "module.h"
|
||||
#include "policy.h"
|
||||
#include "proxy.h"
|
||||
#include "proxy-link.h"
|
||||
#include "proxy-node.h"
|
||||
#include "proxy-port.h"
|
||||
#include "remote.h"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue