From 3745f79fc5b7b49b65718af9561cc72449dab05a Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Fri, 12 Jul 2019 10:04:26 +0200 Subject: [PATCH] media-session: create a local adaper+a2dp sink/source Run the a2dp sink and sources with the adapter in the session manager and export it to PipeWire. The idea is that the codecs should not preferably not run inside the daemon. --- src/examples/bluez-monitor.c | 32 +++++++++++++++++++++----------- src/examples/media-session.c | 1 + 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/src/examples/bluez-monitor.c b/src/examples/bluez-monitor.c index 64c344a99..5657e0841 100644 --- a/src/examples/bluez-monitor.c +++ b/src/examples/bluez-monitor.c @@ -50,9 +50,8 @@ struct bluez5_node { struct pw_properties *props; - struct spa_handle *handle; + struct pw_node *adapter; struct pw_proxy *proxy; - struct spa_node *node; }; struct bluez5_object { @@ -94,6 +93,7 @@ static struct bluez5_node *bluez5_create_node(struct bluez5_object *obj, uint32_ struct bluez5_node *node; struct monitor *monitor = obj->monitor; struct impl *impl = monitor->impl; + struct pw_factory *factory; int res; const char *str; @@ -109,7 +109,8 @@ static struct bluez5_node *bluez5_create_node(struct bluez5_object *obj, uint32_ goto exit; } - node->props = pw_properties_new_dict(info->props); + node->props = pw_properties_copy(obj->props); + pw_properties_update(node->props, info->props); str = pw_properties_get(obj->props, PW_KEY_DEVICE_NICK); if (str == NULL) @@ -124,16 +125,26 @@ static struct bluez5_node *bluez5_create_node(struct bluez5_object *obj, uint32_ node->monitor = monitor; node->object = obj; node->id = id; - node->proxy = pw_core_proxy_create_object(impl->core_proxy, - "adapter", - PW_TYPE_INTERFACE_Node, - PW_VERSION_NODE_PROXY, - &node->props->dict, - 0); - if (node->proxy == NULL) { + + factory = pw_core_find_factory(impl->core, "adapter"); + if (factory == NULL) { + pw_log_error("no adapter factory found"); + res = -EIO; + goto clean_node; + } + node->adapter = pw_factory_create_object(factory, + NULL, + PW_TYPE_INTERFACE_Node, + PW_VERSION_NODE_PROXY, + node->props, + 0); + if (node->adapter == NULL) { res = -errno; goto clean_node; } + node->proxy = pw_remote_export(impl->remote, + PW_TYPE_INTERFACE_Node, + node->props, node->adapter, 0); spa_list_append(&obj->node_list, &node->link); @@ -154,7 +165,6 @@ static void bluez5_remove_node(struct bluez5_object *obj, struct bluez5_node *no pw_log_debug("remove node %u", node->id); spa_list_remove(&node->link); pw_proxy_destroy(node->proxy); - free(node->handle); free(node); } diff --git a/src/examples/media-session.c b/src/examples/media-session.c index d81b877ae..02084178c 100644 --- a/src/examples/media-session.c +++ b/src/examples/media-session.c @@ -1267,6 +1267,7 @@ int main(int argc, char *argv[]) pw_core_add_spa_lib(impl.core, "api.v4l2.*", "v4l2/libspa-v4l2"); pw_module_load(impl.core, "libpipewire-module-client-device", NULL, NULL, NULL, NULL); + pw_module_load(impl.core, "libpipewire-module-adapter", NULL, NULL, NULL, NULL); clock_gettime(CLOCK_MONOTONIC, &impl.now);