Make interface types a string

This is more in line with wayland and it allows us to create new
interfaces in modules without having to add anything to the type
enum. It also removes some lookups to map type_id to readable
name in debug.
This commit is contained in:
Wim Taymans 2019-12-19 13:15:10 +01:00
parent 9657486a81
commit f391353c7f
123 changed files with 791 additions and 1251 deletions

View file

@ -34,6 +34,7 @@
#include <spa/node/node.h>
#include <spa/utils/hook.h>
#include <spa/utils/names.h>
#include <spa/utils/result.h>
#include <spa/param/audio/format-utils.h>
#include <spa/param/props.h>
#include <spa/debug/dict.h>
@ -116,7 +117,7 @@ static struct node *create_node(struct object *obj, uint32_t id,
pw_log_debug("new node %u", id);
if (info->type != SPA_TYPE_INTERFACE_Node)
if (strcmp(info->type, SPA_TYPE_INTERFACE_Node) != 0)
return NULL;
handle = pw_context_load_spa_handle(context,
@ -128,7 +129,7 @@ static struct node *create_node(struct object *obj, uint32_t id,
}
if ((res = spa_handle_get_interface(handle, info->type, &iface)) < 0) {
pw_log_error("can't get %d interface: %d", info->type, res);
pw_log_error("can't get %s interface: %s", info->type, spa_strerror(res));
goto unload_handle;
}
@ -225,7 +226,7 @@ static struct object *create_object(struct impl *impl, uint32_t id,
pw_log_debug("new object %u", id);
if (info->type != SPA_TYPE_INTERFACE_Device)
if (strcmp(info->type, SPA_TYPE_INTERFACE_Device) != 0)
return NULL;
handle = pw_context_load_spa_handle(context,
@ -237,7 +238,7 @@ static struct object *create_object(struct impl *impl, uint32_t id,
}
if ((res = spa_handle_get_interface(handle, info->type, &iface)) < 0) {
pw_log_error("can't get %d interface: %d", info->type, res);
pw_log_error("can't get %s interface: %s", info->type, spa_strerror(res));
goto unload_handle;
}

View file

@ -195,7 +195,7 @@ static int client_endpoint_create_link(void *object, const struct spa_dict *prop
goto exit;
}
obj = sm_media_session_find_object(impl->session, atoi(str));
if (obj == NULL || obj->type != PW_TYPE_INTERFACE_Endpoint) {
if (obj == NULL || strcmp(obj->type, PW_TYPE_INTERFACE_Endpoint) !=0) {
pw_log_warn(NAME" %p: could not find endpoint %s (%p)", impl, str, obj);
res = -EINVAL;
goto exit;
@ -707,15 +707,11 @@ static void session_create(void *data, struct sm_object *object)
struct impl *impl = data;
int res;
switch (object->type) {
case PW_TYPE_INTERFACE_Device:
if (strcmp(object->type, PW_TYPE_INTERFACE_Device) == 0)
res = handle_device(impl, object);
break;
default:
else
res = 0;
break;
}
if (res < 0) {
pw_log_warn(NAME" %p: can't handle global %d: %s", impl,
object->id, spa_strerror(res));
@ -726,16 +722,10 @@ static void session_remove(void *data, struct sm_object *object)
{
struct impl *impl = data;
switch (object->type) {
case PW_TYPE_INTERFACE_Device:
{
if (strcmp(object->type, PW_TYPE_INTERFACE_Device) == 0) {
struct device *device;
if ((device = sm_object_get_data(object, SESSION_KEY)) != NULL)
destroy_device(impl, device);
break;
}
default:
break;
}
}

View file

@ -35,6 +35,7 @@
#include <spa/monitor/device.h>
#include <spa/node/node.h>
#include <spa/node/keys.h>
#include <spa/utils/result.h>
#include <spa/utils/hook.h>
#include <spa/utils/names.h>
#include <spa/utils/keys.h>
@ -147,7 +148,7 @@ static struct node *alsa_create_node(struct device *device, uint32_t id,
pw_log_debug("new node %u", id);
if (info->type != SPA_TYPE_INTERFACE_Node) {
if (strcmp(info->type, SPA_TYPE_INTERFACE_Node) != 0) {
errno = EINVAL;
return NULL;
}
@ -570,7 +571,7 @@ static struct device *alsa_create_device(struct impl *impl, uint32_t id,
pw_log_debug("new device %u", id);
if (info->type != SPA_TYPE_INTERFACE_Device) {
if (strcmp(info->type, SPA_TYPE_INTERFACE_Device) != 0) {
errno = EINVAL;
return NULL;
}
@ -585,7 +586,7 @@ static struct device *alsa_create_device(struct impl *impl, uint32_t id,
}
if ((res = spa_handle_get_interface(handle, info->type, &iface)) < 0) {
pw_log_error("can't get %d interface: %d", info->type, res);
pw_log_error("can't get %s interface: %s", info->type, spa_strerror(res));
goto unload_handle;
}

View file

@ -35,6 +35,7 @@
#include <spa/utils/hook.h>
#include <spa/utils/result.h>
#include <spa/utils/names.h>
#include <spa/utils/result.h>
#include <spa/param/audio/format-utils.h>
#include <spa/param/props.h>
#include <spa/debug/dict.h>
@ -115,7 +116,7 @@ static struct bluez5_node *bluez5_create_node(struct bluez5_object *obj, uint32_
pw_log_debug("new node %u", id);
if (info->type != SPA_TYPE_INTERFACE_Node) {
if (strcmp(info->type, SPA_TYPE_INTERFACE_Node) != 0) {
errno = EINVAL;
return NULL;
}
@ -247,7 +248,7 @@ static struct bluez5_object *bluez5_create_object(struct impl *impl, uint32_t id
pw_log_debug("new object %u", id);
if (info->type != SPA_TYPE_INTERFACE_Device) {
if (strcmp(info->type, SPA_TYPE_INTERFACE_Device) != 0) {
errno = EINVAL;
return NULL;
}
@ -262,7 +263,7 @@ static struct bluez5_object *bluez5_create_object(struct impl *impl, uint32_t id
}
if ((res = spa_handle_get_interface(handle, info->type, &iface)) < 0) {
pw_log_error("can't get %d interface: %d", info->type, res);
pw_log_error("can't get %s interface: %s", info->type, spa_strerror(res));
goto unload_handle;
}

View file

@ -147,7 +147,7 @@ struct link {
};
struct object_info {
uint32_t type;
const char *type;
uint32_t version;
const void *events;
size_t size;
@ -387,6 +387,7 @@ static void device_destroy(void *object)
if (device->info)
pw_device_info_free(device->info);
device->info = NULL;
}
static const struct object_info device_info = {
@ -920,7 +921,10 @@ destroy_proxy(void *data)
if (obj->destroy)
obj->destroy(obj);
pw_properties_free(obj->props);
if (obj->props)
pw_properties_free(obj->props);
obj->props = NULL;
spa_list_consume(d, &obj->data, link) {
spa_list_remove(&d->link);
free(d);
@ -967,41 +971,31 @@ int sm_object_sync_update(struct sm_object *obj)
return obj->pending;
}
static const struct object_info *get_object_info(struct impl *impl, uint32_t type)
static const struct object_info *get_object_info(struct impl *impl, const char *type)
{
const struct object_info *info;
switch (type) {
case PW_TYPE_INTERFACE_Client:
if (strcmp(type, PW_TYPE_INTERFACE_Client) == 0)
info = &client_info;
break;
case SPA_TYPE_INTERFACE_Device:
else if (strcmp(type, SPA_TYPE_INTERFACE_Device) == 0)
info = &spa_device_info;
break;
case PW_TYPE_INTERFACE_Device:
else if (strcmp(type, PW_TYPE_INTERFACE_Device) == 0)
info = &device_info;
break;
case PW_TYPE_INTERFACE_Node:
else if (strcmp(type, PW_TYPE_INTERFACE_Node) == 0)
info = &node_info;
break;
case PW_TYPE_INTERFACE_Port:
else if (strcmp(type, PW_TYPE_INTERFACE_Port) == 0)
info = &port_info;
break;
case PW_TYPE_INTERFACE_Session:
else if (strcmp(type, PW_TYPE_INTERFACE_Session) == 0)
info = &session_info;
break;
case PW_TYPE_INTERFACE_Endpoint:
else if (strcmp(type, PW_TYPE_INTERFACE_Endpoint) == 0)
info = &endpoint_info;
break;
case PW_TYPE_INTERFACE_EndpointStream:
else if (strcmp(type, PW_TYPE_INTERFACE_EndpointStream) == 0)
info = &endpoint_stream_info;
break;
case PW_TYPE_INTERFACE_EndpointLink:
else if (strcmp(type, PW_TYPE_INTERFACE_EndpointLink) == 0)
info = &endpoint_link_info;
break;
default:
else
info = NULL;
break;
}
return info;
}
@ -1041,7 +1035,7 @@ static struct sm_object *
create_object(struct impl *impl, struct pw_proxy *proxy,
const struct spa_dict *props)
{
uint32_t type;
const char *type;
const struct object_info *info;
struct sm_object *obj;
@ -1049,7 +1043,7 @@ create_object(struct impl *impl, struct pw_proxy *proxy,
info = get_object_info(impl, type);
if (info == NULL) {
pw_log_error(NAME" %p: unknown object type %d", impl, type);
pw_log_error(NAME" %p: unknown object type %s", impl, type);
errno = ENOTSUP;
return NULL;
}
@ -1062,7 +1056,7 @@ create_object(struct impl *impl, struct pw_proxy *proxy,
static struct sm_object *
bind_object(struct impl *impl, const struct object_info *info, uint32_t id,
uint32_t permissions, uint32_t type, uint32_t version,
uint32_t permissions, const char *type, uint32_t version,
const struct spa_dict *props)
{
int res;
@ -1090,15 +1084,15 @@ error:
static int
update_object(struct impl *impl, const struct object_info *info,
struct sm_object *obj, uint32_t id,
uint32_t permissions, uint32_t type, uint32_t version,
uint32_t permissions, const char *type, uint32_t version,
const struct spa_dict *props)
{
pw_properties_update(obj->props, props);
if (obj->type == type)
if (strcmp(obj->type, type) == 0)
return 0;
pw_log_debug(NAME" %p: update type:%d -> type:%d", impl, obj->type, type);
pw_log_debug(NAME" %p: update type:%s -> type:%s", impl, obj->type, type);
obj->handle = obj->proxy;
spa_hook_remove(&obj->proxy_listener);
pw_proxy_add_listener(obj->handle, &obj->handle_listener, &proxy_events, obj);
@ -1108,7 +1102,7 @@ update_object(struct impl *impl, const struct object_info *info,
obj->proxy = pw_registry_bind(impl->registry,
id, info->type, info->version, 0);
obj->type = type;
obj->type = info->type;
pw_proxy_add_listener(obj->proxy, &obj->proxy_listener, &proxy_events, obj);
if (info->events)
@ -1123,15 +1117,14 @@ update_object(struct impl *impl, const struct object_info *info,
static void
registry_global(void *data, uint32_t id,
uint32_t permissions, uint32_t type, uint32_t version,
uint32_t permissions, const char *type, uint32_t version,
const struct spa_dict *props)
{
struct impl *impl = data;
struct sm_object *obj;
const struct object_info *info;
pw_log_debug(NAME " %p: new global '%d' %s/%d", impl, id,
spa_debug_type_find_name(pw_type_info(), type), version);
pw_log_debug(NAME " %p: new global '%d' %s/%d", impl, id, type, version);
info = get_object_info(impl, type);
if (info == NULL)
@ -1141,7 +1134,7 @@ registry_global(void *data, uint32_t id,
if (obj == NULL) {
bind_object(impl, info, id, permissions, type, version, props);
} else {
pw_log_debug(NAME " %p: our object %d appeared %d/%d",
pw_log_debug(NAME " %p: our object %d appeared %s/%s",
impl, id, obj->type, type);
update_object(impl, info, obj, id, permissions, type, version, props);
}
@ -1259,7 +1252,7 @@ static const struct pw_registry_events registry_events = {
};
struct pw_proxy *sm_media_session_export(struct sm_media_session *sess,
uint32_t type, const struct spa_dict *props,
const char *type, const struct spa_dict *props,
void *object, size_t user_data_size)
{
struct impl *impl = SPA_CONTAINER_OF(sess, struct impl, this);
@ -1285,7 +1278,7 @@ struct sm_device *sm_media_session_export_device(struct sm_media_session *sess,
}
struct pw_proxy *sm_media_session_create_object(struct sm_media_session *sess,
const char *factory_name, uint32_t type, uint32_t version,
const char *factory_name, const char *type, uint32_t version,
const struct spa_dict *props, size_t user_data_size)
{
struct impl *impl = SPA_CONTAINER_OF(sess, struct impl, this);
@ -1431,36 +1424,36 @@ int sm_media_session_create_links(struct sm_media_session *sess,
/* find output node */
if ((str = spa_dict_lookup(dict, PW_KEY_LINK_OUTPUT_NODE)) != NULL &&
(obj = find_object(impl, atoi(str))) != NULL &&
obj->type == PW_TYPE_INTERFACE_Node) {
strcmp(obj->type, PW_TYPE_INTERFACE_Node) == 0) {
outnode = (struct sm_node*)obj;
}
/* find input node */
if ((str = spa_dict_lookup(dict, PW_KEY_LINK_INPUT_NODE)) != NULL &&
(obj = find_object(impl, atoi(str))) != NULL &&
obj->type == PW_TYPE_INTERFACE_Node) {
strcmp(obj->type, PW_TYPE_INTERFACE_Node) == 0) {
innode = (struct sm_node*)obj;
}
/* find endpoints and streams */
if ((str = spa_dict_lookup(dict, PW_KEY_ENDPOINT_LINK_OUTPUT_ENDPOINT)) != NULL &&
(obj = find_object(impl, atoi(str))) != NULL &&
obj->type == PW_TYPE_INTERFACE_Endpoint) {
strcmp(obj->type, PW_TYPE_INTERFACE_Endpoint) == 0) {
outendpoint = (struct sm_endpoint*)obj;
}
if ((str = spa_dict_lookup(dict, PW_KEY_ENDPOINT_LINK_OUTPUT_STREAM)) != NULL &&
(obj = find_object(impl, atoi(str))) != NULL &&
obj->type == PW_TYPE_INTERFACE_EndpointStream) {
strcmp(obj->type, PW_TYPE_INTERFACE_EndpointStream) == 0) {
outstream = (struct sm_endpoint_stream*)obj;
}
if ((str = spa_dict_lookup(dict, PW_KEY_ENDPOINT_LINK_INPUT_ENDPOINT)) != NULL &&
(obj = find_object(impl, atoi(str))) != NULL &&
obj->type == PW_TYPE_INTERFACE_Endpoint) {
strcmp(obj->type, PW_TYPE_INTERFACE_Endpoint) == 0) {
inendpoint = (struct sm_endpoint*)obj;
}
if ((str = spa_dict_lookup(dict, PW_KEY_ENDPOINT_LINK_INPUT_STREAM)) != NULL &&
(obj = find_object(impl, atoi(str))) != NULL &&
obj->type == PW_TYPE_INTERFACE_EndpointStream) {
strcmp(obj->type, PW_TYPE_INTERFACE_EndpointStream) == 0) {
instream = (struct sm_endpoint_stream*)obj;
}

View file

@ -46,7 +46,7 @@ struct sm_object_events {
struct sm_object {
uint32_t id;
uint32_t type;
const char *type;
struct spa_list link;
struct sm_media_session *session;
@ -226,14 +226,14 @@ struct sm_object *sm_media_session_find_object(struct sm_media_session *sess, ui
int sm_media_session_schedule_rescan(struct sm_media_session *sess);
struct pw_proxy *sm_media_session_export(struct sm_media_session *sess,
uint32_t type, const struct spa_dict *props,
const char *type, const struct spa_dict *props,
void *object, size_t user_data_size);
struct sm_device *sm_media_session_export_device(struct sm_media_session *sess,
const struct spa_dict *props, struct spa_device *device);
struct pw_proxy *sm_media_session_create_object(struct sm_media_session *sess,
const char *factory_name, uint32_t type, uint32_t version,
const char *factory_name, const char *type, uint32_t version,
const struct spa_dict *props, size_t user_data_size);
struct sm_node *sm_media_session_create_node(struct sm_media_session *sess,

View file

@ -219,19 +219,13 @@ static void session_create(void *data, struct sm_object *object)
struct impl *impl = data;
int res;
switch (object->type) {
case PW_TYPE_INTERFACE_Endpoint:
if (strcmp(object->type, PW_TYPE_INTERFACE_Endpoint) == 0)
res = handle_endpoint(impl, object);
break;
case PW_TYPE_INTERFACE_EndpointStream:
else if (strcmp(object->type, PW_TYPE_INTERFACE_EndpointStream) == 0)
res = handle_stream(impl, object);
break;
default:
else
res = 0;
break;
}
if (res < 0) {
pw_log_warn(NAME" %p: can't handle global %d", impl, object->id);
}
@ -244,23 +238,15 @@ static void session_remove(void *data, struct sm_object *object)
struct impl *impl = data;
pw_log_debug(NAME " %p: remove global '%d'", impl, object->id);
switch (object->type) {
case PW_TYPE_INTERFACE_Endpoint:
{
if (strcmp(object->type, PW_TYPE_INTERFACE_Endpoint) == 0) {
struct endpoint *ep;
if ((ep = sm_object_get_data(object, SESSION_KEY)) != NULL)
destroy_endpoint(impl, ep);
break;
}
case PW_TYPE_INTERFACE_EndpointStream:
{
else if (strcmp(object->type, PW_TYPE_INTERFACE_EndpointStream) == 0) {
struct stream *s;
if ((s = sm_object_get_data(object, SESSION_KEY)) != NULL)
destroy_stream(impl, s);
break;
}
default:
break;
}
sm_media_session_schedule_rescan(impl->session);
@ -444,11 +430,11 @@ static int rescan_endpoint(struct impl *impl, struct endpoint *ep)
pw_log_info(NAME " %p: target:%d", impl, path_id);
if ((obj = sm_media_session_find_object(impl->session, path_id)) != NULL) {
switch (obj->type) {
case PW_TYPE_INTERFACE_Endpoint:
if (strcmp(obj->type, PW_TYPE_INTERFACE_Endpoint) == 0) {
peer = sm_object_get_data(obj, SESSION_KEY);
goto do_link;
case PW_TYPE_INTERFACE_Node:
}
else if (strcmp(obj->type, PW_TYPE_INTERFACE_Node) == 0) {
node = (struct sm_node*)obj;
goto do_link_node;
}
@ -469,7 +455,7 @@ static int rescan_endpoint(struct impl *impl, struct endpoint *ep)
}
obj = sm_media_session_find_object(impl->session, ep->client_id);
if (obj && obj->type == PW_TYPE_INTERFACE_Client) {
if (obj && strcmp(obj->type, PW_TYPE_INTERFACE_Client) == 0) {
pw_client_error((struct pw_client*)obj->proxy,
ep->id, -ENOENT, "no endpoint available");
}

View file

@ -207,7 +207,7 @@ static int client_endpoint_create_link(void *object, const struct spa_dict *prop
goto exit;
}
obj = sm_media_session_find_object(impl->session, atoi(str));
if (obj == NULL || obj->type != PW_TYPE_INTERFACE_Endpoint) {
if (obj == NULL || strcmp(obj->type, PW_TYPE_INTERFACE_Endpoint) != 0) {
pw_log_warn(NAME" %p: could not find endpoint %s (%p)", impl, str, obj);
res = -EINVAL;
goto exit;
@ -557,15 +557,11 @@ static void session_create(void *data, struct sm_object *object)
struct impl *impl = data;
int res;
switch (object->type) {
case PW_TYPE_INTERFACE_Node:
if (strcmp(object->type, PW_TYPE_INTERFACE_Node) == 0)
res = handle_node(impl, object);
break;
default:
else
res = 0;
break;
}
if (res < 0) {
pw_log_warn(NAME" %p: can't handle global %d: %s", impl,
object->id, spa_strerror(res));
@ -576,16 +572,10 @@ static void session_remove(void *data, struct sm_object *object)
{
struct impl *impl = data;
switch (object->type) {
case PW_TYPE_INTERFACE_Node:
{
if (strcmp(object->type, PW_TYPE_INTERFACE_Node) == 0) {
struct node *node;
if ((node = sm_object_get_data(object, SESSION_KEY)) != NULL)
destroy_node(impl, node);
break;
}
default:
break;
}
}

View file

@ -161,7 +161,7 @@ static int client_endpoint_create_link(void *object, const struct spa_dict *prop
goto exit;
}
obj = sm_media_session_find_object(impl->session, atoi(str));
if (obj == NULL || obj->type != PW_TYPE_INTERFACE_Endpoint) {
if (obj == NULL || strcmp(obj->type, PW_TYPE_INTERFACE_Endpoint) != 0) {
pw_log_warn(NAME" %p: could not find endpoint %s (%p)", impl, str, obj);
res = -EINVAL;
goto exit;
@ -591,15 +591,11 @@ static void session_create(void *data, struct sm_object *object)
struct impl *impl = data;
int res;
switch (object->type) {
case PW_TYPE_INTERFACE_Device:
if (strcmp(object->type, PW_TYPE_INTERFACE_Device) == 0)
res = handle_device(impl, object);
break;
default:
else
res = 0;
break;
}
if (res < 0) {
pw_log_warn(NAME" %p: can't handle global %d: %s", impl,
object->id, spa_strerror(res));
@ -610,16 +606,10 @@ static void session_remove(void *data, struct sm_object *object)
{
struct impl *impl = data;
switch (object->type) {
case PW_TYPE_INTERFACE_Device:
{
if (strcmp(object->type, PW_TYPE_INTERFACE_Device) == 0) {
struct device *device;
if ((device = sm_object_get_data(object, SESSION_KEY)) != NULL)
destroy_device(impl, device);
break;
}
default:
break;
}
}

View file

@ -34,6 +34,7 @@
#include <spa/node/node.h>
#include <spa/utils/hook.h>
#include <spa/utils/names.h>
#include <spa/utils/result.h>
#include <spa/param/props.h>
#include <spa/debug/dict.h>
#include <spa/pod/builder.h>
@ -121,7 +122,7 @@ static struct node *v4l2_create_node(struct device *dev, uint32_t id,
pw_log_debug("new node %u", id);
if (info->type != SPA_TYPE_INTERFACE_Node) {
if (strcmp(info->type, SPA_TYPE_INTERFACE_Node) != 0) {
errno = EINVAL;
return NULL;
}
@ -337,7 +338,7 @@ static struct device *v4l2_create_device(struct impl *impl, uint32_t id,
pw_log_debug("new device %u", id);
if (info->type != SPA_TYPE_INTERFACE_Device) {
if (strcmp(info->type, SPA_TYPE_INTERFACE_Device) != 0) {
errno = EINVAL;
return NULL;
}
@ -352,7 +353,7 @@ static struct device *v4l2_create_device(struct impl *impl, uint32_t id,
}
if ((res = spa_handle_get_interface(handle, info->type, &iface)) < 0) {
pw_log_error("can't get %d interface: %d", info->type, res);
pw_log_error("can't get %s interface: %s", info->type, spa_strerror(res));
goto unload_handle;
}

View file

@ -32,9 +32,10 @@ extern "C" {
#include <spa/utils/defs.h>
#include <spa/param/param.h>
struct pw_client_node;
#define PW_TYPE_INTERFACE_ClientNode PW_TYPE_INFO_INTERFACE_BASE "ClientNode"
#define PW_VERSION_CLIENT_NODE 3
struct pw_client_node;
#define PW_EXTENSION_MODULE_CLIENT_NODE PIPEWIRE_MODULE_PREFIX "module-client-node"

View file

@ -31,9 +31,10 @@ extern "C" {
#include <spa/utils/defs.h>
struct pw_metadata;
#define PW_TYPE_INTERFACE_Metadata PW_TYPE_INFO_INTERFACE_BASE "Metadata"
#define PW_VERSION_METADATA 3
struct pw_metadata;
#define PW_EXTENSION_MODULE_METADATA PIPEWIRE_MODULE_PREFIX "module-metadata"

View file

@ -36,7 +36,9 @@
extern "C" {
#endif
#define PW_VERSION_CLIENT_ENDPOINT 0
#define PW_TYPE_INTERFACE_ClientEndpoint PW_TYPE_INFO_INTERFACE_BASE "ClientEndpoint"
#define PW_VERSION_CLIENT_ENDPOINT 0
struct pw_client_endpoint;
#define PW_CLIENT_ENDPOINT_EVENT_SET_SESSION_ID 0
@ -166,6 +168,7 @@ struct pw_client_endpoint_methods {
#define pw_client_endpoint_update(o,...) pw_client_endpoint_method(o,update,0,__VA_ARGS__)
#define pw_client_endpoint_stream_update(o,...) pw_client_endpoint_method(o,stream_update,0,__VA_ARGS__)
#define PW_TYPE_INTERFACE_ClientSession PW_TYPE_INFO_INTERFACE_BASE "ClientSession"
#define PW_VERSION_CLIENT_SESSION 0
struct pw_client_session;

View file

@ -35,12 +35,19 @@
extern "C" {
#endif
#define PW_VERSION_SESSION 0
#define PW_TYPE_INTERFACE_Session PW_TYPE_INFO_INTERFACE_BASE "Session"
#define PW_VERSION_SESSION 0
struct pw_session;
#define PW_VERSION_ENDPOINT 0
#define PW_TYPE_INTERFACE_Endpoint PW_TYPE_INFO_INTERFACE_BASE "Endpoint"
#define PW_VERSION_ENDPOINT 0
struct pw_endpoint;
#define PW_VERSION_ENDPOINT_STREAM 0
#define PW_TYPE_INTERFACE_EndpointStream PW_TYPE_INFO_INTERFACE_BASE "EndpointStream"
#define PW_VERSION_ENDPOINT_STREAM 0
struct pw_endpoint_stream;
#define PW_TYPE_INTERFACE_EndpointLink PW_TYPE_INFO_INTERFACE_BASE "EndpointLink"
#define PW_VERSION_ENDPOINT_LINK 0
struct pw_endpoint_link;

View file

@ -447,19 +447,18 @@ static const struct pw_proxy_events proxy_port_events = {
};
static void registry_event_global(void *data, uint32_t id, uint32_t permissions,
uint32_t type, uint32_t version,
const char *type, uint32_t version,
const struct spa_dict *props)
{
struct core_data *rd = data;
GstPipeWireDeviceProvider *self = rd->self;
struct node_data *nd;
if (type == PW_TYPE_INTERFACE_Node) {
if (strcmp(type, PW_TYPE_INTERFACE_Node) == 0) {
struct pw_node *node;
node = pw_registry_bind(rd->registry,
id, PW_TYPE_INTERFACE_Node,
PW_VERSION_NODE, sizeof(*nd));
id, type, PW_VERSION_NODE, sizeof(*nd));
if (node == NULL)
goto no_mem;
@ -473,7 +472,7 @@ static void registry_event_global(void *data, uint32_t id, uint32_t permissions,
pw_proxy_add_listener((struct pw_proxy*)node, &nd->proxy_listener, &proxy_node_events, nd);
add_pending(self, &nd->pending, NULL, NULL);
}
else if (type == PW_TYPE_INTERFACE_Port) {
else if (strcmp(type, PW_TYPE_INTERFACE_Port) == 0) {
struct pw_port *port;
struct port_data *pd;
const char *str;
@ -485,8 +484,7 @@ static void registry_event_global(void *data, uint32_t id, uint32_t permissions,
return;
port = pw_registry_bind(rd->registry,
id, PW_TYPE_INTERFACE_Port,
PW_VERSION_PORT, sizeof(*pd));
id, type, PW_VERSION_PORT, sizeof(*pd));
if (port == NULL)
goto no_mem;

View file

@ -138,7 +138,7 @@ static const struct pw_impl_node_events node_events = {
static void *create_object(void *_data,
struct pw_resource *resource,
uint32_t type,
const char *type,
uint32_t version,
struct pw_properties *properties,
uint32_t new_id)

View file

@ -44,7 +44,7 @@ static const struct spa_dict_item module_props[] = {
};
struct pw_proxy *pw_core_spa_device_export(struct pw_core *core,
uint32_t type, const struct spa_dict *props, void *object,
const char *type, const struct spa_dict *props, void *object,
size_t user_data_size);
struct pw_protocol *pw_protocol_native_ext_client_device_init(struct pw_context *context);
@ -60,7 +60,7 @@ struct factory_data {
static void *create_object(void *_data,
struct pw_resource *resource,
uint32_t type,
const char *type,
uint32_t version,
struct pw_properties *properties,
uint32_t new_id)

View file

@ -425,7 +425,7 @@ static void device_marshal_object_info(void *object, uint32_t id,
spa_pod_builder_push_struct(b, &f[1]);
spa_pod_builder_add(b,
SPA_POD_Id(info->type),
SPA_POD_String(info->type),
SPA_POD_Long(change_mask),
SPA_POD_Long(info->flags),
SPA_POD_Int(n_items), NULL);
@ -465,7 +465,7 @@ static int device_demarshal_object_info(void *object,
spa_pod_parser_pod(&p2, ipod);
if (spa_pod_parser_push_struct(&p2, &f2) < 0 ||
spa_pod_parser_get(&p2,
SPA_POD_Id(&info.type),
SPA_POD_String(&info.type),
SPA_POD_Long(&info.change_mask),
SPA_POD_Long(&info.flags),
SPA_POD_Int(&props.n_items), NULL) < 0)

View file

@ -45,9 +45,9 @@ static const struct spa_dict_item module_props[] = {
};
struct pw_proxy *pw_core_node_export(struct pw_core *core,
uint32_t type, const struct spa_dict *props, void *object, size_t user_data_size);
const char *type, const struct spa_dict *props, void *object, size_t user_data_size);
struct pw_proxy *pw_core_spa_node_export(struct pw_core *core,
uint32_t type, const struct spa_dict *props, void *object, size_t user_data_size);
const char *type, const struct spa_dict *props, void *object, size_t user_data_size);
struct pw_protocol *pw_protocol_native_ext_client_node_init(struct pw_context *context);
struct pw_protocol *pw_protocol_native_ext_client_node0_init(struct pw_context *context);
@ -64,7 +64,7 @@ struct factory_data {
static void *create_object(void *_data,
struct pw_resource *resource,
uint32_t type,
const char *type,
uint32_t version,
struct pw_properties *properties,
uint32_t new_id)

View file

@ -1090,21 +1090,10 @@ node_init(struct node *this,
const struct spa_support *support,
uint32_t n_support)
{
uint32_t i;
this->log = spa_support_find(support, n_support, SPA_TYPE_INTERFACE_Log);
this->data_loop = spa_support_find(support, n_support, SPA_TYPE_INTERFACE_DataLoop);
this->data_system = spa_support_find(support, n_support, SPA_TYPE_INTERFACE_DataSystem);
for (i = 0; i < n_support; i++) {
switch (support[i].type) {
case SPA_TYPE_INTERFACE_Log:
this->log = support[i].data;
break;
case SPA_TYPE_INTERFACE_DataLoop:
this->data_loop = support[i].data;
break;
case SPA_TYPE_INTERFACE_DataSystem:
this->data_system = support[i].data;
break;
}
}
if (this->data_loop == NULL) {
spa_log_error(this->log, "a data-loop is needed");
return -EINVAL;

View file

@ -1078,21 +1078,10 @@ node_init(struct node *this,
const struct spa_support *support,
uint32_t n_support)
{
uint32_t i;
this->log = spa_support_find(support, n_support, SPA_TYPE_INTERFACE_Log);
this->data_loop = spa_support_find(support, n_support, SPA_TYPE_INTERFACE_DataLoop);
this->data_system = spa_support_find(support, n_support, SPA_TYPE_INTERFACE_DataSystem);
for (i = 0; i < n_support; i++) {
switch (support[i].type) {
case SPA_TYPE_INTERFACE_Log:
this->log = support[i].data;
break;
case SPA_TYPE_INTERFACE_DataLoop:
this->data_loop = support[i].data;
break;
case SPA_TYPE_INTERFACE_DataSystem:
this->data_system = support[i].data;
break;
}
}
if (this->data_loop == NULL) {
spa_log_error(this->log, "a data-loop is needed");
return -EINVAL;

View file

@ -30,6 +30,8 @@ extern "C" {
#include <pipewire/proxy.h>
#define PW_TYPE_INTERFACE_ClientNode PW_TYPE_INFO_INTERFACE_BASE "ClientNode"
#define PW_VERSION_CLIENT_NODE0 0
struct pw_client_node0_message;

View file

@ -172,7 +172,7 @@ static struct pw_impl_port *get_port(struct pw_impl_node *node, enum spa_directi
static void *create_object(void *_data,
struct pw_resource *resource,
uint32_t type,
const char *type,
uint32_t version,
struct pw_properties *properties,
uint32_t new_id)
@ -214,13 +214,13 @@ static void *create_object(void *_data,
input_port_id = str ? pw_properties_parse_int(str) : -1;
global = pw_context_find_global(context, output_node_id);
if (global == NULL || pw_global_get_type(global) != PW_TYPE_INTERFACE_Node)
if (global == NULL || !pw_global_is_type(global, PW_TYPE_INTERFACE_Node))
goto error_output;
output_node = pw_global_get_object(global);
global = pw_context_find_global(context, input_node_id);
if (global == NULL || pw_global_get_type(global) != PW_TYPE_INTERFACE_Node)
if (global == NULL || !pw_global_is_type(global, PW_TYPE_INTERFACE_Node))
goto error_input;
input_node = pw_global_get_object(global);
@ -230,7 +230,7 @@ static void *create_object(void *_data,
}
else {
global = pw_context_find_global(context, output_port_id);
if (global == NULL || pw_global_get_type(global) != PW_TYPE_INTERFACE_Port)
if (global == NULL || !pw_global_is_type(global, PW_TYPE_INTERFACE_Port))
goto error_output_port;
outport = pw_global_get_object(global);
@ -242,7 +242,7 @@ static void *create_object(void *_data,
inport = get_port(input_node, SPA_DIRECTION_INPUT);
else {
global = pw_context_find_global(context, input_port_id);
if (global == NULL || pw_global_get_type(global) != PW_TYPE_INTERFACE_Port)
if (global == NULL || !pw_global_is_type(global, PW_TYPE_INTERFACE_Port))
goto error_input_port;
inport = pw_global_get_object(global);

View file

@ -47,7 +47,7 @@ void * pw_metadata_new(struct pw_context *context, struct pw_resource *resource,
struct pw_properties *properties);
struct pw_proxy *pw_core_metadata_export(struct pw_core *core,
uint32_t type, const struct spa_dict *props, void *object, size_t user_data_size);
const char *type, const struct spa_dict *props, void *object, size_t user_data_size);
int pw_protocol_native_ext_metadata_init(struct pw_context *context);
@ -62,7 +62,7 @@ struct factory_data {
static void *create_object(void *_data,
struct pw_resource *resource,
uint32_t type,
const char *type,
uint32_t version,
struct pw_properties *properties,
uint32_t new_id)

View file

@ -193,7 +193,7 @@ static void push_params(struct spa_pod_builder *b, uint32_t n_params,
static void *
core_method_marshal_create_object(void *object,
const char *factory_name,
uint32_t type, uint32_t version,
const char *type, uint32_t version,
const struct spa_dict *props, size_t user_data_size)
{
struct pw_proxy *proxy = object;
@ -213,7 +213,7 @@ core_method_marshal_create_object(void *object,
spa_pod_builder_push_struct(b, &f);
spa_pod_builder_add(b,
SPA_POD_String(factory_name),
SPA_POD_Id(type),
SPA_POD_String(type),
SPA_POD_Int(version),
NULL);
push_dict(b, props);
@ -595,15 +595,15 @@ static int core_method_demarshal_create_object(void *object, const struct pw_pro
struct pw_resource *resource = object;
struct spa_pod_parser prs;
struct spa_pod_frame f[2];
uint32_t version, type, new_id;
const char *factory_name;
uint32_t version, new_id;
const char *factory_name, *type;
struct spa_dict props = SPA_DICT_INIT(NULL, 0);
spa_pod_parser_init(&prs, msg->data, msg->size);
if (spa_pod_parser_push_struct(&prs, &f[0]) < 0 ||
spa_pod_parser_get(&prs,
SPA_POD_String(&factory_name),
SPA_POD_Id(&type),
SPA_POD_String(&type),
SPA_POD_Int(&version),
NULL) < 0)
return -EINVAL;
@ -664,7 +664,7 @@ static int registry_method_marshal_add_listener(void *object,
}
static void registry_marshal_global(void *object, uint32_t id, uint32_t permissions,
uint32_t type, uint32_t version, const struct spa_dict *props)
const char *type, uint32_t version, const struct spa_dict *props)
{
struct pw_resource *resource = object;
struct spa_pod_builder *b;
@ -676,7 +676,7 @@ static void registry_marshal_global(void *object, uint32_t id, uint32_t permissi
spa_pod_builder_add(b,
SPA_POD_Int(id),
SPA_POD_Int(permissions),
SPA_POD_Id(type),
SPA_POD_String(type),
SPA_POD_Int(version),
NULL);
push_dict(b, props);
@ -701,12 +701,13 @@ static int registry_demarshal_bind(void *object, const struct pw_protocol_native
{
struct pw_resource *resource = object;
struct spa_pod_parser prs;
uint32_t id, version, type, new_id;
uint32_t id, version, new_id;
char *type;
spa_pod_parser_init(&prs, msg->data, msg->size);
if (spa_pod_parser_get_struct(&prs,
SPA_POD_Int(&id),
SPA_POD_Id(&type),
SPA_POD_String(&type),
SPA_POD_Int(&version),
SPA_POD_Int(&new_id)) < 0)
return -EINVAL;
@ -998,7 +999,7 @@ static void factory_marshal_info(void *object, const struct pw_factory_info *inf
spa_pod_builder_add(b,
SPA_POD_Int(info->id),
SPA_POD_String(info->name),
SPA_POD_Id(info->type),
SPA_POD_String(info->type),
SPA_POD_Int(info->version),
SPA_POD_Long(info->change_mask),
NULL);
@ -1021,7 +1022,7 @@ static int factory_demarshal_info(void *object, const struct pw_protocol_native_
spa_pod_parser_get(&prs,
SPA_POD_Int(&info.id),
SPA_POD_String(&info.name),
SPA_POD_Id(&info.type),
SPA_POD_String(&info.type),
SPA_POD_Int(&info.version),
SPA_POD_Long(&info.change_mask), NULL) < 0)
return -EINVAL;
@ -1815,7 +1816,8 @@ static int registry_demarshal_global(void *object, const struct pw_protocol_nati
struct pw_proxy *proxy = object;
struct spa_pod_parser prs;
struct spa_pod_frame f[2];
uint32_t id, permissions, type, version;
uint32_t id, permissions, version;
char *type;
struct spa_dict props = SPA_DICT_INIT(NULL, 0);
spa_pod_parser_init(&prs, msg->data, msg->size);
@ -1823,7 +1825,7 @@ static int registry_demarshal_global(void *object, const struct pw_protocol_nati
spa_pod_parser_get(&prs,
SPA_POD_Int(&id),
SPA_POD_Int(&permissions),
SPA_POD_Id(&type),
SPA_POD_String(&type),
SPA_POD_Int(&version), NULL) < 0)
return -EINVAL;
@ -1856,7 +1858,7 @@ static int registry_demarshal_global_remove(void *object, const struct pw_protoc
}
static void * registry_marshal_bind(void *object, uint32_t id,
uint32_t type, uint32_t version, size_t user_data_size)
const char *type, uint32_t version, size_t user_data_size)
{
struct pw_proxy *proxy = object;
struct spa_pod_builder *b;
@ -1873,7 +1875,7 @@ static void * registry_marshal_bind(void *object, uint32_t id,
spa_pod_builder_add_struct(b,
SPA_POD_Int(id),
SPA_POD_Id(type),
SPA_POD_String(type),
SPA_POD_Int(version),
SPA_POD_Int(new_id));

View file

@ -28,6 +28,9 @@
#include "pipewire/protocol.h"
#include "pipewire/resource.h"
#include "extensions/protocol-native.h"
#include "extensions/metadata.h"
#include "extensions/session-manager.h"
#include "extensions/client-node.h"
#include "interfaces.h"
#include "typemap.h"
@ -275,6 +278,23 @@ uint32_t pw_protocol_native0_type_from_v2(struct pw_impl_client *client, uint32_
return type_map[index].id;
}
SPA_EXPORT
const char * pw_protocol_native0_name_from_v2(struct pw_impl_client *client, uint32_t type)
{
void *t;
uint32_t index;
struct protocol_compat_v2 *compat_v2 = client->compat_v2;
if ((t = pw_map_lookup(&compat_v2->types, type)) == NULL)
return NULL;
index = PW_MAP_PTR_TO_ID(t);
if (index >= SPA_N_ELEMENTS(type_map))
return NULL;
return type_map[index].name;
}
SPA_EXPORT
uint32_t pw_protocol_native0_type_to_v2(struct pw_impl_client *client,
const struct spa_type_info *info, uint32_t type)
@ -614,7 +634,7 @@ static int core_demarshal_create_object(void *object, const struct pw_protocol_n
struct spa_pod_parser prs;
struct spa_pod_frame f;
uint32_t version, type, new_id, i;
const char *factory_name;
const char *factory_name, *type_name;
struct spa_dict props;
spa_pod_parser_init(&prs, msg->data, msg->size);
@ -636,10 +656,12 @@ static int core_demarshal_create_object(void *object, const struct pw_protocol_n
if (spa_pod_parser_get(&prs, "i", &new_id, NULL) < 0)
return -EINVAL;
type = pw_protocol_native0_type_from_v2(client, type);
type_name = pw_protocol_native0_name_from_v2(client, type);
if (type_name == NULL)
return -EINVAL;
return pw_resource_notify(resource, struct pw_core_methods, create_object, 0, factory_name,
type, version,
type_name, version,
&props, new_id);
}
@ -702,19 +724,20 @@ static int core_demarshal_update_types_server(void *object, const struct pw_prot
}
static void registry_marshal_global(void *object, uint32_t id, uint32_t permissions,
uint32_t type, uint32_t version, const struct spa_dict *props)
const char *type, uint32_t version, const struct spa_dict *props)
{
struct pw_resource *resource = object;
struct pw_impl_client *client = resource->client;
struct spa_pod_builder *b;
struct spa_pod_frame f;
uint32_t i, n_items, parent_id;
uint32_t type_id;
b = pw_protocol_native_begin_resource(resource, PW_REGISTRY_V0_EVENT_GLOBAL, NULL);
n_items = props ? props->n_items : 0;
type = pw_protocol_native0_type_to_v2(client, pw_type_info(), type);
type_id = pw_protocol_native0_find_type(client, type);
parent_id = 0;
version = 0;
@ -723,7 +746,7 @@ static void registry_marshal_global(void *object, uint32_t id, uint32_t permissi
"i", id,
"i", parent_id,
"i", permissions,
"I", type,
"I", type_id,
"i", version,
"i", n_items, NULL);
@ -754,6 +777,7 @@ static int registry_demarshal_bind(void *object, const struct pw_protocol_native
struct pw_resource *resource = object;
struct spa_pod_parser prs;
uint32_t id, version, type, new_id;
const char *type_name;
spa_pod_parser_init(&prs, msg->data, msg->size);
if (spa_pod_parser_get_struct(&prs,
@ -763,9 +787,11 @@ static int registry_demarshal_bind(void *object, const struct pw_protocol_native
"i", &new_id) < 0)
return -EINVAL;
type = pw_protocol_native0_type_from_v2(resource->client, type);
type_name = pw_protocol_native0_name_from_v2(resource->client, type);
if (type_name == NULL)
return -EINVAL;
return pw_resource_notify(resource, struct pw_registry_methods, bind, 0, id, type, version, new_id);
return pw_resource_notify(resource, struct pw_registry_methods, bind, 0, id, type_name, version, new_id);
}
static void module_marshal_info(void *object, const struct pw_module_info *info)
@ -810,7 +836,7 @@ static void factory_marshal_info(void *object, const struct pw_factory_info *inf
n_items = info->props ? info->props->n_items : 0;
type = pw_protocol_native0_type_to_v2(client, pw_type_info(), info->type);
type = pw_protocol_native0_find_type(client, info->type);
version = 0;
spa_pod_builder_push_struct(b, &f);

View file

@ -5,34 +5,34 @@ const struct type_info {
uint32_t id;
} type_map[] = {
{ "Spa:Interface:TypeMap", SPA_TYPE_INFO_INTERFACE_BASE, 0, },
{ "Spa:Interface:Log", SPA_TYPE_INFO_INTERFACE_BASE "Log", SPA_TYPE_INTERFACE_Log, },
{ "Spa:Interface:Loop", SPA_TYPE_INFO_INTERFACE_BASE "Loop", SPA_TYPE_INTERFACE_Loop, },
{ "Spa:Interface:LoopControl", SPA_TYPE_INFO_INTERFACE_BASE "LoopControl", SPA_TYPE_INTERFACE_LoopControl, },
{ "Spa:Interface:LoopUtils", SPA_TYPE_INFO_INTERFACE_BASE "LoopUtils", SPA_TYPE_INTERFACE_LoopUtils, },
{ "PipeWire:Interface:Core", PW_TYPE_INFO_INTERFACE_BASE "Core", PW_TYPE_INTERFACE_Core, },
{ "PipeWire:Interface:Registry", PW_TYPE_INFO_INTERFACE_BASE "Registry", PW_TYPE_INTERFACE_Registry, },
{ "PipeWire:Interface:Node", PW_TYPE_INFO_INTERFACE_BASE "Node", PW_TYPE_INTERFACE_Node, },
{ "PipeWire:Interface:Port", PW_TYPE_INFO_INTERFACE_BASE "Port", PW_TYPE_INTERFACE_Port,},
{ "PipeWire:Interface:Factory", PW_TYPE_INFO_INTERFACE_BASE "Factory", PW_TYPE_INTERFACE_Factory, },
{ "PipeWire:Interface:Link", PW_TYPE_INFO_INTERFACE_BASE "Link", PW_TYPE_INTERFACE_Link, },
{ "PipeWire:Interface:Client", PW_TYPE_INFO_INTERFACE_BASE "Client", PW_TYPE_INTERFACE_Client, },
{ "PipeWire:Interface:Module", PW_TYPE_INFO_INTERFACE_BASE "Module", PW_TYPE_INTERFACE_Module, },
{ "PipeWire:Interface:Device", PW_TYPE_INFO_INTERFACE_BASE "Device", PW_TYPE_INTERFACE_Device, },
{ "Spa:Interface:Log", SPA_TYPE_INTERFACE_Log, 0, },
{ "Spa:Interface:Loop", SPA_TYPE_INTERFACE_Loop, 0, },
{ "Spa:Interface:LoopControl", SPA_TYPE_INTERFACE_LoopControl, 0, },
{ "Spa:Interface:LoopUtils", SPA_TYPE_INTERFACE_LoopUtils, 0, },
{ "PipeWire:Interface:Core", PW_TYPE_INTERFACE_Core, 0, },
{ "PipeWire:Interface:Registry", PW_TYPE_INTERFACE_Registry, 0, },
{ "PipeWire:Interface:Node", PW_TYPE_INTERFACE_Node, 0, },
{ "PipeWire:Interface:Port", PW_TYPE_INTERFACE_Port,0, },
{ "PipeWire:Interface:Factory", PW_TYPE_INTERFACE_Factory, 0, },
{ "PipeWire:Interface:Link", PW_TYPE_INTERFACE_Link, 0, },
{ "PipeWire:Interface:Client", PW_TYPE_INTERFACE_Client, 0, },
{ "PipeWire:Interface:Module", PW_TYPE_INTERFACE_Module, 0, },
{ "PipeWire:Interface:Device", PW_TYPE_INTERFACE_Device, 0, },
{ "PipeWire:Interface:Metadata", PW_TYPE_INFO_INTERFACE_BASE "Metadata", PW_TYPE_INTERFACE_Metadata, },
{ "PipeWire:Interface:Session", PW_TYPE_INFO_INTERFACE_BASE "Session", PW_TYPE_INTERFACE_Session, },
{ "PipeWire:Interface:Endpoint", PW_TYPE_INFO_INTERFACE_BASE "Endpoint", PW_TYPE_INTERFACE_Endpoint, },
{ "PipeWire:Interface:EndpointStream", PW_TYPE_INFO_INTERFACE_BASE "EndpointStream", PW_TYPE_INTERFACE_EndpointStream, },
{ "PipeWire:Interface:EndpointLink", PW_TYPE_INFO_INTERFACE_BASE "EndpointLink", PW_TYPE_INTERFACE_EndpointLink, },
{ "PipeWire:Interface:Metadata", PW_TYPE_INTERFACE_Metadata, 0, },
{ "PipeWire:Interface:Session", PW_TYPE_INTERFACE_Session, 0, },
{ "PipeWire:Interface:Endpoint", PW_TYPE_INTERFACE_Endpoint, 0, },
{ "PipeWire:Interface:EndpointStream", PW_TYPE_INTERFACE_EndpointStream, 0, },
{ "PipeWire:Interface:EndpointLink", PW_TYPE_INTERFACE_EndpointLink, 0, },
{ "PipeWire:Interface:ClientNode", PW_TYPE_INFO_INTERFACE_BASE "ClientNode", PW_TYPE_INTERFACE_ClientNode, },
{ "PipeWire:Interface:ClientSession", PW_TYPE_INFO_INTERFACE_BASE "ClientSession", PW_TYPE_INTERFACE_ClientSession, },
{ "PipeWire:Interface:ClientEndpoint", PW_TYPE_INFO_INTERFACE_BASE "ClientEndpoint", PW_TYPE_INTERFACE_ClientEndpoint, },
{ "PipeWire:Interface:ClientNode", PW_TYPE_INTERFACE_ClientNode, 0, },
{ "PipeWire:Interface:ClientSession", PW_TYPE_INTERFACE_ClientSession, 0, },
{ "PipeWire:Interface:ClientEndpoint", PW_TYPE_INTERFACE_ClientEndpoint, 0, },
{ "Spa:Interface:Node", SPA_TYPE_INFO_INTERFACE_BASE "Node", SPA_TYPE_INTERFACE_Node, },
{ "Spa:Interface:Node", SPA_TYPE_INTERFACE_Node, 0, },
{ "Spa:Interface:Clock", },
{ "Spa:Interface:Monitor", },
{ "Spa:Interface:Device", SPA_TYPE_INFO_INTERFACE_BASE "Device", SPA_TYPE_INTERFACE_Device, },
{ "Spa:Interface:Device", SPA_TYPE_INTERFACE_Device, 0, },
{ "Spa:POD:Object:Param:Format", SPA_TYPE_INFO_Format, SPA_TYPE_OBJECT_Format, },
{ "Spa:POD:Object:Param:Props", SPA_TYPE_INFO_Props, SPA_TYPE_OBJECT_Props, },
{ "Spa:Pointer:IO:Buffers", },
@ -102,7 +102,7 @@ const struct type_info {
{ "Spa:Enum:ParamId:IO:Props:In", },
{ "Spa:Enum:ParamId:IO:Props:Out", },
{ "Spa:POD:Object:Param:IO:Prop", },
{ "Spa:Interface:DBus", SPA_TYPE_INFO_INTERFACE_BASE "DBus", SPA_TYPE_INTERFACE_DBus, },
{ "Spa:Interface:DBus", SPA_TYPE_INFO_INTERFACE_BASE "DBus", 0, },
{ "Spa:Enum:MediaType:audio", SPA_TYPE_INFO_MEDIA_TYPE_BASE "audio", SPA_MEDIA_TYPE_audio, },
{ "Spa:Enum:MediaType:video", SPA_TYPE_INFO_MEDIA_TYPE_BASE "video", SPA_MEDIA_TYPE_video, },
{ "Spa:Enum:MediaType:image", SPA_TYPE_INFO_MEDIA_TYPE_BASE "image", SPA_MEDIA_TYPE_image, },

View file

@ -160,7 +160,7 @@ static const struct pw_resource_events resource_events = {
static void *create_object(void *data,
struct pw_resource *owner_resource,
uint32_t type,
const char *type,
uint32_t version,
struct pw_properties *properties,
uint32_t new_id)

View file

@ -159,7 +159,7 @@ static const struct pw_resource_events resource_events = {
static void *create_object(void *data,
struct pw_resource *owner_resource,
uint32_t type,
const char *type,
uint32_t version,
struct pw_properties *properties,
uint32_t new_id)

View file

@ -77,7 +77,7 @@ static const struct pw_impl_device_events device_events = {
static void *create_object(void *_data,
struct pw_resource *resource,
uint32_t type,
const char *type,
uint32_t version,
struct pw_properties *properties,
uint32_t new_id)

View file

@ -95,7 +95,7 @@ static const struct pw_impl_node_events node_events = {
static void *create_object(void *_data,
struct pw_resource *resource,
uint32_t type,
const char *type,
uint32_t version,
struct pw_properties *properties,
uint32_t new_id)

View file

@ -35,6 +35,11 @@ extern "C" {
#include <pipewire/proxy.h>
#include <pipewire/permission.h>
#define PW_TYPE_INTERFACE_Client PW_TYPE_INFO_INTERFACE_BASE "Client"
#define PW_VERSION_CLIENT 3
struct pw_client;
/** The client information. Extra information can be added in later versions \memberof pw_introspect */
struct pw_client_info {
uint32_t id; /**< id of the global */
@ -53,9 +58,6 @@ pw_client_info_update(struct pw_client_info *info,
void pw_client_info_free(struct pw_client_info *info);
#define PW_VERSION_CLIENT 3
struct pw_client;
#define PW_CLIENT_EVENT_INFO 0
#define PW_CLIENT_EVENT_PERMISSIONS 1
#define PW_CLIENT_EVENT_NUM 2

View file

@ -876,18 +876,17 @@ struct spa_handle *pw_context_load_spa_handle(struct pw_context *context,
SPA_EXPORT
int pw_context_register_export_type(struct pw_context *context, struct pw_export_type *type)
{
pw_log_debug("context %p: Add export type %d/%s to context", context, type->type,
spa_debug_type_find_name(pw_type_info(), type->type));
pw_log_debug("context %p: Add export type %s to context", context, type->type);
spa_list_append(&context->export_list, &type->link);
return 0;
}
SPA_EXPORT
const struct pw_export_type *pw_context_find_export_type(struct pw_context *context, uint32_t type)
const struct pw_export_type *pw_context_find_export_type(struct pw_context *context, const char *type)
{
const struct pw_export_type *t;
spa_list_for_each(t, &context->export_list, link) {
if (t->type == type)
if (strcmp(t->type, type) == 0)
return t;
}
return NULL;

View file

@ -148,9 +148,9 @@ struct spa_handle *pw_context_load_spa_handle(struct pw_context *context,
/** data for registering export functions */
struct pw_export_type {
struct spa_list link;
uint32_t type;
const char *type;
struct pw_proxy * (*func) (struct pw_core *core,
uint32_t type, const struct spa_dict *props, void *object,
const char *type, const struct spa_dict *props, void *object,
size_t user_data_size);
};
@ -158,7 +158,7 @@ struct pw_export_type {
* extension modules */
int pw_context_register_export_type(struct pw_context *context, struct pw_export_type *type);
/** find information about registered export type */
const struct pw_export_type *pw_context_find_export_type(struct pw_context *context, uint32_t type);
const struct pw_export_type *pw_context_find_export_type(struct pw_context *context, const char *type);
/** add an object to the context */
int pw_context_set_object(struct pw_context *context, const char *type, void *value);

View file

@ -237,7 +237,7 @@ struct pw_proxy *pw_core_find_proxy(struct pw_core *core, uint32_t id)
SPA_EXPORT
struct pw_proxy *pw_core_export(struct pw_core *core,
uint32_t type, const struct spa_dict *props, void *object,
const char *type, const struct spa_dict *props, void *object,
size_t user_data_size)
{
struct pw_proxy *proxy;
@ -258,7 +258,7 @@ struct pw_proxy *pw_core_export(struct pw_core *core,
return proxy;
error_export_type:
pw_log_error(NAME" %p: can't export type %d: %s", core, type, spa_strerror(res));
pw_log_error(NAME" %p: can't export type %s: %s", core, type, spa_strerror(res));
goto exit;
error_proxy_failed:
pw_log_error(NAME" %p: failed to create proxy: %s", core, spa_strerror(res));

View file

@ -34,6 +34,9 @@ extern "C" {
#include <spa/utils/hook.h>
#define PW_TYPE_INTERFACE_Core PW_TYPE_INFO_INTERFACE_BASE "Core"
#define PW_TYPE_INTERFACE_Registry PW_TYPE_INFO_INTERFACE_BASE "Registry"
#define PW_VERSION_CORE 3
struct pw_core;
#define PW_VERSION_REGISTRY 3
@ -278,7 +281,7 @@ struct pw_core_methods {
*/
void * (*create_object) (void *object,
const char *factory_name,
uint32_t type,
const char *type,
uint32_t version,
const struct spa_dict *props,
size_t user_data_size);
@ -342,7 +345,7 @@ pw_core_get_registry(struct pw_core *core, uint32_t version, size_t user_data_si
static inline void *
pw_core_create_object(struct pw_core *core,
const char *factory_name,
uint32_t type,
const char *type,
uint32_t version,
const struct spa_dict *props,
size_t user_data_size)
@ -410,7 +413,7 @@ struct pw_registry_events {
* \param props extra properties of the global
*/
void (*global) (void *object, uint32_t id,
uint32_t permissions, uint32_t type, uint32_t version,
uint32_t permissions, const char *type, uint32_t version,
const struct spa_dict *props);
/**
* Notify of a global object removal
@ -450,7 +453,7 @@ struct pw_registry_methods {
* \param version the interface version to use
* \returns the new object
*/
void * (*bind) (void *object, uint32_t id, uint32_t type, uint32_t version,
void * (*bind) (void *object, uint32_t id, const char *type, uint32_t version,
size_t use_data_size);
/**
@ -477,7 +480,7 @@ struct pw_registry_methods {
static inline void *
pw_registry_bind(struct pw_registry *registry,
uint32_t id, uint32_t type, uint32_t version,
uint32_t id, const char *type, uint32_t version,
size_t user_data_size)
{
void *res = NULL;
@ -550,7 +553,7 @@ struct pw_proxy *pw_core_find_proxy(struct pw_core *core, uint32_t id);
/** Export an object into the PipeWire instance associated with core */
struct pw_proxy *pw_core_export(struct pw_core *core, /**< the core */
uint32_t type, /**< the type of object */
const char *type, /**< the type of object */
const struct spa_dict *props, /**< extra properties */
void *object, /**< object to export */
size_t user_data_size /**< extra user data */);

View file

@ -34,6 +34,8 @@ extern "C" {
#include <pipewire/proxy.h>
#define PW_TYPE_INTERFACE_Device PW_TYPE_INFO_INTERFACE_BASE "Device"
#define PW_VERSION_DEVICE 3
struct pw_device;

View file

@ -37,14 +37,16 @@ extern "C" {
#include <pipewire/proxy.h>
#define PW_VERSION_FACTORY 3
#define PW_TYPE_INTERFACE_Factory PW_TYPE_INFO_INTERFACE_BASE "Factory"
#define PW_VERSION_FACTORY 3
struct pw_factory;
/** The factory information. Extra information can be added in later versions \memberof pw_introspect */
struct pw_factory_info {
uint32_t id; /**< id of the global */
const char *name; /**< name the factory */
uint32_t type; /**< type of the objects created by this factory */
const char *type; /**< type of the objects created by this factory */
uint32_t version; /**< version of the objects */
#define PW_FACTORY_CHANGE_MASK_PROPS (1 << 0)
#define PW_FACTORY_CHANGE_MASK_ALL ((1 << 1)-1)

View file

@ -65,7 +65,7 @@ uint32_t pw_global_get_permissions(struct pw_global *global, struct pw_impl_clie
SPA_EXPORT
struct pw_global *
pw_global_new(struct pw_context *context,
uint32_t type,
const char *type,
uint32_t version,
struct pw_properties *properties,
pw_global_bind_func_t func,
@ -104,9 +104,7 @@ pw_global_new(struct pw_context *context,
spa_list_init(&this->resource_list);
spa_hook_list_init(&this->listener_list);
pw_log_debug(NAME" %p: new %s %d", this,
spa_debug_type_find_name(pw_type_info(), this->type),
this->id);
pw_log_debug(NAME" %p: new %s %d", this, this->type, this->id);
return this;
@ -190,11 +188,17 @@ struct pw_context *pw_global_get_context(struct pw_global *global)
}
SPA_EXPORT
uint32_t pw_global_get_type(struct pw_global *global)
const char * pw_global_get_type(struct pw_global *global)
{
return global->type;
}
SPA_EXPORT
bool pw_global_is_type(struct pw_global *global, const char *type)
{
return strcmp(global->type, type) == 0;
}
SPA_EXPORT
uint32_t pw_global_get_version(struct pw_global *global)
{

View file

@ -79,8 +79,8 @@ struct pw_global_events {
/** Create a new global object */
struct pw_global *
pw_global_new(struct pw_context *context, /**< the context */
uint32_t type, /**< the interface type of the global */
pw_global_new(struct pw_context *context, /**< the context */
const char *type, /**< the interface type of the global */
uint32_t version, /**< the interface version of the global */
struct pw_properties *properties, /**< extra properties */
pw_global_bind_func_t func, /**< function to bind */
@ -102,7 +102,10 @@ uint32_t pw_global_get_permissions(struct pw_global *global, struct pw_impl_clie
struct pw_context *pw_global_get_context(struct pw_global *global);
/** Get the global type */
uint32_t pw_global_get_type(struct pw_global *global);
const char *pw_global_get_type(struct pw_global *global);
/** Check a global type */
bool pw_global_is_type(struct pw_global *global, const char *type);
/** Get the global version */
uint32_t pw_global_get_version(struct pw_global *global);

View file

@ -40,7 +40,7 @@ struct resource_data {
};
static void * registry_bind(void *object, uint32_t id,
uint32_t type, uint32_t version, size_t user_data_size)
const char *type, uint32_t version, size_t user_data_size)
{
struct pw_resource *resource = object;
struct pw_impl_client *client = resource->client;
@ -56,11 +56,11 @@ static void * registry_bind(void *object, uint32_t id,
if (!PW_PERM_IS_R(permissions))
goto error_no_id;
if (global->type != type)
if (strcmp(global->type, type) != 0)
goto error_wrong_interface;
pw_log_debug("global %p: bind global id %d, iface %s/%d to %d", global, id,
spa_debug_type_find_name(pw_type_info(), type), version, new_id);
type, version, new_id);
if (pw_global_bind(global, client, permissions, version, new_id) < 0)
goto error_exit_clean;
@ -72,8 +72,8 @@ error_no_id:
pw_resource_errorf(resource, -ENOENT, "no such global %u", id);
goto error_exit_clean;
error_wrong_interface:
pw_log_debug("registry %p: global with id %u has no interface %u", resource, id, type);
pw_resource_errorf(resource, -ENOENT, "no such interface %u", type);
pw_log_debug("registry %p: global with id %u has no interface %s", resource, id, type);
pw_resource_errorf(resource, -ENOENT, "no such interface %s", type);
goto error_exit_clean;
error_exit_clean:
/* unmark the new_id the map, the client does not yet know about the failed
@ -272,7 +272,7 @@ error_resource:
static void *
core_create_object(void *object,
const char *factory_name,
uint32_t type,
const char *type,
uint32_t version,
const struct spa_dict *props,
size_t user_data_size)
@ -293,7 +293,7 @@ core_create_object(void *object,
if (!PW_PERM_IS_R(pw_global_get_permissions(factory->global, client)))
goto error_no_factory;
if (factory->info.type != type)
if (strcmp(factory->info.type, type) != 0)
goto error_type;
if (factory->info.version < version)

View file

@ -64,6 +64,8 @@ struct resource_data {
struct object_data {
struct spa_list link;
uint32_t id;
#define OBJECT_NODE 0
#define OBJECT_DEVICE 1
uint32_t type;
struct spa_handle *handle;
void *object;
@ -73,10 +75,10 @@ struct object_data {
static void object_destroy(struct object_data *od)
{
switch (od->type) {
case SPA_TYPE_INTERFACE_Node:
case OBJECT_NODE:
pw_impl_node_destroy(od->object);
break;
case SPA_TYPE_INTERFACE_Device:
case OBJECT_DEVICE:
pw_impl_device_destroy(od->object);
break;
}
@ -85,10 +87,10 @@ static void object_destroy(struct object_data *od)
static void object_update(struct object_data *od, const struct spa_dict *props)
{
switch (od->type) {
case SPA_TYPE_INTERFACE_Node:
case OBJECT_NODE:
pw_impl_node_update_properties(od->object, props);
break;
case SPA_TYPE_INTERFACE_Device:
case OBJECT_DEVICE:
pw_impl_device_update_properties(od->object, props);
break;
}
@ -97,11 +99,11 @@ static void object_update(struct object_data *od, const struct spa_dict *props)
static void object_register(struct object_data *od)
{
switch (od->type) {
case SPA_TYPE_INTERFACE_Node:
case OBJECT_NODE:
pw_impl_node_register(od->object, NULL);
pw_impl_node_set_active(od->object, true);
break;
case SPA_TYPE_INTERFACE_Device:
case OBJECT_DEVICE:
pw_impl_device_register(od->object, NULL);
break;
}
@ -550,7 +552,7 @@ static void device_add_object(struct pw_impl_device *device, uint32_t id,
}
if ((res = spa_handle_get_interface(handle, info->type, &iface)) < 0) {
pw_log_error(NAME" %p: can't get NODE interface: %s", device,
pw_log_error(NAME" %p: can't get %s interface: %s", device, info->type,
spa_strerror(res));
return;
}
@ -559,38 +561,31 @@ static void device_add_object(struct pw_impl_device *device, uint32_t id,
if (info->props && props)
pw_properties_update(props, info->props);
switch (info->type) {
case SPA_TYPE_INTERFACE_Node:
{
if (strcmp(info->type, SPA_TYPE_INTERFACE_Node) == 0) {
struct pw_impl_node *node;
node = pw_context_create_node(context, props, sizeof(struct object_data));
od = pw_impl_node_get_user_data(node);
od->object = node;
od->type = OBJECT_NODE;
pw_impl_node_add_listener(node, &od->listener, &node_object_events, od);
pw_impl_node_set_implementation(node, iface);
break;
}
case SPA_TYPE_INTERFACE_Device:
{
} else if (strcmp(info->type, SPA_TYPE_INTERFACE_Device) == 0) {
struct pw_impl_device *dev;
dev = pw_context_create_device(context, props, sizeof(struct object_data));
od = pw_impl_device_get_user_data(dev);
od->object = dev;
od->type = OBJECT_DEVICE;
pw_impl_device_add_listener(dev, &od->listener, &device_object_events, od);
pw_impl_device_set_implementation(dev, iface);
break;
}
default:
pw_log_warn(NAME" %p: unknown type %d", device, info->type);
} else {
pw_log_warn(NAME" %p: unknown type %s", device, info->type);
pw_properties_free(props);
break;
}
if (od) {
od->id = id;
od->type = info->type;
od->handle = handle;
spa_list_append(&device->object_list, &od->link);
if (device->global)

View file

@ -40,7 +40,7 @@ struct resource_data {
SPA_EXPORT
struct pw_impl_factory *pw_context_create_factory(struct pw_context *context,
const char *name,
uint32_t type,
const char *type,
uint32_t version,
struct pw_properties *properties,
size_t user_data_size)
@ -211,8 +211,7 @@ int pw_impl_factory_register(struct pw_impl_factory *factory,
pw_properties_update_keys(properties, &factory->properties->dict, keys);
pw_properties_set(properties, PW_KEY_FACTORY_NAME, factory->info.name);
pw_properties_setf(properties, PW_KEY_FACTORY_TYPE_NAME, "%s",
spa_debug_type_find_name(pw_type_info(), factory->info.type));
pw_properties_setf(properties, PW_KEY_FACTORY_TYPE_NAME, "%s", factory->info.type);
pw_properties_setf(properties, PW_KEY_FACTORY_TYPE_VERSION, "%d", factory->info.version);
factory->global = pw_global_new(context,
@ -276,7 +275,7 @@ void pw_impl_factory_set_implementation(struct pw_impl_factory *factory,
SPA_EXPORT
void *pw_impl_factory_create_object(struct pw_impl_factory *factory,
struct pw_resource *resource,
uint32_t type,
const char *type,
uint32_t version,
struct pw_properties *properties,
uint32_t new_id)

View file

@ -63,7 +63,7 @@ struct pw_impl_factory_implementation {
/** The function to create an object from this factory */
void *(*create_object) (void *data,
struct pw_resource *resource,
uint32_t type,
const char *type,
uint32_t version,
struct pw_properties *properties,
uint32_t new_id);
@ -71,7 +71,7 @@ struct pw_impl_factory_implementation {
struct pw_impl_factory *pw_context_create_factory(struct pw_context *context,
const char *name,
uint32_t type,
const char *type,
uint32_t version,
struct pw_properties *properties,
size_t user_data_size);
@ -104,7 +104,7 @@ void pw_impl_factory_set_implementation(struct pw_impl_factory *factory,
void *pw_impl_factory_create_object(struct pw_impl_factory *factory,
struct pw_resource *resource,
uint32_t type,
const char *type,
uint32_t version,
struct pw_properties *properties,
uint32_t new_id);

View file

@ -285,7 +285,7 @@ struct pw_factory_info *pw_factory_info_update(struct pw_factory_info *info,
info->id = update->id;
info->name = update->name ? strdup(update->name) : NULL;
info->type = update->type;
info->type = update->type ? strdup(update->type) : NULL;
info->version = update->version;
}
info->change_mask = update->change_mask;
@ -302,6 +302,7 @@ SPA_EXPORT
void pw_factory_info_free(struct pw_factory_info *info)
{
free((void *) info->name);
free((void *) info->type);
if (info->props)
pw_spa_dict_destroy(info->props);
free(info);

View file

@ -34,6 +34,8 @@ extern "C" {
#include <pipewire/proxy.h>
#define PW_TYPE_INTERFACE_Link PW_TYPE_INFO_INTERFACE_BASE "Link"
#define PW_VERSION_LINK 3
struct pw_link;

View file

@ -34,6 +34,8 @@ extern "C" {
#include <pipewire/proxy.h>
#define PW_TYPE_INTERFACE_Module PW_TYPE_INFO_INTERFACE_BASE "Module"
#define PW_VERSION_MODULE 3
struct pw_module;

View file

@ -39,6 +39,8 @@ extern "C" {
#include <pipewire/proxy.h>
#define PW_TYPE_INTERFACE_Node PW_TYPE_INFO_INTERFACE_BASE "Node"
#define PW_VERSION_NODE 3
struct pw_node;

View file

@ -314,7 +314,7 @@ int pw_unload_spa_handle(struct spa_handle *handle)
static void *add_interface(struct support *support,
const char *factory_name,
uint32_t type,
const char *type,
const struct spa_dict *info)
{
struct spa_handle *handle;
@ -327,7 +327,7 @@ static void *add_interface(struct support *support,
if (handle == NULL ||
(res = spa_handle_get_interface(handle, type, &iface)) < 0) {
pw_log_error("can't get %d interface %d", type, res);
pw_log_error("can't get %s interface %d", type, res);
} else {
support->support[support->n_support++] =
SPA_SUPPORT_INIT(type, iface);
@ -515,28 +515,6 @@ const char* pw_get_library_version(void)
}
static const struct spa_type_info type_info[] = {
{ PW_TYPE_INTERFACE_Core, SPA_TYPE_Pointer, PW_TYPE_INFO_INTERFACE_BASE "Core", NULL },
{ PW_TYPE_INTERFACE_Registry, SPA_TYPE_Pointer, PW_TYPE_INFO_INTERFACE_BASE "Registry", NULL },
{ PW_TYPE_INTERFACE_Node, SPA_TYPE_Pointer, PW_TYPE_INFO_INTERFACE_BASE "Node", NULL },
{ PW_TYPE_INTERFACE_Port, SPA_TYPE_Pointer, PW_TYPE_INFO_INTERFACE_BASE "Port", NULL },
{ PW_TYPE_INTERFACE_Factory, SPA_TYPE_Pointer, PW_TYPE_INFO_INTERFACE_BASE "Factory", NULL },
{ PW_TYPE_INTERFACE_Link, SPA_TYPE_Pointer, PW_TYPE_INFO_INTERFACE_BASE "Link", NULL },
{ PW_TYPE_INTERFACE_Client, SPA_TYPE_Pointer, PW_TYPE_INFO_INTERFACE_BASE "Client", NULL },
{ PW_TYPE_INTERFACE_Module, SPA_TYPE_Pointer, PW_TYPE_INFO_INTERFACE_BASE "Module", NULL },
{ PW_TYPE_INTERFACE_Device, SPA_TYPE_Pointer, PW_TYPE_INFO_INTERFACE_BASE "Device", NULL },
/* extensions */
{ PW_TYPE_INTERFACE_Metadata, SPA_TYPE_Pointer, PW_TYPE_INFO_INTERFACE_BASE "Metadata", NULL },
{ PW_TYPE_INTERFACE_Session, SPA_TYPE_Pointer, PW_TYPE_INFO_INTERFACE_BASE "Session", NULL},
{ PW_TYPE_INTERFACE_Endpoint, SPA_TYPE_Pointer, PW_TYPE_INFO_INTERFACE_BASE "Endpoint", NULL},
{ PW_TYPE_INTERFACE_EndpointStream, SPA_TYPE_Pointer, PW_TYPE_INFO_INTERFACE_BASE "EndpointStream", NULL},
{ PW_TYPE_INTERFACE_EndpointLink, SPA_TYPE_Pointer, PW_TYPE_INFO_INTERFACE_BASE "EndpointLink", NULL},
/* implementations */
{ PW_TYPE_INTERFACE_ClientNode, SPA_TYPE_Pointer, PW_TYPE_INFO_INTERFACE_BASE "ClientNode", NULL },
{ PW_TYPE_INTERFACE_ClientSession, SPA_TYPE_Pointer, PW_TYPE_INFO_INTERFACE_BASE "ClientSession", NULL},
{ PW_TYPE_INTERFACE_ClientEndpoint, SPA_TYPE_Pointer, PW_TYPE_INFO_INTERFACE_BASE "ClientEndpoint", NULL},
{ SPA_ID_INVALID, SPA_ID_INVALID, "spa_types", spa_types },
{ 0, 0, NULL, NULL },
};

View file

@ -38,6 +38,8 @@ extern "C" {
#include <pipewire/proxy.h>
#define PW_TYPE_INTERFACE_Port PW_TYPE_INFO_INTERFACE_BASE "Port"
#define PW_VERSION_PORT 3
struct pw_port;

View file

@ -171,7 +171,7 @@ struct pw_global {
struct spa_hook_list listener_list;
uint32_t type; /**< type of interface */
const char *type; /**< type of interface */
uint32_t version; /**< version of interface */
pw_global_bind_func_t func; /**< bind function */
@ -707,7 +707,7 @@ struct pw_resource {
uint32_t id; /**< per client unique id, index in client objects */
uint32_t permissions; /**< resource permissions */
uint32_t type; /**< type of the client interface */
const char *type; /**< type of the client interface */
uint32_t version; /**< version of the client interface */
uint32_t bound_id; /**< global id we are bound to */
@ -733,7 +733,7 @@ struct pw_proxy {
struct pw_core *core; /**< the owner core of this proxy */
uint32_t id; /**< client side id */
uint32_t type; /**< type of the interface */
const char *type; /**< type of the interface */
uint32_t version; /**< client side version */
uint32_t bound_id; /**< global id we are bound to */
int refcount;
@ -916,9 +916,9 @@ pw_context_find_port(struct pw_context *context,
struct spa_pod **format_filters,
char **error);
const struct pw_export_type *pw_context_find_export_type(struct pw_context *context, uint32_t type);
const struct pw_export_type *pw_context_find_export_type(struct pw_context *context, const char *type);
int pw_proxy_init(struct pw_proxy *proxy, uint32_t type, uint32_t version);
int pw_proxy_init(struct pw_proxy *proxy, const char *type, uint32_t version);
int pw_proxy_install_marshal(struct pw_proxy *proxy, bool implementor);
void pw_proxy_remove(struct pw_proxy *proxy);

View file

@ -149,28 +149,26 @@ pw_protocol_add_marshal(struct pw_protocol *protocol,
spa_list_append(&protocol->marshal_list, &impl->link);
pw_log_debug(NAME" %p: Add marshal %d/%s:%d to protocol %s", protocol,
marshal->type, spa_debug_type_find_name(pw_type_info(), marshal->type),
marshal->version, protocol->name);
pw_log_debug(NAME" %p: Add marshal %s/%d to protocol %s", protocol,
marshal->type, marshal->version, protocol->name);
return 0;
}
SPA_EXPORT
const struct pw_protocol_marshal *
pw_protocol_get_marshal(struct pw_protocol *protocol, uint32_t type, uint32_t version, uint32_t flags)
pw_protocol_get_marshal(struct pw_protocol *protocol, const char *type, uint32_t version, uint32_t flags)
{
struct marshal *impl;
spa_list_for_each(impl, &protocol->marshal_list, link) {
if (impl->marshal->type == type &&
if (strcmp(impl->marshal->type, type) == 0 &&
impl->marshal->version == version &&
(impl->marshal->flags & flags) == flags)
return impl->marshal;
}
pw_log_debug(NAME" %p: No marshal %d/%s:%d for protocol %s", protocol,
type, spa_debug_type_find_name(pw_type_info(), type),
version, protocol->name);
pw_log_debug(NAME" %p: No marshal %s/%d for protocol %s", protocol,
type, version, protocol->name);
return NULL;
}

View file

@ -76,7 +76,7 @@ struct pw_protocol_server {
#define pw_protocol_server_destroy(l) ((l)->destroy(l))
struct pw_protocol_marshal {
uint32_t type; /**< interface type */
const char *type; /**< interface type */
uint32_t version; /**< version */
#define PW_PROTOCOL_MARSHAL_FLAG_IMPL (1 << 0) /**< marshal for implementations */
uint32_t flags; /**< version */
@ -139,7 +139,7 @@ int pw_protocol_add_marshal(struct pw_protocol *protocol,
const struct pw_protocol_marshal *marshal);
const struct pw_protocol_marshal *
pw_protocol_get_marshal(struct pw_protocol *protocol, uint32_t type, uint32_t version, uint32_t flags);
pw_protocol_get_marshal(struct pw_protocol *protocol, const char *type, uint32_t version, uint32_t flags);
struct pw_protocol * pw_context_find_protocol(struct pw_context *context, const char *name);

View file

@ -40,7 +40,7 @@ struct proxy {
};
/** \endcond */
int pw_proxy_init(struct pw_proxy *proxy, uint32_t type, uint32_t version)
int pw_proxy_init(struct pw_proxy *proxy, const char *type, uint32_t version)
{
int res;
@ -61,8 +61,7 @@ int pw_proxy_init(struct pw_proxy *proxy, uint32_t type, uint32_t version)
if ((res = pw_proxy_install_marshal(proxy, false)) < 0) {
pw_log_error(NAME" %p: no marshal for type %s/%d", proxy,
spa_debug_type_find_name(pw_type_info(), type),
version);
type, version);
goto error_clean;
}
return 0;
@ -89,7 +88,7 @@ error:
*/
SPA_EXPORT
struct pw_proxy *pw_proxy_new(struct pw_proxy *factory,
uint32_t type, uint32_t version,
const char *type, uint32_t version,
size_t user_data_size)
{
struct proxy *impl;
@ -110,9 +109,7 @@ struct pw_proxy *pw_proxy_new(struct pw_proxy *factory,
this->user_data = SPA_MEMBER(impl, sizeof(struct proxy), void);
pw_log_debug(NAME" %p: new %u type %s/%d core-proxy:%p, marshal:%p",
this, this->id,
spa_debug_type_find_name(pw_type_info(), type), version,
this->core, this->marshal);
this, this->id, type, version, this->core, this->marshal);
return this;
error_init:
@ -127,6 +124,9 @@ int pw_proxy_install_marshal(struct pw_proxy *this, bool implementor)
struct pw_core *core = this->core;
const struct pw_protocol_marshal *marshal;
if (core == NULL)
return -EIO;
marshal = pw_protocol_get_marshal(core->conn->protocol,
this->type, this->version,
implementor ? PW_PROTOCOL_MARSHAL_FLAG_IMPL : 0);
@ -134,6 +134,8 @@ int pw_proxy_install_marshal(struct pw_proxy *this, bool implementor)
return -EPROTO;
this->marshal = marshal;
this->type = marshal->type;
this->impl = SPA_INTERFACE_INIT(
this->type,
this->marshal->version,
@ -168,7 +170,7 @@ uint32_t pw_proxy_get_bound_id(struct pw_proxy *proxy)
}
SPA_EXPORT
uint32_t pw_proxy_get_type(struct pw_proxy *proxy, uint32_t *version)
const char *pw_proxy_get_type(struct pw_proxy *proxy, uint32_t *version)
{
if (version)
*version = proxy->version;
@ -184,6 +186,8 @@ struct pw_core *pw_proxy_get_core(struct pw_proxy *proxy)
SPA_EXPORT
struct pw_protocol *pw_proxy_get_protocol(struct pw_proxy *proxy)
{
if (proxy->core == NULL || proxy->core->conn == NULL)
return NULL;
return proxy->core->conn->protocol;
}

View file

@ -124,7 +124,7 @@ struct pw_proxy_events {
* can be retrieved with \ref pw_proxy_get_id . */
struct pw_proxy *
pw_proxy_new(struct pw_proxy *factory, /**< factory */
uint32_t type, /**< interface type */
const char *type, /**< interface type */
uint32_t version, /**< interface version */
size_t user_data_size /**< size of user data */);
@ -151,7 +151,7 @@ void *pw_proxy_get_user_data(struct pw_proxy *proxy);
uint32_t pw_proxy_get_id(struct pw_proxy *proxy);
/** Get the type and version of the proxy */
uint32_t pw_proxy_get_type(struct pw_proxy *proxy, uint32_t *version);
const char *pw_proxy_get_type(struct pw_proxy *proxy, uint32_t *version);
/** Get the protocol used for the proxy */
struct pw_protocol *pw_proxy_get_protocol(struct pw_proxy *proxy);

View file

@ -43,7 +43,7 @@ SPA_EXPORT
struct pw_resource *pw_resource_new(struct pw_impl_client *client,
uint32_t id,
uint32_t permissions,
uint32_t type,
const char *type,
uint32_t version,
size_t user_data_size)
{
@ -81,8 +81,7 @@ struct pw_resource *pw_resource_new(struct pw_impl_client *client,
if ((res = pw_resource_install_marshal(this, false)) < 0) {
pw_log_error(NAME" %p: no marshal for type %s/%d", this,
spa_debug_type_find_name(pw_type_info(), type),
version);
type, version);
goto error_clean;
}
@ -91,9 +90,7 @@ struct pw_resource *pw_resource_new(struct pw_impl_client *client,
this->user_data = SPA_MEMBER(impl, sizeof(struct impl), void);
pw_log_debug(NAME" %p: new %u type %s/%d client:%p marshal:%p",
this, id,
spa_debug_type_find_name(pw_type_info(), type), version,
client, this->marshal);
this, id, type, version, client, this->marshal);
pw_impl_client_emit_resource_added(client, this);
@ -118,6 +115,8 @@ int pw_resource_install_marshal(struct pw_resource *this, bool implementor)
return -EPROTO;
this->marshal = marshal;
this->type = marshal->type;
this->impl = SPA_INTERFACE_INIT(
this->type,
this->marshal->version,
@ -144,7 +143,7 @@ uint32_t pw_resource_get_permissions(struct pw_resource *resource)
}
SPA_EXPORT
uint32_t pw_resource_get_type(struct pw_resource *resource, uint32_t *version)
const char *pw_resource_get_type(struct pw_resource *resource, uint32_t *version)
{
if (version)
*version = resource->version;

View file

@ -80,7 +80,7 @@ struct pw_resource *
pw_resource_new(struct pw_impl_client *client, /**< the client owning the resource */
uint32_t id, /**< the remote per client id */
uint32_t permissions, /**< permissions on this resource */
uint32_t type, /**< interface of the resource */
const char *type, /**< interface of the resource */
uint32_t version, /**< requested interface version */
size_t user_data_size /**< extra user data size */);
@ -97,7 +97,7 @@ uint32_t pw_resource_get_id(struct pw_resource *resource);
uint32_t pw_resource_get_permissions(struct pw_resource *resource);
/** Get the type and optionally the version of this resource */
uint32_t pw_resource_get_type(struct pw_resource *resource, uint32_t *version);
const char *pw_resource_get_type(struct pw_resource *resource, uint32_t *version);
/** Get the protocol used for this resource */
struct pw_protocol *pw_resource_get_protocol(struct pw_resource *resource);

View file

@ -33,31 +33,6 @@ extern "C" {
enum {
PW_TYPE_FIRST = SPA_TYPE_VENDOR_PipeWire,
PW_TYPE_INTERFACE_START = PW_TYPE_FIRST + SPA_TYPE_INTERFACE_START,
PW_TYPE_INTERFACE_Core,
PW_TYPE_INTERFACE_Registry,
PW_TYPE_INTERFACE_Node,
PW_TYPE_INTERFACE_Port,
PW_TYPE_INTERFACE_Factory,
PW_TYPE_INTERFACE_Link,
PW_TYPE_INTERFACE_Client,
PW_TYPE_INTERFACE_Module,
PW_TYPE_INTERFACE_Device,
/* extensions */
PW_TYPE_INTERFACE_EXTENSIONS = PW_TYPE_INTERFACE_START + 0x1000,
PW_TYPE_INTERFACE_Metadata,
PW_TYPE_INTERFACE_Session,
PW_TYPE_INTERFACE_Endpoint,
PW_TYPE_INTERFACE_EndpointStream,
PW_TYPE_INTERFACE_EndpointLink,
/* implementations */
PW_TYPE_INTERFACE_IMPLEMENTATIONS = PW_TYPE_INTERFACE_START + 0x2000,
PW_TYPE_INTERFACE_ClientNode,
PW_TYPE_INTERFACE_ClientSession,
PW_TYPE_INTERFACE_ClientEndpoint,
};
#define PW_TYPE_INFO_BASE "PipeWire:"

View file

@ -22,6 +22,9 @@
* DEALINGS IN THE SOFTWARE.
*/
#include <spa/support/dbus.h>
#include <spa/support/cpu.h>
#include <pipewire/pipewire.h>
#include <pipewire/global.h>
@ -206,7 +209,7 @@ static void test_support(void)
struct pw_context *context;
const struct spa_support *support;
uint32_t n_support;
uint32_t types[] = {
const char * types[] = {
SPA_TYPE_INTERFACE_DataSystem,
SPA_TYPE_INTERFACE_DataLoop,
SPA_TYPE_INTERFACE_System,

View file

@ -48,7 +48,7 @@ static void test_core_abi(void)
uint32_t version, size_t user_data_size);
void * (*create_object) (void *object,
const char *factory_name,
uint32_t type,
const char *type,
uint32_t version,
const struct spa_dict *props,
size_t user_data_size);
@ -101,14 +101,14 @@ static void test_registry_abi(void)
struct spa_hook *listener,
const struct pw_registry_events *events,
void *data);
void * (*bind) (void *object, uint32_t id, uint32_t type, uint32_t version,
void * (*bind) (void *object, uint32_t id, const char *type, uint32_t version,
size_t user_data_size);
int (*destroy) (void *object, uint32_t id);
} methods = { PW_VERSION_REGISTRY_METHODS, };
struct {
uint32_t version;
void (*global) (void *object, uint32_t id,
uint32_t permissions, uint32_t type, uint32_t version,
uint32_t permissions, const char *type, uint32_t version,
const struct spa_dict *props);
void (*global_remove) (void *object, uint32_t id);
} events = { PW_VERSION_REGISTRY_EVENTS, };

View file

@ -54,8 +54,8 @@ struct global {
struct remote_data *rd;
uint32_t id;
uint32_t permissions;
uint32_t type;
uint32_t version;
char *type;
struct pw_proxy *proxy;
bool info_pending;
struct pw_properties *properties;
@ -287,18 +287,15 @@ static int print_global(void *obj, void *data)
{
struct global *global = obj;
const char *filter = data;
const char *type_name = NULL;
if (global == NULL)
return 0;
type_name = spa_debug_type_find_name(pw_type_info(), global->type);
if (filter && !strstr(type_name, filter))
if (filter && !strstr(global->type, filter))
return 0;
fprintf(stdout, "\tid %d, type %s/%d\n", global->id,
type_name,
global->version);
global->type, global->version);
if (global->properties)
print_properties(&global->properties->dict, ' ', false);
@ -306,7 +303,7 @@ static int print_global(void *obj, void *data)
}
static void registry_event_global(void *data, uint32_t id,
uint32_t permissions, uint32_t type, uint32_t version,
uint32_t permissions, const char *type, uint32_t version,
const struct spa_dict *props)
{
struct remote_data *rd = data;
@ -317,7 +314,7 @@ static void registry_event_global(void *data, uint32_t id,
global->rd = rd;
global->id = id;
global->permissions = permissions;
global->type = type;
global->type = strdup(type);
global->version = version;
global->properties = props ? pw_properties_new_dict(props) : NULL;
@ -340,6 +337,7 @@ static int destroy_global(void *obj, void *data)
pw_map_remove(&global->rd->globals, global->id);
if (global->properties)
pw_properties_free(global->properties);
free(global->type);
free(global);
return 0;
}
@ -528,9 +526,7 @@ static void info_global(struct proxy_data *pd)
fprintf(stdout, "\tpermissions: %c%c%c\n", global->permissions & PW_PERM_R ? 'r' : '-',
global->permissions & PW_PERM_W ? 'w' : '-',
global->permissions & PW_PERM_X ? 'x' : '-');
fprintf(stdout, "\ttype: %s/%d\n",
spa_debug_type_find_name(pw_type_info(), global->type),
pd->global->version);
fprintf(stdout, "\ttype: %s/%d\n", global->type, global->version);
}
static void info_core(struct proxy_data *pd)
@ -596,8 +592,7 @@ static void info_factory(struct proxy_data *pd)
info_global(pd);
fprintf(stdout, "\tname: \"%s\"\n", info->name);
fprintf(stdout, "\tobject-type: %s/%d\n",
spa_debug_type_find_name(pw_type_info(), info->type), info->version);
fprintf(stdout, "\tobject-type: %s/%d\n", info->type, info->version);
print_properties(info->props, MARK_CHANGE(PW_FACTORY_CHANGE_MASK_PROPS), true);
info->change_mask = 0;
}
@ -1089,75 +1084,63 @@ static bool bind_global(struct remote_data *rd, struct global *global, char **er
struct proxy_data *pd;
struct pw_proxy *proxy;
switch (global->type) {
case PW_TYPE_INTERFACE_Core:
if (strcmp(global->type, PW_TYPE_INTERFACE_Core) == 0) {
events = &core_events;
client_version = PW_VERSION_CORE;
destroy = (pw_destroy_t) pw_core_info_free;
info_func = info_core;
break;
case PW_TYPE_INTERFACE_Module:
} else if (strcmp(global->type, PW_TYPE_INTERFACE_Module) == 0) {
events = &module_events;
client_version = PW_VERSION_MODULE;
destroy = (pw_destroy_t) pw_module_info_free;
info_func = info_module;
break;
case PW_TYPE_INTERFACE_Device:
} else if (strcmp(global->type, PW_TYPE_INTERFACE_Device) == 0) {
events = &device_events;
client_version = PW_VERSION_DEVICE;
destroy = (pw_destroy_t) pw_device_info_free;
info_func = info_device;
break;
case PW_TYPE_INTERFACE_Node:
} else if (strcmp(global->type, PW_TYPE_INTERFACE_Node) == 0) {
events = &node_events;
client_version = PW_VERSION_NODE;
destroy = (pw_destroy_t) pw_node_info_free;
info_func = info_node;
break;
case PW_TYPE_INTERFACE_Port:
} else if (strcmp(global->type, PW_TYPE_INTERFACE_Port) == 0) {
events = &port_events;
client_version = PW_VERSION_PORT;
destroy = (pw_destroy_t) pw_port_info_free;
info_func = info_port;
break;
case PW_TYPE_INTERFACE_Factory:
} else if (strcmp(global->type, PW_TYPE_INTERFACE_Factory) == 0) {
events = &factory_events;
client_version = PW_VERSION_FACTORY;
destroy = (pw_destroy_t) pw_factory_info_free;
info_func = info_factory;
break;
case PW_TYPE_INTERFACE_Client:
} else if (strcmp(global->type, PW_TYPE_INTERFACE_Client) == 0) {
events = &client_events;
client_version = PW_VERSION_CLIENT;
destroy = (pw_destroy_t) pw_client_info_free;
info_func = info_client;
break;
case PW_TYPE_INTERFACE_Link:
} else if (strcmp(global->type, PW_TYPE_INTERFACE_Link) == 0) {
events = &link_events;
client_version = PW_VERSION_LINK;
destroy = (pw_destroy_t) pw_link_info_free;
info_func = info_link;
break;
case PW_TYPE_INTERFACE_Session:
} else if (strcmp(global->type, PW_TYPE_INTERFACE_Session) == 0) {
events = &session_events;
client_version = PW_VERSION_SESSION;
destroy = (pw_destroy_t) session_info_free;
info_func = info_session;
break;
case PW_TYPE_INTERFACE_Endpoint:
} else if (strcmp(global->type, PW_TYPE_INTERFACE_Endpoint) == 0) {
events = &endpoint_events;
client_version = PW_VERSION_ENDPOINT;
destroy = (pw_destroy_t) endpoint_info_free;
info_func = info_endpoint;
break;
case PW_TYPE_INTERFACE_EndpointStream:
} else if (strcmp(global->type, PW_TYPE_INTERFACE_EndpointStream) == 0) {
events = &endpoint_stream_events;
client_version = PW_VERSION_ENDPOINT_STREAM;
destroy = (pw_destroy_t) endpoint_stream_info_free;
info_func = info_endpoint_stream;
break;
default:
asprintf(error, "unsupported type %s", spa_debug_type_find_name(pw_type_info(), global->type));
} else {
asprintf(error, "unsupported type %s", global->type);
return false;
}
@ -1410,7 +1393,7 @@ static bool do_export_node(struct data *data, const char *cmd, char *args, char
asprintf(error, "object %d does not exist", atoi(a[0]));
return false;
}
if (pw_global_get_type(global) != PW_TYPE_INTERFACE_Node) {
if (!pw_global_is_type(global, PW_TYPE_INTERFACE_Node)) {
asprintf(error, "object %d is not a node", atoi(a[0]));
return false;
}
@ -1454,25 +1437,21 @@ static bool do_enum_params(struct data *data, const char *cmd, char *args, char
return false;
}
switch (global->type) {
case PW_TYPE_INTERFACE_Node:
if (strcmp(global->type, PW_TYPE_INTERFACE_Node) == 0)
pw_node_enum_params((struct pw_node*)global->proxy, 0,
param_id, 0, 0, NULL);
break;
case PW_TYPE_INTERFACE_Port:
else if (strcmp(global->type, PW_TYPE_INTERFACE_Port) == 0)
pw_port_enum_params((struct pw_port*)global->proxy, 0,
param_id, 0, 0, NULL);
break;
case PW_TYPE_INTERFACE_Device:
else if (strcmp(global->type, PW_TYPE_INTERFACE_Device) == 0)
pw_device_enum_params((struct pw_device*)global->proxy, 0,
param_id, 0, 0, NULL);
break;
case PW_TYPE_INTERFACE_Endpoint:
else if (strcmp(global->type, PW_TYPE_INTERFACE_Endpoint) == 0)
pw_endpoint_enum_params((struct pw_endpoint*)global->proxy, 0,
param_id, 0, 0, NULL);
break;
default:
asprintf(error, "enum-params not implemented on object %d", atoi(a[0]));
else {
asprintf(error, "enum-params not implemented on object %d type:%s",
atoi(a[0]), global->type);
return false;
}
return true;
@ -1499,7 +1478,7 @@ static bool do_permissions(struct data *data, const char *cmd, char *args, char
asprintf(error, "%s: unknown global %d", cmd, id);
return false;
}
if (global->type != PW_TYPE_INTERFACE_Client) {
if (strcmp(global->type, PW_TYPE_INTERFACE_Client) != 0) {
asprintf(error, "object %d is not a client", atoi(a[0]));
return false;
}
@ -1537,7 +1516,7 @@ static bool do_get_permissions(struct data *data, const char *cmd, char *args, c
asprintf(error, "%s: unknown global %d", cmd, id);
return false;
}
if (global->type != PW_TYPE_INTERFACE_Client) {
if (strcmp(global->type, PW_TYPE_INTERFACE_Client) != 0) {
asprintf(error, "object %d is not a client", atoi(a[0]));
return false;
}

View file

@ -66,6 +66,13 @@ struct global {
struct pw_proxy *proxy;
uint32_t id;
#define INTERFACE_Port 0
#define INTERFACE_Node 1
#define INTERFACE_Link 2
#define INTERFACE_Client 3
#define INTERFACE_Device 4
#define INTERFACE_Module 5
#define INTERFACE_Factory 6
uint32_t type;
struct pw_properties *props;
void *info;
@ -175,7 +182,7 @@ static void draw_port(struct global *g)
{
spa_assert(g != NULL);
spa_assert(g->info != NULL);
spa_assert(g->type == PW_TYPE_INTERFACE_Port);
spa_assert(g->type == INTERFACE_Port);
struct pw_port_info *info = g->info;
char **dot_str = &g->data->dot_str;
@ -202,7 +209,7 @@ static void draw_node(struct global *g)
{
spa_assert(g != NULL);
spa_assert(g->info != NULL);
spa_assert(g->type == PW_TYPE_INTERFACE_Node);
spa_assert(g->type == INTERFACE_Node);
struct pw_node_info *info = g->info;
char **dot_str = &g->data->dot_str;
@ -242,7 +249,7 @@ static void draw_node(struct global *g)
spa_list_for_each(p, &g->data->globals, link) {
if (p == NULL || p->info == NULL)
continue;
if (p->type != PW_TYPE_INTERFACE_Port)
if (p->type != INTERFACE_Port)
continue;
prop_node_id = pw_properties_get(p->props, PW_KEY_NODE_ID);
if (!prop_node_id || (uint32_t)atoi(prop_node_id) != g->id)
@ -271,7 +278,7 @@ static void draw_link(struct global *g)
{
spa_assert(g != NULL);
spa_assert(g->info != NULL);
spa_assert(g->type == PW_TYPE_INTERFACE_Link);
spa_assert(g->type == INTERFACE_Link);
struct pw_link_info *info = g->info;
char **dot_str = &g->data->dot_str;
@ -299,7 +306,7 @@ static void draw_client(struct global *g)
{
spa_assert(g != NULL);
spa_assert(g->info != NULL);
spa_assert(g->type == PW_TYPE_INTERFACE_Client);
spa_assert(g->type == INTERFACE_Client);
struct pw_client_info *info = g->info;
char **dot_str = &g->data->dot_str;
@ -321,7 +328,7 @@ static void draw_device(struct global *g)
{
spa_assert(g != NULL);
spa_assert(g->info != NULL);
spa_assert(g->type == PW_TYPE_INTERFACE_Device);
spa_assert(g->type == INTERFACE_Device);
struct pw_device_info *info = g->info;
char **dot_str = &g->data->dot_str;
@ -354,7 +361,7 @@ static void draw_factory(struct global *g)
{
spa_assert(g != NULL);
spa_assert(g->info != NULL);
spa_assert(g->type == PW_TYPE_INTERFACE_Factory);
spa_assert(g->type == INTERFACE_Factory);
struct pw_factory_info *info = g->info;
char **dot_str = &g->data->dot_str;
@ -380,7 +387,7 @@ static void draw_module(struct global *g)
{
spa_assert(g != NULL);
spa_assert(g->info != NULL);
spa_assert(g->type == PW_TYPE_INTERFACE_Module);
spa_assert(g->type == INTERFACE_Module);
struct pw_module_info *info = g->info;
char **dot_str = &g->data->dot_str;
@ -403,7 +410,7 @@ static bool is_node_id_link_referenced(uint32_t id, struct spa_list *globals)
spa_list_for_each(g, globals, link) {
if (g == NULL || g->info == NULL)
continue;
if (g->type != PW_TYPE_INTERFACE_Link)
if (g->type != INTERFACE_Link)
continue;
info = g->info;
if (info->input_node_id == id || info->output_node_id == id)
@ -420,7 +427,7 @@ static bool is_module_id_factory_referenced(uint32_t id, struct spa_list *global
spa_list_for_each(g, globals, link) {
if (g == NULL || g->info == NULL)
continue;
if (g->type != PW_TYPE_INTERFACE_Factory)
if (g->type != INTERFACE_Factory)
continue;
info = g->info;
module_id_str = spa_dict_lookup(info->props, PW_KEY_MODULE_ID);
@ -433,9 +440,9 @@ static bool is_module_id_factory_referenced(uint32_t id, struct spa_list *global
static bool is_global_referenced(struct global *g)
{
switch (g->type) {
case PW_TYPE_INTERFACE_Node:
case INTERFACE_Node:
return is_node_id_link_referenced(g->id, &g->data->globals);
case PW_TYPE_INTERFACE_Module:
case INTERFACE_Module:
return is_module_id_factory_referenced(g->id, &g->data->globals);
default:
break;
@ -459,16 +466,16 @@ static int draw_graph(struct data *d, const char *path)
continue;
/* always skip ports since they are drawn by the nodes */
if (g->type == PW_TYPE_INTERFACE_Port)
if (g->type == INTERFACE_Port)
continue;
/* skip clients, devices, factories and modules if all option is disabled */
if (!d->show_all) {
switch (g->type) {
case PW_TYPE_INTERFACE_Client:
case PW_TYPE_INTERFACE_Device:
case PW_TYPE_INTERFACE_Factory:
case PW_TYPE_INTERFACE_Module:
case INTERFACE_Client:
case INTERFACE_Device:
case INTERFACE_Factory:
case INTERFACE_Module:
continue;
default:
break;
@ -597,73 +604,81 @@ static const struct pw_proxy_events proxy_events = {
};
static void registry_event_global(void *data, uint32_t id, uint32_t permissions,
uint32_t type, uint32_t version,
const char *type, uint32_t version,
const struct spa_dict *props)
{
struct data *d = data;
struct pw_proxy *proxy;
uint32_t client_version;
uint32_t object_type;
const void *events;
pw_destroy_t info_destroy;
info_update_t info_update;
draw_t draw;
struct global *g;
switch (type) {
case PW_TYPE_INTERFACE_Port:
if (strcmp(type, PW_TYPE_INTERFACE_Port) == 0) {
events = &port_events;
info_destroy = (pw_destroy_t)pw_port_info_free;
info_update = (info_update_t)pw_port_info_update;
draw = draw_port;
client_version = PW_VERSION_PORT;
break;
case PW_TYPE_INTERFACE_Node:
object_type = INTERFACE_Port;
}
else if (strcmp(type, PW_TYPE_INTERFACE_Node) == 0) {
events = &node_events;
info_destroy = (pw_destroy_t)pw_node_info_free;
info_update = (info_update_t)pw_node_info_update;
draw = draw_node;
client_version = PW_VERSION_NODE;
break;
case PW_TYPE_INTERFACE_Link:
object_type = INTERFACE_Node;
}
else if (strcmp(type, PW_TYPE_INTERFACE_Link) == 0) {
events = &link_events;
info_destroy = (pw_destroy_t)pw_link_info_free;
info_update = (info_update_t)pw_link_info_update;
draw = draw_link;
client_version = PW_VERSION_LINK;
break;
case PW_TYPE_INTERFACE_Client:
object_type = INTERFACE_Link;
}
else if (strcmp(type, PW_TYPE_INTERFACE_Client) == 0) {
events = &client_events;
info_destroy = (pw_destroy_t)pw_client_info_free;
info_update = (info_update_t)pw_client_info_update;
draw = draw_client;
client_version = PW_VERSION_CLIENT;
break;
case PW_TYPE_INTERFACE_Device:
object_type = INTERFACE_Client;
}
else if (strcmp(type, PW_TYPE_INTERFACE_Device) == 0) {
events = &device_events;
info_destroy = (pw_destroy_t)pw_device_info_free;
info_update = (info_update_t)pw_device_info_update;
draw = draw_device;
client_version = PW_VERSION_DEVICE;
break;
case PW_TYPE_INTERFACE_Factory:
object_type = INTERFACE_Device;
}
else if (strcmp(type, PW_TYPE_INTERFACE_Factory) == 0) {
events = &factory_events;
info_destroy = (pw_destroy_t)pw_factory_info_free;
info_update = (info_update_t)pw_factory_info_update;
draw = draw_factory;
client_version = PW_VERSION_FACTORY;
break;
case PW_TYPE_INTERFACE_Module:
object_type = INTERFACE_Factory;
}
else if (strcmp(type, PW_TYPE_INTERFACE_Module) == 0) {
events = &module_events;
info_destroy = (pw_destroy_t)pw_module_info_free;
info_update = (info_update_t)pw_module_info_update;
draw = draw_module;
client_version = PW_VERSION_MODULE;
break;
case PW_TYPE_INTERFACE_Core:
object_type = INTERFACE_Module;
}
else if (strcmp(type, PW_TYPE_INTERFACE_Core) == 0) {
/* sync to notify we are done with globals */
pw_core_sync(d->core, 0, 0);
return;
default:
}
else {
return;
}
@ -679,7 +694,7 @@ static void registry_event_global(void *data, uint32_t id, uint32_t permissions,
g->proxy = proxy;
g->id = id;
g->type = type;
g->type = object_type;
g->props = props ? pw_properties_new_dict(props) : NULL;
g->info = NULL;

View file

@ -63,7 +63,7 @@ struct proxy_data {
uint32_t id;
uint32_t permissions;
uint32_t version;
uint32_t type;
char *type;
void *info;
pw_destroy_t destroy;
struct spa_hook proxy_listener;
@ -187,7 +187,7 @@ static void on_core_info(void *data, const struct pw_core_info *info)
{
bool print_all = true, print_mark = true;
printf("\ttype: %s\n", spa_debug_type_find_name(pw_type_info(), PW_TYPE_INTERFACE_Core));
printf("\ttype: %s\n", PW_TYPE_INTERFACE_Core);
printf("\tcookie: %u\n", info->cookie);
printf("\tuser-name: \"%s\"\n", info->user_name);
printf("\thost-name: \"%s\"\n", info->host_name);
@ -219,8 +219,7 @@ static void module_event_info(void *object, const struct pw_module_info *info)
printf("\tpermissions: %c%c%c\n", data->permissions & PW_PERM_R ? 'r' : '-',
data->permissions & PW_PERM_W ? 'w' : '-',
data->permissions & PW_PERM_X ? 'x' : '-');
printf("\ttype: %s (version %d)\n",
spa_debug_type_find_name(pw_type_info(), data->type), data->version);
printf("\ttype: %s (version %d)\n", data->type, data->version);
printf("\tname: \"%s\"\n", info->name);
printf("\tfilename: \"%s\"\n", info->filename);
printf("\targs: \"%s\"\n", info->args);
@ -254,8 +253,7 @@ static void print_node(struct proxy_data *data)
printf("\tpermissions: %c%c%c\n", data->permissions & PW_PERM_R ? 'r' : '-',
data->permissions & PW_PERM_W ? 'w' : '-',
data->permissions & PW_PERM_X ? 'x' : '-');
printf("\ttype: %s (version %d)\n",
spa_debug_type_find_name(pw_type_info(), data->type), data->version);
printf("\ttype: %s (version %d)\n", data->type, data->version);
if (print_all) {
print_params(data, MARK_CHANGE(PW_NODE_CHANGE_MASK_PARAMS));
printf("%c\tinput ports: %u/%u\n", MARK_CHANGE(PW_NODE_CHANGE_MASK_INPUT_PORTS),
@ -322,8 +320,7 @@ static void print_port(struct proxy_data *data)
printf("\tpermissions: %c%c%c\n", data->permissions & PW_PERM_R ? 'r' : '-',
data->permissions & PW_PERM_W ? 'w' : '-',
data->permissions & PW_PERM_X ? 'x' : '-');
printf("\ttype: %s (version %d)\n",
spa_debug_type_find_name(pw_type_info(), data->type), data->version);
printf("\ttype: %s (version %d)\n", data->type, data->version);
printf("\tdirection: \"%s\"\n", pw_direction_as_string(info->direction));
if (print_all) {
@ -383,11 +380,10 @@ static void factory_event_info(void *object, const struct pw_factory_info *info)
printf("\tpermissions: %c%c%c\n", data->permissions & PW_PERM_R ? 'r' : '-',
data->permissions & PW_PERM_W ? 'w' : '-',
data->permissions & PW_PERM_X ? 'x' : '-');
printf("\ttype: %s (version %d)\n",
spa_debug_type_find_name(pw_type_info(), data->type), data->version);
printf("\ttype: %s (version %d)\n", data->type, data->version);
printf("\tname: \"%s\"\n", info->name);
printf("\tobject-type: %s/%d\n", spa_debug_type_find_name(pw_type_info(), info->type), info->version);
printf("\tobject-type: %s/%d\n", info->type, info->version);
if (print_all) {
print_properties(info->props, MARK_CHANGE(PW_FACTORY_CHANGE_MASK_PROPS));
}
@ -419,8 +415,7 @@ static void client_event_info(void *object, const struct pw_client_info *info)
printf("\tpermissions: %c%c%c\n", data->permissions & PW_PERM_R ? 'r' : '-',
data->permissions & PW_PERM_W ? 'w' : '-',
data->permissions & PW_PERM_X ? 'x' : '-');
printf("\ttype: %s (version %d)\n",
spa_debug_type_find_name(pw_type_info(), data->type), data->version);
printf("\ttype: %s (version %d)\n", data->type, data->version);
if (print_all) {
print_properties(info->props, MARK_CHANGE(PW_CLIENT_CHANGE_MASK_PROPS));
@ -453,8 +448,7 @@ static void link_event_info(void *object, const struct pw_link_info *info)
printf("\tpermissions: %c%c%c\n", data->permissions & PW_PERM_R ? 'r' : '-',
data->permissions & PW_PERM_W ? 'w' : '-',
data->permissions & PW_PERM_X ? 'x' : '-');
printf("\ttype: %s (version %d)\n",
spa_debug_type_find_name(pw_type_info(), data->type), data->version);
printf("\ttype: %s (version %d)\n", data->type, data->version);
printf("\toutput-node-id: %u\n", info->output_node_id);
printf("\toutput-port-id: %u\n", info->output_port_id);
@ -501,8 +495,7 @@ static void print_device(struct proxy_data *data)
printf("\tpermissions: %c%c%c\n", data->permissions & PW_PERM_R ? 'r' : '-',
data->permissions & PW_PERM_W ? 'w' : '-',
data->permissions & PW_PERM_X ? 'x' : '-');
printf("\ttype: %s (version %d)\n",
spa_debug_type_find_name(pw_type_info(), data->type), data->version);
printf("\ttype: %s (version %d)\n", data->type, data->version);
if (print_all) {
print_params(data, MARK_CHANGE(PW_DEVICE_CHANGE_MASK_PARAMS));
@ -556,6 +549,7 @@ destroy_proxy (void *data)
if (pd->destroy)
pd->destroy(pd->info);
pd->info = NULL;
free(pd->type);
}
static const struct pw_proxy_events proxy_events = {
@ -564,7 +558,7 @@ static const struct pw_proxy_events proxy_events = {
};
static void registry_event_global(void *data, uint32_t id,
uint32_t permissions, uint32_t type, uint32_t version,
uint32_t permissions, const char *type, uint32_t version,
const struct spa_dict *props)
{
struct data *d = data;
@ -575,52 +569,44 @@ static void registry_event_global(void *data, uint32_t id,
pw_destroy_t destroy;
print_func_t print_func = NULL;
switch (type) {
case PW_TYPE_INTERFACE_Node:
if (strcmp(type, PW_TYPE_INTERFACE_Node) == 0) {
events = &node_events;
client_version = PW_VERSION_NODE;
destroy = (pw_destroy_t) pw_node_info_free;
print_func = print_node;
break;
case PW_TYPE_INTERFACE_Port:
} else if (strcmp(type, PW_TYPE_INTERFACE_Port) == 0) {
events = &port_events;
client_version = PW_VERSION_PORT;
destroy = (pw_destroy_t) pw_port_info_free;
print_func = print_port;
break;
case PW_TYPE_INTERFACE_Module:
} else if (strcmp(type, PW_TYPE_INTERFACE_Module) == 0) {
events = &module_events;
client_version = PW_VERSION_MODULE;
destroy = (pw_destroy_t) pw_module_info_free;
break;
case PW_TYPE_INTERFACE_Device:
} else if (strcmp(type, PW_TYPE_INTERFACE_Device) == 0) {
events = &device_events;
client_version = PW_VERSION_DEVICE;
destroy = (pw_destroy_t) pw_device_info_free;
print_func = print_device;
break;
case PW_TYPE_INTERFACE_Factory:
} else if (strcmp(type, PW_TYPE_INTERFACE_Factory) == 0) {
events = &factory_events;
client_version = PW_VERSION_FACTORY;
destroy = (pw_destroy_t) pw_factory_info_free;
break;
case PW_TYPE_INTERFACE_Client:
} else if (strcmp(type, PW_TYPE_INTERFACE_Client) == 0) {
events = &client_events;
client_version = PW_VERSION_CLIENT;
destroy = (pw_destroy_t) pw_client_info_free;
break;
case PW_TYPE_INTERFACE_Link:
} else if (strcmp(type, PW_TYPE_INTERFACE_Link) == 0) {
events = &link_events;
client_version = PW_VERSION_LINK;
destroy = (pw_destroy_t) pw_link_info_free;
break;
default:
} else {
printf("added:\n");
printf("\tid: %u\n", id);
printf("\tpermissions: %c%c%c\n", permissions & PW_PERM_R ? 'r' : '-',
permissions & PW_PERM_W ? 'w' : '-',
permissions & PW_PERM_X ? 'x' : '-');
printf("\ttype: %s (version %d)\n", spa_debug_type_find_name(pw_type_info(), type), version);
printf("\ttype: %s (version %d)\n", type, version);
print_properties(props, ' ');
return;
}
@ -638,7 +624,7 @@ static void registry_event_global(void *data, uint32_t id,
pd->id = id;
pd->permissions = permissions;
pd->version = version;
pd->type = type;
pd->type = strdup(type);
pd->destroy = destroy;
pd->pending_seq = 0;
pd->print_func = print_func;