tools: Use a proper implementation of get_flags_from_string

This commit is contained in:
Thibault Saunier 2019-05-01 17:28:26 -04:00
parent dafc1cd8d1
commit ed9cbfed92
3 changed files with 14 additions and 15 deletions

View file

@ -86,9 +86,7 @@ _parse_track_type (const gchar * option_name, const gchar * value,
{
ParsedOptions *opts = &self->priv->parsed_options;
opts->track_types = get_flags_from_string (GES_TYPE_TRACK_TYPE, value);
if (opts->track_types == 0)
if (!get_flags_from_string (GES_TYPE_TRACK_TYPE, value, &opts->track_types))
return FALSE;
return TRUE;

View file

@ -84,21 +84,22 @@ sanitize_timeline_description (int argc, char **argv)
return string;
}
guint
get_flags_from_string (GType type, const gchar * str_flags)
gboolean
get_flags_from_string (GType type, const gchar * str_flags, guint * flags)
{
guint i;
gint flags = 0;
GFlagsClass *class = g_type_class_ref (type);
GValue value = G_VALUE_INIT;
g_value_init (&value, type);
for (i = 0; i < class->n_values; i++) {
if (g_strrstr (str_flags, class->values[i].value_nick)) {
flags |= class->values[i].value;
}
if (!gst_value_deserialize (&value, str_flags)) {
g_value_unset (&value);
return FALSE;
}
g_type_class_unref (class);
return flags;
*flags = g_value_get_flags (&value);
g_value_unset (&value);
return TRUE;
}
gchar *

View file

@ -20,7 +20,7 @@
#include <gst/pbutils/encoding-profile.h>
gchar * sanitize_timeline_description (int argc, char **argv);
guint get_flags_from_string (GType type, const gchar * str_flags);
gboolean get_flags_from_string (GType type, const gchar * str_flags, guint *val);
gchar * ensure_uri (const gchar * location);
GstEncodingProfile * parse_encoding_profile (const gchar * format);
void print_enum (GType enum_type);