param: add more generic port params

Remove port properties and replace them with port params. Move the
params from the PortInfo to enum_params.
Use the Param ranges to specify possible sizes etc.
This commit is contained in:
Wim Taymans 2017-05-22 13:06:18 +02:00
parent 12effccb06
commit d1a6d6e03f
37 changed files with 1044 additions and 755 deletions

View file

@ -27,7 +27,7 @@ extern "C" {
#include <spa/defs.h> #include <spa/defs.h>
#include <spa/props.h> #include <spa/props.h>
#include <spa/format.h> #include <spa/format.h>
#include <spa/alloc-param.h> #include <spa/param-alloc.h>
#include <spa/node.h> #include <spa/node.h>
typedef struct _PinosClientNodeBuffer PinosClientNodeBuffer; typedef struct _PinosClientNodeBuffer PinosClientNodeBuffer;
@ -184,13 +184,14 @@ typedef struct {
uint32_t port_id, uint32_t port_id,
#define PINOS_MESSAGE_PORT_UPDATE_POSSIBLE_FORMATS (1 << 0) #define PINOS_MESSAGE_PORT_UPDATE_POSSIBLE_FORMATS (1 << 0)
#define PINOS_MESSAGE_PORT_UPDATE_FORMAT (1 << 1) #define PINOS_MESSAGE_PORT_UPDATE_FORMAT (1 << 1)
#define PINOS_MESSAGE_PORT_UPDATE_PROPS (1 << 2) #define PINOS_MESSAGE_PORT_UPDATE_PARAMS (1 << 2)
#define PINOS_MESSAGE_PORT_UPDATE_INFO (1 << 3) #define PINOS_MESSAGE_PORT_UPDATE_INFO (1 << 3)
uint32_t change_mask, uint32_t change_mask,
uint32_t n_possible_formats, uint32_t n_possible_formats,
const SpaFormat **possible_formats, const SpaFormat **possible_formats,
const SpaFormat *format, const SpaFormat *format,
const SpaProps *props, uint32_t n_params,
const SpaParam **params,
const SpaPortInfo *info); const SpaPortInfo *info);
void (*event) (void *object, void (*event) (void *object,
SpaEvent *event); SpaEvent *event);

View file

@ -500,14 +500,15 @@ client_node_marshal_port_update (void *object,
uint32_t n_possible_formats, uint32_t n_possible_formats,
const SpaFormat **possible_formats, const SpaFormat **possible_formats,
const SpaFormat *format, const SpaFormat *format,
const SpaProps *props, uint32_t n_params,
const SpaParam **params,
const SpaPortInfo *info) const SpaPortInfo *info)
{ {
PinosProxy *proxy = object; PinosProxy *proxy = object;
PinosConnection *connection = proxy->context->protocol_private; PinosConnection *connection = proxy->context->protocol_private;
Builder b = { { NULL, 0, 0, NULL, write_pod }, connection }; Builder b = { { NULL, 0, 0, NULL, write_pod }, connection };
SpaPODFrame f[2]; SpaPODFrame f[2];
int i, n_items; int i;
if (connection == NULL) if (connection == NULL)
return; return;
@ -527,31 +528,20 @@ client_node_marshal_port_update (void *object,
spa_pod_builder_add (&b.b, spa_pod_builder_add (&b.b,
SPA_POD_TYPE_POD, format, SPA_POD_TYPE_POD, format,
SPA_POD_TYPE_POD, props, SPA_POD_TYPE_INT, n_params,
0); 0);
for (i = 0; i < n_params; i++) {
const SpaParam *p = params[i];
spa_pod_builder_add (&b.b, SPA_POD_TYPE_POD, p, 0);
}
if (info) { if (info) {
spa_pod_builder_add (&b.b, spa_pod_builder_add (&b.b,
SPA_POD_TYPE_STRUCT, &f[1], SPA_POD_TYPE_STRUCT, &f[1],
SPA_POD_TYPE_INT, info->flags, SPA_POD_TYPE_INT, info->flags,
SPA_POD_TYPE_INT, info->rate, SPA_POD_TYPE_INT, info->rate,
SPA_POD_TYPE_LONG, info->maxbuffering,
SPA_POD_TYPE_LONG, info->latency,
SPA_POD_TYPE_INT, info->n_params,
0); 0);
for (i = 0; i < info->n_params; i++) {
SpaAllocParam *p = info->params[i];
spa_pod_builder_add (&b.b, SPA_POD_TYPE_POD, p, 0);
}
n_items = info->extra ? info->extra->n_items : 0;
spa_pod_builder_add (&b.b, SPA_POD_TYPE_INT, n_items, 0);
for (i = 0; i < n_items; i++) {
spa_pod_builder_add (&b.b,
SPA_POD_TYPE_STRING, info->extra->items[i].key,
SPA_POD_TYPE_STRING, info->extra->items[i].value,
0);
}
spa_pod_builder_add (&b.b, -SPA_POD_TYPE_STRUCT, &f[1], 0); spa_pod_builder_add (&b.b, -SPA_POD_TYPE_STRUCT, &f[1], 0);
} else { } else {
spa_pod_builder_add (&b.b, SPA_POD_TYPE_POD, NULL, 0); spa_pod_builder_add (&b.b, SPA_POD_TYPE_POD, NULL, 0);

View file

@ -65,6 +65,9 @@ typedef struct
uint32_t n_possible_formats; uint32_t n_possible_formats;
SpaFormat **possible_formats; SpaFormat **possible_formats;
uint32_t n_params;
SpaParam **params;
SpaFormat *format; SpaFormat *format;
SpaPortInfo port_info; SpaPortInfo port_info;
SpaDirection direction; SpaDirection direction;
@ -289,6 +292,28 @@ set_possible_formats (PinosStream *stream,
} }
} }
static void
set_params (PinosStream *stream,
int n_params,
SpaParam **params)
{
PinosStreamImpl *impl = SPA_CONTAINER_OF (stream, PinosStreamImpl, this);
int i;
if (impl->params) {
for (i = 0; i < impl->n_params; i++)
free (impl->params[i]);
free (impl->params);
impl->params = NULL;
}
impl->n_params = n_params;
if (n_params > 0) {
impl->params = malloc (n_params * sizeof (SpaParam *));
for (i = 0; i < n_params; i++)
impl->params[i] = spa_param_copy (params[i]);
}
}
void void
pinos_stream_destroy (PinosStream *stream) pinos_stream_destroy (PinosStream *stream)
{ {
@ -306,6 +331,7 @@ pinos_stream_destroy (PinosStream *stream)
pinos_signal_remove (&impl->node_proxy_destroy); pinos_signal_remove (&impl->node_proxy_destroy);
set_possible_formats (stream, 0, NULL); set_possible_formats (stream, 0, NULL);
set_params (stream, 0, NULL);
if (impl->format) if (impl->format)
free (impl->format); free (impl->format);
@ -361,7 +387,8 @@ add_port_update (PinosStream *stream, uint32_t change_mask)
impl->n_possible_formats, impl->n_possible_formats,
(const SpaFormat **) impl->possible_formats, (const SpaFormat **) impl->possible_formats,
impl->format, impl->format,
NULL, impl->n_params,
(const SpaParam **)impl->params,
&impl->port_info); &impl->port_info);
} }
@ -1028,7 +1055,7 @@ pinos_stream_connect (PinosStream *stream,
* pinos_stream_finish_format: * pinos_stream_finish_format:
* @stream: a #PinosStream * @stream: a #PinosStream
* @res: a #SpaResult * @res: a #SpaResult
* @params: an array of pointers to #SpaAllocParam * @params: an array of pointers to #SpaParam
* @n_params: number of elements in @params * @n_params: number of elements in @params
* *
* Complete the negotiation process with result code @res. * Complete the negotiation process with result code @res.
@ -1043,16 +1070,15 @@ pinos_stream_connect (PinosStream *stream,
bool bool
pinos_stream_finish_format (PinosStream *stream, pinos_stream_finish_format (PinosStream *stream,
SpaResult res, SpaResult res,
SpaAllocParam **params, SpaParam **params,
uint32_t n_params) uint32_t n_params)
{ {
PinosStreamImpl *impl = SPA_CONTAINER_OF (stream, PinosStreamImpl, this); PinosStreamImpl *impl = SPA_CONTAINER_OF (stream, PinosStreamImpl, this);
impl->port_info.params = params; set_params (stream, n_params, params);
impl->port_info.n_params = n_params;
if (SPA_RESULT_IS_OK (res)) { if (SPA_RESULT_IS_OK (res)) {
add_port_update (stream, (n_params ? PINOS_MESSAGE_PORT_UPDATE_INFO : 0) | add_port_update (stream, (n_params ? PINOS_MESSAGE_PORT_UPDATE_PARAMS : 0) |
PINOS_MESSAGE_PORT_UPDATE_FORMAT); PINOS_MESSAGE_PORT_UPDATE_FORMAT);
if (!impl->format) { if (!impl->format) {
@ -1060,9 +1086,6 @@ pinos_stream_finish_format (PinosStream *stream,
clear_mems (stream); clear_mems (stream);
} }
} }
impl->port_info.params = NULL;
impl->port_info.n_params = 0;
add_async_complete (stream, impl->pending_seq, res); add_async_complete (stream, impl->pending_seq, res);
impl->pending_seq = SPA_ID_INVALID; impl->pending_seq = SPA_ID_INVALID;

View file

@ -113,7 +113,7 @@ bool pinos_stream_disconnect (PinosStream *stream);
bool pinos_stream_finish_format (PinosStream *stream, bool pinos_stream_finish_format (PinosStream *stream,
SpaResult res, SpaResult res,
SpaAllocParam **params, SpaParam **params,
uint32_t n_params); uint32_t n_params);
bool pinos_stream_get_time (PinosStream *stream, bool pinos_stream_get_time (PinosStream *stream,

View file

@ -56,9 +56,9 @@ pinos_type_init (PinosType *type)
spa_type_event_node_map (type->map, &type->event_node); spa_type_event_node_map (type->map, &type->event_node);
spa_type_command_node_map (type->map, &type->command_node); spa_type_command_node_map (type->map, &type->command_node);
spa_type_monitor_map (type->map, &type->monitor); spa_type_monitor_map (type->map, &type->monitor);
spa_type_alloc_param_buffers_map (type->map, &type->alloc_param_buffers); spa_type_param_alloc_buffers_map (type->map, &type->param_alloc_buffers);
spa_type_alloc_param_meta_enable_map (type->map, &type->alloc_param_meta_enable); spa_type_param_alloc_meta_enable_map (type->map, &type->param_alloc_meta_enable);
spa_type_alloc_param_video_padding_map (type->map, &type->alloc_param_video_padding); spa_type_param_alloc_video_padding_map (type->map, &type->param_alloc_video_padding);
pinos_type_event_transport_map (type->map, &type->event_transport); pinos_type_event_transport_map (type->map, &type->event_transport);
} }

View file

@ -28,7 +28,7 @@ extern "C" {
#include <spa/event-node.h> #include <spa/event-node.h>
#include <spa/command-node.h> #include <spa/command-node.h>
#include <spa/monitor.h> #include <spa/monitor.h>
#include <spa/alloc-param.h> #include <spa/param-alloc.h>
#include <pinos/client/map.h> #include <pinos/client/map.h>
#include <pinos/client/transport.h> #include <pinos/client/transport.h>
@ -63,9 +63,9 @@ struct _PinosType {
SpaTypeEventNode event_node; SpaTypeEventNode event_node;
SpaTypeCommandNode command_node; SpaTypeCommandNode command_node;
SpaTypeMonitor monitor; SpaTypeMonitor monitor;
SpaTypeAllocParamBuffers alloc_param_buffers; SpaTypeParamAllocBuffers param_alloc_buffers;
SpaTypeAllocParamMetaEnable alloc_param_meta_enable; SpaTypeParamAllocMetaEnable param_alloc_meta_enable;
SpaTypeAllocParamVideoPadding alloc_param_video_padding; SpaTypeParamAllocVideoPadding param_alloc_video_padding;
PinosTypeEventTransport event_transport; PinosTypeEventTransport event_transport;
}; };

View file

@ -48,7 +48,7 @@ pinos_spa_pod_copy (const SpaPOD *pod)
#define spa_format_copy(f) ((SpaFormat*)pinos_spa_pod_copy(&(f)->pod)) #define spa_format_copy(f) ((SpaFormat*)pinos_spa_pod_copy(&(f)->pod))
#define spa_props_copy(p) ((SpaProps*)pinos_spa_pod_copy(&(p)->pod)) #define spa_props_copy(p) ((SpaProps*)pinos_spa_pod_copy(&(p)->pod))
#define spa_alloc_param_copy(p) ((SpaAllocParam*)pinos_spa_pod_copy(&(p)->pod)) #define spa_param_copy(p) ((SpaParam*)pinos_spa_pod_copy(&(p)->pod))
#ifdef __cplusplus #ifdef __cplusplus
} /* extern "C" */ } /* extern "C" */

View file

@ -247,10 +247,11 @@ on_stream_format_changed (PinosListener *listener,
PinosContext *ctx = stream->context; PinosContext *ctx = stream->context;
SpaPODBuilder b = { NULL }; SpaPODBuilder b = { NULL };
SpaPODFrame f[2]; SpaPODFrame f[2];
SpaAllocParam *params[2]; SpaParam *params[2];
if (format) { if (format) {
Uint32 sdl_format; Uint32 sdl_format;
void *d;
spa_debug_format (format, data->context->type.map); spa_debug_format (format, data->context->type.map);
@ -267,21 +268,22 @@ on_stream_format_changed (PinosListener *listener,
SDL_TEXTUREACCESS_STREAMING, SDL_TEXTUREACCESS_STREAMING,
data->format.size.width, data->format.size.width,
data->format.size.height); data->format.size.height);
data->stride = data->format.size.width * 4; SDL_LockTexture (data->texture, NULL, &d, &data->stride);
SDL_UnlockTexture (data->texture);
spa_pod_builder_init (&b, data->params_buffer, sizeof (data->params_buffer)); spa_pod_builder_init (&b, data->params_buffer, sizeof (data->params_buffer));
spa_pod_builder_object (&b, &f[0], 0, ctx->type.alloc_param_buffers.Buffers, spa_pod_builder_object (&b, &f[0], 0, ctx->type.param_alloc_buffers.Buffers,
PROP (&f[1], ctx->type.alloc_param_buffers.size, SPA_POD_TYPE_INT, PROP (&f[1], ctx->type.param_alloc_buffers.size, SPA_POD_TYPE_INT,
data->stride * data->format.size.height), data->stride * data->format.size.height),
PROP (&f[1], ctx->type.alloc_param_buffers.stride, SPA_POD_TYPE_INT, data->stride), PROP (&f[1], ctx->type.param_alloc_buffers.stride, SPA_POD_TYPE_INT, data->stride),
PROP_U_MM (&f[1], ctx->type.alloc_param_buffers.buffers, SPA_POD_TYPE_INT, 32, 2, 32), PROP_U_MM (&f[1], ctx->type.param_alloc_buffers.buffers, SPA_POD_TYPE_INT, 32, 2, 32),
PROP (&f[1], ctx->type.alloc_param_buffers.align, SPA_POD_TYPE_INT, 16)); PROP (&f[1], ctx->type.param_alloc_buffers.align, SPA_POD_TYPE_INT, 16));
params[0] = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaAllocParam); params[0] = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaParam);
spa_pod_builder_object (&b, &f[0], 0, ctx->type.alloc_param_meta_enable.MetaEnable, spa_pod_builder_object (&b, &f[0], 0, ctx->type.param_alloc_meta_enable.MetaEnable,
PROP (&f[1], ctx->type.alloc_param_meta_enable.type, SPA_POD_TYPE_ID, ctx->type.meta.Header), PROP (&f[1], ctx->type.param_alloc_meta_enable.type, SPA_POD_TYPE_ID, ctx->type.meta.Header),
PROP (&f[1], ctx->type.alloc_param_meta_enable.size, SPA_POD_TYPE_INT, sizeof (SpaMetaHeader))); PROP (&f[1], ctx->type.param_alloc_meta_enable.size, SPA_POD_TYPE_INT, sizeof (SpaMetaHeader)));
params[1] = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaAllocParam); params[1] = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaParam);
pinos_stream_finish_format (stream, SPA_RESULT_OK, params, 2); pinos_stream_finish_format (stream, SPA_RESULT_OK, params, 2);
} }

View file

@ -19,6 +19,7 @@
#include <stdio.h> #include <stdio.h>
#include <errno.h> #include <errno.h>
#include <time.h>
#include <sys/mman.h> #include <sys/mman.h>
#include <spa/type-map.h> #include <spa/type-map.h>
@ -76,6 +77,7 @@ typedef struct {
uint8_t params_buffer[1024]; uint8_t params_buffer[1024];
int counter; int counter;
uint32_t seq;
} Data; } Data;
static void static void
@ -88,6 +90,7 @@ on_timeout (SpaLoopUtils *utils,
SpaBuffer *buf; SpaBuffer *buf;
int i, j; int i, j;
uint8_t *p, *map; uint8_t *p, *map;
SpaMetaHeader *h;
id = pinos_stream_get_empty_buffer (data->stream); id = pinos_stream_get_empty_buffer (data->stream);
if (id == SPA_ID_INVALID) if (id == SPA_ID_INVALID)
@ -110,6 +113,15 @@ on_timeout (SpaLoopUtils *utils,
} else } else
return; return;
if ((h = spa_buffer_find_meta (buf, data->type.meta.Header))) {
struct timespec now;
h->flags = 0;
h->seq = data->seq++;
clock_gettime (CLOCK_MONOTONIC, &now);
h->pts = SPA_TIMESPEC_TO_TIME (&now);
h->dts_offset = 0;
}
for (i = 0; i < data->format.size.height; i++) { for (i = 0; i < data->format.size.height; i++) {
for (j = 0; j < data->format.size.width * BPP; j++) { for (j = 0; j < data->format.size.width * BPP; j++) {
p[j] = data->counter + j * i; p[j] = data->counter + j * i;
@ -119,7 +131,7 @@ on_timeout (SpaLoopUtils *utils,
} }
if (map) if (map)
munmap (map, buf->datas[0].maxsize); munmap (map, buf->datas[0].maxsize + buf->datas[0].mapoffset);
pinos_stream_send_buffer (data->stream, id); pinos_stream_send_buffer (data->stream, id);
} }
@ -177,7 +189,7 @@ on_stream_format_changed (PinosListener *listener,
PinosContext *ctx = stream->context; PinosContext *ctx = stream->context;
SpaPODBuilder b = { NULL }; SpaPODBuilder b = { NULL };
SpaPODFrame f[2]; SpaPODFrame f[2];
SpaAllocParam *params[2]; SpaParam *params[2];
if (format) { if (format) {
spa_format_video_raw_parse (format, &data->format, &data->type.format_video); spa_format_video_raw_parse (format, &data->format, &data->type.format_video);
@ -185,18 +197,18 @@ on_stream_format_changed (PinosListener *listener,
data->stride = SPA_ROUND_UP_N (data->format.size.width * BPP, 4); data->stride = SPA_ROUND_UP_N (data->format.size.width * BPP, 4);
spa_pod_builder_init (&b, data->params_buffer, sizeof (data->params_buffer)); spa_pod_builder_init (&b, data->params_buffer, sizeof (data->params_buffer));
spa_pod_builder_object (&b, &f[0], 0, ctx->type.alloc_param_buffers.Buffers, spa_pod_builder_object (&b, &f[0], 0, ctx->type.param_alloc_buffers.Buffers,
PROP (&f[1], ctx->type.alloc_param_buffers.size, SPA_POD_TYPE_INT, PROP (&f[1], ctx->type.param_alloc_buffers.size, SPA_POD_TYPE_INT,
data->stride * data->format.size.height), data->stride * data->format.size.height),
PROP (&f[1], ctx->type.alloc_param_buffers.stride, SPA_POD_TYPE_INT, data->stride), PROP (&f[1], ctx->type.param_alloc_buffers.stride, SPA_POD_TYPE_INT, data->stride),
PROP_U_MM (&f[1], ctx->type.alloc_param_buffers.buffers, SPA_POD_TYPE_INT, 32, 2, 32), PROP_U_MM (&f[1], ctx->type.param_alloc_buffers.buffers, SPA_POD_TYPE_INT, 32, 2, 32),
PROP (&f[1], ctx->type.alloc_param_buffers.align, SPA_POD_TYPE_INT, 16)); PROP (&f[1], ctx->type.param_alloc_buffers.align, SPA_POD_TYPE_INT, 16));
params[0] = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaAllocParam); params[0] = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaParam);
spa_pod_builder_object (&b, &f[0], 0, ctx->type.alloc_param_meta_enable.MetaEnable, spa_pod_builder_object (&b, &f[0], 0, ctx->type.param_alloc_meta_enable.MetaEnable,
PROP (&f[1], ctx->type.alloc_param_meta_enable.type, SPA_POD_TYPE_ID, ctx->type.meta.Header), PROP (&f[1], ctx->type.param_alloc_meta_enable.type, SPA_POD_TYPE_ID, ctx->type.meta.Header),
PROP (&f[1], ctx->type.alloc_param_meta_enable.size, SPA_POD_TYPE_INT, sizeof (SpaMetaHeader))); PROP (&f[1], ctx->type.param_alloc_meta_enable.size, SPA_POD_TYPE_INT, sizeof (SpaMetaHeader)));
params[1] = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaAllocParam); params[1] = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaParam);
pinos_stream_finish_format (stream, SPA_RESULT_OK, params, 2); pinos_stream_finish_format (stream, SPA_RESULT_OK, params, 2);
} }

View file

@ -243,7 +243,7 @@ pool_activated (GstPinosPool *pool, GstPinosSink *sink)
guint size; guint size;
guint min_buffers; guint min_buffers;
guint max_buffers; guint max_buffers;
SpaAllocParam *port_params[3]; SpaParam *port_params[3];
SpaPODBuilder b = { NULL }; SpaPODBuilder b = { NULL };
uint8_t buffer[1024]; uint8_t buffer[1024];
SpaPODFrame f[2]; SpaPODFrame f[2];
@ -252,28 +252,37 @@ pool_activated (GstPinosPool *pool, GstPinosSink *sink)
gst_buffer_pool_config_get_params (config, &caps, &size, &min_buffers, &max_buffers); gst_buffer_pool_config_get_params (config, &caps, &size, &min_buffers, &max_buffers);
spa_pod_builder_init (&b, buffer, sizeof (buffer)); spa_pod_builder_init (&b, buffer, sizeof (buffer));
spa_pod_builder_object (&b, &f[0], 0, ctx->type.alloc_param_buffers.Buffers, spa_pod_builder_push_object (&b, &f[0], 0, ctx->type.param_alloc_buffers.Buffers);
PROP (&f[1], ctx->type.alloc_param_buffers.size, SPA_POD_TYPE_INT, size), if (size == 0)
PROP (&f[1], ctx->type.alloc_param_buffers.stride, SPA_POD_TYPE_INT, 0), spa_pod_builder_add (&b,
PROP_MM (&f[1], ctx->type.alloc_param_buffers.buffers, SPA_POD_TYPE_INT, min_buffers, min_buffers, max_buffers), PROP_U_MM (&f[1], ctx->type.param_alloc_buffers.size, SPA_POD_TYPE_INT, 0, 0, INT32_MAX), 0);
PROP (&f[1], ctx->type.alloc_param_buffers.align, SPA_POD_TYPE_INT, 16)); else
port_params[0] = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaAllocParam); spa_pod_builder_add (&b,
PROP_MM (&f[1], ctx->type.param_alloc_buffers.size, SPA_POD_TYPE_INT, size, size, INT32_MAX), 0);
spa_pod_builder_object (&b, &f[0], 0, ctx->type.alloc_param_meta_enable.MetaEnable, spa_pod_builder_add (&b,
PROP (&f[1], ctx->type.alloc_param_meta_enable.type, SPA_POD_TYPE_ID, ctx->type.meta.Header), PROP_MM (&f[1], ctx->type.param_alloc_buffers.stride, SPA_POD_TYPE_INT, 0, 0, INT32_MAX),
PROP (&f[1], ctx->type.alloc_param_meta_enable.size, SPA_POD_TYPE_INT, sizeof (SpaMetaHeader))); PROP_U_MM (&f[1], ctx->type.param_alloc_buffers.buffers, SPA_POD_TYPE_INT, min_buffers, min_buffers, max_buffers ? max_buffers : INT32_MAX),
port_params[1] = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaAllocParam); PROP (&f[1], ctx->type.param_alloc_buffers.align, SPA_POD_TYPE_INT, 16),
0);
spa_pod_builder_pop (&b, &f[0]);
port_params[0] = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaParam);
spa_pod_builder_object (&b, &f[0], 0, ctx->type.alloc_param_meta_enable.MetaEnable, spa_pod_builder_object (&b, &f[0], 0, ctx->type.param_alloc_meta_enable.MetaEnable,
PROP (&f[1], ctx->type.alloc_param_meta_enable.type, SPA_POD_TYPE_ID, ctx->type.meta.Ringbuffer), PROP (&f[1], ctx->type.param_alloc_meta_enable.type, SPA_POD_TYPE_ID, ctx->type.meta.Header),
PROP (&f[1], ctx->type.alloc_param_meta_enable.size, SPA_POD_TYPE_INT, sizeof (SpaRingbuffer)), PROP (&f[1], ctx->type.param_alloc_meta_enable.size, SPA_POD_TYPE_INT, sizeof (SpaMetaHeader)));
PROP (&f[1], ctx->type.alloc_param_meta_enable.ringbufferSize, SPA_POD_TYPE_INT, port_params[1] = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaParam);
spa_pod_builder_object (&b, &f[0], 0, ctx->type.param_alloc_meta_enable.MetaEnable,
PROP (&f[1], ctx->type.param_alloc_meta_enable.type, SPA_POD_TYPE_ID, ctx->type.meta.Ringbuffer),
PROP (&f[1], ctx->type.param_alloc_meta_enable.size, SPA_POD_TYPE_INT, sizeof (SpaRingbuffer)),
PROP (&f[1], ctx->type.param_alloc_meta_enable.ringbufferSize, SPA_POD_TYPE_INT,
size * SPA_MAX (4, size * SPA_MAX (4,
SPA_MAX (min_buffers, max_buffers))), SPA_MAX (min_buffers, max_buffers))),
PROP (&f[1], ctx->type.alloc_param_meta_enable.ringbufferStride, SPA_POD_TYPE_INT, 0), PROP (&f[1], ctx->type.param_alloc_meta_enable.ringbufferStride, SPA_POD_TYPE_INT, 0),
PROP (&f[1], ctx->type.alloc_param_meta_enable.ringbufferBlocks, SPA_POD_TYPE_INT, 1), PROP (&f[1], ctx->type.param_alloc_meta_enable.ringbufferBlocks, SPA_POD_TYPE_INT, 1),
PROP (&f[1], ctx->type.alloc_param_meta_enable.ringbufferAlign, SPA_POD_TYPE_INT, 16)); PROP (&f[1], ctx->type.param_alloc_meta_enable.ringbufferAlign, SPA_POD_TYPE_INT, 16));
port_params[2] = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaAllocParam); port_params[2] = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaParam);
pinos_stream_finish_format (sink->stream, SPA_RESULT_OK, port_params, 2); pinos_stream_finish_format (sink->stream, SPA_RESULT_OK, port_params, 2);
} }

View file

@ -776,6 +776,10 @@ connect_error:
#define PROP(f,key,type,...) \ #define PROP(f,key,type,...) \
SPA_POD_PROP (f,key,0,type,1,__VA_ARGS__) SPA_POD_PROP (f,key,0,type,1,__VA_ARGS__)
#define PROP_U_MM(f,key,type,...) \
SPA_POD_PROP (f,key,SPA_POD_PROP_FLAG_UNSET | \
SPA_POD_PROP_RANGE_MIN_MAX,type,3,__VA_ARGS__)
static void static void
on_format_changed (PinosListener *listener, on_format_changed (PinosListener *listener,
PinosStream *stream, PinosStream *stream,
@ -798,19 +802,26 @@ on_format_changed (PinosListener *listener,
gst_caps_unref (caps); gst_caps_unref (caps);
if (res) { if (res) {
SpaAllocParam *params[1]; SpaParam *params[2];
SpaPODBuilder b = { NULL }; SpaPODBuilder b = { NULL };
uint8_t buffer[128]; uint8_t buffer[512];
SpaPODFrame f[2]; SpaPODFrame f[2];
spa_pod_builder_init (&b, buffer, sizeof (buffer)); spa_pod_builder_init (&b, buffer, sizeof (buffer));
spa_pod_builder_object (&b, &f[0], 0, ctx->type.alloc_param_meta_enable.MetaEnable, spa_pod_builder_object (&b, &f[0], 0, ctx->type.param_alloc_buffers.Buffers,
PROP (&f[1], ctx->type.alloc_param_meta_enable.type, SPA_POD_TYPE_ID, ctx->type.meta.Header), PROP_U_MM (&f[1], ctx->type.param_alloc_buffers.size, SPA_POD_TYPE_INT, 0, 0, INT32_MAX),
PROP (&f[1], ctx->type.alloc_param_meta_enable.size, SPA_POD_TYPE_INT, sizeof (SpaMetaHeader))); PROP_U_MM (&f[1], ctx->type.param_alloc_buffers.stride, SPA_POD_TYPE_INT, 0, 0, INT32_MAX),
params[0] = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaAllocParam); PROP_U_MM (&f[1], ctx->type.param_alloc_buffers.buffers, SPA_POD_TYPE_INT, 16, 0, INT32_MAX),
PROP (&f[1], ctx->type.param_alloc_buffers.align, SPA_POD_TYPE_INT, 16));
params[0] = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaParam);
spa_pod_builder_object (&b, &f[0], 0, ctx->type.param_alloc_meta_enable.MetaEnable,
PROP (&f[1], ctx->type.param_alloc_meta_enable.type, SPA_POD_TYPE_ID, ctx->type.meta.Header),
PROP (&f[1], ctx->type.param_alloc_meta_enable.size, SPA_POD_TYPE_INT, sizeof (SpaMetaHeader)));
params[1] = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaParam);
GST_DEBUG_OBJECT (pinossrc, "doing finish format"); GST_DEBUG_OBJECT (pinossrc, "doing finish format");
pinos_stream_finish_format (pinossrc->stream, SPA_RESULT_OK, params, 1); pinos_stream_finish_format (pinossrc->stream, SPA_RESULT_OK, params, 2);
} else { } else {
GST_WARNING_OBJECT (pinossrc, "finish format with error"); GST_WARNING_OBJECT (pinossrc, "finish format with error");
pinos_stream_finish_format (pinossrc->stream, SPA_RESULT_INVALID_MEDIA_TYPE, NULL, 0); pinos_stream_finish_format (pinossrc->stream, SPA_RESULT_INVALID_MEDIA_TYPE, NULL, 0);

View file

@ -76,6 +76,8 @@ typedef struct {
SpaFormat *format; SpaFormat *format;
uint32_t n_formats; uint32_t n_formats;
SpaFormat **formats; SpaFormat **formats;
uint32_t n_params;
SpaParam **params;
SpaPortIO *io; SpaPortIO *io;
uint32_t n_buffers; uint32_t n_buffers;
@ -306,7 +308,8 @@ do_update_port (SpaProxy *this,
uint32_t n_possible_formats, uint32_t n_possible_formats,
const SpaFormat **possible_formats, const SpaFormat **possible_formats,
const SpaFormat *format, const SpaFormat *format,
const SpaProps *props, uint32_t n_params,
const SpaParam **params,
const SpaPortInfo *info) const SpaPortInfo *info)
{ {
SpaProxyPort *port; SpaProxyPort *port;
@ -332,20 +335,17 @@ do_update_port (SpaProxy *this,
port->format = spa_format_copy (format); port->format = spa_format_copy (format);
} }
if (change_mask & PINOS_MESSAGE_PORT_UPDATE_PROPS) { if (change_mask & PINOS_MESSAGE_PORT_UPDATE_PARAMS) {
for (i = 0; i < port->n_params; i++)
free (port->params[i]);
port->n_params = n_params;
port->params = realloc (port->params, port->n_params * sizeof (SpaParam *));
for (i = 0; i < port->n_params; i++)
port->params[i] = spa_param_copy (params[i]);
} }
if (change_mask & PINOS_MESSAGE_PORT_UPDATE_INFO && info) { if (change_mask & PINOS_MESSAGE_PORT_UPDATE_INFO && info)
void *old;
for (i = 0; i < port->info.n_params; i++)
free (port->info.params[i]);
old = port->info.params;
port->info = *info; port->info = *info;
port->info.params = realloc (old, port->info.n_params * sizeof (SpaAllocParam *));
for (i = 0; i < port->info.n_params; i++)
port->info.params[i] = spa_alloc_param_copy (info->params[i]);
port->info.extra = NULL;
}
if (!port->valid) { if (!port->valid) {
spa_log_info (this->log, "proxy %p: adding port %d", this, port_id); spa_log_info (this->log, "proxy %p: adding port %d", this, port_id);
@ -370,11 +370,12 @@ clear_port (SpaProxy *this,
port_id, port_id,
PINOS_MESSAGE_PORT_UPDATE_POSSIBLE_FORMATS | PINOS_MESSAGE_PORT_UPDATE_POSSIBLE_FORMATS |
PINOS_MESSAGE_PORT_UPDATE_FORMAT | PINOS_MESSAGE_PORT_UPDATE_FORMAT |
PINOS_MESSAGE_PORT_UPDATE_PROPS | PINOS_MESSAGE_PORT_UPDATE_PARAMS |
PINOS_MESSAGE_PORT_UPDATE_INFO, PINOS_MESSAGE_PORT_UPDATE_INFO,
0, 0,
NULL, NULL,
NULL, NULL,
0,
NULL, NULL,
NULL); NULL);
clear_buffers (this, port); clear_buffers (this, port);
@ -566,19 +567,37 @@ spa_proxy_node_port_get_info (SpaNode *node,
} }
static SpaResult static SpaResult
spa_proxy_node_port_get_props (SpaNode *node, spa_proxy_node_port_enum_params (SpaNode *node,
SpaDirection direction, SpaDirection direction,
uint32_t port_id, uint32_t port_id,
SpaProps **props) uint32_t index,
SpaParam **param)
{ {
return SPA_RESULT_NOT_IMPLEMENTED; SpaProxy *this;
SpaProxyPort *port;
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, SpaProxy, node);
spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT);
port = direction == SPA_DIRECTION_INPUT ? &this->in_ports[port_id] : &this->out_ports[port_id];
if (index >= port->n_params)
return SPA_RESULT_ENUM_END;
*param = port->params[index];
return SPA_RESULT_OK;
} }
static SpaResult static SpaResult
spa_proxy_node_port_set_props (SpaNode *node, spa_proxy_node_port_set_param (SpaNode *node,
SpaDirection direction, SpaDirection direction,
uint32_t port_id, uint32_t port_id,
const SpaProps *props) const SpaParam *param)
{ {
return SPA_RESULT_NOT_IMPLEMENTED; return SPA_RESULT_NOT_IMPLEMENTED;
} }
@ -726,7 +745,7 @@ static SpaResult
spa_proxy_node_port_alloc_buffers (SpaNode *node, spa_proxy_node_port_alloc_buffers (SpaNode *node,
SpaDirection direction, SpaDirection direction,
uint32_t port_id, uint32_t port_id,
SpaAllocParam **params, SpaParam **params,
uint32_t n_params, uint32_t n_params,
SpaBuffer **buffers, SpaBuffer **buffers,
uint32_t *n_buffers) uint32_t *n_buffers)
@ -927,7 +946,8 @@ client_node_port_update (void *object,
uint32_t n_possible_formats, uint32_t n_possible_formats,
const SpaFormat **possible_formats, const SpaFormat **possible_formats,
const SpaFormat *format, const SpaFormat *format,
const SpaProps *props, uint32_t n_params,
const SpaParam **params,
const SpaPortInfo *info) const SpaPortInfo *info)
{ {
PinosResource *resource = object; PinosResource *resource = object;
@ -952,7 +972,8 @@ client_node_port_update (void *object,
n_possible_formats, n_possible_formats,
possible_formats, possible_formats,
format, format,
props, n_params,
params,
info); info);
} }
} }
@ -1024,8 +1045,8 @@ static const SpaNode proxy_node = {
spa_proxy_node_port_set_format, spa_proxy_node_port_set_format,
spa_proxy_node_port_get_format, spa_proxy_node_port_get_format,
spa_proxy_node_port_get_info, spa_proxy_node_port_get_info,
spa_proxy_node_port_get_props, spa_proxy_node_port_enum_params,
spa_proxy_node_port_set_props, spa_proxy_node_port_set_param,
spa_proxy_node_port_use_buffers, spa_proxy_node_port_use_buffers,
spa_proxy_node_port_alloc_buffers, spa_proxy_node_port_alloc_buffers,
spa_proxy_node_port_set_io, spa_proxy_node_port_set_io,

View file

@ -23,6 +23,8 @@
#include <spa/video/format.h> #include <spa/video/format.h>
#include <spa/pod-utils.h> #include <spa/pod-utils.h>
#include <spa/lib/props.h>
#include "pinos/client/pinos.h" #include "pinos/client/pinos.h"
#include "pinos/client/interfaces.h" #include "pinos/client/interfaces.h"
@ -190,33 +192,33 @@ error:
} }
} }
static void * static SpaParam *
find_param (const SpaPortInfo *info, uint32_t type) find_param (SpaParam **params, int n_params, uint32_t type)
{ {
uint32_t i; uint32_t i;
for (i = 0; i < info->n_params; i++) { for (i = 0; i < n_params; i++) {
if (spa_pod_is_object_type (&info->params[i]->pod, type)) if (spa_pod_is_object_type (&params[i]->pod, type))
return info->params[i]; return params[i];
} }
return NULL; return NULL;
} }
static void * static SpaParam *
find_meta_enable (PinosCore *core, const SpaPortInfo *info, uint32_t type) find_meta_enable (PinosCore *core, SpaParam **params, int n_params, uint32_t type)
{ {
uint32_t i; uint32_t i;
for (i = 0; i < info->n_params; i++) { for (i = 0; i < n_params; i++) {
if (spa_pod_is_object_type (&info->params[i]->pod, core->type.alloc_param_meta_enable.MetaEnable)) { if (spa_pod_is_object_type (&params[i]->pod, core->type.param_alloc_meta_enable.MetaEnable)) {
uint32_t qtype; uint32_t qtype;
if (spa_alloc_param_query (info->params[i], if (spa_param_query (params[i],
core->type.alloc_param_meta_enable.type, SPA_POD_TYPE_ID, &qtype, 0) != 1) core->type.param_alloc_meta_enable.type, SPA_POD_TYPE_ID, &qtype, 0) != 1)
continue; continue;
if (qtype == type) if (qtype == type)
return info->params[i]; return params[i];
} }
} }
return NULL; return NULL;
@ -226,7 +228,7 @@ static SpaBuffer **
alloc_buffers (PinosLink *this, alloc_buffers (PinosLink *this,
uint32_t n_buffers, uint32_t n_buffers,
uint32_t n_params, uint32_t n_params,
SpaAllocParam **params, SpaParam **params,
uint32_t n_datas, uint32_t n_datas,
size_t *data_sizes, size_t *data_sizes,
ssize_t *data_strides, ssize_t *data_strides,
@ -256,17 +258,17 @@ alloc_buffers (PinosLink *this,
/* collect metadata */ /* collect metadata */
for (i = 0; i < n_params; i++) { for (i = 0; i < n_params; i++) {
SpaAllocParam *ap = params[i]; if (spa_pod_is_object_type (&params[i]->pod, this->core->type.param_alloc_meta_enable.MetaEnable)) {
if (ap->pod.type == this->core->type.alloc_param_meta_enable.MetaEnable) {
uint32_t type, size; uint32_t type, size;
if (spa_alloc_param_query (ap, if (spa_param_query (params[i],
this->core->type.alloc_param_meta_enable.type, SPA_POD_TYPE_ID, &type, this->core->type.param_alloc_meta_enable.type, SPA_POD_TYPE_ID, &type,
this->core->type.alloc_param_meta_enable.size, SPA_POD_TYPE_INT, &size, this->core->type.param_alloc_meta_enable.size, SPA_POD_TYPE_INT, &size,
0) != 1) 0) != 2)
continue; continue;
pinos_log_debug ("link %p: enable meta %d %d", this, type, size);
metas[n_metas].type = type; metas[n_metas].type = type;
metas[n_metas].size = size; metas[n_metas].size = size;
meta_size += metas[n_metas].size; meta_size += metas[n_metas].size;
@ -358,6 +360,56 @@ alloc_buffers (PinosLink *this,
return buffers; return buffers;
} }
static int
spa_node_param_filter (PinosLink *this,
SpaNode *in_node,
uint32_t in_port,
SpaNode *out_node,
uint32_t out_port,
SpaPODBuilder *result)
{
SpaResult res;
SpaParam *oparam, *iparam;
int iidx, oidx, num = 0;
for (iidx = 0; ; iidx++) {
if (spa_node_port_enum_params (in_node, SPA_DIRECTION_INPUT, in_port, iidx, &iparam) < 0)
break;
if (pinos_log_level_enabled (SPA_LOG_LEVEL_DEBUG))
spa_debug_param (iparam, this->core->type.map);
for (oidx = 0; ; oidx++) {
SpaPODFrame f;
uint32_t offset;
if (spa_node_port_enum_params (out_node, SPA_DIRECTION_OUTPUT, out_port, oidx, &oparam) < 0)
break;
if (pinos_log_level_enabled (SPA_LOG_LEVEL_DEBUG))
spa_debug_param (oparam, this->core->type.map);
if (iparam->body.body.type != oparam->body.body.type)
continue;
offset = result->offset;
spa_pod_builder_push_object (result, &f, 0, iparam->body.body.type);
if ((res = spa_props_filter (result,
SPA_POD_CONTENTS (SpaParam, iparam),
SPA_POD_CONTENTS_SIZE (SpaParam, iparam),
SPA_POD_CONTENTS (SpaParam, oparam),
SPA_POD_CONTENTS_SIZE (SpaParam, oparam))) < 0) {
result->offset = offset;
result->stack = NULL;
continue;
}
spa_pod_builder_pop (result, &f);
num++;
}
}
return num;
}
static SpaResult static SpaResult
do_allocation (PinosLink *this, uint32_t in_state, uint32_t out_state) do_allocation (PinosLink *this, uint32_t in_state, uint32_t out_state)
{ {
@ -437,55 +489,54 @@ do_allocation (PinosLink *this, uint32_t in_state, uint32_t out_state)
} }
if (impl->buffers == NULL) { if (impl->buffers == NULL) {
SpaAllocParam *in_alloc, *out_alloc; SpaParam **params, *param;
SpaAllocParam *in_me, *out_me; uint8_t buffer[4096];
SpaPODBuilder b = SPA_POD_BUILDER_INIT (buffer, sizeof (buffer));
int i, offset, n_params;
uint32_t max_buffers; uint32_t max_buffers;
size_t minsize = 1024, stride = 0; size_t minsize = 1024, stride = 0;
in_me = find_meta_enable (this->core, iinfo, this->core->type.meta.Ringbuffer); n_params = spa_node_param_filter (this,
out_me = find_meta_enable (this->core, oinfo, this->core->type.meta.Ringbuffer); this->input->node->node,
if (in_me && out_me) { this->input->port_id,
uint32_t ms1, ms2, s1, s2; this->output->node->node,
this->output->port_id,
&b);
params = alloca (n_params * sizeof (SpaParam *));
for (i = 0, offset = 0; i < n_params; i++) {
params[i] = SPA_MEMBER (buffer, offset, SpaParam);
spa_param_fixate (params[i]);
spa_debug_param (params[i], this->core->type.map);
offset += SPA_ROUND_UP_N (SPA_POD_SIZE (params[i]), 8);
}
param = find_meta_enable (this->core, params, n_params,
this->core->type.meta.Ringbuffer);
if (param) {
uint32_t ms, s;
max_buffers = 1; max_buffers = 1;
if (spa_alloc_param_query (in_me, if (spa_param_query (param,
this->core->type.alloc_param_meta_enable.ringbufferSize, SPA_POD_TYPE_INT, &ms1, this->core->type.param_alloc_meta_enable.ringbufferSize, SPA_POD_TYPE_INT, &ms,
this->core->type.alloc_param_meta_enable.ringbufferStride, SPA_POD_TYPE_INT, &s1, 0) == 2 && this->core->type.param_alloc_meta_enable.ringbufferStride, SPA_POD_TYPE_INT, &s, 0) == 2) {
spa_alloc_param_query (in_me, minsize = ms;
this->core->type.alloc_param_meta_enable.ringbufferSize, SPA_POD_TYPE_INT, &ms2, stride = s;
this->core->type.alloc_param_meta_enable.ringbufferStride, SPA_POD_TYPE_INT, &s2, 0) == 2) {
minsize = SPA_MAX (ms1, ms2);
stride = SPA_MAX (s1, s2);
} }
} else { } else {
max_buffers = MAX_BUFFERS; max_buffers = MAX_BUFFERS;
minsize = stride = 0; minsize = stride = 0;
in_alloc = find_param (iinfo, this->core->type.alloc_param_buffers.Buffers); param = find_param (params, n_params,
if (in_alloc) { this->core->type.param_alloc_buffers.Buffers);
if (param) {
uint32_t qmax_buffers = max_buffers, uint32_t qmax_buffers = max_buffers,
qminsize = minsize, qminsize = minsize,
qstride = stride; qstride = stride;
spa_alloc_param_query (in_alloc, spa_param_query (param,
this->core->type.alloc_param_buffers.size, SPA_POD_TYPE_INT, &qminsize, this->core->type.param_alloc_buffers.size, SPA_POD_TYPE_INT, &qminsize,
this->core->type.alloc_param_buffers.stride, SPA_POD_TYPE_INT, &qstride, this->core->type.param_alloc_buffers.stride, SPA_POD_TYPE_INT, &qstride,
this->core->type.alloc_param_buffers.buffers, SPA_POD_TYPE_INT, &qmax_buffers, this->core->type.param_alloc_buffers.buffers, SPA_POD_TYPE_INT, &qmax_buffers,
0);
max_buffers = qmax_buffers == 0 ? max_buffers : SPA_MIN (qmax_buffers, max_buffers);
minsize = SPA_MAX (minsize, qminsize);
stride = SPA_MAX (stride, qstride);
}
out_alloc = find_param (oinfo, this->core->type.alloc_param_buffers.Buffers);
if (out_alloc) {
uint32_t qmax_buffers = max_buffers,
qminsize = minsize,
qstride = stride;
spa_alloc_param_query (out_alloc,
this->core->type.alloc_param_buffers.size, SPA_POD_TYPE_INT, &qminsize,
this->core->type.alloc_param_buffers.stride, SPA_POD_TYPE_INT, &qstride,
this->core->type.alloc_param_buffers.buffers, SPA_POD_TYPE_INT, &qmax_buffers,
0); 0);
max_buffers = qmax_buffers == 0 ? max_buffers : SPA_MIN (qmax_buffers, max_buffers); max_buffers = qmax_buffers == 0 ? max_buffers : SPA_MIN (qmax_buffers, max_buffers);
@ -523,8 +574,8 @@ do_allocation (PinosLink *this, uint32_t in_state, uint32_t out_state)
impl->n_buffers = max_buffers; impl->n_buffers = max_buffers;
impl->buffers = alloc_buffers (this, impl->buffers = alloc_buffers (this,
impl->n_buffers, impl->n_buffers,
oinfo->n_params, n_params,
oinfo->params, params,
1, 1,
data_sizes, data_sizes,
data_strides, data_strides,
@ -537,7 +588,7 @@ do_allocation (PinosLink *this, uint32_t in_state, uint32_t out_state)
if ((res = spa_node_port_alloc_buffers (this->output->node->node, if ((res = spa_node_port_alloc_buffers (this->output->node->node,
SPA_DIRECTION_OUTPUT, SPA_DIRECTION_OUTPUT,
this->output->port_id, this->output->port_id,
iinfo->params, iinfo->n_params, params, n_params,
impl->buffers, &impl->n_buffers)) < 0) { impl->buffers, &impl->n_buffers)) < 0) {
asprintf (&error, "error alloc output buffers: %d", res); asprintf (&error, "error alloc output buffers: %d", res);
goto error; goto error;
@ -553,7 +604,7 @@ do_allocation (PinosLink *this, uint32_t in_state, uint32_t out_state)
if ((res = spa_node_port_alloc_buffers (this->input->node->node, if ((res = spa_node_port_alloc_buffers (this->input->node->node,
SPA_DIRECTION_INPUT, SPA_DIRECTION_INPUT,
this->input->port_id, this->input->port_id,
oinfo->params, oinfo->n_params, params, n_params,
impl->buffers, &impl->n_buffers)) < 0) { impl->buffers, &impl->n_buffers)) < 0) {
asprintf (&error, "error alloc input buffers: %d", res); asprintf (&error, "error alloc input buffers: %d", res);
goto error; goto error;

View file

@ -829,8 +829,8 @@ client_node_demarshal_port_update (void *object,
{ {
PinosResource *resource = object; PinosResource *resource = object;
SpaPODIter it; SpaPODIter it;
uint32_t i, direction, port_id, change_mask, n_possible_formats; uint32_t i, direction, port_id, change_mask, n_possible_formats, n_params;
const SpaProps *props = NULL; const SpaParam **params = NULL;
const SpaFormat **possible_formats = NULL, *format = NULL; const SpaFormat **possible_formats = NULL, *format = NULL;
SpaPortInfo info, *infop = NULL; SpaPortInfo info, *infop = NULL;
SpaPOD *ipod; SpaPOD *ipod;
@ -852,13 +852,21 @@ client_node_demarshal_port_update (void *object,
if (!spa_pod_iter_get (&it, if (!spa_pod_iter_get (&it,
-SPA_POD_TYPE_OBJECT, &format, -SPA_POD_TYPE_OBJECT, &format,
-SPA_POD_TYPE_OBJECT, &props, SPA_POD_TYPE_INT, &n_params,
0))
return false;
params = alloca (n_params * sizeof (SpaParam*));
for (i = 0; i < n_params; i++)
if (!spa_pod_iter_get (&it, SPA_POD_TYPE_OBJECT, &params[i], 0))
return false;
if (!spa_pod_iter_get (&it,
-SPA_POD_TYPE_STRUCT, &ipod, -SPA_POD_TYPE_STRUCT, &ipod,
0)) 0))
return false; return false;
if (ipod) { if (ipod) {
SpaDict dict;
SpaPODIter it2; SpaPODIter it2;
infop = &info; infop = &info;
@ -866,29 +874,8 @@ client_node_demarshal_port_update (void *object,
!spa_pod_iter_get (&it2, !spa_pod_iter_get (&it2,
SPA_POD_TYPE_INT, &info.flags, SPA_POD_TYPE_INT, &info.flags,
SPA_POD_TYPE_INT, &info.rate, SPA_POD_TYPE_INT, &info.rate,
SPA_POD_TYPE_LONG, &info.maxbuffering,
SPA_POD_TYPE_LONG, &info.latency,
SPA_POD_TYPE_INT, &info.n_params,
0)) 0))
return false; return false;
info.params = alloca (info.n_params * sizeof (SpaAllocParam *));
for (i = 0; i < info.n_params; i++)
if (!spa_pod_iter_get (&it2, SPA_POD_TYPE_OBJECT, &info.params[i], 0))
return false;
if (!spa_pod_iter_get (&it2, SPA_POD_TYPE_INT, &dict.n_items, 0))
return false;
info.extra = &dict;
dict.items = alloca (dict.n_items * sizeof (SpaDictItem));
for (i = 0; i < dict.n_items; i++) {
if (!spa_pod_iter_get (&it2,
SPA_POD_TYPE_STRING, &dict.items[i].key,
SPA_POD_TYPE_STRING, &dict.items[i].value,
0))
return false;
}
} }
((PinosClientNodeMethods*)resource->implementation)->port_update (resource, ((PinosClientNodeMethods*)resource->implementation)->port_update (resource,
@ -898,7 +885,8 @@ client_node_demarshal_port_update (void *object,
n_possible_formats, n_possible_formats,
possible_formats, possible_formats,
format, format,
props, n_params,
params,
infop); infop);
return true; return true;
} }

View file

@ -1,163 +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_ALLOC_PARAM_H__
#define __SPA_ALLOC_PARAM_H__
#ifdef __cplusplus
extern "C" {
#endif
typedef struct _SpaAllocParam SpaAllocParam;
#include <spa/defs.h>
#include <spa/type-map.h>
#include <spa/pod-utils.h>
#define SPA_TYPE__AllocParam SPA_TYPE_POD_OBJECT_BASE "AllocParam"
#define SPA_TYPE_ALLOC_PARAM_BASE SPA_TYPE__AllocParam ":"
typedef struct {
SpaPODObjectBody body;
/* SpaPODProp follow */
} SpaAllocParamBody;
struct _SpaAllocParam {
SpaPOD pod;
SpaAllocParamBody body;
};
static inline uint32_t
spa_alloc_param_query (const SpaAllocParam *param, uint32_t key, ...)
{
uint32_t count;
va_list args;
va_start (args, key);
count = spa_pod_contents_queryv (&param->pod, sizeof (SpaAllocParam), key, args);
va_end (args);
return count;
}
#define SPA_TYPE_ALLOC_PARAM__Buffers SPA_TYPE_ALLOC_PARAM_BASE "Buffers"
#define SPA_TYPE_ALLOC_PARAM_BUFFERS_BASE SPA_TYPE_ALLOC_PARAM__Buffers ":"
#define SPA_TYPE_ALLOC_PARAM_BUFFERS__size SPA_TYPE_ALLOC_PARAM_BUFFERS_BASE "size"
#define SPA_TYPE_ALLOC_PARAM_BUFFERS__stride SPA_TYPE_ALLOC_PARAM_BUFFERS_BASE "stride"
#define SPA_TYPE_ALLOC_PARAM_BUFFERS__buffers SPA_TYPE_ALLOC_PARAM_BUFFERS_BASE "buffers"
#define SPA_TYPE_ALLOC_PARAM_BUFFERS__align SPA_TYPE_ALLOC_PARAM_BUFFERS_BASE "align"
typedef struct {
uint32_t Buffers;
uint32_t size;
uint32_t stride;
uint32_t buffers;
uint32_t align;
} SpaTypeAllocParamBuffers;
static inline void
spa_type_alloc_param_buffers_map (SpaTypeMap *map, SpaTypeAllocParamBuffers *type)
{
if (type->Buffers == 0) {
type->Buffers = spa_type_map_get_id (map, SPA_TYPE_ALLOC_PARAM__Buffers);
type->size = spa_type_map_get_id (map, SPA_TYPE_ALLOC_PARAM_BUFFERS__size);
type->stride = spa_type_map_get_id (map, SPA_TYPE_ALLOC_PARAM_BUFFERS__stride);
type->buffers = spa_type_map_get_id (map, SPA_TYPE_ALLOC_PARAM_BUFFERS__buffers);
type->align = spa_type_map_get_id (map, SPA_TYPE_ALLOC_PARAM_BUFFERS__align);
}
}
#define SPA_TYPE_ALLOC_PARAM__MetaEnable SPA_TYPE_ALLOC_PARAM_BASE "MetaEnable"
#define SPA_TYPE_ALLOC_PARAM_META_ENABLE_BASE SPA_TYPE_ALLOC_PARAM__MetaEnable ":"
#define SPA_TYPE_ALLOC_PARAM_META_ENABLE__type SPA_TYPE_ALLOC_PARAM_META_ENABLE_BASE "type"
#define SPA_TYPE_ALLOC_PARAM_META_ENABLE__size SPA_TYPE_ALLOC_PARAM_META_ENABLE_BASE "size"
#define SPA_TYPE_ALLOC_PARAM_META_ENABLE__ringbufferSize SPA_TYPE_ALLOC_PARAM_META_ENABLE_BASE "ringbufferSize"
#define SPA_TYPE_ALLOC_PARAM_META_ENABLE__ringbufferStride SPA_TYPE_ALLOC_PARAM_META_ENABLE_BASE "ringbufferStride"
#define SPA_TYPE_ALLOC_PARAM_META_ENABLE__ringbufferBlocks SPA_TYPE_ALLOC_PARAM_META_ENABLE_BASE "ringbufferBlocks"
#define SPA_TYPE_ALLOC_PARAM_META_ENABLE__ringbufferAlign SPA_TYPE_ALLOC_PARAM_META_ENABLE_BASE "ringbufferAlign"
typedef struct {
uint32_t MetaEnable;
uint32_t type;
uint32_t size;
uint32_t ringbufferSize;
uint32_t ringbufferStride;
uint32_t ringbufferBlocks;
uint32_t ringbufferAlign;
} SpaTypeAllocParamMetaEnable;
static inline void
spa_type_alloc_param_meta_enable_map (SpaTypeMap *map, SpaTypeAllocParamMetaEnable *type)
{
if (type->MetaEnable == 0) {
type->MetaEnable = spa_type_map_get_id (map, SPA_TYPE_ALLOC_PARAM__MetaEnable);
type->type = spa_type_map_get_id (map, SPA_TYPE_ALLOC_PARAM_META_ENABLE__type);
type->size = spa_type_map_get_id (map, SPA_TYPE_ALLOC_PARAM_META_ENABLE__size);
type->ringbufferSize = spa_type_map_get_id (map, SPA_TYPE_ALLOC_PARAM_META_ENABLE__ringbufferSize);
type->ringbufferStride = spa_type_map_get_id (map, SPA_TYPE_ALLOC_PARAM_META_ENABLE__ringbufferStride);
type->ringbufferBlocks = spa_type_map_get_id (map, SPA_TYPE_ALLOC_PARAM_META_ENABLE__ringbufferBlocks);
type->ringbufferAlign = spa_type_map_get_id (map, SPA_TYPE_ALLOC_PARAM_META_ENABLE__ringbufferAlign);
}
}
#define SPA_TYPE_ALLOC_PARAM__VideoPadding SPA_TYPE_ALLOC_PARAM_BASE "VideoPadding"
#define SPA_TYPE_ALLOC_PARAM_VIDEO_PADDING_BASE SPA_TYPE_ALLOC_PARAM__VideoPadding ":"
#define SPA_TYPE_ALLOC_PARAM_VIDEO_PADDING__top SPA_TYPE_ALLOC_PARAM_VIDEO_PADDING_BASE "top"
#define SPA_TYPE_ALLOC_PARAM_VIDEO_PADDING__bottom SPA_TYPE_ALLOC_PARAM_VIDEO_PADDING_BASE "bottom"
#define SPA_TYPE_ALLOC_PARAM_VIDEO_PADDING__left SPA_TYPE_ALLOC_PARAM_VIDEO_PADDING_BASE "left"
#define SPA_TYPE_ALLOC_PARAM_VIDEO_PADDING__right SPA_TYPE_ALLOC_PARAM_VIDEO_PADDING_BASE "right"
#define SPA_TYPE_ALLOC_PARAM_VIDEO_PADDING__strideAlign0 SPA_TYPE_ALLOC_PARAM_VIDEO_PADDING_BASE "strideAlign0"
#define SPA_TYPE_ALLOC_PARAM_VIDEO_PADDING__strideAlign1 SPA_TYPE_ALLOC_PARAM_VIDEO_PADDING_BASE "strideAlign1"
#define SPA_TYPE_ALLOC_PARAM_VIDEO_PADDING__strideAlign2 SPA_TYPE_ALLOC_PARAM_VIDEO_PADDING_BASE "strideAlign2"
#define SPA_TYPE_ALLOC_PARAM_VIDEO_PADDING__strideAlign3 SPA_TYPE_ALLOC_PARAM_VIDEO_PADDING_BASE "strideAlign3"
typedef struct {
uint32_t VideoPadding;
uint32_t top;
uint32_t bottom;
uint32_t left;
uint32_t right;
uint32_t strideAlign[4];
} SpaTypeAllocParamVideoPadding;
static inline void
spa_type_alloc_param_video_padding_map (SpaTypeMap *map, SpaTypeAllocParamVideoPadding *type)
{
if (type->VideoPadding == 0) {
type->VideoPadding = spa_type_map_get_id (map, SPA_TYPE_ALLOC_PARAM__VideoPadding);
type->top = spa_type_map_get_id (map, SPA_TYPE_ALLOC_PARAM_VIDEO_PADDING__top);
type->bottom = spa_type_map_get_id (map, SPA_TYPE_ALLOC_PARAM_VIDEO_PADDING__bottom);
type->left = spa_type_map_get_id (map, SPA_TYPE_ALLOC_PARAM_VIDEO_PADDING__left);
type->right = spa_type_map_get_id (map, SPA_TYPE_ALLOC_PARAM_VIDEO_PADDING__right);
type->strideAlign[0] = spa_type_map_get_id (map, SPA_TYPE_ALLOC_PARAM_VIDEO_PADDING__strideAlign0);
type->strideAlign[1] = spa_type_map_get_id (map, SPA_TYPE_ALLOC_PARAM_VIDEO_PADDING__strideAlign1);
type->strideAlign[2] = spa_type_map_get_id (map, SPA_TYPE_ALLOC_PARAM_VIDEO_PADDING__strideAlign2);
type->strideAlign[3] = spa_type_map_get_id (map, SPA_TYPE_ALLOC_PARAM_VIDEO_PADDING__strideAlign3);
}
}
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* __SPA_ALLOC_PARAM_H__ */

View file

@ -32,7 +32,7 @@ typedef struct _SpaNode SpaNode;
#include <spa/defs.h> #include <spa/defs.h>
#include <spa/plugin.h> #include <spa/plugin.h>
#include <spa/props.h> #include <spa/props.h>
#include <spa/alloc-param.h> #include <spa/param.h>
#include <spa/event-node.h> #include <spa/event-node.h>
#include <spa/command-node.h> #include <spa/command-node.h>
#include <spa/buffer.h> #include <spa/buffer.h>
@ -66,13 +66,14 @@ typedef struct {
* @flags: extra port flags * @flags: extra port flags
* @rate: rate of sequence number increment per second of media data * @rate: rate of sequence number increment per second of media data
* @n_params: number of elements in @params; * @n_params: number of elements in @params;
* @params: extra allocation parameters * @params: type ids of params that can be queried
* @maxbuffering: the maximum amount of bytes that the element will keep * @maxbuffering: the maximum amount of bytes that the element will keep
* around internally * around internally
* @latency: latency on this port in nanoseconds * @latency: latency on this port in nanoseconds
* @extra: a dictionary of extra port info
*/ */
typedef struct { typedef struct {
uint32_t direction;
uint32_t port_id;
#define SPA_PORT_INFO_FLAG_REMOVABLE (1<<0) /* port can be removed */ #define SPA_PORT_INFO_FLAG_REMOVABLE (1<<0) /* port can be removed */
#define SPA_PORT_INFO_FLAG_OPTIONAL (1<<1) /* processing on port is optional */ #define SPA_PORT_INFO_FLAG_OPTIONAL (1<<1) /* processing on port is optional */
#define SPA_PORT_INFO_FLAG_CAN_ALLOC_BUFFERS (1<<2) /* the port can allocate buffer data */ #define SPA_PORT_INFO_FLAG_CAN_ALLOC_BUFFERS (1<<2) /* the port can allocate buffer data */
@ -84,11 +85,6 @@ typedef struct {
* a live clock. */ * a live clock. */
uint32_t flags; uint32_t flags;
uint32_t rate; uint32_t rate;
uint32_t n_params;
SpaAllocParam **params;
uint64_t maxbuffering;
uint64_t latency;
SpaDict *extra;
} SpaPortInfo; } SpaPortInfo;
@ -419,14 +415,15 @@ struct _SpaNode {
uint32_t port_id, uint32_t port_id,
const SpaPortInfo **info); const SpaPortInfo **info);
SpaResult (*port_get_props) (SpaNode *node, SpaResult (*port_enum_params) (SpaNode *node,
SpaDirection direction, SpaDirection direction,
uint32_t port_id, uint32_t port_id,
SpaProps **props); uint32_t index,
SpaResult (*port_set_props) (SpaNode *node, SpaParam **param);
SpaResult (*port_set_param) (SpaNode *node,
SpaDirection direction, SpaDirection direction,
uint32_t port_id, uint32_t port_id,
const SpaProps *props); const SpaParam *param);
/** /**
* SpaNode::port_use_buffers: * SpaNode::port_use_buffers:
@ -501,7 +498,7 @@ struct _SpaNode {
SpaResult (*port_alloc_buffers) (SpaNode *node, SpaResult (*port_alloc_buffers) (SpaNode *node,
SpaDirection direction, SpaDirection direction,
uint32_t port_id, uint32_t port_id,
SpaAllocParam **params, SpaParam **params,
uint32_t n_params, uint32_t n_params,
SpaBuffer **buffers, SpaBuffer **buffers,
uint32_t *n_buffers); uint32_t *n_buffers);
@ -620,8 +617,8 @@ struct _SpaNode {
#define spa_node_port_set_format(n,...) (n)->port_set_format((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_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_get_info(n,...) (n)->port_get_info((n),__VA_ARGS__)
#define spa_node_port_get_props(n,...) (n)->port_get_props((n),__VA_ARGS__) #define spa_node_port_enum_params(n,...) (n)->port_enum_params((n),__VA_ARGS__)
#define spa_node_port_set_props(n,...) (n)->port_set_props((n),__VA_ARGS__) #define spa_node_port_set_param(n,...) (n)->port_set_param((n),__VA_ARGS__)
#define spa_node_port_use_buffers(n,...) (n)->port_use_buffers((n),__VA_ARGS__) #define spa_node_port_use_buffers(n,...) (n)->port_use_buffers((n),__VA_ARGS__)
#define spa_node_port_alloc_buffers(n,...) (n)->port_alloc_buffers((n),__VA_ARGS__) #define spa_node_port_alloc_buffers(n,...) (n)->port_alloc_buffers((n),__VA_ARGS__)
#define spa_node_port_set_io(n,...) (n)->port_set_io((n),__VA_ARGS__) #define spa_node_port_set_io(n,...) (n)->port_set_io((n),__VA_ARGS__)

View file

@ -0,0 +1,138 @@
/* 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_PARAM_ALLOC_H__
#define __SPA_PARAM_ALLOC_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <spa/defs.h>
#include <spa/param.h>
#include <spa/type-map.h>
#define SPA_TYPE__ParamAlloc SPA_TYPE_PARAM_BASE "Alloc"
#define SPA_TYPE_PARAM_ALLOC_BASE SPA_TYPE__ParamAlloc ":"
#define SPA_TYPE_PARAM_ALLOC__Buffers SPA_TYPE_PARAM_ALLOC_BASE "Buffers"
#define SPA_TYPE_PARAM_ALLOC_BUFFERS_BASE SPA_TYPE_PARAM_ALLOC__Buffers ":"
#define SPA_TYPE_PARAM_ALLOC_BUFFERS__size SPA_TYPE_PARAM_ALLOC_BUFFERS_BASE "size"
#define SPA_TYPE_PARAM_ALLOC_BUFFERS__stride SPA_TYPE_PARAM_ALLOC_BUFFERS_BASE "stride"
#define SPA_TYPE_PARAM_ALLOC_BUFFERS__buffers SPA_TYPE_PARAM_ALLOC_BUFFERS_BASE "buffers"
#define SPA_TYPE_PARAM_ALLOC_BUFFERS__align SPA_TYPE_PARAM_ALLOC_BUFFERS_BASE "align"
typedef struct {
uint32_t Buffers;
uint32_t size;
uint32_t stride;
uint32_t buffers;
uint32_t align;
} SpaTypeParamAllocBuffers;
static inline void
spa_type_param_alloc_buffers_map (SpaTypeMap *map, SpaTypeParamAllocBuffers *type)
{
if (type->Buffers == 0) {
type->Buffers = spa_type_map_get_id (map, SPA_TYPE_PARAM_ALLOC__Buffers);
type->size = spa_type_map_get_id (map, SPA_TYPE_PARAM_ALLOC_BUFFERS__size);
type->stride = spa_type_map_get_id (map, SPA_TYPE_PARAM_ALLOC_BUFFERS__stride);
type->buffers = spa_type_map_get_id (map, SPA_TYPE_PARAM_ALLOC_BUFFERS__buffers);
type->align = spa_type_map_get_id (map, SPA_TYPE_PARAM_ALLOC_BUFFERS__align);
}
}
#define SPA_TYPE_PARAM_ALLOC__MetaEnable SPA_TYPE_PARAM_ALLOC_BASE "MetaEnable"
#define SPA_TYPE_PARAM_ALLOC_META_ENABLE_BASE SPA_TYPE_PARAM_ALLOC__MetaEnable ":"
#define SPA_TYPE_PARAM_ALLOC_META_ENABLE__type SPA_TYPE_PARAM_ALLOC_META_ENABLE_BASE "type"
#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__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"
typedef struct {
uint32_t MetaEnable;
uint32_t type;
uint32_t size;
uint32_t ringbufferSize;
uint32_t ringbufferStride;
uint32_t ringbufferBlocks;
uint32_t ringbufferAlign;
} SpaTypeParamAllocMetaEnable;
static inline void
spa_type_param_alloc_meta_enable_map (SpaTypeMap *map, SpaTypeParamAllocMetaEnable *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);
}
}
#define SPA_TYPE_PARAM_ALLOC__VideoPadding SPA_TYPE_PARAM_ALLOC_BASE "VideoPadding"
#define SPA_TYPE_PARAM_ALLOC_VIDEO_PADDING_BASE SPA_TYPE_PARAM_ALLOC__VideoPadding ":"
#define SPA_TYPE_PARAM_ALLOC_VIDEO_PADDING__top SPA_TYPE_PARAM_ALLOC_VIDEO_PADDING_BASE "top"
#define SPA_TYPE_PARAM_ALLOC_VIDEO_PADDING__bottom SPA_TYPE_PARAM_ALLOC_VIDEO_PADDING_BASE "bottom"
#define SPA_TYPE_PARAM_ALLOC_VIDEO_PADDING__left SPA_TYPE_PARAM_ALLOC_VIDEO_PADDING_BASE "left"
#define SPA_TYPE_PARAM_ALLOC_VIDEO_PADDING__right SPA_TYPE_PARAM_ALLOC_VIDEO_PADDING_BASE "right"
#define SPA_TYPE_PARAM_ALLOC_VIDEO_PADDING__strideAlign0 SPA_TYPE_PARAM_ALLOC_VIDEO_PADDING_BASE "strideAlign0"
#define SPA_TYPE_PARAM_ALLOC_VIDEO_PADDING__strideAlign1 SPA_TYPE_PARAM_ALLOC_VIDEO_PADDING_BASE "strideAlign1"
#define SPA_TYPE_PARAM_ALLOC_VIDEO_PADDING__strideAlign2 SPA_TYPE_PARAM_ALLOC_VIDEO_PADDING_BASE "strideAlign2"
#define SPA_TYPE_PARAM_ALLOC_VIDEO_PADDING__strideAlign3 SPA_TYPE_PARAM_ALLOC_VIDEO_PADDING_BASE "strideAlign3"
typedef struct {
uint32_t VideoPadding;
uint32_t top;
uint32_t bottom;
uint32_t left;
uint32_t right;
uint32_t strideAlign[4];
} SpaTypeParamAllocVideoPadding;
static inline void
spa_type_param_alloc_video_padding_map (SpaTypeMap *map, SpaTypeParamAllocVideoPadding *type)
{
if (type->VideoPadding == 0) {
type->VideoPadding = spa_type_map_get_id (map, SPA_TYPE_PARAM_ALLOC__VideoPadding);
type->top = spa_type_map_get_id (map, SPA_TYPE_PARAM_ALLOC_VIDEO_PADDING__top);
type->bottom = spa_type_map_get_id (map, SPA_TYPE_PARAM_ALLOC_VIDEO_PADDING__bottom);
type->left = spa_type_map_get_id (map, SPA_TYPE_PARAM_ALLOC_VIDEO_PADDING__left);
type->right = spa_type_map_get_id (map, SPA_TYPE_PARAM_ALLOC_VIDEO_PADDING__right);
type->strideAlign[0] = spa_type_map_get_id (map, SPA_TYPE_PARAM_ALLOC_VIDEO_PADDING__strideAlign0);
type->strideAlign[1] = spa_type_map_get_id (map, SPA_TYPE_PARAM_ALLOC_VIDEO_PADDING__strideAlign1);
type->strideAlign[2] = spa_type_map_get_id (map, SPA_TYPE_PARAM_ALLOC_VIDEO_PADDING__strideAlign2);
type->strideAlign[3] = spa_type_map_get_id (map, SPA_TYPE_PARAM_ALLOC_VIDEO_PADDING__strideAlign3);
}
}
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* __SPA_PARAM_ALLOC_H__ */

81
spa/include/spa/param.h Normal file
View file

@ -0,0 +1,81 @@
/* Simple Plugin API
* Copyright (C) 2017 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_PARAM_H__
#define __SPA_PARAM_H__
#ifdef __cplusplus
extern "C" {
#endif
typedef struct _SpaParam SpaParam;
#include <spa/defs.h>
#include <spa/pod-utils.h>
#define SPA_TYPE__Param SPA_TYPE_POD_OBJECT_BASE "Param"
#define SPA_TYPE_PARAM_BASE SPA_TYPE__Param ":"
typedef struct {
SpaPODObjectBody body;
/* SpaPODProp follow */
} SpaParamBody;
struct _SpaParam {
SpaPOD pod;
SpaParamBody body;
};
static inline uint32_t
spa_param_query (const SpaParam *param, uint32_t key, ...)
{
uint32_t count;
va_list args;
va_start (args, key);
count = spa_pod_contents_queryv (&param->pod, sizeof (SpaParam), key, args);
va_end (args);
return count;
}
#define SPA_PARAM_BODY_FOREACH(body, size, iter) \
for ((iter) = SPA_MEMBER ((body), sizeof (SpaParamBody), SpaPODProp); \
(iter) < SPA_MEMBER ((body), (size), SpaPODProp); \
(iter) = SPA_MEMBER ((iter), SPA_ROUND_UP_N (SPA_POD_SIZE (iter), 8), SpaPODProp))
#define SPA_PARAM_FOREACH(param, iter) \
SPA_PARAM_BODY_FOREACH(&param->body, SPA_POD_BODY_SIZE(param), iter)
static inline SpaResult
spa_param_fixate (SpaParam *param)
{
SpaPODProp *prop;
SPA_PARAM_FOREACH (param, prop)
prop->body.flags &= ~SPA_POD_PROP_FLAG_UNSET;
return SPA_RESULT_OK;
}
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* __SPA_PARAM_H__ */

View file

@ -29,20 +29,12 @@
SpaResult SpaResult
spa_debug_port_info (const SpaPortInfo *info, const SpaTypeMap *map) spa_debug_port_info (const SpaPortInfo *info, const SpaTypeMap *map)
{ {
int i;
if (info == NULL) if (info == NULL)
return SPA_RESULT_INVALID_ARGUMENTS; return SPA_RESULT_INVALID_ARGUMENTS;
fprintf (stderr, "SpaPortInfo %p:\n", info); fprintf (stderr, "SpaPortInfo %p:\n", info);
fprintf (stderr, " flags: \t%08x\n", info->flags); fprintf (stderr, " flags: \t%08x\n", info->flags);
fprintf (stderr, " maxbuffering: \t%"PRIu64"\n", info->maxbuffering);
fprintf (stderr, " latency: \t%" PRIu64 "\n", info->latency);
fprintf (stderr, " n_params: \t%d\n", info->n_params);
for (i = 0; i < info->n_params; i++) {
SpaAllocParam *param = info->params[i];
spa_debug_pod (&param->pod, map);
}
return SPA_RESULT_OK; return SPA_RESULT_OK;
} }
@ -151,6 +143,13 @@ spa_debug_props (const SpaProps *props, const SpaTypeMap *map)
return SPA_RESULT_OK; return SPA_RESULT_OK;
} }
SpaResult
spa_debug_param (const SpaParam *param, const SpaTypeMap *map)
{
spa_debug_pod (&param->pod, map);
return SPA_RESULT_OK;
}
struct pod_type_name { struct pod_type_name {
const char *name; const char *name;
const char *CCName; const char *CCName;

View file

@ -36,6 +36,7 @@ extern "C" {
SpaResult spa_debug_port_info (const SpaPortInfo *info, const SpaTypeMap *map); SpaResult spa_debug_port_info (const SpaPortInfo *info, const SpaTypeMap *map);
SpaResult spa_debug_buffer (const SpaBuffer *buffer, const SpaTypeMap *map); SpaResult spa_debug_buffer (const SpaBuffer *buffer, const SpaTypeMap *map);
SpaResult spa_debug_props (const SpaProps *props, const SpaTypeMap *map); SpaResult spa_debug_props (const SpaProps *props, const SpaTypeMap *map);
SpaResult spa_debug_param (const SpaParam *param, const SpaTypeMap *map);
SpaResult spa_debug_pod (const SpaPOD *pod, const SpaTypeMap *map); SpaResult spa_debug_pod (const SpaPOD *pod, const SpaTypeMap *map);
SpaResult spa_debug_format (const SpaFormat *format, const SpaTypeMap *map); SpaResult spa_debug_format (const SpaFormat *format, const SpaTypeMap *map);
SpaResult spa_debug_dump_mem (const void *data, size_t size); SpaResult spa_debug_dump_mem (const void *data, size_t size);

View file

@ -183,6 +183,7 @@ spa_props_filter (SpaPODBuilder *b,
nalt1--; nalt1--;
} else { } else {
nalt1 = 1; nalt1 = 1;
rt1 = SPA_POD_PROP_RANGE_NONE;
} }
if (p2->body.flags & SPA_POD_PROP_FLAG_UNSET) { if (p2->body.flags & SPA_POD_PROP_FLAG_UNSET) {
@ -190,6 +191,7 @@ spa_props_filter (SpaPODBuilder *b,
nalt2--; nalt2--;
} else { } else {
nalt2 = 1; nalt2 = 1;
rt2 = SPA_POD_PROP_RANGE_NONE;
} }
if ((rt1 == SPA_POD_PROP_RANGE_NONE && rt2 == SPA_POD_PROP_RANGE_NONE) || if ((rt1 == SPA_POD_PROP_RANGE_NONE && rt2 == SPA_POD_PROP_RANGE_NONE) ||

View file

@ -278,8 +278,6 @@ spa_alsa_sink_node_port_set_format (SpaNode *node,
const SpaFormat *format) const SpaFormat *format)
{ {
SpaALSASink *this; SpaALSASink *this;
SpaPODBuilder b = { NULL };
SpaPODFrame f[2];
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
@ -312,36 +310,11 @@ spa_alsa_sink_node_port_set_format (SpaNode *node,
} }
if (this->have_format) { if (this->have_format) {
this->info.direction = direction;
this->info.port_id = port_id;
this->info.flags = SPA_PORT_INFO_FLAG_CAN_USE_BUFFERS | this->info.flags = SPA_PORT_INFO_FLAG_CAN_USE_BUFFERS |
SPA_PORT_INFO_FLAG_LIVE; SPA_PORT_INFO_FLAG_LIVE;
this->info.maxbuffering = this->buffer_frames * this->frame_size; this->info.rate = this->rate;
this->info.latency = (this->period_frames * SPA_NSEC_PER_SEC) / this->rate;
this->info.n_params = 3;
this->info.params = this->params;
spa_pod_builder_init (&b, this->params_buffer, sizeof (this->params_buffer));
spa_pod_builder_object (&b, &f[0], 0, this->type.alloc_param_buffers.Buffers,
PROP (&f[1], this->type.alloc_param_buffers.size, SPA_POD_TYPE_INT,
this->props.min_latency * this->frame_size),
PROP (&f[1], this->type.alloc_param_buffers.stride, SPA_POD_TYPE_INT, 0),
PROP_MM (&f[1], this->type.alloc_param_buffers.buffers, SPA_POD_TYPE_INT, 32, 1, 32),
PROP (&f[1], this->type.alloc_param_buffers.align, SPA_POD_TYPE_INT, 16));
this->params[0] = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaAllocParam);
spa_pod_builder_object (&b, &f[0], 0, this->type.alloc_param_meta_enable.MetaEnable,
PROP (&f[1], this->type.alloc_param_meta_enable.type, SPA_POD_TYPE_ID, this->type.meta.Header),
PROP (&f[1], this->type.alloc_param_meta_enable.size, SPA_POD_TYPE_INT, sizeof (SpaMetaHeader)));
this->params[1] = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaAllocParam);
spa_pod_builder_object (&b, &f[0], 0, this->type.alloc_param_meta_enable.MetaEnable,
PROP (&f[1], this->type.alloc_param_meta_enable.type, SPA_POD_TYPE_ID, this->type.meta.Ringbuffer),
PROP (&f[1], this->type.alloc_param_meta_enable.size, SPA_POD_TYPE_INT, sizeof (SpaMetaRingbuffer)),
PROP (&f[1], this->type.alloc_param_meta_enable.ringbufferSize, SPA_POD_TYPE_INT, this->period_frames * this->frame_size * 32),
PROP (&f[1], this->type.alloc_param_meta_enable.ringbufferStride, SPA_POD_TYPE_INT, 0),
PROP (&f[1], this->type.alloc_param_meta_enable.ringbufferBlocks, SPA_POD_TYPE_INT, 1),
PROP (&f[1], this->type.alloc_param_meta_enable.ringbufferAlign, SPA_POD_TYPE_INT, 16));
this->params[2] = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaAllocParam);
this->info.extra = NULL;
} }
return SPA_RESULT_OK; return SPA_RESULT_OK;
@ -400,19 +373,66 @@ spa_alsa_sink_node_port_get_info (SpaNode *node,
} }
static SpaResult static SpaResult
spa_alsa_sink_node_port_get_props (SpaNode *node, spa_alsa_sink_node_port_enum_params (SpaNode *node,
SpaDirection direction, SpaDirection direction,
uint32_t port_id, uint32_t port_id,
SpaProps **props) uint32_t index,
SpaParam **param)
{ {
return SPA_RESULT_NOT_IMPLEMENTED;
SpaALSASink *this;
SpaPODBuilder b = { NULL };
SpaPODFrame f[2];
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, SpaALSASink, node);
spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT);
spa_pod_builder_init (&b, this->params_buffer, sizeof (this->params_buffer));
switch (index) {
case 0:
spa_pod_builder_object (&b, &f[0], 0, this->type.param_alloc_buffers.Buffers,
PROP (&f[1], this->type.param_alloc_buffers.size, SPA_POD_TYPE_INT,
this->props.min_latency * this->frame_size),
PROP (&f[1], this->type.param_alloc_buffers.stride, SPA_POD_TYPE_INT, 0),
PROP_MM (&f[1], this->type.param_alloc_buffers.buffers, SPA_POD_TYPE_INT, 32, 1, 32),
PROP (&f[1], this->type.param_alloc_buffers.align, SPA_POD_TYPE_INT, 16));
break;
case 1:
spa_pod_builder_object (&b, &f[0], 0, this->type.param_alloc_meta_enable.MetaEnable,
PROP (&f[1], this->type.param_alloc_meta_enable.type, SPA_POD_TYPE_ID, this->type.meta.Header),
PROP (&f[1], this->type.param_alloc_meta_enable.size, SPA_POD_TYPE_INT, sizeof (SpaMetaHeader)));
break;
case 2:
spa_pod_builder_object (&b, &f[0], 0, this->type.param_alloc_meta_enable.MetaEnable,
PROP (&f[1], this->type.param_alloc_meta_enable.type, SPA_POD_TYPE_ID, this->type.meta.Ringbuffer),
PROP (&f[1], this->type.param_alloc_meta_enable.size, SPA_POD_TYPE_INT, sizeof (SpaMetaRingbuffer)),
PROP (&f[1], this->type.param_alloc_meta_enable.ringbufferSize, SPA_POD_TYPE_INT, this->period_frames * this->frame_size * 32),
PROP (&f[1], this->type.param_alloc_meta_enable.ringbufferStride, SPA_POD_TYPE_INT, 0),
PROP (&f[1], this->type.param_alloc_meta_enable.ringbufferBlocks, SPA_POD_TYPE_INT, 1),
PROP (&f[1], this->type.param_alloc_meta_enable.ringbufferAlign, SPA_POD_TYPE_INT, 16));
break;
default:
return SPA_RESULT_NOT_IMPLEMENTED;
}
*param = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaParam);
return SPA_RESULT_OK;
} }
static SpaResult static SpaResult
spa_alsa_sink_node_port_set_props (SpaNode *node, spa_alsa_sink_node_port_set_param (SpaNode *node,
SpaDirection direction, SpaDirection direction,
uint32_t port_id, uint32_t port_id,
const SpaProps *props) const SpaParam *param)
{ {
return SPA_RESULT_NOT_IMPLEMENTED; return SPA_RESULT_NOT_IMPLEMENTED;
} }
@ -471,7 +491,7 @@ static SpaResult
spa_alsa_sink_node_port_alloc_buffers (SpaNode *node, spa_alsa_sink_node_port_alloc_buffers (SpaNode *node,
SpaDirection direction, SpaDirection direction,
uint32_t port_id, uint32_t port_id,
SpaAllocParam **params, SpaParam **params,
uint32_t n_params, uint32_t n_params,
SpaBuffer **buffers, SpaBuffer **buffers,
uint32_t *n_buffers) uint32_t *n_buffers)
@ -599,8 +619,8 @@ static const SpaNode alsasink_node = {
spa_alsa_sink_node_port_set_format, spa_alsa_sink_node_port_set_format,
spa_alsa_sink_node_port_get_format, spa_alsa_sink_node_port_get_format,
spa_alsa_sink_node_port_get_info, spa_alsa_sink_node_port_get_info,
spa_alsa_sink_node_port_get_props, spa_alsa_sink_node_port_enum_params,
spa_alsa_sink_node_port_set_props, spa_alsa_sink_node_port_set_param,
spa_alsa_sink_node_port_use_buffers, spa_alsa_sink_node_port_use_buffers,
spa_alsa_sink_node_port_alloc_buffers, spa_alsa_sink_node_port_alloc_buffers,
spa_alsa_sink_node_port_set_io, spa_alsa_sink_node_port_set_io,

View file

@ -325,8 +325,6 @@ spa_alsa_source_node_port_set_format (SpaNode *node,
const SpaFormat *format) const SpaFormat *format)
{ {
SpaALSASource *this; SpaALSASource *this;
SpaPODBuilder b = { NULL };
SpaPODFrame f[2];
spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS); spa_return_val_if_fail (node != NULL, SPA_RESULT_INVALID_ARGUMENTS);
@ -358,28 +356,11 @@ spa_alsa_source_node_port_set_format (SpaNode *node,
} }
if (this->have_format) { if (this->have_format) {
this->info.direction = direction;
this->info.port_id = port_id;
this->info.flags = SPA_PORT_INFO_FLAG_CAN_USE_BUFFERS | this->info.flags = SPA_PORT_INFO_FLAG_CAN_USE_BUFFERS |
SPA_PORT_INFO_FLAG_LIVE; SPA_PORT_INFO_FLAG_LIVE;
this->info.maxbuffering = this->buffer_frames * this->frame_size; this->info.rate = this->rate;
this->info.latency = (this->period_frames * SPA_NSEC_PER_SEC) / this->rate;
this->info.n_params = 2;
this->info.params = this->params;
spa_pod_builder_init (&b, this->params_buffer, sizeof (this->params_buffer));
spa_pod_builder_object (&b, &f[0], 0, this->type.alloc_param_buffers.Buffers,
PROP (&f[1], this->type.alloc_param_buffers.size, SPA_POD_TYPE_INT,
this->props.min_latency * this->frame_size),
PROP (&f[1], this->type.alloc_param_buffers.stride, SPA_POD_TYPE_INT, 0),
PROP_MM (&f[1], this->type.alloc_param_buffers.buffers, SPA_POD_TYPE_INT, 32, 1, 32),
PROP (&f[1], this->type.alloc_param_buffers.align, SPA_POD_TYPE_INT, 16));
this->params[0] = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaAllocParam);
spa_pod_builder_object (&b, &f[0], 0, this->type.alloc_param_meta_enable.MetaEnable,
PROP (&f[1], this->type.alloc_param_meta_enable.type, SPA_POD_TYPE_ID, this->type.meta.Header),
PROP (&f[1], this->type.alloc_param_meta_enable.size, SPA_POD_TYPE_INT, sizeof (SpaMetaHeader)));
this->params[1] = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaAllocParam);
this->info.extra = NULL;
} }
return SPA_RESULT_OK; return SPA_RESULT_OK;
@ -438,19 +419,55 @@ spa_alsa_source_node_port_get_info (SpaNode *node,
} }
static SpaResult static SpaResult
spa_alsa_source_node_port_get_props (SpaNode *node, spa_alsa_source_node_port_enum_params (SpaNode *node,
SpaDirection direction, SpaDirection direction,
uint32_t port_id, uint32_t port_id,
SpaProps **props) uint32_t index,
SpaParam **param)
{ {
return SPA_RESULT_NOT_IMPLEMENTED; SpaALSASource *this;
SpaPODBuilder b = { NULL, };
SpaPODFrame f[2];
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, SpaALSASource, node);
spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT);
spa_pod_builder_init (&b, this->params_buffer, sizeof (this->params_buffer));
switch (index) {
case 0:
spa_pod_builder_object (&b, &f[0], 0, this->type.param_alloc_buffers.Buffers,
PROP (&f[1], this->type.param_alloc_buffers.size, SPA_POD_TYPE_INT,
this->props.min_latency * this->frame_size),
PROP (&f[1], this->type.param_alloc_buffers.stride, SPA_POD_TYPE_INT, 0),
PROP_MM (&f[1], this->type.param_alloc_buffers.buffers, SPA_POD_TYPE_INT, 32, 1, 32),
PROP (&f[1], this->type.param_alloc_buffers.align, SPA_POD_TYPE_INT, 16));
break;
case 1:
spa_pod_builder_object (&b, &f[0], 0, this->type.param_alloc_meta_enable.MetaEnable,
PROP (&f[1], this->type.param_alloc_meta_enable.type, SPA_POD_TYPE_ID, this->type.meta.Header),
PROP (&f[1], this->type.param_alloc_meta_enable.size, SPA_POD_TYPE_INT, sizeof (SpaMetaHeader)));
break;
default:
return SPA_RESULT_NOT_IMPLEMENTED;
}
*param = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaParam);
return SPA_RESULT_OK;
} }
static SpaResult static SpaResult
spa_alsa_source_node_port_set_props (SpaNode *node, spa_alsa_source_node_port_set_param (SpaNode *node,
SpaDirection direction, SpaDirection direction,
uint32_t port_id, uint32_t port_id,
const SpaProps *props) const SpaParam *param)
{ {
return SPA_RESULT_NOT_IMPLEMENTED; return SPA_RESULT_NOT_IMPLEMENTED;
} }
@ -508,7 +525,7 @@ static SpaResult
spa_alsa_source_node_port_alloc_buffers (SpaNode *node, spa_alsa_source_node_port_alloc_buffers (SpaNode *node,
SpaDirection direction, SpaDirection direction,
uint32_t port_id, uint32_t port_id,
SpaAllocParam **params, SpaParam **params,
uint32_t n_params, uint32_t n_params,
SpaBuffer **buffers, SpaBuffer **buffers,
uint32_t *n_buffers) uint32_t *n_buffers)
@ -639,8 +656,8 @@ static const SpaNode alsasource_node = {
spa_alsa_source_node_port_set_format, spa_alsa_source_node_port_set_format,
spa_alsa_source_node_port_get_format, spa_alsa_source_node_port_get_format,
spa_alsa_source_node_port_get_info, spa_alsa_source_node_port_get_info,
spa_alsa_source_node_port_get_props, spa_alsa_source_node_port_enum_params,
spa_alsa_source_node_port_set_props, spa_alsa_source_node_port_set_param,
spa_alsa_source_node_port_use_buffers, spa_alsa_source_node_port_use_buffers,
spa_alsa_source_node_port_alloc_buffers, spa_alsa_source_node_port_alloc_buffers,
spa_alsa_source_node_port_set_io, spa_alsa_source_node_port_set_io,

View file

@ -33,6 +33,7 @@ extern "C" {
#include <spa/log.h> #include <spa/log.h>
#include <spa/list.h> #include <spa/list.h>
#include <spa/node.h> #include <spa/node.h>
#include <spa/param-alloc.h>
#include <spa/loop.h> #include <spa/loop.h>
#include <spa/ringbuffer.h> #include <spa/ringbuffer.h>
#include <spa/audio/format-utils.h> #include <spa/audio/format-utils.h>
@ -76,8 +77,8 @@ typedef struct {
SpaTypeAudioFormat audio_format; SpaTypeAudioFormat audio_format;
SpaTypeEventNode event_node; SpaTypeEventNode event_node;
SpaTypeCommandNode command_node; SpaTypeCommandNode command_node;
SpaTypeAllocParamBuffers alloc_param_buffers; SpaTypeParamAllocBuffers param_alloc_buffers;
SpaTypeAllocParamMetaEnable alloc_param_meta_enable; SpaTypeParamAllocMetaEnable param_alloc_meta_enable;
} Type; } Type;
static inline void static inline void
@ -101,8 +102,8 @@ init_type (Type *type, SpaTypeMap *map)
spa_type_audio_format_map (map, &type->audio_format); spa_type_audio_format_map (map, &type->audio_format);
spa_type_event_node_map (map, &type->event_node); spa_type_event_node_map (map, &type->event_node);
spa_type_command_node_map (map, &type->command_node); spa_type_command_node_map (map, &type->command_node);
spa_type_alloc_param_buffers_map (map, &type->alloc_param_buffers); spa_type_param_alloc_buffers_map (map, &type->param_alloc_buffers);
spa_type_alloc_param_meta_enable_map (map, &type->alloc_param_meta_enable); spa_type_param_alloc_meta_enable_map (map, &type->param_alloc_meta_enable);
} }
struct _SpaALSAState { struct _SpaALSAState {
@ -142,7 +143,7 @@ struct _SpaALSAState {
size_t frame_size; size_t frame_size;
SpaPortInfo info; SpaPortInfo info;
SpaAllocParam *params[3]; uint32_t params[3];
uint8_t params_buffer[1024]; uint8_t params_buffer[1024];
SpaPortIO *io; SpaPortIO *io;

View file

@ -431,19 +431,20 @@ spa_audiomixer_node_port_get_info (SpaNode *node,
} }
static SpaResult static SpaResult
spa_audiomixer_node_port_get_props (SpaNode *node, spa_audiomixer_node_port_enum_params (SpaNode *node,
SpaDirection direction, SpaDirection direction,
uint32_t port_id, uint32_t port_id,
SpaProps **props) uint32_t index,
SpaParam **param)
{ {
return SPA_RESULT_NOT_IMPLEMENTED; return SPA_RESULT_NOT_IMPLEMENTED;
} }
static SpaResult static SpaResult
spa_audiomixer_node_port_set_props (SpaNode *node, spa_audiomixer_node_port_set_param (SpaNode *node,
SpaDirection direction, SpaDirection direction,
uint32_t port_id, uint32_t port_id,
const SpaProps *props) const SpaParam *param)
{ {
return SPA_RESULT_NOT_IMPLEMENTED; return SPA_RESULT_NOT_IMPLEMENTED;
} }
@ -499,7 +500,7 @@ static SpaResult
spa_audiomixer_node_port_alloc_buffers (SpaNode *node, spa_audiomixer_node_port_alloc_buffers (SpaNode *node,
SpaDirection direction, SpaDirection direction,
uint32_t port_id, uint32_t port_id,
SpaAllocParam **params, SpaParam **params,
uint32_t n_params, uint32_t n_params,
SpaBuffer **buffers, SpaBuffer **buffers,
uint32_t *n_buffers) uint32_t *n_buffers)
@ -798,8 +799,8 @@ static const SpaNode audiomixer_node = {
spa_audiomixer_node_port_set_format, spa_audiomixer_node_port_set_format,
spa_audiomixer_node_port_get_format, spa_audiomixer_node_port_get_format,
spa_audiomixer_node_port_get_info, spa_audiomixer_node_port_get_info,
spa_audiomixer_node_port_get_props, spa_audiomixer_node_port_enum_params,
spa_audiomixer_node_port_set_props, spa_audiomixer_node_port_set_param,
spa_audiomixer_node_port_use_buffers, spa_audiomixer_node_port_use_buffers,
spa_audiomixer_node_port_alloc_buffers, spa_audiomixer_node_port_alloc_buffers,
spa_audiomixer_node_port_set_io, spa_audiomixer_node_port_set_io,

View file

@ -28,6 +28,7 @@
#include <spa/log.h> #include <spa/log.h>
#include <spa/loop.h> #include <spa/loop.h>
#include <spa/node.h> #include <spa/node.h>
#include <spa/param-alloc.h>
#include <spa/list.h> #include <spa/list.h>
#include <spa/audio/format-utils.h> #include <spa/audio/format-utils.h>
#include <spa/format-builder.h> #include <spa/format-builder.h>
@ -56,8 +57,8 @@ typedef struct {
SpaTypeAudioFormat audio_format; SpaTypeAudioFormat audio_format;
SpaTypeEventNode event_node; SpaTypeEventNode event_node;
SpaTypeCommandNode command_node; SpaTypeCommandNode command_node;
SpaTypeAllocParamBuffers alloc_param_buffers; SpaTypeParamAllocBuffers param_alloc_buffers;
SpaTypeAllocParamMetaEnable alloc_param_meta_enable; SpaTypeParamAllocMetaEnable param_alloc_meta_enable;
} Type; } Type;
static inline void static inline void
@ -81,8 +82,8 @@ init_type (Type *type, SpaTypeMap *map)
spa_type_audio_format_map (map, &type->audio_format); spa_type_audio_format_map (map, &type->audio_format);
spa_type_event_node_map (map, &type->event_node); spa_type_event_node_map (map, &type->event_node);
spa_type_command_node_map (map, &type->command_node); spa_type_command_node_map (map, &type->command_node);
spa_type_alloc_param_buffers_map (map, &type->alloc_param_buffers); spa_type_param_alloc_buffers_map (map, &type->param_alloc_buffers);
spa_type_alloc_param_meta_enable_map (map, &type->alloc_param_meta_enable); spa_type_param_alloc_meta_enable_map (map, &type->param_alloc_meta_enable);
} }
typedef struct _SpaAudioTestSrc SpaAudioTestSrc; typedef struct _SpaAudioTestSrc SpaAudioTestSrc;
@ -128,7 +129,7 @@ struct _SpaAudioTestSrc {
struct itimerspec timerspec; struct itimerspec timerspec;
SpaPortInfo info; SpaPortInfo info;
SpaAllocParam *params[2]; uint32_t params[2];
uint8_t params_buffer[1024]; uint8_t params_buffer[1024];
SpaPortIO *io; SpaPortIO *io;
@ -607,29 +608,9 @@ spa_audiotestsrc_node_port_set_format (SpaNode *node,
} }
if (this->have_format) { if (this->have_format) {
SpaPODBuilder b = { NULL }; this->info.direction = direction;
SpaPODFrame f[2]; this->info.port_id = port_id;
this->info.rate = this->current_format.info.raw.rate;
this->info.maxbuffering = -1;
this->info.latency = BYTES_TO_TIME (this, 1024);
this->info.n_params = 2;
this->info.params = this->params;
spa_pod_builder_init (&b, this->params_buffer, sizeof (this->params_buffer));
spa_pod_builder_object (&b, &f[0], 0, this->type.alloc_param_buffers.Buffers,
PROP (&f[1], this->type.alloc_param_buffers.size, SPA_POD_TYPE_INT, 1024 * this->bpf),
PROP (&f[1], this->type.alloc_param_buffers.stride, SPA_POD_TYPE_INT, this->bpf),
PROP_U_MM (&f[1], this->type.alloc_param_buffers.buffers, SPA_POD_TYPE_INT, 32, 2, 32),
PROP (&f[1], this->type.alloc_param_buffers.align, SPA_POD_TYPE_INT, 16));
this->params[0] = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaAllocParam);
spa_pod_builder_object (&b, &f[0], 0, this->type.alloc_param_meta_enable.MetaEnable,
PROP (&f[1], this->type.alloc_param_meta_enable.type, SPA_POD_TYPE_ID, this->type.meta.Header),
PROP (&f[1], this->type.alloc_param_meta_enable.size, SPA_POD_TYPE_INT, sizeof (SpaMetaHeader)));
this->params[1] = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaAllocParam);
this->info.extra = NULL;
} }
return SPA_RESULT_OK; return SPA_RESULT_OK;
@ -688,19 +669,54 @@ spa_audiotestsrc_node_port_get_info (SpaNode *node,
} }
static SpaResult static SpaResult
spa_audiotestsrc_node_port_get_props (SpaNode *node, spa_audiotestsrc_node_port_enum_params (SpaNode *node,
SpaDirection direction, SpaDirection direction,
uint32_t port_id, uint32_t port_id,
SpaProps **props) uint32_t index,
SpaParam **param)
{ {
return SPA_RESULT_NOT_IMPLEMENTED; SpaAudioTestSrc *this;
SpaPODBuilder b = { NULL, };
SpaPODFrame f[2];
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, SpaAudioTestSrc, node);
spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT);
spa_pod_builder_init (&b, this->params_buffer, sizeof (this->params_buffer));
switch (index) {
case 0:
spa_pod_builder_object (&b, &f[0], 0, this->type.param_alloc_buffers.Buffers,
PROP (&f[1], this->type.param_alloc_buffers.size, SPA_POD_TYPE_INT, 1024 * this->bpf),
PROP (&f[1], this->type.param_alloc_buffers.stride, SPA_POD_TYPE_INT, this->bpf),
PROP_U_MM (&f[1], this->type.param_alloc_buffers.buffers, SPA_POD_TYPE_INT, 32, 2, 32),
PROP (&f[1], this->type.param_alloc_buffers.align, SPA_POD_TYPE_INT, 16));
break;
case 1:
spa_pod_builder_object (&b, &f[0], 0, this->type.param_alloc_meta_enable.MetaEnable,
PROP (&f[1], this->type.param_alloc_meta_enable.type, SPA_POD_TYPE_ID, this->type.meta.Header),
PROP (&f[1], this->type.param_alloc_meta_enable.size, SPA_POD_TYPE_INT, sizeof (SpaMetaHeader)));
break;
default:
return SPA_RESULT_NOT_IMPLEMENTED;
}
*param = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaParam);
return SPA_RESULT_OK;
} }
static SpaResult static SpaResult
spa_audiotestsrc_node_port_set_props (SpaNode *node, spa_audiotestsrc_node_port_set_param (SpaNode *node,
SpaDirection direction, SpaDirection direction,
uint32_t port_id, uint32_t port_id,
const SpaProps *props) const SpaParam *param)
{ {
return SPA_RESULT_NOT_IMPLEMENTED; return SPA_RESULT_NOT_IMPLEMENTED;
} }
@ -753,7 +769,7 @@ static SpaResult
spa_audiotestsrc_node_port_alloc_buffers (SpaNode *node, spa_audiotestsrc_node_port_alloc_buffers (SpaNode *node,
SpaDirection direction, SpaDirection direction,
uint32_t port_id, uint32_t port_id,
SpaAllocParam **params, SpaParam **params,
uint32_t n_params, uint32_t n_params,
SpaBuffer **buffers, SpaBuffer **buffers,
uint32_t *n_buffers) uint32_t *n_buffers)
@ -882,8 +898,8 @@ static const SpaNode audiotestsrc_node = {
spa_audiotestsrc_node_port_set_format, spa_audiotestsrc_node_port_set_format,
spa_audiotestsrc_node_port_get_format, spa_audiotestsrc_node_port_get_format,
spa_audiotestsrc_node_port_get_info, spa_audiotestsrc_node_port_get_info,
spa_audiotestsrc_node_port_get_props, spa_audiotestsrc_node_port_enum_params,
spa_audiotestsrc_node_port_set_props, spa_audiotestsrc_node_port_set_param,
spa_audiotestsrc_node_port_use_buffers, spa_audiotestsrc_node_port_use_buffers,
spa_audiotestsrc_node_port_alloc_buffers, spa_audiotestsrc_node_port_alloc_buffers,
spa_audiotestsrc_node_port_set_io, spa_audiotestsrc_node_port_set_io,

View file

@ -324,19 +324,20 @@ spa_ffmpeg_dec_node_port_get_info (SpaNode *node,
} }
static SpaResult static SpaResult
spa_ffmpeg_dec_node_port_get_props (SpaNode *node, spa_ffmpeg_dec_node_port_enum_params (SpaNode *node,
SpaDirection direction, SpaDirection direction,
uint32_t port_id, uint32_t port_id,
SpaProps **props) uint32_t index,
SpaParam **param)
{ {
return SPA_RESULT_NOT_IMPLEMENTED; return SPA_RESULT_NOT_IMPLEMENTED;
} }
static SpaResult static SpaResult
spa_ffmpeg_dec_node_port_set_props (SpaNode *node, spa_ffmpeg_dec_node_port_set_param (SpaNode *node,
SpaDirection direction, SpaDirection direction,
uint32_t port_id, uint32_t port_id,
const SpaProps *props) const SpaParam *param)
{ {
return SPA_RESULT_NOT_IMPLEMENTED; return SPA_RESULT_NOT_IMPLEMENTED;
} }
@ -361,7 +362,7 @@ static SpaResult
spa_ffmpeg_dec_node_port_alloc_buffers (SpaNode *node, spa_ffmpeg_dec_node_port_alloc_buffers (SpaNode *node,
SpaDirection direction, SpaDirection direction,
uint32_t port_id, uint32_t port_id,
SpaAllocParam **params, SpaParam **params,
uint32_t n_params, uint32_t n_params,
SpaBuffer **buffers, SpaBuffer **buffers,
uint32_t *n_buffers) uint32_t *n_buffers)
@ -463,8 +464,8 @@ static const SpaNode ffmpeg_dec_node = {
spa_ffmpeg_dec_node_port_set_format, spa_ffmpeg_dec_node_port_set_format,
spa_ffmpeg_dec_node_port_get_format, spa_ffmpeg_dec_node_port_get_format,
spa_ffmpeg_dec_node_port_get_info, spa_ffmpeg_dec_node_port_get_info,
spa_ffmpeg_dec_node_port_get_props, spa_ffmpeg_dec_node_port_enum_params,
spa_ffmpeg_dec_node_port_set_props, spa_ffmpeg_dec_node_port_set_param,
spa_ffmpeg_dec_node_port_use_buffers, spa_ffmpeg_dec_node_port_use_buffers,
spa_ffmpeg_dec_node_port_alloc_buffers, spa_ffmpeg_dec_node_port_alloc_buffers,
spa_ffmpeg_dec_node_port_set_io, spa_ffmpeg_dec_node_port_set_io,

View file

@ -328,19 +328,20 @@ spa_ffmpeg_enc_node_port_get_info (SpaNode *node,
} }
static SpaResult static SpaResult
spa_ffmpeg_enc_node_port_get_props (SpaNode *node, spa_ffmpeg_enc_node_port_enum_params (SpaNode *node,
SpaDirection direction, SpaDirection direction,
uint32_t port_id, uint32_t port_id,
SpaProps **props) uint32_t index,
SpaParam **param)
{ {
return SPA_RESULT_NOT_IMPLEMENTED; return SPA_RESULT_NOT_IMPLEMENTED;
} }
static SpaResult static SpaResult
spa_ffmpeg_enc_node_port_set_props (SpaNode *node, spa_ffmpeg_enc_node_port_set_param (SpaNode *node,
SpaDirection direction, SpaDirection direction,
uint32_t port_id, uint32_t port_id,
const SpaProps *props) const SpaParam *param)
{ {
return SPA_RESULT_NOT_IMPLEMENTED; return SPA_RESULT_NOT_IMPLEMENTED;
} }
@ -365,7 +366,7 @@ static SpaResult
spa_ffmpeg_enc_node_port_alloc_buffers (SpaNode *node, spa_ffmpeg_enc_node_port_alloc_buffers (SpaNode *node,
SpaDirection direction, SpaDirection direction,
uint32_t port_id, uint32_t port_id,
SpaAllocParam **params, SpaParam **params,
uint32_t n_params, uint32_t n_params,
SpaBuffer **buffers, SpaBuffer **buffers,
uint32_t *n_buffers) uint32_t *n_buffers)
@ -466,8 +467,8 @@ static const SpaNode ffmpeg_enc_node = {
spa_ffmpeg_enc_node_port_set_format, spa_ffmpeg_enc_node_port_set_format,
spa_ffmpeg_enc_node_port_get_format, spa_ffmpeg_enc_node_port_get_format,
spa_ffmpeg_enc_node_port_get_info, spa_ffmpeg_enc_node_port_get_info,
spa_ffmpeg_enc_node_port_get_props, spa_ffmpeg_enc_node_port_enum_params,
spa_ffmpeg_enc_node_port_set_props, spa_ffmpeg_enc_node_port_set_param,
spa_ffmpeg_enc_node_port_use_buffers, spa_ffmpeg_enc_node_port_use_buffers,
spa_ffmpeg_enc_node_port_alloc_buffers, spa_ffmpeg_enc_node_port_alloc_buffers,
spa_ffmpeg_enc_node_port_set_io, spa_ffmpeg_enc_node_port_set_io,

View file

@ -60,8 +60,6 @@ typedef struct {
bool have_buffers; bool have_buffers;
LibvaBuffer buffers[MAX_BUFFERS]; LibvaBuffer buffers[MAX_BUFFERS];
SpaPortInfo info; SpaPortInfo info;
SpaAllocParam *params[1];
SpaAllocParamBuffers param_buffers;
SpaPortStatus status; SpaPortStatus status;
} SpaLibvaState; } SpaLibvaState;
@ -412,7 +410,7 @@ spa_libva_dec_node_port_use_buffers (SpaHandle *handle,
static SpaResult static SpaResult
spa_libva_dec_node_port_alloc_buffers (SpaHandle *handle, spa_libva_dec_node_port_alloc_buffers (SpaHandle *handle,
uint32_t port_id, uint32_t port_id,
SpaAllocParam **params, SpaParam **params,
uint32_t n_params, uint32_t n_params,
SpaBuffer **buffers, SpaBuffer **buffers,
uint32_t *n_buffers) uint32_t *n_buffers)

View file

@ -28,6 +28,7 @@
#include <spa/log.h> #include <spa/log.h>
#include <spa/loop.h> #include <spa/loop.h>
#include <spa/node.h> #include <spa/node.h>
#include <spa/param-alloc.h>
#include <spa/list.h> #include <spa/list.h>
#include <spa/format-builder.h> #include <spa/format-builder.h>
#include <lib/props.h> #include <lib/props.h>
@ -42,8 +43,8 @@ typedef struct {
SpaTypeData data; SpaTypeData data;
SpaTypeEventNode event_node; SpaTypeEventNode event_node;
SpaTypeCommandNode command_node; SpaTypeCommandNode command_node;
SpaTypeAllocParamBuffers alloc_param_buffers; SpaTypeParamAllocBuffers param_alloc_buffers;
SpaTypeAllocParamMetaEnable alloc_param_meta_enable; SpaTypeParamAllocMetaEnable param_alloc_meta_enable;
} Type; } Type;
static inline void static inline void
@ -58,8 +59,8 @@ init_type (Type *type, SpaTypeMap *map)
spa_type_data_map (map, &type->data); spa_type_data_map (map, &type->data);
spa_type_event_node_map (map, &type->event_node); spa_type_event_node_map (map, &type->event_node);
spa_type_command_node_map (map, &type->command_node); spa_type_command_node_map (map, &type->command_node);
spa_type_alloc_param_buffers_map (map, &type->alloc_param_buffers); spa_type_param_alloc_buffers_map (map, &type->param_alloc_buffers);
spa_type_alloc_param_meta_enable_map (map, &type->alloc_param_meta_enable); spa_type_param_alloc_meta_enable_map (map, &type->param_alloc_meta_enable);
} }
typedef struct _SpaFakeSink SpaFakeSink; typedef struct _SpaFakeSink SpaFakeSink;
@ -100,7 +101,6 @@ struct _SpaFakeSink {
struct itimerspec timerspec; struct itimerspec timerspec;
SpaPortInfo info; SpaPortInfo info;
SpaAllocParam *params[2];
uint8_t params_buffer[1024]; uint8_t params_buffer[1024];
SpaPortIO *io; SpaPortIO *io;
@ -467,33 +467,6 @@ spa_fakesink_node_port_set_format (SpaNode *node,
memcpy (this->format_buffer, format, SPA_POD_SIZE (format)); memcpy (this->format_buffer, format, SPA_POD_SIZE (format));
this->have_format = true; this->have_format = true;
} }
if (this->have_format) {
SpaPODBuilder b = { NULL };
SpaPODFrame f[2];
this->info.latency = 0;
this->info.maxbuffering = -1;
this->info.n_params = 2;
this->info.params = this->params;
spa_pod_builder_init (&b, this->params_buffer, sizeof (this->params_buffer));
spa_pod_builder_object (&b, &f[0], 0, this->type.alloc_param_buffers.Buffers,
PROP (&f[1], this->type.alloc_param_buffers.size, SPA_POD_TYPE_INT, 128),
PROP (&f[1], this->type.alloc_param_buffers.stride, SPA_POD_TYPE_INT, 1),
PROP_U_MM (&f[1], this->type.alloc_param_buffers.buffers, SPA_POD_TYPE_INT, 32, 2, 32),
PROP (&f[1], this->type.alloc_param_buffers.align, SPA_POD_TYPE_INT, 16));
this->params[0] = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaAllocParam);
spa_pod_builder_object (&b, &f[0], 0, this->type.alloc_param_meta_enable.MetaEnable,
PROP (&f[1], this->type.alloc_param_meta_enable.type, SPA_POD_TYPE_ID, this->type.meta.Header),
PROP (&f[1], this->type.alloc_param_meta_enable.size, SPA_POD_TYPE_INT, sizeof (SpaMetaHeader)));
this->params[1] = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaAllocParam);
this->info.extra = NULL;
}
return SPA_RESULT_OK; return SPA_RESULT_OK;
} }
@ -541,29 +514,63 @@ spa_fakesink_node_port_get_info (SpaNode *node,
} }
static SpaResult static SpaResult
spa_fakesink_node_port_get_props (SpaNode *node, spa_fakesink_node_port_enum_params (SpaNode *node,
SpaDirection direction, SpaDirection direction,
uint32_t port_id, uint32_t port_id,
SpaProps **props) uint32_t index,
SpaParam **param)
{ {
return SPA_RESULT_NOT_IMPLEMENTED; SpaFakeSink *this;
SpaPODBuilder b = { NULL };
SpaPODFrame f[2];
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, SpaFakeSink, node);
spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT);
spa_pod_builder_init (&b, this->params_buffer, sizeof (this->params_buffer));
switch (index) {
case 0:
spa_pod_builder_object (&b, &f[0], 0, this->type.param_alloc_buffers.Buffers,
PROP (&f[1], this->type.param_alloc_buffers.size, SPA_POD_TYPE_INT, 128),
PROP (&f[1], this->type.param_alloc_buffers.stride, SPA_POD_TYPE_INT, 1),
PROP_U_MM (&f[1], this->type.param_alloc_buffers.buffers, SPA_POD_TYPE_INT, 32, 2, 32),
PROP (&f[1], this->type.param_alloc_buffers.align, SPA_POD_TYPE_INT, 16));
break;
case 1:
spa_pod_builder_object (&b, &f[0], 0, this->type.param_alloc_meta_enable.MetaEnable,
PROP (&f[1], this->type.param_alloc_meta_enable.type, SPA_POD_TYPE_ID, this->type.meta.Header),
PROP (&f[1], this->type.param_alloc_meta_enable.size, SPA_POD_TYPE_INT, sizeof (SpaMetaHeader)));
break;
default:
return SPA_RESULT_NOT_IMPLEMENTED;
}
*param = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaParam);
return SPA_RESULT_OK;
} }
static SpaResult static SpaResult
spa_fakesink_node_port_set_props (SpaNode *node, spa_fakesink_node_port_set_param (SpaNode *node,
SpaDirection direction, SpaDirection direction,
uint32_t port_id, uint32_t port_id,
const SpaProps *props) const SpaParam *param)
{ {
return SPA_RESULT_NOT_IMPLEMENTED; return SPA_RESULT_NOT_IMPLEMENTED;
} }
static SpaResult static SpaResult
spa_fakesink_node_port_use_buffers (SpaNode *node, spa_fakesink_node_port_use_buffers (SpaNode *node,
SpaDirection direction, SpaDirection direction,
uint32_t port_id, uint32_t port_id,
SpaBuffer **buffers, SpaBuffer **buffers,
uint32_t n_buffers) uint32_t n_buffers)
{ {
SpaFakeSink *this; SpaFakeSink *this;
uint32_t i; uint32_t i;
@ -604,7 +611,7 @@ static SpaResult
spa_fakesink_node_port_alloc_buffers (SpaNode *node, spa_fakesink_node_port_alloc_buffers (SpaNode *node,
SpaDirection direction, SpaDirection direction,
uint32_t port_id, uint32_t port_id,
SpaAllocParam **params, SpaParam **params,
uint32_t n_params, uint32_t n_params,
SpaBuffer **buffers, SpaBuffer **buffers,
uint32_t *n_buffers) uint32_t *n_buffers)
@ -716,8 +723,8 @@ static const SpaNode fakesink_node = {
spa_fakesink_node_port_set_format, spa_fakesink_node_port_set_format,
spa_fakesink_node_port_get_format, spa_fakesink_node_port_get_format,
spa_fakesink_node_port_get_info, spa_fakesink_node_port_get_info,
spa_fakesink_node_port_get_props, spa_fakesink_node_port_enum_params,
spa_fakesink_node_port_set_props, spa_fakesink_node_port_set_param,
spa_fakesink_node_port_use_buffers, spa_fakesink_node_port_use_buffers,
spa_fakesink_node_port_alloc_buffers, spa_fakesink_node_port_alloc_buffers,
spa_fakesink_node_port_set_io, spa_fakesink_node_port_set_io,

View file

@ -28,6 +28,7 @@
#include <spa/log.h> #include <spa/log.h>
#include <spa/loop.h> #include <spa/loop.h>
#include <spa/node.h> #include <spa/node.h>
#include <spa/param-alloc.h>
#include <spa/list.h> #include <spa/list.h>
#include <spa/format-builder.h> #include <spa/format-builder.h>
#include <lib/props.h> #include <lib/props.h>
@ -43,8 +44,8 @@ typedef struct {
SpaTypeData data; SpaTypeData data;
SpaTypeEventNode event_node; SpaTypeEventNode event_node;
SpaTypeCommandNode command_node; SpaTypeCommandNode command_node;
SpaTypeAllocParamBuffers alloc_param_buffers; SpaTypeParamAllocBuffers param_alloc_buffers;
SpaTypeAllocParamMetaEnable alloc_param_meta_enable; SpaTypeParamAllocMetaEnable param_alloc_meta_enable;
} Type; } Type;
static inline void static inline void
@ -60,8 +61,8 @@ init_type (Type *type, SpaTypeMap *map)
spa_type_data_map (map, &type->data); spa_type_data_map (map, &type->data);
spa_type_event_node_map (map, &type->event_node); spa_type_event_node_map (map, &type->event_node);
spa_type_command_node_map (map, &type->command_node); spa_type_command_node_map (map, &type->command_node);
spa_type_alloc_param_buffers_map (map, &type->alloc_param_buffers); spa_type_param_alloc_buffers_map (map, &type->param_alloc_buffers);
spa_type_alloc_param_meta_enable_map (map, &type->alloc_param_meta_enable); spa_type_param_alloc_meta_enable_map (map, &type->param_alloc_meta_enable);
} }
typedef struct _SpaFakeSrc SpaFakeSrc; typedef struct _SpaFakeSrc SpaFakeSrc;
@ -103,7 +104,6 @@ struct _SpaFakeSrc {
struct itimerspec timerspec; struct itimerspec timerspec;
SpaPortInfo info; SpaPortInfo info;
SpaAllocParam *params[2];
uint8_t params_buffer[1024]; uint8_t params_buffer[1024];
SpaPortIO *io; SpaPortIO *io;
@ -481,29 +481,6 @@ spa_fakesrc_node_port_set_format (SpaNode *node,
} }
if (this->have_format) { if (this->have_format) {
SpaPODBuilder b = { NULL };
SpaPODFrame f[2];
this->info.latency = 0;
this->info.maxbuffering = -1;
this->info.n_params = 2;
this->info.params = this->params;
spa_pod_builder_init (&b, this->params_buffer, sizeof (this->params_buffer));
spa_pod_builder_object (&b, &f[0], 0, this->type.alloc_param_buffers.Buffers,
PROP (&f[1], this->type.alloc_param_buffers.size, SPA_POD_TYPE_INT, 128),
PROP (&f[1], this->type.alloc_param_buffers.stride, SPA_POD_TYPE_INT, 1),
PROP_U_MM (&f[1], this->type.alloc_param_buffers.buffers, SPA_POD_TYPE_INT, 32, 2, 32),
PROP (&f[1], this->type.alloc_param_buffers.align, SPA_POD_TYPE_INT, 16));
this->params[0] = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaAllocParam);
spa_pod_builder_object (&b, &f[0], 0, this->type.alloc_param_meta_enable.MetaEnable,
PROP (&f[1], this->type.alloc_param_meta_enable.type, SPA_POD_TYPE_ID, this->type.meta.Header),
PROP (&f[1], this->type.alloc_param_meta_enable.size, SPA_POD_TYPE_INT, sizeof (SpaMetaHeader)));
this->params[1] = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaAllocParam);
this->info.extra = NULL;
} }
return SPA_RESULT_OK; return SPA_RESULT_OK;
@ -553,19 +530,53 @@ spa_fakesrc_node_port_get_info (SpaNode *node,
} }
static SpaResult static SpaResult
spa_fakesrc_node_port_get_props (SpaNode *node, spa_fakesrc_node_port_enum_params (SpaNode *node,
SpaDirection direction, SpaDirection direction,
uint32_t port_id, uint32_t port_id,
SpaProps **props) uint32_t index,
SpaParam **param)
{ {
return SPA_RESULT_NOT_IMPLEMENTED; SpaFakeSrc *this;
SpaPODBuilder b = { NULL };
SpaPODFrame f[2];
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, SpaFakeSrc, node);
spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT);
spa_pod_builder_init (&b, this->params_buffer, sizeof (this->params_buffer));
switch (index) {
case 0:
spa_pod_builder_object (&b, &f[0], 0, this->type.param_alloc_buffers.Buffers,
PROP (&f[1], this->type.param_alloc_buffers.size, SPA_POD_TYPE_INT, 128),
PROP (&f[1], this->type.param_alloc_buffers.stride, SPA_POD_TYPE_INT, 1),
PROP_U_MM (&f[1], this->type.param_alloc_buffers.buffers, SPA_POD_TYPE_INT, 32, 2, 32),
PROP (&f[1], this->type.param_alloc_buffers.align, SPA_POD_TYPE_INT, 16));
break;
case 1:
spa_pod_builder_object (&b, &f[0], 0, this->type.param_alloc_meta_enable.MetaEnable,
PROP (&f[1], this->type.param_alloc_meta_enable.type, SPA_POD_TYPE_ID, this->type.meta.Header),
PROP (&f[1], this->type.param_alloc_meta_enable.size, SPA_POD_TYPE_INT, sizeof (SpaMetaHeader)));
break;
default:
return SPA_RESULT_NOT_IMPLEMENTED;
}
*param = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaParam);
return SPA_RESULT_OK;
} }
static SpaResult static SpaResult
spa_fakesrc_node_port_set_props (SpaNode *node, spa_fakesrc_node_port_set_param (SpaNode *node,
SpaDirection direction, SpaDirection direction,
uint32_t port_id, uint32_t port_id,
const SpaProps *props) const SpaParam *param)
{ {
return SPA_RESULT_NOT_IMPLEMENTED; return SPA_RESULT_NOT_IMPLEMENTED;
} }
@ -618,7 +629,7 @@ static SpaResult
spa_fakesrc_node_port_alloc_buffers (SpaNode *node, spa_fakesrc_node_port_alloc_buffers (SpaNode *node,
SpaDirection direction, SpaDirection direction,
uint32_t port_id, uint32_t port_id,
SpaAllocParam **params, SpaParam **params,
uint32_t n_params, uint32_t n_params,
SpaBuffer **buffers, SpaBuffer **buffers,
uint32_t *n_buffers) uint32_t *n_buffers)
@ -749,8 +760,8 @@ static const SpaNode fakesrc_node = {
spa_fakesrc_node_port_set_format, spa_fakesrc_node_port_set_format,
spa_fakesrc_node_port_get_format, spa_fakesrc_node_port_get_format,
spa_fakesrc_node_port_get_info, spa_fakesrc_node_port_get_info,
spa_fakesrc_node_port_get_props, spa_fakesrc_node_port_enum_params,
spa_fakesrc_node_port_set_props, spa_fakesrc_node_port_set_param,
spa_fakesrc_node_port_use_buffers, spa_fakesrc_node_port_use_buffers,
spa_fakesrc_node_port_alloc_buffers, spa_fakesrc_node_port_alloc_buffers,
spa_fakesrc_node_port_set_io, spa_fakesrc_node_port_set_io,

View file

@ -30,6 +30,7 @@
#include <spa/list.h> #include <spa/list.h>
#include <spa/log.h> #include <spa/log.h>
#include <spa/loop.h> #include <spa/loop.h>
#include <spa/param-alloc.h>
#include <spa/type-map.h> #include <spa/type-map.h>
#include <spa/format-builder.h> #include <spa/format-builder.h>
#include <lib/debug.h> #include <lib/debug.h>
@ -78,8 +79,8 @@ typedef struct {
SpaTypeVideoFormat video_format; SpaTypeVideoFormat video_format;
SpaTypeEventNode event_node; SpaTypeEventNode event_node;
SpaTypeCommandNode command_node; SpaTypeCommandNode command_node;
SpaTypeAllocParamBuffers alloc_param_buffers; SpaTypeParamAllocBuffers param_alloc_buffers;
SpaTypeAllocParamMetaEnable alloc_param_meta_enable; SpaTypeParamAllocMetaEnable param_alloc_meta_enable;
SpaTypeMeta meta; SpaTypeMeta meta;
SpaTypeData data; SpaTypeData data;
} Type; } Type;
@ -101,8 +102,8 @@ init_type (Type *type, SpaTypeMap *map)
spa_type_video_format_map (map, &type->video_format); spa_type_video_format_map (map, &type->video_format);
spa_type_event_node_map (map, &type->event_node); spa_type_event_node_map (map, &type->event_node);
spa_type_command_node_map (map, &type->command_node); spa_type_command_node_map (map, &type->command_node);
spa_type_alloc_param_buffers_map (map, &type->alloc_param_buffers); spa_type_param_alloc_buffers_map (map, &type->param_alloc_buffers);
spa_type_alloc_param_meta_enable_map (map, &type->alloc_param_meta_enable); spa_type_param_alloc_meta_enable_map (map, &type->param_alloc_meta_enable);
spa_type_meta_map (map, &type->meta); spa_type_meta_map (map, &type->meta);
spa_type_data_map (map, &type->data); spa_type_data_map (map, &type->data);
} }
@ -139,7 +140,6 @@ typedef struct {
SpaSource source; SpaSource source;
SpaPortInfo info; SpaPortInfo info;
SpaAllocParam *params[2];
uint8_t params_buffer[1024]; uint8_t params_buffer[1024];
SpaPortIO *io; SpaPortIO *io;
@ -637,19 +637,58 @@ spa_v4l2_source_node_port_get_info (SpaNode *node,
} }
static SpaResult static SpaResult
spa_v4l2_source_node_port_get_props (SpaNode *node, spa_v4l2_source_node_port_enum_params (SpaNode *node,
SpaDirection direction, SpaDirection direction,
uint32_t port_id, uint32_t port_id,
SpaProps **props) uint32_t index,
SpaParam **param)
{ {
return SPA_RESULT_NOT_IMPLEMENTED;
SpaV4l2Source *this;
SpaV4l2State *state;
SpaPODBuilder b = { NULL, };
SpaPODFrame f[2];
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, SpaV4l2Source, node);
spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT);
state = &this->state[port_id];
spa_pod_builder_init (&b, state->params_buffer, sizeof (state->params_buffer));
switch (index) {
case 0:
spa_pod_builder_object (&b, &f[0], 0, this->type.param_alloc_buffers.Buffers,
PROP (&f[1], this->type.param_alloc_buffers.size, SPA_POD_TYPE_INT, state->fmt.fmt.pix.sizeimage),
PROP (&f[1], this->type.param_alloc_buffers.stride, SPA_POD_TYPE_INT, state->fmt.fmt.pix.bytesperline),
PROP_U_MM (&f[1], this->type.param_alloc_buffers.buffers, SPA_POD_TYPE_INT, MAX_BUFFERS, 2, MAX_BUFFERS),
PROP (&f[1], this->type.param_alloc_buffers.align, SPA_POD_TYPE_INT, 16));
break;
case 1:
spa_pod_builder_object (&b, &f[0], 0, this->type.param_alloc_meta_enable.MetaEnable,
PROP (&f[1], this->type.param_alloc_meta_enable.type, SPA_POD_TYPE_ID, this->type.meta.Header),
PROP (&f[1], this->type.param_alloc_meta_enable.size, SPA_POD_TYPE_INT, sizeof (SpaMetaHeader)));
break;
default:
return SPA_RESULT_NOT_IMPLEMENTED;
}
*param = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaParam);
return SPA_RESULT_OK;
} }
static SpaResult static SpaResult
spa_v4l2_source_node_port_set_props (SpaNode *node, spa_v4l2_source_node_port_set_param (SpaNode *node,
SpaDirection direction, SpaDirection direction,
uint32_t port_id, uint32_t port_id,
const SpaProps *props) const SpaParam *param)
{ {
return SPA_RESULT_NOT_IMPLEMENTED; return SPA_RESULT_NOT_IMPLEMENTED;
} }
@ -692,7 +731,7 @@ static SpaResult
spa_v4l2_source_node_port_alloc_buffers (SpaNode *node, spa_v4l2_source_node_port_alloc_buffers (SpaNode *node,
SpaDirection direction, SpaDirection direction,
uint32_t port_id, uint32_t port_id,
SpaAllocParam **params, SpaParam **params,
uint32_t n_params, uint32_t n_params,
SpaBuffer **buffers, SpaBuffer **buffers,
uint32_t *n_buffers) uint32_t *n_buffers)
@ -831,8 +870,8 @@ static const SpaNode v4l2source_node = {
spa_v4l2_source_node_port_set_format, spa_v4l2_source_node_port_set_format,
spa_v4l2_source_node_port_get_format, spa_v4l2_source_node_port_get_format,
spa_v4l2_source_node_port_get_info, spa_v4l2_source_node_port_get_info,
spa_v4l2_source_node_port_get_props, spa_v4l2_source_node_port_enum_params,
spa_v4l2_source_node_port_set_props, spa_v4l2_source_node_port_set_param,
spa_v4l2_source_node_port_use_buffers, spa_v4l2_source_node_port_use_buffers,
spa_v4l2_source_node_port_alloc_buffers, spa_v4l2_source_node_port_alloc_buffers,
spa_v4l2_source_node_port_set_io, spa_v4l2_source_node_port_set_io,

View file

@ -814,8 +814,6 @@ spa_v4l2_set_format (SpaV4l2Source *this, SpaVideoInfo *format, bool try_only)
uint32_t video_format; uint32_t video_format;
SpaRectangle *size = NULL; SpaRectangle *size = NULL;
SpaFraction *framerate = NULL; SpaFraction *framerate = NULL;
SpaPODBuilder b = { NULL };
SpaPODFrame f[2];
CLEAR (fmt); CLEAR (fmt);
CLEAR (streamparm); CLEAR (streamparm);
@ -900,30 +898,12 @@ spa_v4l2_set_format (SpaV4l2Source *this, SpaVideoInfo *format, bool try_only)
framerate->denom = streamparm.parm.capture.timeperframe.numerator; framerate->denom = streamparm.parm.capture.timeperframe.numerator;
state->fmt = fmt; state->fmt = fmt;
state->info.direction = SPA_DIRECTION_OUTPUT;
state->info.port_id = 0;
state->info.flags = (state->export_buf ? SPA_PORT_INFO_FLAG_CAN_ALLOC_BUFFERS : 0) | state->info.flags = (state->export_buf ? SPA_PORT_INFO_FLAG_CAN_ALLOC_BUFFERS : 0) |
SPA_PORT_INFO_FLAG_CAN_USE_BUFFERS | SPA_PORT_INFO_FLAG_CAN_USE_BUFFERS |
SPA_PORT_INFO_FLAG_LIVE; SPA_PORT_INFO_FLAG_LIVE;
state->info.maxbuffering = -1; state->info.rate = streamparm.parm.capture.timeperframe.denominator;
state->info.latency = (streamparm.parm.capture.timeperframe.numerator * SPA_NSEC_PER_SEC) /
streamparm.parm.capture.timeperframe.denominator;
state->info.n_params = 2;
state->info.params = state->params;
spa_pod_builder_init (&b, state->params_buffer, sizeof (state->params_buffer));
spa_pod_builder_object (&b, &f[0], 0, this->type.alloc_param_buffers.Buffers,
PROP (&f[1], this->type.alloc_param_buffers.size, SPA_POD_TYPE_INT, fmt.fmt.pix.sizeimage),
PROP (&f[1], this->type.alloc_param_buffers.stride, SPA_POD_TYPE_INT, fmt.fmt.pix.bytesperline),
PROP_U_MM (&f[1], this->type.alloc_param_buffers.buffers, SPA_POD_TYPE_INT, MAX_BUFFERS, 2, MAX_BUFFERS),
PROP (&f[1], this->type.alloc_param_buffers.align, SPA_POD_TYPE_INT, 16));
state->params[0] = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaAllocParam);
spa_pod_builder_object (&b, &f[0], 0, this->type.alloc_param_meta_enable.MetaEnable,
PROP (&f[1], this->type.alloc_param_meta_enable.type, SPA_POD_TYPE_ID, this->type.meta.Header),
PROP (&f[1], this->type.alloc_param_meta_enable.size, SPA_POD_TYPE_INT, sizeof (SpaMetaHeader)));
state->params[1] = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaAllocParam);
state->info.extra = NULL;
return 0; return 0;
} }
@ -1077,7 +1057,7 @@ spa_v4l2_use_buffers (SpaV4l2Source *this, SpaBuffer **buffers, uint32_t n_buffe
static SpaResult static SpaResult
mmap_init (SpaV4l2Source *this, mmap_init (SpaV4l2Source *this,
SpaAllocParam **params, SpaParam **params,
uint32_t n_params, uint32_t n_params,
SpaBuffer **buffers, SpaBuffer **buffers,
uint32_t *n_buffers) uint32_t *n_buffers)
@ -1189,7 +1169,7 @@ read_init (SpaV4l2Source *this)
static SpaResult static SpaResult
spa_v4l2_alloc_buffers (SpaV4l2Source *this, spa_v4l2_alloc_buffers (SpaV4l2Source *this,
SpaAllocParam **params, SpaParam **params,
uint32_t n_params, uint32_t n_params,
SpaBuffer **buffers, SpaBuffer **buffers,
uint32_t *n_buffers) uint32_t *n_buffers)

View file

@ -29,6 +29,7 @@
#include <spa/log.h> #include <spa/log.h>
#include <spa/loop.h> #include <spa/loop.h>
#include <spa/node.h> #include <spa/node.h>
#include <spa/param-alloc.h>
#include <spa/list.h> #include <spa/list.h>
#include <spa/video/format-utils.h> #include <spa/video/format-utils.h>
#include <spa/format-builder.h> #include <spa/format-builder.h>
@ -54,8 +55,8 @@ typedef struct {
SpaTypeVideoFormat video_format; SpaTypeVideoFormat video_format;
SpaTypeEventNode event_node; SpaTypeEventNode event_node;
SpaTypeCommandNode command_node; SpaTypeCommandNode command_node;
SpaTypeAllocParamBuffers alloc_param_buffers; SpaTypeParamAllocBuffers param_alloc_buffers;
SpaTypeAllocParamMetaEnable alloc_param_meta_enable; SpaTypeParamAllocMetaEnable param_alloc_meta_enable;
} Type; } Type;
static inline void static inline void
@ -77,8 +78,8 @@ init_type (Type *type, SpaTypeMap *map)
spa_type_video_format_map (map, &type->video_format); spa_type_video_format_map (map, &type->video_format);
spa_type_event_node_map (map, &type->event_node); spa_type_event_node_map (map, &type->event_node);
spa_type_command_node_map (map, &type->command_node); spa_type_command_node_map (map, &type->command_node);
spa_type_alloc_param_buffers_map (map, &type->alloc_param_buffers); spa_type_param_alloc_buffers_map (map, &type->param_alloc_buffers);
spa_type_alloc_param_meta_enable_map (map, &type->alloc_param_meta_enable); spa_type_param_alloc_meta_enable_map (map, &type->param_alloc_meta_enable);
} }
typedef struct _SpaVideoTestSrc SpaVideoTestSrc; typedef struct _SpaVideoTestSrc SpaVideoTestSrc;
@ -120,7 +121,6 @@ struct _SpaVideoTestSrc {
struct itimerspec timerspec; struct itimerspec timerspec;
SpaPortInfo info; SpaPortInfo info;
SpaAllocParam *params[2];
uint8_t params_buffer[1024]; uint8_t params_buffer[1024];
SpaPortIO *io; SpaPortIO *io;
@ -560,30 +560,7 @@ spa_videotestsrc_node_port_set_format (SpaNode *node,
if (this->have_format) { if (this->have_format) {
SpaVideoInfoRaw *raw_info = &this->current_format.info.raw; SpaVideoInfoRaw *raw_info = &this->current_format.info.raw;
SpaPODBuilder b = { NULL };
SpaPODFrame f[2];
this->info.latency = 0;
this->info.maxbuffering = -1;
this->info.n_params = 2;
this->info.params = this->params;
this->stride = SPA_ROUND_UP_N (this->bpp * raw_info->size.width, 4); this->stride = SPA_ROUND_UP_N (this->bpp * raw_info->size.width, 4);
spa_pod_builder_init (&b, this->params_buffer, sizeof (this->params_buffer));
spa_pod_builder_object (&b, &f[0], 0, this->type.alloc_param_buffers.Buffers,
PROP (&f[1], this->type.alloc_param_buffers.size, SPA_POD_TYPE_INT, this->stride * raw_info->size.height),
PROP (&f[1], this->type.alloc_param_buffers.stride, SPA_POD_TYPE_INT, this->stride),
PROP_U_MM (&f[1], this->type.alloc_param_buffers.buffers, SPA_POD_TYPE_INT, 32, 2, 32),
PROP (&f[1], this->type.alloc_param_buffers.align, SPA_POD_TYPE_INT, 16));
this->params[0] = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaAllocParam);
spa_pod_builder_object (&b, &f[0], 0, this->type.alloc_param_meta_enable.MetaEnable,
PROP (&f[1], this->type.alloc_param_meta_enable.type, SPA_POD_TYPE_ID, this->type.meta.Header),
PROP (&f[1], this->type.alloc_param_meta_enable.size, SPA_POD_TYPE_INT, sizeof (SpaMetaHeader)));
this->params[1] = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaAllocParam);
this->info.extra = NULL;
} }
return SPA_RESULT_OK; return SPA_RESULT_OK;
@ -641,19 +618,57 @@ spa_videotestsrc_node_port_get_info (SpaNode *node,
} }
static SpaResult static SpaResult
spa_videotestsrc_node_port_get_props (SpaNode *node, spa_videotestsrc_node_port_enum_params (SpaNode *node,
SpaDirection direction, SpaDirection direction,
uint32_t port_id, uint32_t port_id,
SpaProps **props) uint32_t index,
SpaParam **param)
{ {
return SPA_RESULT_NOT_IMPLEMENTED; SpaVideoTestSrc *this;
SpaPODBuilder b = { NULL, };
SpaPODFrame f[2];
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, SpaVideoTestSrc, node);
spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT);
spa_pod_builder_init (&b, this->params_buffer, sizeof (this->params_buffer));
switch (index) {
case 0:
{
SpaVideoInfoRaw *raw_info = &this->current_format.info.raw;
spa_pod_builder_object (&b, &f[0], 0, this->type.param_alloc_buffers.Buffers,
PROP (&f[1], this->type.param_alloc_buffers.size, SPA_POD_TYPE_INT, this->stride * raw_info->size.height),
PROP (&f[1], this->type.param_alloc_buffers.stride, SPA_POD_TYPE_INT, this->stride),
PROP_U_MM (&f[1], this->type.param_alloc_buffers.buffers, SPA_POD_TYPE_INT, 32, 2, 32),
PROP (&f[1], this->type.param_alloc_buffers.align, SPA_POD_TYPE_INT, 16));
break;
}
case 1:
spa_pod_builder_object (&b, &f[0], 0, this->type.param_alloc_meta_enable.MetaEnable,
PROP (&f[1], this->type.param_alloc_meta_enable.type, SPA_POD_TYPE_ID, this->type.meta.Header),
PROP (&f[1], this->type.param_alloc_meta_enable.size, SPA_POD_TYPE_INT, sizeof (SpaMetaHeader)));
break;
default:
return SPA_RESULT_NOT_IMPLEMENTED;
}
*param = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaParam);
return SPA_RESULT_OK;
} }
static SpaResult static SpaResult
spa_videotestsrc_node_port_set_props (SpaNode *node, spa_videotestsrc_node_port_set_param (SpaNode *node,
SpaDirection direction, SpaDirection direction,
uint32_t port_id, uint32_t port_id,
const SpaProps *props) const SpaParam *param)
{ {
return SPA_RESULT_NOT_IMPLEMENTED; return SPA_RESULT_NOT_IMPLEMENTED;
} }
@ -705,7 +720,7 @@ static SpaResult
spa_videotestsrc_node_port_alloc_buffers (SpaNode *node, spa_videotestsrc_node_port_alloc_buffers (SpaNode *node,
SpaDirection direction, SpaDirection direction,
uint32_t port_id, uint32_t port_id,
SpaAllocParam **params, SpaParam **params,
uint32_t n_params, uint32_t n_params,
SpaBuffer **buffers, SpaBuffer **buffers,
uint32_t *n_buffers) uint32_t *n_buffers)
@ -834,8 +849,8 @@ static const SpaNode videotestsrc_node = {
spa_videotestsrc_node_port_set_format, spa_videotestsrc_node_port_set_format,
spa_videotestsrc_node_port_get_format, spa_videotestsrc_node_port_get_format,
spa_videotestsrc_node_port_get_info, spa_videotestsrc_node_port_get_info,
spa_videotestsrc_node_port_get_props, spa_videotestsrc_node_port_enum_params,
spa_videotestsrc_node_port_set_props, spa_videotestsrc_node_port_set_param,
spa_videotestsrc_node_port_use_buffers, spa_videotestsrc_node_port_use_buffers,
spa_videotestsrc_node_port_alloc_buffers, spa_videotestsrc_node_port_alloc_buffers,
spa_videotestsrc_node_port_set_io, spa_videotestsrc_node_port_set_io,

View file

@ -26,6 +26,7 @@
#include <spa/list.h> #include <spa/list.h>
#include <spa/audio/format-utils.h> #include <spa/audio/format-utils.h>
#include <spa/format-builder.h> #include <spa/format-builder.h>
#include <spa/param-alloc.h>
#include <lib/props.h> #include <lib/props.h>
#define MAX_BUFFERS 16 #define MAX_BUFFERS 16
@ -50,7 +51,6 @@ typedef struct {
bool have_format; bool have_format;
SpaPortInfo info; SpaPortInfo info;
SpaAllocParam *params[2];
uint8_t params_buffer[1024]; uint8_t params_buffer[1024];
SpaVolumeBuffer buffers[MAX_BUFFERS]; SpaVolumeBuffer buffers[MAX_BUFFERS];
@ -74,8 +74,8 @@ typedef struct {
SpaTypeAudioFormat audio_format; SpaTypeAudioFormat audio_format;
SpaTypeEventNode event_node; SpaTypeEventNode event_node;
SpaTypeCommandNode command_node; SpaTypeCommandNode command_node;
SpaTypeAllocParamBuffers alloc_param_buffers; SpaTypeParamAllocBuffers param_alloc_buffers;
SpaTypeAllocParamMetaEnable alloc_param_meta_enable; SpaTypeParamAllocMetaEnable param_alloc_meta_enable;
} Type; } Type;
static inline void static inline void
@ -94,8 +94,8 @@ init_type (Type *type, SpaTypeMap *map)
spa_type_audio_format_map (map, &type->audio_format); spa_type_audio_format_map (map, &type->audio_format);
spa_type_event_node_map (map, &type->event_node); spa_type_event_node_map (map, &type->event_node);
spa_type_command_node_map (map, &type->command_node); spa_type_command_node_map (map, &type->command_node);
spa_type_alloc_param_buffers_map (map, &type->alloc_param_buffers); spa_type_param_alloc_buffers_map (map, &type->param_alloc_buffers);
spa_type_alloc_param_meta_enable_map (map, &type->alloc_param_meta_enable); spa_type_param_alloc_meta_enable_map (map, &type->param_alloc_meta_enable);
} }
struct _SpaVolume { struct _SpaVolume {
@ -388,32 +388,6 @@ spa_volume_node_port_set_format (SpaNode *node,
port->have_format = true; port->have_format = true;
} }
if (port->have_format) {
SpaPODBuilder b = { NULL };
SpaPODFrame f[2];
port->info.maxbuffering = -1;
port->info.latency = 0;
port->info.n_params = 2;
port->info.params = port->params;
spa_pod_builder_init (&b, port->params_buffer, sizeof (port->params_buffer));
spa_pod_builder_object (&b, &f[0], 0, this->type.alloc_param_buffers.Buffers,
PROP (&f[1], this->type.alloc_param_buffers.size, SPA_POD_TYPE_INT, 16),
PROP (&f[1], this->type.alloc_param_buffers.stride, SPA_POD_TYPE_INT, 16),
PROP_U_MM (&f[1], this->type.alloc_param_buffers.buffers, SPA_POD_TYPE_INT, MAX_BUFFERS, 2, MAX_BUFFERS),
PROP (&f[1], this->type.alloc_param_buffers.align, SPA_POD_TYPE_INT, 16));
port->params[0] = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaAllocParam);
spa_pod_builder_object (&b, &f[0], 0, this->type.alloc_param_meta_enable.MetaEnable,
PROP (&f[1], this->type.alloc_param_meta_enable.type, SPA_POD_TYPE_ID, this->type.meta.Header),
PROP (&f[1], this->type.alloc_param_meta_enable.size, SPA_POD_TYPE_INT, sizeof (SpaMetaHeader)));
port->params[1] = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaAllocParam);
port->info.extra = NULL;
}
return SPA_RESULT_OK; return SPA_RESULT_OK;
} }
@ -466,19 +440,57 @@ spa_volume_node_port_get_info (SpaNode *node,
} }
static SpaResult static SpaResult
spa_volume_node_port_get_props (SpaNode *node, spa_volume_node_port_enum_params (SpaNode *node,
SpaDirection direction, SpaDirection direction,
uint32_t port_id, uint32_t port_id,
SpaProps **props) uint32_t index,
SpaParam **param)
{ {
return SPA_RESULT_NOT_IMPLEMENTED; SpaPODBuilder b = { NULL };
SpaPODFrame f[2];
SpaVolume *this;
SpaVolumePort *port;
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, SpaVolume, node);
spa_return_val_if_fail (CHECK_PORT (this, direction, port_id), SPA_RESULT_INVALID_PORT);
port = direction == SPA_DIRECTION_INPUT ? &this->in_ports[port_id] : &this->out_ports[port_id];
spa_pod_builder_init (&b, port->params_buffer, sizeof (port->params_buffer));
switch (index) {
case 0:
spa_pod_builder_object (&b, &f[0], 0, this->type.param_alloc_buffers.Buffers,
PROP (&f[1], this->type.param_alloc_buffers.size, SPA_POD_TYPE_INT, 16),
PROP (&f[1], this->type.param_alloc_buffers.stride, SPA_POD_TYPE_INT, 16),
PROP_U_MM (&f[1], this->type.param_alloc_buffers.buffers, SPA_POD_TYPE_INT, MAX_BUFFERS, 2, MAX_BUFFERS),
PROP (&f[1], this->type.param_alloc_buffers.align, SPA_POD_TYPE_INT, 16));
break;
case 1:
spa_pod_builder_object (&b, &f[0], 0, this->type.param_alloc_meta_enable.MetaEnable,
PROP (&f[1], this->type.param_alloc_meta_enable.type, SPA_POD_TYPE_ID, this->type.meta.Header),
PROP (&f[1], this->type.param_alloc_meta_enable.size, SPA_POD_TYPE_INT, sizeof (SpaMetaHeader)));
break;
default:
return SPA_RESULT_NOT_IMPLEMENTED;
}
*param = SPA_POD_BUILDER_DEREF (&b, f[0].ref, SpaParam);
return SPA_RESULT_OK;
} }
static SpaResult static SpaResult
spa_volume_node_port_set_props (SpaNode *node, spa_volume_node_port_set_param (SpaNode *node,
SpaDirection direction, SpaDirection direction,
uint32_t port_id, uint32_t port_id,
const SpaProps *props) const SpaParam *param)
{ {
return SPA_RESULT_NOT_IMPLEMENTED; return SPA_RESULT_NOT_IMPLEMENTED;
} }
@ -538,7 +550,7 @@ static SpaResult
spa_volume_node_port_alloc_buffers (SpaNode *node, spa_volume_node_port_alloc_buffers (SpaNode *node,
SpaDirection direction, SpaDirection direction,
uint32_t port_id, uint32_t port_id,
SpaAllocParam **params, SpaParam **params,
uint32_t n_params, uint32_t n_params,
SpaBuffer **buffers, SpaBuffer **buffers,
uint32_t *n_buffers) uint32_t *n_buffers)
@ -772,8 +784,8 @@ static const SpaNode volume_node = {
spa_volume_node_port_set_format, spa_volume_node_port_set_format,
spa_volume_node_port_get_format, spa_volume_node_port_get_format,
spa_volume_node_port_get_info, spa_volume_node_port_get_info,
spa_volume_node_port_get_props, spa_volume_node_port_enum_params,
spa_volume_node_port_set_props, spa_volume_node_port_set_param,
spa_volume_node_port_use_buffers, spa_volume_node_port_use_buffers,
spa_volume_node_port_alloc_buffers, spa_volume_node_port_alloc_buffers,
spa_volume_node_port_set_io, spa_volume_node_port_set_io,

View file

@ -388,19 +388,20 @@ spa_xv_sink_node_port_get_info (SpaNode *node,
} }
static SpaResult static SpaResult
spa_xv_sink_node_port_get_props (SpaNode *node, spa_xv_sink_node_port_enum_params (SpaNode *node,
SpaDirection direction, SpaDirection direction,
uint32_t port_id, uint32_t port_id,
SpaProps **props) uint32_t index,
SpaParam **param)
{ {
return SPA_RESULT_NOT_IMPLEMENTED; return SPA_RESULT_NOT_IMPLEMENTED;
} }
static SpaResult static SpaResult
spa_xv_sink_node_port_set_props (SpaNode *node, spa_xv_sink_node_port_set_param (SpaNode *node,
SpaDirection direction, SpaDirection direction,
uint32_t port_id, uint32_t port_id,
const SpaProps *props) const SpaParam *param)
{ {
return SPA_RESULT_NOT_IMPLEMENTED; return SPA_RESULT_NOT_IMPLEMENTED;
} }
@ -419,7 +420,7 @@ static SpaResult
spa_xv_sink_node_port_alloc_buffers (SpaNode *node, spa_xv_sink_node_port_alloc_buffers (SpaNode *node,
SpaDirection direction, SpaDirection direction,
uint32_t port_id, uint32_t port_id,
SpaAllocParam **params, SpaParam **params,
uint32_t n_params, uint32_t n_params,
SpaBuffer **buffers, SpaBuffer **buffers,
uint32_t *n_buffers) uint32_t *n_buffers)
@ -492,8 +493,8 @@ static const SpaNode xvsink_node = {
spa_xv_sink_node_port_set_format, spa_xv_sink_node_port_set_format,
spa_xv_sink_node_port_get_format, spa_xv_sink_node_port_get_format,
spa_xv_sink_node_port_get_info, spa_xv_sink_node_port_get_info,
spa_xv_sink_node_port_get_props, spa_xv_sink_node_port_enum_params,
spa_xv_sink_node_port_set_props, spa_xv_sink_node_port_set_param,
spa_xv_sink_node_port_use_buffers, spa_xv_sink_node_port_use_buffers,
spa_xv_sink_node_port_alloc_buffers, spa_xv_sink_node_port_alloc_buffers,
spa_xv_sink_node_port_set_io, spa_xv_sink_node_port_set_io,

View file

@ -51,10 +51,9 @@ inspect_port (AppData *data, SpaNode *node, SpaDirection direction, uint32_t por
{ {
SpaResult res; SpaResult res;
SpaFormat *format; SpaFormat *format;
uint32_t index = 0; uint32_t index;
SpaProps *props;
while (true) { for (index = 0; ; index++) {
if ((res = spa_node_port_enum_formats (node, direction, port_id, &format, NULL, index)) < 0) { if ((res = spa_node_port_enum_formats (node, direction, port_id, &format, NULL, index)) < 0) {
if (res != SPA_RESULT_ENUM_END) if (res != SPA_RESULT_ENUM_END)
printf ("got error %d\n", res); printf ("got error %d\n", res);
@ -62,12 +61,19 @@ inspect_port (AppData *data, SpaNode *node, SpaDirection direction, uint32_t por
} }
if (format) if (format)
spa_debug_format (format, data->map); spa_debug_format (format, data->map);
index++;
} }
if ((res = spa_node_port_get_props (node, direction, port_id, &props)) < 0)
printf ("port_get_props error: %d\n", res);
else for (index = 0; ; index++) {
spa_debug_props (props, data->map); SpaParam *param;
if ((res = spa_node_port_enum_params (node, direction, port_id, index, &param)) < 0) {
if (res != SPA_RESULT_ENUM_END)
printf ("port_enum_params error: %d\n", res);
break;
}
spa_debug_param (param, data->map);
}
} }
static void static void