diff --git a/pinos/client/serialize.c b/pinos/client/serialize.c index b56b07ff1..35719f91b 100644 --- a/pinos/client/serialize.c +++ b/pinos/client/serialize.c @@ -205,131 +205,30 @@ pinos_serialize_port_info_copy_into (void *dest, const SpaPortInfo *info) size_t pinos_serialize_props_get_size (const SpaProps *props) { - size_t len; - unsigned int i, j; - SpaPropInfo *pi; - SpaPropRangeInfo *ri; - if (props == NULL) return 0; - len = sizeof (SpaProps); - for (i = 0; i < props->n_prop_info; i++) { - pi = (SpaPropInfo *) &props->prop_info[i]; - len += sizeof (SpaPropInfo); - len += pi->name ? strlen (pi->name) + 1 : 0; - /* for the value */ - len += pi->maxsize; - for (j = 0; j < pi->n_range_values; j++) { - ri = (SpaPropRangeInfo *)&pi->range_values[j]; - len += sizeof (SpaPropRangeInfo); - len += ri->name ? strlen (ri->name) + 1 : 0; - /* the size of the range value */ - len += ri->val.size; - } - } - return len; + return SPA_POD_SIZE (props); } size_t pinos_serialize_props_serialize (void *p, const SpaProps *props) { - size_t len, slen; - unsigned int i, j, c; - SpaProps *tp; - SpaPropInfo *pi; - SpaPropRangeInfo *ri; + size_t size; if (props == NULL) return 0; - tp = p; - memcpy (tp, props, sizeof (SpaProps)); - pi = SPA_MEMBER (tp, sizeof(SpaProps), SpaPropInfo); - ri = SPA_MEMBER (pi, sizeof(SpaPropInfo) * tp->n_prop_info, SpaPropRangeInfo); + size = SPA_POD_SIZE (props); + memcpy (p, props, size); - tp->prop_info = SPA_INT_TO_PTR (SPA_PTRDIFF (pi, tp)); - - /* write propinfo array */ - for (i = 0, c = 0; i < tp->n_prop_info; i++) { - memcpy (&pi[i], &props->prop_info[i], sizeof (SpaPropInfo)); - pi[i].range_values = SPA_INT_TO_PTR (SPA_PTRDIFF (&ri[c], tp)); - for (j = 0; j < pi[i].n_range_values; j++, c++) { - memcpy (&ri[c], &props->prop_info[i].range_values[j], sizeof (SpaPropRangeInfo)); - } - } - p = &ri[c]; - /* strings and default values from props and ranges */ - for (i = 0, c = 0; i < tp->n_prop_info; i++) { - if (pi[i].name) { - slen = strlen (pi[i].name) + 1; - memcpy (p, pi[i].name, slen); - pi[i].name = SPA_INT_TO_PTR (SPA_PTRDIFF (p, tp)); - p += slen; - } else { - pi[i].name = 0; - } - for (j = 0; j < pi[i].n_range_values; j++, c++) { - if (ri[c].name) { - slen = strlen (ri[c].name) + 1; - memcpy (p, ri[c].name, slen); - ri[c].name = SPA_INT_TO_PTR (SPA_PTRDIFF (p, tp)); - p += slen; - } else { - ri[c].name = 0; - } - if (ri[c].val.size) { - memcpy (p, ri[c].val.value, ri[c].val.size); - ri[c].val.value = SPA_INT_TO_PTR (SPA_PTRDIFF (p, tp)); - p += ri[c].val.size; - } else { - ri[c].val.value = 0; - } - } - } - /* and the actual values */ - for (i = 0; i < tp->n_prop_info; i++) { - if (pi[i].offset) { - memcpy (p, SPA_MEMBER (props, pi[i].offset, void), pi[i].maxsize); - pi[i].offset = SPA_PTRDIFF (p, tp); - p += pi[i].maxsize; - } else { - pi[i].offset = 0; - } - } - len = SPA_PTRDIFF (p, tp); - - return len; + return size; } SpaProps * pinos_serialize_props_deserialize (void *p, off_t offset) { - SpaProps *tp; - unsigned int i, j; - SpaPropInfo *pi; - SpaPropRangeInfo *ri; - - tp = SPA_MEMBER (p, offset, SpaProps); - if (tp->prop_info) - tp->prop_info = SPA_MEMBER (tp, SPA_PTR_TO_INT (tp->prop_info), SpaPropInfo); - /* now fix all the pointers */ - for (i = 0; i < tp->n_prop_info; i++) { - pi = (SpaPropInfo *) &tp->prop_info[i]; - if (pi->name) - pi->name = SPA_MEMBER (tp, SPA_PTR_TO_INT (pi->name), char); - if (pi->range_values) - pi->range_values = SPA_MEMBER (tp, SPA_PTR_TO_INT (pi->range_values), SpaPropRangeInfo); - - for (j = 0; j < pi->n_range_values; j++) { - ri = (SpaPropRangeInfo *) &pi->range_values[j]; - if (ri->name) - ri->name = SPA_MEMBER (tp, SPA_PTR_TO_INT (ri->name), char); - if (ri->val.value) - ri->val.value = SPA_MEMBER (tp, SPA_PTR_TO_INT (ri->val.value), void); - } - } - return tp; + return SPA_MEMBER (p, offset, SpaProps); } SpaProps * diff --git a/pinos/gst/gstpinosformat.c b/pinos/gst/gstpinosformat.c index 1c21dc38d..c4cfdd84c 100644 --- a/pinos/gst/gstpinosformat.c +++ b/pinos/gst/gstpinosformat.c @@ -443,14 +443,18 @@ GstCaps * gst_caps_from_format (const SpaFormat *format) { GstCaps *res = NULL; + uint32_t media_type, media_subtype; - if (format->body.media_type == SPA_MEDIA_TYPE_VIDEO) { + media_type = format->body.media_type.value; + media_subtype = format->body.media_subtype.value; + + if (media_type == SPA_MEDIA_TYPE_VIDEO) { SpaVideoInfo f; if (spa_format_video_parse (format, &f) < 0) return NULL; - if (format->body.media_subtype == SPA_MEDIA_SUBTYPE_RAW) { + if (media_subtype == SPA_MEDIA_SUBTYPE_RAW) { res = gst_caps_new_simple ("video/x-raw", "format", G_TYPE_STRING, gst_video_format_to_string (f.info.raw.format), "width", G_TYPE_INT, f.info.raw.size.width, @@ -458,14 +462,14 @@ gst_caps_from_format (const SpaFormat *format) "framerate", GST_TYPE_FRACTION, f.info.raw.framerate.num, f.info.raw.framerate.denom, NULL); } - else if (format->body.media_subtype == SPA_MEDIA_SUBTYPE_MJPG) { + else if (media_subtype == SPA_MEDIA_SUBTYPE_MJPG) { res = gst_caps_new_simple ("image/jpeg", "width", G_TYPE_INT, f.info.mjpg.size.width, "height", G_TYPE_INT, f.info.mjpg.size.height, "framerate", GST_TYPE_FRACTION, f.info.mjpg.framerate.num, f.info.mjpg.framerate.denom, NULL); } - else if (format->body.media_subtype == SPA_MEDIA_SUBTYPE_H264) { + else if (media_subtype == SPA_MEDIA_SUBTYPE_H264) { res = gst_caps_new_simple ("video/x-h264", "width", G_TYPE_INT, f.info.h264.size.width, "height", G_TYPE_INT, f.info.h264.size.height, @@ -474,13 +478,13 @@ gst_caps_from_format (const SpaFormat *format) "alignment", G_TYPE_STRING, "au", NULL); } - } else if (format->body.media_type == SPA_MEDIA_TYPE_AUDIO) { + } else if (media_type == SPA_MEDIA_TYPE_AUDIO) { SpaAudioInfo f; if (spa_format_audio_parse (format, &f) < 0) return NULL; - if (format->body.media_subtype == SPA_MEDIA_SUBTYPE_RAW) { + if (media_subtype == SPA_MEDIA_SUBTYPE_RAW) { res = gst_caps_new_simple ("audio/x-raw", "format", G_TYPE_STRING, gst_audio_format_to_string (f.info.raw.format), "layout", G_TYPE_STRING, "interleaved", diff --git a/pinos/modules/spa/module.c b/pinos/modules/spa/module.c index bf7eb32f6..91dea1f68 100644 --- a/pinos/modules/spa/module.c +++ b/pinos/modules/spa/module.c @@ -34,7 +34,7 @@ static SpaResult setup_video_node (SpaNode *spa_node, PinosProperties *pinos_props) { SpaResult res; SpaProps *props; - SpaPropValue value; +// SpaPropValue value; const char *pattern; uint32_t pattern_int; @@ -49,15 +49,15 @@ setup_video_node (SpaNode *spa_node, PinosProperties *pinos_props) { return SPA_RESULT_ERROR; } - value.value = &pattern_int; - value.size = sizeof(uint32_t); +//// value.value = &pattern_int; +// value.size = sizeof(uint32_t); if ((res = spa_node_get_props (spa_node, &props)) != SPA_RESULT_OK) { pinos_log_debug ("spa_node_get_props failed: %d", res); return SPA_RESULT_ERROR; } - spa_props_set_value (props, spa_props_index_for_name (props, "pattern"), &value); +// spa_props_set_value (props, spa_props_index_for_name (props, "pattern"), &value); if ((res = spa_node_set_props (spa_node, props)) != SPA_RESULT_OK) { pinos_log_debug ("spa_node_set_props failed: %d", res); diff --git a/spa/include/spa/format-builder.h b/spa/include/spa/format-builder.h index 5c6f29b82..d0f2d0afb 100644 --- a/spa/include/spa/format-builder.h +++ b/spa/include/spa/format-builder.h @@ -35,9 +35,10 @@ spa_pod_builder_push_format (SpaPODBuilder *builder, uint32_t media_type, uint32_t media_subtype) { - const SpaFormat p = { { sizeof (SpaFormatBody), SPA_POD_TYPE_FORMAT }, - { media_type, media_subtype } }; - return spa_pod_builder_push (builder, frame, &p.pod, + const SpaFormat p = { { { sizeof (SpaPODObjectBody) + sizeof (SpaFormatBody), SPA_POD_TYPE_OBJECT }, { 0, 0 } }, + { { { sizeof (uint32_t), SPA_POD_TYPE_INT }, media_type }, + { { sizeof (uint32_t), SPA_POD_TYPE_INT }, media_subtype } } }; + return spa_pod_builder_push (builder, frame, &p.obj.pod, spa_pod_builder_raw (builder, &p, sizeof(p), false)); } diff --git a/spa/include/spa/format.h b/spa/include/spa/format.h index 0474d4817..aa8f1cbc8 100644 --- a/spa/include/spa/format.h +++ b/spa/include/spa/format.h @@ -90,8 +90,8 @@ typedef enum { } SpaFormatProps; typedef struct { - uint32_t media_type; - uint32_t media_subtype; + SpaPODInt media_type; + SpaPODInt media_subtype; /* contents follow, series of SpaPODProp */ } SpaFormatBody; @@ -102,7 +102,7 @@ typedef struct { * @pod: POD object with properties */ struct _SpaFormat { - SpaPOD pod; + SpaPODObject obj; SpaFormatBody body; }; @@ -115,7 +115,7 @@ static inline SpaPODProp * spa_format_find_prop (const SpaFormat *format, uint32_t key) { SpaPODProp *res; - SPA_POD_FOREACH (format, res) { + SPA_FORMAT_BODY_FOREACH (&format->body, SPA_POD_BODY_SIZE (format), res) { if (res->pod.type == SPA_POD_TYPE_PROP && res->body.key == key) return res; } diff --git a/spa/include/spa/pod.h b/spa/include/spa/pod.h index e24e96e1a..155e4ebda 100644 --- a/spa/include/spa/pod.h +++ b/spa/include/spa/pod.h @@ -47,8 +47,7 @@ typedef enum { SPA_POD_TYPE_STRUCT, SPA_POD_TYPE_OBJECT, SPA_POD_TYPE_PROP, - SPA_POD_TYPE_BYTES, - SPA_POD_TYPE_FORMAT + SPA_POD_TYPE_BYTES } SpaPODType; typedef struct { diff --git a/spa/include/spa/props.h b/spa/include/spa/props.h index 357a5bf2a..d14768a05 100644 --- a/spa/include/spa/props.h +++ b/spa/include/spa/props.h @@ -24,167 +24,39 @@ extern "C" { #endif -typedef struct _SpaProps SpaProps; +#include +#include + +typedef SpaPODObject SpaProps; #define SPA_PROPS_URI "http://spaplug.in/ns/props" #define SPA_PROPS_PREFIX SPA_PROPS_URI "#" -#include -#include -#include -/** - * SpaPropType: - */ -typedef enum { - SPA_PROP_TYPE_INVALID = 0, - SPA_PROP_TYPE_BOOL, - SPA_PROP_TYPE_INT8, - SPA_PROP_TYPE_UINT8, - SPA_PROP_TYPE_INT16, - SPA_PROP_TYPE_UINT16, - SPA_PROP_TYPE_INT32, - SPA_PROP_TYPE_UINT32, - SPA_PROP_TYPE_INT64, - SPA_PROP_TYPE_UINT64, - SPA_PROP_TYPE_INT, - SPA_PROP_TYPE_UINT, - SPA_PROP_TYPE_FLOAT, - SPA_PROP_TYPE_DOUBLE, - SPA_PROP_TYPE_STRING, - SPA_PROP_TYPE_RECTANGLE, - SPA_PROP_TYPE_FRACTION, - SPA_PROP_TYPE_BITMASK, - SPA_PROP_TYPE_POINTER -} SpaPropType; - -/** - * SpaPropFlags: - * @SPA_PROP_FLAG_NONE: no flags - * @SPA_PROP_FLAG_OPTIONAL: the value can be left unset - * @SPA_PROP_FLAG_READABLE: property is readable - * @SPA_PROP_FLAG_WRITABLE: property is writable - * @SPA_PROP_FLAG_READWRITE: property is readable and writable - * @SPA_PROP_FLAG_DEPRECATED: property is deprecated and should not be used - * @SPA_PROP_FLAG_INFO: property is to get/set the complete structure - */ -typedef enum { - SPA_PROP_FLAG_NONE = 0, - SPA_PROP_FLAG_OPTIONAL = (1 << 0), - SPA_PROP_FLAG_READABLE = (1 << 1), - SPA_PROP_FLAG_WRITABLE = (1 << 2), - SPA_PROP_FLAG_READWRITE = SPA_PROP_FLAG_READABLE | SPA_PROP_FLAG_WRITABLE, - SPA_PROP_FLAG_DEPRECATED = (1 << 3), - SPA_PROP_FLAG_INFO = (1 << 4), -} SpaPropFlags; - -/* SpaPropRangeType: - * @SPA_PROP_RANGE_TYPE_NONE: no range specified, full range of type applies - * @SPA_PROP_RANGE_TYPE_MIN_MAX: range contains 2 values, min and max - * @SPA_PROP_RANGE_TYPE_STEP: range contains 3 values, min, max and step - * @SPA_PROP_RANGE_TYPE_ENUM: range contains enum of possible values - * @SPA_PROP_RANGE_TYPE_FLAGS: range contains flags of possible values - */ -typedef enum { - SPA_PROP_RANGE_TYPE_NONE = 0, - SPA_PROP_RANGE_TYPE_MIN_MAX, - SPA_PROP_RANGE_TYPE_STEP, - SPA_PROP_RANGE_TYPE_ENUM, - SPA_PROP_RANGE_TYPE_FLAGS, -} SpaPropRangeType; - -/** - * SpaPropValue: - * @size: the property size - * @value: the property value. - * - * The structure to set and get properties. - */ -typedef struct { - size_t size; - const void *value; -} SpaPropValue; - -/** - * SpaPropRangeInfo: - * @name: name of this value - * @val: the value - */ -typedef struct { - const char *name; - SpaPropValue val; -} SpaPropRangeInfo; - -/** - * SpaPropInfo: - * @id: unique id - * @offset: offset in structure with data - * @name: human readable name - * @flags: property flags - * @type: property type - * @max_size: maximum size of property value - * @range_type: type of the range values - * @n_range_values: number of elements in @range_values - * @range_values: array of possible values - * @extra: extra info - */ -typedef struct { - uint32_t id; - size_t offset; - const char *name; - SpaPropFlags flags; - SpaPropType type; - size_t maxsize; - SpaPropRangeType range_type; - unsigned int n_range_values; - const SpaPropRangeInfo *range_values; - SpaDict *extra; -} SpaPropInfo; - -/** - * SpaProps: - * @n_prop_info: number of elements in @prop_info - * @prop_info: array of #SpaPropInfo. Contains info about the - * properties. Can be %NULL when unspecified. - * @unset_mask: mask of unset properties. For each property in @prop_info there - * is a corresponding bit that specifies if the property is currently - * unset. When more than 32 properties are present, more uint32_t - * fields follow this one. - * - * Generic propertiers. - */ -struct _SpaProps { - unsigned int n_prop_info; - const SpaPropInfo *prop_info; - uint32_t unset_mask; -}; - -#define SPA_PROPS_INDEX_IS_UNSET(p,idx) ((&(p)->unset_mask)[(idx) >> 5] & (1U << ((idx) & 31))) -#define SPA_PROPS_INDEX_UNSET(p,idx) ((&(p)->unset_mask)[(idx) >> 5] |= (1U << ((idx) & 31))) -#define SPA_PROPS_INDEX_SET(p,idx) ((&(p)->unset_mask)[(idx) >> 5] &= ~(1U << ((idx) & 31))) - -static inline unsigned int -spa_props_index_for_id (const SpaProps *props, uint32_t id) +static inline off_t +spa_pod_builder_push_props (SpaPODBuilder *builder, + SpaPODFrame *frame) { - unsigned int i; - - for (i = 0; i < props->n_prop_info; i++) { - if (props->prop_info[i].id == id) - return i; - } - return SPA_IDX_INVALID; + return spa_pod_builder_push_object (builder, frame, 0, 0); } -static inline unsigned int -spa_props_index_for_name (const SpaProps *props, const char *name) +static inline off_t +spa_pod_builder_props (SpaPODBuilder *builder, + uint32_t propid, ...) { - unsigned int i; + SpaPODFrame f; + va_list args; + off_t off; - for (i = 0; i < props->n_prop_info; i++) { - if (strcmp (props->prop_info[i].name, name) == 0) - return i; - } - return SPA_IDX_INVALID; + off = spa_pod_builder_push_props (builder, &f); + + va_start (args, propid); + spa_pod_builder_propv (builder, propid, args); + va_end (args); + + spa_pod_builder_pop (builder, &f); + + return off; } #ifdef __cplusplus diff --git a/spa/lib/audio-raw.c b/spa/lib/audio-raw.c index 3bdcefbf5..0a85cb3b4 100644 --- a/spa/lib/audio-raw.c +++ b/spa/lib/audio-raw.c @@ -60,10 +60,13 @@ spa_format_audio_parse (const SpaFormat *format, SpaPODProp *prop; const ParseInfo *pinfo, *find; - if (format->body.media_type != SPA_MEDIA_TYPE_AUDIO) + if (format->body.media_type.value != SPA_MEDIA_TYPE_AUDIO) return SPA_RESULT_INVALID_MEDIA_TYPE; - switch (format->body.media_subtype) { + info->media_type = format->body.media_type.value; + info->media_subtype = format->body.media_subtype.value; + + switch (info->media_subtype) { case SPA_MEDIA_SUBTYPE_RAW: pinfo = raw_parse_info; break; @@ -85,9 +88,6 @@ spa_format_audio_parse (const SpaFormat *format, return SPA_RESULT_INVALID_ARGUMENTS; } - info->media_type = format->body.media_type; - info->media_subtype = format->body.media_subtype; - SPA_POD_FOREACH (format, prop) { if ((find = parse_info_find (pinfo, prop->body.key, prop->body.value.type))) { memcpy (SPA_MEMBER (info, find->offset, void), diff --git a/spa/lib/debug.c b/spa/lib/debug.c index 0b316116c..d00f52c17 100644 --- a/spa/lib/debug.c +++ b/spa/lib/debug.c @@ -227,6 +227,7 @@ spa_debug_dump_mem (const void *mem, size_t size) SpaResult spa_debug_props (const SpaProps *props, bool print_ranges) { + spa_debug_pod (&props->pod); return SPA_RESULT_OK; } @@ -352,7 +353,7 @@ print_pod_value (uint32_t size, uint32_t type, void *body, int prefix) printf ("%-*sDouble %g\n", prefix, "", *(double *) body); break; case SPA_POD_TYPE_STRING: - printf ("%-*sString %s\n", prefix, "", (char *) body); + printf ("%-*sString \"%s\"\n", prefix, "", (char *) body); break; case SPA_POD_TYPE_RECTANGLE: { @@ -419,17 +420,6 @@ print_pod_value (uint32_t size, uint32_t type, void *body, int prefix) } break; } - case SPA_POD_TYPE_FORMAT: - { - SpaFormatBody *b = body; - SpaPODProp *p; - - printf ("%-*sFormat: size %d\n", prefix, "", size); - printf ("%-*s Media Type: %d / %d\n", prefix, "", b->media_type, b->media_subtype); - SPA_FORMAT_BODY_FOREACH (b, size, p) - print_pod_value (p->pod.size, p->pod.type, SPA_POD_BODY (p), prefix + 6); - break; - } } } @@ -491,16 +481,20 @@ spa_debug_format (const SpaFormat *format) const char *media_subtype; const char **prop_names; SpaPODProp *prop; + uint32_t mtype, mstype; if (format == NULL) return SPA_RESULT_INVALID_ARGUMENTS; - if (format->body.media_type > 0 && format->body.media_type < SPA_N_ELEMENTS (media_type_names)) { - media_type = media_type_names[format->body.media_type].name; - first = media_type_names[format->body.media_type].first; - last = media_type_names[format->body.media_type].last; - idx = media_type_names[format->body.media_type].idx; - prop_names = media_type_names[format->body.media_type].prop_names; + mtype = format->body.media_type.value; + mstype = format->body.media_subtype.value; + + if (mtype > 0 && mtype < SPA_N_ELEMENTS (media_type_names)) { + media_type = media_type_names[mtype].name; + first = media_type_names[mtype].first; + last = media_type_names[mtype].last; + idx = media_type_names[mtype].idx; + prop_names = media_type_names[mtype].prop_names; } else { media_type = "unknown"; @@ -508,11 +502,11 @@ spa_debug_format (const SpaFormat *format) prop_names = NULL; } - if (format->body.media_subtype >= SPA_MEDIA_SUBTYPE_ANY_FIRST && - format->body.media_subtype <= SPA_MEDIA_SUBTYPE_ANY_LAST) { - media_subtype = media_subtype_names[format->body.media_subtype].name; - } else if (format->body.media_subtype >= first && format->body.media_subtype <= last) - media_subtype = media_subtype_names[format->body.media_subtype - first + idx].name; + if (mstype >= SPA_MEDIA_SUBTYPE_ANY_FIRST && + mstype <= SPA_MEDIA_SUBTYPE_ANY_LAST) { + media_subtype = media_subtype_names[mstype].name; + } else if (mstype >= first && mstype <= last) + media_subtype = media_subtype_names[mstype - first + idx].name; else media_subtype = "unknown"; diff --git a/spa/lib/meson.build b/spa/lib/meson.build index 582bd4bd8..e88930e5d 100644 --- a/spa/lib/meson.build +++ b/spa/lib/meson.build @@ -1,7 +1,6 @@ spalib_sources = ['audio-raw.c', 'debug.c', 'mapper.c', - 'props.c', 'video-raw.c'] spalib = shared_library('spa-lib', diff --git a/spa/lib/props.h b/spa/lib/props.h index fdb7c79e7..a840258d8 100644 --- a/spa/lib/props.h +++ b/spa/lib/props.h @@ -26,42 +26,6 @@ extern "C" { #include -/** - * spa_props_set_value: - * @props: a #SpaProps - * @index: the index of the property in the prop_info array - * @value: the value to set - * - * Sets @value in @prop. type should match the type specified - * in the #SpaPropInfo at @index or else #SPA_RESULT_WRONG_PROPERTY_TYPE - * is returned. - * - * Returns: #SPA_RESULT_OK on success. - * #SPA_RESULT_INVALID_PROPERTY_INDEX when @index is not valid - * #SPA_RESULT_WRONG_PROPERTY_TYPE when type is not correct - */ -SpaResult spa_props_set_value (SpaProps *props, - unsigned int index, - const SpaPropValue *value); -/** - * spa_props_get_value: - * @props: a #SpaProps - * @index: the property index in the prop_info array - * @value: a location for the type, size and value - * - * Get the size and value of the property at @index. - * - * Returns: #SPA_RESULT_OK on success. - * #SPA_RESULT_INVALID_PROPERTY_INDEX when @index is not valid - * #SPA_RESULT_PROPERTY_UNSET when no value has been set yet - */ -SpaResult spa_props_get_value (const SpaProps *props, - unsigned int index, - SpaPropValue *value); - -SpaResult spa_props_copy_values (const SpaProps *src, - SpaProps *dest); - #ifdef __cplusplus } /* extern "C" */ #endif diff --git a/spa/lib/video-raw.c b/spa/lib/video-raw.c index be77240b8..fb97cbb42 100644 --- a/spa/lib/video-raw.c +++ b/spa/lib/video-raw.c @@ -85,10 +85,13 @@ spa_format_video_parse (const SpaFormat *format, SpaPODProp *prop; const ParseInfo *pinfo, *find; - if (format->body.media_type != SPA_MEDIA_TYPE_VIDEO) + if (format->body.media_type.value != SPA_MEDIA_TYPE_VIDEO) return SPA_RESULT_INVALID_MEDIA_TYPE; - switch (format->body.media_subtype) { + info->media_type = format->body.media_type.value; + info->media_subtype = format->body.media_subtype.value; + + switch (info->media_subtype) { case SPA_MEDIA_SUBTYPE_RAW: pinfo = raw_parse_info; break; @@ -116,9 +119,6 @@ spa_format_video_parse (const SpaFormat *format, return SPA_RESULT_INVALID_ARGUMENTS; } - info->media_type = format->body.media_type; - info->media_subtype = format->body.media_subtype; - SPA_POD_FOREACH (format, prop) { if ((find = parse_info_find (pinfo, prop->body.key, prop->body.value.type))) { memcpy (SPA_MEMBER (info, find->offset, void), @@ -142,8 +142,8 @@ spa_format_filter (const SpaFormat *format, return SPA_RESULT_OK; } - if (filter->body.media_type != format->body.media_type || - filter->body.media_subtype != format->body.media_subtype) + if (filter->body.media_type.value != format->body.media_type.value || + filter->body.media_subtype.value != format->body.media_subtype.value) return SPA_RESULT_INVALID_MEDIA_TYPE; spa_pod_builder_raw (result, format, SPA_POD_SIZE (format), true); diff --git a/spa/plugins/alsa/alsa-sink.c b/spa/plugins/alsa/alsa-sink.c index f369ff257..2ed5d6f85 100644 --- a/spa/plugins/alsa/alsa-sink.c +++ b/spa/plugins/alsa/alsa-sink.c @@ -52,6 +52,7 @@ update_state (SpaALSASink *this, SpaNodeState state) this->node.state = state; } +#if 0 static const uint32_t min_uint32 = 1; static const uint32_t max_uint32 = UINT32_MAX; @@ -109,6 +110,7 @@ static const SpaPropInfo prop_info[] = SPA_PROP_RANGE_TYPE_NONE, 0, NULL, NULL }, }; +#endif static SpaResult spa_alsa_sink_node_get_props (SpaNode *node, @@ -146,7 +148,7 @@ spa_alsa_sink_node_set_props (SpaNode *node, return SPA_RESULT_OK; } - res = spa_props_copy_values (props, &p->props); + //res = spa_props_copy_values (props, &p->props); return res; } @@ -829,8 +831,10 @@ alsa_sink_init (const SpaHandleFactory *factory, this->uri.node = spa_id_map_get_id (this->map, SPA_NODE_URI); this->node = alsasink_node; +#if 0 this->props[1].props.n_prop_info = PROP_ID_LAST; this->props[1].props.prop_info = prop_info; +#endif this->stream = SND_PCM_STREAM_PLAYBACK; reset_alsa_sink_props (&this->props[1]); @@ -839,7 +843,7 @@ alsa_sink_init (const SpaHandleFactory *factory, for (i = 0; info && i < info->n_items; i++) { if (!strcmp (info->items[i].key, "alsa.card")) { snprintf (this->props[1].device, 63, "hw:%s", info->items[i].value); - this->props[1].props.unset_mask &= ~1; +// this->props[1].props.unset_mask &= ~1; } } diff --git a/spa/plugins/alsa/alsa-source.c b/spa/plugins/alsa/alsa-source.c index 3f0443587..2b6eb7980 100644 --- a/spa/plugins/alsa/alsa-source.c +++ b/spa/plugins/alsa/alsa-source.c @@ -50,9 +50,9 @@ reset_alsa_props (SpaALSAProps *props) props->period_size = default_period_size; props->periods = default_periods; props->period_event = default_period_event; - props->props.unset_mask = 0xf; } +#if 0 static const uint32_t min_uint32 = 1; static const uint32_t max_uint32 = UINT32_MAX; @@ -110,6 +110,7 @@ static const SpaPropInfo prop_info[] = SPA_PROP_RANGE_TYPE_NONE, 0, NULL, NULL }, }; +#endif static SpaResult spa_alsa_source_node_get_props (SpaNode *node, @@ -147,7 +148,7 @@ spa_alsa_source_node_set_props (SpaNode *node, return SPA_RESULT_OK; } - res = spa_props_copy_values (props, &p->props); + //res = spa_props_copy_values (props, &p->props); return res; } @@ -896,8 +897,10 @@ alsa_source_init (const SpaHandleFactory *factory, this->node = alsasource_node; this->clock = alsasource_clock; +#if 0 this->props[1].props.n_prop_info = PROP_ID_LAST; this->props[1].props.prop_info = prop_info; +#endif this->stream = SND_PCM_STREAM_CAPTURE; reset_alsa_props (&this->props[1]); @@ -907,7 +910,7 @@ alsa_source_init (const SpaHandleFactory *factory, for (i = 0; info && i < info->n_items; i++) { if (!strcmp (info->items[i].key, "alsa.card")) { snprintf (this->props[1].device, 63, "hw:%s", info->items[i].value); - this->props[1].props.unset_mask &= ~1; +// this->props[1].props.unset_mask &= ~1; } } diff --git a/spa/plugins/audiomixer/audiomixer.c b/spa/plugins/audiomixer/audiomixer.c index ce7e1347b..0ed305095 100644 --- a/spa/plugins/audiomixer/audiomixer.c +++ b/spa/plugins/audiomixer/audiomixer.c @@ -97,11 +97,6 @@ enum { PROP_ID_LAST, }; -static const SpaPropInfo prop_info[] = -{ - { PROP_ID_LAST, }, -}; - static void reset_audiomixer_props (SpaAudioMixerProps *props) { @@ -119,7 +114,6 @@ spa_audiomixer_node_get_props (SpaNode *node, this = SPA_CONTAINER_OF (node, SpaAudioMixer, node); memcpy (&this->props[0], &this->props[1], sizeof (this->props[1])); - *props = &this->props[0].props; return SPA_RESULT_OK; } @@ -142,7 +136,6 @@ spa_audiomixer_node_set_props (SpaNode *node, reset_audiomixer_props (p); return SPA_RESULT_OK; } - res = spa_props_copy_values (props, &p->props); return res; } @@ -755,8 +748,10 @@ spa_audiomixer_init (const SpaHandleFactory *factory, this->uri.node = spa_id_map_get_id (this->map, SPA_NODE_URI); this->node = audiomixer_node; +#if 0 this->props[1].props.n_prop_info = PROP_ID_LAST; this->props[1].props.prop_info = prop_info; +#endif reset_audiomixer_props (&this->props[1]); this->out_ports[0].valid = true; diff --git a/spa/plugins/audiotestsrc/audiotestsrc.c b/spa/plugins/audiotestsrc/audiotestsrc.c index 5f8e24744..60a7e5cd7 100644 --- a/spa/plugins/audiotestsrc/audiotestsrc.c +++ b/spa/plugins/audiotestsrc/audiotestsrc.c @@ -111,19 +111,20 @@ struct _SpaAudioTestSrc { #define DEFAULT_FREQ 440.0 #define DEFAULT_LIVE true +#if 0 static const double min_volume = 0.0; static const double max_volume = 10.0; static const double min_freq = 0.0; static const double max_freq = 50000000.0; +static const uint32_t wave_val_sine = 0; +static const uint32_t wave_val_square = 1; + static const SpaPropRangeInfo volume_range[] = { { "min", { sizeof (double), &min_volume } }, { "max", { sizeof (double), &max_volume } }, }; -static const uint32_t wave_val_sine = 0; -static const uint32_t wave_val_square = 1; - static const SpaPropRangeInfo wave_range[] = { { "sine", { sizeof (uint32_t), &wave_val_sine } }, { "square", { sizeof (uint32_t), &wave_val_square } }, @@ -169,6 +170,7 @@ static const SpaPropInfo prop_info[] = SPA_PROP_RANGE_TYPE_MIN_MAX, 2, volume_range, NULL }, }; +#endif static SpaResult reset_audiotestsrc_props (SpaAudioTestSrcProps *props) @@ -193,7 +195,6 @@ spa_audiotestsrc_node_get_props (SpaNode *node, this = SPA_CONTAINER_OF (node, SpaAudioTestSrc, node); memcpy (&this->props[0], &this->props[1], sizeof (this->props[1])); - *props = &this->props[0].props; return SPA_RESULT_OK; } @@ -215,7 +216,7 @@ spa_audiotestsrc_node_set_props (SpaNode *node, if (props == NULL) { res = reset_audiotestsrc_props (p); } else { - res = spa_props_copy_values (props, &p->props); +// res = spa_props_copy_values (props, &p->props); } if (this->props[1].live) @@ -988,8 +989,10 @@ audiotestsrc_init (const SpaHandleFactory *factory, this->node = audiotestsrc_node; this->clock = audiotestsrc_clock; +#if 0 this->props[1].props.n_prop_info = PROP_ID_LAST; this->props[1].props.prop_info = prop_info; +#endif reset_audiotestsrc_props (&this->props[1]); spa_list_init (&this->empty); diff --git a/spa/plugins/ffmpeg/ffmpeg-dec.c b/spa/plugins/ffmpeg/ffmpeg-dec.c index 5c7680431..1a4a117da 100644 --- a/spa/plugins/ffmpeg/ffmpeg-dec.c +++ b/spa/plugins/ffmpeg/ffmpeg-dec.c @@ -87,11 +87,6 @@ enum { PROP_ID_LAST, }; -static const SpaPropInfo prop_info[] = -{ - { 0, }, -}; - static SpaResult spa_ffmpeg_dec_node_get_props (SpaNode *node, SpaProps **props) @@ -128,7 +123,7 @@ spa_ffmpeg_dec_node_set_props (SpaNode *node, return SPA_RESULT_OK; } - res = spa_props_copy_values (props, &p->props); + //res = spa_props_copy_values (props, &p->props); return res; } @@ -581,8 +576,10 @@ spa_ffmpeg_dec_init (SpaHandle *handle, this->uri.node = spa_id_map_get_id (this->map, SPA_NODE_URI); this->node = ffmpeg_dec_node; +#if 0 this->props[1].props.n_prop_info = PROP_ID_LAST; this->props[1].props.prop_info = prop_info; +#endif reset_ffmpeg_dec_props (&this->props[1]); this->in_ports[0].info.flags = SPA_PORT_INFO_FLAG_NONE; diff --git a/spa/plugins/ffmpeg/ffmpeg-enc.c b/spa/plugins/ffmpeg/ffmpeg-enc.c index 584ebefc1..72722324e 100644 --- a/spa/plugins/ffmpeg/ffmpeg-enc.c +++ b/spa/plugins/ffmpeg/ffmpeg-enc.c @@ -91,11 +91,6 @@ enum { PROP_ID_LAST, }; -static const SpaPropInfo prop_info[] = -{ - { 0, }, -}; - static void update_state (SpaFFMpegEnc *this, SpaNodeState state) { @@ -138,7 +133,7 @@ spa_ffmpeg_enc_node_set_props (SpaNode *node, return SPA_RESULT_OK; } - res = spa_props_copy_values (props, &p->props); + //res = spa_props_copy_values (props, &p->props); return res; } @@ -308,8 +303,8 @@ spa_ffmpeg_enc_node_port_set_format (SpaNode *node, return SPA_RESULT_OK; } - if (format->body.media_type != SPA_MEDIA_TYPE_VIDEO || - format->body.media_subtype != SPA_MEDIA_SUBTYPE_RAW) + if (format->body.media_type.value != SPA_MEDIA_TYPE_VIDEO || + format->body.media_subtype.value != SPA_MEDIA_SUBTYPE_RAW) return SPA_RESULT_INVALID_MEDIA_TYPE; if ((res = spa_format_video_parse (format, &port->format[0]) < 0)) @@ -588,8 +583,6 @@ spa_ffmpeg_enc_init (SpaHandle *handle, this->uri.node = spa_id_map_get_id (this->map, SPA_NODE_URI); this->node = ffmpeg_enc_node; - this->props[1].props.n_prop_info = PROP_ID_LAST; - this->props[1].props.prop_info = prop_info; reset_ffmpeg_enc_props (&this->props[1]); this->in_ports[0].info.flags = SPA_PORT_INFO_FLAG_NONE; diff --git a/spa/plugins/v4l2/v4l2-source.c b/spa/plugins/v4l2/v4l2-source.c index 57d9ca516..10a07d08a 100644 --- a/spa/plugins/v4l2/v4l2-source.c +++ b/spa/plugins/v4l2/v4l2-source.c @@ -39,7 +39,6 @@ typedef struct _SpaV4l2Source SpaV4l2Source; static const char default_device[] = "/dev/video0"; typedef struct { - SpaProps props; char device[64]; char device_name[128]; int device_fd; @@ -49,7 +48,6 @@ static void reset_v4l2_source_props (SpaV4l2SourceProps *props) { strncpy (props->device, default_device, 64); - props->props.unset_mask = 7; } #define MAX_BUFFERS 64 @@ -121,7 +119,8 @@ struct _SpaV4l2Source { uint32_t seq; - SpaV4l2SourceProps props[2]; + uint8_t props_buffer[512]; + SpaV4l2SourceProps props; SpaNodeEventCallback event_cb; void *user_data; @@ -140,32 +139,10 @@ update_state (SpaV4l2Source *this, SpaNodeState state) #include "v4l2-utils.c" enum { + PROP_ID_NONE, PROP_ID_DEVICE, PROP_ID_DEVICE_NAME, PROP_ID_DEVICE_FD, - PROP_ID_LAST, -}; - -static const SpaPropInfo prop_info[] = -{ - { PROP_ID_DEVICE, offsetof (SpaV4l2SourceProps, device), - "device", - SPA_PROP_FLAG_READWRITE, - SPA_PROP_TYPE_STRING, 63, - SPA_PROP_RANGE_TYPE_NONE, 0, NULL, - NULL }, - { PROP_ID_DEVICE_NAME, offsetof (SpaV4l2SourceProps, device_name), - "device-name", - SPA_PROP_FLAG_READABLE, - SPA_PROP_TYPE_STRING, 127, - SPA_PROP_RANGE_TYPE_NONE, 0, NULL, - NULL }, - { PROP_ID_DEVICE_FD, offsetof (SpaV4l2SourceProps, device_fd), - "device-fd", - SPA_PROP_FLAG_READABLE, - SPA_PROP_TYPE_UINT32, sizeof (uint32_t), - SPA_PROP_RANGE_TYPE_NONE, 0, NULL, - NULL }, }; static SpaResult @@ -173,14 +150,33 @@ spa_v4l2_source_node_get_props (SpaNode *node, SpaProps **props) { SpaV4l2Source *this; + SpaPODBuilder b = { NULL, }; if (node == NULL || props == NULL) return SPA_RESULT_INVALID_ARGUMENTS; this = SPA_CONTAINER_OF (node, SpaV4l2Source, node); - memcpy (&this->props[0], &this->props[1], sizeof (this->props[1])); - *props = &this->props[0].props; + b.data = this->props_buffer; + b.size = sizeof (this->props_buffer); + + *props = SPA_MEMBER (b.data, spa_pod_builder_props (&b, + + PROP_ID_DEVICE, SPA_POD_TYPE_STRING, + this->props.device, sizeof (this->props.device), + SPA_POD_PROP_FLAG_READWRITE | + SPA_POD_PROP_RANGE_NONE, + + PROP_ID_DEVICE_NAME, SPA_POD_TYPE_STRING, + this->props.device_name, sizeof (this->props.device_name), + SPA_POD_PROP_FLAG_READABLE | + SPA_POD_PROP_RANGE_NONE, + + PROP_ID_DEVICE_FD, SPA_POD_TYPE_INT, + this->props.device_fd, + SPA_POD_PROP_FLAG_READABLE | + SPA_POD_PROP_RANGE_NONE, + 0), SpaProps); return SPA_RESULT_OK; } @@ -190,23 +186,27 @@ spa_v4l2_source_node_set_props (SpaNode *node, const SpaProps *props) { SpaV4l2Source *this; - SpaV4l2SourceProps *p; - SpaResult res; if (node == NULL) return SPA_RESULT_INVALID_ARGUMENTS; this = SPA_CONTAINER_OF (node, SpaV4l2Source, node); - p = &this->props[1]; if (props == NULL) { - reset_v4l2_source_props (p); + reset_v4l2_source_props (&this->props); return SPA_RESULT_OK; + } else { + SpaPODProp *pr; + + SPA_POD_OBJECT_BODY_FOREACH (&props->body, props->pod.size, pr) { + switch (pr->body.key) { + case PROP_ID_DEVICE: + strncpy (this->props.device, SPA_POD_CONTENTS (SpaPODProp, pr), 63); + break; + } + } } - - res = spa_props_copy_values (props, &p->props); - - return res; + return SPA_RESULT_OK; } static SpaResult @@ -961,9 +961,8 @@ v4l2_source_init (const SpaHandleFactory *factory, this->node = v4l2source_node; this->clock = v4l2source_clock; - this->props[1].props.n_prop_info = PROP_ID_LAST; - this->props[1].props.prop_info = prop_info; - reset_v4l2_source_props (&this->props[1]); + + reset_v4l2_source_props (&this->props); this->state[0].log = this->log; this->state[0].info.flags = SPA_PORT_INFO_FLAG_LIVE; @@ -971,10 +970,8 @@ v4l2_source_init (const SpaHandleFactory *factory, this->state[0].export_buf = true; if (info && (str = spa_dict_lookup (info, "device.path"))) { - strncpy (this->props[1].device, str, 63); - this->props[1].props.unset_mask &= ~1; + strncpy (this->props.device, str, 63); } - this->props[1].props.unset_mask &= ~1; update_state (this, SPA_NODE_STATE_CONFIGURE); diff --git a/spa/plugins/v4l2/v4l2-utils.c b/spa/plugins/v4l2/v4l2-utils.c index c1b8643c2..c7c6c8dac 100644 --- a/spa/plugins/v4l2/v4l2-utils.c +++ b/spa/plugins/v4l2/v4l2-utils.c @@ -28,12 +28,12 @@ spa_v4l2_open (SpaV4l2Source *this) { SpaV4l2State *state = &this->state[0]; struct stat st; - SpaV4l2SourceProps *props = &this->props[1]; + SpaV4l2SourceProps *props = &this->props; if (state->opened) return 0; - if (props->props.unset_mask & 1) { + if (props->device[0] == '\0') { spa_log_error (state->log, "v4l2: Device property not set"); return -1; } @@ -326,9 +326,9 @@ enum_filter_format (const SpaFormat *filter, unsigned int index) { SpaVideoFormat video_format = SPA_VIDEO_FORMAT_UNKNOWN; - if ((filter->body.media_type == SPA_MEDIA_TYPE_VIDEO || - filter->body.media_type == SPA_MEDIA_TYPE_IMAGE)) { - if (filter->body.media_subtype == SPA_MEDIA_SUBTYPE_RAW) { + if ((filter->body.media_type.value == SPA_MEDIA_TYPE_VIDEO || + filter->body.media_type.value == SPA_MEDIA_TYPE_IMAGE)) { + if (filter->body.media_subtype.value == SPA_MEDIA_SUBTYPE_RAW) { SpaPODProp *p; unsigned int n_values; const uint32_t *values; @@ -488,8 +488,8 @@ next_fmtdesc: if (video_format == SPA_VIDEO_FORMAT_UNKNOWN) return SPA_RESULT_ENUM_END; - info = find_format_info_by_media_type (filter->body.media_type, - filter->body.media_subtype, + info = find_format_info_by_media_type (filter->body.media_type.value, + filter->body.media_subtype.value, video_format, 0); if (info == NULL) @@ -562,12 +562,12 @@ do_frmsize: &values[2], &step)) goto have_size; - } else if (range == SPA_PROP_RANGE_TYPE_STEP && n_values > 3) { + } else if (range == SPA_POD_PROP_RANGE_STEP && n_values > 3) { if (filter_framesize (&state->frmsize, &values[1], &values[2], &values[3])) goto have_size; - } else if (range == SPA_PROP_RANGE_TYPE_ENUM) { + } else if (range == SPA_POD_PROP_RANGE_ENUM) { for (i = 1; i < n_values; i++) { if (filter_framesize (&state->frmsize, &values[i], &values[i], @@ -668,17 +668,17 @@ have_size: &values[0], &step)) goto have_framerate; - } else if (range == SPA_PROP_RANGE_TYPE_MIN_MAX && n_values > 2) { + } else if (range == SPA_POD_PROP_RANGE_MIN_MAX && n_values > 2) { if (filter_framerate (&state->frmival, &values[1], &values[2], &step)) goto have_framerate; - } else if (range == SPA_PROP_RANGE_TYPE_STEP && n_values > 3) { + } else if (range == SPA_POD_PROP_RANGE_STEP && n_values > 3) { if (filter_framerate (&state->frmival, &values[1], &values[2], &values[3])) goto have_framerate; - } else if (range == SPA_PROP_RANGE_TYPE_ENUM) { + } else if (range == SPA_POD_PROP_RANGE_ENUM) { for (i = 1; i < n_values; i++) { if (filter_framerate (&state->frmival, &values[i], &values[i], @@ -693,7 +693,7 @@ have_size: have_framerate: if (state->frmival.type == V4L2_FRMIVAL_TYPE_DISCRETE) { - prop->body.flags |= SPA_PROP_RANGE_TYPE_ENUM; + prop->body.flags |= SPA_POD_PROP_RANGE_ENUM; spa_pod_builder_fraction (&b, state->frmival.discrete.denominator, state->frmival.discrete.numerator); @@ -708,9 +708,9 @@ have_framerate: state->frmival.stepwise.max.numerator); if (state->frmival.type == V4L2_FRMIVAL_TYPE_CONTINUOUS) { - prop->body.flags |= SPA_PROP_RANGE_TYPE_MIN_MAX; + prop->body.flags |= SPA_POD_PROP_RANGE_MIN_MAX; } else { - prop->body.flags |= SPA_PROP_RANGE_TYPE_STEP; + prop->body.flags |= SPA_POD_PROP_RANGE_STEP; spa_pod_builder_fraction (&b, state->frmival.stepwise.step.denominator, state->frmival.stepwise.step.numerator); diff --git a/spa/plugins/videotestsrc/draw.c b/spa/plugins/videotestsrc/draw.c index 73c8e7c70..f7563e38f 100644 --- a/spa/plugins/videotestsrc/draw.c +++ b/spa/plugins/videotestsrc/draw.c @@ -283,7 +283,7 @@ draw (SpaVideoTestSrc *this, char *data) if (res != SPA_RESULT_OK) return res; - pattern = this->props[1].pattern; + pattern = this->props.pattern; if (pattern == pattern_val_smpte_snow) draw_smpte_snow (&dd); else if (pattern == pattern_val_snow) diff --git a/spa/plugins/videotestsrc/videotestsrc.c b/spa/plugins/videotestsrc/videotestsrc.c index dc9729349..ff5fd8c18 100644 --- a/spa/plugins/videotestsrc/videotestsrc.c +++ b/spa/plugins/videotestsrc/videotestsrc.c @@ -44,7 +44,6 @@ typedef struct { typedef struct _SpaVideoTestSrc SpaVideoTestSrc; typedef struct { - SpaProps props; bool live; uint32_t pattern; } SpaVideoTestSrcProps; @@ -72,7 +71,8 @@ struct _SpaVideoTestSrc { SpaLog *log; SpaLoop *data_loop; - SpaVideoTestSrcProps props[2]; + SpaVideoTestSrcProps props; + uint8_t props_buffer[256]; SpaNodeEventCallback event_cb; void *user_data; @@ -110,17 +110,18 @@ struct _SpaVideoTestSrc { static const uint32_t pattern_val_smpte_snow = 0; static const uint32_t pattern_val_snow = 1; +enum { + PROP_ID_NONE = 0, + PROP_ID_LIVE, + PROP_ID_PATTERN, +}; + +#if 0 static const SpaPropRangeInfo pattern_range[] = { { "smpte-snow", { sizeof (uint32_t), &pattern_val_smpte_snow } }, { "snow", { sizeof (uint32_t), &pattern_val_snow } }, }; -enum { - PROP_ID_LIVE, - PROP_ID_PATTERN, - PROP_ID_LAST, -}; - static const SpaPropInfo prop_info[] = { { PROP_ID_LIVE, offsetof (SpaVideoTestSrcProps, live), @@ -136,6 +137,7 @@ static const SpaPropInfo prop_info[] = SPA_PROP_RANGE_TYPE_ENUM, SPA_N_ELEMENTS (pattern_range), pattern_range, NULL }, }; +#endif static SpaResult reset_videotestsrc_props (SpaVideoTestSrcProps *props) @@ -151,14 +153,28 @@ spa_videotestsrc_node_get_props (SpaNode *node, SpaProps **props) { SpaVideoTestSrc *this; + SpaPODBuilder b = { NULL, }; if (node == NULL || props == NULL) return SPA_RESULT_INVALID_ARGUMENTS; this = SPA_CONTAINER_OF (node, SpaVideoTestSrc, node); - memcpy (&this->props[0], &this->props[1], sizeof (this->props[1])); - *props = &this->props[0].props; + b.data = this->props_buffer; + b.size = sizeof (this->props_buffer); + + *props = SPA_MEMBER (b.data, spa_pod_builder_props (&b, + PROP_ID_LIVE, SPA_POD_TYPE_BOOL, + this->props.live, + SPA_POD_PROP_FLAG_READWRITE | + SPA_POD_PROP_RANGE_NONE, + PROP_ID_PATTERN, SPA_POD_TYPE_INT, + this->props.pattern, + SPA_POD_PROP_FLAG_READWRITE | + SPA_POD_PROP_RANGE_ENUM, 2, + pattern_val_smpte_snow, + pattern_val_snow, + 0), SpaProps); return SPA_RESULT_OK; } @@ -175,15 +191,26 @@ spa_videotestsrc_node_set_props (SpaNode *node, return SPA_RESULT_INVALID_ARGUMENTS; this = SPA_CONTAINER_OF (node, SpaVideoTestSrc, node); - p = &this->props[1]; + p = &this->props; if (props == NULL) { res = reset_videotestsrc_props (p); } else { - res = spa_props_copy_values (props, &p->props); + SpaPODProp *pr; + + SPA_POD_OBJECT_BODY_FOREACH(&props->body, props->pod.size, pr) { + switch (pr->body.key) { + case PROP_ID_LIVE: + this->props.live = ((SpaPODBool*)&pr->body.value)->value; + break; + case PROP_ID_PATTERN: + this->props.pattern = ((SpaPODInt*)&pr->body.value)->value; + break; + } + } } - if (this->props[1].live) + if (this->props.live) this->info.flags |= SPA_PORT_INFO_FLAG_LIVE; else this->info.flags &= ~SPA_PORT_INFO_FLAG_LIVE; @@ -217,7 +244,7 @@ static void set_timer (SpaVideoTestSrc *this, bool enabled) { if (enabled) { - if (this->props[1].live) { + if (this->props.live) { uint64_t next_time = this->start_time + this->elapsed_time; this->timerspec.it_value.tv_sec = next_time / SPA_NSEC_PER_SEC; this->timerspec.it_value.tv_nsec = next_time % SPA_NSEC_PER_SEC; @@ -305,7 +332,7 @@ spa_videotestsrc_node_send_command (SpaNode *node, return SPA_RESULT_OK; clock_gettime (CLOCK_MONOTONIC, &now); - if (this->props[1].live) + if (this->props.live) this->start_time = SPA_TIMESPEC_TO_TIME (&now); else this->start_time = 0; @@ -782,7 +809,7 @@ spa_videotestsrc_node_port_reuse_buffer (SpaNode *node, b->outstanding = false; spa_list_insert (this->empty.prev, &b->link); - if (!this->props[1].live) + if (!this->props.live) set_timer (this, true); return SPA_RESULT_OK; @@ -962,9 +989,11 @@ videotestsrc_init (const SpaHandleFactory *factory, this->node = videotestsrc_node; this->clock = videotestsrc_clock; +#if 0 this->props[1].props.n_prop_info = PROP_ID_LAST; this->props[1].props.prop_info = prop_info; - reset_videotestsrc_props (&this->props[1]); +#endif + reset_videotestsrc_props (&this->props); spa_list_init (&this->empty); @@ -980,7 +1009,7 @@ videotestsrc_init (const SpaHandleFactory *factory, this->info.flags = SPA_PORT_INFO_FLAG_CAN_USE_BUFFERS | SPA_PORT_INFO_FLAG_NO_REF; - if (this->props[1].live) + if (this->props.live) this->info.flags |= SPA_PORT_INFO_FLAG_LIVE; this->node.state = SPA_NODE_STATE_CONFIGURE; diff --git a/spa/plugins/volume/volume.c b/spa/plugins/volume/volume.c index 6e2398ef0..32e28a0e5 100644 --- a/spa/plugins/volume/volume.c +++ b/spa/plugins/volume/volume.c @@ -91,9 +91,11 @@ struct _SpaVolume { #define CHECK_PORT(this,d,p) ((p) == 0) static const double default_volume = 1.0; +static const bool default_mute = false; + +#if 0 static const double min_volume = 0.0; static const double max_volume = 10.0; -static const bool default_mute = false; static const SpaPropRangeInfo volume_range[] = { { "min", { sizeof (double), &min_volume } }, @@ -122,6 +124,8 @@ static const SpaPropInfo prop_info[] = NULL }, }; +#endif + static void reset_volume_props (SpaVolumeProps *props) { @@ -170,7 +174,7 @@ spa_volume_node_set_props (SpaNode *node, reset_volume_props (p); return SPA_RESULT_OK; } - res = spa_props_copy_values (props, &p->props); + //res = spa_props_copy_values (props, &p->props); return res; } @@ -848,8 +852,10 @@ volume_init (const SpaHandleFactory *factory, this->uri.node = spa_id_map_get_id (this->map, SPA_NODE_URI); this->node = volume_node; +#if 0 this->props[1].props.n_prop_info = PROP_ID_LAST; this->props[1].props.prop_info = prop_info; +#endif reset_volume_props (&this->props[1]); this->in_ports[0].info.flags = SPA_PORT_INFO_FLAG_CAN_USE_BUFFERS | diff --git a/spa/plugins/xv/xv-sink.c b/spa/plugins/xv/xv-sink.c index 05d5d0b5e..307155ca6 100644 --- a/spa/plugins/xv/xv-sink.c +++ b/spa/plugins/xv/xv-sink.c @@ -107,6 +107,7 @@ enum { PROP_ID_LAST, }; +#if 0 static const SpaPropInfo prop_info[] = { { PROP_ID_DEVICE, offsetof (SpaXvSinkProps, device), @@ -128,6 +129,7 @@ static const SpaPropInfo prop_info[] = SPA_PROP_RANGE_TYPE_NONE, 0, NULL, NULL }, }; +#endif static void update_state (SpaXvSink *this, SpaNodeState state) @@ -147,7 +149,6 @@ spa_xv_sink_node_get_props (SpaNode *node, this = SPA_CONTAINER_OF (node, SpaXvSink, node); memcpy (&this->props[0], &this->props[1], sizeof (this->props[1])); - *props = &this->props[0].props; return SPA_RESULT_OK; } @@ -170,9 +171,6 @@ spa_xv_sink_node_set_props (SpaNode *node, reset_xv_sink_props (p); return SPA_RESULT_OK; } - - res = spa_props_copy_values (props, &p->props); - return res; } @@ -337,8 +335,8 @@ spa_xv_sink_node_port_set_format (SpaNode *node, return SPA_RESULT_OK; } - if (format->body.media_type == SPA_MEDIA_TYPE_VIDEO) { - if (format->body.media_subtype == SPA_MEDIA_SUBTYPE_RAW) { + if (format->body.media_type.value == SPA_MEDIA_TYPE_VIDEO) { + if (format->body.media_subtype.value == SPA_MEDIA_SUBTYPE_RAW) { if ((res = spa_format_video_parse (format, &info) < 0)) return res; } else @@ -584,8 +582,10 @@ xv_sink_init (const SpaHandleFactory *factory, this->uri.node = spa_id_map_get_id (this->map, SPA_NODE_URI); this->node = xvsink_node; +#if 0 this->props[1].props.n_prop_info = PROP_ID_LAST; this->props[1].props.prop_info = prop_info; +#endif reset_xv_sink_props (&this->props[1]); this->info.flags = SPA_PORT_INFO_FLAG_NONE; diff --git a/spa/tests/test-props.c b/spa/tests/test-props.c index 4456efc1f..1137bb742 100644 --- a/spa/tests/test-props.c +++ b/spa/tests/test-props.c @@ -86,9 +86,10 @@ static const struct _test_format { } framerate_vals; } props; } test_format = { - { { sizeof (test_format.props) + sizeof (SpaFormatBody), SPA_POD_TYPE_FORMAT }, - { SPA_MEDIA_TYPE_VIDEO, - SPA_MEDIA_SUBTYPE_RAW }, + { { { sizeof (test_format.props) + sizeof (SpaFormatBody) + sizeof (SpaPODObjectBody), SPA_POD_TYPE_OBJECT }, + { 0, 0 } }, + { { { sizeof (uint32_t), SPA_POD_TYPE_INT }, SPA_MEDIA_TYPE_VIDEO }, + { { sizeof (uint32_t), SPA_POD_TYPE_INT }, SPA_MEDIA_SUBTYPE_RAW } }, }, { { { sizeof (test_format.props.format_vals) + sizeof (SpaPODPropBody), SPA_POD_TYPE_PROP } , @@ -156,7 +157,7 @@ main (int argc, char *argv[]) spa_pod_builder_pop (&b, &frame[0]); - spa_debug_pod (&fmt->pod); + spa_debug_pod (&fmt->obj.pod); memset (&b, 0, sizeof(b)); b.data = buffer; @@ -183,10 +184,10 @@ main (int argc, char *argv[]) 0); fmt = SPA_MEMBER (buffer, o, SpaFormat); - spa_debug_pod (&fmt->pod); + spa_debug_pod (&fmt->obj.pod); spa_debug_format (fmt); - spa_debug_pod (&test_format.fmt.pod); + spa_debug_pod (&test_format.fmt.obj.pod); spa_debug_format (&test_format.fmt); return 0;