#include <stdio.h>
#include <errno.h>
#include <math.h>
#include <time.h>
#include "config.h"
#define NAME "bluez-session"
struct impl;
struct object;
struct node {
struct impl *impl;
struct object *object;
uint32_t id;
};
struct object {
struct impl *impl;
uint32_t id;
};
struct impl {
};
static struct node *find_node(struct object *obj, uint32_t id)
{
struct node *node;
if (node->id == id)
return node;
}
return NULL;
}
static void update_node(struct object *obj, struct node *node,
{
}
static struct node *create_node(struct object *obj, uint32_t id,
{
struct node *node;
struct impl *impl = obj->impl;
int res;
void *iface;
return NULL;
info->factory_name,
info->props);
if (handle == NULL) {
goto exit;
}
goto unload_handle;
}
node = calloc(1, sizeof(*node));
if (node == NULL)
goto unload_handle;
node->impl = impl;
node->object = obj;
node->id = id;
node->handle = handle;
node->node = iface;
info->type, info->props, node->node, 0);
if (node->proxy == NULL)
goto clean_node;
update_node(obj, node, info);
return node;
clean_node:
free(node);
unload_handle:
exit:
return NULL;
}
static void remove_node(struct object *obj, struct node *node)
{
free(node->handle);
free(node);
}
static void device_object_info(void *data, uint32_t id,
{
struct object *obj = data;
struct node *node;
node = find_node(obj, id);
if (info == NULL) {
if (node == NULL) {
return;
}
remove_node(obj, node);
} else if (node == NULL) {
create_node(obj, id, info);
} else {
update_node(obj, node, info);
}
}
};
static struct object *find_object(struct impl *impl, uint32_t id)
{
struct object *obj;
if (obj->id == id)
return obj;
}
return NULL;
}
static void update_object(struct impl *impl, struct object *obj,
{
}
static struct object *create_object(struct impl *impl, uint32_t id,
{
struct object *obj;
int res;
void *iface;
return NULL;
info->factory_name,
info->props);
if (handle == NULL) {
goto exit;
}
goto unload_handle;
}
obj = calloc(1, sizeof(*obj));
if (obj == NULL)
goto unload_handle;
obj->impl = impl;
obj->id = id;
obj->handle = handle;
obj->device = iface;
info->type, info->props, obj->device, 0);
if (obj->proxy == NULL)
goto clean_object;
&obj->listener, &device_events, obj);
update_object(impl, obj, info);
return obj;
clean_object:
free(obj);
unload_handle:
exit:
return NULL;
}
static void remove_object(struct impl *impl, struct object *obj)
{
free(obj);
}
static void dbus_device_object_info(void *data, uint32_t id,
{
struct impl *impl = data;
struct object *obj;
obj = find_object(impl, id);
if (info == NULL) {
if (obj == NULL)
return;
remove_object(impl, obj);
} else if (obj == NULL) {
if (create_object(impl, id, info) == NULL)
return;
} else {
update_object(impl, obj, info);
}
}
{
};
static int start_monitor(struct impl *impl)
{
int res;
void *iface;
if (handle == NULL) {
res = -errno;
goto out;
}
goto out_unload;
}
impl->handle = handle;
impl->device = iface;
return 0;
out_unload:
out:
return res;
}
static void on_core_error(void *data, uint32_t id, int seq, int res, const char *message)
{
struct impl *impl = data;
}
};
int main(int argc, char *argv[])
{
struct impl impl = { 0, };
int res;
if (impl.core == NULL) {
return -1;
}
return -1;
}
&impl.core_listener,
&core_events, &impl);
if ((res = start_monitor(&impl)) < 0) {
return -1;
}
return 0;
}
struct spa_handle * pw_context_load_spa_handle(struct pw_context *context, const char *factory_name, const struct spa_dict *info)
Load a SPA handle from a context.
Definition context.c:1936
void pw_context_destroy(struct pw_context *context)
destroy a context object, all resources except the main_loop will be destroyed
Definition context.c:529
struct pw_context * pw_context_new(struct pw_loop *main_loop, struct pw_properties *props, size_t user_data_size)
Make a new context object for a given main_loop.
Definition context.c:317
#define PW_ID_CORE
default ID for the core object after connect
Definition core.h:62
struct pw_core * pw_context_connect(struct pw_context *context, struct pw_properties *properties, size_t user_data_size)
Connect to a PipeWire instance.
Definition core.c:394
struct pw_proxy * pw_core_export(struct pw_core *core, const char *type, const struct spa_dict *props, void *object, size_t user_data_size)
Export an object into the PipeWire instance associated with core.
Definition core.c:269
#define pw_core_add_listener(c,...)
Definition core.h:384
#define PW_VERSION_CORE_EVENTS
Definition core.h:130
#define pw_log_warn(...)
Definition log.h:179
#define pw_log_debug(...)
Definition log.h:181
#define pw_log_error(...)
Definition log.h:178
int pw_main_loop_quit(struct pw_main_loop *loop)
Quit a main loop.
Definition main-loop.c:108
void pw_main_loop_destroy(struct pw_main_loop *loop)
Destroy a loop.
Definition main-loop.c:73
int pw_main_loop_run(struct pw_main_loop *loop)
Run a main loop.
Definition main-loop.c:122
struct pw_main_loop * pw_main_loop_new(const struct spa_dict *props)
Create a new main loop.
Definition main-loop.c:63
struct pw_loop * pw_main_loop_get_loop(struct pw_main_loop *loop)
Get the loop implementation.
Definition main-loop.c:96
void pw_init(int *argc, char **argv[])
Initialize PipeWire.
Definition pipewire.c:488
int pw_unload_spa_handle(struct spa_handle *handle)
Definition pipewire.c:321
struct pw_properties * pw_properties_new(const char *key,...)
Make a new properties object.
Definition properties.c:96
void pw_proxy_destroy(struct pw_proxy *proxy)
destroy a proxy
Definition proxy.c:206
static int spa_debug_dict(int indent, const struct spa_dict *dict)
Definition dict.h:35
#define SPA_TYPE_INTERFACE_Device
Definition device.h:36
#define SPA_VERSION_DEVICE_EVENTS
version of the structure
Definition device.h:122
#define spa_device_add_listener(d,...)
Set events to receive asynchronous notifications from the device.
Definition device.h:262
#define spa_handle_get_interface(h,...)
Definition plugin.h:60
static void spa_hook_remove(struct spa_hook *hook)
Remove a hook.
Definition hook.h:391
static void spa_list_init(struct spa_list *list)
Definition list.h:35
static void spa_list_remove(struct spa_list *elem)
Definition list.h:65
#define spa_list_for_each(pos, head, member)
Definition list.h:107
#define spa_list_append(list, item)
Definition list.h:77
#define SPA_NAME_API_BLUEZ5_ENUM_DBUS
keys for bluez5 factory names
Definition names.h:133
#define SPA_TYPE_INTERFACE_Node
Definition node.h:37
#define spa_strerror(err)
Definition result.h:49
static bool spa_streq(const char *s1, const char *s2)
Definition string.h:41
Core events.
Definition core.h:128
void(* error)(void *data, uint32_t id, int seq, int res, const char *message)
Fatal error event.
Definition core.h:176
Definition properties.h:34
spa_device_events:
Definition device.h:119
void(* object_info)(void *data, uint32_t id, const struct spa_device_object_info *info)
info changed for an object managed by the device, info is NULL when the object is removed
Definition device.h:136
Information about a device object.
Definition device.h:73
A hook, contains the structure with functions and the data passed to the functions.
Definition hook.h:350