mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-23 08:46:40 +00:00
gst-validate: add formatting for GstAudioMeta
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6461>
This commit is contained in:
parent
8d003f00e9
commit
cbc58c0483
1 changed files with 81 additions and 19 deletions
|
@ -31,6 +31,7 @@
|
||||||
|
|
||||||
#include <gst/gst.h>
|
#include <gst/gst.h>
|
||||||
#include <gst/video/video.h>
|
#include <gst/video/video.h>
|
||||||
|
#include <gst/audio/gstaudiometa.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <glib/gprintf.h>
|
#include <glib/gprintf.h>
|
||||||
|
@ -216,30 +217,55 @@ validate_flow_format_caps (const GstCaps * caps, gchar ** wanted_fields,
|
||||||
return caps_str;
|
return caps_str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Returns a newly-allocated string for the provided enum nickname, or NULL */
|
||||||
static gchar *
|
static gchar *
|
||||||
buffer_get_flags_string (GstBuffer * buffer)
|
validate_flow_get_enum_nickname (GType enum_type, gint enum_value)
|
||||||
{
|
{
|
||||||
GFlagsClass *flags_class =
|
gchar *nickname = NULL;
|
||||||
G_FLAGS_CLASS (g_type_class_ref (gst_buffer_flags_get_type ()));
|
|
||||||
GstBufferFlags flags = GST_BUFFER_FLAGS (buffer);
|
|
||||||
GString *string = NULL;
|
|
||||||
|
|
||||||
while (1) {
|
GEnumClass *enum_class = G_ENUM_CLASS (g_type_class_ref (enum_type));
|
||||||
GFlagsValue *value = g_flags_get_first_value (flags_class, flags);
|
if (enum_class) {
|
||||||
if (!value)
|
GEnumValue *value = g_enum_get_value (enum_class, enum_value);
|
||||||
break;
|
if (value)
|
||||||
|
nickname = g_strdup (value->value_nick);
|
||||||
|
|
||||||
if (string == NULL)
|
g_type_class_unref (enum_class);
|
||||||
string = g_string_new (NULL);
|
|
||||||
else
|
|
||||||
g_string_append (string, " ");
|
|
||||||
|
|
||||||
g_string_append (string, value->value_nick);
|
|
||||||
flags &= ~value->value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (string != NULL) ? g_string_free (string, FALSE) : NULL;
|
return nickname;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Returns a newly-allocated string with the space-separated list of nicknames of the provided flags, or NULL */
|
||||||
|
static gchar *
|
||||||
|
validate_flow_get_flags_nicknames (GType flags_type, guint flags_value)
|
||||||
|
{
|
||||||
|
GString *nicknames = NULL;
|
||||||
|
|
||||||
|
GFlagsClass *flags_class = G_FLAGS_CLASS (g_type_class_ref (flags_type));
|
||||||
|
if (flags_class) {
|
||||||
|
guint flags = flags_value;
|
||||||
|
|
||||||
|
for (;;) {
|
||||||
|
GFlagsValue *value = g_flags_get_first_value (flags_class, flags);
|
||||||
|
if (!value)
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (nicknames)
|
||||||
|
g_string_append (nicknames, " ");
|
||||||
|
else
|
||||||
|
nicknames = g_string_new (NULL);
|
||||||
|
|
||||||
|
g_string_append (nicknames, value->value_nick);
|
||||||
|
flags &= ~value->value;
|
||||||
|
|
||||||
|
if (flags == 0)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_type_class_unref (flags_class);
|
||||||
|
}
|
||||||
|
|
||||||
|
return nicknames ? g_string_free (nicknames, FALSE) : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Returns a newly-allocated string describing the metas on this buffer, or NULL */
|
/* Returns a newly-allocated string describing the metas on this buffer, or NULL */
|
||||||
|
@ -270,6 +296,40 @@ buffer_get_meta_string (GstBuffer * buffer)
|
||||||
"GstVideoRegionOfInterestMeta[x=%" G_GUINT32_FORMAT ", y=%"
|
"GstVideoRegionOfInterestMeta[x=%" G_GUINT32_FORMAT ", y=%"
|
||||||
G_GUINT32_FORMAT ", width=%" G_GUINT32_FORMAT ", height=%"
|
G_GUINT32_FORMAT ", width=%" G_GUINT32_FORMAT ", height=%"
|
||||||
G_GUINT32_FORMAT "]", roi->x, roi->y, roi->w, roi->h);
|
G_GUINT32_FORMAT "]", roi->x, roi->y, roi->w, roi->h);
|
||||||
|
|
||||||
|
} else if (meta->info->api == GST_AUDIO_META_API_TYPE) {
|
||||||
|
GstAudioMeta *audio_meta = (GstAudioMeta *) meta;
|
||||||
|
|
||||||
|
gint channels = GST_AUDIO_INFO_CHANNELS (&audio_meta->info);
|
||||||
|
gchar *layout = validate_flow_get_enum_nickname (GST_TYPE_AUDIO_LAYOUT,
|
||||||
|
GST_AUDIO_INFO_LAYOUT (&audio_meta->info));
|
||||||
|
gchar *flags = validate_flow_get_flags_nicknames (GST_TYPE_AUDIO_FLAGS,
|
||||||
|
GST_AUDIO_INFO_FLAGS (&audio_meta->info));
|
||||||
|
|
||||||
|
g_string_append_printf (s,
|
||||||
|
"GstAudioMeta[format=%s, layout=%s, rate=%d, bpf=%d, flags=%s, channels=%d, position=[",
|
||||||
|
GST_AUDIO_INFO_NAME (&audio_meta->info), layout,
|
||||||
|
GST_AUDIO_INFO_RATE (&audio_meta->info),
|
||||||
|
GST_AUDIO_INFO_BPF (&audio_meta->info), flags, channels);
|
||||||
|
|
||||||
|
if (!GST_AUDIO_INFO_IS_UNPOSITIONED (&audio_meta->info)) {
|
||||||
|
for (gint i = 0; i < channels; ++i) {
|
||||||
|
if (i > 0)
|
||||||
|
g_string_append (s, ", ");
|
||||||
|
|
||||||
|
gchar *position =
|
||||||
|
validate_flow_get_enum_nickname (GST_TYPE_AUDIO_CHANNEL_POSITION,
|
||||||
|
GST_AUDIO_INFO_POSITION (&audio_meta->info, i));
|
||||||
|
g_string_append (s, position);
|
||||||
|
g_free (position);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
g_string_append (s, "]]");
|
||||||
|
|
||||||
|
g_free (layout);
|
||||||
|
g_free (flags);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
g_string_append (s, desc);
|
g_string_append (s, desc);
|
||||||
}
|
}
|
||||||
|
@ -358,7 +418,9 @@ validate_flow_format_buffer (GstBuffer * buffer, gint checksum_type,
|
||||||
buffer_parts[buffer_parts_index++] = g_strdup_printf ("dur=%s", time_str);
|
buffer_parts[buffer_parts_index++] = g_strdup_printf ("dur=%s", time_str);
|
||||||
}
|
}
|
||||||
|
|
||||||
flags_str = buffer_get_flags_string (buffer);
|
flags_str =
|
||||||
|
validate_flow_get_flags_nicknames (GST_TYPE_BUFFER_FLAGS,
|
||||||
|
GST_BUFFER_FLAGS (buffer));
|
||||||
if (flags_str && use_field ("flags", logged_fields, ignored_fields)) {
|
if (flags_str && use_field ("flags", logged_fields, ignored_fields)) {
|
||||||
buffer_parts[buffer_parts_index++] =
|
buffer_parts[buffer_parts_index++] =
|
||||||
g_strdup_printf ("flags=%s", flags_str);
|
g_strdup_printf ("flags=%s", flags_str);
|
||||||
|
|
Loading…
Reference in a new issue