mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-01 22:58:50 -04:00
Implement param filtering
Make a new pod filter function and use it in the plugins to filter in enum_params. Small tweaks to the pod_builder
This commit is contained in:
parent
cc47fb7e3a
commit
58451d626c
35 changed files with 1150 additions and 917 deletions
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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,11 +232,83 @@ 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_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 **param)
|
||||
{
|
||||
struct impl *this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
struct port *port;
|
||||
|
||||
port =
|
||||
direction == SPA_DIRECTION_INPUT ? &this->in_ports[port_id] : &this->out_ports[port_id];
|
||||
|
||||
if (!port->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
|
||||
if (*index > 0)
|
||||
return SPA_RESULT_ENUM_END;
|
||||
|
||||
*param = NULL;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
spa_ffmpeg_dec_node_port_enum_params(struct spa_node *node,
|
||||
enum spa_direction direction, uint32_t port_id,
|
||||
uint32_t id, uint32_t *index,
|
||||
const struct spa_pod_object *filter,
|
||||
struct spa_pod_builder *builder)
|
||||
{
|
||||
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))
|
||||
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) {
|
||||
if ((res = port_enum_formats(node, direction, port_id, index, filter, builder, ¶m)) < 0)
|
||||
return res;
|
||||
}
|
||||
else if (id == t->param.idFormat) {
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
@ -259,85 +356,6 @@ static int port_set_format(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 impl *this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
struct port *port;
|
||||
|
||||
port =
|
||||
direction == SPA_DIRECTION_INPUT ? &this->in_ports[port_id] : &this->out_ports[port_id];
|
||||
|
||||
if (!port->have_format)
|
||||
return SPA_RESULT_NO_FORMAT;
|
||||
|
||||
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;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
spa_ffmpeg_dec_node_port_enum_params(struct spa_node *node,
|
||||
enum spa_direction direction, uint32_t port_id,
|
||||
uint32_t id, uint32_t *index,
|
||||
const struct spa_pod_object *filter,
|
||||
struct spa_pod_builder *builder)
|
||||
{
|
||||
struct impl *this = SPA_CONTAINER_OF(node, struct impl, node);
|
||||
struct type *t = &this->type;
|
||||
|
||||
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,
|
||||
":", 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);
|
||||
}
|
||||
else if (id == t->param.idFormat) {
|
||||
return port_get_format(node, direction, port_id, index, filter, builder);
|
||||
}
|
||||
else
|
||||
return SPA_RESULT_UNKNOWN_PARAM;
|
||||
|
||||
(*index)++;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
spa_ffmpeg_dec_node_port_set_param(struct spa_node *node,
|
||||
enum spa_direction direction, uint32_t port_id,
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
||||
|
|
|
|||
|
|
@ -31,7 +31,6 @@
|
|||
#include <spa/node.h>
|
||||
#include <spa/param-alloc.h>
|
||||
#include <spa/list.h>
|
||||
#include <lib/props.h>
|
||||
|
||||
#define NAME "mapper"
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue