diff options
Diffstat (limited to 'spa/plugins')
-rw-r--r-- | spa/plugins/alsa/alsa-sink.c | 86 | ||||
-rw-r--r-- | spa/plugins/alsa/alsa-source.c | 39 | ||||
-rw-r--r-- | spa/plugins/alsa/alsa-utils.c | 4 | ||||
-rw-r--r-- | spa/plugins/audiomixer/audiomixer.c | 49 | ||||
-rw-r--r-- | spa/plugins/audiotestsrc/audiotestsrc.c | 61 | ||||
-rw-r--r-- | spa/plugins/ffmpeg/ffmpeg-dec.c | 162 | ||||
-rw-r--r-- | spa/plugins/ffmpeg/ffmpeg-enc.c | 30 | ||||
-rw-r--r-- | spa/plugins/support/logger.c | 2 | ||||
-rw-r--r-- | spa/plugins/support/mapper.c | 1 | ||||
-rw-r--r-- | spa/plugins/test/fakesink.c | 45 | ||||
-rw-r--r-- | spa/plugins/test/fakesrc.c | 48 | ||||
-rw-r--r-- | spa/plugins/v4l2/v4l2-source.c | 46 | ||||
-rw-r--r-- | spa/plugins/videotestsrc/videotestsrc.c | 64 | ||||
-rw-r--r-- | spa/plugins/volume/volume.c | 61 |
14 files changed, 428 insertions, 270 deletions
diff --git a/spa/plugins/alsa/alsa-sink.c b/spa/plugins/alsa/alsa-sink.c index 5c1430ba..5e319c06 100644 --- a/spa/plugins/alsa/alsa-sink.c +++ b/spa/plugins/alsa/alsa-sink.c @@ -23,7 +23,7 @@ #include <spa/node.h> #include <spa/audio/format.h> -#include <lib/props.h> +#include <lib/pod.h> #define NAME "alsa-sink" @@ -49,6 +49,8 @@ static int impl_node_enum_params(struct spa_node *node, { struct state *this; struct type *t; + struct spa_pod *param; + uint32_t offset; spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS); spa_return_val_if_fail(index != NULL, SPA_RESULT_INVALID_ARGUMENTS); @@ -57,11 +59,14 @@ static int impl_node_enum_params(struct spa_node *node, this = SPA_CONTAINER_OF(node, struct state, node); t = &this->type; + offset = builder->offset; + + next: if (id == t->param.idList) { if (*index > 0) return SPA_RESULT_ENUM_END; - spa_pod_builder_object(builder, + param = spa_pod_builder_object(builder, id, t->param.List, ":", t->param.listId, "I", t->param.idProps); } @@ -71,21 +76,25 @@ static int impl_node_enum_params(struct spa_node *node, if (*index > 0) return SPA_RESULT_ENUM_END; - spa_pod_builder_object(builder, - id, t->props, - ":", t->prop_device, "S", p->device, sizeof(p->device), - ":", t->prop_device_name, "S-r", p->device_name, sizeof(p->device_name), - ":", t->prop_card_name, "S-r", p->card_name, sizeof(p->card_name), - ":", t->prop_min_latency, "ir", p->min_latency, - 2, 1, INT32_MAX, - ":", t->prop_max_latency, "ir", p->max_latency, - 2, 1, INT32_MAX); + param = spa_pod_builder_object(builder, + id, t->props, + ":", t->prop_device, "S", p->device, sizeof(p->device), + ":", t->prop_device_name, "S-r", p->device_name, sizeof(p->device_name), + ":", t->prop_card_name, "S-r", p->card_name, sizeof(p->card_name), + ":", t->prop_min_latency, "ir", p->min_latency, + 2, 1, INT32_MAX, + ":", t->prop_max_latency, "ir", p->max_latency, + 2, 1, INT32_MAX); } else return SPA_RESULT_UNKNOWN_PARAM; (*index)++; + spa_pod_builder_reset(builder, offset); + if (spa_pod_filter(builder, param, (struct spa_pod*)filter) < 0) + goto next; + return SPA_RESULT_OK; } @@ -261,31 +270,6 @@ impl_node_port_get_info(struct spa_node *node, return SPA_RESULT_OK; } -static int port_get_format(struct spa_node *node, - enum spa_direction direction, uint32_t port_id, - uint32_t *index, - const struct spa_pod_object *filter, - struct spa_pod_builder *builder) -{ - struct state *this = SPA_CONTAINER_OF(node, struct state, node); - struct type *t = &this->type; - - if (!this->have_format) - return SPA_RESULT_NO_FORMAT; - if (*index > 0) - return SPA_RESULT_ENUM_END; - - spa_pod_builder_object(builder, - t->param.idFormat, t->format, - "I", t->media_type.audio, - "I", t->media_subtype.raw, - ":", t->format_audio.format, "I", this->current_format.info.raw.format, - ":", t->format_audio.rate, "i", this->current_format.info.raw.rate, - ":", t->format_audio.channels, "i", this->current_format.info.raw.channels); - - return SPA_RESULT_OK; -} - static int impl_node_port_enum_params(struct spa_node *node, enum spa_direction direction, uint32_t port_id, @@ -296,6 +280,8 @@ impl_node_port_enum_params(struct spa_node *node, struct state *this; struct type *t; + struct spa_pod *param; + uint32_t offset; spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS); spa_return_val_if_fail(index != NULL, SPA_RESULT_INVALID_ARGUMENTS); @@ -306,6 +292,9 @@ impl_node_port_enum_params(struct spa_node *node, spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT); + offset = builder->offset; + + next: if (id == t->param.idList) { uint32_t list[] = { t->param.idEnumFormat, t->param.idFormat, @@ -313,7 +302,7 @@ impl_node_port_enum_params(struct spa_node *node, t->param.idMeta }; if (*index < SPA_N_ELEMENTS(list)) - spa_pod_builder_object(builder, id, t->param.List, + param = spa_pod_builder_object(builder, id, t->param.List, ":", t->param.listId, "I", list[*index]); else return SPA_RESULT_ENUM_END; @@ -322,7 +311,18 @@ impl_node_port_enum_params(struct spa_node *node, return spa_alsa_enum_format(this, index, filter, builder); } else if (id == t->param.idFormat) { - return port_get_format(node, direction, port_id, index, filter, builder); + if (!this->have_format) + return SPA_RESULT_NO_FORMAT; + if (*index > 0) + return SPA_RESULT_ENUM_END; + + param = spa_pod_builder_object(builder, + t->param.idFormat, t->format, + "I", t->media_type.audio, + "I", t->media_subtype.raw, + ":", t->format_audio.format, "I", this->current_format.info.raw.format, + ":", t->format_audio.rate, "i", this->current_format.info.raw.rate, + ":", t->format_audio.channels, "i", this->current_format.info.raw.channels); } else if (id == t->param.idBuffers) { if (!this->have_format) @@ -330,7 +330,7 @@ impl_node_port_enum_params(struct spa_node *node, if (*index > 0) return SPA_RESULT_ENUM_END; - spa_pod_builder_object(builder, + param = spa_pod_builder_object(builder, id, t->param_alloc_buffers.Buffers, ":", t->param_alloc_buffers.size, "iru", this->props.min_latency * this->frame_size, 2, this->props.min_latency * this->frame_size, @@ -346,13 +346,13 @@ impl_node_port_enum_params(struct spa_node *node, switch (*index) { case 0: - spa_pod_builder_object(builder, + param = spa_pod_builder_object(builder, id, t->param_alloc_meta_enable.MetaEnable, ":", t->param_alloc_meta_enable.type, "I", t->meta.Header, ":", t->param_alloc_meta_enable.size, "i", sizeof(struct spa_meta_header)); break; case 1: - spa_pod_builder_object(builder, + param = spa_pod_builder_object(builder, id, t->param_alloc_meta_enable.MetaEnable, ":", t->param_alloc_meta_enable.type, "I", t->meta.Ringbuffer, ":", t->param_alloc_meta_enable.size, "i", sizeof(struct spa_meta_ringbuffer), @@ -373,6 +373,10 @@ impl_node_port_enum_params(struct spa_node *node, (*index)++; + spa_pod_builder_reset(builder, offset); + if (spa_pod_filter(builder, param, (struct spa_pod*)filter) < 0) + goto next; + return SPA_RESULT_OK; } diff --git a/spa/plugins/alsa/alsa-source.c b/spa/plugins/alsa/alsa-source.c index 8ff5c59c..a1bcb228 100644 --- a/spa/plugins/alsa/alsa-source.c +++ b/spa/plugins/alsa/alsa-source.c @@ -24,7 +24,8 @@ #include <spa/node.h> #include <spa/list.h> #include <spa/audio/format.h> -#include <lib/props.h> + +#include <lib/pod.h> #define NAME "alsa-source" @@ -48,6 +49,8 @@ static int impl_node_enum_params(struct spa_node *node, { struct state *this; struct type *t; + struct spa_pod *param; + uint32_t offset; spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS); spa_return_val_if_fail(index != NULL, SPA_RESULT_INVALID_ARGUMENTS); @@ -56,11 +59,14 @@ static int impl_node_enum_params(struct spa_node *node, this = SPA_CONTAINER_OF(node, struct state, node); t = &this->type; + offset = builder->offset; + + next: if (id == t->param.idList) { if (*index > 0) return SPA_RESULT_ENUM_END; - spa_pod_builder_object(builder, + param = spa_pod_builder_object(builder, id, t->param.List, ":", t->param.listId, "I", t->param.idProps); } @@ -70,7 +76,7 @@ static int impl_node_enum_params(struct spa_node *node, if (*index > 0) return SPA_RESULT_ENUM_END; - spa_pod_builder_object(builder, + param = spa_pod_builder_object(builder, id, t->props, ":", t->prop_device, "S", p->device, sizeof(p->device), ":", t->prop_device_name, "S-r", p->device_name, sizeof(p->device_name), @@ -83,6 +89,10 @@ static int impl_node_enum_params(struct spa_node *node, (*index)++; + spa_pod_builder_reset(builder, offset); + if (spa_pod_filter(builder, param, (struct spa_pod*)filter) < 0) + goto next; + return SPA_RESULT_OK; } @@ -290,7 +300,7 @@ static void recycle_buffer(struct state *this, uint32_t buffer_id) static int port_get_format(struct spa_node *node, enum spa_direction direction, uint32_t port_id, uint32_t *index, - const struct spa_pod_object *filter, + struct spa_pod **param, struct spa_pod_builder *builder) { struct state *this = SPA_CONTAINER_OF(node, struct state, node); @@ -301,7 +311,7 @@ static int port_get_format(struct spa_node *node, if (*index > 0) return SPA_RESULT_ENUM_END; - spa_pod_builder_object(builder, + *param = spa_pod_builder_object(builder, t->param.idFormat, t->format, "I", t->media_type.audio, "I", t->media_subtype.raw, @@ -321,6 +331,9 @@ impl_node_port_enum_params(struct spa_node *node, { struct state *this; struct type *t; + struct spa_pod *param; + uint32_t offset; + int res; spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS); spa_return_val_if_fail(index != NULL, SPA_RESULT_INVALID_ARGUMENTS); @@ -331,6 +344,9 @@ impl_node_port_enum_params(struct spa_node *node, spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT); + offset = builder->offset; + + next: if (id == t->param.idList) { uint32_t list[] = { t->param.idEnumFormat, t->param.idFormat, @@ -338,7 +354,7 @@ impl_node_port_enum_params(struct spa_node *node, t->param.idMeta }; if (*index < SPA_N_ELEMENTS(list)) - spa_pod_builder_object(builder, id, t->param.List, + param = spa_pod_builder_object(builder, id, t->param.List, ":", t->param.listId, "I", list[*index]); else return SPA_RESULT_ENUM_END; @@ -347,7 +363,8 @@ impl_node_port_enum_params(struct spa_node *node, return spa_alsa_enum_format(this, index, filter, builder); } else if (id == t->param.idFormat) { - return port_get_format(node, direction, port_id, index, filter, builder); + if ((res = port_get_format(node, direction, port_id, index, ¶m, builder)) < 0) + return res; } else if (id == t->param.idBuffers) { if (!this->have_format) @@ -355,7 +372,7 @@ impl_node_port_enum_params(struct spa_node *node, if (*index > 0) return SPA_RESULT_ENUM_END; - spa_pod_builder_object(builder, + param = spa_pod_builder_object(builder, id, t->param_alloc_buffers.Buffers, ":", t->param_alloc_buffers.size, "i", this->props.min_latency * this->frame_size, ":", t->param_alloc_buffers.stride, "i", 0, @@ -369,7 +386,7 @@ impl_node_port_enum_params(struct spa_node *node, switch (*index) { case 0: - spa_pod_builder_object(builder, + param = spa_pod_builder_object(builder, id, t->param_alloc_meta_enable.MetaEnable, ":", t->param_alloc_meta_enable.type, "I", t->meta.Header, ":", t->param_alloc_meta_enable.size, "i", sizeof(struct spa_meta_header)); @@ -383,6 +400,10 @@ impl_node_port_enum_params(struct spa_node *node, (*index)++; + spa_pod_builder_reset(builder, offset); + if (spa_pod_filter(builder, param, (struct spa_pod*)filter) < 0) + goto next; + return SPA_RESULT_OK; } diff --git a/spa/plugins/alsa/alsa-utils.c b/spa/plugins/alsa/alsa-utils.c index 191ced23..c78f1917 100644 --- a/spa/plugins/alsa/alsa-utils.c +++ b/spa/plugins/alsa/alsa-utils.c @@ -10,7 +10,7 @@ #include <sys/timerfd.h> #include <lib/debug.h> -#include <lib/format.h> +#include <lib/pod.h> #include "alsa-utils.h" @@ -202,7 +202,7 @@ spa_alsa_enum_format(struct state *state, uint32_t *index, (*index)++; - if ((res = spa_pod_object_filter(fmt, filter, builder)) < 0) + if ((res = spa_pod_filter(builder, (struct spa_pod*)fmt, (struct spa_pod*)filter)) < 0) goto next; if (!opened) diff --git a/spa/plugins/audiomixer/audiomixer.c b/spa/plugins/audiomixer/audiomixer.c index 01e99900..c51d12c6 100644 --- a/spa/plugins/audiomixer/audiomixer.c +++ b/spa/plugins/audiomixer/audiomixer.c @@ -25,10 +25,10 @@ #include <spa/type-map.h> #include <spa/node.h> #include <spa/audio/format-utils.h> -#include <lib/format.h> -#include <lib/props.h> #include <spa/param-alloc.h> +#include <lib/pod.h> + #include "conv.h" #define NAME "audiomixer" @@ -323,22 +323,15 @@ impl_node_port_get_info(struct spa_node *node, static int port_enum_formats(struct spa_node *node, enum spa_direction direction, uint32_t port_id, uint32_t *index, - const struct spa_pod_object *filter, + struct spa_pod **param, struct spa_pod_builder *builder) { struct impl *this = SPA_CONTAINER_OF(node, struct impl, node); - struct spa_pod_object *fmt; - uint8_t buffer[256]; - struct spa_pod_builder b = { NULL, }; struct type *t = &this->type; - int res; - - next: - spa_pod_builder_init(&b, buffer, sizeof(buffer)); switch (*index) { case 0: - fmt = spa_pod_builder_object(&b, + *param = spa_pod_builder_object(builder, t->param.idEnumFormat, t->format, "I", t->media_type.audio, "I", t->media_subtype.raw, @@ -353,19 +346,13 @@ static int port_enum_formats(struct spa_node *node, default: return SPA_RESULT_ENUM_END; } - - (*index)++; - - if ((res = spa_pod_object_filter(fmt, filter, builder)) != SPA_RESULT_OK) - goto next; - return SPA_RESULT_OK; } static int port_get_format(struct spa_node *node, enum spa_direction direction, uint32_t port_id, uint32_t *index, - const struct spa_pod_object *filter, + struct spa_pod **param, struct spa_pod_builder *builder) { struct impl *this = SPA_CONTAINER_OF(node, struct impl, node); @@ -377,7 +364,7 @@ static int port_get_format(struct spa_node *node, if (*index > 0) return SPA_RESULT_ENUM_END; - spa_pod_builder_object(builder, + *param = spa_pod_builder_object(builder, t->param.idFormat, t->format, "I", t->media_type.audio, "I", t->media_subtype.raw, @@ -398,6 +385,9 @@ impl_node_port_enum_params(struct spa_node *node, struct impl *this; struct type *t; struct port *port; + struct spa_pod *param; + uint32_t offset; + int res; spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS); spa_return_val_if_fail(index != NULL, SPA_RESULT_INVALID_ARGUMENTS); @@ -410,6 +400,9 @@ impl_node_port_enum_params(struct spa_node *node, port = GET_PORT(this, direction, port_id); + offset = builder->offset; + + next: if (id == t->param.idList) { uint32_t list[] = { t->param.idEnumFormat, t->param.idFormat, @@ -417,16 +410,18 @@ impl_node_port_enum_params(struct spa_node *node, t->param.idMeta }; if (*index < SPA_N_ELEMENTS(list)) - spa_pod_builder_object(builder, id, t->param.List, + param = spa_pod_builder_object(builder, id, t->param.List, ":", t->param.listId, "I", list[*index]); else return SPA_RESULT_ENUM_END; } else if (id == t->param.idEnumFormat) { - return port_enum_formats(node, direction, port_id, index, filter, builder); + if ((res = port_enum_formats(node, direction, port_id, index, ¶m, builder)) < 0) + return res; } else if (id == t->param.idFormat) { - return port_get_format(node, direction, port_id, index, filter, builder); + if ((res = port_get_format(node, direction, port_id, index, ¶m, builder)) < 0) + return res; } else if (id == t->param.idBuffers) { if (!port->have_format) @@ -434,7 +429,7 @@ impl_node_port_enum_params(struct spa_node *node, if (*index > 0) return SPA_RESULT_ENUM_END; - spa_pod_builder_object(builder, + param = spa_pod_builder_object(builder, id, t->param_alloc_buffers.Buffers, ":", t->param_alloc_buffers.size, "iru", 1024 * this->bpf, 2, 16 * this->bpf, @@ -450,13 +445,13 @@ impl_node_port_enum_params(struct spa_node *node, switch (*index) { case 0: - spa_pod_builder_object(builder, + param = spa_pod_builder_object(builder, id, t->param_alloc_meta_enable.MetaEnable, ":", t->param_alloc_meta_enable.type, "I", t->meta.Header, ":", t->param_alloc_meta_enable.size, "i", sizeof(struct spa_meta_header)); break; case 1: - spa_pod_builder_object(builder, + param = spa_pod_builder_object(builder, id, t->param_alloc_meta_enable.MetaEnable, ":", t->param_alloc_meta_enable.type, "I", t->meta.Ringbuffer, ":", t->param_alloc_meta_enable.size, "i", sizeof(struct spa_meta_ringbuffer), @@ -475,6 +470,10 @@ impl_node_port_enum_params(struct spa_node *node, (*index)++; + spa_pod_builder_reset(builder, offset); + if (spa_pod_filter(builder, param, (struct spa_pod*)filter) < 0) + goto next; + return SPA_RESULT_OK; } diff --git a/spa/plugins/audiotestsrc/audiotestsrc.c b/spa/plugins/audiotestsrc/audiotestsrc.c index 1ca581f4..e2a58561 100644 --- a/spa/plugins/audiotestsrc/audiotestsrc.c +++ b/spa/plugins/audiotestsrc/audiotestsrc.c @@ -32,8 +32,7 @@ #include <spa/list.h> #include <spa/audio/format-utils.h> -#include <lib/format.h> -#include <lib/props.h> +#include <lib/pod.h> #define NAME "audiotestsrc" @@ -173,6 +172,8 @@ static int impl_node_enum_params(struct spa_node *node, { struct impl *this; struct type *t; + uint32_t offset; + struct spa_pod *param; spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS); spa_return_val_if_fail(index != NULL, SPA_RESULT_INVALID_ARGUMENTS); @@ -181,11 +182,14 @@ static int impl_node_enum_params(struct spa_node *node, this = SPA_CONTAINER_OF(node, struct impl, node); t = &this->type; + offset = builder->offset; + + next: if (id == t->param.idList) { if (*index > 0) return SPA_RESULT_ENUM_END; - spa_pod_builder_object(builder, + param = spa_pod_builder_object(builder, id, t->param.List, ":", t->param.listId, "I", t->param.idProps); } @@ -195,7 +199,7 @@ static int impl_node_enum_params(struct spa_node *node, if (*index > 0) return SPA_RESULT_ENUM_END; - spa_pod_builder_object(builder, + param = spa_pod_builder_object(builder, id, t->props, ":", t->prop_live, "b", p->live, ":", t->prop_wave, "Ie", p->wave, @@ -211,6 +215,10 @@ static int impl_node_enum_params(struct spa_node *node, (*index)++; + spa_pod_builder_reset(builder, offset); + if (spa_pod_filter(builder, param, (struct spa_pod*)filter) < 0) + goto next; + return SPA_RESULT_OK; } @@ -507,21 +515,14 @@ static int port_enum_formats(struct impl *this, enum spa_direction direction, uint32_t port_id, uint32_t *index, - const struct spa_pod_object *filter, + struct spa_pod **param, struct spa_pod_builder *builder) { - struct spa_pod_object *fmt; struct type *t = &this->type; - uint8_t buffer[1024]; - struct spa_pod_builder b = { 0 }; - int res; - - next: - spa_pod_builder_init(&b, buffer, sizeof(buffer)); switch (*index) { case 0: - fmt = spa_pod_builder_object(&b, + *param = spa_pod_builder_object(builder, t->param.idEnumFormat, t->format, "I", t->media_type.audio, "I", t->media_subtype.raw, @@ -538,12 +539,6 @@ port_enum_formats(struct impl *this, default: return SPA_RESULT_ENUM_END; } - - (*index)++; - - if ((res = spa_pod_object_filter(fmt, filter, builder)) != SPA_RESULT_OK) - goto next; - return SPA_RESULT_OK; } @@ -552,7 +547,7 @@ port_get_format(struct impl *this, enum spa_direction direction, uint32_t port_id, uint32_t *index, - const struct spa_pod_object *filter, + struct spa_pod **param, struct spa_pod_builder *builder) { struct type *t = &this->type; @@ -563,7 +558,7 @@ port_get_format(struct impl *this, if (*index > 0) return SPA_RESULT_ENUM_END; - spa_pod_builder_object(builder, + *param = spa_pod_builder_object(builder, t->param.idFormat, t->format, "I", t->media_type.audio, "I", t->media_subtype.raw, @@ -583,6 +578,9 @@ impl_node_port_enum_params(struct spa_node *node, { struct impl *this; struct type *t; + uint32_t offset; + struct spa_pod *param; + int res; spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS); spa_return_val_if_fail(index != NULL, SPA_RESULT_INVALID_ARGUMENTS); @@ -593,6 +591,9 @@ impl_node_port_enum_params(struct spa_node *node, spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT); + offset = builder->offset; + + next: if (id == t->param.idList) { uint32_t list[] = { t->param.idEnumFormat, t->param.idFormat, @@ -600,16 +601,18 @@ impl_node_port_enum_params(struct spa_node *node, t->param.idMeta }; if (*index < SPA_N_ELEMENTS(list)) - spa_pod_builder_object(builder, id, t->param.List, + param = spa_pod_builder_object(builder, id, t->param.List, ":", t->param.listId, "I", list[*index]); else return SPA_RESULT_ENUM_END; } else if (id == t->param.idEnumFormat) { - return port_enum_formats(this, direction, port_id, index, filter, builder); + if ((res = port_enum_formats(this, direction, port_id, index, ¶m, builder)) < 0) + return res; } else if (id == t->param.idFormat) { - return port_get_format(this, direction, port_id, index, filter, builder); + if ((res = port_get_format(this, direction, port_id, index, ¶m, builder)) < 0) + return res; } else if (id == t->param.idBuffers) { if (!this->have_format) @@ -617,7 +620,7 @@ impl_node_port_enum_params(struct spa_node *node, if (*index > 0) return SPA_RESULT_ENUM_END; - spa_pod_builder_object(builder, + param = spa_pod_builder_object(builder, id, t->param_alloc_buffers.Buffers, ":", t->param_alloc_buffers.size, "iru", 1024 * this->bpf, 2, 16 * this->bpf, @@ -633,13 +636,13 @@ impl_node_port_enum_params(struct spa_node *node, switch (*index) { case 0: - spa_pod_builder_object(builder, + param = spa_pod_builder_object(builder, id, t->param_alloc_meta_enable.MetaEnable, ":", t->param_alloc_meta_enable.type, "I", t->meta.Header, ":", t->param_alloc_meta_enable.size, "i", sizeof(struct spa_meta_header)); break; case 1: - spa_pod_builder_object(builder, + param = spa_pod_builder_object(builder, id, t->param_alloc_meta_enable.MetaEnable, ":", t->param_alloc_meta_enable.type, "I", t->meta.Ringbuffer, ":", t->param_alloc_meta_enable.size, "i", sizeof(struct spa_meta_ringbuffer), @@ -658,6 +661,10 @@ impl_node_port_enum_params(struct spa_node *node, (*index)++; + spa_pod_builder_reset(builder, offset); + if (spa_pod_filter(builder, param, (struct spa_pod*)filter) < 0) + goto next; + return SPA_RESULT_OK; } diff --git a/spa/plugins/ffmpeg/ffmpeg-dec.c b/spa/plugins/ffmpeg/ffmpeg-dec.c index 46891d7c..642dfd83 100644 --- a/spa/plugins/ffmpeg/ffmpeg-dec.c +++ b/spa/plugins/ffmpeg/ffmpeg-dec.c @@ -26,7 +26,7 @@ #include <spa/log.h> #include <spa/node.h> #include <spa/video/format-utils.h> -#include <lib/props.h> +#include <lib/pod.h> #define IS_VALID_PORT(this,d,id) ((id) == 0) #define MAX_BUFFERS 32 @@ -189,11 +189,36 @@ spa_ffmpeg_dec_node_remove_port(struct spa_node *node, return SPA_RESULT_NOT_IMPLEMENTED; } +static int +spa_ffmpeg_dec_node_port_get_info(struct spa_node *node, + enum spa_direction direction, + uint32_t port_id, + const struct spa_port_info **info) +{ + struct impl *this; + struct port *port; + + if (node == NULL || info == NULL) + return SPA_RESULT_INVALID_ARGUMENTS; + + this = SPA_CONTAINER_OF(node, struct impl, node); + + if (!IS_VALID_PORT(this, direction, port_id)) + return SPA_RESULT_INVALID_PORT; + + port = + direction == SPA_DIRECTION_INPUT ? &this->in_ports[port_id] : &this->out_ports[port_id]; + *info = &port->info; + + return SPA_RESULT_OK; +} + static int port_enum_formats(struct spa_node *node, enum spa_direction direction, uint32_t port_id, uint32_t *index, const struct spa_pod_object *filter, - struct spa_pod_builder *builder) + struct spa_pod_builder *builder, + struct spa_pod **param) { //struct impl *this; @@ -207,55 +232,13 @@ static int port_enum_formats(struct spa_node *node, switch (*index) { case 0: + *param = NULL; break; default: return SPA_RESULT_ENUM_END; } - return SPA_RESULT_OK; -} - -static int port_set_format(struct spa_node *node, - enum spa_direction direction, uint32_t port_id, - uint32_t flags, - const struct spa_pod_object *format) -{ - struct impl *this; - struct port *port; - - if (node == NULL || format == NULL) - return SPA_RESULT_INVALID_ARGUMENTS; - - this = SPA_CONTAINER_OF(node, struct impl, node); - - if (!IS_VALID_PORT(this, direction, port_id)) - return SPA_RESULT_INVALID_PORT; - - port = - direction == SPA_DIRECTION_INPUT ? &this->in_ports[port_id] : &this->out_ports[port_id]; - - if (format == NULL) { - port->have_format = false; - return SPA_RESULT_OK; - } else { - struct spa_video_info info = { 0 }; - - spa_pod_object_parse(format, - "I", &info.media_type, - "I", &info.media_subtype); - if (info.media_type != this->type.media_type.video && - info.media_subtype != this->type.media_subtype.raw) - return SPA_RESULT_INVALID_MEDIA_TYPE; - - if (spa_format_video_raw_parse(format, &info.info.raw, &this->type.format_video) < 0) - return SPA_RESULT_INVALID_MEDIA_TYPE; - - if (!(flags & SPA_NODE_PARAM_FLAG_TEST_ONLY)) { - port->current_format = info; - port->have_format = true; - } - } return SPA_RESULT_OK; } @@ -263,7 +246,8 @@ static int port_get_format(struct spa_node *node, enum spa_direction direction, uint32_t port_id, uint32_t *index, const struct spa_pod_object *filter, - struct spa_pod_builder *builder) + struct spa_pod_builder *builder, + struct spa_pod **param) { struct impl *this = SPA_CONTAINER_OF(node, struct impl, node); struct port *port; @@ -277,29 +261,7 @@ static int port_get_format(struct spa_node *node, if (*index > 0) return SPA_RESULT_ENUM_END; - return SPA_RESULT_OK; -} - -static int -spa_ffmpeg_dec_node_port_get_info(struct spa_node *node, - enum spa_direction direction, - uint32_t port_id, - const struct spa_port_info **info) -{ - struct impl *this; - struct port *port; - - if (node == NULL || info == NULL) - return SPA_RESULT_INVALID_ARGUMENTS; - - this = SPA_CONTAINER_OF(node, struct impl, node); - - if (!IS_VALID_PORT(this, direction, port_id)) - return SPA_RESULT_INVALID_PORT; - - port = - direction == SPA_DIRECTION_INPUT ? &this->in_ports[port_id] : &this->out_ports[port_id]; - *info = &port->info; + *param = NULL; return SPA_RESULT_OK; } @@ -313,28 +275,84 @@ spa_ffmpeg_dec_node_port_enum_params(struct spa_node *node, { struct impl *this = SPA_CONTAINER_OF(node, struct impl, node); struct type *t = &this->type; + uint32_t offset; + struct spa_pod *param; + int res; + offset = builder->offset; + + next: if (id == t->param.idList) { uint32_t list[] = { t->param.idEnumFormat, t->param.idFormat }; if (*index < SPA_N_ELEMENTS(list)) - spa_pod_builder_object(builder, id, t->param.List, + param = spa_pod_builder_object(builder, id, t->param.List, ":", t->param.listId, "I", list[*index]); else return SPA_RESULT_ENUM_END; } else if (id == t->param.idEnumFormat) { - return port_enum_formats(node, direction, port_id, index, filter, builder); + if ((res = port_enum_formats(node, direction, port_id, index, filter, builder, ¶m)) < 0) + return res; } else if (id == t->param.idFormat) { - return port_get_format(node, direction, port_id, index, filter, builder); + if ((res = port_get_format(node, direction, port_id, index, filter, builder, ¶m)) < 0) + return res; } else return SPA_RESULT_UNKNOWN_PARAM; (*index)++; + spa_pod_builder_reset(builder, offset); + if (spa_pod_filter(builder, param, (struct spa_pod*)filter) < 0) + goto next; + + return SPA_RESULT_OK; +} + +static int port_set_format(struct spa_node *node, + enum spa_direction direction, uint32_t port_id, + uint32_t flags, + const struct spa_pod_object *format) +{ + struct impl *this; + struct port *port; + + if (node == NULL || format == NULL) + return SPA_RESULT_INVALID_ARGUMENTS; + + this = SPA_CONTAINER_OF(node, struct impl, node); + + if (!IS_VALID_PORT(this, direction, port_id)) + return SPA_RESULT_INVALID_PORT; + + port = + direction == SPA_DIRECTION_INPUT ? &this->in_ports[port_id] : &this->out_ports[port_id]; + + if (format == NULL) { + port->have_format = false; + return SPA_RESULT_OK; + } else { + struct spa_video_info info = { 0 }; + + spa_pod_object_parse(format, + "I", &info.media_type, + "I", &info.media_subtype); + + if (info.media_type != this->type.media_type.video && + info.media_subtype != this->type.media_subtype.raw) + return SPA_RESULT_INVALID_MEDIA_TYPE; + + if (spa_format_video_raw_parse(format, &info.info.raw, &this->type.format_video) < 0) + return SPA_RESULT_INVALID_MEDIA_TYPE; + + if (!(flags & SPA_NODE_PARAM_FLAG_TEST_ONLY)) { + port->current_format = info; + port->have_format = true; + } + } return SPA_RESULT_OK; } diff --git a/spa/plugins/ffmpeg/ffmpeg-enc.c b/spa/plugins/ffmpeg/ffmpeg-enc.c index 829cec02..7fb7aed9 100644 --- a/spa/plugins/ffmpeg/ffmpeg-enc.c +++ b/spa/plugins/ffmpeg/ffmpeg-enc.c @@ -26,7 +26,8 @@ #include <spa/type-map.h> #include <spa/node.h> #include <spa/video/format-utils.h> -#include <lib/props.h> + +#include <lib/pod.h> #define IS_VALID_PORT(this,d,id) ((id) == 0) #define MAX_BUFFERS 32 @@ -218,7 +219,8 @@ static int port_enum_formats(struct spa_node *node, enum spa_direction direction, uint32_t port_id, uint32_t *index, const struct spa_pod_object *filter, - struct spa_pod_builder *builder) + struct spa_pod_builder *builder, + struct spa_pod **param) { //struct impl *this = SPA_CONTAINER_OF (node, struct impl, node); //struct port *port; @@ -227,6 +229,7 @@ static int port_enum_formats(struct spa_node *node, switch (*index) { case 0: + *param = NULL; break; default: return SPA_RESULT_ENUM_END; @@ -238,7 +241,8 @@ static int port_get_format(struct spa_node *node, enum spa_direction direction, uint32_t port_id, uint32_t *index, const struct spa_pod_object *filter, - struct spa_pod_builder *builder) + struct spa_pod_builder *builder, + struct spa_pod **param) { struct impl *this = SPA_CONTAINER_OF(node, struct impl, node); struct port *port; @@ -252,6 +256,8 @@ static int port_get_format(struct spa_node *node, if (*index > 0) return SPA_RESULT_ENUM_END; + *param = NULL; + return SPA_RESULT_OK; } @@ -264,28 +270,40 @@ spa_ffmpeg_enc_node_port_enum_params(struct spa_node *node, { struct impl *this = SPA_CONTAINER_OF(node, struct impl, node); struct type *t = &this->type; + uint32_t offset; + struct spa_pod *param; + int res; + offset = builder->offset; + + next: if (id == t->param.idList) { uint32_t list[] = { t->param.idEnumFormat, t->param.idFormat }; if (*index < SPA_N_ELEMENTS(list)) - spa_pod_builder_object(builder, id, t->param.List, + param = spa_pod_builder_object(builder, id, t->param.List, ":", t->param.listId, "I", list[*index]); else return SPA_RESULT_ENUM_END; } else if (id == t->param.idEnumFormat) { - return port_enum_formats(node, direction, port_id, index, filter, builder); + if ((res = port_enum_formats(node, direction, port_id, index, filter, builder, ¶m)) < 0) + return res; } else if (id == t->param.idFormat) { - return port_get_format(node, direction, port_id, index, filter, builder); + if ((res = port_get_format(node, direction, port_id, index, filter, builder, ¶m)) < 0) + return res; } else return SPA_RESULT_UNKNOWN_PARAM; (*index)++; + spa_pod_builder_reset(builder, offset); + if (spa_pod_filter(builder, param, (struct spa_pod*)filter) < 0) + goto next; + return SPA_RESULT_OK; } diff --git a/spa/plugins/support/logger.c b/spa/plugins/support/logger.c index f181f9a5..bc7bd6a9 100644 --- a/spa/plugins/support/logger.c +++ b/spa/plugins/support/logger.c @@ -31,7 +31,7 @@ #include <spa/node.h> #include <spa/param-alloc.h> #include <spa/list.h> -#include <lib/props.h> +#include <lib/pod.h> #define NAME "logger" diff --git a/spa/plugins/support/mapper.c b/spa/plugins/support/mapper.c index 9c4ff2a0..2b1807c1 100644 --- a/spa/plugins/support/mapper.c +++ b/spa/plugins/support/mapper.c @@ -31,7 +31,6 @@ #include <spa/node.h> #include <spa/param-alloc.h> #include <spa/list.h> -#include <lib/props.h> #define NAME "mapper" diff --git a/spa/plugins/test/fakesink.c b/spa/plugins/test/fakesink.c index e4ce4ba9..2556f389 100644 --- a/spa/plugins/test/fakesink.c +++ b/spa/plugins/test/fakesink.c @@ -30,7 +30,7 @@ #include <spa/node.h> #include <spa/param-alloc.h> #include <spa/list.h> -#include <lib/props.h> +#include <lib/pod.h> #define NAME "fakesink" @@ -130,6 +130,8 @@ static int impl_node_enum_params(struct spa_node *node, { struct impl *this; struct type *t; + uint32_t offset; + struct spa_pod *param; spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS); spa_return_val_if_fail(builder != NULL, SPA_RESULT_INVALID_ARGUMENTS); @@ -137,11 +139,14 @@ static int impl_node_enum_params(struct spa_node *node, this = SPA_CONTAINER_OF(node, struct impl, node); t = &this->type; + offset = builder->offset; + + next: if (id == t->param.idList) { if (*index > 0) return SPA_RESULT_ENUM_END; - spa_pod_builder_object(builder, + param = spa_pod_builder_object(builder, id, t->param.List, ":", t->param.listId, "I", t->param.idProps); } @@ -149,7 +154,7 @@ static int impl_node_enum_params(struct spa_node *node, if (*index > 0) return SPA_RESULT_ENUM_END; - spa_pod_builder_object(builder, + param = spa_pod_builder_object(builder, id, t->props, ":", t->prop_live, "b", this->props.live); } @@ -158,6 +163,10 @@ static int impl_node_enum_params(struct spa_node *node, (*index)++; + spa_pod_builder_reset(builder, offset); + if (spa_pod_filter(builder, param, (struct spa_pod*)filter) < 0) + goto next; + return SPA_RESULT_OK; } @@ -421,7 +430,8 @@ static int port_enum_formats(struct spa_node *node, enum spa_direction direction, uint32_t port_id, uint32_t *index, const struct spa_pod_object *filter, - struct spa_pod_builder *builder) + struct spa_pod_builder *builder, + struct spa_pod **param) { return SPA_RESULT_ENUM_END; } @@ -430,7 +440,8 @@ static int port_get_format(struct spa_node *node, enum spa_direction direction, uint32_t port_id, uint32_t *index, const struct spa_pod_object *filter, - struct spa_pod_builder *builder) + struct spa_pod_builder *builder, + struct spa_pod **param) { struct impl *this = SPA_CONTAINER_OF(node, struct impl, node); @@ -440,7 +451,7 @@ static int port_get_format(struct spa_node *node, if (*index > 0) return SPA_RESULT_ENUM_END; - spa_pod_builder_primitive(builder, SPA_MEMBER(this->format_buffer, 0, struct spa_pod)); + *param = SPA_MEMBER(this->format_buffer, 0, struct spa_pod); return SPA_RESULT_OK; } @@ -454,6 +465,9 @@ impl_node_port_enum_params(struct spa_node *node, { struct impl *this; struct type *t; + uint32_t offset; + struct spa_pod *param; + int res; spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS); spa_return_val_if_fail(index != NULL, SPA_RESULT_INVALID_ARGUMENTS); @@ -464,6 +478,9 @@ impl_node_port_enum_params(struct spa_node *node, spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT); + offset = builder->offset; + + next: if (id == t->param.idList) { uint32_t list[] = { t->param.idEnumFormat, t->param.idFormat, @@ -471,22 +488,24 @@ impl_node_port_enum_params(struct spa_node *node, t->param.idMeta }; if (*index < SPA_N_ELEMENTS(list)) - spa_pod_builder_object(builder, id, t->param.List, + param = spa_pod_builder_object(builder, id, t->param.List, ":", t->param.listId, "I", list[*index]); else return SPA_RESULT_ENUM_END; } else if (id == t->param.idEnumFormat) { - return port_enum_formats(node, direction, port_id, index, filter, builder); + if ((res = port_enum_formats(node, direction, port_id, index, filter, builder, ¶m)) < 0) + return res; } else if (id == t->param.idFormat) { - return port_get_format(node, direction, port_id, index, filter, builder); + if ((res = port_get_format(node, direction, port_id, index, filter, builder, ¶m)) < 0) + return res; } else if (id == t->param.idBuffers) { if (*index > 0) return SPA_RESULT_ENUM_END; - spa_pod_builder_object(builder, + param = spa_pod_builder_object(builder, id, t->param_alloc_buffers.Buffers, ":", t->param_alloc_buffers.size, "i", 128, ":", t->param_alloc_buffers.stride, "i", 1, @@ -497,7 +516,7 @@ impl_node_port_enum_params(struct spa_node *node, else if (id == t->param.idMeta) { switch (*index) { case 0: - spa_pod_builder_object(builder, + param = spa_pod_builder_object(builder, id, t->param_alloc_meta_enable.MetaEnable, ":", t->param_alloc_meta_enable.type, "I", t->meta.Header, ":", t->param_alloc_meta_enable.size, "i", sizeof(struct spa_meta_header)); @@ -511,6 +530,10 @@ impl_node_port_enum_params(struct spa_node *node, (*index)++; + spa_pod_builder_reset(builder, offset); + if (spa_pod_filter(builder, param, (struct spa_pod*)filter) < 0) + goto next; + return SPA_RESULT_OK; } diff --git a/spa/plugins/test/fakesrc.c b/spa/plugins/test/fakesrc.c index 8fa752f5..47a03fe0 100644 --- a/spa/plugins/test/fakesrc.c +++ b/spa/plugins/test/fakesrc.c @@ -30,7 +30,8 @@ #include <spa/node.h> #include <spa/param-alloc.h> #include <spa/list.h> -#include <lib/props.h> + +#include <lib/pod.h> #define NAME "fakesrc" @@ -136,6 +137,8 @@ static int impl_node_enum_params(struct spa_node *node, { struct impl *this; struct type *t; + uint32_t offset; + struct spa_pod *param; spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS); spa_return_val_if_fail(index != NULL, SPA_RESULT_INVALID_ARGUMENTS); @@ -144,21 +147,24 @@ static int impl_node_enum_params(struct spa_node *node, this = SPA_CONTAINER_OF(node, struct impl, node); t = &this->type; + offset = builder->offset; + + next: if (id == t->param.idList) { if (*index > 0) return SPA_RESULT_ENUM_END; - spa_pod_builder_object(builder, + param = spa_pod_builder_object(builder, id, t->param.List, ":", t->param.listId, "I", t->param.idProps); } - if (id == t->param.idProps) { + else if (id == t->param.idProps) { struct props *p = &this->props; if (*index > 0) return SPA_RESULT_ENUM_END; - spa_pod_builder_object(builder, + param = spa_pod_builder_object(builder, id, t->props, ":", t->prop_live, "b", p->live, ":", t->prop_pattern, "Ie", p->pattern, @@ -169,6 +175,10 @@ static int impl_node_enum_params(struct spa_node *node, (*index)++; + spa_pod_builder_reset(builder, offset); + if (spa_pod_filter(builder, param, (struct spa_pod*)filter) < 0) + goto next; + return SPA_RESULT_OK; } @@ -436,7 +446,8 @@ static int port_enum_formats(struct spa_node *node, enum spa_direction direction, uint32_t port_id, uint32_t *index, const struct spa_pod_object *filter, - struct spa_pod_builder *builder) + struct spa_pod_builder *builder, + struct spa_pod **param) { return SPA_RESULT_ENUM_END; } @@ -445,7 +456,8 @@ static int port_get_format(struct spa_node *node, enum spa_direction direction, uint32_t port_id, uint32_t *index, const struct spa_pod_object *filter, - struct spa_pod_builder *builder) + struct spa_pod_builder *builder, + struct spa_pod **param) { struct impl *this = SPA_CONTAINER_OF(node, struct impl, node); @@ -454,7 +466,7 @@ static int port_get_format(struct spa_node *node, if (*index > 0) return SPA_RESULT_ENUM_END; - spa_pod_builder_primitive(builder, SPA_MEMBER(this->format_buffer, 0, struct spa_pod)); + *param = SPA_MEMBER(this->format_buffer, 0, struct spa_pod); return SPA_RESULT_OK; } @@ -468,6 +480,9 @@ impl_node_port_enum_params(struct spa_node *node, { struct impl *this; struct type *t; + uint32_t offset; + struct spa_pod *param; + int res; spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS); spa_return_val_if_fail(index != NULL, SPA_RESULT_INVALID_ARGUMENTS); @@ -478,6 +493,9 @@ impl_node_port_enum_params(struct spa_node *node, spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT); + offset = builder->offset; + + next: if (id == t->param.idList) { uint32_t list[] = { t->param.idEnumFormat, t->param.idFormat, @@ -485,22 +503,24 @@ impl_node_port_enum_params(struct spa_node *node, t->param.idMeta }; if (*index < SPA_N_ELEMENTS(list)) - spa_pod_builder_object(builder, id, t->param.List, + param = spa_pod_builder_object(builder, id, t->param.List, ":", t->param.listId, "I", list[*index]); else return SPA_RESULT_ENUM_END; } else if (id == t->param.idEnumFormat) { - return port_enum_formats(node, direction, port_id, index, filter, builder); + if ((res = port_enum_formats(node, direction, port_id, index, filter, builder, ¶m)) < 0) + return res; } else if (id == t->param.idFormat) { - return port_get_format(node, direction, port_id, index, filter, builder); + if ((res = port_get_format(node, direction, port_id, index, filter, builder, ¶m)) < 0) + return res; } else if (id == t->param.idBuffers) { if (*index > 0) return SPA_RESULT_ENUM_END; - spa_pod_builder_object(builder, + param = spa_pod_builder_object(builder, id, t->param_alloc_buffers.Buffers, ":", t->param_alloc_buffers.size, "i", 128, ":", t->param_alloc_buffers.stride, "i", 1, @@ -511,7 +531,7 @@ impl_node_port_enum_params(struct spa_node *node, else if (id == t->param.idMeta) { switch (*index) { case 0: - spa_pod_builder_object(builder, + param = spa_pod_builder_object(builder, id, t->param_alloc_meta_enable.MetaEnable, ":", t->param_alloc_meta_enable.type, "I", t->meta.Header, ":", t->param_alloc_meta_enable.size, "i", sizeof(struct spa_meta_header)); @@ -525,6 +545,10 @@ impl_node_port_enum_params(struct spa_node *node, (*index)++; + spa_pod_builder_reset(builder, offset); + if (spa_pod_filter(builder, param, (struct spa_pod*)filter) < 0) + goto next; + return SPA_RESULT_OK; } diff --git a/spa/plugins/v4l2/v4l2-source.c b/spa/plugins/v4l2/v4l2-source.c index 5a76fb60..3a331ed3 100644 --- a/spa/plugins/v4l2/v4l2-source.c +++ b/spa/plugins/v4l2/v4l2-source.c @@ -32,8 +32,9 @@ #include <spa/loop.h> #include <spa/param-alloc.h> #include <spa/type-map.h> + #include <lib/debug.h> -#include <lib/props.h> +#include <lib/pod.h> #define NAME "v4l2-source" @@ -173,6 +174,8 @@ static int impl_node_enum_params(struct spa_node *node, { struct impl *this; struct type *t; + struct spa_pod *param; + uint32_t offset; spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS); spa_return_val_if_fail(index != NULL, SPA_RESULT_INVALID_ARGUMENTS); @@ -181,11 +184,14 @@ static int impl_node_enum_params(struct spa_node *node, this = SPA_CONTAINER_OF(node, struct impl, node); t = &this->type; + offset = builder->offset; + + next: if (id == t->param.idList) { if (*index > 0) return SPA_RESULT_ENUM_END; - spa_pod_builder_object(builder, + param = spa_pod_builder_object(builder, id, t->param.List, ":", t->param.listId, "I", t->param.idProps); } @@ -195,16 +201,20 @@ static int impl_node_enum_params(struct spa_node *node, if (*index > 0) return SPA_RESULT_ENUM_END; - spa_pod_builder_object(builder, t->param.idProps, t->props, - ":", t->prop_device, "S", p->device, sizeof(p->device), - ":", t->prop_device_name, "S-r", p->device_name, sizeof(p->device_name), - ":", t->prop_device_fd, "i-r", p->device_fd); + param = spa_pod_builder_object(builder, t->param.idProps, t->props, + ":", t->prop_device, "S", p->device, sizeof(p->device), + ":", t->prop_device_name, "S-r", p->device_name, sizeof(p->device_name), + ":", t->prop_device_fd, "i-r", p->device_fd); } else return SPA_RESULT_UNKNOWN_PARAM; (*index)++; + spa_pod_builder_reset(builder, offset); + if (spa_pod_filter(builder, param, (struct spa_pod*)filter) < 0) + goto next; + return SPA_RESULT_OK; } @@ -459,7 +469,8 @@ static int port_get_format(struct spa_node *node, enum spa_direction direction, uint32_t port_id, uint32_t *index, const struct spa_pod_object *filter, - struct spa_pod_builder *builder) + struct spa_pod_builder *builder, + struct spa_pod **param) { struct impl *this = SPA_CONTAINER_OF(node, struct impl, node); struct type *t = &this->type; @@ -493,7 +504,7 @@ static int port_get_format(struct spa_node *node, } else return SPA_RESULT_NO_FORMAT; - spa_pod_builder_pop(builder); + *param = spa_pod_builder_pop_deref(builder); return SPA_RESULT_OK; } @@ -509,6 +520,9 @@ static int impl_node_port_enum_params(struct spa_node *node, struct impl *this; struct port *port; struct type *t; + struct spa_pod *param; + uint32_t offset; + int res; spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS); spa_return_val_if_fail(index != NULL, SPA_RESULT_INVALID_ARGUMENTS); @@ -521,6 +535,9 @@ static int impl_node_port_enum_params(struct spa_node *node, port = &this->out_ports[port_id]; + offset = builder->offset; + + next: if (id == t->param.idList) { uint32_t list[] = { t->param.idEnumFormat, t->param.idFormat, @@ -528,7 +545,7 @@ static int impl_node_port_enum_params(struct spa_node *node, t->param.idMeta }; if (*index < SPA_N_ELEMENTS(list)) - spa_pod_builder_object(builder, id, t->param.List, + param = spa_pod_builder_object(builder, id, t->param.List, ":", t->param.listId, "I", list[*index]); else return SPA_RESULT_ENUM_END; @@ -537,7 +554,8 @@ static int impl_node_port_enum_params(struct spa_node *node, return spa_v4l2_enum_format(this, index, filter, builder); } else if (id == t->param.idFormat) { - return port_get_format(node, direction, port_id, index, filter, builder); + if((res = port_get_format(node, direction, port_id, index, filter, builder, ¶m)) < 0) + return res; } else if (id == t->param.idBuffers) { if (!port->have_format) @@ -545,7 +563,7 @@ static int impl_node_port_enum_params(struct spa_node *node, if (*index > 0) return SPA_RESULT_ENUM_END; - spa_pod_builder_object(builder, + param = spa_pod_builder_object(builder, id, t->param_alloc_buffers.Buffers, ":", t->param_alloc_buffers.size, "i", port->fmt.fmt.pix.sizeimage, ":", t->param_alloc_buffers.stride, "i", port->fmt.fmt.pix.bytesperline, @@ -556,7 +574,7 @@ static int impl_node_port_enum_params(struct spa_node *node, else if (id == t->param.idMeta) { switch (*index) { case 0: - spa_pod_builder_object(builder, + param = spa_pod_builder_object(builder, id, t->param_alloc_meta_enable.MetaEnable, ":", t->param_alloc_meta_enable.type, "I", t->meta.Header, ":", t->param_alloc_meta_enable.size, "i", sizeof(struct spa_meta_header)); @@ -570,6 +588,10 @@ static int impl_node_port_enum_params(struct spa_node *node, (*index)++; + spa_pod_builder_reset(builder, offset); + if (spa_pod_filter(builder, param, (struct spa_pod*)filter) < 0) + goto next; + return SPA_RESULT_OK; } diff --git a/spa/plugins/videotestsrc/videotestsrc.c b/spa/plugins/videotestsrc/videotestsrc.c index c8d88952..9089a4e5 100644 --- a/spa/plugins/videotestsrc/videotestsrc.c +++ b/spa/plugins/videotestsrc/videotestsrc.c @@ -33,8 +33,7 @@ #include <spa/list.h> #include <spa/video/format-utils.h> -#include <lib/format.h> -#include <lib/props.h> +#include <lib/pod.h> #define NAME "videotestsrc" @@ -157,6 +156,8 @@ static int impl_node_enum_params(struct spa_node *node, { struct impl *this; struct type *t; + uint32_t offset; + struct spa_pod *param; spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS); spa_return_val_if_fail(builder != NULL, SPA_RESULT_INVALID_ARGUMENTS); @@ -164,11 +165,14 @@ static int impl_node_enum_params(struct spa_node *node, this = SPA_CONTAINER_OF(node, struct impl, node); t = &this->type; + offset = builder->offset; + + next: if (id == t->param.idList) { if (*index > 0) return SPA_RESULT_ENUM_END; - spa_pod_builder_object(builder, + param = spa_pod_builder_object(builder, id, t->param.List, ":", t->param.listId, "I", t->param.idProps); } @@ -178,7 +182,7 @@ static int impl_node_enum_params(struct spa_node *node, if (*index > 0) return SPA_RESULT_ENUM_END; - spa_pod_builder_object(builder, + param = spa_pod_builder_object(builder, id, t->props, ":", t->prop_live, "b", p->live, ":", t->prop_pattern, "Ie", p->pattern, @@ -190,6 +194,10 @@ static int impl_node_enum_params(struct spa_node *node, (*index)++; + spa_pod_builder_reset(builder, offset); + if (spa_pod_filter(builder, param, (struct spa_pod*)filter) < 0) + goto next; + return SPA_RESULT_OK; } @@ -451,21 +459,15 @@ static int port_enum_formats(struct spa_node *node, enum spa_direction direction, uint32_t port_id, uint32_t *index, const struct spa_pod_object *filter, - struct spa_pod_builder *builder) + struct spa_pod_builder *builder, + struct spa_pod **param) { struct impl *this = SPA_CONTAINER_OF(node, struct impl, node); - struct spa_pod_object *fmt; - uint8_t buffer[256]; - struct spa_pod_builder b = { NULL, }; struct type *t = &this->type; - int res; - - next: - spa_pod_builder_init(&b, buffer, sizeof(buffer)); switch (*index) { case 0: - fmt = spa_pod_builder_object(&b, + *param = spa_pod_builder_object(builder, t->param.idEnumFormat, t->format, "I", t->media_type.video, "I", t->media_subtype.raw, @@ -482,11 +484,6 @@ static int port_enum_formats(struct spa_node *node, default: return SPA_RESULT_ENUM_END; } - (*index)++; - - if ((res = spa_pod_object_filter(fmt, filter, builder)) != SPA_RESULT_OK) - goto next; - return SPA_RESULT_OK; } @@ -494,18 +491,18 @@ static int port_get_format(struct spa_node *node, enum spa_direction direction, uint32_t port_id, uint32_t *index, const struct spa_pod_object *filter, - struct spa_pod_builder *builder) + struct spa_pod_builder *builder, + struct spa_pod **param) { struct impl *this = SPA_CONTAINER_OF(node, struct impl, node); struct type *t = &this->type; if (!this->have_format) return SPA_RESULT_NO_FORMAT; - if (*index > 0) return SPA_RESULT_ENUM_END; - spa_pod_builder_object(builder, + *param = spa_pod_builder_object(builder, t->param.idFormat, t->format, "I", t->media_type.video, "I", t->media_subtype.raw, @@ -525,6 +522,9 @@ impl_node_port_enum_params(struct spa_node *node, { struct impl *this; struct type *t; + uint32_t offset; + struct spa_pod *param; + int res; spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS); spa_return_val_if_fail(index != NULL, SPA_RESULT_INVALID_ARGUMENTS); @@ -535,6 +535,9 @@ impl_node_port_enum_params(struct spa_node *node, spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT); + offset = builder->offset; + + next: if (id == t->param.idList) { uint32_t list[] = { t->param.idEnumFormat, t->param.idFormat, @@ -542,16 +545,18 @@ impl_node_port_enum_params(struct spa_node *node, t->param.idMeta }; if (*index < SPA_N_ELEMENTS(list)) - spa_pod_builder_object(builder, id, t->param.List, + param = spa_pod_builder_object(builder, id, t->param.List, ":", t->param.listId, "I", list[*index]); else return SPA_RESULT_ENUM_END; } else if (id == t->param.idEnumFormat) { - return port_enum_formats(node, direction, port_id, index, filter, builder); + if ((res = port_enum_formats(node, direction, port_id, index, filter, builder, ¶m)) < 0) + return res; } else if (id == t->param.idFormat) { - return port_get_format(node, direction, port_id, index, filter, builder); + if ((res = port_get_format(node, direction, port_id, index, filter, builder, ¶m)) < 0) + return res; } else if (id == t->param.idBuffers) { struct spa_video_info_raw *raw_info = &this->current_format.info.raw; @@ -561,7 +566,7 @@ impl_node_port_enum_params(struct spa_node *node, if (*index > 0) return SPA_RESULT_ENUM_END; - spa_pod_builder_object(builder, + param = spa_pod_builder_object(builder, id, t->param_alloc_buffers.Buffers, ":", t->param_alloc_buffers.size, "i", this->stride * raw_info->size.height, ":", t->param_alloc_buffers.stride, "i", this->stride, @@ -575,7 +580,7 @@ impl_node_port_enum_params(struct spa_node *node, switch (*index) { case 0: - spa_pod_builder_object(builder, + param = spa_pod_builder_object(builder, id, t->param_alloc_meta_enable.MetaEnable, ":", t->param_alloc_meta_enable.type, "I", t->meta.Header, ":", t->param_alloc_meta_enable.size, "i", sizeof(struct spa_meta_header)); @@ -585,8 +590,15 @@ impl_node_port_enum_params(struct spa_node *node, return SPA_RESULT_ENUM_END; } } + else + return SPA_RESULT_UNKNOWN_PARAM; + (*index)++; + spa_pod_builder_reset(builder, offset); + if (spa_pod_filter(builder, param, (struct spa_pod*)filter) < 0) + goto next; + return SPA_RESULT_OK; } diff --git a/spa/plugins/volume/volume.c b/spa/plugins/volume/volume.c index 17d8aafc..0eae0b30 100644 --- a/spa/plugins/volume/volume.c +++ b/spa/plugins/volume/volume.c @@ -26,8 +26,8 @@ #include <spa/list.h> #include <spa/audio/format-utils.h> #include <spa/param-alloc.h> -#include <lib/props.h> -#include <lib/format.h> + +#include <lib/pod.h> #define NAME "volume" @@ -143,6 +143,8 @@ static int impl_node_enum_params(struct spa_node *node, { struct impl *this; struct type *t; + uint32_t offset; + struct spa_pod *param; spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS); spa_return_val_if_fail(index != NULL, SPA_RESULT_INVALID_ARGUMENTS); @@ -151,11 +153,14 @@ static int impl_node_enum_params(struct spa_node *node, this = SPA_CONTAINER_OF(node, struct impl, node); t = &this->type; + offset = builder->offset; + + next: if (id == t->param.idList) { if (*index > 0) return SPA_RESULT_ENUM_END; - spa_pod_builder_object(builder, + param = spa_pod_builder_object(builder, id, t->param.List, ":", t->param.listId, "I", t->param.idProps); } @@ -165,7 +170,7 @@ static int impl_node_enum_params(struct spa_node *node, if(*index > 0) return SPA_RESULT_ENUM_END; - spa_pod_builder_object(builder, + param = spa_pod_builder_object(builder, id, t->props, ":", t->prop_volume, "dr", p->volume, 2, 0.0, 10.0, ":", t->prop_mute, "b", p->mute); @@ -175,6 +180,10 @@ static int impl_node_enum_params(struct spa_node *node, (*index)++; + spa_pod_builder_reset(builder, offset); + if (spa_pod_filter(builder, param, (struct spa_pod*)filter) < 0) + goto next; + return SPA_RESULT_OK; } @@ -318,21 +327,15 @@ static int port_enum_formats(struct spa_node *node, enum spa_direction direction, uint32_t port_id, uint32_t *index, const struct spa_pod_object *filter, - struct spa_pod_builder *builder) + struct spa_pod_builder *builder, + struct spa_pod **param) { struct impl *this = SPA_CONTAINER_OF(node, struct impl, node); - int res; - struct spa_pod_object *fmt; - uint8_t buffer[1024]; - struct spa_pod_builder b = { NULL, }; struct type *t = &this->type; - next: - spa_pod_builder_init(&b, buffer, sizeof(buffer)); - switch (*index) { case 0: - fmt = spa_pod_builder_object(&b, + *param = spa_pod_builder_object(builder, t->param.idEnumFormat, t->format, "I", t->media_type.audio, "I", t->media_subtype.raw, @@ -345,11 +348,6 @@ static int port_enum_formats(struct spa_node *node, default: return SPA_RESULT_ENUM_END; } - (*index)++; - - if ((res = spa_pod_object_filter(fmt, filter, builder)) != SPA_RESULT_OK) - goto next; - return SPA_RESULT_OK; } @@ -357,7 +355,8 @@ static int port_get_format(struct spa_node *node, enum spa_direction direction, uint32_t port_id, uint32_t *index, const struct spa_pod_object *filter, - struct spa_pod_builder *builder) + struct spa_pod_builder *builder, + struct spa_pod **param) { struct impl *this = SPA_CONTAINER_OF(node, struct impl, node); struct port *port; @@ -370,7 +369,7 @@ static int port_get_format(struct spa_node *node, if (*index > 0) return SPA_RESULT_ENUM_END; - spa_pod_builder_object(builder, + *param = spa_pod_builder_object(builder, t->param.idFormat, t->format, "I", t->media_type.audio, "I", t->media_subtype.raw, @@ -391,6 +390,9 @@ impl_node_port_enum_params(struct spa_node *node, struct impl *this; struct type *t; struct port *port; + uint32_t offset; + struct spa_pod *param; + int res; spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS); spa_return_val_if_fail(index != NULL, SPA_RESULT_INVALID_ARGUMENTS); @@ -403,6 +405,9 @@ impl_node_port_enum_params(struct spa_node *node, port = GET_PORT(this, direction, port_id); + offset = builder->offset; + + next: if (id == t->param.idList) { uint32_t list[] = { t->param.idEnumFormat, t->param.idFormat, @@ -410,16 +415,18 @@ impl_node_port_enum_params(struct spa_node *node, t->param.idMeta }; if (*index < SPA_N_ELEMENTS(list)) - spa_pod_builder_object(builder, id, t->param.List, + param = spa_pod_builder_object(builder, id, t->param.List, ":", t->param.listId, "I", list[*index]); else return SPA_RESULT_ENUM_END; } else if (id == t->param.idEnumFormat) { - return port_enum_formats(node, direction, port_id, index, filter, builder); + if ((res = port_enum_formats(node, direction, port_id, index, filter, builder, ¶m)) < 0) + return res; } else if (id == t->param.idFormat) { - return port_get_format(node, direction, port_id, index, filter, builder); + if ((res = port_get_format(node, direction, port_id, index, filter, builder, ¶m)) < 0) + return res; } else if (id == t->param.idBuffers) { if (!port->have_format) @@ -427,7 +434,7 @@ impl_node_port_enum_params(struct spa_node *node, if (*index > 0) return SPA_RESULT_ENUM_END; - spa_pod_builder_object(builder, + param = spa_pod_builder_object(builder, id, t->param_alloc_buffers.Buffers, ":", t->param_alloc_buffers.size, "iru", 1024 * this->bpf, 2, 16 * this->bpf, @@ -440,7 +447,7 @@ impl_node_port_enum_params(struct spa_node *node, else if (id == t->param.idMeta) { switch (*index) { case 0: - spa_pod_builder_object(builder, + param = spa_pod_builder_object(builder, id, t->param_alloc_meta_enable.MetaEnable, ":", t->param_alloc_meta_enable.type, "I", t->meta.Header, ":", t->param_alloc_meta_enable.size, "i", sizeof(struct spa_meta_header)); @@ -454,6 +461,10 @@ impl_node_port_enum_params(struct spa_node *node, (*index)++; + spa_pod_builder_reset(builder, offset); + if (spa_pod_filter(builder, param, (struct spa_pod*)filter) < 0) + goto next; + return SPA_RESULT_OK; } |