mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-06 13:30:01 -05:00
Type changes
Only allow properties inside objects, this makes it easier to iterate the object, which is needed for efficiently processing control streams. Add a choice type to mark variable properties. SPA_TYPE_Enum -> SPA_TYPE_Id to avoid confusion with choice enum Make it easier to allocate and initialize properties on the stack Make more efficient methods to make objects.
This commit is contained in:
parent
03fdabd155
commit
cc842cbdc8
63 changed files with 2253 additions and 1880 deletions
|
|
@ -112,10 +112,13 @@ static void update_param(struct data *data)
|
|||
return;
|
||||
|
||||
spa_pod_builder_init(&b, data->io_notify, data->io_notify_size);
|
||||
spa_pod_builder_sequence(&b, 0,
|
||||
".", 0, SPA_CONTROL_Properties,
|
||||
SPA_POD_OBJECT(SPA_TYPE_OBJECT_Props, 0,
|
||||
":", SPA_PROP_contrast, "f", (sin(data->param_accum) * 127.0) + 127.0));
|
||||
spa_pod_builder_push_sequence(&b, 0);
|
||||
spa_pod_builder_control_header(&b, 0, SPA_CONTROL_Properties);
|
||||
spa_pod_builder_push_object(&b, SPA_TYPE_OBJECT_Props, 0);
|
||||
spa_pod_builder_prop(&b, SPA_PROP_contrast, 0);
|
||||
spa_pod_builder_float(&b, (sin(data->param_accum) * 127.0) + 127.0);
|
||||
spa_pod_builder_pop(&b);
|
||||
spa_pod_builder_pop(&b);
|
||||
|
||||
data->param_accum += M_PI_M2 / 30.0;
|
||||
if (data->param_accum >= M_PI_M2)
|
||||
|
|
@ -235,7 +238,8 @@ static int impl_port_enum_params(struct spa_node *node,
|
|||
if (*index < SPA_N_ELEMENTS(list))
|
||||
param = spa_pod_builder_object(builder,
|
||||
SPA_TYPE_OBJECT_ParamList, id,
|
||||
":", SPA_PARAM_LIST_id, "I", list[*index]);
|
||||
SPA_PARAM_LIST_id, &SPA_POD_Id(list[*index]),
|
||||
0);
|
||||
else
|
||||
return 0;
|
||||
break;
|
||||
|
|
@ -255,12 +259,12 @@ static int impl_port_enum_params(struct spa_node *node,
|
|||
|
||||
param = spa_pod_builder_object(builder,
|
||||
SPA_TYPE_OBJECT_ParamBuffers, id,
|
||||
":", SPA_PARAM_BUFFERS_buffers, "iru", 2,
|
||||
SPA_POD_PROP_MIN_MAX(2, MAX_BUFFERS),
|
||||
":", SPA_PARAM_BUFFERS_blocks, "i", 1,
|
||||
":", SPA_PARAM_BUFFERS_size, "i", d->stride * d->format.size.height,
|
||||
":", SPA_PARAM_BUFFERS_stride, "i", d->stride,
|
||||
":", SPA_PARAM_BUFFERS_align, "i", 16);
|
||||
SPA_PARAM_BUFFERS_buffers, &SPA_POD_CHOICE_RANGE_Int(2, 2, MAX_BUFFERS),
|
||||
SPA_PARAM_BUFFERS_blocks, &SPA_POD_Int(1),
|
||||
SPA_PARAM_BUFFERS_size, &SPA_POD_Int(d->stride * d->format.size.height),
|
||||
SPA_PARAM_BUFFERS_stride, &SPA_POD_Int(d->stride),
|
||||
SPA_PARAM_BUFFERS_align, &SPA_POD_Int(16),
|
||||
0);
|
||||
break;
|
||||
|
||||
case SPA_PARAM_Meta:
|
||||
|
|
@ -268,14 +272,16 @@ static int impl_port_enum_params(struct spa_node *node,
|
|||
case 0:
|
||||
param = spa_pod_builder_object(builder,
|
||||
SPA_TYPE_OBJECT_ParamMeta, id,
|
||||
":", SPA_PARAM_META_type, "I", SPA_META_Header,
|
||||
":", SPA_PARAM_META_size, "i", sizeof(struct spa_meta_header));
|
||||
SPA_PARAM_META_type, &SPA_POD_Id(SPA_META_Header),
|
||||
SPA_PARAM_META_size, &SPA_POD_Int(sizeof(struct spa_meta_header)),
|
||||
0);
|
||||
break;
|
||||
case 1:
|
||||
param = spa_pod_builder_object(builder,
|
||||
SPA_TYPE_OBJECT_ParamMeta, id,
|
||||
":", SPA_PARAM_META_type, "I", SPA_META_VideoDamage,
|
||||
":", SPA_PARAM_META_size, "i", sizeof(struct spa_meta_region));
|
||||
SPA_PARAM_META_type, &SPA_POD_Id(SPA_META_VideoDamage),
|
||||
SPA_PARAM_META_size, &SPA_POD_Int(sizeof(struct spa_meta_region)),
|
||||
0);
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
|
|
@ -287,14 +293,16 @@ static int impl_port_enum_params(struct spa_node *node,
|
|||
case 0:
|
||||
param = spa_pod_builder_object(builder,
|
||||
SPA_TYPE_OBJECT_ParamIO, id,
|
||||
":", SPA_PARAM_IO_id, "I", SPA_IO_Buffers,
|
||||
":", SPA_PARAM_IO_size, "i", sizeof(struct spa_io_buffers));
|
||||
SPA_PARAM_IO_id, &SPA_POD_Id(SPA_IO_Buffers),
|
||||
SPA_PARAM_IO_size, &SPA_POD_Int(sizeof(struct spa_io_buffers)),
|
||||
0);
|
||||
break;
|
||||
case 1:
|
||||
param = spa_pod_builder_object(builder,
|
||||
SPA_TYPE_OBJECT_ParamIO, id,
|
||||
":", SPA_PARAM_IO_id, "I", SPA_IO_Notify,
|
||||
":", SPA_PARAM_IO_size, "i", sizeof(struct spa_io_sequence) + 1024);
|
||||
SPA_PARAM_IO_id, &SPA_POD_Id(SPA_IO_Notify),
|
||||
SPA_PARAM_IO_size, &SPA_POD_Int(sizeof(struct spa_io_sequence) + 1024),
|
||||
0);
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -33,17 +33,6 @@
|
|||
|
||||
#define BUFFER_SAMPLES 128
|
||||
|
||||
#define DEFAULT_VOLUME 1.0
|
||||
|
||||
struct props {
|
||||
double volume;
|
||||
};
|
||||
|
||||
static void reset_props(struct props *props)
|
||||
{
|
||||
props->volume = DEFAULT_VOLUME;
|
||||
}
|
||||
|
||||
struct buffer {
|
||||
struct spa_buffer *buffer;
|
||||
struct spa_list link;
|
||||
|
|
@ -52,8 +41,6 @@ struct buffer {
|
|||
};
|
||||
|
||||
struct data {
|
||||
struct props props;
|
||||
|
||||
const char *path;
|
||||
|
||||
struct pw_main_loop *loop;
|
||||
|
|
@ -72,8 +59,8 @@ struct data {
|
|||
const struct spa_node_callbacks *callbacks;
|
||||
void *callbacks_data;
|
||||
struct spa_io_buffers *io;
|
||||
|
||||
struct spa_pod_double *ctrl_volume;
|
||||
struct spa_io_control *io_notify;
|
||||
uint32_t io_notify_size;
|
||||
|
||||
struct spa_audio_info_raw format;
|
||||
|
||||
|
|
@ -87,10 +74,20 @@ struct data {
|
|||
|
||||
static void update_volume(struct data *data)
|
||||
{
|
||||
if (data->ctrl_volume == NULL)
|
||||
struct spa_pod_builder b = { 0, };
|
||||
|
||||
if (data->io_notify == NULL)
|
||||
return;
|
||||
|
||||
data->ctrl_volume->value = (sin(data->volume_accum) / 2.0) + 0.5;
|
||||
spa_pod_builder_init(&b, data->io_notify, data->io_notify_size);
|
||||
spa_pod_builder_push_sequence(&b, 0);
|
||||
spa_pod_builder_control_header(&b, 0, SPA_CONTROL_Properties);
|
||||
spa_pod_builder_push_object(&b, SPA_TYPE_OBJECT_Props, 0);
|
||||
spa_pod_builder_prop(&b, SPA_PROP_volume, 0);
|
||||
spa_pod_builder_float(&b, (sin(data->volume_accum) / 2.0) + 0.5);
|
||||
spa_pod_builder_pop(&b);
|
||||
spa_pod_builder_pop(&b);
|
||||
|
||||
data->volume_accum += M_PI_M2 / 1000.0;
|
||||
if (data->volume_accum >= M_PI_M2)
|
||||
data->volume_accum -= M_PI_M2;
|
||||
|
|
@ -137,19 +134,17 @@ static int impl_port_set_io(struct spa_node *node, enum spa_direction direction,
|
|||
{
|
||||
struct data *d = SPA_CONTAINER_OF(node, struct data, impl_node);
|
||||
|
||||
if (id == SPA_IO_Buffers)
|
||||
switch (id) {
|
||||
case SPA_IO_Buffers:
|
||||
d->io = data;
|
||||
#if 0
|
||||
else if (id == type.io_prop_volume) {
|
||||
if (data && size >= sizeof(struct spa_pod_double))
|
||||
d->ctrl_volume = data;
|
||||
else
|
||||
d->ctrl_volume = NULL;
|
||||
}
|
||||
#endif
|
||||
else
|
||||
break;
|
||||
case SPA_IO_Notify:
|
||||
d->io_notify = data;
|
||||
d->io_notify_size = size;
|
||||
break;
|
||||
default:
|
||||
return -ENOENT;
|
||||
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -182,18 +177,19 @@ static int port_enum_formats(struct spa_node *node,
|
|||
|
||||
*param = spa_pod_builder_object(builder,
|
||||
SPA_TYPE_OBJECT_Format, SPA_PARAM_EnumFormat,
|
||||
":", SPA_FORMAT_mediaType, "I", SPA_MEDIA_TYPE_audio,
|
||||
":", SPA_FORMAT_mediaSubtype, "I", SPA_MEDIA_SUBTYPE_raw,
|
||||
":", SPA_FORMAT_AUDIO_format, "Ieu", SPA_AUDIO_FORMAT_S16,
|
||||
SPA_POD_PROP_ENUM(2, SPA_AUDIO_FORMAT_S16,
|
||||
SPA_AUDIO_FORMAT_F32),
|
||||
":", SPA_FORMAT_AUDIO_layout, "Ieu", SPA_AUDIO_LAYOUT_INTERLEAVED,
|
||||
SPA_POD_PROP_ENUM(2, SPA_AUDIO_LAYOUT_INTERLEAVED,
|
||||
SPA_AUDIO_LAYOUT_NON_INTERLEAVED),
|
||||
":", SPA_FORMAT_AUDIO_channels, "iru", 2,
|
||||
SPA_POD_PROP_MIN_MAX(1, INT32_MAX),
|
||||
":", SPA_FORMAT_AUDIO_rate, "iru", 44100,
|
||||
SPA_POD_PROP_MIN_MAX(1, INT32_MAX));
|
||||
SPA_FORMAT_mediaType, &SPA_POD_Id(SPA_MEDIA_TYPE_audio),
|
||||
SPA_FORMAT_mediaSubtype, &SPA_POD_Id(SPA_MEDIA_SUBTYPE_raw),
|
||||
SPA_FORMAT_AUDIO_format, &SPA_POD_CHOICE_ENUM_Id(3,
|
||||
SPA_AUDIO_FORMAT_S16,
|
||||
SPA_AUDIO_FORMAT_S16,
|
||||
SPA_AUDIO_FORMAT_F32),
|
||||
SPA_FORMAT_AUDIO_layout, &SPA_POD_CHOICE_ENUM_Id(3,
|
||||
SPA_AUDIO_LAYOUT_INTERLEAVED,
|
||||
SPA_AUDIO_LAYOUT_INTERLEAVED,
|
||||
SPA_AUDIO_LAYOUT_NON_INTERLEAVED),
|
||||
SPA_FORMAT_AUDIO_channels, &SPA_POD_CHOICE_RANGE_Int(2, 1, INT32_MAX),
|
||||
SPA_FORMAT_AUDIO_rate, &SPA_POD_CHOICE_RANGE_Int(44100, 1, INT32_MAX),
|
||||
0);
|
||||
|
||||
(*index)++;
|
||||
|
||||
|
|
@ -222,7 +218,8 @@ static int impl_port_enum_params(struct spa_node *node,
|
|||
if (*index < SPA_N_ELEMENTS(list))
|
||||
param = spa_pod_builder_object(builder,
|
||||
SPA_TYPE_OBJECT_ParamList, id,
|
||||
":", SPA_PARAM_LIST_id, "I", list[*index]);
|
||||
SPA_PARAM_LIST_id, &SPA_POD_Id(list[*index]),
|
||||
0);
|
||||
else
|
||||
return 0;
|
||||
break;
|
||||
|
|
@ -244,13 +241,12 @@ static int impl_port_enum_params(struct spa_node *node,
|
|||
|
||||
param = spa_pod_builder_object(builder,
|
||||
SPA_TYPE_OBJECT_ParamBuffers, id,
|
||||
":", SPA_PARAM_BUFFERS_buffers, "iru", 1,
|
||||
SPA_POD_PROP_MIN_MAX(1, 32),
|
||||
":", SPA_PARAM_BUFFERS_blocks, "i", 1,
|
||||
":", SPA_PARAM_BUFFERS_size, "iru", BUFFER_SAMPLES * sizeof(float),
|
||||
SPA_POD_PROP_MIN_MAX(32, 4096),
|
||||
":", SPA_PARAM_BUFFERS_stride, "i", 0,
|
||||
":", SPA_PARAM_BUFFERS_align, "i", 16);
|
||||
SPA_PARAM_BUFFERS_buffers, &SPA_POD_CHOICE_RANGE_Int(1, 1, 32),
|
||||
SPA_PARAM_BUFFERS_blocks, &SPA_POD_Int(1),
|
||||
SPA_PARAM_BUFFERS_size, &SPA_POD_CHOICE_RANGE_Int(BUFFER_SAMPLES * sizeof(float), 32, 4096),
|
||||
SPA_PARAM_BUFFERS_stride, &SPA_POD_Int(0),
|
||||
SPA_PARAM_BUFFERS_align, &SPA_POD_Int(16),
|
||||
0);
|
||||
break;
|
||||
|
||||
case SPA_PARAM_Meta:
|
||||
|
|
@ -258,8 +254,9 @@ static int impl_port_enum_params(struct spa_node *node,
|
|||
case 0:
|
||||
param = spa_pod_builder_object(builder,
|
||||
SPA_TYPE_OBJECT_ParamMeta, id,
|
||||
":", SPA_PARAM_META_type, "I", SPA_META_Header,
|
||||
":", SPA_PARAM_META_size, "i", sizeof(struct spa_meta_header));
|
||||
SPA_PARAM_META_type, &SPA_POD_Id(SPA_META_Header),
|
||||
SPA_PARAM_META_size, &SPA_POD_Int(sizeof(struct spa_meta_header)),
|
||||
0);
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
|
|
@ -270,32 +267,21 @@ static int impl_port_enum_params(struct spa_node *node,
|
|||
case 0:
|
||||
param = spa_pod_builder_object(builder,
|
||||
SPA_TYPE_OBJECT_ParamIO, id,
|
||||
":", SPA_PARAM_IO_id, "I", SPA_IO_Buffers,
|
||||
":", SPA_PARAM_IO_size, "i", sizeof(struct spa_io_buffers));
|
||||
SPA_PARAM_IO_id, &SPA_POD_Id(SPA_IO_Buffers),
|
||||
SPA_PARAM_IO_size, &SPA_POD_Int(sizeof(struct spa_io_buffers)),
|
||||
0);
|
||||
break;
|
||||
case 1:
|
||||
param = spa_pod_builder_object(builder,
|
||||
SPA_TYPE_OBJECT_ParamIO, id,
|
||||
SPA_PARAM_IO_id, &SPA_POD_Id(SPA_IO_Notify),
|
||||
SPA_PARAM_IO_size, &SPA_POD_Int(sizeof(struct spa_io_sequence) + 1024),
|
||||
0);
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
#if 0
|
||||
else if (id == t->param_io.idPropsOut) {
|
||||
struct props *p = &d->props;
|
||||
|
||||
switch (*index) {
|
||||
case 0:
|
||||
param = spa_pod_builder_object(builder,
|
||||
id, t->param_io.Prop,
|
||||
":", t->param_io.id, "I", d->type.io_prop_volume,
|
||||
":", t->param_io.size, "i", sizeof(struct spa_pod_double),
|
||||
":", t->param.propId, "I", d->type.prop_volume,
|
||||
":", t->param.propType, "dru", p->volume,
|
||||
SPA_POD_PROP_MIN_MAX(0.0, 10.0));
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
default:
|
||||
return -ENOENT;
|
||||
}
|
||||
|
|
@ -554,7 +540,6 @@ int main(int argc, char *argv[])
|
|||
data.path = argc > 1 ? argv[1] : NULL;
|
||||
|
||||
spa_list_init(&data.empty);
|
||||
reset_props(&data.props);
|
||||
|
||||
pw_remote_add_listener(data.remote, &data.remote_listener, &remote_events, &data);
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,11 @@
|
|||
#include <stdio.h>
|
||||
#include <sys/mman.h>
|
||||
|
||||
#include <SDL2/SDL.h>
|
||||
#define WIDTH 640
|
||||
#define HEIGHT 480
|
||||
#define BPP 3
|
||||
|
||||
#include "sdl.h"
|
||||
|
||||
#include <spa/param/video/format-utils.h>
|
||||
#include <spa/param/props.h>
|
||||
|
|
@ -31,10 +35,6 @@
|
|||
#include <pipewire/module.h>
|
||||
#include <pipewire/factory.h>
|
||||
|
||||
#define WIDTH 640
|
||||
#define HEIGHT 480
|
||||
#define BPP 3
|
||||
|
||||
struct data {
|
||||
SDL_Renderer *renderer;
|
||||
SDL_Window *window;
|
||||
|
|
@ -76,76 +76,6 @@ static void handle_events(struct data *data)
|
|||
}
|
||||
}
|
||||
|
||||
static struct {
|
||||
Uint32 format;
|
||||
uint32_t id;
|
||||
} video_formats[] = {
|
||||
{ SDL_PIXELFORMAT_UNKNOWN, SPA_VIDEO_FORMAT_UNKNOWN,},
|
||||
{ SDL_PIXELFORMAT_INDEX1LSB, SPA_VIDEO_FORMAT_UNKNOWN,},
|
||||
{ SDL_PIXELFORMAT_UNKNOWN, SPA_VIDEO_FORMAT_UNKNOWN,},
|
||||
{ SDL_PIXELFORMAT_INDEX1LSB, SPA_VIDEO_FORMAT_UNKNOWN,},
|
||||
{ SDL_PIXELFORMAT_INDEX1MSB, SPA_VIDEO_FORMAT_UNKNOWN,},
|
||||
{ SDL_PIXELFORMAT_INDEX4LSB, SPA_VIDEO_FORMAT_UNKNOWN,},
|
||||
{ SDL_PIXELFORMAT_INDEX4MSB, SPA_VIDEO_FORMAT_UNKNOWN,},
|
||||
{ SDL_PIXELFORMAT_INDEX8, SPA_VIDEO_FORMAT_UNKNOWN,},
|
||||
{ SDL_PIXELFORMAT_RGB332, SPA_VIDEO_FORMAT_UNKNOWN,},
|
||||
{ SDL_PIXELFORMAT_RGB444, SPA_VIDEO_FORMAT_UNKNOWN,},
|
||||
{ SDL_PIXELFORMAT_RGB555, SPA_VIDEO_FORMAT_UNKNOWN,},
|
||||
{ SDL_PIXELFORMAT_BGR555, SPA_VIDEO_FORMAT_UNKNOWN,},
|
||||
{ SDL_PIXELFORMAT_ARGB4444, SPA_VIDEO_FORMAT_UNKNOWN,},
|
||||
{ SDL_PIXELFORMAT_RGBA4444, SPA_VIDEO_FORMAT_UNKNOWN,},
|
||||
{ SDL_PIXELFORMAT_ABGR4444, SPA_VIDEO_FORMAT_UNKNOWN,},
|
||||
{ SDL_PIXELFORMAT_BGRA4444, SPA_VIDEO_FORMAT_UNKNOWN,},
|
||||
{ SDL_PIXELFORMAT_ARGB1555, SPA_VIDEO_FORMAT_UNKNOWN,},
|
||||
{ SDL_PIXELFORMAT_RGBA5551, SPA_VIDEO_FORMAT_UNKNOWN,},
|
||||
{ SDL_PIXELFORMAT_ABGR1555, SPA_VIDEO_FORMAT_UNKNOWN,},
|
||||
{ SDL_PIXELFORMAT_BGRA5551, SPA_VIDEO_FORMAT_UNKNOWN,},
|
||||
{ SDL_PIXELFORMAT_RGB565, SPA_VIDEO_FORMAT_UNKNOWN,},
|
||||
{ SDL_PIXELFORMAT_BGR565, SPA_VIDEO_FORMAT_UNKNOWN,},
|
||||
{ SDL_PIXELFORMAT_RGB24, SPA_VIDEO_FORMAT_RGB,},
|
||||
{ SDL_PIXELFORMAT_RGB888, SPA_VIDEO_FORMAT_RGB,},
|
||||
{ SDL_PIXELFORMAT_RGBX8888, SPA_VIDEO_FORMAT_RGBx,},
|
||||
{ SDL_PIXELFORMAT_BGR24, SPA_VIDEO_FORMAT_BGR,},
|
||||
{ SDL_PIXELFORMAT_BGR888, SPA_VIDEO_FORMAT_BGR,},
|
||||
{ SDL_PIXELFORMAT_BGRX8888, SPA_VIDEO_FORMAT_BGRx,},
|
||||
{ SDL_PIXELFORMAT_ARGB2101010, SPA_VIDEO_FORMAT_UNKNOWN,},
|
||||
{ SDL_PIXELFORMAT_RGBA8888, SPA_VIDEO_FORMAT_RGBA,},
|
||||
{ SDL_PIXELFORMAT_ARGB8888, SPA_VIDEO_FORMAT_ARGB,},
|
||||
{ SDL_PIXELFORMAT_BGRA8888, SPA_VIDEO_FORMAT_BGRA,},
|
||||
{ SDL_PIXELFORMAT_ABGR8888, SPA_VIDEO_FORMAT_ABGR,},
|
||||
{ SDL_PIXELFORMAT_YV12, SPA_VIDEO_FORMAT_YV12,},
|
||||
{ SDL_PIXELFORMAT_IYUV, SPA_VIDEO_FORMAT_I420,},
|
||||
{ SDL_PIXELFORMAT_YUY2, SPA_VIDEO_FORMAT_YUY2,},
|
||||
{ SDL_PIXELFORMAT_UYVY, SPA_VIDEO_FORMAT_UYVY,},
|
||||
{ SDL_PIXELFORMAT_YVYU, SPA_VIDEO_FORMAT_YVYU,},
|
||||
#if SDL_VERSION_ATLEAST(2,0,4)
|
||||
{ SDL_PIXELFORMAT_NV12, SPA_VIDEO_FORMAT_NV12,},
|
||||
{ SDL_PIXELFORMAT_NV21, SPA_VIDEO_FORMAT_NV21,},
|
||||
#endif
|
||||
};
|
||||
|
||||
static uint32_t sdl_format_to_id(struct data *data, Uint32 format)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < SPA_N_ELEMENTS(video_formats); i++) {
|
||||
if (video_formats[i].format == format)
|
||||
return video_formats[i].id;
|
||||
}
|
||||
return SPA_VIDEO_FORMAT_UNKNOWN;
|
||||
}
|
||||
|
||||
static Uint32 id_to_sdl_format(struct data *data, uint32_t id)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < SPA_N_ELEMENTS(video_formats); i++) {
|
||||
if (video_formats[i].id == id)
|
||||
return video_formats[i].format;
|
||||
}
|
||||
return SDL_PIXELFORMAT_UNKNOWN;
|
||||
}
|
||||
|
||||
static int impl_send_command(struct spa_node *node, const struct spa_command *command)
|
||||
{
|
||||
return 0;
|
||||
|
|
@ -218,50 +148,12 @@ static int port_enum_formats(struct spa_node *node,
|
|||
{
|
||||
struct data *d = SPA_CONTAINER_OF(node, struct data, impl_node);
|
||||
SDL_RendererInfo info;
|
||||
uint32_t i, c;
|
||||
|
||||
if (*index != 0)
|
||||
return 0;
|
||||
|
||||
SDL_GetRendererInfo(d->renderer, &info);
|
||||
|
||||
spa_pod_builder_push_object(builder, SPA_TYPE_OBJECT_Format, SPA_PARAM_EnumFormat);
|
||||
spa_pod_builder_push_prop(builder, SPA_FORMAT_mediaType, 0);
|
||||
spa_pod_builder_enum(builder, SPA_MEDIA_TYPE_video);
|
||||
spa_pod_builder_pop(builder);
|
||||
|
||||
spa_pod_builder_push_prop(builder, SPA_FORMAT_mediaSubtype, 0);
|
||||
spa_pod_builder_enum(builder, SPA_MEDIA_SUBTYPE_raw);
|
||||
spa_pod_builder_pop(builder);
|
||||
|
||||
spa_pod_builder_push_prop(builder, SPA_FORMAT_VIDEO_format,
|
||||
SPA_POD_PROP_FLAG_UNSET |
|
||||
SPA_POD_PROP_RANGE_ENUM);
|
||||
for (i = 0, c = 0; i < info.num_texture_formats; i++) {
|
||||
uint32_t id = sdl_format_to_id(d, info.texture_formats[i]);
|
||||
if (id == 0)
|
||||
continue;
|
||||
if (c++ == 0)
|
||||
spa_pod_builder_enum(builder, id);
|
||||
spa_pod_builder_enum(builder, id);
|
||||
}
|
||||
for (i = 0; i < SPA_N_ELEMENTS(video_formats); i++) {
|
||||
uint32_t id = video_formats[i].id;
|
||||
if (id != SPA_VIDEO_FORMAT_UNKNOWN)
|
||||
spa_pod_builder_enum(builder, id);
|
||||
}
|
||||
spa_pod_builder_pop(builder);
|
||||
|
||||
spa_pod_builder_add(builder,
|
||||
":", SPA_FORMAT_VIDEO_size, "Rru", &SPA_RECTANGLE(WIDTH, HEIGHT),
|
||||
SPA_POD_PROP_MIN_MAX(&SPA_RECTANGLE(1,1),
|
||||
&SPA_RECTANGLE(info.max_texture_width,
|
||||
info.max_texture_height)),
|
||||
":", SPA_FORMAT_VIDEO_framerate, "Fru", &SPA_FRACTION(25,1),
|
||||
SPA_POD_PROP_MIN_MAX(&SPA_FRACTION(0,1),
|
||||
&SPA_FRACTION(30,1)),
|
||||
NULL);
|
||||
*result = spa_pod_builder_pop(builder);
|
||||
*result = sdl_build_formats(&info, builder);
|
||||
|
||||
(*index)++;
|
||||
|
||||
|
|
@ -287,12 +179,12 @@ static int impl_port_enum_params(struct spa_node *node,
|
|||
|
||||
*result = spa_pod_builder_object(builder,
|
||||
SPA_TYPE_OBJECT_ParamBuffers, id,
|
||||
":", SPA_PARAM_BUFFERS_buffers, "iru", 2,
|
||||
SPA_POD_PROP_MIN_MAX(1, 32),
|
||||
":", SPA_PARAM_BUFFERS_blocks, "i", 1,
|
||||
":", SPA_PARAM_BUFFERS_size, "i", d->stride * d->format.size.height,
|
||||
":", SPA_PARAM_BUFFERS_stride, "i", d->stride,
|
||||
":", SPA_PARAM_BUFFERS_align, "i", 16);
|
||||
SPA_PARAM_BUFFERS_buffers, &SPA_POD_CHOICE_RANGE_Int(2, 1, 32),
|
||||
SPA_PARAM_BUFFERS_blocks, &SPA_POD_Int(1),
|
||||
SPA_PARAM_BUFFERS_size, &SPA_POD_Int(d->stride * d->format.size.height),
|
||||
SPA_PARAM_BUFFERS_stride, &SPA_POD_Int(d->stride),
|
||||
SPA_PARAM_BUFFERS_align, &SPA_POD_Int(16),
|
||||
0);
|
||||
break;
|
||||
|
||||
case SPA_PARAM_Meta:
|
||||
|
|
@ -301,8 +193,9 @@ static int impl_port_enum_params(struct spa_node *node,
|
|||
|
||||
*result = spa_pod_builder_object(builder,
|
||||
SPA_TYPE_OBJECT_ParamMeta, id,
|
||||
":", SPA_PARAM_META_type, "I", SPA_META_Header,
|
||||
":", SPA_PARAM_META_size, "i", sizeof(struct spa_meta_header));
|
||||
SPA_PARAM_META_type, &SPA_POD_Id(SPA_META_Header),
|
||||
SPA_PARAM_META_size, &SPA_POD_Int(sizeof(struct spa_meta_header)),
|
||||
0);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
@ -327,7 +220,7 @@ static int port_set_format(struct spa_node *node, enum spa_direction direction,
|
|||
|
||||
spa_format_video_raw_parse(format, &d->format);
|
||||
|
||||
sdl_format = id_to_sdl_format(d, d->format.format);
|
||||
sdl_format = id_to_sdl_format(d->format.format);
|
||||
if (sdl_format == SDL_PIXELFORMAT_UNKNOWN)
|
||||
return -EINVAL;
|
||||
|
||||
|
|
|
|||
|
|
@ -98,38 +98,37 @@ static struct spa_pod *sdl_build_formats(SDL_RendererInfo *info, struct spa_pod_
|
|||
int i, c;
|
||||
|
||||
spa_pod_builder_push_object(b, SPA_TYPE_OBJECT_Format, SPA_PARAM_EnumFormat);
|
||||
spa_pod_builder_push_prop(b, SPA_FORMAT_mediaType, 0);
|
||||
spa_pod_builder_enum(b, SPA_MEDIA_TYPE_video);
|
||||
spa_pod_builder_pop(b);
|
||||
spa_pod_builder_push_prop(b, SPA_FORMAT_mediaSubtype, 0);
|
||||
spa_pod_builder_enum(b, SPA_MEDIA_SUBTYPE_raw);
|
||||
spa_pod_builder_pop(b);
|
||||
spa_pod_builder_prop(b, SPA_FORMAT_mediaType, 0);
|
||||
spa_pod_builder_id(b, SPA_MEDIA_TYPE_video);
|
||||
spa_pod_builder_prop(b, SPA_FORMAT_mediaSubtype, 0);
|
||||
spa_pod_builder_id(b, SPA_MEDIA_SUBTYPE_raw);
|
||||
|
||||
spa_pod_builder_push_prop(b, SPA_FORMAT_VIDEO_format,
|
||||
SPA_POD_PROP_FLAG_UNSET |
|
||||
SPA_POD_PROP_RANGE_ENUM);
|
||||
spa_pod_builder_prop(b, SPA_FORMAT_VIDEO_format, 0);
|
||||
spa_pod_builder_push_choice(b, SPA_CHOICE_Enum, 0);
|
||||
for (i = 0, c = 0; i < info->num_texture_formats; i++) {
|
||||
uint32_t id = sdl_format_to_id(info->texture_formats[i]);
|
||||
if (id == 0)
|
||||
continue;
|
||||
if (c++ == 0)
|
||||
spa_pod_builder_enum(b, id);
|
||||
spa_pod_builder_enum(b, id);
|
||||
spa_pod_builder_id(b, id);
|
||||
spa_pod_builder_id(b, id);
|
||||
}
|
||||
for (i = 0; i < SPA_N_ELEMENTS(sdl_video_formats); i++) {
|
||||
uint32_t id = sdl_video_formats[i].id;
|
||||
if (id != SPA_VIDEO_FORMAT_UNKNOWN)
|
||||
spa_pod_builder_enum(b, id);
|
||||
spa_pod_builder_id(b, id);
|
||||
}
|
||||
spa_pod_builder_pop(b);
|
||||
spa_pod_builder_add(b,
|
||||
":", SPA_FORMAT_VIDEO_size, "Rru", &SPA_RECTANGLE(WIDTH, HEIGHT),
|
||||
SPA_POD_PROP_MIN_MAX(&SPA_RECTANGLE(1,1),
|
||||
&SPA_RECTANGLE(info->max_texture_width,
|
||||
info->max_texture_height)),
|
||||
":", SPA_FORMAT_VIDEO_framerate, "Fru", &SPA_FRACTION(25,1),
|
||||
SPA_POD_PROP_MIN_MAX(&SPA_FRACTION(0,1),
|
||||
&SPA_FRACTION(30,1)),
|
||||
NULL);
|
||||
spa_pod_builder_props(b,
|
||||
SPA_FORMAT_VIDEO_size, &SPA_POD_CHOICE_RANGE_Rectangle(
|
||||
SPA_RECTANGLE(WIDTH, HEIGHT),
|
||||
SPA_RECTANGLE(1,1),
|
||||
SPA_RECTANGLE(info->max_texture_width,
|
||||
info->max_texture_height)),
|
||||
SPA_FORMAT_VIDEO_framerate, &SPA_POD_CHOICE_RANGE_Fraction(
|
||||
SPA_FRACTION(25,1),
|
||||
SPA_FRACTION(0,1),
|
||||
SPA_FRACTION(30,1)),
|
||||
0);
|
||||
return spa_pod_builder_pop(b);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -170,17 +170,18 @@ on_stream_format_changed(void *_data, const struct spa_pod *format)
|
|||
|
||||
params[0] = spa_pod_builder_object(&b,
|
||||
SPA_TYPE_OBJECT_ParamBuffers, SPA_PARAM_Buffers,
|
||||
":", SPA_PARAM_BUFFERS_buffers, "iru", 8,
|
||||
SPA_POD_PROP_MIN_MAX(2, 16),
|
||||
":", SPA_PARAM_BUFFERS_blocks, "i", 1,
|
||||
":", SPA_PARAM_BUFFERS_size, "i", data->stride * data->format.size.height,
|
||||
":", SPA_PARAM_BUFFERS_stride, "i", data->stride,
|
||||
":", SPA_PARAM_BUFFERS_align, "i", 16);
|
||||
SPA_PARAM_BUFFERS_buffers, &SPA_POD_CHOICE_RANGE_Int(8, 2, 16),
|
||||
SPA_PARAM_BUFFERS_blocks, &SPA_POD_Int(1),
|
||||
SPA_PARAM_BUFFERS_size, &SPA_POD_Int(data->stride * data->format.size.height),
|
||||
SPA_PARAM_BUFFERS_stride, &SPA_POD_Int(data->stride),
|
||||
SPA_PARAM_BUFFERS_align, &SPA_POD_Int(16),
|
||||
0);
|
||||
|
||||
params[1] = spa_pod_builder_object(&b,
|
||||
SPA_TYPE_OBJECT_ParamMeta, SPA_PARAM_Meta,
|
||||
":", SPA_PARAM_META_type, "I", SPA_META_Header,
|
||||
":", SPA_PARAM_META_size, "i", sizeof(struct spa_meta_header));
|
||||
SPA_PARAM_META_type, &SPA_POD_Id(SPA_META_Header),
|
||||
SPA_PARAM_META_size, &SPA_POD_Int(sizeof(struct spa_meta_header)),
|
||||
0);
|
||||
|
||||
pw_stream_finish_format(stream, 0, params, 2);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -169,24 +169,27 @@ on_stream_format_changed(void *_data, const struct spa_pod *format)
|
|||
|
||||
params[0] = spa_pod_builder_object(&b,
|
||||
SPA_TYPE_OBJECT_ParamBuffers, SPA_PARAM_Buffers,
|
||||
":", SPA_PARAM_BUFFERS_buffers, "iru", 2,
|
||||
SPA_POD_PROP_MIN_MAX(1, 32),
|
||||
":", SPA_PARAM_BUFFERS_blocks, "i", 1,
|
||||
":", SPA_PARAM_BUFFERS_size, "i", data->stride * data->format.size.height,
|
||||
":", SPA_PARAM_BUFFERS_stride, "i", data->stride,
|
||||
":", SPA_PARAM_BUFFERS_align, "i", 16);
|
||||
SPA_PARAM_BUFFERS_buffers, &SPA_POD_CHOICE_RANGE_Int(2, 1, 32),
|
||||
SPA_PARAM_BUFFERS_blocks, &SPA_POD_Int(1),
|
||||
SPA_PARAM_BUFFERS_size, &SPA_POD_Int(data->stride * data->format.size.height),
|
||||
SPA_PARAM_BUFFERS_stride, &SPA_POD_Int(data->stride),
|
||||
SPA_PARAM_BUFFERS_align, &SPA_POD_Int(16),
|
||||
0);
|
||||
|
||||
params[1] = spa_pod_builder_object(&b,
|
||||
SPA_TYPE_OBJECT_ParamMeta, SPA_PARAM_Meta,
|
||||
":", SPA_PARAM_META_type, "I", SPA_META_Header,
|
||||
":", SPA_PARAM_META_size, "i", sizeof(struct spa_meta_header));
|
||||
SPA_PARAM_META_type, &SPA_POD_Id(SPA_META_Header),
|
||||
SPA_PARAM_META_size, &SPA_POD_Int(sizeof(struct spa_meta_header)),
|
||||
0);
|
||||
|
||||
params[2] = spa_pod_builder_object(&b,
|
||||
SPA_TYPE_OBJECT_ParamMeta, SPA_PARAM_Meta,
|
||||
":", SPA_PARAM_META_type, "I", SPA_META_VideoDamage,
|
||||
":", SPA_PARAM_META_size, "iru", sizeof(struct spa_meta_region) * 16,
|
||||
SPA_POD_PROP_MIN_MAX(sizeof(struct spa_meta_region) * 1,
|
||||
sizeof(struct spa_meta_region) * 16));
|
||||
SPA_PARAM_META_type, &SPA_POD_Id(SPA_META_VideoDamage),
|
||||
SPA_PARAM_META_size, &SPA_POD_CHOICE_RANGE_Int(
|
||||
sizeof(struct spa_meta_region) * 16,
|
||||
sizeof(struct spa_meta_region) * 1,
|
||||
sizeof(struct spa_meta_region) * 16),
|
||||
0);
|
||||
|
||||
pw_stream_finish_format(stream, 0, params, 3);
|
||||
}
|
||||
|
|
@ -224,13 +227,15 @@ static void on_state_changed(void *_data, enum pw_remote_state old, enum pw_remo
|
|||
|
||||
params[0] = spa_pod_builder_object(&b,
|
||||
SPA_TYPE_OBJECT_Format, SPA_PARAM_EnumFormat,
|
||||
":", SPA_FORMAT_mediaType, "I", SPA_MEDIA_TYPE_video,
|
||||
":", SPA_FORMAT_mediaSubtype, "I", SPA_MEDIA_SUBTYPE_raw,
|
||||
":", SPA_FORMAT_VIDEO_format, "I", SPA_VIDEO_FORMAT_RGB,
|
||||
":", SPA_FORMAT_VIDEO_size, "Rru", &SPA_RECTANGLE(320, 240),
|
||||
SPA_POD_PROP_MIN_MAX(&SPA_RECTANGLE(1, 1),
|
||||
&SPA_RECTANGLE(4096, 4096)),
|
||||
":", SPA_FORMAT_VIDEO_framerate, "F", &SPA_FRACTION(25, 1));
|
||||
SPA_FORMAT_mediaType, &SPA_POD_Id(SPA_MEDIA_TYPE_video),
|
||||
SPA_FORMAT_mediaSubtype, &SPA_POD_Id(SPA_MEDIA_SUBTYPE_raw),
|
||||
SPA_FORMAT_VIDEO_format, &SPA_POD_Id(SPA_VIDEO_FORMAT_RGB),
|
||||
SPA_FORMAT_VIDEO_size, &SPA_POD_CHOICE_RANGE_Rectangle(
|
||||
SPA_RECTANGLE(320, 240),
|
||||
SPA_RECTANGLE(1, 1),
|
||||
SPA_RECTANGLE(4096, 4096)),
|
||||
SPA_FORMAT_VIDEO_framerate, &SPA_POD_Fraction(SPA_FRACTION(25, 1)),
|
||||
0);
|
||||
|
||||
pw_stream_add_listener(data->stream,
|
||||
&data->stream_listener,
|
||||
|
|
|
|||
|
|
@ -317,22 +317,22 @@ get_range_type (const GValue *val)
|
|||
GType type = G_VALUE_TYPE (val);
|
||||
|
||||
if (type == GST_TYPE_LIST)
|
||||
return SPA_POD_PROP_RANGE_ENUM;
|
||||
return SPA_CHOICE_Enum;
|
||||
if (type == GST_TYPE_DOUBLE_RANGE || type == GST_TYPE_FRACTION_RANGE)
|
||||
return SPA_POD_PROP_RANGE_MIN_MAX;
|
||||
return SPA_CHOICE_Range;
|
||||
if (type == GST_TYPE_INT_RANGE) {
|
||||
if (gst_value_get_int_range_step (val) == 1)
|
||||
return SPA_POD_PROP_RANGE_MIN_MAX;
|
||||
return SPA_CHOICE_Range;
|
||||
else
|
||||
return SPA_POD_PROP_RANGE_STEP;
|
||||
return SPA_CHOICE_Step;
|
||||
}
|
||||
if (type == GST_TYPE_INT64_RANGE) {
|
||||
if (gst_value_get_int64_range_step (val) == 1)
|
||||
return SPA_POD_PROP_RANGE_MIN_MAX;
|
||||
return SPA_CHOICE_Range;
|
||||
else
|
||||
return SPA_POD_PROP_RANGE_STEP;
|
||||
return SPA_CHOICE_Step;
|
||||
}
|
||||
return SPA_POD_PROP_RANGE_NONE;
|
||||
return SPA_CHOICE_None;
|
||||
}
|
||||
|
||||
static const uint32_t
|
||||
|
|
@ -345,11 +345,11 @@ get_range_type2 (const GValue *v1, const GValue *v2)
|
|||
|
||||
if (r1 == r2)
|
||||
return r1;
|
||||
if (r1 == SPA_POD_PROP_RANGE_STEP || r2 == SPA_POD_PROP_RANGE_STEP)
|
||||
return SPA_POD_PROP_RANGE_STEP;
|
||||
if (r1 == SPA_POD_PROP_RANGE_MIN_MAX || r2 == SPA_POD_PROP_RANGE_MIN_MAX)
|
||||
return SPA_POD_PROP_RANGE_MIN_MAX;
|
||||
return SPA_POD_PROP_RANGE_MIN_MAX;
|
||||
if (r1 == SPA_CHOICE_Step || r2 == SPA_CHOICE_Step)
|
||||
return SPA_CHOICE_Step;
|
||||
if (r1 == SPA_CHOICE_Range || r2 == SPA_CHOICE_Range)
|
||||
return SPA_CHOICE_Range;
|
||||
return SPA_CHOICE_Range;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
|
@ -357,73 +357,73 @@ handle_video_fields (ConvertData *d)
|
|||
{
|
||||
const GValue *value, *value2;
|
||||
int i;
|
||||
struct spa_pod_prop *prop;
|
||||
struct spa_pod_choice *choice;
|
||||
|
||||
value = gst_structure_get_value (d->cs, "format");
|
||||
if (value) {
|
||||
const char *v;
|
||||
int idx;
|
||||
for (i = 0; (v = get_nth_string (value, i)); i++) {
|
||||
if (i == 0)
|
||||
spa_pod_builder_push_prop (&d->b,
|
||||
SPA_FORMAT_VIDEO_format,
|
||||
get_range_type (value));
|
||||
if (i == 0) {
|
||||
spa_pod_builder_prop (&d->b, SPA_FORMAT_VIDEO_format, 0);
|
||||
spa_pod_builder_push_choice(&d->b, get_range_type (value), 0);
|
||||
}
|
||||
|
||||
idx = gst_video_format_from_string (v);
|
||||
if (idx < SPA_N_ELEMENTS (video_format_map))
|
||||
spa_pod_builder_enum (&d->b, video_format_map[idx]);
|
||||
spa_pod_builder_id (&d->b, video_format_map[idx]);
|
||||
}
|
||||
prop = spa_pod_builder_pop(&d->b);
|
||||
if (i > 1)
|
||||
prop->body.flags |= SPA_POD_PROP_FLAG_UNSET;
|
||||
choice = spa_pod_builder_pop(&d->b);
|
||||
if (i <= 1)
|
||||
choice->body.type = SPA_CHOICE_None;
|
||||
}
|
||||
value = gst_structure_get_value (d->cs, "width");
|
||||
value2 = gst_structure_get_value (d->cs, "height");
|
||||
if (value || value2) {
|
||||
struct spa_rectangle v;
|
||||
for (i = 0; get_nth_rectangle (value, value2, i, &v); i++) {
|
||||
if (i == 0)
|
||||
spa_pod_builder_push_prop (&d->b,
|
||||
SPA_FORMAT_VIDEO_size,
|
||||
get_range_type2 (value, value2));
|
||||
if (i == 0) {
|
||||
spa_pod_builder_prop (&d->b, SPA_FORMAT_VIDEO_size, 0);
|
||||
spa_pod_builder_push_choice(&d->b, get_range_type2 (value, value2), 0);
|
||||
}
|
||||
|
||||
spa_pod_builder_rectangle (&d->b, v.width, v.height);
|
||||
}
|
||||
prop = spa_pod_builder_pop(&d->b);
|
||||
if (i > 1)
|
||||
prop->body.flags |= SPA_POD_PROP_FLAG_UNSET;
|
||||
choice = spa_pod_builder_pop(&d->b);
|
||||
if (i <= 1)
|
||||
choice->body.type = SPA_CHOICE_None;
|
||||
}
|
||||
|
||||
value = gst_structure_get_value (d->cs, "framerate");
|
||||
if (value) {
|
||||
struct spa_fraction v;
|
||||
for (i = 0; get_nth_fraction (value, i, &v); i++) {
|
||||
if (i == 0)
|
||||
spa_pod_builder_push_prop (&d->b,
|
||||
SPA_FORMAT_VIDEO_framerate,
|
||||
get_range_type (value));
|
||||
if (i == 0) {
|
||||
spa_pod_builder_prop (&d->b, SPA_FORMAT_VIDEO_framerate, 0);
|
||||
spa_pod_builder_push_choice(&d->b, get_range_type (value), 0);
|
||||
}
|
||||
|
||||
spa_pod_builder_fraction (&d->b, v.num, v.denom);
|
||||
}
|
||||
prop = spa_pod_builder_pop(&d->b);
|
||||
if (i > 1)
|
||||
prop->body.flags |= SPA_POD_PROP_FLAG_UNSET;
|
||||
choice = spa_pod_builder_pop(&d->b);
|
||||
if (i <= 1)
|
||||
choice->body.type = SPA_CHOICE_None;
|
||||
}
|
||||
|
||||
value = gst_structure_get_value (d->cs, "max-framerate");
|
||||
if (value) {
|
||||
struct spa_fraction v;
|
||||
for (i = 0; get_nth_fraction (value, i, &v); i++) {
|
||||
if (i == 0)
|
||||
spa_pod_builder_push_prop (&d->b,
|
||||
SPA_FORMAT_VIDEO_maxFramerate,
|
||||
get_range_type (value));
|
||||
if (i == 0) {
|
||||
spa_pod_builder_prop (&d->b, SPA_FORMAT_VIDEO_maxFramerate, 0);
|
||||
spa_pod_builder_push_choice(&d->b, get_range_type (value), 0);
|
||||
}
|
||||
|
||||
spa_pod_builder_fraction (&d->b, v.num, v.denom);
|
||||
}
|
||||
prop = spa_pod_builder_pop(&d->b);
|
||||
if (i > 1)
|
||||
prop->body.flags |= SPA_POD_PROP_FLAG_UNSET;
|
||||
choice = spa_pod_builder_pop(&d->b);
|
||||
if (i <= 1)
|
||||
choice->body.type = SPA_CHOICE_None;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
|
@ -432,7 +432,7 @@ static gboolean
|
|||
handle_audio_fields (ConvertData *d)
|
||||
{
|
||||
const GValue *value;
|
||||
struct spa_pod_prop *prop;
|
||||
struct spa_pod_choice *choice;
|
||||
int i = 0;
|
||||
|
||||
value = gst_structure_get_value (d->cs, "format");
|
||||
|
|
@ -440,18 +440,18 @@ handle_audio_fields (ConvertData *d)
|
|||
const char *v;
|
||||
int idx;
|
||||
for (i = 0; (v = get_nth_string (value, i)); i++) {
|
||||
if (i == 0)
|
||||
spa_pod_builder_push_prop (&d->b,
|
||||
SPA_FORMAT_AUDIO_format,
|
||||
get_range_type (value));
|
||||
if (i == 0) {
|
||||
spa_pod_builder_prop (&d->b, SPA_FORMAT_AUDIO_format, 0);
|
||||
spa_pod_builder_push_choice(&d->b, get_range_type (value), 0);
|
||||
}
|
||||
|
||||
idx = gst_audio_format_from_string (v);
|
||||
if (idx < SPA_N_ELEMENTS (audio_format_map))
|
||||
spa_pod_builder_enum (&d->b, audio_format_map[idx]);
|
||||
spa_pod_builder_id (&d->b, audio_format_map[idx]);
|
||||
}
|
||||
prop = spa_pod_builder_pop(&d->b);
|
||||
if (i > 1)
|
||||
prop->body.flags |= SPA_POD_PROP_FLAG_UNSET;
|
||||
choice = spa_pod_builder_pop(&d->b);
|
||||
if (i <= 1)
|
||||
choice->body.type = SPA_CHOICE_None;
|
||||
}
|
||||
|
||||
value = gst_structure_get_value (d->cs, "layout");
|
||||
|
|
@ -467,46 +467,46 @@ handle_audio_fields (ConvertData *d)
|
|||
else
|
||||
break;
|
||||
|
||||
if (i == 0)
|
||||
spa_pod_builder_push_prop (&d->b,
|
||||
SPA_FORMAT_AUDIO_layout,
|
||||
get_range_type (value));
|
||||
if (i == 0) {
|
||||
spa_pod_builder_prop (&d->b, SPA_FORMAT_AUDIO_layout, 0);
|
||||
spa_pod_builder_push_choice(&d->b, get_range_type (value), 0);
|
||||
}
|
||||
|
||||
spa_pod_builder_enum (&d->b, layout);
|
||||
spa_pod_builder_id (&d->b, layout);
|
||||
}
|
||||
prop = spa_pod_builder_pop(&d->b);
|
||||
if (i > 1)
|
||||
prop->body.flags |= SPA_POD_PROP_FLAG_UNSET;
|
||||
choice = spa_pod_builder_pop(&d->b);
|
||||
if (i <= 1)
|
||||
choice->body.type = SPA_CHOICE_None;
|
||||
}
|
||||
value = gst_structure_get_value (d->cs, "rate");
|
||||
if (value) {
|
||||
int v;
|
||||
for (i = 0; get_nth_int (value, i, &v); i++) {
|
||||
if (i == 0)
|
||||
spa_pod_builder_push_prop (&d->b,
|
||||
SPA_FORMAT_AUDIO_rate,
|
||||
get_range_type (value));
|
||||
if (i == 0) {
|
||||
spa_pod_builder_prop (&d->b, SPA_FORMAT_AUDIO_rate, 0);
|
||||
spa_pod_builder_push_choice(&d->b, get_range_type (value), 0);
|
||||
}
|
||||
|
||||
spa_pod_builder_int (&d->b, v);
|
||||
}
|
||||
prop = spa_pod_builder_pop(&d->b);
|
||||
if (i > 1)
|
||||
prop->body.flags |= SPA_POD_PROP_FLAG_UNSET;
|
||||
choice = spa_pod_builder_pop(&d->b);
|
||||
if (i <= 1)
|
||||
choice->body.type = SPA_CHOICE_None;
|
||||
}
|
||||
value = gst_structure_get_value (d->cs, "channels");
|
||||
if (value) {
|
||||
int v;
|
||||
for (i = 0; get_nth_int (value, i, &v); i++) {
|
||||
if (i == 0)
|
||||
spa_pod_builder_push_prop (&d->b,
|
||||
SPA_FORMAT_AUDIO_channels,
|
||||
get_range_type (value));
|
||||
if (i == 0) {
|
||||
spa_pod_builder_prop (&d->b, SPA_FORMAT_AUDIO_channels, 0);
|
||||
spa_pod_builder_push_choice(&d->b, get_range_type (value), 0);
|
||||
}
|
||||
|
||||
spa_pod_builder_int (&d->b, v);
|
||||
}
|
||||
prop = spa_pod_builder_pop(&d->b);
|
||||
if (i > 1)
|
||||
prop->body.flags |= SPA_POD_PROP_FLAG_UNSET;
|
||||
choice = spa_pod_builder_pop(&d->b);
|
||||
if (i <= 1)
|
||||
choice->body.type = SPA_CHOICE_None;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
|
@ -536,13 +536,11 @@ convert_1 (ConvertData *d)
|
|||
|
||||
spa_pod_builder_push_object (&d->b, SPA_TYPE_OBJECT_Format, d->id);
|
||||
|
||||
spa_pod_builder_push_prop (&d->b, SPA_FORMAT_mediaType, 0);
|
||||
spa_pod_builder_enum(&d->b, d->type->media_type);
|
||||
spa_pod_builder_pop (&d->b);
|
||||
spa_pod_builder_prop (&d->b, SPA_FORMAT_mediaType, 0);
|
||||
spa_pod_builder_id(&d->b, d->type->media_type);
|
||||
|
||||
spa_pod_builder_push_prop (&d->b, SPA_FORMAT_mediaSubtype, 0);
|
||||
spa_pod_builder_enum(&d->b, d->type->media_subtype);
|
||||
spa_pod_builder_pop (&d->b);
|
||||
spa_pod_builder_prop (&d->b, SPA_FORMAT_mediaSubtype, 0);
|
||||
spa_pod_builder_id(&d->b, d->type->media_subtype);
|
||||
|
||||
if (d->type->media_type == SPA_MEDIA_TYPE_video)
|
||||
handle_video_fields (d);
|
||||
|
|
@ -627,21 +625,23 @@ static void
|
|||
handle_id_prop (struct spa_pod_prop *prop, const char *key, id_to_string_func func, GstCaps *res)
|
||||
{
|
||||
const char * str;
|
||||
uint32_t *id = SPA_POD_CONTENTS (struct spa_pod_prop, prop);
|
||||
uint32_t i, n_items = SPA_POD_PROP_N_VALUES (prop);
|
||||
uint32_t flags;
|
||||
struct spa_pod *val;
|
||||
uint32_t *id;
|
||||
uint32_t i, n_items, choice;
|
||||
|
||||
flags = prop->body.flags;
|
||||
if (!(flags & SPA_POD_PROP_FLAG_UNSET))
|
||||
flags &= ~SPA_POD_PROP_RANGE_MASK;
|
||||
val = spa_pod_get_values(&prop->value, &n_items, &choice);
|
||||
if (val->type != SPA_TYPE_Id)
|
||||
return;
|
||||
|
||||
switch (flags & SPA_POD_PROP_RANGE_MASK) {
|
||||
case SPA_POD_PROP_RANGE_NONE:
|
||||
id = SPA_POD_BODY(val);
|
||||
|
||||
switch (choice) {
|
||||
case SPA_CHOICE_None:
|
||||
if (!(str = func(id[0])))
|
||||
return;
|
||||
gst_caps_set_simple (res, key, G_TYPE_STRING, rindex (str, ':') + 1, NULL);
|
||||
break;
|
||||
case SPA_POD_PROP_RANGE_ENUM:
|
||||
case SPA_CHOICE_Enum:
|
||||
{
|
||||
GValue list = { 0 }, v = { 0 };
|
||||
|
||||
|
|
@ -666,34 +666,36 @@ handle_id_prop (struct spa_pod_prop *prop, const char *key, id_to_string_func fu
|
|||
static void
|
||||
handle_int_prop (struct spa_pod_prop *prop, const char *key, GstCaps *res)
|
||||
{
|
||||
uint32_t *val = SPA_POD_CONTENTS (struct spa_pod_prop, prop);
|
||||
uint32_t i, n_items = SPA_POD_PROP_N_VALUES (prop);
|
||||
uint32_t flags;
|
||||
struct spa_pod *val;
|
||||
uint32_t *ints;
|
||||
uint32_t i, n_items, choice;
|
||||
|
||||
flags = prop->body.flags;
|
||||
if (!(flags & SPA_POD_PROP_FLAG_UNSET))
|
||||
flags &= ~SPA_POD_PROP_RANGE_MASK;
|
||||
val = spa_pod_get_values(&prop->value, &n_items, &choice);
|
||||
if (val->type != SPA_TYPE_Int)
|
||||
return;
|
||||
|
||||
switch (flags & SPA_POD_PROP_RANGE_MASK) {
|
||||
case SPA_POD_PROP_RANGE_NONE:
|
||||
gst_caps_set_simple (res, key, G_TYPE_INT, val[0], NULL);
|
||||
ints = SPA_POD_BODY(val);
|
||||
|
||||
switch (choice) {
|
||||
case SPA_CHOICE_None:
|
||||
gst_caps_set_simple (res, key, G_TYPE_INT, ints[0], NULL);
|
||||
break;
|
||||
case SPA_POD_PROP_RANGE_MIN_MAX:
|
||||
case SPA_POD_PROP_RANGE_STEP:
|
||||
case SPA_CHOICE_Range:
|
||||
case SPA_CHOICE_Step:
|
||||
{
|
||||
if (n_items < 3)
|
||||
return;
|
||||
gst_caps_set_simple (res, key, GST_TYPE_INT_RANGE, val[1], val[2], NULL);
|
||||
gst_caps_set_simple (res, key, GST_TYPE_INT_RANGE, ints[1], ints[2], NULL);
|
||||
break;
|
||||
}
|
||||
case SPA_POD_PROP_RANGE_ENUM:
|
||||
case SPA_CHOICE_Enum:
|
||||
{
|
||||
GValue list = { 0 }, v = { 0 };
|
||||
|
||||
g_value_init (&list, GST_TYPE_LIST);
|
||||
for (i = 1; i < n_items; i++) {
|
||||
g_value_init (&v, G_TYPE_INT);
|
||||
g_value_set_int (&v, val[i]);
|
||||
g_value_set_int (&v, ints[i]);
|
||||
gst_value_list_append_and_take_value (&list, &v);
|
||||
}
|
||||
gst_caps_set_value (res, key, &list);
|
||||
|
|
@ -708,21 +710,23 @@ handle_int_prop (struct spa_pod_prop *prop, const char *key, GstCaps *res)
|
|||
static void
|
||||
handle_rect_prop (struct spa_pod_prop *prop, const char *width, const char *height, GstCaps *res)
|
||||
{
|
||||
struct spa_rectangle *rect = SPA_POD_CONTENTS (struct spa_pod_prop, prop);
|
||||
uint32_t i, n_items = SPA_POD_PROP_N_VALUES (prop);
|
||||
uint32_t flags;
|
||||
struct spa_pod *val;
|
||||
struct spa_rectangle *rect;
|
||||
uint32_t i, n_items, choice;
|
||||
|
||||
flags = prop->body.flags;
|
||||
if (!(flags & SPA_POD_PROP_FLAG_UNSET))
|
||||
flags &= ~SPA_POD_PROP_RANGE_MASK;
|
||||
val = spa_pod_get_values(&prop->value, &n_items, &choice);
|
||||
if (val->type != SPA_TYPE_Rectangle)
|
||||
return;
|
||||
|
||||
switch (flags & SPA_POD_PROP_RANGE_MASK) {
|
||||
case SPA_POD_PROP_RANGE_NONE:
|
||||
rect = SPA_POD_BODY(val);
|
||||
|
||||
switch (choice) {
|
||||
case SPA_CHOICE_None:
|
||||
gst_caps_set_simple (res, width, G_TYPE_INT, rect[0].width,
|
||||
height, G_TYPE_INT, rect[0].height, NULL);
|
||||
break;
|
||||
case SPA_POD_PROP_RANGE_MIN_MAX:
|
||||
case SPA_POD_PROP_RANGE_STEP:
|
||||
case SPA_CHOICE_Range:
|
||||
case SPA_CHOICE_Step:
|
||||
{
|
||||
if (n_items < 3)
|
||||
return;
|
||||
|
|
@ -730,7 +734,7 @@ handle_rect_prop (struct spa_pod_prop *prop, const char *width, const char *heig
|
|||
height, GST_TYPE_INT_RANGE, rect[1].height, rect[2].height, NULL);
|
||||
break;
|
||||
}
|
||||
case SPA_POD_PROP_RANGE_ENUM:
|
||||
case SPA_CHOICE_Enum:
|
||||
{
|
||||
GValue l1 = { 0 }, l2 = { 0 }, v1 = { 0 }, v2 = { 0 };
|
||||
|
||||
|
|
@ -759,20 +763,22 @@ handle_rect_prop (struct spa_pod_prop *prop, const char *width, const char *heig
|
|||
static void
|
||||
handle_fraction_prop (struct spa_pod_prop *prop, const char *key, GstCaps *res)
|
||||
{
|
||||
struct spa_fraction *fract = SPA_POD_CONTENTS (struct spa_pod_prop, prop);
|
||||
uint32_t i, n_items = SPA_POD_PROP_N_VALUES (prop);
|
||||
uint32_t flags;
|
||||
struct spa_pod *val;
|
||||
struct spa_fraction *fract;
|
||||
uint32_t i, n_items, choice;
|
||||
|
||||
flags = prop->body.flags;
|
||||
if (!(flags & SPA_POD_PROP_FLAG_UNSET))
|
||||
flags &= ~SPA_POD_PROP_RANGE_MASK;
|
||||
val = spa_pod_get_values(&prop->value, &n_items, &choice);
|
||||
if (val->type != SPA_TYPE_Fraction)
|
||||
return;
|
||||
|
||||
switch (flags & SPA_POD_PROP_RANGE_MASK) {
|
||||
case SPA_POD_PROP_RANGE_NONE:
|
||||
fract = SPA_POD_BODY(val);
|
||||
|
||||
switch (choice) {
|
||||
case SPA_CHOICE_None:
|
||||
gst_caps_set_simple (res, key, GST_TYPE_FRACTION, fract[0].num, fract[0].denom, NULL);
|
||||
break;
|
||||
case SPA_POD_PROP_RANGE_MIN_MAX:
|
||||
case SPA_POD_PROP_RANGE_STEP:
|
||||
case SPA_CHOICE_Range:
|
||||
case SPA_CHOICE_Step:
|
||||
{
|
||||
if (n_items < 3)
|
||||
return;
|
||||
|
|
@ -780,7 +786,7 @@ handle_fraction_prop (struct spa_pod_prop *prop, const char *key, GstCaps *res)
|
|||
fract[2].num, fract[2].denom, NULL);
|
||||
break;
|
||||
}
|
||||
case SPA_POD_PROP_RANGE_ENUM:
|
||||
case SPA_CHOICE_Enum:
|
||||
{
|
||||
GValue l1 = { 0 }, v1 = { 0 };
|
||||
|
||||
|
|
|
|||
|
|
@ -232,25 +232,25 @@ pool_activated (GstPipeWirePool *pool, GstPipeWireSink *sink)
|
|||
spa_pod_builder_init (&b, buffer, sizeof (buffer));
|
||||
spa_pod_builder_push_object (&b, SPA_TYPE_OBJECT_ParamBuffers, SPA_PARAM_Buffers);
|
||||
if (size == 0)
|
||||
spa_pod_builder_add (&b,
|
||||
":", SPA_PARAM_BUFFERS_size, "iru", 0, SPA_POD_PROP_MIN_MAX(0, INT32_MAX), NULL);
|
||||
spa_pod_builder_props (&b,
|
||||
SPA_PARAM_BUFFERS_size, &SPA_POD_CHOICE_RANGE_Int(0, 0, INT32_MAX), 0);
|
||||
else
|
||||
spa_pod_builder_add (&b,
|
||||
":", SPA_PARAM_BUFFERS_size, "iru", size, SPA_POD_PROP_MIN_MAX(size, INT32_MAX), NULL);
|
||||
spa_pod_builder_props (&b,
|
||||
SPA_PARAM_BUFFERS_size, &SPA_POD_CHOICE_RANGE_Int(size, size, INT32_MAX), 0);
|
||||
|
||||
spa_pod_builder_add (&b,
|
||||
":", SPA_PARAM_BUFFERS_stride, "iru", 0, SPA_POD_PROP_MIN_MAX(0, INT32_MAX),
|
||||
":", SPA_PARAM_BUFFERS_buffers, "iru", min_buffers,
|
||||
SPA_POD_PROP_MIN_MAX(min_buffers,
|
||||
spa_pod_builder_props (&b,
|
||||
SPA_PARAM_BUFFERS_stride, &SPA_POD_CHOICE_RANGE_Int(0, 0, INT32_MAX),
|
||||
SPA_PARAM_BUFFERS_buffers, &SPA_POD_CHOICE_RANGE_Int(min_buffers, min_buffers,
|
||||
max_buffers ? max_buffers : INT32_MAX),
|
||||
":", SPA_PARAM_BUFFERS_align, "i", 16,
|
||||
NULL);
|
||||
SPA_PARAM_BUFFERS_align, &SPA_POD_Int(16),
|
||||
0);
|
||||
port_params[0] = spa_pod_builder_pop (&b);
|
||||
|
||||
port_params[1] = spa_pod_builder_object (&b,
|
||||
SPA_TYPE_OBJECT_ParamMeta, SPA_PARAM_Meta,
|
||||
":", SPA_PARAM_META_type, "I", SPA_META_Header,
|
||||
":", SPA_PARAM_META_size, "i", sizeof (struct spa_meta_header));
|
||||
SPA_PARAM_META_type, &SPA_POD_Int(SPA_META_Header),
|
||||
SPA_PARAM_META_size, &SPA_POD_Int(sizeof (struct spa_meta_header)),
|
||||
0);
|
||||
|
||||
|
||||
pw_thread_loop_lock (sink->main_loop);
|
||||
|
|
|
|||
|
|
@ -703,16 +703,18 @@ on_format_changed (void *data,
|
|||
spa_pod_builder_init (&b, buffer, sizeof (buffer));
|
||||
params[0] = spa_pod_builder_object (&b,
|
||||
SPA_TYPE_OBJECT_ParamBuffers, SPA_PARAM_Buffers,
|
||||
":", SPA_PARAM_BUFFERS_buffers, "iru", 16, SPA_POD_PROP_MIN_MAX(1, INT32_MAX),
|
||||
":", SPA_PARAM_BUFFERS_blocks, "iru", 0, SPA_POD_PROP_MIN_MAX(1, INT32_MAX),
|
||||
":", SPA_PARAM_BUFFERS_size, "iru", 0, SPA_POD_PROP_MIN_MAX(0, INT32_MAX),
|
||||
":", SPA_PARAM_BUFFERS_stride, "iru", 0, SPA_POD_PROP_MIN_MAX(0, INT32_MAX),
|
||||
":", SPA_PARAM_BUFFERS_align, "i", 16);
|
||||
SPA_PARAM_BUFFERS_buffers, &SPA_POD_CHOICE_RANGE_Int(16, 1, INT32_MAX),
|
||||
SPA_PARAM_BUFFERS_blocks, &SPA_POD_CHOICE_RANGE_Int(0, 1, INT32_MAX),
|
||||
SPA_PARAM_BUFFERS_size, &SPA_POD_CHOICE_RANGE_Int(0, 0, INT32_MAX),
|
||||
SPA_PARAM_BUFFERS_stride, &SPA_POD_CHOICE_RANGE_Int(0, 0, INT32_MAX),
|
||||
SPA_PARAM_BUFFERS_align, &SPA_POD_Int(16),
|
||||
0);
|
||||
|
||||
params[1] = spa_pod_builder_object (&b,
|
||||
SPA_TYPE_OBJECT_ParamMeta, SPA_PARAM_Meta,
|
||||
":", SPA_PARAM_META_type, "I", SPA_META_Header,
|
||||
":", SPA_PARAM_META_size, "i", sizeof (struct spa_meta_header));
|
||||
SPA_PARAM_META_type, &SPA_POD_Id(SPA_META_Header),
|
||||
SPA_PARAM_META_size, &SPA_POD_Int(sizeof (struct spa_meta_header)),
|
||||
0);
|
||||
|
||||
GST_DEBUG_OBJECT (pwsrc, "doing finish format");
|
||||
pw_stream_finish_format (pwsrc->stream, 0, params, 2);
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ client_node_marshal_done(void *object, int seq, int res)
|
|||
|
||||
b = pw_protocol_native_begin_proxy(proxy, PW_CLIENT_NODE_PROXY_METHOD_DONE);
|
||||
|
||||
spa_pod_builder_struct(b,
|
||||
spa_pod_builder_add_struct(b,
|
||||
"i", seq,
|
||||
"i", res);
|
||||
|
||||
|
|
@ -136,7 +136,7 @@ static void client_node_marshal_set_active(void *object, bool active)
|
|||
|
||||
b = pw_protocol_native_begin_proxy(proxy, PW_CLIENT_NODE_PROXY_METHOD_SET_ACTIVE);
|
||||
|
||||
spa_pod_builder_struct(b, "b", active);
|
||||
spa_pod_builder_add_struct(b, "b", active);
|
||||
|
||||
pw_protocol_native_end_proxy(proxy, b);
|
||||
}
|
||||
|
|
@ -148,7 +148,7 @@ static void client_node_marshal_event_method(void *object, struct spa_event *eve
|
|||
|
||||
b = pw_protocol_native_begin_proxy(proxy, PW_CLIENT_NODE_PROXY_METHOD_EVENT);
|
||||
|
||||
spa_pod_builder_struct(b, "P", event);
|
||||
spa_pod_builder_add_struct(b, "P", event);
|
||||
|
||||
pw_protocol_native_end_proxy(proxy, b);
|
||||
}
|
||||
|
|
@ -160,7 +160,7 @@ static void client_node_marshal_destroy(void *object)
|
|||
|
||||
b = pw_protocol_native_begin_proxy(proxy, PW_CLIENT_NODE_PROXY_METHOD_DESTROY);
|
||||
|
||||
spa_pod_builder_struct(b);
|
||||
spa_pod_builder_add_struct(b);
|
||||
|
||||
pw_protocol_native_end_proxy(proxy, b);
|
||||
}
|
||||
|
|
@ -471,7 +471,7 @@ client_node_marshal_add_mem(void *object,
|
|||
|
||||
b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE_PROXY_EVENT_ADD_MEM);
|
||||
|
||||
spa_pod_builder_struct(b,
|
||||
spa_pod_builder_add_struct(b,
|
||||
"i", mem_id,
|
||||
"I", type,
|
||||
"i", pw_protocol_native_add_resource_fd(resource, memfd),
|
||||
|
|
@ -487,7 +487,7 @@ static void client_node_marshal_transport(void *object, uint32_t node_id, int re
|
|||
|
||||
b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE_PROXY_EVENT_TRANSPORT);
|
||||
|
||||
spa_pod_builder_struct(b,
|
||||
spa_pod_builder_add_struct(b,
|
||||
"i", node_id,
|
||||
"i", pw_protocol_native_add_resource_fd(resource, readfd),
|
||||
"i", pw_protocol_native_add_resource_fd(resource, writefd));
|
||||
|
|
@ -504,7 +504,7 @@ client_node_marshal_set_param(void *object, uint32_t seq, uint32_t id, uint32_t
|
|||
|
||||
b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE_PROXY_EVENT_SET_PARAM);
|
||||
|
||||
spa_pod_builder_struct(b,
|
||||
spa_pod_builder_add_struct(b,
|
||||
"i", seq,
|
||||
"I", id,
|
||||
"i", flags,
|
||||
|
|
@ -520,7 +520,7 @@ static void client_node_marshal_event_event(void *object, const struct spa_event
|
|||
|
||||
b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE_PROXY_EVENT_EVENT);
|
||||
|
||||
spa_pod_builder_struct(b, "P", event);
|
||||
spa_pod_builder_add_struct(b, "P", event);
|
||||
|
||||
pw_protocol_native_end_resource(resource, b);
|
||||
}
|
||||
|
|
@ -533,7 +533,7 @@ client_node_marshal_command(void *object, uint32_t seq, const struct spa_command
|
|||
|
||||
b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE_PROXY_EVENT_COMMAND);
|
||||
|
||||
spa_pod_builder_struct(b, "i", seq, "P", command);
|
||||
spa_pod_builder_add_struct(b, "i", seq, "P", command);
|
||||
|
||||
pw_protocol_native_end_resource(resource, b);
|
||||
}
|
||||
|
|
@ -547,7 +547,7 @@ client_node_marshal_add_port(void *object,
|
|||
|
||||
b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE_PROXY_EVENT_ADD_PORT);
|
||||
|
||||
spa_pod_builder_struct(b,
|
||||
spa_pod_builder_add_struct(b,
|
||||
"i", seq,
|
||||
"i", direction,
|
||||
"i", port_id);
|
||||
|
|
@ -564,7 +564,7 @@ client_node_marshal_remove_port(void *object,
|
|||
|
||||
b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE_PROXY_EVENT_REMOVE_PORT);
|
||||
|
||||
spa_pod_builder_struct(b,
|
||||
spa_pod_builder_add_struct(b,
|
||||
"i", seq,
|
||||
"i", direction,
|
||||
"i", port_id);
|
||||
|
|
@ -586,7 +586,7 @@ client_node_marshal_port_set_param(void *object,
|
|||
|
||||
b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE_PROXY_EVENT_PORT_SET_PARAM);
|
||||
|
||||
spa_pod_builder_struct(b,
|
||||
spa_pod_builder_add_struct(b,
|
||||
"i", seq,
|
||||
"i", direction,
|
||||
"i", port_id,
|
||||
|
|
@ -662,7 +662,7 @@ client_node_marshal_port_command(void *object,
|
|||
|
||||
b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE_PROXY_EVENT_PORT_COMMAND);
|
||||
|
||||
spa_pod_builder_struct(b,
|
||||
spa_pod_builder_add_struct(b,
|
||||
"i", direction,
|
||||
"i", port_id,
|
||||
"P", command);
|
||||
|
|
@ -686,7 +686,7 @@ client_node_marshal_port_set_io(void *object,
|
|||
|
||||
b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE_PROXY_EVENT_PORT_SET_IO);
|
||||
|
||||
spa_pod_builder_struct(b,
|
||||
spa_pod_builder_add_struct(b,
|
||||
"i", seq,
|
||||
"i", direction,
|
||||
"i", port_id,
|
||||
|
|
@ -710,7 +710,7 @@ client_node_marshal_set_io(void *object,
|
|||
struct spa_pod_builder *b;
|
||||
|
||||
b = pw_protocol_native_begin_resource(resource, PW_CLIENT_NODE_PROXY_EVENT_SET_IO);
|
||||
spa_pod_builder_struct(b,
|
||||
spa_pod_builder_add_struct(b,
|
||||
"I", id,
|
||||
"i", memid,
|
||||
"i", offset,
|
||||
|
|
|
|||
|
|
@ -329,13 +329,13 @@ static int port_enum_formats(struct spa_node *node,
|
|||
} else {
|
||||
*param = spa_pod_builder_object(builder,
|
||||
SPA_TYPE_OBJECT_Format, SPA_PARAM_EnumFormat,
|
||||
":", SPA_FORMAT_mediaType, "I", SPA_MEDIA_TYPE_audio,
|
||||
":", SPA_FORMAT_mediaSubtype, "I", SPA_MEDIA_SUBTYPE_raw,
|
||||
":", SPA_FORMAT_AUDIO_format, "I", SPA_AUDIO_FORMAT_F32,
|
||||
":", SPA_FORMAT_AUDIO_layout, "I", SPA_AUDIO_LAYOUT_NON_INTERLEAVED,
|
||||
":", SPA_FORMAT_AUDIO_rate, "iru", 44100,
|
||||
SPA_POD_PROP_MIN_MAX(1, INT32_MAX),
|
||||
":", SPA_FORMAT_AUDIO_channels, "iru", 1);
|
||||
SPA_FORMAT_mediaType, &SPA_POD_Id(SPA_MEDIA_TYPE_audio),
|
||||
SPA_FORMAT_mediaSubtype, &SPA_POD_Id(SPA_MEDIA_SUBTYPE_raw),
|
||||
SPA_FORMAT_AUDIO_format, &SPA_POD_Id(SPA_AUDIO_FORMAT_F32),
|
||||
SPA_FORMAT_AUDIO_layout, &SPA_POD_Id(SPA_AUDIO_LAYOUT_NON_INTERLEAVED),
|
||||
SPA_FORMAT_AUDIO_rate, &SPA_POD_CHOICE_RANGE_Int(44100, 1, INT32_MAX),
|
||||
SPA_FORMAT_AUDIO_channels, &SPA_POD_Int(1),
|
||||
0);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
|
@ -382,8 +382,10 @@ impl_node_port_enum_params(struct spa_node *node,
|
|||
SPA_PARAM_IO };
|
||||
|
||||
if (*index < SPA_N_ELEMENTS(list))
|
||||
param = spa_pod_builder_object(&b, SPA_TYPE_OBJECT_ParamList, id,
|
||||
":", SPA_PARAM_LIST_id, "I", list[*index]);
|
||||
param = spa_pod_builder_object(&b,
|
||||
SPA_TYPE_OBJECT_ParamList, id,
|
||||
SPA_PARAM_LIST_id, &SPA_POD_Id(list[*index]),
|
||||
0);
|
||||
else
|
||||
return 0;
|
||||
break;
|
||||
|
|
@ -410,13 +412,15 @@ impl_node_port_enum_params(struct spa_node *node,
|
|||
|
||||
param = spa_pod_builder_object(&b,
|
||||
SPA_TYPE_OBJECT_ParamBuffers, id,
|
||||
":", SPA_PARAM_BUFFERS_buffers, "iru", 1,
|
||||
SPA_POD_PROP_MIN_MAX(1, MAX_BUFFERS),
|
||||
":", SPA_PARAM_BUFFERS_blocks, "i", 1,
|
||||
":", SPA_PARAM_BUFFERS_size, "iru", 1024 * this->stride,
|
||||
SPA_POD_PROP_MIN_MAX(16 * this->stride, INT32_MAX / this->stride),
|
||||
":", SPA_PARAM_BUFFERS_stride, "i", this->stride,
|
||||
":", SPA_PARAM_BUFFERS_align, "i", 16);
|
||||
SPA_PARAM_BUFFERS_buffers, &SPA_POD_CHOICE_RANGE_Int(1, 1, MAX_BUFFERS),
|
||||
SPA_PARAM_BUFFERS_blocks, &SPA_POD_Int(1),
|
||||
SPA_PARAM_BUFFERS_size, &SPA_POD_CHOICE_RANGE_Int(
|
||||
1024 * this->stride,
|
||||
16 * this->stride,
|
||||
INT32_MAX / this->stride),
|
||||
SPA_PARAM_BUFFERS_stride, &SPA_POD_Int(this->stride),
|
||||
SPA_PARAM_BUFFERS_align, &SPA_POD_Int(16),
|
||||
0);
|
||||
break;
|
||||
|
||||
case SPA_PARAM_Meta:
|
||||
|
|
@ -427,8 +431,9 @@ impl_node_port_enum_params(struct spa_node *node,
|
|||
case 0:
|
||||
param = spa_pod_builder_object(&b,
|
||||
SPA_TYPE_OBJECT_ParamMeta, id,
|
||||
":", SPA_PARAM_META_type, "I", SPA_META_Header,
|
||||
":", SPA_PARAM_META_size, "i", sizeof(struct spa_meta_header));
|
||||
SPA_PARAM_META_type, &SPA_POD_Id(SPA_META_Header),
|
||||
SPA_PARAM_META_size, &SPA_POD_Int(sizeof(struct spa_meta_header)),
|
||||
0);
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
|
|
@ -440,20 +445,23 @@ impl_node_port_enum_params(struct spa_node *node,
|
|||
case 0:
|
||||
param = spa_pod_builder_object(&b,
|
||||
SPA_TYPE_OBJECT_ParamIO, id,
|
||||
":", SPA_PARAM_IO_id, "I", SPA_IO_Buffers,
|
||||
":", SPA_PARAM_IO_size, "i", sizeof(struct spa_io_buffers));
|
||||
SPA_PARAM_IO_id, &SPA_POD_Id(SPA_IO_Buffers),
|
||||
SPA_PARAM_IO_size, &SPA_POD_Int(sizeof(struct spa_io_buffers)),
|
||||
0);
|
||||
break;
|
||||
case 1:
|
||||
param = spa_pod_builder_object(&b,
|
||||
SPA_TYPE_OBJECT_ParamIO, id,
|
||||
":", SPA_PARAM_IO_id, "I", SPA_IO_Range,
|
||||
":", SPA_PARAM_IO_size, "i", sizeof(struct spa_io_range));
|
||||
SPA_PARAM_IO_id, &SPA_POD_Id(SPA_IO_Range),
|
||||
SPA_PARAM_IO_size, &SPA_POD_Int(sizeof(struct spa_io_range)),
|
||||
0);
|
||||
break;
|
||||
case 2:
|
||||
param = spa_pod_builder_object(&b,
|
||||
SPA_TYPE_OBJECT_ParamIO, id,
|
||||
":", SPA_PARAM_IO_id, "I", SPA_IO_Control,
|
||||
":", SPA_PARAM_IO_size, "i", sizeof(struct spa_io_sequence));
|
||||
SPA_PARAM_IO_id, &SPA_POD_Id(SPA_IO_Control),
|
||||
SPA_PARAM_IO_size, &SPA_POD_Int(sizeof(struct spa_io_sequence)),
|
||||
0);
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ static void core_marshal_hello(void *object)
|
|||
|
||||
b = pw_protocol_native_begin_proxy(proxy, PW_CORE_PROXY_METHOD_HELLO);
|
||||
|
||||
spa_pod_builder_struct(b, "P", NULL);
|
||||
spa_pod_builder_add_struct(b, "P", NULL);
|
||||
|
||||
pw_protocol_native_end_proxy(proxy, b);
|
||||
}
|
||||
|
|
@ -93,7 +93,7 @@ static void core_marshal_sync(void *object, uint32_t seq)
|
|||
|
||||
b = pw_protocol_native_begin_proxy(proxy, PW_CORE_PROXY_METHOD_SYNC);
|
||||
|
||||
spa_pod_builder_struct(b, "i", seq);
|
||||
spa_pod_builder_add_struct(b, "i", seq);
|
||||
|
||||
pw_protocol_native_end_proxy(proxy, b);
|
||||
}
|
||||
|
|
@ -105,7 +105,7 @@ static void core_marshal_get_registry(void *object, uint32_t version, uint32_t n
|
|||
|
||||
b = pw_protocol_native_begin_proxy(proxy, PW_CORE_PROXY_METHOD_GET_REGISTRY);
|
||||
|
||||
spa_pod_builder_struct(b,
|
||||
spa_pod_builder_add_struct(b,
|
||||
"i", version,
|
||||
"i", new_id);
|
||||
|
||||
|
|
@ -153,7 +153,7 @@ core_marshal_destroy(void *object, uint32_t id)
|
|||
|
||||
b = pw_protocol_native_begin_proxy(proxy, PW_CORE_PROXY_METHOD_DESTROY);
|
||||
|
||||
spa_pod_builder_struct(b, "i", id);
|
||||
spa_pod_builder_add_struct(b, "i", id);
|
||||
|
||||
pw_protocol_native_end_proxy(proxy, b);
|
||||
}
|
||||
|
|
@ -276,7 +276,7 @@ static void core_marshal_done(void *object, uint32_t seq)
|
|||
|
||||
b = pw_protocol_native_begin_resource(resource, PW_CORE_PROXY_EVENT_DONE);
|
||||
|
||||
spa_pod_builder_struct(b, "i", seq);
|
||||
spa_pod_builder_add_struct(b, "i", seq);
|
||||
|
||||
pw_protocol_native_end_resource(resource, b);
|
||||
}
|
||||
|
|
@ -294,7 +294,7 @@ static void core_marshal_error(void *object, uint32_t id, int res, const char *e
|
|||
vsnprintf(buffer, sizeof(buffer), error, ap);
|
||||
va_end(ap);
|
||||
|
||||
spa_pod_builder_struct(b,
|
||||
spa_pod_builder_add_struct(b,
|
||||
"i", id,
|
||||
"i", res,
|
||||
"s", buffer);
|
||||
|
|
@ -309,7 +309,7 @@ static void core_marshal_remove_id(void *object, uint32_t id)
|
|||
|
||||
b = pw_protocol_native_begin_resource(resource, PW_CORE_PROXY_EVENT_REMOVE_ID);
|
||||
|
||||
spa_pod_builder_struct(b, "i", id);
|
||||
spa_pod_builder_add_struct(b, "i", id);
|
||||
|
||||
pw_protocol_native_end_resource(resource, b);
|
||||
}
|
||||
|
|
@ -485,7 +485,7 @@ static void registry_marshal_global_remove(void *object, uint32_t id)
|
|||
|
||||
b = pw_protocol_native_begin_resource(resource, PW_REGISTRY_PROXY_EVENT_GLOBAL_REMOVE);
|
||||
|
||||
spa_pod_builder_struct(b, "i", id);
|
||||
spa_pod_builder_add_struct(b, "i", id);
|
||||
|
||||
pw_protocol_native_end_resource(resource, b);
|
||||
}
|
||||
|
|
@ -704,7 +704,7 @@ static void node_marshal_param(void *object, uint32_t id, uint32_t index, uint32
|
|||
|
||||
b = pw_protocol_native_begin_resource(resource, PW_NODE_PROXY_EVENT_PARAM);
|
||||
|
||||
spa_pod_builder_struct(b, "I", id, "i", index, "i", next, "P", param);
|
||||
spa_pod_builder_add_struct(b, "I", id, "i", index, "i", next, "P", param);
|
||||
|
||||
pw_protocol_native_end_resource(resource, b);
|
||||
}
|
||||
|
|
@ -736,7 +736,7 @@ static void node_marshal_enum_params(void *object, uint32_t id, uint32_t index,
|
|||
|
||||
b = pw_protocol_native_begin_proxy(proxy, PW_NODE_PROXY_METHOD_ENUM_PARAMS);
|
||||
|
||||
spa_pod_builder_struct(b,
|
||||
spa_pod_builder_add_struct(b,
|
||||
"I", id,
|
||||
"i", index,
|
||||
"i", num,
|
||||
|
|
@ -828,7 +828,7 @@ static void port_marshal_param(void *object, uint32_t id, uint32_t index, uint32
|
|||
|
||||
b = pw_protocol_native_begin_resource(resource, PW_PORT_PROXY_EVENT_PARAM);
|
||||
|
||||
spa_pod_builder_struct(b, "I", id, "i", index, "i", next, "P", param);
|
||||
spa_pod_builder_add_struct(b, "I", id, "i", index, "i", next, "P", param);
|
||||
|
||||
pw_protocol_native_end_resource(resource, b);
|
||||
}
|
||||
|
|
@ -860,7 +860,7 @@ static void port_marshal_enum_params(void *object, uint32_t id, uint32_t index,
|
|||
|
||||
b = pw_protocol_native_begin_proxy(proxy, PW_PORT_PROXY_METHOD_ENUM_PARAMS);
|
||||
|
||||
spa_pod_builder_struct(b,
|
||||
spa_pod_builder_add_struct(b,
|
||||
"I", id,
|
||||
"i", index,
|
||||
"i", num,
|
||||
|
|
@ -1060,7 +1060,7 @@ static void registry_marshal_bind(void *object, uint32_t id,
|
|||
|
||||
b = pw_protocol_native_begin_proxy(proxy, PW_REGISTRY_PROXY_METHOD_BIND);
|
||||
|
||||
spa_pod_builder_struct(b,
|
||||
spa_pod_builder_add_struct(b,
|
||||
"i", id,
|
||||
"I", type,
|
||||
"i", version,
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@
|
|||
#include <spa/node/node.h>
|
||||
#include <spa/monitor/monitor.h>
|
||||
#include <spa/pod/parser.h>
|
||||
#include <spa/debug/pod.h>
|
||||
|
||||
#include <pipewire/log.h>
|
||||
#include <pipewire/type.h>
|
||||
|
|
@ -80,8 +81,11 @@ static struct monitor_item *add_item(struct pw_spa_monitor *this,
|
|||
":", SPA_MONITOR_ITEM_name, "s", &name,
|
||||
":", SPA_MONITOR_ITEM_class, "s", &klass,
|
||||
":", SPA_MONITOR_ITEM_factory, "p", &factory,
|
||||
":", SPA_MONITOR_ITEM_info, "T", &info, NULL) < 0)
|
||||
":", SPA_MONITOR_ITEM_info, "T", &info, NULL) < 0) {
|
||||
pw_log_warn("monitor %p: could not parse item", this);
|
||||
spa_debug_pod(0, NULL, item);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pw_log_debug("monitor %p: add: \"%s\" (%s)", this, name, id);
|
||||
|
||||
|
|
|
|||
|
|
@ -181,29 +181,29 @@ setup_props(struct pw_core *core, struct spa_node *spa_node, struct pw_propertie
|
|||
|
||||
pw_log_info("configure prop %s", key);
|
||||
|
||||
switch(prop->body.value.type) {
|
||||
switch(prop->value.type) {
|
||||
case SPA_TYPE_Bool:
|
||||
SPA_POD_VALUE(struct spa_pod_bool, &prop->body.value) =
|
||||
SPA_POD_VALUE(struct spa_pod_bool, &prop->value) =
|
||||
pw_properties_parse_bool(value);
|
||||
break;
|
||||
case SPA_TYPE_Enum:
|
||||
SPA_POD_VALUE(struct spa_pod_enum, &prop->body.value) =
|
||||
case SPA_TYPE_Id:
|
||||
SPA_POD_VALUE(struct spa_pod_id, &prop->value) =
|
||||
spa_debug_type_find_type(NULL, value);
|
||||
break;
|
||||
case SPA_TYPE_Int:
|
||||
SPA_POD_VALUE(struct spa_pod_int, &prop->body.value) =
|
||||
SPA_POD_VALUE(struct spa_pod_int, &prop->value) =
|
||||
pw_properties_parse_int(value);
|
||||
break;
|
||||
case SPA_TYPE_Long:
|
||||
SPA_POD_VALUE(struct spa_pod_long, &prop->body.value) =
|
||||
SPA_POD_VALUE(struct spa_pod_long, &prop->value) =
|
||||
pw_properties_parse_int64(value);
|
||||
break;
|
||||
case SPA_TYPE_Float:
|
||||
SPA_POD_VALUE(struct spa_pod_float, &prop->body.value) =
|
||||
SPA_POD_VALUE(struct spa_pod_float, &prop->value) =
|
||||
pw_properties_parse_float(value);
|
||||
break;
|
||||
case SPA_TYPE_Double:
|
||||
SPA_POD_VALUE(struct spa_pod_double, &prop->body.value) =
|
||||
SPA_POD_VALUE(struct spa_pod_double, &prop->value) =
|
||||
pw_properties_parse_double(value);
|
||||
break;
|
||||
case SPA_TYPE_String:
|
||||
|
|
|
|||
|
|
@ -406,7 +406,8 @@ static int impl_port_enum_params(struct spa_node *node,
|
|||
if (last_id == SPA_ID_INVALID){
|
||||
*result = spa_pod_builder_object(builder,
|
||||
SPA_TYPE_OBJECT_ParamList, id,
|
||||
":", SPA_PARAM_LIST_id, "I", new_id);
|
||||
SPA_PARAM_LIST_id, &SPA_POD_Id(new_id),
|
||||
0);
|
||||
last_id = new_id;
|
||||
}
|
||||
else if (last_id != new_id) {
|
||||
|
|
@ -631,10 +632,9 @@ static int process_notify(struct stream *impl, struct spa_pod_sequence *sequence
|
|||
if (impl->props.changed) {
|
||||
spa_pod_builder_control_header(&b, 0, SPA_CONTROL_Properties);
|
||||
spa_pod_builder_push_object(&b, SPA_TYPE_OBJECT_Props, 0);
|
||||
spa_pod_builder_push_prop(&b, SPA_PROP_volume, 0);
|
||||
spa_pod_builder_prop(&b, SPA_PROP_volume, 0);
|
||||
spa_pod_builder_float(&b, impl->props.volume);
|
||||
spa_pod_builder_pop(&b);
|
||||
spa_pod_builder_pop(&b);
|
||||
impl->props.changed = false;
|
||||
}
|
||||
spa_pod_builder_pop(&b);
|
||||
|
|
@ -1004,14 +1004,16 @@ static void add_controls(struct pw_stream *stream)
|
|||
add_param(stream, PARAM_TYPE_INIT,
|
||||
spa_pod_builder_object(&b,
|
||||
SPA_TYPE_OBJECT_ParamIO, SPA_PARAM_IO,
|
||||
":", SPA_PARAM_IO_id, "I", SPA_IO_Notify,
|
||||
":", SPA_PARAM_IO_size, "i", sizeof(struct spa_io_sequence) + 1024));
|
||||
SPA_PARAM_IO_id, &SPA_POD_Id(SPA_IO_Notify),
|
||||
SPA_PARAM_IO_size, &SPA_POD_Int(sizeof(struct spa_io_sequence) + 1024),
|
||||
0));
|
||||
|
||||
add_param(stream, PARAM_TYPE_INIT,
|
||||
spa_pod_builder_object(&b,
|
||||
SPA_TYPE_OBJECT_ParamIO, SPA_PARAM_IO,
|
||||
":", SPA_PARAM_IO_id, "I", SPA_IO_Control,
|
||||
":", SPA_PARAM_IO_size, "i", sizeof(struct spa_io_sequence)));
|
||||
SPA_PARAM_IO_id, &SPA_POD_Id(SPA_IO_Control),
|
||||
SPA_PARAM_IO_size, &SPA_POD_Int(sizeof(struct spa_io_sequence)),
|
||||
0));
|
||||
}
|
||||
|
||||
int
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue