tools, tests: don't access the GstPluginFeature structure directly
authorTim-Philipp Müller <tim.muller@collabora.co.uk>
Sat, 19 May 2012 16:23:43 +0000 (17:23 +0100)
committerTim-Philipp Müller <tim.muller@collabora.co.uk>
Sat, 19 May 2012 16:23:43 +0000 (17:23 +0100)
tests/check/gst/gstplugin.c
tools/gst-inspect.c

index 0824b06..c4c3395 100644 (file)
@@ -161,12 +161,16 @@ GST_END_TEST;
 GST_START_TEST (test_find_feature)
 {
   GstPluginFeature *feature;
+  GstPlugin *plugin;
 
   feature = gst_registry_find_feature (gst_registry_get (),
       "identity", GST_TYPE_ELEMENT_FACTORY);
   fail_if (feature == NULL, "Failed to find identity element factory");
-  fail_if (strcmp (feature->plugin_name, "coreelements"),
-      "Expected identity to be from coreelements plugin");
+
+  plugin = gst_plugin_feature_get_plugin (feature);
+  fail_unless (plugin != NULL);
+  fail_unless_equals_string (gst_plugin_get_name (plugin), "coreelements");
+  gst_object_unref (plugin);
 
   fail_if (GST_OBJECT_REFCOUNT_VALUE (feature) != 2,
       "Refcount of feature should be 2");
index cd622d6..9642ea9 100644 (file)
@@ -185,12 +185,12 @@ static void
 print_factory_details_info (GstElementFactory * factory)
 {
   gchar **keys, **k;
+  GstRank rank;
   char s[20];
 
+  rank = gst_plugin_feature_get_rank (GST_PLUGIN_FEATURE (factory));
   n_print ("Factory Details:\n");
-  n_print ("  Rank:\t\t%s (%d)\n",
-      get_rank_name (s, GST_PLUGIN_FEATURE (factory)->rank),
-      GST_PLUGIN_FEATURE (factory)->rank);
+  n_print ("  Rank:\t\t%s (%d)\n", get_rank_name (s, rank), rank);
 
   keys = gst_element_factory_get_metadata_keys (factory);
   if (keys != NULL) {
@@ -1297,6 +1297,7 @@ static int
 print_element_info (GstElementFactory * factory, gboolean print_names)
 {
   GstElement *element;
+  GstPlugin *plugin;
   gint maxlevel = 0;
 
   factory =
@@ -1321,14 +1322,11 @@ print_element_info (GstElementFactory * factory, gboolean print_names)
     _name = NULL;
 
   print_factory_details_info (factory);
-  if (GST_PLUGIN_FEATURE (factory)->plugin_name) {
-    GstPlugin *plugin;
 
-    plugin = gst_registry_find_plugin (gst_registry_get (),
-        GST_PLUGIN_FEATURE (factory)->plugin_name);
-    if (plugin) {
-      print_plugin_info (plugin);
-    }
+  plugin = gst_plugin_feature_get_plugin (GST_PLUGIN_FEATURE (factory));
+  if (plugin) {
+    print_plugin_info (plugin);
+    gst_object_unref (plugin);
   }
 
   print_hierarchy (G_OBJECT_TYPE (element), 0, &maxlevel);
@@ -1451,22 +1449,21 @@ print_plugin_automatic_install_info_protocols (GstElementFactory * factory)
 static void
 print_plugin_automatic_install_info (GstPlugin * plugin)
 {
-  const gchar *plugin_name;
   GList *features, *l;
 
-  plugin_name = gst_plugin_get_name (plugin);
-
   /* not interested in typefind factories, only element factories */
   features = gst_registry_get_feature_list (gst_registry_get (),
       GST_TYPE_ELEMENT_FACTORY);
 
   for (l = features; l != NULL; l = l->next) {
     GstPluginFeature *feature;
+    GstPlugin *feature_plugin;
 
     feature = GST_PLUGIN_FEATURE (l->data);
 
     /* only interested in the ones that are in the plugin we just loaded */
-    if (g_str_equal (plugin_name, feature->plugin_name)) {
+    feature_plugin = gst_plugin_feature_get_plugin (feature);
+    if (feature_plugin == plugin) {
       GstElementFactory *factory;
 
       g_print ("element-%s\n", gst_plugin_feature_get_name (feature));
@@ -1475,6 +1472,8 @@ print_plugin_automatic_install_info (GstPlugin * plugin)
       print_plugin_automatic_install_info_protocols (factory);
       print_plugin_automatic_install_info_codecs (factory);
     }
+    if (feature_plugin)
+      gst_object_unref (feature_plugin);
   }
 
   g_list_foreach (features, (GFunc) gst_object_unref, NULL);