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
This commit is contained in:
Wim Taymans 2021-07-28 10:48:49 +02:00
parent 4e087caa2b
commit 44583367db
3 changed files with 4 additions and 2 deletions

View file

@ -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);

View file

@ -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;

View file

@ -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 */