format: make media types and properties dynamic

Use URI properties to dynamically register the media types/subtypes and
property names. Add some helpers to set up the mappings.
This commit is contained in:
Wim Taymans 2017-03-21 11:28:23 +01:00
parent ee470fc6c6
commit 3f5a3e215b
25 changed files with 769 additions and 685 deletions

View file

@ -29,19 +29,41 @@ extern "C" {
typedef struct _SpaAudioInfo SpaAudioInfo;
typedef enum {
SPA_PROP_ID_AUDIO_INFO = SPA_PROP_ID_MEDIA_CUSTOM_START,
SPA_PROP_ID_AUDIO_FORMAT,
SPA_PROP_ID_AUDIO_FLAGS,
SPA_PROP_ID_AUDIO_LAYOUT,
SPA_PROP_ID_AUDIO_RATE,
SPA_PROP_ID_AUDIO_CHANNELS,
SPA_PROP_ID_AUDIO_CHANNEL_MASK,
} SpaPropIdAudio;
#define SPA_PROP_AUDIO_URI "http://spaplug.in/ns/prop-audio"
#define SPA_PROP_AUDIO_PREFIX SPA_PROP_AUDIO_URI "#"
#define SPA_PROP_AUDIO__format SPA_PROP_AUDIO_PREFIX "format"
#define SPA_PROP_AUDIO__flags SPA_PROP_AUDIO_PREFIX "flags"
#define SPA_PROP_AUDIO__layout SPA_PROP_AUDIO_PREFIX "layout"
#define SPA_PROP_AUDIO__rate SPA_PROP_AUDIO_PREFIX "rate"
#define SPA_PROP_AUDIO__channels SPA_PROP_AUDIO_PREFIX "channels"
#define SPA_PROP_AUDIO__channelMask SPA_PROP_AUDIO_PREFIX "channel-mask"
typedef struct {
uint32_t format;
uint32_t flags;
uint32_t layout;
uint32_t rate;
uint32_t channels;
uint32_t channel_mask;
} SpaPropAudio;
static inline void
spa_prop_audio_map (SpaIDMap *map, SpaPropAudio *types)
{
if (types->format == 0) {
types->format = spa_id_map_get_id (map, SPA_PROP_AUDIO__format);
types->flags = spa_id_map_get_id (map, SPA_PROP_AUDIO__flags);
types->layout = spa_id_map_get_id (map, SPA_PROP_AUDIO__layout);
types->rate = spa_id_map_get_id (map, SPA_PROP_AUDIO__rate);
types->channels = spa_id_map_get_id (map, SPA_PROP_AUDIO__channels);
types->channel_mask = spa_id_map_get_id (map, SPA_PROP_AUDIO__channelMask);
}
}
struct _SpaAudioInfo {
SpaMediaType media_type;
SpaMediaSubType media_subtype;
uint32_t media_type;
uint32_t media_subtype;
union {
SpaAudioInfoRaw raw;
} info;