From 85979f996d477c2cae9f108fe06461a1ad105d21 Mon Sep 17 00:00:00 2001 From: Thibault Saunier Date: Wed, 21 Dec 2016 11:05:30 -0300 Subject: [PATCH] encoding-target: Allow using name and targets from serialized file We used to only care about the name of the files even if the name is defined in the encoding target serialized file. That commit also allows user to define several names for a single target file (using a ';' between the names) which allows us to have a target for youtube that is called 'youtube;yt' or a target for 'ogg;ogv;oga' file extension. --- gst-libs/gst/pbutils/encoding-target.c | 30 ++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/gst-libs/gst/pbutils/encoding-target.c b/gst-libs/gst/pbutils/encoding-target.c index b236b10aa7..a7472ca30b 100644 --- a/gst-libs/gst/pbutils/encoding-target.c +++ b/gst-libs/gst/pbutils/encoding-target.c @@ -179,6 +179,10 @@ validate_name (const gchar * name) /* if an hyphen, continue */ if (name[i] == '-') continue; + /* if an ';', continue (list delimiter) */ + if (name[i] == ';') { + continue; + } /* remaining should only be ascii letters */ if (!g_ascii_isalpha (name[i])) return FALSE; @@ -862,6 +866,32 @@ gst_encoding_target_load (const gchar * name, const gchar * category, g_free (tldir); } + if (!target) { + GList *tmp, *targets = gst_encoding_list_all_targets (NULL); + + for (tmp = targets; tmp; tmp = tmp->next) { + gint i; + GstEncodingTarget *tmptarget = tmp->data; + gchar **names = g_strsplit (tmptarget->name, ";", -1); + + for (i = 0; names[i]; i++) { + if (!g_strcmp0 (names[i], lname) && (!category || + !g_strcmp0 (tmptarget->category, category))) { + target = gst_object_ref (tmptarget); + + break; + } + } + g_strfreev (names); + + if (target) + break; + } + + g_list_free_full (targets, gst_object_unref); + } + + done: g_free (lfilename); g_free (lname);