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

@ -278,8 +278,6 @@ spa_alsa_sink_node_port_set_format (SpaNode *node,
const SpaFormat *format)
{
SpaALSASink *this;
SpaPODBuilder b = { NULL };
SpaPODFrame f[2];
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) {
this->info.direction = direction;
this->info.port_id = port_id;
this->info.flags = SPA_PORT_INFO_FLAG_CAN_USE_BUFFERS |
SPA_PORT_INFO_FLAG_LIVE;
this->info.maxbuffering = this->buffer_frames * this->frame_size;
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;
this->info.rate = this->rate;
}
return SPA_RESULT_OK;
@ -400,19 +373,66 @@ spa_alsa_sink_node_port_get_info (SpaNode *node,
}
static SpaResult
spa_alsa_sink_node_port_get_props (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
SpaProps **props)
spa_alsa_sink_node_port_enum_params (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
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
spa_alsa_sink_node_port_set_props (SpaNode *node,
spa_alsa_sink_node_port_set_param (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
const SpaProps *props)
const SpaParam *param)
{
return SPA_RESULT_NOT_IMPLEMENTED;
}
@ -471,7 +491,7 @@ static SpaResult
spa_alsa_sink_node_port_alloc_buffers (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
SpaAllocParam **params,
SpaParam **params,
uint32_t n_params,
SpaBuffer **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_get_format,
spa_alsa_sink_node_port_get_info,
spa_alsa_sink_node_port_get_props,
spa_alsa_sink_node_port_set_props,
spa_alsa_sink_node_port_enum_params,
spa_alsa_sink_node_port_set_param,
spa_alsa_sink_node_port_use_buffers,
spa_alsa_sink_node_port_alloc_buffers,
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)
{
SpaALSASource *this;
SpaPODBuilder b = { NULL };
SpaPODFrame f[2];
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) {
this->info.direction = direction;
this->info.port_id = port_id;
this->info.flags = SPA_PORT_INFO_FLAG_CAN_USE_BUFFERS |
SPA_PORT_INFO_FLAG_LIVE;
this->info.maxbuffering = this->buffer_frames * this->frame_size;
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;
this->info.rate = this->rate;
}
return SPA_RESULT_OK;
@ -438,19 +419,55 @@ spa_alsa_source_node_port_get_info (SpaNode *node,
}
static SpaResult
spa_alsa_source_node_port_get_props (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
SpaProps **props)
spa_alsa_source_node_port_enum_params (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
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
spa_alsa_source_node_port_set_props (SpaNode *node,
spa_alsa_source_node_port_set_param (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
const SpaProps *props)
const SpaParam *param)
{
return SPA_RESULT_NOT_IMPLEMENTED;
}
@ -508,7 +525,7 @@ static SpaResult
spa_alsa_source_node_port_alloc_buffers (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
SpaAllocParam **params,
SpaParam **params,
uint32_t n_params,
SpaBuffer **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_get_format,
spa_alsa_source_node_port_get_info,
spa_alsa_source_node_port_get_props,
spa_alsa_source_node_port_set_props,
spa_alsa_source_node_port_enum_params,
spa_alsa_source_node_port_set_param,
spa_alsa_source_node_port_use_buffers,
spa_alsa_source_node_port_alloc_buffers,
spa_alsa_source_node_port_set_io,

View file

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

View file

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

View file

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

View file

@ -324,19 +324,20 @@ spa_ffmpeg_dec_node_port_get_info (SpaNode *node,
}
static SpaResult
spa_ffmpeg_dec_node_port_get_props (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
SpaProps **props)
spa_ffmpeg_dec_node_port_enum_params (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
uint32_t index,
SpaParam **param)
{
return SPA_RESULT_NOT_IMPLEMENTED;
}
static SpaResult
spa_ffmpeg_dec_node_port_set_props (SpaNode *node,
spa_ffmpeg_dec_node_port_set_param (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
const SpaProps *props)
const SpaParam *param)
{
return SPA_RESULT_NOT_IMPLEMENTED;
}
@ -361,7 +362,7 @@ static SpaResult
spa_ffmpeg_dec_node_port_alloc_buffers (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
SpaAllocParam **params,
SpaParam **params,
uint32_t n_params,
SpaBuffer **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_get_format,
spa_ffmpeg_dec_node_port_get_info,
spa_ffmpeg_dec_node_port_get_props,
spa_ffmpeg_dec_node_port_set_props,
spa_ffmpeg_dec_node_port_enum_params,
spa_ffmpeg_dec_node_port_set_param,
spa_ffmpeg_dec_node_port_use_buffers,
spa_ffmpeg_dec_node_port_alloc_buffers,
spa_ffmpeg_dec_node_port_set_io,

View file

@ -328,19 +328,20 @@ spa_ffmpeg_enc_node_port_get_info (SpaNode *node,
}
static SpaResult
spa_ffmpeg_enc_node_port_get_props (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
SpaProps **props)
spa_ffmpeg_enc_node_port_enum_params (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
uint32_t index,
SpaParam **param)
{
return SPA_RESULT_NOT_IMPLEMENTED;
}
static SpaResult
spa_ffmpeg_enc_node_port_set_props (SpaNode *node,
spa_ffmpeg_enc_node_port_set_param (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
const SpaProps *props)
const SpaParam *param)
{
return SPA_RESULT_NOT_IMPLEMENTED;
}
@ -365,7 +366,7 @@ static SpaResult
spa_ffmpeg_enc_node_port_alloc_buffers (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
SpaAllocParam **params,
SpaParam **params,
uint32_t n_params,
SpaBuffer **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_get_format,
spa_ffmpeg_enc_node_port_get_info,
spa_ffmpeg_enc_node_port_get_props,
spa_ffmpeg_enc_node_port_set_props,
spa_ffmpeg_enc_node_port_enum_params,
spa_ffmpeg_enc_node_port_set_param,
spa_ffmpeg_enc_node_port_use_buffers,
spa_ffmpeg_enc_node_port_alloc_buffers,
spa_ffmpeg_enc_node_port_set_io,

View file

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

View file

@ -28,6 +28,7 @@
#include <spa/log.h>
#include <spa/loop.h>
#include <spa/node.h>
#include <spa/param-alloc.h>
#include <spa/list.h>
#include <spa/format-builder.h>
#include <lib/props.h>
@ -42,8 +43,8 @@ typedef struct {
SpaTypeData data;
SpaTypeEventNode event_node;
SpaTypeCommandNode command_node;
SpaTypeAllocParamBuffers alloc_param_buffers;
SpaTypeAllocParamMetaEnable alloc_param_meta_enable;
SpaTypeParamAllocBuffers param_alloc_buffers;
SpaTypeParamAllocMetaEnable param_alloc_meta_enable;
} Type;
static inline void
@ -58,8 +59,8 @@ init_type (Type *type, SpaTypeMap *map)
spa_type_data_map (map, &type->data);
spa_type_event_node_map (map, &type->event_node);
spa_type_command_node_map (map, &type->command_node);
spa_type_alloc_param_buffers_map (map, &type->alloc_param_buffers);
spa_type_alloc_param_meta_enable_map (map, &type->alloc_param_meta_enable);
spa_type_param_alloc_buffers_map (map, &type->param_alloc_buffers);
spa_type_param_alloc_meta_enable_map (map, &type->param_alloc_meta_enable);
}
typedef struct _SpaFakeSink SpaFakeSink;
@ -100,7 +101,6 @@ struct _SpaFakeSink {
struct itimerspec timerspec;
SpaPortInfo info;
SpaAllocParam *params[2];
uint8_t params_buffer[1024];
SpaPortIO *io;
@ -467,33 +467,6 @@ spa_fakesink_node_port_set_format (SpaNode *node,
memcpy (this->format_buffer, format, SPA_POD_SIZE (format));
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;
}
@ -541,29 +514,63 @@ spa_fakesink_node_port_get_info (SpaNode *node,
}
static SpaResult
spa_fakesink_node_port_get_props (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
SpaProps **props)
spa_fakesink_node_port_enum_params (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
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
spa_fakesink_node_port_set_props (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
const SpaProps *props)
spa_fakesink_node_port_set_param (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
const SpaParam *param)
{
return SPA_RESULT_NOT_IMPLEMENTED;
}
static SpaResult
spa_fakesink_node_port_use_buffers (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
SpaBuffer **buffers,
uint32_t n_buffers)
SpaDirection direction,
uint32_t port_id,
SpaBuffer **buffers,
uint32_t n_buffers)
{
SpaFakeSink *this;
uint32_t i;
@ -604,7 +611,7 @@ static SpaResult
spa_fakesink_node_port_alloc_buffers (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
SpaAllocParam **params,
SpaParam **params,
uint32_t n_params,
SpaBuffer **buffers,
uint32_t *n_buffers)
@ -716,8 +723,8 @@ static const SpaNode fakesink_node = {
spa_fakesink_node_port_set_format,
spa_fakesink_node_port_get_format,
spa_fakesink_node_port_get_info,
spa_fakesink_node_port_get_props,
spa_fakesink_node_port_set_props,
spa_fakesink_node_port_enum_params,
spa_fakesink_node_port_set_param,
spa_fakesink_node_port_use_buffers,
spa_fakesink_node_port_alloc_buffers,
spa_fakesink_node_port_set_io,

View file

@ -28,6 +28,7 @@
#include <spa/log.h>
#include <spa/loop.h>
#include <spa/node.h>
#include <spa/param-alloc.h>
#include <spa/list.h>
#include <spa/format-builder.h>
#include <lib/props.h>
@ -43,8 +44,8 @@ typedef struct {
SpaTypeData data;
SpaTypeEventNode event_node;
SpaTypeCommandNode command_node;
SpaTypeAllocParamBuffers alloc_param_buffers;
SpaTypeAllocParamMetaEnable alloc_param_meta_enable;
SpaTypeParamAllocBuffers param_alloc_buffers;
SpaTypeParamAllocMetaEnable param_alloc_meta_enable;
} Type;
static inline void
@ -60,8 +61,8 @@ init_type (Type *type, SpaTypeMap *map)
spa_type_data_map (map, &type->data);
spa_type_event_node_map (map, &type->event_node);
spa_type_command_node_map (map, &type->command_node);
spa_type_alloc_param_buffers_map (map, &type->alloc_param_buffers);
spa_type_alloc_param_meta_enable_map (map, &type->alloc_param_meta_enable);
spa_type_param_alloc_buffers_map (map, &type->param_alloc_buffers);
spa_type_param_alloc_meta_enable_map (map, &type->param_alloc_meta_enable);
}
typedef struct _SpaFakeSrc SpaFakeSrc;
@ -103,7 +104,6 @@ struct _SpaFakeSrc {
struct itimerspec timerspec;
SpaPortInfo info;
SpaAllocParam *params[2];
uint8_t params_buffer[1024];
SpaPortIO *io;
@ -481,29 +481,6 @@ spa_fakesrc_node_port_set_format (SpaNode *node,
}
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;
@ -553,19 +530,53 @@ spa_fakesrc_node_port_get_info (SpaNode *node,
}
static SpaResult
spa_fakesrc_node_port_get_props (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
SpaProps **props)
spa_fakesrc_node_port_enum_params (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
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
spa_fakesrc_node_port_set_props (SpaNode *node,
spa_fakesrc_node_port_set_param (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
const SpaProps *props)
const SpaParam *param)
{
return SPA_RESULT_NOT_IMPLEMENTED;
}
@ -618,7 +629,7 @@ static SpaResult
spa_fakesrc_node_port_alloc_buffers (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
SpaAllocParam **params,
SpaParam **params,
uint32_t n_params,
SpaBuffer **buffers,
uint32_t *n_buffers)
@ -749,8 +760,8 @@ static const SpaNode fakesrc_node = {
spa_fakesrc_node_port_set_format,
spa_fakesrc_node_port_get_format,
spa_fakesrc_node_port_get_info,
spa_fakesrc_node_port_get_props,
spa_fakesrc_node_port_set_props,
spa_fakesrc_node_port_enum_params,
spa_fakesrc_node_port_set_param,
spa_fakesrc_node_port_use_buffers,
spa_fakesrc_node_port_alloc_buffers,
spa_fakesrc_node_port_set_io,

View file

@ -30,6 +30,7 @@
#include <spa/list.h>
#include <spa/log.h>
#include <spa/loop.h>
#include <spa/param-alloc.h>
#include <spa/type-map.h>
#include <spa/format-builder.h>
#include <lib/debug.h>
@ -78,8 +79,8 @@ typedef struct {
SpaTypeVideoFormat video_format;
SpaTypeEventNode event_node;
SpaTypeCommandNode command_node;
SpaTypeAllocParamBuffers alloc_param_buffers;
SpaTypeAllocParamMetaEnable alloc_param_meta_enable;
SpaTypeParamAllocBuffers param_alloc_buffers;
SpaTypeParamAllocMetaEnable param_alloc_meta_enable;
SpaTypeMeta meta;
SpaTypeData data;
} Type;
@ -101,8 +102,8 @@ init_type (Type *type, SpaTypeMap *map)
spa_type_video_format_map (map, &type->video_format);
spa_type_event_node_map (map, &type->event_node);
spa_type_command_node_map (map, &type->command_node);
spa_type_alloc_param_buffers_map (map, &type->alloc_param_buffers);
spa_type_alloc_param_meta_enable_map (map, &type->alloc_param_meta_enable);
spa_type_param_alloc_buffers_map (map, &type->param_alloc_buffers);
spa_type_param_alloc_meta_enable_map (map, &type->param_alloc_meta_enable);
spa_type_meta_map (map, &type->meta);
spa_type_data_map (map, &type->data);
}
@ -139,7 +140,6 @@ typedef struct {
SpaSource source;
SpaPortInfo info;
SpaAllocParam *params[2];
uint8_t params_buffer[1024];
SpaPortIO *io;
@ -637,19 +637,58 @@ spa_v4l2_source_node_port_get_info (SpaNode *node,
}
static SpaResult
spa_v4l2_source_node_port_get_props (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
SpaProps **props)
spa_v4l2_source_node_port_enum_params (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
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
spa_v4l2_source_node_port_set_props (SpaNode *node,
spa_v4l2_source_node_port_set_param (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
const SpaProps *props)
const SpaParam *param)
{
return SPA_RESULT_NOT_IMPLEMENTED;
}
@ -692,7 +731,7 @@ static SpaResult
spa_v4l2_source_node_port_alloc_buffers (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
SpaAllocParam **params,
SpaParam **params,
uint32_t n_params,
SpaBuffer **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_get_format,
spa_v4l2_source_node_port_get_info,
spa_v4l2_source_node_port_get_props,
spa_v4l2_source_node_port_set_props,
spa_v4l2_source_node_port_enum_params,
spa_v4l2_source_node_port_set_param,
spa_v4l2_source_node_port_use_buffers,
spa_v4l2_source_node_port_alloc_buffers,
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;
SpaRectangle *size = NULL;
SpaFraction *framerate = NULL;
SpaPODBuilder b = { NULL };
SpaPODFrame f[2];
CLEAR (fmt);
CLEAR (streamparm);
@ -900,30 +898,12 @@ spa_v4l2_set_format (SpaV4l2Source *this, SpaVideoInfo *format, bool try_only)
framerate->denom = streamparm.parm.capture.timeperframe.numerator;
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) |
SPA_PORT_INFO_FLAG_CAN_USE_BUFFERS |
SPA_PORT_INFO_FLAG_LIVE;
state->info.maxbuffering = -1;
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;
state->info.rate = streamparm.parm.capture.timeperframe.denominator;
return 0;
}
@ -1077,7 +1057,7 @@ spa_v4l2_use_buffers (SpaV4l2Source *this, SpaBuffer **buffers, uint32_t n_buffe
static SpaResult
mmap_init (SpaV4l2Source *this,
SpaAllocParam **params,
SpaParam **params,
uint32_t n_params,
SpaBuffer **buffers,
uint32_t *n_buffers)
@ -1189,7 +1169,7 @@ read_init (SpaV4l2Source *this)
static SpaResult
spa_v4l2_alloc_buffers (SpaV4l2Source *this,
SpaAllocParam **params,
SpaParam **params,
uint32_t n_params,
SpaBuffer **buffers,
uint32_t *n_buffers)

View file

@ -29,6 +29,7 @@
#include <spa/log.h>
#include <spa/loop.h>
#include <spa/node.h>
#include <spa/param-alloc.h>
#include <spa/list.h>
#include <spa/video/format-utils.h>
#include <spa/format-builder.h>
@ -54,8 +55,8 @@ typedef struct {
SpaTypeVideoFormat video_format;
SpaTypeEventNode event_node;
SpaTypeCommandNode command_node;
SpaTypeAllocParamBuffers alloc_param_buffers;
SpaTypeAllocParamMetaEnable alloc_param_meta_enable;
SpaTypeParamAllocBuffers param_alloc_buffers;
SpaTypeParamAllocMetaEnable param_alloc_meta_enable;
} Type;
static inline void
@ -77,8 +78,8 @@ init_type (Type *type, SpaTypeMap *map)
spa_type_video_format_map (map, &type->video_format);
spa_type_event_node_map (map, &type->event_node);
spa_type_command_node_map (map, &type->command_node);
spa_type_alloc_param_buffers_map (map, &type->alloc_param_buffers);
spa_type_alloc_param_meta_enable_map (map, &type->alloc_param_meta_enable);
spa_type_param_alloc_buffers_map (map, &type->param_alloc_buffers);
spa_type_param_alloc_meta_enable_map (map, &type->param_alloc_meta_enable);
}
typedef struct _SpaVideoTestSrc SpaVideoTestSrc;
@ -120,7 +121,6 @@ struct _SpaVideoTestSrc {
struct itimerspec timerspec;
SpaPortInfo info;
SpaAllocParam *params[2];
uint8_t params_buffer[1024];
SpaPortIO *io;
@ -560,30 +560,7 @@ spa_videotestsrc_node_port_set_format (SpaNode *node,
if (this->have_format) {
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);
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;
@ -641,19 +618,57 @@ spa_videotestsrc_node_port_get_info (SpaNode *node,
}
static SpaResult
spa_videotestsrc_node_port_get_props (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
SpaProps **props)
spa_videotestsrc_node_port_enum_params (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
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
spa_videotestsrc_node_port_set_props (SpaNode *node,
spa_videotestsrc_node_port_set_param (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
const SpaProps *props)
const SpaParam *param)
{
return SPA_RESULT_NOT_IMPLEMENTED;
}
@ -705,7 +720,7 @@ static SpaResult
spa_videotestsrc_node_port_alloc_buffers (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
SpaAllocParam **params,
SpaParam **params,
uint32_t n_params,
SpaBuffer **buffers,
uint32_t *n_buffers)
@ -834,8 +849,8 @@ static const SpaNode videotestsrc_node = {
spa_videotestsrc_node_port_set_format,
spa_videotestsrc_node_port_get_format,
spa_videotestsrc_node_port_get_info,
spa_videotestsrc_node_port_get_props,
spa_videotestsrc_node_port_set_props,
spa_videotestsrc_node_port_enum_params,
spa_videotestsrc_node_port_set_param,
spa_videotestsrc_node_port_use_buffers,
spa_videotestsrc_node_port_alloc_buffers,
spa_videotestsrc_node_port_set_io,

View file

@ -26,6 +26,7 @@
#include <spa/list.h>
#include <spa/audio/format-utils.h>
#include <spa/format-builder.h>
#include <spa/param-alloc.h>
#include <lib/props.h>
#define MAX_BUFFERS 16
@ -50,7 +51,6 @@ typedef struct {
bool have_format;
SpaPortInfo info;
SpaAllocParam *params[2];
uint8_t params_buffer[1024];
SpaVolumeBuffer buffers[MAX_BUFFERS];
@ -74,8 +74,8 @@ typedef struct {
SpaTypeAudioFormat audio_format;
SpaTypeEventNode event_node;
SpaTypeCommandNode command_node;
SpaTypeAllocParamBuffers alloc_param_buffers;
SpaTypeAllocParamMetaEnable alloc_param_meta_enable;
SpaTypeParamAllocBuffers param_alloc_buffers;
SpaTypeParamAllocMetaEnable param_alloc_meta_enable;
} Type;
static inline void
@ -94,8 +94,8 @@ init_type (Type *type, SpaTypeMap *map)
spa_type_audio_format_map (map, &type->audio_format);
spa_type_event_node_map (map, &type->event_node);
spa_type_command_node_map (map, &type->command_node);
spa_type_alloc_param_buffers_map (map, &type->alloc_param_buffers);
spa_type_alloc_param_meta_enable_map (map, &type->alloc_param_meta_enable);
spa_type_param_alloc_buffers_map (map, &type->param_alloc_buffers);
spa_type_param_alloc_meta_enable_map (map, &type->param_alloc_meta_enable);
}
struct _SpaVolume {
@ -388,32 +388,6 @@ spa_volume_node_port_set_format (SpaNode *node,
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;
}
@ -466,19 +440,57 @@ spa_volume_node_port_get_info (SpaNode *node,
}
static SpaResult
spa_volume_node_port_get_props (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
SpaProps **props)
spa_volume_node_port_enum_params (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
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
spa_volume_node_port_set_props (SpaNode *node,
spa_volume_node_port_set_param (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
const SpaProps *props)
const SpaParam *param)
{
return SPA_RESULT_NOT_IMPLEMENTED;
}
@ -538,7 +550,7 @@ static SpaResult
spa_volume_node_port_alloc_buffers (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
SpaAllocParam **params,
SpaParam **params,
uint32_t n_params,
SpaBuffer **buffers,
uint32_t *n_buffers)
@ -772,8 +784,8 @@ static const SpaNode volume_node = {
spa_volume_node_port_set_format,
spa_volume_node_port_get_format,
spa_volume_node_port_get_info,
spa_volume_node_port_get_props,
spa_volume_node_port_set_props,
spa_volume_node_port_enum_params,
spa_volume_node_port_set_param,
spa_volume_node_port_use_buffers,
spa_volume_node_port_alloc_buffers,
spa_volume_node_port_set_io,

View file

@ -388,19 +388,20 @@ spa_xv_sink_node_port_get_info (SpaNode *node,
}
static SpaResult
spa_xv_sink_node_port_get_props (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
SpaProps **props)
spa_xv_sink_node_port_enum_params (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
uint32_t index,
SpaParam **param)
{
return SPA_RESULT_NOT_IMPLEMENTED;
}
static SpaResult
spa_xv_sink_node_port_set_props (SpaNode *node,
spa_xv_sink_node_port_set_param (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
const SpaProps *props)
const SpaParam *param)
{
return SPA_RESULT_NOT_IMPLEMENTED;
}
@ -419,7 +420,7 @@ static SpaResult
spa_xv_sink_node_port_alloc_buffers (SpaNode *node,
SpaDirection direction,
uint32_t port_id,
SpaAllocParam **params,
SpaParam **params,
uint32_t n_params,
SpaBuffer **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_get_format,
spa_xv_sink_node_port_get_info,
spa_xv_sink_node_port_get_props,
spa_xv_sink_node_port_set_props,
spa_xv_sink_node_port_enum_params,
spa_xv_sink_node_port_set_param,
spa_xv_sink_node_port_use_buffers,
spa_xv_sink_node_port_alloc_buffers,
spa_xv_sink_node_port_set_io,