encoding-profile: Let the user decide what preset name to use
authorThibault Saunier <thibault.saunier@collabora.com>
Wed, 5 Dec 2012 18:21:43 +0000 (15:21 -0300)
committerThibault Saunier <thibault.saunier@collabora.com>
Wed, 5 Dec 2012 20:36:21 +0000 (17:36 -0300)
It was possible to decide only what #GstElement implementing #GstPreset
to use during the encoding, we can now let the user select a specific preset previously
saved using #gst_preset_save_preset specifying the name chosen when it was saved
in the gst_encoding_profile_set_preset_name.

Actually loading a preset with %NULL as a name would have always failed, so
in the current state of the API that feature is unusable

API:
  gst_encoding_profile_set_preset_name
  gst_encoding_profile_get_preset_name

docs/libs/gst-plugins-base-libs-sections.txt
gst-libs/gst/pbutils/encoding-profile.c
gst-libs/gst/pbutils/encoding-profile.h

index c2d4632..e9065db 100644 (file)
@@ -1851,12 +1851,14 @@ gst_encoding_profile_get_name
 gst_encoding_profile_get_description
 gst_encoding_profile_get_format
 gst_encoding_profile_get_preset
+gst_encoding_profile_get_preset_name
 gst_encoding_profile_get_presence
 gst_encoding_profile_get_restriction
 gst_encoding_profile_set_name
 gst_encoding_profile_set_description
 gst_encoding_profile_set_format
 gst_encoding_profile_set_preset
+gst_encoding_profile_set_preset_name
 gst_encoding_profile_set_restriction
 gst_encoding_profile_set_presence
 gst_encoding_profile_is_equal
index e9de791..b2221df 100644 (file)
  *   gchar *category = (gchar *) tmpc->data;
  *
  *   ... and we can list all targets within that category ...
- *   
+ *
  *   targets = gst_encoding_target_list_all (category);
  *
  *   ... and show a list to our users ...
@@ -138,6 +138,7 @@ struct _GstEncodingProfile
   gchar *description;
   GstCaps *format;
   gchar *preset;
+  gchar *preset_name;
   guint presence;
   GstCaps *restriction;
 };
@@ -260,7 +261,8 @@ gst_encoding_profile_get_format (GstEncodingProfile * profile)
  * gst_encoding_profile_get_preset:
  * @profile: a #GstEncodingProfile
  *
- * Returns: the name of the #GstPreset to be used in the profile.
+ * Returns: the name of the #GstElement that implements #GstPreset to
+ * be used in the profile.
  */
 const gchar *
 gst_encoding_profile_get_preset (GstEncodingProfile * profile)
@@ -269,6 +271,19 @@ 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.
+ */
+const gchar *
+gst_encoding_profile_get_preset_name (GstEncodingProfile * profile)
+{
+  return profile->preset_name;
+}
+
+/**
  * gst_encoding_profile_get_presence:
  * @profile: a #GstEncodingProfile
  *
@@ -351,7 +366,8 @@ gst_encoding_profile_set_format (GstEncodingProfile * profile, GstCaps * format)
  * @profile: a #GstEncodingProfile
  * @preset: the element preset to use
  *
- * Sets the preset to use for the profile.
+ * Sets the name of the #GstElement that implements the #GstPreset interface
+ * to use for the profile.
  */
 void
 gst_encoding_profile_set_preset (GstEncodingProfile * profile,
@@ -363,6 +379,23 @@ gst_encoding_profile_set_preset (GstEncodingProfile * profile,
 }
 
 /**
+ * gst_encoding_profile_get_preset_name:
+ * @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.
+ */
+void
+gst_encoding_profile_set_preset_name (GstEncodingProfile * profile,
+    const gchar * preset_name)
+{
+  if (profile->preset_name)
+    g_free (profile->preset_name);
+  profile->preset_name = g_strdup (preset_name);
+}
+
+/**
  * gst_encoding_profile_set_presence:
  * @profile: a #GstEncodingProfile
  * @presence: the number of time the profile can be used
@@ -651,7 +684,7 @@ gst_encoding_container_profile_contains_profile (GstEncodingContainerProfile *
  * @profile: (transfer full): the #GstEncodingProfile to add.
  *
  * Add a #GstEncodingProfile to the list of profiles handled by @container.
- * 
+ *
  * No copy of @profile will be made, if you wish to use it elsewhere after this
  * method you should increment its reference count.
  *
@@ -697,6 +730,7 @@ common_creation (GType objtype, GstCaps * format, const gchar * preset,
   if (restriction)
     prof->restriction = gst_caps_ref (restriction);
   prof->presence = presence;
+  prof->preset_name = NULL;
 
   return prof;
 }
index 56addc8..22342f0 100644 (file)
@@ -126,11 +126,14 @@ GstCaps *       gst_encoding_profile_get_format         (GstEncodingProfile *pro
 void            gst_encoding_profile_set_format         (GstEncodingProfile *profile,
                                                          GstCaps *format);
 const gchar *   gst_encoding_profile_get_preset         (GstEncodingProfile *profile);
+const gchar *   gst_encoding_profile_get_preset_name    (GstEncodingProfile *profile);
 void            gst_encoding_profile_set_preset         (GstEncodingProfile *profile,
                                                          const gchar *preset);
 guint           gst_encoding_profile_get_presence       (GstEncodingProfile *profile);
 void            gst_encoding_profile_set_presence       (GstEncodingProfile *profile,
                                                          guint presence);
+void            gst_encoding_profile_set_preset_name    (GstEncodingProfile * profile,
+                                                         const gchar * preset_name);
 GstCaps *       gst_encoding_profile_get_restriction    (GstEncodingProfile *profile);
 void            gst_encoding_profile_set_restriction    (GstEncodingProfile *profile,
                                                          GstCaps *restriction);