From 44583367dbf10a6276a583910eb8865ab223b6af Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Wed, 28 Jul 2021 10:48:49 +0200 Subject: [PATCH] pod: add prop option to avoid fixation Add a DONT_FIXATE flag to spa_pod_props. The flag avoids fixation of the property by spa_pod_fixate(). When filtering properties, 'and' the flags together in the filtered property. This mostly preserves the merged property flags. It also merges the DONT_FIXATE flags so that when both sides can handle the non-fixated result, it will be returned. This can be used to let PipeWire filter out the common property fields and leave the final selection of fields to the producer. This can only work when the final selected field can be transported in some other way than the format param, like on the buffer fields or in metadata. One use case is negotiation of the DMABUF modifiers. See #1084 --- spa/include/spa/pod/filter.h | 2 +- spa/include/spa/pod/iter.h | 3 ++- spa/include/spa/pod/pod.h | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/spa/include/spa/pod/filter.h b/spa/include/spa/pod/filter.h index 4821cd409..944b4cc64 100644 --- a/spa/include/spa/pod/filter.h +++ b/spa/include/spa/pod/filter.h @@ -163,7 +163,7 @@ spa_pod_filter_prop(struct spa_pod_builder *b, } /* start with copying the property */ - spa_pod_builder_prop(b, p1->key, 0); + spa_pod_builder_prop(b, p1->key, p1->flags & p2->flags); spa_pod_builder_push_choice(b, &f, 0, 0); nc = (struct spa_pod_choice*)spa_pod_builder_frame(b, &f); diff --git a/spa/include/spa/pod/iter.h b/spa/include/spa/pod/iter.h index 5d7727da7..b710a816b 100644 --- a/spa/include/spa/pod/iter.h +++ b/spa/include/spa/pod/iter.h @@ -432,7 +432,8 @@ static inline int spa_pod_object_fixate(struct spa_pod_object *pod) { struct spa_pod_prop *res; SPA_POD_OBJECT_FOREACH(pod, res) { - if (res->value.type == SPA_TYPE_Choice) + if (res->value.type == SPA_TYPE_Choice && + !SPA_FLAG_IS_SET(res->flags, SPA_POD_PROP_FLAG_DONT_FIXATE)) ((struct spa_pod_choice*)&res->value)->body.type = SPA_CHOICE_None; } return 0; diff --git a/spa/include/spa/pod/pod.h b/spa/include/spa/pod/pod.h index af72515b0..2d2eaad6a 100644 --- a/spa/include/spa/pod/pod.h +++ b/spa/include/spa/pod/pod.h @@ -207,6 +207,7 @@ struct spa_pod_prop { * (String : key, * String : value)*)) */ #define SPA_POD_PROP_FLAG_MANDATORY (1u<<3) /**< is mandatory */ +#define SPA_POD_PROP_FLAG_DONT_FIXATE (1u<<4) /**< choices need no fixation */ uint32_t flags; /**< flags for property */ struct spa_pod value; /* value follows */