pod: add SPA_POD_PROP_FLAG_DROP

The property will be dropped from the filtered result when one of the
pods to filter does not have the property.

This can be used as a feature mask. If side A provides a flags property
and B doesn't, the property will be removed from the result. Without the
flag, property A would be added and it would not be possible to see if
filtering happened (when B had compatible flags) or not.
This commit is contained in:
Wim Taymans 2025-09-16 11:00:04 +02:00
parent 03c5f493dc
commit 83b59d6ebe
2 changed files with 6 additions and 3 deletions

View file

@ -294,7 +294,7 @@ SPA_API_POD_FILTER int spa_pod_filter_part(struct spa_pod_builder *b,
res = spa_pod_filter_prop(b, p1, p2);
else if (SPA_FLAG_IS_SET(p1->flags, SPA_POD_PROP_FLAG_MANDATORY))
res = -EINVAL;
else
else if (!SPA_FLAG_IS_SET(p1->flags, SPA_POD_PROP_FLAG_DROP))
spa_pod_builder_raw_padded(b, p1, SPA_POD_PROP_SIZE(p1));
if (res < 0)
break;
@ -307,7 +307,7 @@ SPA_API_POD_FILTER int spa_pod_filter_part(struct spa_pod_builder *b,
continue;
if (SPA_FLAG_IS_SET(p2->flags, SPA_POD_PROP_FLAG_MANDATORY))
res = -EINVAL;
else
else if (!SPA_FLAG_IS_SET(p2->flags, SPA_POD_PROP_FLAG_DROP))
spa_pod_builder_raw_padded(b, p2, SPA_POD_PROP_SIZE(p2));
if (res < 0)
break;

View file

@ -201,8 +201,11 @@ struct spa_pod_prop {
* Int : n_items,
* (String : key,
* String : value)*)) */
#define SPA_POD_PROP_FLAG_MANDATORY (1u<<3) /**< is mandatory */
#define SPA_POD_PROP_FLAG_MANDATORY (1u<<3) /**< is mandatory, when filtering, both sides
* need this property or filtering fails. */
#define SPA_POD_PROP_FLAG_DONT_FIXATE (1u<<4) /**< choices need no fixation */
#define SPA_POD_PROP_FLAG_DROP (1u<<5) /**< drop property, when filtering, both sides
* need the property or it will be dropped. */
uint32_t flags; /**< flags for property */
struct spa_pod value;
/* value follows */