meta: add metadata features

Add a new features property to the metadata param. This should be
of type CHOICE_FEATURES_Int and should contain the extra features
supported by this metadata.

Make a special features metadata type that is a combination of the
metadata type in the upper 16 bits and the features for that type in the
lower 16 bits. Make a function to search if a type has certain feature
bits.

On the server, when negotiating buffers and metadata, check the result
of the features after filtering and if they are not 0, place them as
0 sized extra feature metadata on the buffer.

Add some metadata features for the sync_timeline, one that specifies
that the RELEASE flag is supported. With this in place, a producer can
see if a consumer supports the UNSCHEDULED_RELEASE flag.

See #4885
This commit is contained in:
Wim Taymans 2025-09-19 14:05:04 +02:00
parent a859c7a651
commit 00d983a40d
4 changed files with 31 additions and 4 deletions

View file

@ -118,6 +118,17 @@ SPA_API_BUFFER void *spa_buffer_find_meta_data(const struct spa_buffer *b, uint3
return NULL;
}
SPA_API_BUFFER bool spa_buffer_has_meta_features(const struct spa_buffer *b, uint32_t type, uint32_t features)
{
uint32_t i;
for (i = 0; i < b->n_metas; i++) {
uint32_t t = b->metas[i].type;
if ((t >> 16) == type && (t & features) == features)
return true;
}
return false;
}
/**
* \}
*/

View file

@ -37,10 +37,17 @@ enum spa_meta_type {
SPA_META_Busy, /**< don't write to buffer when count > 0 */
SPA_META_VideoTransform, /**< struct spa_meta_transform */
SPA_META_SyncTimeline, /**< struct spa_meta_sync_timeline */
_SPA_META_LAST, /**< not part of ABI/API */
SPA_META_START_custom = 0x200,
SPA_META_START_features = 0x10000, /* features start, these have 0 size, the
* type in the upper 16 bits and a bitmask in
* the lower 16 bits with type specific features. */
};
#define SPA_META_TYPE_FEATURES(type,features) (((type)<<16)|(features))
/**
* A metadata element.
*
@ -183,6 +190,8 @@ struct spa_meta_videotransform {
* this metadata as SPA_PARAM_BUFFERS_metaType when negotiating a buffer
* layout with 2 extra fds.
*/
#define SPA_META_FEATURE_SYNC_TIMELINE_RELEASE (1<<0) /**< metadata supports RELEASE */
struct spa_meta_sync_timeline {
#define SPA_META_SYNC_TIMELINE_UNSCHEDULED_RELEASE (1<<0) /**< this flag is set by the producer and cleared
* by the consumer when it promises to signal

View file

@ -33,6 +33,7 @@ enum spa_param_meta {
SPA_PARAM_META_START,
SPA_PARAM_META_type, /**< the metadata, one of enum spa_meta_type (Id enum spa_meta_type) */
SPA_PARAM_META_size, /**< the expected maximum size the meta (Int) */
SPA_PARAM_META_features, /**< meta data features (Features Int) */
};
/** properties for SPA_TYPE_OBJECT_ParamIO */