+2005-10-14 Tim-Philipp Müller <tim at centricular dot net>
+
+ * gst/gstpluginfeature.c: (gst_plugin_feature_check_version):
+ * gst/gstpluginfeature.h:
+ * gst/gstregistry.c: (gst_default_registry_check_feature_version):
+ * gst/gstregistry.h:
+ * docs/gst/gstreamer-sections.txt:
+ Add new API to check plugin feature version requirements.
+
+ * check/gst/gstplugin.c: (test_version_checks), (gst_plugin_suite):
+ Some basic tests for the above.
+
2005-10-13 Thomas Vander Stichele <thomas at apestaart dot org>
* gst/gststructure.c: (gst_structure_to_string):
GST_END_TEST;
#endif
+GST_START_TEST (test_version_checks)
+{
+ fail_if (gst_default_registry_check_feature_version ("identity",
+ GST_VERSION_MAJOR, GST_VERSION_MINOR, GST_VERSION_MICRO) == FALSE,
+ "Unexpected version check result");
+
+ fail_if (gst_default_registry_check_feature_version ("identity",
+ GST_VERSION_MAJOR + 1, GST_VERSION_MINOR, GST_VERSION_MICRO) == TRUE,
+ "Unexpected version check result");
+
+ fail_if (gst_default_registry_check_feature_version ("identity",
+ GST_VERSION_MAJOR, GST_VERSION_MINOR + 1, GST_VERSION_MICRO) == TRUE,
+ "Unexpected version check result");
+
+ fail_if (gst_default_registry_check_feature_version ("identity",
+ GST_VERSION_MAJOR, GST_VERSION_MINOR, GST_VERSION_MICRO + 1) == TRUE,
+ "Unexpected version check result");
+
+ if (GST_VERSION_MAJOR > 0) {
+ fail_if (gst_default_registry_check_feature_version ("identity",
+ GST_VERSION_MAJOR - 1, GST_VERSION_MINOR,
+ GST_VERSION_MICRO) == FALSE, "Unexpected version check result");
+ }
+
+ if (GST_VERSION_MINOR > 0) {
+ fail_if (gst_default_registry_check_feature_version ("identity",
+ GST_VERSION_MAJOR, GST_VERSION_MINOR - 1,
+ GST_VERSION_MICRO) == FALSE, "Unexpected version check result");
+ }
+
+ if (GST_VERSION_MICRO > 0) {
+ fail_if (gst_default_registry_check_feature_version ("identity",
+ GST_VERSION_MAJOR, GST_VERSION_MINOR,
+ GST_VERSION_MICRO - 1) == FALSE, "Unexpected version check result");
+ }
+
+ fail_if (gst_default_registry_check_feature_version ("entityid",
+ GST_VERSION_MAJOR, GST_VERSION_MINOR, GST_VERSION_MICRO) == TRUE,
+ "Unexpected version check result");
+}
+
+GST_END_TEST;
+
Suite *
gst_plugin_suite (void)
{
tcase_add_test (tc_chain, test_find_plugin);
tcase_add_test (tc_chain, test_find_feature);
tcase_add_test (tc_chain, test_find_element);
+ tcase_add_test (tc_chain, test_version_checks);
//tcase_add_test (tc_chain, test_typefind);
return s;
}
-
int
main (int argc, char **argv)
{
gst_plugin_feature_get_name
gst_plugin_feature_load
gst_plugin_feature_list_free
+gst_plugin_feature_check_version
<SUBSECTION Standard>
GstPluginFeatureClass
GST_PLUGIN_FEATURE
gst_registry_get_plugin_list
gst_registry_add_feature
<SUBSECTION Default Registry>
+gst_default_registry_check_feature_version
gst_default_registry_get_path_list
gst_default_registry_add_plugin
gst_default_registry_add_path
}
/**
- * gst_plugin_feature_get rank:
+ * gst_plugin_feature_get_rank:
* @feature: a feature
*
* Gets the rank of a plugin feature.
}
g_list_free (list);
}
+
+/**
+ * gst_plugin_feature_check_version:
+ * @feature: a feature
+ * @min_major: minimum required major version
+ * @min_minor: minimum required minor version
+ * @min_micro: minimum required micro version
+ *
+ * Checks whether the given plugin feature is at least
+ * the required version
+ *
+ * Returns: #TRUE if the plugin feature has at least
+ * the required version, otherwise #FALSE.
+ */
+gboolean
+gst_plugin_feature_check_version (GstPluginFeature * feature,
+ guint min_major, guint min_minor, guint min_micro)
+{
+ GstRegistry *registry;
+ GstPlugin *plugin;
+ gboolean ret = FALSE;
+
+ g_return_val_if_fail (feature != NULL, FALSE);
+ 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);
+
+ registry = gst_registry_get_default ();
+ plugin = gst_registry_find_plugin (registry, feature->plugin_name);
+
+ if (plugin) {
+ const gchar *ver_str;
+ guint major, minor, micro;
+
+ ver_str = gst_plugin_get_version (plugin);
+ g_return_val_if_fail (ver_str != NULL, FALSE);
+
+ if (sscanf (ver_str, "%u.%u.%u", &major, &minor, µ) == 3) {
+ if (major > min_major)
+ ret = TRUE;
+ else if (major < min_major)
+ ret = FALSE;
+ else if (minor > min_minor)
+ ret = TRUE;
+ else if (minor < min_minor)
+ ret = FALSE;
+ else if (micro > min_micro)
+ ret = TRUE;
+ else
+ ret = (micro == min_micro);
+
+ GST_DEBUG ("Checking whether %u.%u.%u >= %u.%u.%u? %s", major, minor,
+ micro, min_major, min_minor, min_micro, (ret) ? "yes" : "no");
+ } else {
+ GST_WARNING ("Could not parse version string '%s' of plugin '%s'",
+ ver_str, feature->plugin_name);
+ }
+
+ gst_object_unref (plugin);
+ } else {
+ GST_DEBUG ("Could not find plugin '%s'", feature->plugin_name);
+ }
+
+ return ret;
+}
void gst_plugin_feature_list_free (GList *list);
+gboolean gst_plugin_feature_check_version (GstPluginFeature *feature,
+ guint min_major,
+ guint min_minor,
+ guint min_micro);
+
G_END_DECLS
gst_object_unref (_gst_registry_default);
_gst_registry_default = NULL;
}
+
+/**
+ * gst_default_registry_check_feature_version:
+ * @feature_name: the name of the feature (e.g. "oggdemux")
+ * @min_major: the minimum major version number
+ * @min_minor: the minimum minor version number
+ * @min_micro: the minimum micro version number
+ *
+ * Checks whether a plugin feature by the given name exists in the
+ * default registry and whether its version is at least the
+ * version required.
+ *
+ * Returns: #TRUE if the feature could be found and the version is
+ * the same as the required version or newer, and #FALSE otherwise.
+ */
+gboolean
+gst_default_registry_check_feature_version (const gchar * feature_name,
+ guint min_major, guint min_minor, guint min_micro)
+{
+ GstPluginFeature *feature;
+ GstRegistry *registry;
+ gboolean ret = FALSE;
+
+ g_return_val_if_fail (feature_name != NULL, FALSE);
+
+ GST_DEBUG ("Looking up plugin feature '%s'", feature_name);
+
+ registry = gst_registry_get_default ();
+ feature = gst_registry_lookup_feature (registry, feature_name);
+ if (feature) {
+ ret = gst_plugin_feature_check_version (feature, min_major, min_minor,
+ min_micro);
+ gst_object_unref (feature);
+ } else {
+ GST_DEBUG ("Could not find plugin feature '%s'", feature_name);
+ }
+
+ return ret;
+}
void (*plugin_added) (GstRegistry *registry, GstPlugin *plugin);
void (*feature_added) (GstRegistry *registry, GstPluginFeature *feature);
+ /*< private >*/
gpointer _gst_reserved[GST_PADDING];
};
#define gst_default_registry_feature_filter(filter,first,user_data) \
gst_registry_feature_filter (gst_registry_get_default(),filter,first,user_data)
+gboolean gst_default_registry_check_feature_version (const gchar *feature_name,
+ guint min_major,
+ guint min_minor,
+ guint min_micro);
+
G_END_DECLS
#endif /* __GST_REGISTRY_H__ */
GST_END_TEST;
#endif
+GST_START_TEST (test_version_checks)
+{
+ fail_if (gst_default_registry_check_feature_version ("identity",
+ GST_VERSION_MAJOR, GST_VERSION_MINOR, GST_VERSION_MICRO) == FALSE,
+ "Unexpected version check result");
+
+ fail_if (gst_default_registry_check_feature_version ("identity",
+ GST_VERSION_MAJOR + 1, GST_VERSION_MINOR, GST_VERSION_MICRO) == TRUE,
+ "Unexpected version check result");
+
+ fail_if (gst_default_registry_check_feature_version ("identity",
+ GST_VERSION_MAJOR, GST_VERSION_MINOR + 1, GST_VERSION_MICRO) == TRUE,
+ "Unexpected version check result");
+
+ fail_if (gst_default_registry_check_feature_version ("identity",
+ GST_VERSION_MAJOR, GST_VERSION_MINOR, GST_VERSION_MICRO + 1) == TRUE,
+ "Unexpected version check result");
+
+ if (GST_VERSION_MAJOR > 0) {
+ fail_if (gst_default_registry_check_feature_version ("identity",
+ GST_VERSION_MAJOR - 1, GST_VERSION_MINOR,
+ GST_VERSION_MICRO) == FALSE, "Unexpected version check result");
+ }
+
+ if (GST_VERSION_MINOR > 0) {
+ fail_if (gst_default_registry_check_feature_version ("identity",
+ GST_VERSION_MAJOR, GST_VERSION_MINOR - 1,
+ GST_VERSION_MICRO) == FALSE, "Unexpected version check result");
+ }
+
+ if (GST_VERSION_MICRO > 0) {
+ fail_if (gst_default_registry_check_feature_version ("identity",
+ GST_VERSION_MAJOR, GST_VERSION_MINOR,
+ GST_VERSION_MICRO - 1) == FALSE, "Unexpected version check result");
+ }
+
+ fail_if (gst_default_registry_check_feature_version ("entityid",
+ GST_VERSION_MAJOR, GST_VERSION_MINOR, GST_VERSION_MICRO) == TRUE,
+ "Unexpected version check result");
+}
+
+GST_END_TEST;
+
Suite *
gst_plugin_suite (void)
{
tcase_add_test (tc_chain, test_find_plugin);
tcase_add_test (tc_chain, test_find_feature);
tcase_add_test (tc_chain, test_find_element);
+ tcase_add_test (tc_chain, test_version_checks);
//tcase_add_test (tc_chain, test_typefind);
return s;
}
-
int
main (int argc, char **argv)
{