encodebing: Use the preset_name as the factory name and preset as the name of the...
authorThibault Saunier <thibault.saunier@collabora.com>
Sat, 15 Dec 2012 17:43:40 +0000 (14:43 -0300)
committerThibault Saunier <thibault.saunier@collabora.com>
Mon, 17 Dec 2012 13:12:11 +0000 (10:12 -0300)
The naming is not perfect, but at least we can keep the exact same behaviour as
before.

gst-libs/gst/pbutils/encoding-profile.c
gst/encoding/gstencodebin.c
tests/check/elements/encodebin.c

index b8e9714..3ae2ea1 100644 (file)
@@ -261,8 +261,8 @@ gst_encoding_profile_get_format (GstEncodingProfile * profile)
  * gst_encoding_profile_get_preset:
  * @profile: a #GstEncodingProfile
  *
- * Returns: the name of the #GstElement that implements #GstPreset to
- * be used in the profile.
+ * Returns: the name of the #GstPreset to be used in the profile.
+ * This is the name that has been set when saving the preset.
  */
 const gchar *
 gst_encoding_profile_get_preset (GstEncodingProfile * profile)
@@ -274,8 +274,7 @@ gst_encoding_profile_get_preset (GstEncodingProfile * profile)
  * gst_encoding_profile_get_preset_name:
  * @profile: a #GstEncodingProfile
  *
- * Returns: the name of the #GstPreset to be used in the profile.
- * This is the name that has been set when saving the preset.
+ * Returns: the name of the #GstPreset factory to be used in the profile.
  */
 const gchar *
 gst_encoding_profile_get_preset_name (GstEncodingProfile * profile)
@@ -368,6 +367,7 @@ gst_encoding_profile_set_format (GstEncodingProfile * profile, GstCaps * format)
  *
  * Sets the name of the #GstElement that implements the #GstPreset interface
  * to use for the profile.
+ * This is the name that has been set when saving the preset.
  */
 void
 gst_encoding_profile_set_preset (GstEncodingProfile * profile,
@@ -383,8 +383,7 @@ gst_encoding_profile_set_preset (GstEncodingProfile * profile,
  * @profile: a #GstEncodingProfile
  * @preset_name: The name of the preset to use in this @profile.
  *
- * Sets the name of the #GstPreset to be used in the profile.
- * This is the name that has been set when saving the preset.
+ * Sets the name of the #GstPreset's factory to be used in the profile.
  */
 void
 gst_encoding_profile_set_preset_name (GstEncodingProfile * profile,
index e226f94..fc32bbd 100644 (file)
@@ -825,24 +825,26 @@ _create_element_and_set_preset (GstElementFactory * factory,
       " preset name: %s)", GST_OBJECT_NAME (factory), preset, preset_name);
 
   res = gst_element_factory_create (factory, name);
-  if (preset) {
-    if (g_strcmp0 (gst_object_get_name (GST_OBJECT (factory)), preset) == 0) {
-      if (preset_name) {
-        if (!gst_preset_load_preset (GST_PRESET (res), preset_name)) {
-          GST_WARNING ("Couldn't set preset [%s] on element [%s]",
-              preset, GST_OBJECT_NAME (factory));
-          gst_object_unref (res);
-          res = NULL;
-        }
-      } else {
-        GST_DEBUG ("Using a preset with no preset name, making use of the"
-            " proper element without setting any property");
+
+  if (preset && GST_IS_PRESET (res)) {
+    if (preset_name == NULL ||
+        g_strcmp0 (GST_OBJECT_NAME (factory), preset_name) == 0) {
+
+      if (!gst_preset_load_preset (GST_PRESET (res), preset)) {
+        GST_WARNING ("Couldn't set preset [%s] on element [%s]",
+            preset, GST_OBJECT_NAME (factory));
+        gst_object_unref (res);
+        res = NULL;
       }
     } else {
-      gst_object_unref (res);
-      res = NULL;
+      GST_DEBUG ("Using a preset with no preset name, making use of the"
+          " proper element without setting any property");
     }
+  } else if (preset_name && g_strcmp0 (GST_OBJECT_NAME (factory), preset_name)) {
+    gst_object_unref (res);
+    res = NULL;
   }
+  /* Else we keep it */
 
   return res;
 }
index 5f193b4..1551538 100644 (file)
@@ -220,8 +220,8 @@ GST_START_TEST (test_encodebin_preset)
   /* Give a name someone should never use outside of that test */
   gst_preset_save_preset (oggmuxpreset, "test_encodebin_preset");
 
-  gst_encoding_profile_set_preset (prof, "oggmux");
-  gst_encoding_profile_set_preset_name (prof, "test_encodebin_preset");
+  gst_encoding_profile_set_preset (prof, "test_encodebin_preset");
+  gst_encoding_profile_set_preset_name (prof, "oggmux");
 
   g_object_set (ebin, "profile", prof, NULL);