gstfunnel: avoid access of freed pad
[platform/upstream/gstreamer.git] / gst / gstpluginfeature.c
index c72a1f7..3e1228e 100644 (file)
@@ -63,8 +63,7 @@ gst_plugin_feature_finalize (GObject * object)
 {
   GstPluginFeature *feature = GST_PLUGIN_FEATURE_CAST (object);
 
-  GST_DEBUG ("finalizing feature %p: '%s'", feature,
-      GST_PLUGIN_FEATURE_NAME (feature));
+  GST_DEBUG ("finalizing feature %p: '%s'", feature, GST_OBJECT_NAME (feature));
 
   if (feature->plugin != NULL) {
     g_object_remove_weak_pointer ((GObject *) feature->plugin,
@@ -103,7 +102,7 @@ gst_plugin_feature_load (GstPluginFeature * feature)
   g_return_val_if_fail (GST_IS_PLUGIN_FEATURE (feature), FALSE);
 
   GST_DEBUG ("loading plugin for feature %p; '%s'", feature,
-      GST_PLUGIN_FEATURE_NAME (feature));
+      GST_OBJECT_NAME (feature));
   if (feature->loaded)
     return gst_object_ref (feature);
 
@@ -115,8 +114,8 @@ gst_plugin_feature_load (GstPluginFeature * feature)
   GST_DEBUG ("loaded plugin %s", feature->plugin_name);
   gst_object_unref (plugin);
 
-  real_feature =
-      gst_registry_lookup_feature (gst_registry_get_default (), feature->name);
+  real_feature = gst_registry_lookup_feature (gst_registry_get (),
+      GST_OBJECT_NAME (feature));
 
   if (real_feature == NULL)
     goto disappeared;
@@ -129,85 +128,25 @@ gst_plugin_feature_load (GstPluginFeature * feature)
 load_failed:
   {
     GST_WARNING ("Failed to load plugin containing feature '%s'.",
-        GST_PLUGIN_FEATURE_NAME (feature));
+        GST_OBJECT_NAME (feature));
     return NULL;
   }
 disappeared:
   {
     GST_INFO
         ("Loaded plugin containing feature '%s', but feature disappeared.",
-        feature->name);
+        GST_OBJECT_NAME (feature));
     return NULL;
   }
 not_found:
   {
     GST_INFO ("Tried to load plugin containing feature '%s', but feature was "
-        "not found.", real_feature->name);
+        "not found.", GST_OBJECT_NAME (real_feature));
     return NULL;
   }
 }
 
 /**
- * gst_plugin_feature_type_name_filter:
- * @feature: the #GstPluginFeature
- * @data: (in): the type and name to check against
- *
- * Compares type and name of plugin feature. Can be used with gst_filter_run().
- *
- * Returns: TRUE if equal.
- */
-gboolean
-gst_plugin_feature_type_name_filter (GstPluginFeature * feature,
-    GstTypeNameData * data)
-{
-  g_return_val_if_fail (GST_IS_PLUGIN_FEATURE (feature), FALSE);
-
-  return ((data->type == 0 || data->type == G_OBJECT_TYPE (feature)) &&
-      (data->name == NULL
-          || !strcmp (data->name, GST_PLUGIN_FEATURE_NAME (feature))));
-}
-
-/**
- * gst_plugin_feature_set_name:
- * @feature: a feature
- * @name: the name to set
- *
- * Sets the name of a plugin feature. The name uniquely identifies a feature
- * within all features of the same type. Renaming a plugin feature is not
- * allowed. A copy is made of the name so you should free the supplied @name
- * after calling this function.
- */
-void
-gst_plugin_feature_set_name (GstPluginFeature * feature, const gchar * name)
-{
-  g_return_if_fail (GST_IS_PLUGIN_FEATURE (feature));
-  g_return_if_fail (name != NULL);
-
-  if (G_UNLIKELY (feature->name)) {
-    g_return_if_fail (strcmp (feature->name, name) == 0);
-  } else {
-    gst_object_set_name (GST_OBJECT (feature), name);
-    feature->name = GST_OBJECT_NAME (GST_OBJECT (feature));
-  }
-}
-
-/**
- * gst_plugin_feature_get_name:
- * @feature: a feature
- *
- * Gets the name of a plugin feature.
- *
- * Returns: the name
- */
-const gchar *
-gst_plugin_feature_get_name (GstPluginFeature * feature)
-{
-  g_return_val_if_fail (GST_IS_PLUGIN_FEATURE (feature), NULL);
-
-  return feature->name;
-}
-
-/**
  * gst_plugin_feature_set_rank:
  * @feature: feature to rank
  * @rank: rank value - higher number means more priority rank
@@ -241,6 +180,26 @@ gst_plugin_feature_get_rank (GstPluginFeature * feature)
 }
 
 /**
+ * gst_plugin_feature_get_plugin:
+ * @feature: a feature
+ *
+ * Get the plugin that provides this feature.
+ *
+ * Returns: (transfer full): the plugin that provides this feature, or %NULL.
+ *     Unref with gst_object_unref() when no longer needed.
+ */
+GstPlugin *
+gst_plugin_feature_get_plugin (GstPluginFeature * feature)
+{
+  g_return_val_if_fail (GST_IS_PLUGIN_FEATURE (feature), NULL);
+
+  if (feature->plugin == NULL)
+    return NULL;
+
+  return (GstPlugin *) gst_object_ref (feature->plugin);
+}
+
+/**
  * gst_plugin_feature_list_free:
  * @list: (transfer full) (element-type Gst.PluginFeature): list
  *     of #GstPluginFeature
@@ -282,7 +241,7 @@ gst_plugin_feature_list_copy (GList * list)
     GList *last;
 
     new_list = g_list_alloc ();
-    new_list->data = g_object_ref ((GObject *) list->data);
+    new_list->data = gst_object_ref (list->data);
     new_list->prev = NULL;
     last = new_list;
     list = list->next;
@@ -290,7 +249,7 @@ gst_plugin_feature_list_copy (GList * list)
       last->next = g_list_alloc ();
       last->next->prev = last;
       last = last->next;
-      last->data = g_object_ref ((GObject *) list->data);
+      last->data = gst_object_ref (list->data);
       list = list->next;
     }
     last->next = NULL;
@@ -345,9 +304,9 @@ gst_plugin_feature_check_version (GstPluginFeature * feature,
   g_return_val_if_fail (GST_IS_PLUGIN_FEATURE (feature), FALSE);
 
   GST_DEBUG ("Looking up plugin '%s' containing plugin feature '%s'",
-      feature->plugin_name, feature->name);
+      feature->plugin_name, GST_OBJECT_NAME (feature));
 
-  registry = gst_registry_get_default ();
+  registry = gst_registry_get ();
   plugin = gst_registry_find_plugin (registry, feature->plugin_name);
 
   if (plugin) {
@@ -362,6 +321,15 @@ gst_plugin_feature_check_version (GstPluginFeature * feature,
     GST_DEBUG ("version string '%s' parsed to %d values", ver_str, nscan);
 
     if (nscan >= 3) {
+      /* FIXME 1.0: Remove this before doing the actual 1.0.0 release */
+      if ((major == 0 && minor == 11 && micro >= 90) ||
+          (major == 0 && minor == 11 && micro == 89 && nano > 0)) {
+        major = 1;
+        minor = 0;
+        micro = 0;
+        nano = 0;
+      }
+
       if (major > min_major)
         ret = TRUE;
       else if (major < min_major)
@@ -372,7 +340,7 @@ gst_plugin_feature_check_version (GstPluginFeature * feature,
         ret = FALSE;
       else if (micro > min_micro)
         ret = TRUE;
-      /* micro is 1 smaller but we have a nano version, this is the upcomming
+      /* micro is 1 smaller but we have a nano version, this is the upcoming
        * release of the requested version and we're ok then */
       else if (nscan == 4 && nano > 0 && (micro + 1 == min_micro))
         ret = TRUE;
@@ -422,7 +390,7 @@ gst_plugin_feature_rank_compare_func (gconstpointer p1, gconstpointer p2)
   if (diff != 0)
     return diff;
 
-  diff = strcmp (f2->name, f1->name);
+  diff = strcmp (GST_OBJECT_NAME (f2), GST_OBJECT_NAME (f1));
 
   return diff;
 }