mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-01 22:58:50 -04:00
improve props test
This commit is contained in:
parent
ded1ea69a1
commit
cf94117244
4 changed files with 92 additions and 75 deletions
|
|
@ -29,6 +29,12 @@ extern "C" {
|
|||
#include <spa/format.h>
|
||||
#include <spa/pod-builder.h>
|
||||
|
||||
#define SPA_FORMAT_INIT(size,type,media_type,media_subtype,...) \
|
||||
{ { size, SPA_POD_TYPE_OBJECT }, \
|
||||
{ { 0, type }, \
|
||||
SPA_POD_ID_INIT(media_type), \
|
||||
SPA_POD_ID_INIT(media_subtype) } }
|
||||
|
||||
static inline uint32_t
|
||||
spa_pod_builder_push_format(struct spa_pod_builder *builder,
|
||||
struct spa_pod_frame *frame,
|
||||
|
|
@ -36,10 +42,8 @@ spa_pod_builder_push_format(struct spa_pod_builder *builder,
|
|||
uint32_t media_type,
|
||||
uint32_t media_subtype)
|
||||
{
|
||||
const struct spa_format p = {
|
||||
{sizeof(struct spa_format_body), SPA_POD_TYPE_OBJECT}, {{0, format_type},
|
||||
{{sizeof(uint32_t), SPA_POD_TYPE_ID}, media_type},
|
||||
{{sizeof(uint32_t), SPA_POD_TYPE_ID}, media_subtype} } };
|
||||
const struct spa_format p = SPA_FORMAT_INIT(sizeof(struct spa_format_body),
|
||||
0, format_type, media_type, media_subtype);
|
||||
return spa_pod_builder_push(builder, frame, &p.pod,
|
||||
spa_pod_builder_raw(builder, &p, sizeof(p)));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -136,12 +136,6 @@ spa_type_media_subtype_audio_map(struct spa_type_map *map,
|
|||
}
|
||||
}
|
||||
|
||||
#define SPA_FORMAT_INIT(size,type,media_type,media_subtype,...) \
|
||||
{ { size, SPA_POD_TYPE_OBJECT }, \
|
||||
{ { 0, type }, \
|
||||
SPA_POD_ID_INIT(media_type), \
|
||||
SPA_POD_ID_INIT(media_subtype) } }
|
||||
|
||||
#define SPA_FORMAT_BODY_FOREACH(body, size, iter) \
|
||||
for ((iter) = SPA_MEMBER((body), sizeof(struct spa_format_body), struct spa_pod_prop); \
|
||||
(iter) < SPA_MEMBER((body), (size), struct spa_pod_prop); \
|
||||
|
|
|
|||
|
|
@ -298,13 +298,15 @@ spa_pod_builder_push_object(struct spa_pod_builder *builder,
|
|||
spa_pod_builder_raw(builder, &p, sizeof(p)));
|
||||
}
|
||||
|
||||
#define SPA_POD_PROP_INIT(size,key,flags,val_size,val_type) \
|
||||
{ { size, SPA_POD_TYPE_PROP}, {key, flags, { val_size, val_type } } }
|
||||
|
||||
static inline uint32_t
|
||||
spa_pod_builder_push_prop(struct spa_pod_builder *builder,
|
||||
struct spa_pod_frame *frame, uint32_t key, uint32_t flags)
|
||||
{
|
||||
const struct spa_pod_prop p = { {sizeof(struct spa_pod_prop_body) -
|
||||
sizeof(struct spa_pod), SPA_POD_TYPE_PROP},
|
||||
{key, flags, {0, 0}} };
|
||||
const struct spa_pod_prop p = SPA_POD_PROP_INIT (sizeof(struct spa_pod_prop_body) -
|
||||
sizeof(struct spa_pod), key, flags, 0, 0);
|
||||
return spa_pod_builder_push(builder, frame, &p.pod,
|
||||
spa_pod_builder_raw(builder, &p,
|
||||
sizeof(p) - sizeof(struct spa_pod)));
|
||||
|
|
|
|||
|
|
@ -37,6 +37,14 @@
|
|||
* format: (int 1) { 1 2 },
|
||||
* size: (rect (320 240)) { (1 1) (MAX MAX) },
|
||||
* framerate: (frac (25 1)) { (0 1) (MAX 1) },
|
||||
*
|
||||
* "(object $format
|
||||
* (id $video) (id $raw)
|
||||
* (prop $format (int $I420) { $I420 $YUY2 } )
|
||||
* (prop $size (rect (320 240)) [ (1 1) (MAX MAX) ] )
|
||||
* (prop $framerate (frac (25 1))))
|
||||
* "
|
||||
*
|
||||
*/
|
||||
|
||||
spa_build(SPA_MEDIA_TYPE_VIDEO, SPA_MEDIA_SUBTYPE_RAW,
|
||||
|
|
@ -79,21 +87,21 @@ static void do_static_struct(struct spa_type_map *map)
|
|||
struct spa_format fmt;
|
||||
|
||||
struct {
|
||||
struct spa_pod_prop prop_format;
|
||||
struct spa_pod_prop prop_format; SPA_ALIGNED(8)
|
||||
struct {
|
||||
uint32_t def_format;
|
||||
uint32_t enum_format[2];
|
||||
} format_vals;
|
||||
uint32_t pad;
|
||||
|
||||
struct spa_pod_prop prop_size;
|
||||
struct spa_pod_prop prop_size; SPA_ALIGNED(8)
|
||||
struct {
|
||||
struct spa_rectangle def_size;
|
||||
struct spa_rectangle min_size;
|
||||
struct spa_rectangle max_size;
|
||||
} size_vals;
|
||||
|
||||
struct spa_pod_prop prop_framerate;
|
||||
struct spa_pod_prop prop_framerate; SPA_ALIGNED(8)
|
||||
struct {
|
||||
struct spa_fraction def_framerate;
|
||||
struct spa_fraction min_framerate;
|
||||
|
|
@ -101,47 +109,38 @@ static void do_static_struct(struct spa_type_map *map)
|
|||
} framerate_vals;
|
||||
} props;
|
||||
} test_format = {
|
||||
{ {
|
||||
sizeof(test_format.props) + sizeof(struct spa_format), SPA_POD_TYPE_OBJECT},
|
||||
{ {
|
||||
0, type.format}, { {
|
||||
sizeof(uint32_t), SPA_POD_TYPE_ID}
|
||||
, type.media_type.video}
|
||||
, { {
|
||||
sizeof(uint32_t), SPA_POD_TYPE_ID}
|
||||
, type.media_subtype.raw}
|
||||
SPA_FORMAT_INIT(sizeof(test_format.props) + sizeof(struct spa_format_body),
|
||||
type.format, type.media_type.video, type.media_subtype.raw),
|
||||
{
|
||||
SPA_POD_PROP_INIT(sizeof(test_format.props.format_vals) +
|
||||
sizeof(struct spa_pod_prop_body),
|
||||
type.format_video.format,
|
||||
SPA_POD_PROP_RANGE_ENUM | SPA_POD_PROP_FLAG_UNSET,
|
||||
sizeof(uint32_t), SPA_POD_TYPE_ID),
|
||||
{
|
||||
type.video_format.I420,
|
||||
{ type.video_format.I420, type.video_format.YUY2 }
|
||||
}, 0,
|
||||
SPA_POD_PROP_INIT(sizeof(test_format.props.size_vals) +
|
||||
sizeof(struct spa_pod_prop_body),
|
||||
type.format_video.size,
|
||||
SPA_POD_PROP_RANGE_MIN_MAX | SPA_POD_PROP_FLAG_UNSET,
|
||||
sizeof(struct spa_rectangle), SPA_POD_TYPE_RECTANGLE),
|
||||
|
||||
{
|
||||
{ 320, 243},
|
||||
{ 1, 1}, { INT32_MAX, INT32_MAX}
|
||||
},
|
||||
SPA_POD_PROP_INIT(sizeof(test_format.props.framerate_vals) +
|
||||
sizeof(struct spa_pod_prop_body),
|
||||
type.format_video.framerate,
|
||||
SPA_POD_PROP_RANGE_MIN_MAX | SPA_POD_PROP_FLAG_UNSET,
|
||||
sizeof(struct spa_fraction), SPA_POD_TYPE_FRACTION),
|
||||
{
|
||||
{ 25, 1},
|
||||
{ 0, 1}, { INT32_MAX, 1}
|
||||
}
|
||||
}
|
||||
,}
|
||||
, {
|
||||
{ {
|
||||
sizeof(test_format.props.format_vals) +
|
||||
sizeof(struct spa_pod_prop_body), SPA_POD_TYPE_PROP}, {
|
||||
type.format_video.format,
|
||||
SPA_POD_PROP_RANGE_ENUM | SPA_POD_PROP_FLAG_UNSET, {
|
||||
sizeof(uint32_t), SPA_POD_TYPE_ID}
|
||||
}
|
||||
,}
|
||||
, {
|
||||
type.video_format.I420, {
|
||||
type.video_format.I420, type.video_format.YUY2}
|
||||
}
|
||||
, 0, { {
|
||||
sizeof(test_format.props.size_vals) +
|
||||
sizeof(struct spa_pod_prop_body), SPA_POD_TYPE_PROP}, {
|
||||
type.format_video.size,
|
||||
SPA_POD_PROP_RANGE_MIN_MAX | SPA_POD_PROP_FLAG_UNSET, {
|
||||
sizeof(struct spa_rectangle), SPA_POD_TYPE_RECTANGLE}},}, { {
|
||||
320, 243}, {
|
||||
1, 1}, {
|
||||
INT32_MAX, INT32_MAX}}, { {
|
||||
sizeof(test_format.props.framerate_vals) +
|
||||
sizeof(struct spa_pod_prop_body), SPA_POD_TYPE_PROP}, {
|
||||
type.format_video.framerate,
|
||||
SPA_POD_PROP_RANGE_MIN_MAX | SPA_POD_PROP_FLAG_UNSET, {
|
||||
sizeof(struct spa_fraction), SPA_POD_TYPE_FRACTION}},}, { {
|
||||
25, 1}, {
|
||||
0, 1}, {
|
||||
INT32_MAX, 1}},}
|
||||
};
|
||||
|
||||
spa_debug_pod(&test_format.fmt.pod, map);
|
||||
|
|
@ -152,7 +151,16 @@ static void do_static_struct(struct spa_type_map *map)
|
|||
struct spa_fraction frac = { 0, 0 };
|
||||
|
||||
match = spa_pod_contents_query(&test_format.fmt.pod, sizeof(struct spa_format),
|
||||
type.format_video.format, SPA_POD_TYPE_INT, &format,
|
||||
type.format_video.format, SPA_POD_TYPE_ID, &format,
|
||||
type.format_video.framerate, SPA_POD_TYPE_FRACTION,
|
||||
&frac, 0);
|
||||
|
||||
printf("%d %d %d %d\n", match, format, frac.num, frac.denom);
|
||||
|
||||
spa_format_fixate(&test_format.fmt);
|
||||
|
||||
match = spa_pod_contents_query(&test_format.fmt.pod, sizeof(struct spa_format),
|
||||
type.format_video.format, SPA_POD_TYPE_ID, &format,
|
||||
type.format_video.framerate, SPA_POD_TYPE_FRACTION,
|
||||
&frac, 0);
|
||||
|
||||
|
|
@ -209,23 +217,29 @@ int main(int argc, char *argv[])
|
|||
spa_pod_builder_format(&b, &frame[0], type.format,
|
||||
type.media_type.video,
|
||||
type.media_subtype.raw,
|
||||
SPA_POD_TYPE_PROP, &frame[1], type.format_video.format,
|
||||
SPA_POD_PROP_FLAG_UNSET | SPA_POD_PROP_RANGE_ENUM, SPA_POD_TYPE_ID, 3,
|
||||
type.video_format.I420,
|
||||
type.video_format.I420,
|
||||
type.video_format.YUY2,
|
||||
SPA_POD_TYPE_PROP, &frame[1],
|
||||
type.format_video.format,
|
||||
SPA_POD_PROP_FLAG_UNSET | SPA_POD_PROP_RANGE_ENUM,
|
||||
SPA_POD_TYPE_ID, 3,
|
||||
type.video_format.I420,
|
||||
type.video_format.I420,
|
||||
type.video_format.YUY2,
|
||||
-SPA_POD_TYPE_PROP, &frame[1],
|
||||
SPA_POD_TYPE_PROP, &frame[1], type.format_video.size,
|
||||
SPA_POD_PROP_FLAG_UNSET | SPA_POD_PROP_RANGE_MIN_MAX, SPA_POD_TYPE_RECTANGLE, 3,
|
||||
320, 241,
|
||||
1, 1,
|
||||
INT32_MAX, INT32_MAX,
|
||||
SPA_POD_TYPE_PROP, &frame[1],
|
||||
type.format_video.size,
|
||||
SPA_POD_PROP_FLAG_UNSET | SPA_POD_PROP_RANGE_MIN_MAX,
|
||||
SPA_POD_TYPE_RECTANGLE, 3,
|
||||
320, 241,
|
||||
1, 1,
|
||||
INT32_MAX, INT32_MAX,
|
||||
-SPA_POD_TYPE_PROP, &frame[1],
|
||||
SPA_POD_TYPE_PROP, &frame[1], type.format_video.framerate,
|
||||
SPA_POD_PROP_FLAG_UNSET | SPA_POD_PROP_RANGE_MIN_MAX, SPA_POD_TYPE_FRACTION, 3,
|
||||
25, 1,
|
||||
0, 1,
|
||||
INT32_MAX, 1,
|
||||
SPA_POD_TYPE_PROP, &frame[1],
|
||||
type.format_video.framerate,
|
||||
SPA_POD_PROP_FLAG_UNSET | SPA_POD_PROP_RANGE_MIN_MAX,
|
||||
SPA_POD_TYPE_FRACTION, 3,
|
||||
25, 1,
|
||||
0, 1,
|
||||
INT32_MAX, 1,
|
||||
-SPA_POD_TYPE_PROP, &frame[1]);
|
||||
|
||||
fmt = SPA_MEMBER(buffer, frame[0].ref, struct spa_format);
|
||||
|
|
@ -240,21 +254,24 @@ int main(int argc, char *argv[])
|
|||
SPA_POD_TYPE_ID, type.media_subtype.raw,
|
||||
SPA_POD_TYPE_PROP, &frame[1],
|
||||
type.format_video.format,
|
||||
SPA_POD_PROP_FLAG_UNSET | SPA_POD_PROP_RANGE_ENUM, SPA_POD_TYPE_ID, 3,
|
||||
SPA_POD_PROP_FLAG_UNSET | SPA_POD_PROP_RANGE_ENUM,
|
||||
SPA_POD_TYPE_ID, 3,
|
||||
type.video_format.I420,
|
||||
type.video_format.I420,
|
||||
type.video_format.YUY2,
|
||||
-SPA_POD_TYPE_PROP, &frame[1],
|
||||
SPA_POD_TYPE_PROP, &frame[1],
|
||||
type.format_video.size,
|
||||
SPA_POD_PROP_FLAG_UNSET | SPA_POD_PROP_RANGE_MIN_MAX, SPA_POD_TYPE_RECTANGLE, 3,
|
||||
SPA_POD_PROP_FLAG_UNSET | SPA_POD_PROP_RANGE_MIN_MAX,
|
||||
SPA_POD_TYPE_RECTANGLE, 3,
|
||||
320, 242,
|
||||
1, 1,
|
||||
INT32_MAX, INT32_MAX,
|
||||
-SPA_POD_TYPE_PROP, &frame[1],
|
||||
SPA_POD_TYPE_PROP, &frame[1],
|
||||
type.format_video.framerate,
|
||||
SPA_POD_PROP_FLAG_UNSET | SPA_POD_PROP_RANGE_MIN_MAX, SPA_POD_TYPE_FRACTION, 3,
|
||||
SPA_POD_PROP_FLAG_UNSET | SPA_POD_PROP_RANGE_MIN_MAX,
|
||||
SPA_POD_TYPE_FRACTION, 3,
|
||||
25, 1,
|
||||
0, 1,
|
||||
INT32_MAX, 1,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue