impl-port: add port.group property

Can be used to group ports together. Mostly because they are all from
the same stream and split into multiple ports by audioconvert/adapter.

Also useful for the alsa sequence to group client ports together.

Also interesting when pw-filter would be able to handle streams in the
future to find out what ports belong to what streams.
This commit is contained in:
Wim Taymans 2024-06-24 12:34:38 +02:00
parent 54c3fa06ed
commit 9d1d1fcbef
13 changed files with 62 additions and 23 deletions

View file

@ -76,7 +76,8 @@ struct port {
struct spa_ringbuffer ring = SPA_RINGBUFFER_INIT();
uint32_t ring_ids[MAX_BUFFERS];
static constexpr uint64_t info_all = SPA_PORT_CHANGE_MASK_FLAGS | SPA_PORT_CHANGE_MASK_PARAMS;
static constexpr uint64_t info_all = SPA_PORT_CHANGE_MASK_FLAGS |
SPA_PORT_CHANGE_MASK_PROPS | SPA_PORT_CHANGE_MASK_PARAMS;
struct spa_port_info info = SPA_PORT_INFO_INIT();
struct spa_io_buffers *io = nullptr;
struct spa_io_sequence *control = nullptr;
@ -402,15 +403,14 @@ static int impl_node_send_command(void *object, const struct spa_command *comman
return 0;
}
static const struct spa_dict_item info_items[] = {
{ SPA_KEY_DEVICE_API, "libcamera" },
{ SPA_KEY_MEDIA_CLASS, "Video/Source" },
{ SPA_KEY_MEDIA_ROLE, "Camera" },
{ SPA_KEY_NODE_DRIVER, "true" },
};
static void emit_node_info(struct impl *impl, bool full)
{
static const struct spa_dict_item info_items[] = {
{ SPA_KEY_DEVICE_API, "libcamera" },
{ SPA_KEY_MEDIA_CLASS, "Video/Source" },
{ SPA_KEY_MEDIA_ROLE, "Camera" },
{ SPA_KEY_NODE_DRIVER, "true" },
};
uint64_t old = full ? impl->info.change_mask : 0;
if (full)
impl->info.change_mask = impl->info_all;
@ -424,10 +424,15 @@ static void emit_node_info(struct impl *impl, bool full)
static void emit_port_info(struct impl *impl, struct port *port, bool full)
{
static const struct spa_dict_item info_items[] = {
{ SPA_KEY_PORT_GROUP, "stream.0" },
};
uint64_t old = full ? port->info.change_mask : 0;
if (full)
port->info.change_mask = port->info_all;
if (port->info.change_mask) {
struct spa_dict dict = SPA_DICT_INIT_ARRAY(info_items);
port->info.props = &dict;
spa_node_emit_port_info(&impl->hooks,
SPA_DIRECTION_OUTPUT, 0, &port->info);
port->info.change_mask = old;