From 8600721de068d1bebce458ee5a97b3942fcd238c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Thu, 22 Jan 2026 14:39:46 +0100 Subject: [PATCH] stream: Change PW_CAPABILITY_DEVICE_ID_NEGOTIATION to a version number This allows easier evolvement of the negotiation protocol. --- doc/dox/internals/dma-buf.dox | 7 ++++--- src/examples/video-play-fixate.c | 7 ++++--- src/examples/video-src-fixate.c | 7 ++++--- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/doc/dox/internals/dma-buf.dox b/doc/dox/internals/dma-buf.dox index 273be930e..7815a8c42 100644 --- a/doc/dox/internals/dma-buf.dox +++ b/doc/dox/internals/dma-buf.dox @@ -313,12 +313,13 @@ performed. Device ID negotiation needs explicit support by both end points of a stream, thus, the first step of negotiation is discovering whether other peer has support for it. This is done by advertising a \ref SPA_PARAM_Capability with the key \ref -PW_CAPABILITY_DEVICE_ID_NEGOTIATION and value `true` +PW_CAPABILITY_DEVICE_ID_NEGOTIATION and value `1` which corresponds to the +current negotiation API version. ``` spa_param_dict_build_dict(&b, SPA_PARAM_Capability, &SPA_DICT_ITEMS( - SPA_DICT_ITEM(PW_CAPABILITY_DEVICE_ID_NEGOTIATION, "true"))); + SPA_DICT_ITEM(PW_CAPABILITY_DEVICE_ID_NEGOTIATION, "1"))); ``` To do this, when connecting to the stream, the \ref PW_STREAM_FLAG_INACTIVE flag must be @@ -369,7 +370,7 @@ To achieve this, the consumer adds another \ref SPA_PARAM_PeerCapability item wi ``` char *device_ids = ...; /* Base 64 encoding of a dev_t. */. &SPA_DICT_ITEMS( - SPA_DICT_ITEM(PW_CAPABILITY_DEVICE_ID_NEGOTIATION, "true"), + SPA_DICT_ITEM(PW_CAPABILITY_DEVICE_ID_NEGOTIATION, "1"), SPA_DICT_ITEM(PW_CAPABILITY_DEVICE_IDS, device_ids))); ``` diff --git a/src/examples/video-play-fixate.c b/src/examples/video-play-fixate.c index 6fdc561e6..2ee71a941 100644 --- a/src/examples/video-play-fixate.c +++ b/src/examples/video-play-fixate.c @@ -438,8 +438,9 @@ discover_capabilities(struct data *data, const struct spa_pod *param) return; spa_dict_for_each(it, &dict) { - if (spa_streq(it->key, PW_CAPABILITY_DEVICE_ID_NEGOTIATION) && - spa_streq(it->value, "true")) { + if (spa_streq(it->key, PW_CAPABILITY_DEVICE_ID_NEGOTIATION)) { + int version = atoi(it->value); + if (version >= 1) data->device_negotiation_supported = true; } else if (spa_streq(it->key, PW_CAPABILITY_DEVICE_IDS)) { collect_device_ids(data, it->value); @@ -787,7 +788,7 @@ int main(int argc, char *argv[]) params[n_params++] = spa_param_dict_build_dict(&b, SPA_PARAM_Capability, &SPA_DICT_ITEMS( - SPA_DICT_ITEM(PW_CAPABILITY_DEVICE_ID_NEGOTIATION, "true"))); + SPA_DICT_ITEM(PW_CAPABILITY_DEVICE_ID_NEGOTIATION, "1"))); #endif /* now connect the stream, we need a direction (input/output), diff --git a/src/examples/video-src-fixate.c b/src/examples/video-src-fixate.c index 0671ab1be..0e072c27b 100644 --- a/src/examples/video-src-fixate.c +++ b/src/examples/video-src-fixate.c @@ -450,8 +450,9 @@ discover_capabilities(struct data *data, const struct spa_pod *param) return; spa_dict_for_each(it, &dict) { - if (spa_streq(it->key, PW_CAPABILITY_DEVICE_ID_NEGOTIATION) && - spa_streq(it->value, "true")) { + if (spa_streq(it->key, PW_CAPABILITY_DEVICE_ID_NEGOTIATION)) { + int version = atoi(it->value); + if (version >= 1) data->device_negotiation_supported = true; } } @@ -799,7 +800,7 @@ int main(int argc, char *argv[]) params[n_params++] = spa_param_dict_build_dict(&b, SPA_PARAM_Capability, - &SPA_DICT_ITEMS(SPA_DICT_ITEM(PW_CAPABILITY_DEVICE_ID_NEGOTIATION, "true"), + &SPA_DICT_ITEMS(SPA_DICT_ITEM(PW_CAPABILITY_DEVICE_ID_NEGOTIATION, "1"), #ifdef SUPPORT_DEVICE_IDS_LIST SPA_DICT_ITEM(PW_CAPABILITY_DEVICE_IDS, device_ids) #endif /* SUPPORT_DEVICE_IDS_LIST */