mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-03 09:01:54 -05:00
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:
parent
b6ee67905d
commit
f3bca48398
87 changed files with 3773 additions and 3580 deletions
|
|
@ -51,7 +51,7 @@ spa_type_format_audio_map(struct spa_type_map *map, struct spa_type_format_audio
|
|||
}
|
||||
|
||||
static inline int
|
||||
spa_format_audio_raw_parse(const struct spa_format *format,
|
||||
spa_format_audio_raw_parse(const struct spa_pod_object *format,
|
||||
struct spa_audio_info_raw *info, struct spa_type_format_audio *type)
|
||||
{
|
||||
struct spa_pod_parser prs;
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ enum spa_clock_state {
|
|||
|
||||
#include <spa/defs.h>
|
||||
#include <spa/plugin.h>
|
||||
#include <spa/props.h>
|
||||
#include <spa/pod-builder.h>
|
||||
|
||||
/**
|
||||
* spa_clock:
|
||||
|
|
@ -64,9 +64,8 @@ struct spa_clock {
|
|||
/**
|
||||
* spa_clock::get_props:
|
||||
* @clock: a #spa_clock
|
||||
* @props: a location for a #struct spa_props pointer
|
||||
*
|
||||
* Get the configurable properties of @clock.
|
||||
* Get the parameters of @clock.
|
||||
*
|
||||
* The returned @props is a snapshot of the current configuration and
|
||||
* can be modified. The modifications will take effect after a call
|
||||
|
|
@ -77,8 +76,9 @@ struct spa_clock {
|
|||
* #SPA_RESULT_NOT_IMPLEMENTED when there are no properties
|
||||
* implemented on @clock
|
||||
*/
|
||||
int (*get_props) (struct spa_clock *clock,
|
||||
struct spa_props **props);
|
||||
int (*enum_params) (struct spa_clock *clock,
|
||||
uint32_t id, uint32_t *index,
|
||||
struct spa_pod_builder *builder);
|
||||
/**
|
||||
* spa_clock::set_props:
|
||||
* @clock: a #spa_clock
|
||||
|
|
@ -101,8 +101,9 @@ struct spa_clock {
|
|||
* #SPA_RESULT_WRONG_PROPERTY_TYPE when a property has the wrong
|
||||
* type.
|
||||
*/
|
||||
int (*set_props) (struct spa_clock *clock,
|
||||
const struct spa_props *props);
|
||||
int (*set_param) (struct spa_clock *clock,
|
||||
uint32_t id, uint32_t flags,
|
||||
const struct spa_pod_object *param);
|
||||
|
||||
int (*get_time) (struct spa_clock *clock,
|
||||
int32_t *rate,
|
||||
|
|
@ -110,8 +111,8 @@ struct spa_clock {
|
|||
int64_t *monotonic_time);
|
||||
};
|
||||
|
||||
#define spa_clock_get_props(n,...) (n)->get_props((n),__VA_ARGS__)
|
||||
#define spa_clock_set_props(n,...) (n)->set_props((n),__VA_ARGS__)
|
||||
#define spa_clock_enum_params(n,...) (n)->enum_params((n),__VA_ARGS__)
|
||||
#define spa_clock_set_param(n,...) (n)->set_param((n),__VA_ARGS__)
|
||||
#define spa_clock_get_time(n,...) (n)->get_time((n),__VA_ARGS__)
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
|||
|
|
@ -73,6 +73,8 @@ enum spa_result {
|
|||
SPA_RESULT_INCOMPATIBLE_VERSION = -37,
|
||||
SPA_RESULT_NOT_FOUND = -38,
|
||||
SPA_RESULT_BUSY = -39,
|
||||
SPA_RESULT_UNKNOWN_PARAM = -40,
|
||||
SPA_RESULT_PARAM_INCOMPLETE = -41,
|
||||
};
|
||||
|
||||
#define SPA_ASYNC_BIT (1 << 30)
|
||||
|
|
|
|||
|
|
@ -1,61 +0,0 @@
|
|||
/* Simple Plugin API
|
||||
* Copyright (C) 2016 Wim Taymans <wim.taymans@gmail.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __SPA_FORMAT_BUILDER_H__
|
||||
#define __SPA_FORMAT_BUILDER_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
#include <spa/format.h>
|
||||
#include <spa/pod-builder.h>
|
||||
|
||||
#define SPA_FORMAT_INIT(size,type,media_type,media_subtype) \
|
||||
{ { size, SPA_POD_TYPE_OBJECT }, \
|
||||
{ { 0, type }, \
|
||||
SPA_POD_ID_INIT(media_type), \
|
||||
SPA_POD_ID_INIT(media_subtype) } }
|
||||
|
||||
static inline uint32_t
|
||||
spa_pod_builder_push_format(struct spa_pod_builder *builder,
|
||||
struct spa_pod_frame *frame,
|
||||
uint32_t format_type,
|
||||
uint32_t media_type,
|
||||
uint32_t media_subtype)
|
||||
{
|
||||
const struct spa_format p = SPA_FORMAT_INIT(sizeof(struct spa_format_body),
|
||||
format_type, media_type, media_subtype);
|
||||
return spa_pod_builder_push(builder, frame, &p.pod,
|
||||
spa_pod_builder_raw(builder, &p, sizeof(p)));
|
||||
}
|
||||
|
||||
#define spa_pod_builder_format(b,format_type,media_type,media_subtype,...) \
|
||||
spa_pod_builder_object(b, 0, format_type, \
|
||||
"I",media_type, \
|
||||
"I",media_subtype, \
|
||||
##__VA_ARGS__)
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* __SPA_FORMAT_BUILDER_H__ */
|
||||
|
|
@ -138,40 +138,6 @@ spa_type_media_subtype_audio_map(struct spa_type_map *map,
|
|||
}
|
||||
}
|
||||
|
||||
#define SPA_FORMAT_BODY_FOREACH(body, size, iter) \
|
||||
for ((iter) = SPA_MEMBER((body), sizeof(struct spa_format_body), struct spa_pod_prop); \
|
||||
(iter) < SPA_MEMBER((body), (size), struct spa_pod_prop); \
|
||||
(iter) = SPA_MEMBER((iter), SPA_ROUND_UP_N(SPA_POD_SIZE(iter), 8), struct spa_pod_prop))
|
||||
|
||||
#define SPA_FORMAT_FOREACH(format, iter) \
|
||||
SPA_FORMAT_BODY_FOREACH(&format->body, SPA_POD_BODY_SIZE(format), iter)
|
||||
|
||||
#define SPA_FORMAT_MEDIA_TYPE(f) SPA_POD_VALUE(struct spa_pod_id, &f->body.media_type)
|
||||
#define SPA_FORMAT_MEDIA_SUBTYPE(f) SPA_POD_VALUE(struct spa_pod_id, &f->body.media_subtype)
|
||||
|
||||
#define spa_format_parse(format,...) \
|
||||
({ \
|
||||
struct spa_pod_parser __p; \
|
||||
const struct spa_format *__format = format; \
|
||||
spa_pod_parser_pod(&__p, &__format->pod); \
|
||||
spa_pod_parser_get(&__p, "<", ##__VA_ARGS__, NULL); \
|
||||
})
|
||||
|
||||
static inline struct spa_pod_prop *spa_format_find_prop(const struct spa_format *format, uint32_t key)
|
||||
{
|
||||
return spa_pod_contents_find_prop(&format->pod, sizeof(struct spa_format), key);
|
||||
}
|
||||
|
||||
static inline int spa_format_fixate(struct spa_format *format)
|
||||
{
|
||||
struct spa_pod_prop *prop;
|
||||
|
||||
SPA_FORMAT_FOREACH(format, prop)
|
||||
prop->body.flags &= ~SPA_POD_PROP_FLAG_UNSET;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct spa_format;
|
||||
#define SPA_TYPE__Format SPA_TYPE_POD_OBJECT_BASE "Format"
|
||||
#define SPA_TYPE_FORMAT_BASE SPA_TYPE__Format ":"
|
||||
|
||||
|
|
@ -77,24 +76,6 @@ struct spa_format;
|
|||
#define SPA_TYPE_MEDIA_SUBTYPE__gsm SPA_TYPE_MEDIA_SUBTYPE_BASE "gsm"
|
||||
#define SPA_TYPE_MEDIA_SUBTYPE__midi SPA_TYPE_MEDIA_SUBTYPE_BASE "midi"
|
||||
|
||||
struct spa_format_body {
|
||||
struct spa_pod_object_body obj_body;
|
||||
struct spa_pod_id media_type SPA_ALIGNED(8);
|
||||
struct spa_pod_id media_subtype SPA_ALIGNED(8);
|
||||
/* contents follow, series of spa_pod_prop */
|
||||
};
|
||||
|
||||
/**
|
||||
* spa_format:
|
||||
* @media_type: media type
|
||||
* @media_subtype: subtype
|
||||
* @pod: POD object with properties
|
||||
*/
|
||||
struct spa_format {
|
||||
struct spa_pod pod;
|
||||
struct spa_format_body body;
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ spa_headers = [
|
|||
'event.h',
|
||||
'event-node.h',
|
||||
'format.h',
|
||||
'format-builder.h',
|
||||
'format-utils.h',
|
||||
'hook.h',
|
||||
'list.h',
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ struct spa_node;
|
|||
#include <spa/defs.h>
|
||||
#include <spa/plugin.h>
|
||||
#include <spa/props.h>
|
||||
#include <spa/pod-builder.h>
|
||||
#include <spa/param.h>
|
||||
#include <spa/event-node.h>
|
||||
#include <spa/command-node.h>
|
||||
|
|
@ -134,6 +135,10 @@ struct spa_node_callbacks {
|
|||
|
||||
};
|
||||
|
||||
#define SPA_NODE_PARAM_FLAG_TEST_ONLY (1 << 0) /* just check if the param is accepted */
|
||||
#define SPA_NODE_PARAM_FLAG_FIXATE (1 << 1) /* fixate the non-optional unset fields */
|
||||
#define SPA_NODE_PARAM_FLAG_NEAREST (1 << 2) /* allow set fields to be rounded to the
|
||||
* nearest allowed field value. */
|
||||
/**
|
||||
* struct spa_node:
|
||||
*
|
||||
|
|
@ -154,49 +159,61 @@ struct spa_node {
|
|||
*/
|
||||
const struct spa_dict *info;
|
||||
/**
|
||||
* spa_node::get_props:
|
||||
* @node: a #spa_node
|
||||
* @props: a location for a #struct spa_props pointer
|
||||
* Enumerate the parameters of a node.
|
||||
*
|
||||
* Get the configurable properties of @node.
|
||||
* Parameters are identified with an \a id. Some parameters can have
|
||||
* multiple values, see the documentation of the parameter id.
|
||||
*
|
||||
* The returned @props is a snapshot of the current configuration and
|
||||
* can be modified. The modifications will take effect after a call
|
||||
* to spa_node::set_props.
|
||||
* Parameters can be filtered by passing a non-NULL \a filter.
|
||||
*
|
||||
* This function must be called from the main thread.
|
||||
*
|
||||
* Returns: #SPA_RESULT_OK on success
|
||||
* #SPA_RESULT_INVALID_ARGUMENTS when node or props are %NULL
|
||||
* #SPA_RESULT_NOT_IMPLEMENTED when there are no properties
|
||||
* implemented on @node
|
||||
* \param node a \ref spa_node
|
||||
* \param id the param id to enumerate
|
||||
* \param index the index of enumeration, pass 0 for the first item and the
|
||||
* index is updated to retrieve the next item.
|
||||
* \param filter and optional filter to use
|
||||
* \param param builder for the result object.
|
||||
*
|
||||
* \return #SPA_RESULT_OK on success
|
||||
* #SPA_RESULT_INVALID_ARGUMENTS when node or builder are %NULL
|
||||
* #SPA_RESULT_UNKNOWN_PARAM the parameter \a id is unknown
|
||||
* #SPA_RESULT_ENUM_END when there are no more parameters to enumerate
|
||||
* #SPA_RESULT_NOT_IMPLEMENTED when there are no parameters
|
||||
* implemented on \a node
|
||||
*/
|
||||
int (*get_props) (struct spa_node *node, struct spa_props **props);
|
||||
int (*enum_params) (struct spa_node *node,
|
||||
uint32_t id, uint32_t *index,
|
||||
const struct spa_pod_object *filter,
|
||||
struct spa_pod_builder *builder);
|
||||
/**
|
||||
* struct spa_node::set_props:
|
||||
* @node: a #struct spa_node
|
||||
* @props: a #struct spa_props
|
||||
* Set the configurable parameter in \a node.
|
||||
*
|
||||
* Set the configurable properties in @node.
|
||||
* Usually, \a param will be obtained from enum_params and then
|
||||
* modified but it is also possible to set another spa_pod_object
|
||||
* as long as its keys and types match a supported object.
|
||||
*
|
||||
* Usually, @props will be obtained from struct spa_node::get_props and then
|
||||
* modified but it is also possible to set another #struct spa_props object
|
||||
* as long as its keys and types match those of struct spa_props::get_props.
|
||||
*
|
||||
* Properties with keys that are not known are ignored.
|
||||
*
|
||||
* If @props is NULL, all the properties are reset to their defaults.
|
||||
* Objects with property keys that are not known are ignored.
|
||||
*
|
||||
* This function must be called from the main thread.
|
||||
*
|
||||
* Returns: #SPA_RESULT_OK on success
|
||||
* #SPA_RESULT_INVALID_ARGUMENTS when node is %NULL
|
||||
* #SPA_RESULT_NOT_IMPLEMENTED when no properties can be
|
||||
* modified on @node.
|
||||
* #SPA_RESULT_WRONG_PROPERTY_TYPE when a property has the wrong
|
||||
* \param node a \ref spa_node
|
||||
* \param id the parameter id to configure
|
||||
* \param flags additional flags
|
||||
* \param param the parameter to configure
|
||||
*
|
||||
* \return #SPA_RESULT_OK on success
|
||||
* #SPA_RESULT_INVALID_ARGUMENTS when node is %NULL
|
||||
* #SPA_RESULT_NOT_IMPLEMENTED when there are no parameters
|
||||
* implemented on \a node
|
||||
* #SPA_RESULT_WRONG_PROPERTY_TYPE when a property has the wrong
|
||||
* type.
|
||||
* #SPA_RESULT_UNKNOWN_PARAM the parameter is unknown
|
||||
*/
|
||||
int (*set_props) (struct spa_node *node, const struct spa_props *props);
|
||||
int (*set_param) (struct spa_node *node,
|
||||
uint32_t id, uint32_t flags,
|
||||
const struct spa_pod_object *param);
|
||||
|
||||
/**
|
||||
* struct spa_node::send_command:
|
||||
* @node: a #struct spa_node
|
||||
|
|
@ -292,117 +309,72 @@ struct spa_node {
|
|||
int (*add_port) (struct spa_node *node, enum spa_direction direction, uint32_t port_id);
|
||||
int (*remove_port) (struct spa_node *node, enum spa_direction direction, uint32_t port_id);
|
||||
|
||||
/**
|
||||
* struct spa_node::port_enum_formats:
|
||||
* @node: a #struct spa_node
|
||||
* @direction: a #enum spa_direction
|
||||
* @port_id: the port to query
|
||||
* @format: pointer to a format
|
||||
* @filter: a format filter
|
||||
* @index: an index variable, 0 to get the first item
|
||||
*
|
||||
* Enumerate all possible formats on @port_id of @node that are compatible
|
||||
* with @filter. When @port_id is #SPA_ID_INVALID, the enumeration will
|
||||
* list all the formats possible on a port that would be added with
|
||||
* add_port().
|
||||
*
|
||||
* Use @index to retrieve the formats one by one until the function
|
||||
* returns #SPA_RESULT_ENUM_END.
|
||||
*
|
||||
* The result format can be queried and modified and ultimately be used
|
||||
* to call struct spa_node::port_set_format.
|
||||
*
|
||||
* This function must be called from the main thread.
|
||||
*
|
||||
* Returns: #SPA_RESULT_OK on success
|
||||
* #SPA_RESULT_INVALID_ARGUMENTS when node or format is %NULL
|
||||
* #SPA_RESULT_INVALID_PORT when port_id is not valid
|
||||
* #SPA_RESULT_ENUM_END when no format exists
|
||||
*/
|
||||
int (*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);
|
||||
/**
|
||||
* struct spa_node::port_set_format:
|
||||
* @node: a #struct spa_node
|
||||
* @direction: a #enum spa_direction
|
||||
* @port_id: the port to configure
|
||||
* @flags: flags
|
||||
* @format: a #struct spa_format with the format
|
||||
*
|
||||
* Set a format on @port_id of @node.
|
||||
*
|
||||
* When @format is %NULL, the current format will be removed.
|
||||
*
|
||||
* This function takes a copy of the format.
|
||||
*
|
||||
* Upon completion, this function might change the state of a node to
|
||||
* the READY state or to CONFIGURE when @format is NULL.
|
||||
*
|
||||
* This function must be called from the main thread.
|
||||
*
|
||||
* Returns: #SPA_RESULT_OK on success
|
||||
* #SPA_RESULT_OK_RECHECK on success, the value of @format might have been
|
||||
* changed depending on @flags and the final value can be found by
|
||||
* doing struct spa_node::get_format.
|
||||
* #SPA_RESULT_INVALID_ARGUMENTS when node is %NULL
|
||||
* #SPA_RESULT_INVALID_PORT when port_id is not valid
|
||||
* #SPA_RESULT_INVALID_MEDIA_TYPE when the media type is not valid
|
||||
* #SPA_RESULT_INVALID_FORMAT_PROPERTIES when one of the mandatory format
|
||||
* properties is not specified and #SPA_PORT_FORMAT_FLAG_FIXATE was
|
||||
* not set in @flags.
|
||||
* #SPA_RESULT_WRONG_PROPERTY_TYPE when the type or size of a property
|
||||
* is not correct.
|
||||
* #SPA_RESULT_ASYNC the function is executed asynchronously
|
||||
*/
|
||||
#define SPA_PORT_FORMAT_FLAG_TEST_ONLY (1 << 0) /* just check if the format is accepted */
|
||||
#define SPA_PORT_FORMAT_FLAG_FIXATE (1 << 1) /* fixate the non-optional unset fields */
|
||||
#define SPA_PORT_FORMAT_FLAG_NEAREST (1 << 2) /* allow set fields to be rounded to the
|
||||
* nearest allowed field value. */
|
||||
int (*port_set_format) (struct spa_node *node,
|
||||
enum spa_direction direction,
|
||||
uint32_t port_id,
|
||||
uint32_t flags,
|
||||
const struct spa_format *format);
|
||||
/**
|
||||
* struct spa_node::port_get_format:
|
||||
* @node: a #struct spa_node
|
||||
* @direction: a #enum spa_direction
|
||||
* @port_id: the port to query
|
||||
* @format: a pointer to a location to hold the #struct spa_format
|
||||
*
|
||||
* Get the format on @port_id of @node. The result #struct spa_format can
|
||||
* not be modified.
|
||||
*
|
||||
* This function must be called from the main thread.
|
||||
*
|
||||
* Returns: #SPA_RESULT_OK on success
|
||||
* #SPA_RESULT_INVALID_ARGUMENTS when @node or @format is %NULL
|
||||
* #SPA_RESULT_INVALID_PORT when @port_id is not valid
|
||||
* #SPA_RESULT_INVALID_NO_FORMAT when no format was set
|
||||
*/
|
||||
int (*port_get_format) (struct spa_node *node,
|
||||
enum spa_direction direction,
|
||||
uint32_t port_id,
|
||||
const struct spa_format **format);
|
||||
|
||||
int (*port_get_info) (struct spa_node *node,
|
||||
enum spa_direction direction,
|
||||
uint32_t port_id,
|
||||
const struct spa_port_info **info);
|
||||
|
||||
/**
|
||||
* Enumerate all possible parameters of \a id on \a port_id of \a node
|
||||
* that are compatible with \a filter.
|
||||
*
|
||||
* Use \a index to retrieve the parameters one by one until the function
|
||||
* returns #SPA_RESULT_ENUM_END.
|
||||
*
|
||||
* The result parameters can be queried and modified and ultimately be used
|
||||
* to call struct spa_node::port_set_param.
|
||||
*
|
||||
* This function must be called from the main thread.
|
||||
*
|
||||
* \param node a #struct spa_node
|
||||
* \param direction a #enum spa_direction
|
||||
* \param port_id the port to query
|
||||
* \param id the parameter id to query
|
||||
* \param index an index state variable, 0 to get the first item
|
||||
* \param filter a parameter filter or NULL for no filter
|
||||
* \param builder a builder for the result parameter object
|
||||
* \return #SPA_RESULT_OK on success
|
||||
* #SPA_RESULT_INVALID_ARGUMENTS when node or index or builder is %NULL
|
||||
* #SPA_RESULT_INVALID_PORT when port_id is not valid
|
||||
* #SPA_RESULT_ENUM_END when no more parameters exists
|
||||
* #SPA_RESULT_UNKNOWN_PARAM when \a id is unknown
|
||||
*/
|
||||
int (*port_enum_params) (struct spa_node *node,
|
||||
enum spa_direction direction,
|
||||
uint32_t port_id,
|
||||
uint32_t index,
|
||||
struct spa_param **param);
|
||||
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);
|
||||
|
||||
/**
|
||||
* Set a parameter on \a port_id of \a node.
|
||||
*
|
||||
* When \a param is %NULL, the parameter will be unset.
|
||||
*
|
||||
* This function must be called from the main thread.
|
||||
*
|
||||
* \param node a #struct spa_node
|
||||
* \param direction a #enum spa_direction
|
||||
* \param port_id the port to configure
|
||||
* \param flags optional flags
|
||||
* \param param a #struct spa_pod_object with the parameter to set
|
||||
* \return #SPA_RESULT_OK on success
|
||||
* #SPA_RESULT_OK_RECHECK on success, the value of \a param might have been
|
||||
* changed depending on \a flags and the final value can be found by
|
||||
* doing struct spa_node::enum_params.
|
||||
* #SPA_RESULT_INVALID_ARGUMENTS when node is %NULL
|
||||
* #SPA_RESULT_INVALID_PORT when port_id is not valid
|
||||
* #SPA_RESULT_INVALID_PARAM_INCOMPLETE when one of the mandatory param
|
||||
* properties is not specified and #SPA_NODE_PARAM_FLAG_FIXATE was
|
||||
* not set in \a flags.
|
||||
* #SPA_RESULT_WRONG_PROPERTY_TYPE when the type or size of a property
|
||||
* is not correct.
|
||||
* #SPA_RESULT_ASYNC the function is executed asynchronously
|
||||
*/
|
||||
int (*port_set_param) (struct spa_node *node,
|
||||
enum spa_direction direction,
|
||||
uint32_t port_id,
|
||||
const struct spa_param *param);
|
||||
uint32_t id, uint32_t flags,
|
||||
const struct spa_pod_object *param);
|
||||
|
||||
/**
|
||||
* struct spa_node::port_use_buffers:
|
||||
|
|
@ -477,7 +449,7 @@ struct spa_node {
|
|||
int (*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);
|
||||
|
|
@ -595,17 +567,14 @@ struct spa_node {
|
|||
int (*process_output) (struct spa_node *node);
|
||||
};
|
||||
|
||||
#define spa_node_get_props(n,...) (n)->get_props((n),__VA_ARGS__)
|
||||
#define spa_node_set_props(n,...) (n)->set_props((n),__VA_ARGS__)
|
||||
#define spa_node_enum_params(n,...) (n)->enum_params((n),__VA_ARGS__)
|
||||
#define spa_node_set_param(n,...) (n)->set_param((n),__VA_ARGS__)
|
||||
#define spa_node_send_command(n,...) (n)->send_command((n),__VA_ARGS__)
|
||||
#define spa_node_set_callbacks(n,...) (n)->set_callbacks((n),__VA_ARGS__)
|
||||
#define spa_node_get_n_ports(n,...) (n)->get_n_ports((n),__VA_ARGS__)
|
||||
#define spa_node_get_port_ids(n,...) (n)->get_port_ids((n),__VA_ARGS__)
|
||||
#define spa_node_add_port(n,...) (n)->add_port((n),__VA_ARGS__)
|
||||
#define spa_node_remove_port(n,...) (n)->remove_port((n),__VA_ARGS__)
|
||||
#define spa_node_port_enum_formats(n,...) (n)->port_enum_formats((n),__VA_ARGS__)
|
||||
#define spa_node_port_set_format(n,...) (n)->port_set_format((n),__VA_ARGS__)
|
||||
#define spa_node_port_get_format(n,...) (n)->port_get_format((n),__VA_ARGS__)
|
||||
#define spa_node_port_get_info(n,...) (n)->port_get_info((n),__VA_ARGS__)
|
||||
#define spa_node_port_enum_params(n,...) (n)->port_enum_params((n),__VA_ARGS__)
|
||||
#define spa_node_port_set_param(n,...) (n)->port_set_param((n),__VA_ARGS__)
|
||||
|
|
|
|||
|
|
@ -66,6 +66,7 @@ spa_type_param_alloc_buffers_map(struct spa_type_map *map,
|
|||
#define SPA_TYPE_PARAM_ALLOC_META_ENABLE__size SPA_TYPE_PARAM_ALLOC_META_ENABLE_BASE "size"
|
||||
|
||||
#define SPA_TYPE_PARAM_ALLOC_META_ENABLE__ringbufferSize SPA_TYPE_PARAM_ALLOC_META_ENABLE_BASE "ringbufferSize"
|
||||
#define SPA_TYPE_PARAM_ALLOC_META_ENABLE__ringbufferMinAvail SPA_TYPE_PARAM_ALLOC_META_ENABLE_BASE "ringbufferMinAvail"
|
||||
#define SPA_TYPE_PARAM_ALLOC_META_ENABLE__ringbufferStride SPA_TYPE_PARAM_ALLOC_META_ENABLE_BASE "ringbufferStride"
|
||||
#define SPA_TYPE_PARAM_ALLOC_META_ENABLE__ringbufferBlocks SPA_TYPE_PARAM_ALLOC_META_ENABLE_BASE "ringbufferBlocks"
|
||||
#define SPA_TYPE_PARAM_ALLOC_META_ENABLE__ringbufferAlign SPA_TYPE_PARAM_ALLOC_META_ENABLE_BASE "ringbufferAlign"
|
||||
|
|
@ -75,6 +76,7 @@ struct spa_type_param_alloc_meta_enable {
|
|||
uint32_t type;
|
||||
uint32_t size;
|
||||
uint32_t ringbufferSize;
|
||||
uint32_t ringbufferMinAvail;
|
||||
uint32_t ringbufferStride;
|
||||
uint32_t ringbufferBlocks;
|
||||
uint32_t ringbufferAlign;
|
||||
|
|
@ -85,13 +87,21 @@ spa_type_param_alloc_meta_enable_map(struct spa_type_map *map,
|
|||
struct spa_type_param_alloc_meta_enable *type)
|
||||
{
|
||||
if (type->MetaEnable == 0) {
|
||||
type->MetaEnable = spa_type_map_get_id(map, SPA_TYPE_PARAM_ALLOC__MetaEnable);
|
||||
type->type = spa_type_map_get_id(map, SPA_TYPE_PARAM_ALLOC_META_ENABLE__type);
|
||||
type->size = spa_type_map_get_id(map, SPA_TYPE_PARAM_ALLOC_META_ENABLE__size);
|
||||
type->ringbufferSize = spa_type_map_get_id(map, SPA_TYPE_PARAM_ALLOC_META_ENABLE__ringbufferSize);
|
||||
type->ringbufferStride = spa_type_map_get_id(map, SPA_TYPE_PARAM_ALLOC_META_ENABLE__ringbufferStride);
|
||||
type->ringbufferBlocks = spa_type_map_get_id(map, SPA_TYPE_PARAM_ALLOC_META_ENABLE__ringbufferBlocks);
|
||||
type->ringbufferAlign = spa_type_map_get_id(map, SPA_TYPE_PARAM_ALLOC_META_ENABLE__ringbufferAlign);
|
||||
int i;
|
||||
#define OFF(n) offsetof(struct spa_type_param_alloc_meta_enable, n)
|
||||
static struct { off_t offset; const char *type; } tab[] = {
|
||||
{ OFF(MetaEnable), SPA_TYPE_PARAM_ALLOC__MetaEnable },
|
||||
{ OFF(type), SPA_TYPE_PARAM_ALLOC_META_ENABLE__type },
|
||||
{ OFF(size), SPA_TYPE_PARAM_ALLOC_META_ENABLE__size },
|
||||
{ OFF(ringbufferSize), SPA_TYPE_PARAM_ALLOC_META_ENABLE__ringbufferSize },
|
||||
{ OFF(ringbufferMinAvail), SPA_TYPE_PARAM_ALLOC_META_ENABLE__ringbufferMinAvail },
|
||||
{ OFF(ringbufferStride), SPA_TYPE_PARAM_ALLOC_META_ENABLE__ringbufferStride },
|
||||
{ OFF(ringbufferBlocks), SPA_TYPE_PARAM_ALLOC_META_ENABLE__ringbufferBlocks },
|
||||
{ OFF(ringbufferAlign), SPA_TYPE_PARAM_ALLOC_META_ENABLE__ringbufferAlign },
|
||||
};
|
||||
#undef OFF
|
||||
for (i = 0; i < SPA_N_ELEMENTS(tab); i++)
|
||||
*SPA_MEMBER(type, tab[i].offset, uint32_t) = spa_type_map_get_id(map, tab[i].type);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -26,52 +26,64 @@ extern "C" {
|
|||
|
||||
#include <spa/defs.h>
|
||||
#include <spa/pod-utils.h>
|
||||
#include <spa/type-map.h>
|
||||
|
||||
struct spa_param;
|
||||
#define SPA_TYPE__Param SPA_TYPE_POD_OBJECT_BASE "Param"
|
||||
#define SPA_TYPE_PARAM_BASE SPA_TYPE__Param ":"
|
||||
/* base for parameter objects */
|
||||
#define SPA_TYPE__Param SPA_TYPE_POD_OBJECT_BASE "Param"
|
||||
#define SPA_TYPE_PARAM_BASE SPA_TYPE__Param ":"
|
||||
|
||||
struct spa_param {
|
||||
struct spa_pod_object object;
|
||||
/* base for parameter object enumerations */
|
||||
#define SPA_TYPE__ParamId SPA_TYPE_ENUM_BASE "ParamId"
|
||||
#define SPA_TYPE_PARAM_ID_BASE SPA_TYPE__ParamId ":"
|
||||
|
||||
/** List of supported parameters */
|
||||
#define SPA_TYPE_PARAM_ID__List SPA_TYPE_PARAM_ID_BASE "List"
|
||||
|
||||
/* object with supported parameter id */
|
||||
#define SPA_TYPE_PARAM__List SPA_TYPE_PARAM_BASE "List"
|
||||
#define SPA_TYPE_PARAM_LIST_BASE SPA_TYPE_PARAM__List ":"
|
||||
#define SPA_TYPE_PARAM_LIST__id SPA_TYPE_PARAM_LIST_BASE "id"
|
||||
|
||||
/** Property parameter id, deals with SPA_TYPE__Props */
|
||||
#define SPA_TYPE_PARAM_ID__Props SPA_TYPE_PARAM_ID_BASE "Props"
|
||||
|
||||
/** The available formats */
|
||||
#define SPA_TYPE_PARAM_ID__EnumFormat SPA_TYPE_PARAM_ID_BASE "EnumFormat"
|
||||
|
||||
/** The current format */
|
||||
#define SPA_TYPE_PARAM_ID__Format SPA_TYPE_PARAM_ID_BASE "Format"
|
||||
|
||||
/** The supported buffer sizes */
|
||||
#define SPA_TYPE_PARAM_ID__Buffers SPA_TYPE_PARAM_ID_BASE "Buffers"
|
||||
|
||||
/** The supported metadata */
|
||||
#define SPA_TYPE_PARAM_ID__Meta SPA_TYPE_PARAM_ID_BASE "Meta"
|
||||
|
||||
struct spa_type_param {
|
||||
uint32_t idList; /**< id of the list param */
|
||||
uint32_t List; /**< list object type */
|
||||
uint32_t listId; /**< id in the list object */
|
||||
uint32_t idProps; /**< id to enumerate properties */
|
||||
uint32_t idEnumFormat; /**< id to enumerate formats */
|
||||
uint32_t idFormat; /**< id to get/set format parameter */
|
||||
uint32_t idBuffers; /**< id to enumerate buffer requirements */
|
||||
uint32_t idMeta; /**< id to enumerate supported metadata */
|
||||
};
|
||||
|
||||
static inline uint32_t
|
||||
spa_pod_builder_push_param(struct spa_pod_builder *builder,
|
||||
struct spa_pod_frame *frame,
|
||||
uint32_t param_type)
|
||||
static inline void
|
||||
spa_type_param_map(struct spa_type_map *map,
|
||||
struct spa_type_param *type)
|
||||
{
|
||||
return spa_pod_builder_push_object(builder, frame, 0, param_type);
|
||||
}
|
||||
|
||||
#define spa_pod_builder_param(b,param_type,...) \
|
||||
spa_pod_builder_object(b, 0, param_type, \
|
||||
##__VA_ARGS__)
|
||||
|
||||
|
||||
#define spa_param_parse(param,...) \
|
||||
({ \
|
||||
struct spa_pod_parser __p; \
|
||||
const struct spa_param *__param = param; \
|
||||
spa_pod_parser_pod(&__p, &__param->object.pod); \
|
||||
spa_pod_parser_get(&__p, "<", ##__VA_ARGS__, NULL); \
|
||||
})
|
||||
|
||||
#define SPA_PARAM_BODY_FOREACH(body, size, iter) \
|
||||
for ((iter) = SPA_MEMBER((body), sizeof(struct spa_pod_object_body), struct spa_pod_prop); \
|
||||
(iter) < SPA_MEMBER((body), (size), struct spa_pod_prop); \
|
||||
(iter) = SPA_MEMBER((iter), SPA_ROUND_UP_N(SPA_POD_SIZE(iter), 8), struct spa_pod_prop))
|
||||
|
||||
#define SPA_PARAM_FOREACH(param, iter) \
|
||||
SPA_PARAM_BODY_FOREACH(¶m->object.body, SPA_POD_BODY_SIZE(param), iter)
|
||||
|
||||
static inline int spa_param_fixate(struct spa_param *param)
|
||||
{
|
||||
struct spa_pod_prop *prop;
|
||||
|
||||
SPA_PARAM_FOREACH(param, prop)
|
||||
prop->body.flags &= ~SPA_POD_PROP_FLAG_UNSET;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
if (type->idList == 0) {
|
||||
type->idList = spa_type_map_get_id(map, SPA_TYPE_PARAM_ID__List);
|
||||
type->List = spa_type_map_get_id(map, SPA_TYPE_PARAM__List);
|
||||
type->listId = spa_type_map_get_id(map, SPA_TYPE_PARAM_LIST__id);
|
||||
type->idProps = spa_type_map_get_id(map, SPA_TYPE_PARAM_ID__Props);
|
||||
type->idEnumFormat = spa_type_map_get_id(map, SPA_TYPE_PARAM_ID__EnumFormat);
|
||||
type->idFormat = spa_type_map_get_id(map, SPA_TYPE_PARAM_ID__Format);
|
||||
type->idBuffers = spa_type_map_get_id(map, SPA_TYPE_PARAM_ID__Buffers);
|
||||
type->idMeta = spa_type_map_get_id(map, SPA_TYPE_PARAM_ID__Meta);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
|||
|
|
@ -98,6 +98,8 @@ static inline struct spa_pod_prop *spa_pod_struct_find_prop(const struct spa_pod
|
|||
return spa_pod_contents_find_prop(&obj->pod, sizeof(struct spa_pod_struct), key);
|
||||
}
|
||||
|
||||
#include <spa/pod-parser.h>
|
||||
|
||||
#define spa_pod_object_parse(object,...) \
|
||||
({ \
|
||||
struct spa_pod_parser __p; \
|
||||
|
|
@ -106,6 +108,16 @@ static inline struct spa_pod_prop *spa_pod_struct_find_prop(const struct spa_pod
|
|||
spa_pod_parser_get(&__p, "<", ##__VA_ARGS__, NULL); \
|
||||
})
|
||||
|
||||
static inline int spa_pod_object_fixate(struct spa_pod_object *obj)
|
||||
{
|
||||
struct spa_pod *res;
|
||||
SPA_POD_OBJECT_FOREACH(obj, res) {
|
||||
if (res->type == SPA_POD_TYPE_PROP)
|
||||
((struct spa_pod_prop *) res)->body.flags &= ~SPA_POD_PROP_FLAG_UNSET;
|
||||
}
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -25,16 +25,12 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
#include <spa/pod.h>
|
||||
#include <spa/pod-builder.h>
|
||||
#include <spa/pod-parser.h>
|
||||
#include <spa/param.h>
|
||||
|
||||
struct spa_props {
|
||||
struct spa_pod_object object;
|
||||
};
|
||||
|
||||
#define SPA_TYPE__Props SPA_TYPE_POD_OBJECT_BASE "Props"
|
||||
#define SPA_TYPE_PROPS_BASE SPA_TYPE__Props ":"
|
||||
#define SPA_TYPE__Props SPA_TYPE_POD_OBJECT_BASE "Props"
|
||||
#define SPA_TYPE_PROPS_BASE SPA_TYPE__Props ":"
|
||||
|
||||
/** Common property ids */
|
||||
#define SPA_TYPE_PROPS__device SPA_TYPE_PROPS_BASE "device"
|
||||
#define SPA_TYPE_PROPS__deviceName SPA_TYPE_PROPS_BASE "deviceName"
|
||||
#define SPA_TYPE_PROPS__deviceFd SPA_TYPE_PROPS_BASE "deviceFd"
|
||||
|
|
@ -52,25 +48,6 @@ struct spa_props {
|
|||
#define SPA_TYPE_PROPS__mute SPA_TYPE_PROPS_BASE "mute"
|
||||
#define SPA_TYPE_PROPS__patternType SPA_TYPE_PROPS_BASE "patternType"
|
||||
|
||||
static inline uint32_t
|
||||
spa_pod_builder_push_props(struct spa_pod_builder *builder,
|
||||
struct spa_pod_frame *frame,
|
||||
uint32_t props_type)
|
||||
{
|
||||
return spa_pod_builder_push_object(builder, frame, 0, props_type);
|
||||
}
|
||||
|
||||
#define spa_pod_builder_props(b,props_type,...) \
|
||||
spa_pod_builder_object(b, 0, props_type,##__VA_ARGS__)
|
||||
|
||||
#define spa_props_parse(props,...) \
|
||||
({ \
|
||||
struct spa_pod_parser __p; \
|
||||
const struct spa_props *__props = props; \
|
||||
spa_pod_parser_pod(&__p, &__props->object.pod); \
|
||||
spa_pod_parser_get(&__p, "<", ##__VA_ARGS__, NULL); \
|
||||
})
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ spa_type_format_video_map(struct spa_type_map *map, struct spa_type_format_video
|
|||
}
|
||||
|
||||
static inline int
|
||||
spa_format_video_raw_parse(const struct spa_format *format,
|
||||
spa_format_video_raw_parse(const struct spa_pod_object *format,
|
||||
struct spa_video_info_raw *info, struct spa_type_format_video *type)
|
||||
{
|
||||
struct spa_pod_parser prs;
|
||||
|
|
@ -98,7 +98,7 @@ spa_format_video_raw_parse(const struct spa_format *format,
|
|||
}
|
||||
|
||||
static inline int
|
||||
spa_format_video_h264_parse(const struct spa_format *format,
|
||||
spa_format_video_h264_parse(const struct spa_pod_object *format,
|
||||
struct spa_video_info_h264 *info, struct spa_type_format_video *type)
|
||||
{
|
||||
struct spa_pod_parser prs;
|
||||
|
|
@ -112,7 +112,7 @@ spa_format_video_h264_parse(const struct spa_format *format,
|
|||
}
|
||||
|
||||
static inline int
|
||||
spa_format_video_mjpg_parse(const struct spa_format *format,
|
||||
spa_format_video_mjpg_parse(const struct spa_pod_object *format,
|
||||
struct spa_video_info_mjpg *info, struct spa_type_format_video *type)
|
||||
{
|
||||
struct spa_pod_parser prs;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue