mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-17 07:00:03 -05:00
Add link introspection
This commit is contained in:
parent
b969623ec8
commit
e6f45a7686
8 changed files with 156 additions and 39 deletions
|
|
@ -255,6 +255,46 @@ client_dispatch_func (void *object,
|
|||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
link_dispatch_func (void *object,
|
||||
PinosMessageType type,
|
||||
void *message,
|
||||
void *data)
|
||||
{
|
||||
PinosContextImpl *impl = data;
|
||||
PinosContext *this = &impl->this;
|
||||
PinosProxy *proxy = object;
|
||||
|
||||
switch (type) {
|
||||
case PINOS_MESSAGE_LINK_INFO:
|
||||
{
|
||||
PinosMessageLinkInfo *m = message;
|
||||
PinosSubscriptionEvent event;
|
||||
|
||||
pinos_log_debug ("got link info %d", type);
|
||||
if (proxy->user_data == NULL)
|
||||
event = PINOS_SUBSCRIPTION_EVENT_NEW;
|
||||
else
|
||||
event = PINOS_SUBSCRIPTION_EVENT_CHANGE;
|
||||
|
||||
proxy->user_data = pinos_link_info_update (proxy->user_data, m->info);
|
||||
|
||||
if (impl->subscribe_func) {
|
||||
impl->subscribe_func (this,
|
||||
event,
|
||||
proxy->type,
|
||||
proxy->id,
|
||||
impl->subscribe_data);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
pinos_log_warn ("unhandled message %d", type);
|
||||
break;
|
||||
}
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
registry_dispatch_func (void *object,
|
||||
PinosMessageType type,
|
||||
|
|
@ -291,6 +331,11 @@ registry_dispatch_func (void *object,
|
|||
proxy->dispatch_func = client_dispatch_func;
|
||||
proxy->dispatch_data = impl;
|
||||
} else if (!strcmp (ng->type, PINOS_LINK_URI)) {
|
||||
proxy = pinos_proxy_new (this,
|
||||
SPA_ID_INVALID,
|
||||
this->uri.link);
|
||||
proxy->dispatch_func = link_dispatch_func;
|
||||
proxy->dispatch_data = impl;
|
||||
}
|
||||
if (proxy) {
|
||||
PinosMessageBind m;
|
||||
|
|
|
|||
|
|
@ -277,3 +277,39 @@ pinos_client_info_free (PinosClientInfo *info)
|
|||
pinos_spa_dict_destroy (info->props);
|
||||
free (info);
|
||||
}
|
||||
|
||||
PinosLinkInfo *
|
||||
pinos_link_info_update (PinosLinkInfo *info,
|
||||
const PinosLinkInfo *update)
|
||||
{
|
||||
uint64_t change_mask;
|
||||
|
||||
if (update == NULL)
|
||||
return info;
|
||||
|
||||
if (info == NULL) {
|
||||
info = calloc (1, sizeof (PinosLinkInfo));
|
||||
change_mask = ~0;
|
||||
} else {
|
||||
change_mask = info->change_mask | update->change_mask;
|
||||
}
|
||||
info->id = update->id;
|
||||
info->change_mask = change_mask;
|
||||
|
||||
if (update->change_mask & (1 << 0))
|
||||
info->output_node_id = update->output_node_id;
|
||||
if (update->change_mask & (1 << 1))
|
||||
info->output_port_id = update->output_port_id;
|
||||
if (update->change_mask & (1 << 2))
|
||||
info->input_node_id = update->input_node_id;
|
||||
if (update->change_mask & (1 << 3))
|
||||
info->input_port_id = update->input_port_id;
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
void
|
||||
pinos_link_info_free (PinosLinkInfo *info)
|
||||
{
|
||||
free (info);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -301,6 +301,10 @@ struct _PinosLinkInfo {
|
|||
uint32_t input_port_id;
|
||||
};
|
||||
|
||||
PinosLinkInfo * pinos_link_info_update (PinosLinkInfo *info,
|
||||
const PinosLinkInfo *update);
|
||||
void pinos_link_info_free (PinosLinkInfo *info);
|
||||
|
||||
|
||||
/**
|
||||
* PinosLinkInfoCallback:
|
||||
|
|
|
|||
|
|
@ -606,37 +606,6 @@ stream_dispatch_func (void *object,
|
|||
PinosStreamImpl *impl = SPA_CONTAINER_OF (stream, PinosStreamImpl, this);
|
||||
|
||||
switch (type) {
|
||||
case PINOS_MESSAGE_SYNC:
|
||||
case PINOS_MESSAGE_GET_REGISTRY:
|
||||
case PINOS_MESSAGE_BIND:
|
||||
case PINOS_MESSAGE_DESTROY:
|
||||
case PINOS_MESSAGE_REMOVE_ID:
|
||||
case PINOS_MESSAGE_CREATE_NODE:
|
||||
case PINOS_MESSAGE_CREATE_CLIENT_NODE:
|
||||
case PINOS_MESSAGE_NODE_UPDATE:
|
||||
case PINOS_MESSAGE_PORT_UPDATE:
|
||||
case PINOS_MESSAGE_PORT_STATUS_CHANGE:
|
||||
case PINOS_MESSAGE_NODE_STATE_CHANGE:
|
||||
case PINOS_MESSAGE_CORE_INFO:
|
||||
case PINOS_MESSAGE_MODULE_INFO:
|
||||
case PINOS_MESSAGE_NODE_INFO:
|
||||
case PINOS_MESSAGE_CLIENT_INFO:
|
||||
case PINOS_MESSAGE_LINK_INFO:
|
||||
pinos_log_warn ("got unexpected message %d", type);
|
||||
break;
|
||||
|
||||
case PINOS_MESSAGE_NOTIFY_DONE:
|
||||
pinos_log_warn ("notify done %d", type);
|
||||
break;
|
||||
|
||||
case PINOS_MESSAGE_NOTIFY_GLOBAL:
|
||||
pinos_log_warn ("notify global %d", type);
|
||||
break;
|
||||
|
||||
case PINOS_MESSAGE_NOTIFY_GLOBAL_REMOVE:
|
||||
pinos_log_warn ("notify global %d", type);
|
||||
break;
|
||||
|
||||
case PINOS_MESSAGE_CREATE_NODE_DONE:
|
||||
pinos_log_warn ("create node done %d", type);
|
||||
break;
|
||||
|
|
@ -838,6 +807,7 @@ stream_dispatch_func (void *object,
|
|||
pinos_log_debug ("transport update %d %p", impl->rtfd, impl->trans);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
case PINOS_MESSAGE_INVALID:
|
||||
pinos_log_warn ("unhandled message %d", type);
|
||||
break;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue