From 636cd255cef7fc2432ad10d97561008d557fa6b4 Mon Sep 17 00:00:00 2001 From: Thibault Saunier Date: Wed, 21 Dec 2016 13:24:37 -0300 Subject: [PATCH] encoding-profile: Handle path to serialized target when deserializing a profile The synthax is path/to/encoding/profile.gep:profilename --- gst-libs/gst/pbutils/encoding-profile.c | 47 +++++++++++++++++++++++++++++---- gst-libs/gst/pbutils/encoding-target.c | 2 +- 2 files changed, 43 insertions(+), 6 deletions(-) diff --git a/gst-libs/gst/pbutils/encoding-profile.c b/gst-libs/gst/pbutils/encoding-profile.c index 3418162..2df7589 100644 --- a/gst-libs/gst/pbutils/encoding-profile.c +++ b/gst-libs/gst/pbutils/encoding-profile.c @@ -1548,6 +1548,46 @@ parse_encoding_profile (const gchar * value) return res; } +static GstEncodingProfile * +profile_from_string (const gchar * string) +{ + GstEncodingProfile *profile; + gchar *filename_end; + + profile = combo_search (string); + + if (profile) + return profile; + + filename_end = g_strrstr (string, ".gep"); + if (filename_end) { + GstEncodingTarget *target; + gchar *profilename = NULL, *filename; + + if (filename_end[4] == ':') + profilename = g_strdup (&filename_end[5]); + + if (filename_end[4] == '\0' || profilename) { + filename = g_strndup (string, filename_end - string + strlen (".gep")); + + target = gst_encoding_target_load_from_file (filename, NULL); + if (target) { + profile = gst_encoding_target_get_profile (target, + profilename ? profilename : "default"); + gst_encoding_target_unref (target); + } + + g_free (profilename); + g_free (filename); + } + } + + if (!profile) + profile = parse_encoding_profile (string); + + return profile; +} + /* GValue transform function */ static void string_to_profile_transform (const GValue * src_value, GValue * dest_value) @@ -1557,7 +1597,7 @@ string_to_profile_transform (const GValue * src_value, GValue * dest_value) profilename = g_value_get_string (src_value); - profile = combo_search (profilename); + profile = profile_from_string (profilename); if (profile) g_value_take_object (dest_value, (GObject *) profile); @@ -1568,10 +1608,7 @@ gst_encoding_profile_deserialize_valfunc (GValue * value, const gchar * s) { GstEncodingProfile *profile; - profile = combo_search (s); - - if (!profile) - profile = parse_encoding_profile (s); + profile = profile_from_string (s); if (profile) { g_value_take_object (value, (GObject *) profile); diff --git a/gst-libs/gst/pbutils/encoding-target.c b/gst-libs/gst/pbutils/encoding-target.c index a7472ca..464874c 100644 --- a/gst-libs/gst/pbutils/encoding-target.c +++ b/gst-libs/gst/pbutils/encoding-target.c @@ -816,7 +816,7 @@ gst_encoding_target_load (const gchar * name, const gchar * category, GError ** error) { gint i; - gchar *p, *lname, *lfilename, *tldir, **encoding_target_dirs; + gchar *p, *lname, *lfilename = NULL, *tldir, **encoding_target_dirs; const gchar *envvar; GstEncodingTarget *target = NULL; -- 2.7.4