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);