encodebin: Add a way to enable/disabled a GstEncodingProfile
authorThibault Saunier <tsaunier@gnome.org>
Thu, 7 May 2015 08:26:47 +0000 (10:26 +0200)
committerThibault Saunier <tsaunier@gnome.org>
Mon, 1 Jun 2015 08:22:31 +0000 (10:22 +0200)
Summary:
So that the user can easily use the same encoding profile to render
with/without audio/video stream.

API:
  gst_encoding_profile_is_disabled
  gst_encoding_pofile_set_enabled

https://bugzilla.gnome.org/show_bug.cgi?id=749056

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

index 0258250..22c8fe4 100644 (file)
@@ -2185,12 +2185,14 @@ gst_encoding_profile_get_restriction
 gst_encoding_profile_get_file_extension
 gst_encoding_profile_set_name
 gst_encoding_profile_set_description
+gst_encoding_profile_set_enabled
 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
+gst_encoding_profile_is_enabled
 gst_encoding_profile_get_input_caps
 gst_encoding_profile_get_type_nick
 <SUBSECTION container>
index 770e2ce..c1f502e 100644 (file)
@@ -189,6 +189,7 @@ struct _GstEncodingProfile
   guint presence;
   GstCaps *restriction;
   gboolean allow_dynamic_output;
+  gboolean enabled;
 };
 
 struct _GstEncodingProfileClass
@@ -401,6 +402,20 @@ gst_encoding_profile_get_presence (GstEncodingProfile * profile)
 }
 
 /**
+ * gst_encoding_profile_get_enabled:
+ * @profile: a #GstEncodingProfile
+ *
+ * Returns: Whther @profile is enabled or not
+ */
+gboolean
+gst_encoding_profile_is_enabled (GstEncodingProfile * profile)
+{
+  g_return_val_if_fail (GST_IS_ENCODING_PROFILE (profile), FALSE);
+
+  return profile->enabled;
+}
+
+/**
  * gst_encoding_profile_get_restriction:
  * @profile: a #GstEncodingProfile
  *
@@ -543,6 +558,22 @@ gst_encoding_profile_set_presence (GstEncodingProfile * profile, guint presence)
 }
 
 /**
+ * gst_encoding_profile_set_enabled:
+ * @profile: a #GstEncodingProfile
+ * @enabled: %FALSE to disable #profile, %TRUE to enable it
+ *
+ * Set whether the profile should be used or not.
+ */
+void
+gst_encoding_profile_set_enabled (GstEncodingProfile * profile,
+    gboolean enabled)
+{
+  g_return_if_fail (GST_IS_ENCODING_PROFILE (profile));
+
+  profile->enabled = enabled;
+}
+
+/**
  * gst_encoding_profile_set_restriction:
  * @profile: a #GstEncodingProfile
  * @restriction: (transfer full): the restriction to apply
@@ -868,6 +899,7 @@ common_creation (GType objtype, GstCaps * format, const gchar * preset,
   prof->presence = presence;
   prof->preset_name = NULL;
   prof->allow_dynamic_output = TRUE;
+  prof->enabled = TRUE;
 
   return prof;
 }
index 401c547..a667f8c 100644 (file)
@@ -152,6 +152,9 @@ GstEncodingProfile * gst_encoding_profile_find (const gchar *targetname,
                                                 const gchar *profilename,
                                                 const gchar *category);
 
+gboolean        gst_encoding_profile_is_enabled        (GstEncodingProfile *profile);
+void            gst_encoding_profile_set_enabled       (GstEncodingProfile *profile,
+                                                         gboolean enabled);
 /* GstEncodingContainerProfile API */
 gboolean        gst_encoding_container_profile_add_profile       (GstEncodingContainerProfile *container,
                                                                   GstEncodingProfile *profile);
index 212cb46..8895208 100644 (file)
@@ -659,8 +659,15 @@ next_unused_stream_profile (GstEncodeBin * ebin, GType ptype,
 
         if (profilename && !strcmp (name, profilename)) {
           guint presence = gst_encoding_profile_get_presence (sprof);
+
           GST_DEBUG ("Found profile matching the requested name");
 
+          if (!gst_encoding_profile_is_enabled (sprof)) {
+            GST_INFO_OBJECT (ebin, "%p is disabled, not using it", sprof);
+
+            return NULL;
+          }
+
           if (presence == 0
               || presence > stream_profile_used_count (ebin, sprof))
             return sprof;
@@ -686,7 +693,9 @@ next_unused_stream_profile (GstEncodeBin * ebin, GType ptype,
       if (G_TYPE_FROM_INSTANCE (sprof) == ptype) {
         guint presence = gst_encoding_profile_get_presence (sprof);
         GST_DEBUG ("Found a stream profile with the same type");
-        if (presence == 0
+        if (!gst_encoding_profile_is_enabled (sprof)) {
+          GST_INFO_OBJECT (ebin, "%p is disabled, not using it", sprof);
+        } else if (presence == 0
             || (presence > stream_profile_used_count (ebin, sprof)))
           return sprof;
       } else if (caps && ptype == G_TYPE_NONE) {
@@ -1873,7 +1882,8 @@ create_elements_and_pads (GstEncodeBin * ebin)
       GST_DEBUG ("Trying stream profile with presence %d",
           gst_encoding_profile_get_presence (sprof));
 
-      if (gst_encoding_profile_get_presence (sprof) != 0) {
+      if (gst_encoding_profile_get_presence (sprof) != 0 &&
+          gst_encoding_profile_is_enabled (sprof)) {
         if (G_UNLIKELY (_create_stream_group (ebin, sprof, NULL, NULL) == NULL))
           goto stream_error;
       }