#include <stdio.h>
#include <sys/mman.h>
#include <signal.h>
#include <spa/param/video/format-utils.h>
struct data {
const char *library;
const char *factory;
const char *path;
uint32_t id;
};
static void proxy_event_bound(void *_data, uint32_t global_id)
{
struct data *data = _data;
if (data->id != global_id) {
printf("node id: %u\n", global_id);
data->id = global_id;
}
}
.bound = proxy_event_bound,
};
static int make_node(struct data *data)
{
void *iface;
int res;
NULL);
if (hndl == NULL)
return -errno;
return res;
data->node = iface;
if (data->path) {
}
data->node, 0);
if (data->proxy == NULL)
return -errno;
&data->proxy_listener, &proxy_events, data);
return 0;
}
static void on_core_error(void *data, uint32_t id, int seq, int res, const char *message)
{
struct data *d = data;
}
.error = on_core_error,
};
static void do_quit(void *data, int signal_number)
{
struct data *d = data;
}
int main(int argc, char *argv[])
{
struct data data = { 0, };
if (argc < 3) {
fprintf(stderr, "usage: %s <library> <factory> [path]\n\n"
"\texample: %s v4l2/libspa-v4l2 api.v4l2.source\n\n",
argv[0], argv[0]);
return -1;
}
data.library = argv[1];
data.factory = argv[2];
if (argc > 3)
data.path = argv[3];
if (data.core == NULL) {
printf("can't connect: %m\n");
return -1;
}
&data.core_listener,
&core_events, &data);
if (make_node(&data) < 0) {
return -1;
}
return 0;
}
void pw_context_destroy(struct pw_context *context)
destroy a context object, all resources except the main_loop will be destroyed
Definition: context.c:380
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:168
struct spa_handle * pw_context_load_spa_handle(struct pw_context *context, const char *factory_name, const struct spa_dict *info)
Definition: context.c:1440
#define PW_ID_CORE
default ID for the core object after connect
Definition: core.h:59
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:382
int pw_core_disconnect(struct pw_core *core)
disconnect and destroy a core
Definition: core.c:469
#define pw_core_add_listener(c,...)
Definition: core.h:343
#define PW_VERSION_CORE_EVENTS
Definition: core.h:123
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:255
struct pw_impl_module * pw_context_load_module(struct pw_context *context, const char *name, const char *args, struct pw_properties *properties)
Load a module.
Definition: impl-module.c:142
#define PW_KEY_NODE_AUTOCONNECT
node wants to be automatically connected to a compatible node
Definition: src/pipewire/keys.h:199
#define PW_KEY_TARGET_OBJECT
a target object to link to.
Definition: src/pipewire/keys.h:486
#define pw_log_error(...)
Definition: src/pipewire/log.h:142
#define pw_loop_add_signal(l,...)
Definition: src/pipewire/loop.h:63
struct pw_main_loop * pw_main_loop_new(const struct spa_dict *props)
Create a new main loop.
Definition: main-loop.c:60
int pw_main_loop_quit(struct pw_main_loop *loop)
Quit a main loop.
Definition: main-loop.c:105
void pw_main_loop_destroy(struct pw_main_loop *loop)
Destroy a loop.
Definition: main-loop.c:70
int pw_main_loop_run(struct pw_main_loop *loop)
Run a main loop.
Definition: main-loop.c:119
struct pw_loop * pw_main_loop_get_loop(struct pw_main_loop *loop)
Get the loop implementation.
Definition: main-loop.c:93
void pw_init(int *argc, char **argv[])
Initialize PipeWire.
Definition: pipewire.c:558
void pw_properties_free(struct pw_properties *properties)
Free a properties object.
Definition: properties.c:348
struct pw_properties * pw_properties_new(const char *key,...) 1
Make a new properties object.
Definition: properties.c:82
int pw_properties_set(struct pw_properties *properties, const char *key, const char *value)
Set a property value.
Definition: properties.c:419
void pw_proxy_add_listener(struct pw_proxy *proxy, struct spa_hook *listener, const struct pw_proxy_events *events, void *data)
Add an event listener to proxy.
Definition: proxy.c:177
#define PW_VERSION_PROXY_EVENTS
Definition: proxy.h:98
void pw_proxy_destroy(struct pw_proxy *proxy)
destroy a proxy
Definition: proxy.c:211
#define SPA_KEY_FACTORY_NAME
the name of a factory
Definition: plugin.h:202
#define SPA_KEY_LIBRARY_NAME
the name of a library.
Definition: plugin.h:211
#define spa_handle_get_interface(h,...)
Definition: plugin.h:60
#define SPA_TYPE_INTERFACE_Node
Definition: spa/include/spa/node/node.h:37
#define spa_strerror(err)
Definition: result.h:49
Core events.
Definition: core.h:121
Definition: src/pipewire/loop.h:31
Definition: properties.h:33
struct spa_dict dict
dictionary of key/values
Definition: properties.h:34
Proxy events, use pw_proxy_add_listener.
Definition: proxy.h:96
A hook, contains the structure with functions and the data passed to the functions.
Definition: hook.h:331
Definition: spa/include/spa/node/node.h:41