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/props.h>
#include <spa/format.h>
#include <spa/alloc-param.h>
#include <spa/param-alloc.h>
#include <spa/node.h>
typedef struct _PinosClientNodeBuffer PinosClientNodeBuffer;
@ -184,13 +184,14 @@ typedef struct {
uint32_t port_id,
#define PINOS_MESSAGE_PORT_UPDATE_POSSIBLE_FORMATS (1 << 0)
#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)
uint32_t change_mask,
uint32_t n_possible_formats,
const SpaFormat **possible_formats,
const SpaFormat *format,
const SpaProps *props,
uint32_t n_params,
const SpaParam **params,
const SpaPortInfo *info);
void (*event) (void *object,
SpaEvent *event);

View file

@ -500,14 +500,15 @@ client_node_marshal_port_update (void *object,
uint32_t n_possible_formats,
const SpaFormat **possible_formats,
const SpaFormat *format,
const SpaProps *props,
uint32_t n_params,
const SpaParam **params,
const SpaPortInfo *info)
{
PinosProxy *proxy = object;
PinosConnection *connection = proxy->context->protocol_private;
Builder b = { { NULL, 0, 0, NULL, write_pod }, connection };
SpaPODFrame f[2];
int i, n_items;
int i;
if (connection == NULL)
return;
@ -527,31 +528,20 @@ client_node_marshal_port_update (void *object,
spa_pod_builder_add (&b.b,
SPA_POD_TYPE_POD, format,
SPA_POD_TYPE_POD, props,
SPA_POD_TYPE_INT, n_params,
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) {
spa_pod_builder_add (&b.b,
SPA_POD_TYPE_STRUCT, &f[1],
SPA_POD_TYPE_INT, info->flags,
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);
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);
} else {
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;
SpaFormat **possible_formats;
uint32_t n_params;
SpaParam **params;
SpaFormat *format;
SpaPortInfo port_info;
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
pinos_stream_destroy (PinosStream *stream)
{
@ -306,6 +331,7 @@ pinos_stream_destroy (PinosStream *stream)
pinos_signal_remove (&impl->node_proxy_destroy);
set_possible_formats (stream, 0, NULL);
set_params (stream, 0, NULL);
if (impl->format)
free (impl->format);
@ -361,7 +387,8 @@ add_port_update (PinosStream *stream, uint32_t change_mask)
impl->n_possible_formats,
(const SpaFormat **) impl->possible_formats,
impl->format,
NULL,
impl->n_params,
(const SpaParam **)impl->params,
&impl->port_info);
}
@ -1028,7 +1055,7 @@ pinos_stream_connect (PinosStream *stream,
* pinos_stream_finish_format:
* @stream: a #PinosStream
* @res: a #SpaResult
* @params: an array of pointers to #SpaAllocParam
* @params: an array of pointers to #SpaParam
* @n_params: number of elements in @params
*
* Complete the negotiation process with result code @res.
@ -1043,16 +1070,15 @@ pinos_stream_connect (PinosStream *stream,
bool
pinos_stream_finish_format (PinosStream *stream,
SpaResult res,
SpaAllocParam **params,
SpaParam **params,
uint32_t n_params)
{
PinosStreamImpl *impl = SPA_CONTAINER_OF (stream, PinosStreamImpl, this);
impl->port_info.params = params;
impl->port_info.n_params = n_params;
set_params (stream, n_params, params);
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);
if (!impl->format) {
@ -1060,9 +1086,6 @@ pinos_stream_finish_format (PinosStream *stream,
clear_mems (stream);
}
}
impl->port_info.params = NULL;
impl->port_info.n_params = 0;
add_async_complete (stream, impl->pending_seq, res);
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,
SpaResult res,
SpaAllocParam **params,
SpaParam **params,
uint32_t n_params);
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_command_node_map (type->map, &type->command_node);
spa_type_monitor_map (type->map, &type->monitor);
spa_type_alloc_param_buffers_map (type->map, &type->alloc_param_buffers);
spa_type_alloc_param_meta_enable_map (type->map, &type->alloc_param_meta_enable);
spa_type_alloc_param_video_padding_map (type->map, &type->alloc_param_video_padding);
spa_type_param_alloc_buffers_map (type->map, &type->param_alloc_buffers);
spa_type_param_alloc_meta_enable_map (type->map, &type->param_alloc_meta_enable);
spa_type_param_alloc_video_padding_map (type->map, &type->param_alloc_video_padding);
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/command-node.h>
#include <spa/monitor.h>
#include <spa/alloc-param.h>
#include <spa/param-alloc.h>
#include <pinos/client/map.h>
#include <pinos/client/transport.h>
@ -63,9 +63,9 @@ struct _PinosType {
SpaTypeEventNode event_node;
SpaTypeCommandNode command_node;
SpaTypeMonitor monitor;
SpaTypeAllocParamBuffers alloc_param_buffers;
SpaTypeAllocParamMetaEnable alloc_param_meta_enable;
SpaTypeAllocParamVideoPadding alloc_param_video_padding;
SpaTypeParamAllocBuffers param_alloc_buffers;
SpaTypeParamAllocMetaEnable param_alloc_meta_enable;
SpaTypeParamAllocVideoPadding param_alloc_video_padding;
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_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
} /* extern "C" */