encoding-target: Allow using name and targets from serialized file
authorThibault Saunier <thibault.saunier@osg.samsung.com>
Wed, 21 Dec 2016 14:05:30 +0000 (11:05 -0300)
committerThibault Saunier <thibault.saunier@osg.samsung.com>
Fri, 23 Dec 2016 20:40:23 +0000 (17:40 -0300)
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

index b236b10..a7472ca 100644 (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);