Unify props, params and formats

Make enum_params and set_param to configure properties, format
and other parameters. This allows us to remove some duplicate
code and make the properties and parameters much more extensible.
Use the object id to mark the id of the parameter.
Remove the spa_format and spa_props.
We can now make the client-node easier by merging the various
format methods into the params.
Make the stream API more powerful now that we can pass params
around.
This commit is contained in:
Wim Taymans 2017-11-07 17:39:31 +01:00
parent b6ee67905d
commit f3bca48398
87 changed files with 3773 additions and 3580 deletions

View file

@ -32,7 +32,6 @@
#include <spa/loop.h>
#include <spa/param-alloc.h>
#include <spa/type-map.h>
#include <spa/format-builder.h>
#include <lib/debug.h>
#include <lib/props.h>
@ -69,6 +68,7 @@ struct type {
uint32_t prop_device;
uint32_t prop_device_name;
uint32_t prop_device_fd;
struct spa_type_param param;
struct spa_type_media_type media_type;
struct spa_type_media_subtype media_subtype;
struct spa_type_media_subtype_video media_subtype_video;
@ -91,6 +91,7 @@ static inline void init_type(struct type *type, struct spa_type_map *map)
type->prop_device = spa_type_map_get_id(map, SPA_TYPE_PROPS__device);
type->prop_device_name = spa_type_map_get_id(map, SPA_TYPE_PROPS__deviceName);
type->prop_device_fd = spa_type_map_get_id(map, SPA_TYPE_PROPS__deviceFd);
spa_type_param_map(map, &type->param);
spa_type_media_type_map(map, &type->media_type);
spa_type_media_subtype_map(map, &type->media_subtype);
spa_type_media_subtype_video_map(map, &type->media_subtype_video);
@ -136,7 +137,6 @@ struct port {
struct spa_source source;
struct spa_port_info info;
uint8_t params_buffer[1024];
struct spa_port_io *io;
int64_t last_ticks;
@ -168,28 +168,51 @@ struct impl {
#include "v4l2-utils.c"
static int impl_node_get_props(struct spa_node *node, struct spa_props **props)
static int get_props(struct impl *this, uint32_t *index,
const struct spa_pod_object *filter,
struct spa_pod_builder *builder)
{
struct impl *this;
struct spa_pod_builder b = { NULL, };
struct type *t;
struct type *t = &this->type;
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail(props != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF(node, struct impl, node);
t = &this->type;
spa_pod_builder_init(&b, this->props_buffer, sizeof(this->props_buffer));
*props = spa_pod_builder_props(&b, t->props,
switch (*index) {
case 0:
spa_pod_builder_object(builder, t->param.idProps, t->props,
":", t->prop_device, "S", this->props.device, sizeof(this->props.device),
":", t->prop_device_name, "S-r", this->props.device_name, sizeof(this->props.device_name),
":", t->prop_device_fd, "i-r", this->props.device_fd);
break;
default:
return SPA_RESULT_ENUM_END;
}
(*index)++;
return SPA_RESULT_OK;
}
static int impl_node_set_props(struct spa_node *node, const struct spa_props *props)
static int impl_node_enum_params(struct spa_node *node,
uint32_t id, uint32_t *index,
const struct spa_pod_object *filter,
struct spa_pod_builder *builder)
{
struct impl *this;
struct type *t;
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail(index != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail(builder != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF(node, struct impl, node);
t = &this->type;
if (id == t->param.idProps)
return get_props(this, index, filter, builder);
return SPA_RESULT_UNKNOWN_PARAM;
}
static int impl_node_set_param(struct spa_node *node,
uint32_t id, uint32_t flags,
const struct spa_pod_object *param)
{
struct impl *this;
struct type *t;
@ -199,12 +222,16 @@ static int impl_node_set_props(struct spa_node *node, const struct spa_props *pr
this = SPA_CONTAINER_OF(node, struct impl, node);
t = &this->type;
if (props == NULL) {
reset_props(&this->props);
return SPA_RESULT_OK;
if (id == t->param.idProps) {
if (param == NULL) {
reset_props(&this->props);
return SPA_RESULT_OK;
}
spa_pod_object_parse(param,
":", t->prop_device, "?S", this->props.device, sizeof(this->props.device), NULL);
}
spa_props_parse(props,
":", t->prop_device, "?S", this->props.device, sizeof(this->props.device), NULL);
else
return SPA_RESULT_UNKNOWN_PARAM;
return SPA_RESULT_OK;
}
@ -409,41 +436,96 @@ static int impl_node_remove_port(struct spa_node *node,
return SPA_RESULT_NOT_IMPLEMENTED;
}
static int
impl_node_port_enum_formats(struct spa_node *node,
enum spa_direction direction,
uint32_t port_id,
struct spa_format **format,
const struct spa_format *filter,
uint32_t index)
static int impl_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;
int res;
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail(format != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail(info != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF(node, struct impl, node);
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT);
res = spa_v4l2_enum_format(this, format, filter, index);
*info = &this->out_ports[port_id].info;
return res;
return SPA_RESULT_OK;
}
static int impl_node_port_set_format(struct spa_node *node,
enum spa_direction direction,
uint32_t port_id,
uint32_t flags,
const struct spa_format *format)
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 impl *this = SPA_CONTAINER_OF(node, struct impl, node);
return spa_v4l2_enum_format(this, index, filter, builder);
}
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 spa_pod_frame f[1];
struct type *t = &this->type;
struct port *port = &this->out_ports[port_id];
if (!port->have_format)
return SPA_RESULT_NO_FORMAT;
if (*index > 0)
return SPA_RESULT_ENUM_END;
spa_pod_builder_push_object(builder, &f[0],
t->param.idFormat, t->format);
spa_pod_builder_add(builder,
"I", port->current_format.media_type,
"I", port->current_format.media_subtype, 0);
if (port->current_format.media_subtype == t->media_subtype.raw) {
spa_pod_builder_add(builder,
":", t->format_video.format, "I", port->current_format.info.raw.format,
":", t->format_video.size, "R", &port->current_format.info.raw.size,
":", t->format_video.framerate, "F", &port->current_format.info.raw.framerate, 0);
} else if (port->current_format.media_subtype == t->media_subtype_video.mjpg ||
port->current_format.media_subtype == t->media_subtype_video.jpeg) {
spa_pod_builder_add(builder,
":", t->format_video.size, "R", &port->current_format.info.mjpg.size,
":", t->format_video.framerate, "F", &port->current_format.info.mjpg.framerate, 0);
} else if (port->current_format.media_subtype == t->media_subtype_video.h264) {
spa_pod_builder_add(builder,
":", t->format_video.size, "R", &port->current_format.info.h264.size,
":", t->format_video.framerate, "F", &port->current_format.info.h264.framerate, 0);
} else
return SPA_RESULT_NO_FORMAT;
spa_pod_builder_pop(builder, &f[0]);
return SPA_RESULT_OK;
}
static int impl_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;
struct port *port;
struct spa_video_info info;
struct type *t;
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail(index != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail(builder != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF(node, struct impl, node);
t = &this->type;
@ -452,6 +534,66 @@ static int impl_node_port_set_format(struct spa_node *node,
port = &this->out_ports[port_id];
if (id == t->param.idList) {
uint32_t list[] = { t->param.idEnumFormat,
t->param.idFormat,
t->param.idBuffers,
t->param.idMeta };
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 if (id == t->param.idBuffers) {
if (*index > 0)
return SPA_RESULT_ENUM_END;
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,
":", t->param_alloc_buffers.buffers, "iru", MAX_BUFFERS,
2, 2, MAX_BUFFERS,
":", t->param_alloc_buffers.align, "i", 16);
}
else if (id == t->param.idMeta) {
switch (*index) {
case 0:
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;
default:
return SPA_RESULT_ENUM_END;
}
}
else
return SPA_RESULT_UNKNOWN_PARAM;
(*index)++;
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 = SPA_CONTAINER_OF(node, struct impl, node);
struct spa_video_info info;
struct type *t = &this->type;
struct port *port = &this->out_ports[port_id];
if (format == NULL) {
spa_v4l2_stream_off(this);
spa_v4l2_clear_buffers(this);
@ -459,8 +601,9 @@ static int impl_node_port_set_format(struct spa_node *node,
port->have_format = false;
return SPA_RESULT_OK;
} else {
info.media_type = SPA_FORMAT_MEDIA_TYPE(format);
info.media_subtype = SPA_FORMAT_MEDIA_SUBTYPE(format);
spa_pod_object_parse(format,
"I", &info.media_type,
"I", &info.media_subtype);
if (info.media_type != t->media_type.video) {
spa_log_error(this->log, "media type must be video");
@ -500,15 +643,15 @@ static int impl_node_port_set_format(struct spa_node *node,
}
}
if (port->have_format && !(flags & SPA_PORT_FORMAT_FLAG_TEST_ONLY)) {
if (port->have_format && !(flags & SPA_NODE_PARAM_FLAG_TEST_ONLY)) {
spa_v4l2_use_buffers(this, NULL, 0);
port->have_format = false;
}
if (spa_v4l2_set_format(this, &info, flags & SPA_PORT_FORMAT_FLAG_TEST_ONLY) < 0)
if (spa_v4l2_set_format(this, &info, flags & SPA_NODE_PARAM_FLAG_TEST_ONLY) < 0)
return SPA_RESULT_INVALID_MEDIA_TYPE;
if (!(flags & SPA_PORT_FORMAT_FLAG_TEST_ONLY)) {
if (!(flags & SPA_NODE_PARAM_FLAG_TEST_ONLY)) {
port->current_format = info;
port->have_format = true;
}
@ -516,131 +659,26 @@ static int impl_node_port_set_format(struct spa_node *node,
return SPA_RESULT_OK;
}
static int impl_node_port_get_format(struct spa_node *node,
enum spa_direction direction,
uint32_t port_id,
const struct spa_format **format)
{
struct impl *this;
struct port *port;
struct spa_pod_builder b = { NULL, };
struct spa_pod_frame f[1];
struct type *t;
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail(format != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF(node, struct impl, node);
t = &this->type;
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT);
port = &this->out_ports[port_id];
if (!port->have_format)
return SPA_RESULT_NO_FORMAT;
b.data = port->format_buffer;
b.size = sizeof(port->format_buffer);
spa_pod_builder_push_format(&b, &f[0], t->format,
port->current_format.media_type,
port->current_format.media_subtype);
if (port->current_format.media_subtype == t->media_subtype.raw) {
spa_pod_builder_add(&b,
":", t->format_video.format, "I", port->current_format.info.raw.format,
":", t->format_video.size, "R", &port->current_format.info.raw.size,
":", t->format_video.framerate, "F", &port->current_format.info.raw.framerate, 0);
} else if (port->current_format.media_subtype == t->media_subtype_video.mjpg ||
port->current_format.media_subtype == t->media_subtype_video.jpeg) {
spa_pod_builder_add(&b,
":", t->format_video.size, "R", &port->current_format.info.mjpg.size,
":", t->format_video.framerate, "F", &port->current_format.info.mjpg.framerate, 0);
} else if (port->current_format.media_subtype == t->media_subtype_video.h264) {
spa_pod_builder_add(&b,
":", t->format_video.size, "R", &port->current_format.info.h264.size,
":", t->format_video.framerate, "F", &port->current_format.info.h264.framerate, 0);
} else
return SPA_RESULT_NO_FORMAT;
spa_pod_builder_pop(&b, &f[0]);
*format = SPA_POD_BUILDER_DEREF(&b, f[0].ref, struct spa_format);
return SPA_RESULT_OK;
}
static int impl_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;
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail(info != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF(node, struct impl, node);
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT);
*info = &this->out_ports[port_id].info;
return SPA_RESULT_OK;
}
static int impl_node_port_enum_params(struct spa_node *node,
enum spa_direction direction,
uint32_t port_id,
uint32_t index,
struct spa_param **param)
{
struct impl *this;
struct port *port;
struct spa_pod_builder b = { NULL, };
struct type *t;
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
spa_return_val_if_fail(param != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF(node, struct impl, node);
t = &this->type;
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT);
port = &this->out_ports[port_id];
spa_pod_builder_init(&b, port->params_buffer, sizeof(port->params_buffer));
switch (index) {
case 0:
*param = spa_pod_builder_param(&b, 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,
":", t->param_alloc_buffers.buffers, "iru", MAX_BUFFERS,
2, 2, MAX_BUFFERS,
":", t->param_alloc_buffers.align, "i", 16);
break;
case 1:
*param = spa_pod_builder_param(&b, 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;
default:
return SPA_RESULT_NOT_IMPLEMENTED;
}
return SPA_RESULT_OK;
}
static int impl_node_port_set_param(struct spa_node *node,
enum spa_direction direction,
uint32_t port_id,
const struct spa_param *param)
enum spa_direction direction, uint32_t port_id,
uint32_t id, uint32_t flags,
const struct spa_pod_object *param)
{
return SPA_RESULT_NOT_IMPLEMENTED;
struct impl *this;
struct type *t;
spa_return_val_if_fail(node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
this = SPA_CONTAINER_OF(node, struct impl, node);
t = &this->type;
spa_return_val_if_fail(CHECK_PORT(this, direction, port_id), SPA_RESULT_INVALID_PORT);
if (id == t->param.idFormat) {
return port_set_format(node, direction, port_id, flags, param);
}
else
return SPA_RESULT_UNKNOWN_PARAM;
}
static int impl_node_port_use_buffers(struct spa_node *node,
@ -680,7 +718,7 @@ static int
impl_node_port_alloc_buffers(struct spa_node *node,
enum spa_direction direction,
uint32_t port_id,
struct spa_param **params,
struct spa_pod_object **params,
uint32_t n_params,
struct spa_buffer **buffers,
uint32_t *n_buffers)
@ -812,17 +850,14 @@ static const struct spa_dict info = {
static const struct spa_node impl_node = {
SPA_VERSION_NODE,
&info,
impl_node_get_props,
impl_node_set_props,
impl_node_enum_params,
impl_node_set_param,
impl_node_send_command,
impl_node_set_callbacks,
impl_node_get_n_ports,
impl_node_get_port_ids,
impl_node_add_port,
impl_node_remove_port,
impl_node_port_enum_formats,
impl_node_port_set_format,
impl_node_port_get_format,
impl_node_port_get_info,
impl_node_port_enum_params,
impl_node_port_set_param,
@ -835,12 +870,15 @@ static const struct spa_node impl_node = {
impl_node_process_output,
};
static int impl_clock_get_props(struct spa_clock *clock, struct spa_props **props)
static int impl_clock_enum_params(struct spa_clock *clock, uint32_t id, uint32_t *index,
struct spa_pod_builder *builder)
{
return SPA_RESULT_NOT_IMPLEMENTED;
}
static int impl_clock_set_props(struct spa_clock *clock, const struct spa_props *props)
static int impl_clock_set_param(struct spa_clock *clock,
uint32_t id, uint32_t flags,
const struct spa_pod_object *param)
{
return SPA_RESULT_NOT_IMPLEMENTED;
}
@ -872,8 +910,8 @@ static const struct spa_clock impl_clock = {
SPA_VERSION_CLOCK,
NULL,
SPA_CLOCK_STATE_STOPPED,
impl_clock_get_props,
impl_clock_set_props,
impl_clock_enum_params,
impl_clock_set_param,
impl_clock_get_time,
};

View file

@ -398,18 +398,19 @@ static const struct format_info *find_format_info_by_media_type(struct type *typ
}
static uint32_t
enum_filter_format(struct type *type, const struct spa_format *filter, uint32_t index)
enum_filter_format(struct type *type, uint32_t media_type, int32_t media_subtype,
const struct spa_pod_object *filter, uint32_t index)
{
uint32_t video_format = 0;
if ((filter->body.media_type.value == type->media_type.video ||
filter->body.media_type.value == type->media_type.image)) {
if (filter->body.media_subtype.value == type->media_subtype.raw) {
if ((media_type == type->media_type.video ||
media_type == type->media_type.image)) {
if (media_subtype == type->media_subtype.raw) {
struct spa_pod_prop *p;
uint32_t n_values;
const uint32_t *values;
if (!(p = spa_format_find_prop(filter, type->format_video.format)))
if (!(p = spa_pod_object_find_prop(filter, type->format_video.format)))
return type->video_format.UNKNOWN;
if (p->body.value.type != SPA_POD_TYPE_ID)
@ -522,24 +523,22 @@ filter_framerate(struct v4l2_frmivalenum *frmival,
static int
spa_v4l2_enum_format(struct impl *this,
struct spa_format **format,
const struct spa_format *filter,
uint32_t index)
uint32_t *index,
const struct spa_pod_object *filter,
struct spa_pod_builder *builder)
{
struct port *port = &this->out_ports[0];
int res, n_fractions;
const struct format_info *info;
struct spa_pod_frame f[2];
struct spa_pod_prop *prop;
struct spa_pod_builder b = { NULL, };
uint32_t media_type, media_subtype, video_format;
uint32_t filter_media_type, filter_media_subtype;
if (spa_v4l2_open(this) < 0)
return SPA_RESULT_ERROR;
*format = NULL;
if (index == 0) {
if (*index == 0) {
spa_zero(port->fmtdesc);
port->fmtdesc.index = 0;
port->fmtdesc.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
@ -549,6 +548,12 @@ spa_v4l2_enum_format(struct impl *this,
spa_zero(port->frmival);
}
if (filter) {
spa_pod_object_parse(filter,
"I", &filter_media_type,
"I", &filter_media_subtype);
}
if (false) {
next_fmtdesc:
port->fmtdesc.index++;
@ -557,14 +562,17 @@ spa_v4l2_enum_format(struct impl *this,
while (port->next_fmtdesc) {
if (filter) {
video_format =
enum_filter_format(&this->type, filter, port->fmtdesc.index);
video_format = enum_filter_format(&this->type,
filter_media_type,
filter_media_subtype,
filter, port->fmtdesc.index);
if (video_format == this->type.video_format.UNKNOWN)
return SPA_RESULT_ENUM_END;
info = find_format_info_by_media_type(&this->type,
filter->body.media_type.value,
filter->body.media_subtype.value,
filter_media_type,
filter_media_subtype,
video_format, 0);
if (info == NULL)
goto next_fmtdesc;
@ -591,7 +599,7 @@ spa_v4l2_enum_format(struct impl *this,
struct spa_pod_prop *p;
/* check if we have a fixed frame size */
if (!(p = spa_format_find_prop(filter, this->type.format_video.size)))
if (!(p = spa_pod_object_find_prop(filter, this->type.format_video.size)))
goto do_frmsize;
if (p->body.value.type != SPA_POD_TYPE_RECTANGLE)
@ -625,7 +633,7 @@ spa_v4l2_enum_format(struct impl *this,
uint32_t i, n_values;
/* check if we have a fixed frame size */
if (!(p = spa_format_find_prop(filter, this->type.format_video.size)))
if (!(p = spa_pod_object_find_prop(filter, this->type.format_video.size)))
goto have_size;
range = p->body.flags & SPA_POD_PROP_RANGE_MASK;
@ -675,21 +683,25 @@ spa_v4l2_enum_format(struct impl *this,
media_subtype = *SPA_MEMBER(&this->type, info->media_subtype_offset, uint32_t);
video_format = *SPA_MEMBER(&this->type, info->format_offset, uint32_t);
spa_pod_builder_init(&b, port->format_buffer, sizeof(port->format_buffer));
spa_pod_builder_push_format(&b, &f[0], this->type.format, media_type, media_subtype);
spa_pod_builder_init(builder, port->format_buffer, sizeof(port->format_buffer));
spa_pod_builder_push_object(builder, &f[0],
this->type.param.idEnumFormat, this->type.format);
spa_pod_builder_add(builder,
"I", media_type,
"I", media_subtype, 0);
if (media_subtype == this->type.media_subtype.raw) {
spa_pod_builder_add(&b,
":", this->type.format_video.format, "I", video_format, 0);
spa_pod_builder_add(builder,
":", this->type.format_video.format, "I", video_format, 0);
}
spa_pod_builder_add(&b,
spa_pod_builder_add(builder,
":", this->type.format_video.size, "R", &SPA_RECTANGLE(port->frmsize.discrete.width,
port->frmsize.discrete.height), 0);
spa_pod_builder_push_prop(&b, &f[1], this->type.format_video.framerate,
spa_pod_builder_push_prop(builder, &f[1], this->type.format_video.framerate,
SPA_POD_PROP_RANGE_NONE | SPA_POD_PROP_FLAG_UNSET);
prop = SPA_POD_BUILDER_DEREF(&b, f[1].ref, struct spa_pod_prop);
prop = SPA_POD_BUILDER_DEREF(builder, f[1].ref, struct spa_pod_prop);
n_fractions = 0;
port->frmival.index = 0;
@ -712,7 +724,7 @@ spa_v4l2_enum_format(struct impl *this,
uint32_t i, n_values;
const struct spa_fraction step = { 1, 1 }, *values;
if (!(p = spa_format_find_prop(filter, this->type.format_video.framerate)))
if (!(p = spa_pod_object_find_prop(filter, this->type.format_video.framerate)))
goto have_framerate;
if (p->body.value.type != SPA_POD_TYPE_FRACTION)
@ -746,21 +758,21 @@ spa_v4l2_enum_format(struct impl *this,
if (port->frmival.type == V4L2_FRMIVAL_TYPE_DISCRETE) {
prop->body.flags |= SPA_POD_PROP_RANGE_ENUM;
if (n_fractions == 0)
spa_pod_builder_fraction(&b,
spa_pod_builder_fraction(builder,
port->frmival.discrete.denominator,
port->frmival.discrete.numerator);
spa_pod_builder_fraction(&b,
spa_pod_builder_fraction(builder,
port->frmival.discrete.denominator,
port->frmival.discrete.numerator);
port->frmival.index++;
} else if (port->frmival.type == V4L2_FRMIVAL_TYPE_CONTINUOUS ||
port->frmival.type == V4L2_FRMIVAL_TYPE_STEPWISE) {
if (n_fractions == 0)
spa_pod_builder_fraction(&b, 25, 1);
spa_pod_builder_fraction(&b,
spa_pod_builder_fraction(builder, 25, 1);
spa_pod_builder_fraction(builder,
port->frmival.stepwise.min.denominator,
port->frmival.stepwise.min.numerator);
spa_pod_builder_fraction(&b,
spa_pod_builder_fraction(builder,
port->frmival.stepwise.max.denominator,
port->frmival.stepwise.max.numerator);
@ -768,7 +780,7 @@ spa_v4l2_enum_format(struct impl *this,
prop->body.flags |= SPA_POD_PROP_RANGE_MIN_MAX;
} else {
prop->body.flags |= SPA_POD_PROP_RANGE_STEP;
spa_pod_builder_fraction(&b,
spa_pod_builder_fraction(builder,
port->frmival.stepwise.step.denominator,
port->frmival.stepwise.step.numerator);
}
@ -779,10 +791,10 @@ spa_v4l2_enum_format(struct impl *this,
if (n_fractions <= 1) {
prop->body.flags &= ~(SPA_POD_PROP_RANGE_MASK | SPA_POD_PROP_FLAG_UNSET);
}
spa_pod_builder_pop(&b, &f[1]);
spa_pod_builder_pop(&b, &f[0]);
spa_pod_builder_pop(builder, &f[1]);
spa_pod_builder_pop(builder, &f[0]);
*format = SPA_POD_BUILDER_DEREF(&b, f[0].ref, struct spa_format);
(*index)++;
return SPA_RESULT_OK;
}
@ -1028,7 +1040,7 @@ static int spa_v4l2_use_buffers(struct impl *this, struct spa_buffer **buffers,
static int
mmap_init(struct impl *this,
struct spa_param **params,
struct spa_pod_object **params,
uint32_t n_params,
struct spa_buffer **buffers,
uint32_t *n_buffers)
@ -1137,7 +1149,7 @@ static int read_init(struct impl *this)
static int
spa_v4l2_alloc_buffers(struct impl *this,
struct spa_param **params,
struct spa_pod_object **params,
uint32_t n_params,
struct spa_buffer **buffers,
uint32_t *n_buffers)