From af91d232042d9ffe9980192041e8eae9d6e7f5c7 Mon Sep 17 00:00:00 2001 From: Stefan Sauer Date: Sat, 16 Jan 2016 18:55:07 +0100 Subject: tracer: use the new flags to create the optional field in the format string This spares us explicitly listing the field in the spec. and thus hide this implementation detail. --- gst/gsttracerrecord.c | 19 +++++++++++++++++-- gst/gsttracerrecord.h | 4 +++- 2 files changed, 20 insertions(+), 3 deletions(-) (limited to 'gst') diff --git a/gst/gsttracerrecord.c b/gst/gsttracerrecord.c index 060aead6d..73ecc7dfa 100644 --- a/gst/gsttracerrecord.c +++ b/gst/gsttracerrecord.c @@ -32,6 +32,7 @@ #define GST_USE_UNSTABLE_API #include "gst_private.h" +#include "gstenumtypes.h" #include "gstinfo.h" #include "gststructure.h" #include "gsttracerrecord.h" @@ -73,14 +74,28 @@ build_field_template (GQuark field_id, const GValue * value, gpointer user_data) const GstStructure *sub; GValue template_value = { 0, }; GType type; + GstTracerValueFlags flags; gboolean res; g_return_val_if_fail (G_VALUE_TYPE (value) == GST_TYPE_STRUCTURE, FALSE); sub = gst_value_get_structure (value); - type = g_value_get_gtype (gst_structure_get_value (sub, "type")); - g_value_init (&template_value, type); + gst_structure_get (sub, "type", G_TYPE_GTYPE, &type, "flags", + GST_TYPE_TRACER_VALUE_FLAGS, &flags, NULL); + + if (flags & GST_TRACER_VALUE_FLAGS_OPTIONAL) { + gchar *opt_name = g_strconcat ("have-", g_quark_to_string (field_id), NULL); + + /* add a boolean field, that indicates the presence of the next field */ + g_value_init (&template_value, G_TYPE_BOOLEAN); + res = + priv__gst_structure_append_template_to_gstring (g_quark_from_string + (opt_name), &template_value, s); + g_value_unset (&template_value); + g_free (opt_name); + } + g_value_init (&template_value, type); res = priv__gst_structure_append_template_to_gstring (field_id, &template_value, s); g_value_unset (&template_value); diff --git a/gst/gsttracerrecord.h b/gst/gsttracerrecord.h index 9aef0a67b..5e66fa671 100644 --- a/gst/gsttracerrecord.h +++ b/gst/gsttracerrecord.h @@ -70,7 +70,9 @@ typedef enum /** * GstTracerValueFlags: * @GST_TRACER_VALUE_FLAGS_NONE: no flags - * @GST_TRACER_VALUE_FLAGS_OPTIONAL: the value is optional + * @GST_TRACER_VALUE_FLAGS_OPTIONAL: the value is optional. When using this flag + * one need to have an additional boolean arg before this value in the + * var-args list passed to gst_tracer_record_log(). * @GST_TRACER_VALUE_FLAGS_AGGREGATED: the value is combined since the start of * tracing * -- cgit v1.2.3