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.
This commit is contained in:
Thibault Saunier 2016-12-21 11:05:30 -03:00
parent 2c9db14d03
commit 85979f996d

View file

@ -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);