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

@ -63,6 +63,9 @@ typedef struct {
typedef struct {
uint32_t node;
SpaMediaTypes media_types;
SpaMediaSubtypes media_subtypes;
SpaPropAudio prop_audio;
} URI;
struct _SpaVolume {
@ -307,13 +310,14 @@ next:
switch (index++) {
case 0:
spa_pod_builder_format (&b, &f[0], SPA_MEDIA_TYPE_AUDIO, SPA_MEDIA_SUBTYPE_RAW,
PROP_U_EN (&f[1], SPA_PROP_ID_AUDIO_FORMAT, SPA_POD_TYPE_INT, 3,
SPA_AUDIO_FORMAT_S16,
SPA_AUDIO_FORMAT_S16,
SPA_AUDIO_FORMAT_S32),
PROP_U_MM (&f[1], SPA_PROP_ID_AUDIO_RATE, SPA_POD_TYPE_INT, 44100, 1, INT32_MAX),
PROP_U_MM (&f[1], SPA_PROP_ID_AUDIO_CHANNELS, SPA_POD_TYPE_INT, 2, 1, INT32_MAX));
spa_pod_builder_format (&b, &f[0],
this->uri.media_types.audio, this->uri.media_subtypes.raw,
PROP_U_EN (&f[1], this->uri.prop_audio.format, SPA_POD_TYPE_INT, 3,
SPA_AUDIO_FORMAT_S16,
SPA_AUDIO_FORMAT_S16,
SPA_AUDIO_FORMAT_S32),
PROP_U_MM (&f[1], this->uri.prop_audio.rate, SPA_POD_TYPE_INT, 44100, 1, INT32_MAX),
PROP_U_MM (&f[1], this->uri.prop_audio.channels, SPA_POD_TYPE_INT, 2, 1, INT32_MAX));
break;
default:
@ -837,6 +841,9 @@ volume_init (const SpaHandleFactory *factory,
return SPA_RESULT_ERROR;
}
this->uri.node = spa_id_map_get_id (this->map, SPA_NODE_URI);
spa_media_types_fill (&this->uri.media_types, this->map);
spa_media_subtypes_map (this->map, &this->uri.media_subtypes);
spa_prop_audio_map (this->map, &this->uri.prop_audio);
this->node = volume_node;
reset_volume_props (&this->props);