Add h264 format

Improve format support
Remove the type from the value because we can find that from the
property info.
This commit is contained in:
Wim Taymans 2016-09-07 16:25:31 +02:00
parent 648e5a299b
commit 829adbab59
19 changed files with 363 additions and 309 deletions

View file

@ -191,8 +191,8 @@ convert_1 (GstCapsFeatures *cf, GstStructure *cs)
bri[ri].name = NULL;
bri[ri].description = NULL;
bri[ri].size = sizeof (SpaRectangle);
bri[ri].value = p;
bri[ri].val.size = sizeof (SpaRectangle);
bri[ri].val.value = p;
sv->width = gst_value_get_int_range_min (val);
sv->height = gst_value_get_int_range_min (val2);
p = ++sv;
@ -200,8 +200,8 @@ convert_1 (GstCapsFeatures *cf, GstStructure *cs)
bri[ri].name = NULL;
bri[ri].description = NULL;
bri[ri].size = sizeof (SpaRectangle);
bri[ri].value = p;
bri[ri].val.size = sizeof (SpaRectangle);
bri[ri].val.value = p;
sv->width = gst_value_get_int_range_max (val);
sv->height = gst_value_get_int_range_max (val2);
p = ++sv;
@ -248,8 +248,8 @@ convert_1 (GstCapsFeatures *cf, GstStructure *cs)
bri[ri].name = NULL;
bri[ri].description = NULL;
bri[ri].size = sizeof (SpaFraction);
bri[ri].value = p;
bri[ri].val.size = sizeof (SpaFraction);
bri[ri].val.value = p;
sv->num = gst_value_get_fraction_numerator (min);
sv->denom = gst_value_get_fraction_denominator (min);
p = ++sv;
@ -257,8 +257,8 @@ convert_1 (GstCapsFeatures *cf, GstStructure *cs)
bri[ri].name = NULL;
bri[ri].description = NULL;
bri[ri].size = sizeof (SpaFraction);
bri[ri].value = p;
bri[ri].val.size = sizeof (SpaFraction);
bri[ri].val.value = p;
sv->num = gst_value_get_fraction_numerator (max);
sv->denom = gst_value_get_fraction_denominator (max);
p = ++sv;
@ -380,6 +380,9 @@ convert_1 (GstCapsFeatures *cf, GstStructure *cs)
} else if (gst_structure_has_name (cs, "image/jpeg")) {
f->media_type = SPA_MEDIA_TYPE_VIDEO;
f->media_subtype = SPA_MEDIA_SUBTYPE_MJPG;
} else if (gst_structure_has_name (cs, "video/x-h264")) {
f->media_type = SPA_MEDIA_TYPE_VIDEO;
f->media_subtype = SPA_MEDIA_SUBTYPE_H264;
}
return f;
}
@ -437,7 +440,8 @@ gst_caps_from_format (SpaFormat *format)
if (format->media_type == SPA_MEDIA_TYPE_VIDEO) {
SpaFormatVideo f;
spa_format_video_parse (format, &f);
if (spa_format_video_parse (format, &f) < 0)
return NULL;
if (format->media_subtype == SPA_MEDIA_SUBTYPE_RAW) {
res = gst_caps_new_simple ("video/x-raw",
@ -454,10 +458,20 @@ gst_caps_from_format (SpaFormat *format)
"framerate", GST_TYPE_FRACTION, f.info.mjpg.framerate.num, f.info.mjpg.framerate.denom,
NULL);
}
else if (format->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,
"framerate", GST_TYPE_FRACTION, f.info.h264.framerate.num, f.info.h264.framerate.denom,
"stream-format", G_TYPE_STRING, "byte-stream",
"alignment", G_TYPE_STRING, "au",
NULL);
}
} else if (format->media_type == SPA_MEDIA_TYPE_AUDIO) {
SpaFormatAudio f;
spa_format_audio_parse (format, &f);
if (spa_format_audio_parse (format, &f) < 0)
return NULL;
if (format->media_subtype == SPA_MEDIA_SUBTYPE_RAW) {
res = gst_caps_new_simple ("audio/x-raw",

View file

@ -153,7 +153,6 @@ setup_node (PinosSpaAlsaSink *this)
if ((res = spa_node_get_props (node->node, &props)) < 0)
g_debug ("got get_props error %d", res);
value.type = SPA_PROP_TYPE_STRING;
value.value = "hw:1";
value.size = strlen (value.value)+1;
spa_props_set_prop (props, spa_props_index_for_name (props, "device"), &value);

View file

@ -94,7 +94,6 @@ setup_node (PinosSpaAudioTestSrc *this)
if ((res = spa_node_get_props (node->node, &props)) < 0)
g_debug ("got get_props error %d", res);
value.type = SPA_PROP_TYPE_STRING;
value.value = "hw:1";
value.size = strlen (value.value)+1;
spa_props_set_prop (props, spa_props_index_for_name (props, "device"), &value);

View file

@ -104,7 +104,6 @@ setup_node (PinosSpaV4l2Source *this)
if ((res = spa_node_get_props (node->node, &props)) < 0)
g_debug ("got get_props error %d", res);
value.type = SPA_PROP_TYPE_STRING;
value.value = "/dev/video1";
value.size = strlen (value.value)+1;
spa_props_set_prop (props, spa_props_index_for_name (props, "device"), &value);

View file

@ -138,7 +138,6 @@ pinos_client_node_get_socket_pair (PinosClientNode *this,
priv->fd = g_socket_get_fd (priv->sockets[0]);
spa_node_get_props (node->node, &props);
value.type = SPA_PROP_TYPE_INT;
value.value = &priv->fd;
value.size = sizeof (int);
spa_props_set_prop (props, spa_props_index_for_name (props, "socket"), &value);

View file

@ -97,18 +97,28 @@ typedef 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
* @description: user visible description of this value
* @size: the size of value
* @value: a possible value
* @val: the value
*/
typedef struct {
const char *name;
const char *description;
size_t size;
const void *value;
SpaPropValue val;
} SpaPropRangeInfo;
/**
@ -139,20 +149,6 @@ typedef struct {
const char **tags;
} SpaPropInfo;
/**
* SpaPropValue:
* @type: a property type
* @size: the property size
* @value: the property value.
*
* The structure to set and get properties.
*/
typedef struct {
SpaPropType type;
size_t size;
const void *value;
} SpaPropValue;
/**
* SpaProps:
* @n_prop_info: number of elements in @prop_info

View file

@ -24,11 +24,33 @@
extern "C" {
#endif
typedef struct _SpaVideoInfoH264 SpaVideoInfoH264;
typedef struct _SpaVideoInfoMJPG SpaVideoInfoMJPG;
#include <spa/format.h>
#include <spa/video/format.h>
typedef enum {
SPA_H264_STREAM_FORMAT_UNKNOWN = 0,
SPA_H264_STREAM_FORMAT_AVC,
SPA_H264_STREAM_FORMAT_AVC3,
SPA_H264_STREAM_FORMAT_BYTESTREAM
} SpaH264StreamFormat;
typedef enum {
SPA_H264_ALIGNMENT_UNKNOWN = 0,
SPA_H264_ALIGNMENT_AU,
SPA_H264_ALIGNMENT_NAL
} SpaH264Alignment;
struct _SpaVideoInfoH264 {
SpaRectangle size;
SpaFraction framerate;
SpaFraction max_framerate;
SpaH264StreamFormat stream_format;
SpaH264Alignment alignment;
};
struct _SpaVideoInfoMJPG {
SpaRectangle size;
SpaFraction framerate;

View file

@ -31,7 +31,8 @@ extern "C" {
typedef struct _SpaFormatVideo SpaFormatVideo;
typedef enum {
SPA_PROP_ID_VIDEO_FORMAT = SPA_PROP_ID_MEDIA_CUSTOM_START,
SPA_PROP_ID_VIDEO_INFO = SPA_PROP_ID_MEDIA_CUSTOM_START,
SPA_PROP_ID_VIDEO_FORMAT,
SPA_PROP_ID_VIDEO_SIZE,
SPA_PROP_ID_VIDEO_FRAMERATE,
SPA_PROP_ID_VIDEO_MAX_FRAMERATE,
@ -45,8 +46,10 @@ typedef enum {
SPA_PROP_ID_VIDEO_COLOR_MATRIX,
SPA_PROP_ID_VIDEO_TRANSFER_FUNCTION,
SPA_PROP_ID_VIDEO_COLOR_PRIMARIES,
SPA_PROP_ID_VIDEO_INFO_RAW,
SPA_PROP_ID_VIDEO_INFO_MJPG,
SPA_PROP_ID_VIDEO_PROFILE,
SPA_PROP_ID_VIDEO_LEVEL,
SPA_PROP_ID_VIDEO_STREAM_FORMAT,
SPA_PROP_ID_VIDEO_ALIGNMENT,
} SpaPropIdVideo;
SpaResult spa_prop_info_fill_video (SpaPropInfo *info,
@ -63,6 +66,7 @@ struct _SpaFormatVideo {
SpaFormat format;
union {
SpaVideoInfoRaw raw;
SpaVideoInfoH264 h264;
SpaVideoInfoMJPG mjpg;
} info;
};

View file

@ -75,36 +75,36 @@ static const uint32_t format_values[] = {
};
static const SpaPropRangeInfo format_format_range[] = {
{ "S8", "S8", sizeof (uint32_t), &format_values[0] },
{ "U8", "U8", sizeof (uint32_t), &format_values[1] },
{ "S16LE", "S16LE", sizeof (uint32_t), &format_values[2] },
{ "S16BE", "S16BE", sizeof (uint32_t), &format_values[3] },
{ "U16LE", "U16LE", sizeof (uint32_t), &format_values[4] },
{ "U16BE", "U16BE", sizeof (uint32_t), &format_values[5] },
{ "S24_32LE", "S24_32LE", sizeof (uint32_t), &format_values[6] },
{ "S24_32BE", "S24_32BE", sizeof (uint32_t), &format_values[7] },
{ "U24_32LE", "U24_32LE", sizeof (uint32_t), &format_values[8] },
{ "U24_32BE", "U24_32BE", sizeof (uint32_t), &format_values[9] },
{ "S32LE", "S32LE", sizeof (uint32_t), &format_values[10] },
{ "S32BE", "S32BE", sizeof (uint32_t), &format_values[11] },
{ "U32LE", "U32LE", sizeof (uint32_t), &format_values[12] },
{ "U32BE", "U32BE", sizeof (uint32_t), &format_values[13] },
{ "S24LE", "S24LE", sizeof (uint32_t), &format_values[14] },
{ "S24BE", "S24BE", sizeof (uint32_t), &format_values[15] },
{ "U24LE", "U24LE", sizeof (uint32_t), &format_values[16] },
{ "U24BE", "U24BE", sizeof (uint32_t), &format_values[17] },
{ "S20LE", "S20LE", sizeof (uint32_t), &format_values[18] },
{ "S20BE", "S20BE", sizeof (uint32_t), &format_values[19] },
{ "U20LE", "U20LE", sizeof (uint32_t), &format_values[20] },
{ "U20BE", "U20BE", sizeof (uint32_t), &format_values[21] },
{ "S18LE", "S18LE", sizeof (uint32_t), &format_values[22] },
{ "S18BE", "S18BE", sizeof (uint32_t), &format_values[23] },
{ "U18LE", "U18LE", sizeof (uint32_t), &format_values[24] },
{ "U18BE", "U18BE", sizeof (uint32_t), &format_values[25] },
{ "F32LE", "F32LE", sizeof (uint32_t), &format_values[26] },
{ "F32BE", "F32BE", sizeof (uint32_t), &format_values[27] },
{ "F64LE", "F64LE", sizeof (uint32_t), &format_values[28] },
{ "F64BE", "F64BE", sizeof (uint32_t), &format_values[29] },
{ "S8", "S8", { sizeof (uint32_t), &format_values[0] } },
{ "U8", "U8", { sizeof (uint32_t), &format_values[1] } },
{ "S16LE", "S16LE", { sizeof (uint32_t), &format_values[2] } },
{ "S16BE", "S16BE", { sizeof (uint32_t), &format_values[3] } },
{ "U16LE", "U16LE", { sizeof (uint32_t), &format_values[4] } },
{ "U16BE", "U16BE", { sizeof (uint32_t), &format_values[5] } },
{ "S24_32LE", "S24_32LE", { sizeof (uint32_t), &format_values[6] } },
{ "S24_32BE", "S24_32BE", { sizeof (uint32_t), &format_values[7] } },
{ "U24_32LE", "U24_32LE", { sizeof (uint32_t), &format_values[8] } },
{ "U24_32BE", "U24_32BE", { sizeof (uint32_t), &format_values[9] } },
{ "S32LE", "S32LE", { sizeof (uint32_t), &format_values[10] } },
{ "S32BE", "S32BE", { sizeof (uint32_t), &format_values[11] } },
{ "U32LE", "U32LE", { sizeof (uint32_t), &format_values[12] } },
{ "U32BE", "U32BE", { sizeof (uint32_t), &format_values[13] } },
{ "S24LE", "S24LE", { sizeof (uint32_t), &format_values[14] } },
{ "S24BE", "S24BE", { sizeof (uint32_t), &format_values[15] } },
{ "U24LE", "U24LE", { sizeof (uint32_t), &format_values[16] } },
{ "U24BE", "U24BE", { sizeof (uint32_t), &format_values[17] } },
{ "S20LE", "S20LE", { sizeof (uint32_t), &format_values[18] } },
{ "S20BE", "S20BE", { sizeof (uint32_t), &format_values[19] } },
{ "U20LE", "U20LE", { sizeof (uint32_t), &format_values[20] } },
{ "U20BE", "U20BE", { sizeof (uint32_t), &format_values[21] } },
{ "S18LE", "S18LE", { sizeof (uint32_t), &format_values[22] } },
{ "S18BE", "S18BE", { sizeof (uint32_t), &format_values[23] } },
{ "U18LE", "U18LE", { sizeof (uint32_t), &format_values[24] } },
{ "U18BE", "U18BE", { sizeof (uint32_t), &format_values[25] } },
{ "F32LE", "F32LE", { sizeof (uint32_t), &format_values[26] } },
{ "F32BE", "F32BE", { sizeof (uint32_t), &format_values[27] } },
{ "F64LE", "F64LE", { sizeof (uint32_t), &format_values[28] } },
{ "F64BE", "F64BE", { sizeof (uint32_t), &format_values[29] } },
};
static const uint32_t format_layouts[] = {
@ -113,8 +113,8 @@ static const uint32_t format_layouts[] = {
};
static const SpaPropRangeInfo layouts_range[] = {
{ "interleaved", "Interleaved samples", sizeof (uint32_t), &format_layouts[0] },
{ "non-interleaved", "Non-interleaved samples", sizeof (uint32_t), &format_layouts[1] },
{ "interleaved", "Interleaved samples", { sizeof (uint32_t), &format_layouts[0] } },
{ "non-interleaved", "Non-interleaved samples", { sizeof (uint32_t), &format_layouts[1] } },
};
static const uint32_t format_flags[] = {
@ -123,16 +123,16 @@ static const uint32_t format_flags[] = {
};
static const SpaPropRangeInfo flags_range[] = {
{ "none", "No flags", sizeof (uint32_t), &format_flags[0] },
{ "unpositioned", "Unpositioned channels", sizeof (uint32_t), &format_flags[1] },
{ "none", "No flags", { sizeof (uint32_t), &format_flags[0] } },
{ "unpositioned", "Unpositioned channels", { sizeof (uint32_t), &format_flags[1] } },
};
static const uint32_t min_uint32 = 1;
static const uint32_t max_uint32 = UINT32_MAX;
static const SpaPropRangeInfo uint32_range[] = {
{ "min", "Minimum value", 4, &min_uint32 },
{ "max", "Maximum value", 4, &max_uint32 },
{ "min", "Minimum value", { sizeof (uint32_t), &min_uint32 } },
{ "max", "Maximum value", { sizeof (uint32_t), &max_uint32 } },
};
static const SpaPropInfo format_prop_info[] =
@ -274,6 +274,7 @@ spa_format_audio_parse (const SpaFormat *format,
SpaPropValue value;
const SpaProps *props;
SpaResult res;
unsigned int idx;
if ((void *)format == (void *)aformat)
return SPA_RESULT_OK;
@ -281,18 +282,20 @@ spa_format_audio_parse (const SpaFormat *format,
if (format->media_type != SPA_MEDIA_TYPE_AUDIO)
return SPA_RESULT_INVALID_MEDIA_TYPE;
spa_format_audio_init (format->media_type,
if ((res = spa_format_audio_init (format->media_type,
format->media_subtype,
aformat);
aformat)) < 0)
return res;
props = &format->props;
if ((res = spa_props_get_prop (props, spa_props_index_for_id (props, SPA_PROP_ID_AUDIO_INFO_RAW), &value)) < 0)
idx = spa_props_index_for_id (props, SPA_PROP_ID_AUDIO_INFO_RAW);
if ((res = spa_props_get_prop (props, idx, &value)) < 0)
goto fallback;
if (value.type != SPA_PROP_TYPE_POINTER || value.size != sizeof (SpaAudioInfoRaw))
if (props->prop_info[idx].type != SPA_PROP_TYPE_POINTER)
goto fallback;
memcpy (&aformat->info, value.value, sizeof (SpaAudioInfoRaw));
memcpy (&aformat->info, value.value, SPA_MIN (value.size, sizeof (SpaAudioInfoRaw)));
return SPA_RESULT_OK;

View file

@ -367,8 +367,8 @@ parse_props (SpaMemory *mem, void *p, off_t offset)
ri->name = SPA_MEMBER (tp, SPA_PTR_TO_INT (ri->name), char);
if (ri->description)
ri->description = SPA_MEMBER (tp, SPA_PTR_TO_INT (ri->description), char);
if (ri->value)
ri->value = SPA_MEMBER (tp, SPA_PTR_TO_INT (ri->value), void);
if (ri->val.value)
ri->val.value = SPA_MEMBER (tp, SPA_PTR_TO_INT (ri->val.value), void);
}
}
return tp;
@ -838,7 +838,7 @@ calc_props_len (const SpaProps *props)
len += ri->name ? strlen (ri->name) + 1 : 0;
len += ri->description ? strlen (ri->description) + 1 : 0;
/* the size of the range value */
len += ri->size;
len += ri->val.size;
}
}
return len;
@ -912,12 +912,12 @@ write_props (void *p, const SpaProps *props, off_t offset)
} else {
ri->description = 0;
}
if (ri->size) {
memcpy (p, ri->value, ri->size);
ri->value = SPA_INT_TO_PTR (SPA_PTRDIFF (p, tp));
p += ri->size;
if (ri->val.size) {
memcpy (p, ri->val.value, ri->val.size);
ri->val.value = SPA_INT_TO_PTR (SPA_PTRDIFF (p, tp));
p += ri->val.size;
} else {
ri->value = 0;
ri->val.value = 0;
}
ri++;
}

View file

@ -242,7 +242,7 @@ struct prop_type_name {
};
static void
print_value (const SpaPropInfo *info, int size, const void *value)
print_value (const SpaPropInfo *info, const SpaPropValue *val)
{
SpaPropType type = info->type;
bool enum_string = false;
@ -252,7 +252,7 @@ print_value (const SpaPropInfo *info, int size, const void *value)
int i;
for (i = 0; i < info->n_range_values; i++) {
if (memcmp (info->range_values[i].value, value, size) == 0) {
if (memcmp (info->range_values[i].val.value, val->value, val->size) == 0) {
if (info->range_values[i].name) {
enum_value = info->range_values[i].name;
enum_string = true;
@ -266,63 +266,63 @@ print_value (const SpaPropInfo *info, int size, const void *value)
fprintf (stderr, "invalid");
break;
case SPA_PROP_TYPE_BOOL:
fprintf (stderr, "%s", *(bool *)value ? "true" : "false");
fprintf (stderr, "%s", *(bool *)val->value ? "true" : "false");
break;
case SPA_PROP_TYPE_INT8:
fprintf (stderr, "%" PRIi8, *(int8_t *)value);
fprintf (stderr, "%" PRIi8, *(int8_t *)val->value);
break;
case SPA_PROP_TYPE_UINT8:
fprintf (stderr, "%" PRIu8, *(uint8_t *)value);
fprintf (stderr, "%" PRIu8, *(uint8_t *)val->value);
break;
case SPA_PROP_TYPE_INT16:
fprintf (stderr, "%" PRIi16, *(int16_t *)value);
fprintf (stderr, "%" PRIi16, *(int16_t *)val->value);
break;
case SPA_PROP_TYPE_UINT16:
fprintf (stderr, "%" PRIu16, *(uint16_t *)value);
fprintf (stderr, "%" PRIu16, *(uint16_t *)val->value);
break;
case SPA_PROP_TYPE_INT32:
fprintf (stderr, "%" PRIi32, *(int32_t *)value);
fprintf (stderr, "%" PRIi32, *(int32_t *)val->value);
break;
case SPA_PROP_TYPE_UINT32:
fprintf (stderr, "%" PRIu32, *(uint32_t *)value);
fprintf (stderr, "%" PRIu32, *(uint32_t *)val->value);
break;
case SPA_PROP_TYPE_INT64:
fprintf (stderr, "%" PRIi64 "\n", *(int64_t *)value);
fprintf (stderr, "%" PRIi64 "\n", *(int64_t *)val->value);
break;
case SPA_PROP_TYPE_UINT64:
fprintf (stderr, "%" PRIu64 "\n", *(uint64_t *)value);
fprintf (stderr, "%" PRIu64 "\n", *(uint64_t *)val->value);
break;
case SPA_PROP_TYPE_INT:
fprintf (stderr, "%d", *(int *)value);
fprintf (stderr, "%d", *(int *)val->value);
break;
case SPA_PROP_TYPE_UINT:
fprintf (stderr, "%u", *(unsigned int *)value);
fprintf (stderr, "%u", *(unsigned int *)val->value);
break;
case SPA_PROP_TYPE_FLOAT:
fprintf (stderr, "%f", *(float *)value);
fprintf (stderr, "%f", *(float *)val->value);
break;
case SPA_PROP_TYPE_DOUBLE:
fprintf (stderr, "%g", *(double *)value);
fprintf (stderr, "%g", *(double *)val->value);
break;
case SPA_PROP_TYPE_STRING:
fprintf (stderr, "\"%s\"", (char *)value);
fprintf (stderr, "\"%s\"", (char *)val->value);
break;
case SPA_PROP_TYPE_RECTANGLE:
{
const SpaRectangle *r = value;
const SpaRectangle *r = val->value;
fprintf (stderr, "%"PRIu32"x%"PRIu32, r->width, r->height);
break;
}
case SPA_PROP_TYPE_FRACTION:
{
const SpaFraction *f = value;
const SpaFraction *f = val->value;
fprintf (stderr, "%"PRIu32"/%"PRIu32, f->num, f->denom);
break;
}
case SPA_PROP_TYPE_BITMASK:
break;
case SPA_PROP_TYPE_POINTER:
fprintf (stderr, "%p", value);
fprintf (stderr, "%p", val->value);
break;
default:
break;
@ -365,7 +365,7 @@ spa_debug_props (const SpaProps *props, bool print_ranges)
fprintf (stderr, "Current: ");
if (res == SPA_RESULT_OK)
print_value (info, value.size, value.value);
print_value (info, &value);
else if (res == SPA_RESULT_PROPERTY_UNSET)
fprintf (stderr, "Unset");
else
@ -399,7 +399,7 @@ spa_debug_props (const SpaProps *props, bool print_ranges)
for (j = 0; j < info->n_range_values; j++) {
const SpaPropRangeInfo *rinfo = &info->range_values[j];
fprintf (stderr, "%-23.23s ", "");
print_value (info, rinfo->size, rinfo->value);
print_value (info, &rinfo->val);
fprintf (stderr, "\t: %-12s - %s \n", rinfo->name, rinfo->description);
}
}
@ -460,7 +460,7 @@ spa_debug_format (const SpaFormat *format)
fprintf (stderr, " %20s : (%s) ", info->name, prop_type_names[info->type].name);
if (res == SPA_RESULT_OK) {
print_value (info, value.size, value.value);
print_value (info, &value);
} else if (res == SPA_RESULT_PROPERTY_UNSET) {
int j;
const char *ssep, *esep, *sep;
@ -484,7 +484,7 @@ spa_debug_format (const SpaFormat *format)
fprintf (stderr, ssep);
for (j = 0; j < info->n_range_values; j++) {
const SpaPropRangeInfo *rinfo = &info->range_values[j];
print_value (info, rinfo->size, rinfo->value);
print_value (info, &rinfo->val);
fprintf (stderr, "%s", j + 1 < info->n_range_values ? sep : "");
}
fprintf (stderr, esep);

View file

@ -39,8 +39,6 @@ spa_props_set_prop (SpaProps *props,
info = &props->prop_info[index];
if ((info->flags & SPA_PROP_FLAG_WRITABLE) == 0)
return SPA_RESULT_INVALID_PROPERTY_ACCESS;
if (info->type != value->type)
return SPA_RESULT_WRONG_PROPERTY_TYPE;
if (info->maxsize < value->size)
return SPA_RESULT_WRONG_PROPERTY_SIZE;
@ -71,7 +69,6 @@ spa_props_get_prop (const SpaProps *props,
if (SPA_PROPS_INDEX_IS_UNSET (props, index))
return SPA_RESULT_PROPERTY_UNSET;
value->type = info->type;
value->size = info->maxsize;
value->value = SPA_MEMBER (props, info->offset, void);
@ -96,8 +93,6 @@ spa_props_copy (const SpaProps *src,
continue;
if ((res = spa_props_get_prop (src, spa_props_index_for_id (src, info->id), &value)) < 0)
continue;
if (value.type != info->type)
return SPA_RESULT_WRONG_PROPERTY_TYPE;
if (value.size > info->maxsize)
return SPA_RESULT_WRONG_PROPERTY_SIZE;

View file

@ -25,23 +25,6 @@
#include <spa/video/raw.h>
#include <spa/video/format.h>
static const SpaVideoInfoRaw default_raw_info = {
SPA_VIDEO_FORMAT_UNKNOWN,
{ 320, 240 },
{ 1, 25 },
{ 1, 25 },
1,
SPA_VIDEO_INTERLACE_MODE_PROGRESSIVE,
{ 1, 1},
SPA_VIDEO_MULTIVIEW_MODE_MONO,
SPA_VIDEO_MULTIVIEW_FLAGS_NONE,
SPA_VIDEO_CHROMA_SITE_UNKNOWN,
SPA_VIDEO_COLOR_RANGE_UNKNOWN,
SPA_VIDEO_COLOR_MATRIX_UNKNOWN,
SPA_VIDEO_TRANSFER_UNKNOWN,
SPA_VIDEO_COLOR_PRIMARIES_UNKNOWN
};
static const uint32_t format_values[] = {
SPA_VIDEO_FORMAT_UNKNOWN,
SPA_VIDEO_FORMAT_ENCODED,
@ -110,77 +93,77 @@ static const uint32_t format_values[] = {
};
static const SpaPropRangeInfo format_range[] = {
{ "ENCODED", "ENCODED", sizeof (uint32_t), &format_values[1] },
{ "I420", "I420", sizeof (uint32_t), &format_values[2] },
{ "YV12", "YV12", sizeof (uint32_t), &format_values[3] },
{ "YUY2", "YUY2", sizeof (uint32_t), &format_values[4] },
{ "UYVY", "UYVY", sizeof (uint32_t), &format_values[5] },
{ "AYUV", "AYUV", sizeof (uint32_t), &format_values[6] },
{ "RGBx", "RGBx", sizeof (uint32_t), &format_values[7] },
{ "BGRx", "BGRx", sizeof (uint32_t), &format_values[8] },
{ "xRGB", "xRGB", sizeof (uint32_t), &format_values[9] },
{ "xBGR", "xBGR", sizeof (uint32_t), &format_values[10] },
{ "RGBA", "RGBA", sizeof (uint32_t), &format_values[11] },
{ "BGRA", "BGRA", sizeof (uint32_t), &format_values[12] },
{ "ARGB", "ARGB", sizeof (uint32_t), &format_values[13] },
{ "ABGR", "ABGR", sizeof (uint32_t), &format_values[14] },
{ "RGB", "RGB", sizeof (uint32_t), &format_values[15] },
{ "BGR", "BGR", sizeof (uint32_t), &format_values[16] },
{ "Y41B", "Y41B", sizeof (uint32_t), &format_values[17] },
{ "Y42B", "Y42B", sizeof (uint32_t), &format_values[18] },
{ "YVYU", "YVYU", sizeof (uint32_t), &format_values[19] },
{ "Y444", "Y444", sizeof (uint32_t), &format_values[20] },
{ "v210", "v210", sizeof (uint32_t), &format_values[21] },
{ "v216", "v216", sizeof (uint32_t), &format_values[22] },
{ "NV12", "NV12", sizeof (uint32_t), &format_values[23] },
{ "NV21", "NV21", sizeof (uint32_t), &format_values[24] },
{ "GRAY8", "GRAY8", sizeof (uint32_t), &format_values[25] },
{ "GRAY16_BE", "GRAY16_BE", sizeof (uint32_t), &format_values[26] },
{ "GRAY16_LE", "GRAY16_LE", sizeof (uint32_t), &format_values[27] },
{ "v308", "v308", sizeof (uint32_t), &format_values[28] },
{ "RGB16", "RGB16", sizeof (uint32_t), &format_values[29] },
{ "BGR16", "BGR16", sizeof (uint32_t), &format_values[30] },
{ "RGB15", "RGB15", sizeof (uint32_t), &format_values[31] },
{ "BGR15", "BGR15", sizeof (uint32_t), &format_values[32] },
{ "UYVP", "UYVP", sizeof (uint32_t), &format_values[33] },
{ "A420", "A420", sizeof (uint32_t), &format_values[34] },
{ "RGB8P", "RGB8P", sizeof (uint32_t), &format_values[35] },
{ "YUV9", "YUV9", sizeof (uint32_t), &format_values[36] },
{ "YVU9", "YVU9", sizeof (uint32_t), &format_values[37] },
{ "IYU1", "IYU1", sizeof (uint32_t), &format_values[38] },
{ "ARGB64", "ARGB64", sizeof (uint32_t), &format_values[39] },
{ "AYUV64", "AYUV64", sizeof (uint32_t), &format_values[40] },
{ "r210", "r210", sizeof (uint32_t), &format_values[41] },
{ "I420_10BE", "I420_10BE", sizeof (uint32_t), &format_values[42] },
{ "I420_10LE", "I420_10LE", sizeof (uint32_t), &format_values[43] },
{ "I422_10BE", "I422_10BE", sizeof (uint32_t), &format_values[44] },
{ "I422_10LE", "I422_10LE", sizeof (uint32_t), &format_values[45] },
{ "I444_10BE", "I444_10BE", sizeof (uint32_t), &format_values[46] },
{ "I444_10LE", "I444_10LE", sizeof (uint32_t), &format_values[47] },
{ "GBR", "GBR", sizeof (uint32_t), &format_values[48] },
{ "GBR_10BE", "GBR_10BE", sizeof (uint32_t), &format_values[49] },
{ "GBR_10LE", "GBR_10LE", sizeof (uint32_t), &format_values[50] },
{ "NV16", "NV16", sizeof (uint32_t), &format_values[51] },
{ "NV24", "NV24", sizeof (uint32_t), &format_values[52] },
{ "NV12_64Z32", "NV12_64Z32", sizeof (uint32_t), &format_values[53] },
{ "A420_10BE", "A420_10BE", sizeof (uint32_t), &format_values[54] },
{ "A420_10LE", "A420_10LE", sizeof (uint32_t), &format_values[55] },
{ "A422_10BE", "A422_10BE", sizeof (uint32_t), &format_values[56] },
{ "A422_10LE", "A422_10LE", sizeof (uint32_t), &format_values[57] },
{ "A444_10BE", "A444_10BE", sizeof (uint32_t), &format_values[58] },
{ "A444_10LE", "A444_10LE", sizeof (uint32_t), &format_values[59] },
{ "NV61", "NV61", sizeof (uint32_t), &format_values[60] },
{ "P010_10BE", "P010_10BE", sizeof (uint32_t), &format_values[61] },
{ "P010_10LE", "P010_10LE", sizeof (uint32_t), &format_values[62] },
{ "IYU2", "IYU2", sizeof (uint32_t), &format_values[63] },
{ "ENCODED", "ENCODED", { sizeof (uint32_t), &format_values[1] } },
{ "I420", "I420", { sizeof (uint32_t), &format_values[2] } },
{ "YV12", "YV12", { sizeof (uint32_t), &format_values[3] } },
{ "YUY2", "YUY2", { sizeof (uint32_t), &format_values[4] } },
{ "UYVY", "UYVY", { sizeof (uint32_t), &format_values[5] } },
{ "AYUV", "AYUV", { sizeof (uint32_t), &format_values[6] } },
{ "RGBx", "RGBx", { sizeof (uint32_t), &format_values[7] } },
{ "BGRx", "BGRx", { sizeof (uint32_t), &format_values[8] } },
{ "xRGB", "xRGB", { sizeof (uint32_t), &format_values[9] } },
{ "xBGR", "xBGR", { sizeof (uint32_t), &format_values[10] } },
{ "RGBA", "RGBA", { sizeof (uint32_t), &format_values[11] } },
{ "BGRA", "BGRA", { sizeof (uint32_t), &format_values[12] } },
{ "ARGB", "ARGB", { sizeof (uint32_t), &format_values[13] } },
{ "ABGR", "ABGR", { sizeof (uint32_t), &format_values[14] } },
{ "RGB", "RGB", { sizeof (uint32_t), &format_values[15] } },
{ "BGR", "BGR", { sizeof (uint32_t), &format_values[16] } },
{ "Y41B", "Y41B", { sizeof (uint32_t), &format_values[17] } },
{ "Y42B", "Y42B", { sizeof (uint32_t), &format_values[18] } },
{ "YVYU", "YVYU", { sizeof (uint32_t), &format_values[19] } },
{ "Y444", "Y444", { sizeof (uint32_t), &format_values[20] } },
{ "v210", "v210", { sizeof (uint32_t), &format_values[21] } },
{ "v216", "v216", { sizeof (uint32_t), &format_values[22] } },
{ "NV12", "NV12", { sizeof (uint32_t), &format_values[23] } },
{ "NV21", "NV21", { sizeof (uint32_t), &format_values[24] } },
{ "GRAY8", "GRAY8", { sizeof (uint32_t), &format_values[25] } },
{ "GRAY16_BE", "GRAY16_BE", { sizeof (uint32_t), &format_values[26] } },
{ "GRAY16_LE", "GRAY16_LE", { sizeof (uint32_t), &format_values[27] } },
{ "v308", "v308", { sizeof (uint32_t), &format_values[28] } },
{ "RGB16", "RGB16", { sizeof (uint32_t), &format_values[29] } },
{ "BGR16", "BGR16", { sizeof (uint32_t), &format_values[30] } },
{ "RGB15", "RGB15", { sizeof (uint32_t), &format_values[31] } },
{ "BGR15", "BGR15", { sizeof (uint32_t), &format_values[32] } },
{ "UYVP", "UYVP", { sizeof (uint32_t), &format_values[33] } },
{ "A420", "A420", { sizeof (uint32_t), &format_values[34] } },
{ "RGB8P", "RGB8P", { sizeof (uint32_t), &format_values[35] } },
{ "YUV9", "YUV9", { sizeof (uint32_t), &format_values[36] } },
{ "YVU9", "YVU9", { sizeof (uint32_t), &format_values[37] } },
{ "IYU1", "IYU1", { sizeof (uint32_t), &format_values[38] } },
{ "ARGB64", "ARGB64", { sizeof (uint32_t), &format_values[39] } },
{ "AYUV64", "AYUV64", { sizeof (uint32_t), &format_values[40] } },
{ "r210", "r210", { sizeof (uint32_t), &format_values[41] } },
{ "I420_10BE", "I420_10BE", { sizeof (uint32_t), &format_values[42] } },
{ "I420_10LE", "I420_10LE", { sizeof (uint32_t), &format_values[43] } },
{ "I422_10BE", "I422_10BE", { sizeof (uint32_t), &format_values[44] } },
{ "I422_10LE", "I422_10LE", { sizeof (uint32_t), &format_values[45] } },
{ "I444_10BE", "I444_10BE", { sizeof (uint32_t), &format_values[46] } },
{ "I444_10LE", "I444_10LE", { sizeof (uint32_t), &format_values[47] } },
{ "GBR", "GBR", { sizeof (uint32_t), &format_values[48] } },
{ "GBR_10BE", "GBR_10BE", { sizeof (uint32_t), &format_values[49] } },
{ "GBR_10LE", "GBR_10LE", { sizeof (uint32_t), &format_values[50] } },
{ "NV16", "NV16", { sizeof (uint32_t), &format_values[51] } },
{ "NV24", "NV24", { sizeof (uint32_t), &format_values[52] } },
{ "NV12_64Z32", "NV12_64Z32", { sizeof (uint32_t), &format_values[53] } },
{ "A420_10BE", "A420_10BE", { sizeof (uint32_t), &format_values[54] } },
{ "A420_10LE", "A420_10LE", { sizeof (uint32_t), &format_values[55] } },
{ "A422_10BE", "A422_10BE", { sizeof (uint32_t), &format_values[56] } },
{ "A422_10LE", "A422_10LE", { sizeof (uint32_t), &format_values[57] } },
{ "A444_10BE", "A444_10BE", { sizeof (uint32_t), &format_values[58] } },
{ "A444_10LE", "A444_10LE", { sizeof (uint32_t), &format_values[59] } },
{ "NV61", "NV61", { sizeof (uint32_t), &format_values[60] } },
{ "P010_10BE", "P010_10BE", { sizeof (uint32_t), &format_values[61] } },
{ "P010_10LE", "P010_10LE", { sizeof (uint32_t), &format_values[62] } },
{ "IYU2", "IYU2", { sizeof (uint32_t), &format_values[63] } },
};
static const SpaRectangle min_size = { 1, 1 };
static const SpaRectangle max_size = { UINT32_MAX, UINT32_MAX };
static const SpaPropRangeInfo size_range[] = {
{ "min", "Minimum value", sizeof (SpaRectangle), &min_size },
{ "max", "Maximum value", sizeof (SpaRectangle), &max_size },
{ "min", "Minimum value", { sizeof (SpaRectangle), &min_size } },
{ "max", "Maximum value", { sizeof (SpaRectangle), &max_size } },
};
static const uint32_t interlace_modes[] = {
@ -191,10 +174,10 @@ static const uint32_t interlace_modes[] = {
};
static const SpaPropRangeInfo interlace_mode_range[] = {
{ "progressive", "Progressive video", sizeof (uint32_t), &interlace_modes[0] },
{ "interleaved", "Interleaved video", sizeof (uint32_t), &interlace_modes[1] },
{ "mixed", "Mixed interlaced video", sizeof (uint32_t), &interlace_modes[2] },
{ "fields", "Fields interlaced video", sizeof (uint32_t), &interlace_modes[3] },
{ "progressive", "Progressive video", { sizeof (uint32_t), &interlace_modes[0] } },
{ "interleaved", "Interleaved video", { sizeof (uint32_t), &interlace_modes[1] } },
{ "mixed", "Mixed interlaced video", { sizeof (uint32_t), &interlace_modes[2] } },
{ "fields", "Fields interlaced video", { sizeof (uint32_t), &interlace_modes[3] } },
};
@ -215,18 +198,18 @@ static const uint32_t multiview_modes[] = {
};
static const SpaPropRangeInfo multiview_mode_range[] = {
{ "mono", "Mono", sizeof (uint32_t), &multiview_modes[1] },
{ "left", "Left", sizeof (uint32_t), &multiview_modes[2] },
{ "right", "Right", sizeof (uint32_t), &multiview_modes[3] },
{ "side-by-side", "Side by side", sizeof (uint32_t), &multiview_modes[4] },
{ "side-by-side-quincunx", "Side by side Cuincunx", sizeof (uint32_t), &multiview_modes[5] },
{ "column-interleaved", "Column Interleaved", sizeof (uint32_t), &multiview_modes[6] },
{ "row-interleaved", "Row Interleaved", sizeof (uint32_t), &multiview_modes[7] },
{ "top-bottom", "Top Bottom", sizeof (uint32_t), &multiview_modes[8] },
{ "checkerboard", "Checkerboard", sizeof (uint32_t), &multiview_modes[9] },
{ "frame-by-frame", "Frame by frame", sizeof (uint32_t), &multiview_modes[10] },
{ "multiview-frame-by-frame", "Multiview Frame by frame", sizeof (uint32_t), &multiview_modes[11] },
{ "separated", "Separated", sizeof (uint32_t), &multiview_modes[12] },
{ "mono", "Mono", { sizeof (uint32_t), &multiview_modes[1] } },
{ "left", "Left", { sizeof (uint32_t), &multiview_modes[2] } },
{ "right", "Right", { sizeof (uint32_t), &multiview_modes[3] } },
{ "side-by-side", "Side by side", { sizeof (uint32_t), &multiview_modes[4] } },
{ "side-by-side-quincunx", "Side by side Cuincunx", { sizeof (uint32_t), &multiview_modes[5] } },
{ "column-interleaved", "Column Interleaved", { sizeof (uint32_t), &multiview_modes[6] } },
{ "row-interleaved", "Row Interleaved", { sizeof (uint32_t), &multiview_modes[7] } },
{ "top-bottom", "Top Bottom", { sizeof (uint32_t), &multiview_modes[8] } },
{ "checkerboard", "Checkerboard", { sizeof (uint32_t), &multiview_modes[9] } },
{ "frame-by-frame", "Frame by frame", { sizeof (uint32_t), &multiview_modes[10] } },
{ "multiview-frame-by-frame", "Multiview Frame by frame", { sizeof (uint32_t), &multiview_modes[11] } },
{ "separated", "Separated", { sizeof (uint32_t), &multiview_modes[12] } },
};
static const uint32_t multiview_flags[] = {
@ -241,14 +224,14 @@ static const uint32_t multiview_flags[] = {
};
static const SpaPropRangeInfo multiview_flags_range[] = {
{ "none", "None", sizeof (uint32_t), &multiview_flags[0] },
{ "right-view-first", "Right view first", sizeof (uint32_t), &multiview_flags[1] },
{ "left-flipped", "Left flipped", sizeof (uint32_t), &multiview_flags[2] },
{ "left-flopped", "Left flopped", sizeof (uint32_t), &multiview_flags[3] },
{ "right-flipped", "Right flipped", sizeof (uint32_t), &multiview_flags[4] },
{ "right-flopped", "Right flopped", sizeof (uint32_t), &multiview_flags[5] },
{ "half-aspect", "Half aspect", sizeof (uint32_t), &multiview_flags[6] },
{ "mixed-mono", "Mixed mono", sizeof (uint32_t), &multiview_flags[7] },
{ "none", "None", { sizeof (uint32_t), &multiview_flags[0] } },
{ "right-view-first", "Right view first", { sizeof (uint32_t), &multiview_flags[1] } },
{ "left-flipped", "Left flipped", { sizeof (uint32_t), &multiview_flags[2] } },
{ "left-flopped", "Left flopped", { sizeof (uint32_t), &multiview_flags[3] } },
{ "right-flipped", "Right flipped", { sizeof (uint32_t), &multiview_flags[4] } },
{ "right-flopped", "Right flopped", { sizeof (uint32_t), &multiview_flags[5] } },
{ "half-aspect", "Half aspect", { sizeof (uint32_t), &multiview_flags[6] } },
{ "mixed-mono", "Mixed mono", { sizeof (uint32_t), &multiview_flags[7] } },
};
static const uint32_t chroma_sites[] = {
@ -260,11 +243,11 @@ static const uint32_t chroma_sites[] = {
};
static const SpaPropRangeInfo chroma_site_range[] = {
{ "unknown", "Unknown", sizeof (uint32_t), &chroma_sites[0] },
{ "none", "None", sizeof (uint32_t), &chroma_sites[1] },
{ "h-cosited", "H-cosited", sizeof (uint32_t), &chroma_sites[2] },
{ "v-cosited", "V-cosited", sizeof (uint32_t), &chroma_sites[3] },
{ "alt-line", "Alt line", sizeof (uint32_t), &chroma_sites[4] }
{ "unknown", "Unknown", { sizeof (uint32_t), &chroma_sites[0] } },
{ "none", "None", { sizeof (uint32_t), &chroma_sites[1] } },
{ "h-cosited", "H-cosited", { sizeof (uint32_t), &chroma_sites[2] } },
{ "v-cosited", "V-cosited", { sizeof (uint32_t), &chroma_sites[3] } },
{ "alt-line", "Alt line", { sizeof (uint32_t), &chroma_sites[4] } }
};
static const uint32_t color_ranges[] = {
@ -274,9 +257,9 @@ static const uint32_t color_ranges[] = {
};
static const SpaPropRangeInfo color_range_range[] = {
{ "unknown", "Unknown color range", sizeof (uint32_t), &color_ranges[0] },
{ "0_255", "0-255", sizeof (uint32_t), &color_ranges[1] },
{ "16_235", "16-235", sizeof (uint32_t), &color_ranges[2] },
{ "unknown", "Unknown color range", { sizeof (uint32_t), &color_ranges[0] } },
{ "0_255", "0-255", { sizeof (uint32_t), &color_ranges[1] } },
{ "16_235", "16-235", { sizeof (uint32_t), &color_ranges[2] } },
};
static const uint32_t color_matrices[] = {
@ -290,13 +273,13 @@ static const uint32_t color_matrices[] = {
};
static const SpaPropRangeInfo color_matrix_range[] = {
{ "unknown", "Unknown color matrix", sizeof (uint32_t), &color_matrices[0] },
{ "rgb", "identity matrix", sizeof (uint32_t), &color_matrices[1] },
{ "fcc", "FCC color matrix", sizeof (uint32_t), &color_matrices[2] },
{ "bt709", "ITU-R BT.709 color matrix", sizeof (uint32_t), &color_matrices[3] },
{ "bt601", "ITU-R BT.601 color matrix", sizeof (uint32_t), &color_matrices[4] },
{ "smpte240m", "SMPTE 240M color matrix", sizeof (uint32_t), &color_matrices[5] },
{ "bt2020", "ITU-R BT.2020 color matrix", sizeof (uint32_t), &color_matrices[6] },
{ "unknown", "Unknown color matrix", { sizeof (uint32_t), &color_matrices[0] } },
{ "rgb", "identity matrix", { sizeof (uint32_t), &color_matrices[1] } },
{ "fcc", "FCC color matrix", { sizeof (uint32_t), &color_matrices[2] } },
{ "bt709", "ITU-R BT.709 color matrix", { sizeof (uint32_t), &color_matrices[3] } },
{ "bt601", "ITU-R BT.601 color matrix", { sizeof (uint32_t), &color_matrices[4] } },
{ "smpte240m", "SMPTE 240M color matrix", { sizeof (uint32_t), &color_matrices[5] } },
{ "bt2020", "ITU-R BT.2020 color matrix", { sizeof (uint32_t), &color_matrices[6] } },
};
static const uint32_t transfer_functions[] = {
@ -316,19 +299,19 @@ static const uint32_t transfer_functions[] = {
};
static const SpaPropRangeInfo transfer_function_range[] = {
{ "unknown", "Unknown transfer function", sizeof (uint32_t), &transfer_functions[0] },
{ "gamma10", "linear RGB, gamma 1.0 curve", sizeof (uint32_t), &transfer_functions[1] },
{ "gamma18", "gamma 1.8 curve", sizeof (uint32_t), &transfer_functions[2] },
{ "gamma20", "gamma 2.0 curve", sizeof (uint32_t), &transfer_functions[3] },
{ "gamma22", "gamma 2.2 curve", sizeof (uint32_t), &transfer_functions[4] },
{ "bt709", "Gamma 2.2 curve with a linear segment", sizeof (uint32_t), &transfer_functions[5] },
{ "smpte240m", "Gamma 2.2 curve with a linear segment", sizeof (uint32_t), &transfer_functions[6] },
{ "srgb", "Gamma 2.4 curve with a linear segment", sizeof (uint32_t), &transfer_functions[7] },
{ "gamma28", "Gamma 2.8 curve", sizeof (uint32_t), &transfer_functions[8] },
{ "log100", "Logarithmic transfer characteristic 100:1 range", sizeof (uint32_t), &transfer_functions[9] },
{ "log316", "Logarithmic transfer characteristic 316.22777:1 range", sizeof (uint32_t), &transfer_functions[10] },
{ "bt2020_12", "Gamma 2.2 curve with a linear segment", sizeof (uint32_t), &transfer_functions[11] },
{ "adobergb", "Gamma 2.19921875", sizeof (uint32_t), &transfer_functions[12] },
{ "unknown", "Unknown transfer function", { sizeof (uint32_t), &transfer_functions[0] } },
{ "gamma10", "linear RGB, gamma 1.0 curve", { sizeof (uint32_t), &transfer_functions[1] } },
{ "gamma18", "gamma 1.8 curve", { sizeof (uint32_t), &transfer_functions[2] } },
{ "gamma20", "gamma 2.0 curve", { sizeof (uint32_t), &transfer_functions[3] } },
{ "gamma22", "gamma 2.2 curve", { sizeof (uint32_t), &transfer_functions[4] } },
{ "bt709", "Gamma 2.2 curve with a linear segment", { sizeof (uint32_t), &transfer_functions[5] } },
{ "smpte240m", "Gamma 2.2 curve with a linear segment", { sizeof (uint32_t), &transfer_functions[6] } },
{ "srgb", "Gamma 2.4 curve with a linear segment", { sizeof (uint32_t), &transfer_functions[7] } },
{ "gamma28", "Gamma 2.8 curve", { sizeof (uint32_t), &transfer_functions[8] } },
{ "log100", "Logarithmic transfer characteristic 100:1 range", { sizeof (uint32_t), &transfer_functions[9] } },
{ "log316", "Logarithmic transfer characteristic 316.22777:1 range", { sizeof (uint32_t), &transfer_functions[10] } },
{ "bt2020_12", "Gamma 2.2 curve with a linear segment", { sizeof (uint32_t), &transfer_functions[11] } },
{ "adobergb", "Gamma 2.19921875", { sizeof (uint32_t), &transfer_functions[12] } },
};
static const uint32_t color_primaries[] = {
@ -344,35 +327,41 @@ static const uint32_t color_primaries[] = {
};
static const SpaPropRangeInfo color_primaries_range[] = {
{ "unknown", "Unknown color primaries", sizeof (uint32_t), &color_primaries[0] },
{ "bt709", "BT709 primaries", sizeof (uint32_t), &color_primaries[1] },
{ "bt470M", "BT470M primaries", sizeof (uint32_t), &color_primaries[2] },
{ "bt470BG", "BT470BG primaries", sizeof (uint32_t), &color_primaries[3] },
{ "smpte170m", "SMPTE170M primaries", sizeof (uint32_t), &color_primaries[4] },
{ "smpte240m", "SMPTE240M primaries", sizeof (uint32_t), &color_primaries[5] },
{ "film", "Generic film primaries", sizeof (uint32_t), &color_primaries[6] },
{ "bt2020", "BT2020 primaries", sizeof (uint32_t), &color_primaries[7] },
{ "adobergb", "Adobe RGB primaries", sizeof (uint32_t), &color_primaries[8] },
{ "unknown", "Unknown color primaries", { sizeof (uint32_t), &color_primaries[0] } },
{ "bt709", "BT709 primaries", { sizeof (uint32_t), &color_primaries[1] } },
{ "bt470M", "BT470M primaries", { sizeof (uint32_t), &color_primaries[2] } },
{ "bt470BG", "BT470BG primaries", { sizeof (uint32_t), &color_primaries[3] } },
{ "smpte170m", "SMPTE170M primaries", { sizeof (uint32_t), &color_primaries[4] } },
{ "smpte240m", "SMPTE240M primaries", { sizeof (uint32_t), &color_primaries[5] } },
{ "film", "Generic film primaries", { sizeof (uint32_t), &color_primaries[6] } },
{ "bt2020", "BT2020 primaries", { sizeof (uint32_t), &color_primaries[7] } },
{ "adobergb", "Adobe RGB primaries", { sizeof (uint32_t), &color_primaries[8] } },
};
static const uint32_t min_uint32 = 1;
static const uint32_t max_uint32 = UINT32_MAX;
static const SpaPropRangeInfo uint32_range[] = {
{ "min", "Minimum value", sizeof (uint32_t), &min_uint32 },
{ "max", "Maximum value", sizeof (uint32_t), &max_uint32 },
{ "min", "Minimum value", { sizeof (uint32_t), &min_uint32 } },
{ "max", "Maximum value", { sizeof (uint32_t), &max_uint32 } },
};
static const SpaFraction min_framerate = { 0, 1 };
static const SpaFraction max_framerate = { UINT32_MAX, 1 };
static const SpaPropRangeInfo framerate_range[] = {
{ "min", "Minimum value", sizeof (SpaFraction), &min_framerate },
{ "max", "Maximum value", sizeof (SpaFraction), &max_framerate },
{ "min", "Minimum value", { sizeof (SpaFraction), &min_framerate } },
{ "max", "Maximum value", { sizeof (SpaFraction), &max_framerate } },
};
static const SpaPropInfo format_prop_info[] =
{
{ SPA_PROP_ID_VIDEO_INFO, 0,
"info", "the SpaVideoInfo structure",
SPA_PROP_FLAG_READWRITE | SPA_PROP_FLAG_OPTIONAL,
SPA_PROP_TYPE_POINTER, sizeof (SpaVideoInfoRaw),
SPA_PROP_RANGE_TYPE_NONE, 0, NULL,
NULL },
{ SPA_PROP_ID_VIDEO_FORMAT, 0,
"format", "The media format",
SPA_PROP_FLAG_READWRITE,
@ -457,12 +446,6 @@ static const SpaPropInfo format_prop_info[] =
SPA_PROP_TYPE_UINT32, sizeof (uint32_t),
SPA_PROP_RANGE_TYPE_ENUM, SPA_N_ELEMENTS (color_primaries_range), color_primaries_range,
NULL },
{ SPA_PROP_ID_VIDEO_INFO_RAW, 0,
"info", "the SpaVideoRawInfo structure",
SPA_PROP_FLAG_READWRITE | SPA_PROP_FLAG_OPTIONAL,
SPA_PROP_TYPE_POINTER, sizeof (SpaVideoInfoRaw),
SPA_PROP_RANGE_TYPE_NONE, 0, NULL,
NULL },
};
SpaResult
@ -502,6 +485,7 @@ spa_format_video_init (SpaMediaType type,
case SPA_MEDIA_SUBTYPE_RAW:
{
static SpaPropInfo raw_prop_info[] = {
{ SPA_PROP_ID_VIDEO_INFO, offsetof (SpaFormatVideo, info.raw) },
{ SPA_PROP_ID_VIDEO_FORMAT, offsetof (SpaFormatVideo, info.raw.format) },
{ SPA_PROP_ID_VIDEO_SIZE, offsetof (SpaFormatVideo, info.raw.size) },
{ SPA_PROP_ID_VIDEO_FRAMERATE, offsetof (SpaFormatVideo, info.raw.framerate) },
@ -516,7 +500,22 @@ spa_format_video_init (SpaMediaType type,
{ SPA_PROP_ID_VIDEO_COLOR_MATRIX, offsetof (SpaFormatVideo, info.raw.color_matrix) },
{ SPA_PROP_ID_VIDEO_TRANSFER_FUNCTION, offsetof (SpaFormatVideo, info.raw.transfer_function) },
{ SPA_PROP_ID_VIDEO_COLOR_PRIMARIES, offsetof (SpaFormatVideo, info.raw.color_primaries) },
{ SPA_PROP_ID_VIDEO_INFO_RAW, offsetof (SpaFormatVideo, info.raw) },
};
static const SpaVideoInfoRaw default_raw_info = {
SPA_VIDEO_FORMAT_UNKNOWN,
{ 320, 240 },
{ 1, 25 },
{ 1, 25 },
1,
SPA_VIDEO_INTERLACE_MODE_PROGRESSIVE,
{ 1, 1},
SPA_VIDEO_MULTIVIEW_MODE_MONO,
SPA_VIDEO_MULTIVIEW_FLAGS_NONE,
SPA_VIDEO_CHROMA_SITE_UNKNOWN,
SPA_VIDEO_COLOR_RANGE_UNKNOWN,
SPA_VIDEO_COLOR_MATRIX_UNKNOWN,
SPA_VIDEO_TRANSFER_UNKNOWN,
SPA_VIDEO_COLOR_PRIMARIES_UNKNOWN
};
prop_info = raw_prop_info;
n_prop_info = SPA_N_ELEMENTS (raw_prop_info);
@ -526,20 +525,42 @@ spa_format_video_init (SpaMediaType type,
}
case SPA_MEDIA_SUBTYPE_H264:
return SPA_RESULT_NOT_IMPLEMENTED;
{
static SpaPropInfo h264_prop_info[] = {
{ SPA_PROP_ID_VIDEO_INFO, offsetof (SpaFormatVideo, info.h264) },
{ SPA_PROP_ID_VIDEO_SIZE, offsetof (SpaFormatVideo, info.h264.size) },
{ SPA_PROP_ID_VIDEO_FRAMERATE, offsetof (SpaFormatVideo, info.h264.framerate) },
{ SPA_PROP_ID_VIDEO_MAX_FRAMERATE, offsetof (SpaFormatVideo, info.h264.max_framerate) },
};
static const SpaVideoInfoH264 default_h264_info = {
{ 320, 240 },
{ 1, 25 },
{ 1, 25 }
};
prop_info = h264_prop_info;
n_prop_info = SPA_N_ELEMENTS (h264_prop_info);
format->format.props.unset_mask = (1 << 3)-1;
format->info.h264 = default_h264_info;
break;
}
case SPA_MEDIA_SUBTYPE_MJPG:
{
static SpaPropInfo mjpg_prop_info[] = {
{ SPA_PROP_ID_VIDEO_INFO, offsetof (SpaFormatVideo, info.mjpg) },
{ SPA_PROP_ID_VIDEO_SIZE, offsetof (SpaFormatVideo, info.mjpg.size) },
{ SPA_PROP_ID_VIDEO_FRAMERATE, offsetof (SpaFormatVideo, info.mjpg.framerate) },
{ SPA_PROP_ID_VIDEO_MAX_FRAMERATE, offsetof (SpaFormatVideo, info.mjpg.max_framerate) },
{ SPA_PROP_ID_VIDEO_INFO_MJPG, offsetof (SpaFormatVideo, info.mjpg) },
};
static const SpaVideoInfoMJPG default_mjpg_info = {
{ 320, 240 },
{ 1, 25 },
{ 1, 25 }
};
prop_info = mjpg_prop_info;
n_prop_info = SPA_N_ELEMENTS (mjpg_prop_info);
format->format.props.unset_mask = (1 << 3)-1;
format->info.raw = default_raw_info;
format->info.mjpg = default_mjpg_info;
break;
}
@ -583,6 +604,7 @@ spa_format_video_parse (const SpaFormat *format,
SpaPropValue value;
const SpaProps *props;
SpaResult res;
unsigned int idx;
if ((void *)format == (void *)vformat)
return SPA_RESULT_OK;
@ -590,18 +612,20 @@ spa_format_video_parse (const SpaFormat *format,
if (format->media_type != SPA_MEDIA_TYPE_VIDEO)
return SPA_RESULT_INVALID_MEDIA_TYPE;
spa_format_video_init (format->media_type,
if ((res = spa_format_video_init (format->media_type,
format->media_subtype,
vformat);
vformat)) < 0)
return res;
props = &format->props;
if ((res = spa_props_get_prop (props, spa_props_index_for_id (props, SPA_PROP_ID_VIDEO_INFO_RAW), &value)) < 0)
idx = spa_props_index_for_id (props, SPA_PROP_ID_VIDEO_INFO);
if ((res = spa_props_get_prop (props, idx, &value)) < 0)
goto fallback;
if (value.type != SPA_PROP_TYPE_POINTER)
if (props->prop_info[idx].type != SPA_PROP_TYPE_POINTER)
goto fallback;
memcpy (&vformat->info, value.value, value.size);
memcpy (&vformat->info, value.value, SPA_MIN (value.size, sizeof (SpaVideoInfoRaw)));
return SPA_RESULT_OK;

View file

@ -107,8 +107,8 @@ static const uint32_t min_uint32 = 1;
static const uint32_t max_uint32 = UINT32_MAX;
static const SpaPropRangeInfo uint32_range[] = {
{ "min", "Minimum value", 4, &min_uint32 },
{ "max", "Maximum value", 4, &max_uint32 },
{ "min", "Minimum value", { 4, &min_uint32 } },
{ "max", "Maximum value", { 4, &max_uint32 } },
};
enum {

View file

@ -88,21 +88,21 @@ static const double min_freq = 0.0;
static const double max_freq = 50000000.0;
static const SpaPropRangeInfo volume_range[] = {
{ "min", "Minimum value", sizeof (double), &min_volume },
{ "max", "Maximum value", sizeof (double), &max_volume },
{ "min", "Minimum value", { sizeof (double), &min_volume } },
{ "max", "Maximum value", { 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", "Sine", sizeof (uint32_t), &wave_val_sine },
{ "square", "Square", sizeof (uint32_t), &wave_val_square },
{ "sine", "Sine", { sizeof (uint32_t), &wave_val_sine } },
{ "square", "Square", { sizeof (uint32_t), &wave_val_square } },
};
static const SpaPropRangeInfo freq_range[] = {
{ "min", "Minimum value", sizeof (double), &min_freq },
{ "max", "Maximum value", sizeof (double), &max_freq },
{ "min", "Minimum value", { sizeof (double), &min_freq } },
{ "max", "Maximum value", { sizeof (double), &max_freq } },
};
enum {

View file

@ -324,7 +324,7 @@ enum_filter_format (const SpaFormat *filter, unsigned int index)
} else if (res == SPA_RESULT_PROPERTY_UNSET) {
if (index < pi->n_range_values)
video_format = *((SpaVideoFormat *)pi->range_values[index].value);
video_format = *((SpaVideoFormat *)pi->range_values[index].val.value);
}
} else {
if (index == 0)
@ -536,20 +536,20 @@ do_frmsize:
pi = &filter->props.prop_info[idx];
if (pi->range_type == SPA_PROP_RANGE_TYPE_MIN_MAX) {
if (filter_framesize (&state->frmsize, pi->range_values[0].value,
pi->range_values[1].value,
if (filter_framesize (&state->frmsize, pi->range_values[0].val.value,
pi->range_values[1].val.value,
&step))
goto have_size;
} else if (pi->range_type == SPA_PROP_RANGE_TYPE_STEP) {
if (filter_framesize (&state->frmsize, pi->range_values[0].value,
pi->range_values[1].value,
pi->range_values[2].value))
if (filter_framesize (&state->frmsize, pi->range_values[0].val.value,
pi->range_values[1].val.value,
pi->range_values[2].val.value))
goto have_size;
} else if (pi->range_type == SPA_PROP_RANGE_TYPE_ENUM) {
unsigned int i;
for (i = 0; i < pi->n_range_values; i++) {
if (filter_framesize (&state->frmsize, pi->range_values[i].value,
pi->range_values[i].value,
if (filter_framesize (&state->frmsize, pi->range_values[i].val.value,
pi->range_values[i].val.value,
&step))
goto have_size;
}
@ -649,20 +649,20 @@ have_size:
&step))
goto have_framerate;
} else if (pi->range_type == SPA_PROP_RANGE_TYPE_MIN_MAX) {
if (filter_framerate (&state->frmival, pi->range_values[0].value,
pi->range_values[1].value,
if (filter_framerate (&state->frmival, pi->range_values[0].val.value,
pi->range_values[1].val.value,
&step))
goto have_framerate;
} else if (pi->range_type == SPA_PROP_RANGE_TYPE_STEP) {
if (filter_framerate (&state->frmival, pi->range_values[0].value,
pi->range_values[1].value,
pi->range_values[2].value))
if (filter_framerate (&state->frmival, pi->range_values[0].val.value,
pi->range_values[1].val.value,
pi->range_values[2].val.value))
goto have_framerate;
} else if (pi->range_type == SPA_PROP_RANGE_TYPE_ENUM) {
unsigned int i;
for (i = 0; i < pi->n_range_values; i++) {
if (filter_framerate (&state->frmival, pi->range_values[i].value,
pi->range_values[i].value,
if (filter_framerate (&state->frmival, pi->range_values[i].val.value,
pi->range_values[i].val.value,
&step))
goto have_framerate;
}
@ -676,20 +676,22 @@ have_framerate:
fmt->ranges[i].description = NULL;
if (state->frmival.type == V4L2_FRMIVAL_TYPE_DISCRETE) {
fmt->infos[pi].range_type = SPA_PROP_RANGE_TYPE_ENUM;
fmt->ranges[i].size = sizeof (SpaFraction);
fmt->framerates[i].num = state->frmival.discrete.denominator;
fmt->framerates[i].denom = state->frmival.discrete.numerator;
fmt->ranges[i].value = &fmt->framerates[i];
fmt->ranges[i].val.size = sizeof (SpaFraction);
fmt->ranges[i].val.value = &fmt->framerates[i];
i++;
state->frmival.index++;
} else if (state->frmival.type == V4L2_FRMIVAL_TYPE_CONTINUOUS ||
state->frmival.type == V4L2_FRMIVAL_TYPE_STEPWISE) {
fmt->framerates[0].num = state->frmival.stepwise.min.denominator;
fmt->framerates[0].denom = state->frmival.stepwise.min.numerator;
fmt->ranges[0].value = &fmt->framerates[0];
fmt->ranges[0].val.size = sizeof (SpaFraction);
fmt->ranges[0].val.value = &fmt->framerates[0];
fmt->framerates[1].num = state->frmival.stepwise.max.denominator;
fmt->framerates[1].denom = state->frmival.stepwise.max.numerator;
fmt->ranges[1].value = &fmt->framerates[1];
fmt->ranges[1].val.size = sizeof (SpaFraction);
fmt->ranges[1].val.value = &fmt->framerates[1];
if (state->frmival.type == V4L2_FRMIVAL_TYPE_CONTINUOUS) {
fmt->infos[pi].range_type = SPA_PROP_RANGE_TYPE_MIN_MAX;
i = 2;
@ -697,7 +699,8 @@ have_framerate:
fmt->infos[pi].range_type = SPA_PROP_RANGE_TYPE_STEP;
fmt->framerates[2].num = state->frmival.stepwise.step.denominator;
fmt->framerates[2].denom = state->frmival.stepwise.step.numerator;
fmt->ranges[2].value = &fmt->framerates[2];
fmt->ranges[2].val.size = sizeof (SpaFraction);
fmt->ranges[2].val.value = &fmt->framerates[2];
i = 3;
}
break;

View file

@ -63,8 +63,8 @@ static const double max_volume = 10.0;
static const bool default_mute = false;
static const SpaPropRangeInfo volume_range[] = {
{ "min", "Minimum value", sizeof (double), &min_volume },
{ "max", "Maximum value", sizeof (double), &max_volume },
{ "min", "Minimum value", { sizeof (double), &min_volume } },
{ "max", "Maximum value", { sizeof (double), &max_volume } },
};
enum {

View file

@ -188,7 +188,6 @@ make_nodes (AppData *data)
if ((res = spa_node_get_props (data->sink, &props)) < 0)
printf ("got get_props error %d\n", res);
value.type = SPA_PROP_TYPE_STRING;
value.value = "hw:0";
value.size = strlen (value.value)+1;
spa_props_set_prop (props, spa_props_index_for_name (props, "device"), &value);
@ -229,7 +228,6 @@ negotiate_formats (AppData *data)
props = &format->props;
value.type = SPA_PROP_TYPE_UINT32;
value.size = sizeof (uint32_t);
value.value = &val;

View file

@ -213,7 +213,6 @@ make_nodes (AppData *data, const char *device)
if ((res = spa_node_get_props (data->source, &props)) < 0)
printf ("got get_props error %d\n", res);
value.type = SPA_PROP_TYPE_STRING;
value.value = device ? device : "/dev/video0";
value.size = strlen (value.value)+1;
spa_props_set_prop (props, spa_props_index_for_name (props, "device"), &value);