mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-26 19:51:11 +00:00
Add new API to check plugin feature version requirements.
Original commit message from CVS: * 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.
This commit is contained in:
parent
b10cc10e8c
commit
45258dbc4c
8 changed files with 219 additions and 3 deletions
12
ChangeLog
12
ChangeLog
|
@ -1,3 +1,15 @@
|
||||||
|
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>
|
2005-10-13 Thomas Vander Stichele <thomas at apestaart dot org>
|
||||||
|
|
||||||
* gst/gststructure.c: (gst_structure_to_string):
|
* gst/gststructure.c: (gst_structure_to_string):
|
||||||
|
|
|
@ -247,6 +247,49 @@ GST_START_TEST (test_typefind)
|
||||||
GST_END_TEST;
|
GST_END_TEST;
|
||||||
#endif
|
#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 *
|
Suite *
|
||||||
gst_plugin_suite (void)
|
gst_plugin_suite (void)
|
||||||
{
|
{
|
||||||
|
@ -264,12 +307,12 @@ gst_plugin_suite (void)
|
||||||
tcase_add_test (tc_chain, test_find_plugin);
|
tcase_add_test (tc_chain, test_find_plugin);
|
||||||
tcase_add_test (tc_chain, test_find_feature);
|
tcase_add_test (tc_chain, test_find_feature);
|
||||||
tcase_add_test (tc_chain, test_find_element);
|
tcase_add_test (tc_chain, test_find_element);
|
||||||
|
tcase_add_test (tc_chain, test_version_checks);
|
||||||
//tcase_add_test (tc_chain, test_typefind);
|
//tcase_add_test (tc_chain, test_typefind);
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main (int argc, char **argv)
|
main (int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1504,6 +1504,7 @@ gst_plugin_feature_get_rank
|
||||||
gst_plugin_feature_get_name
|
gst_plugin_feature_get_name
|
||||||
gst_plugin_feature_load
|
gst_plugin_feature_load
|
||||||
gst_plugin_feature_list_free
|
gst_plugin_feature_list_free
|
||||||
|
gst_plugin_feature_check_version
|
||||||
<SUBSECTION Standard>
|
<SUBSECTION Standard>
|
||||||
GstPluginFeatureClass
|
GstPluginFeatureClass
|
||||||
GST_PLUGIN_FEATURE
|
GST_PLUGIN_FEATURE
|
||||||
|
@ -1614,6 +1615,7 @@ gst_registry_lookup_feature
|
||||||
gst_registry_get_plugin_list
|
gst_registry_get_plugin_list
|
||||||
gst_registry_add_feature
|
gst_registry_add_feature
|
||||||
<SUBSECTION Default Registry>
|
<SUBSECTION Default Registry>
|
||||||
|
gst_default_registry_check_feature_version
|
||||||
gst_default_registry_get_path_list
|
gst_default_registry_get_path_list
|
||||||
gst_default_registry_add_plugin
|
gst_default_registry_add_plugin
|
||||||
gst_default_registry_add_path
|
gst_default_registry_add_path
|
||||||
|
|
|
@ -199,7 +199,7 @@ gst_plugin_feature_set_rank (GstPluginFeature * feature, guint rank)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gst_plugin_feature_get rank:
|
* gst_plugin_feature_get_rank:
|
||||||
* @feature: a feature
|
* @feature: a feature
|
||||||
*
|
*
|
||||||
* Gets the rank of a plugin feature.
|
* Gets the rank of a plugin feature.
|
||||||
|
@ -232,3 +232,69 @@ gst_plugin_feature_list_free (GList * list)
|
||||||
}
|
}
|
||||||
g_list_free (list);
|
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;
|
||||||
|
}
|
||||||
|
|
|
@ -126,6 +126,11 @@ G_CONST_RETURN gchar *gst_plugin_feature_get_name (GstPluginFeature *feature);
|
||||||
|
|
||||||
void gst_plugin_feature_list_free (GList *list);
|
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
|
G_END_DECLS
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -803,3 +803,42 @@ _gst_registry_cleanup ()
|
||||||
gst_object_unref (_gst_registry_default);
|
gst_object_unref (_gst_registry_default);
|
||||||
_gst_registry_default = NULL;
|
_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;
|
||||||
|
}
|
||||||
|
|
|
@ -60,6 +60,7 @@ struct _GstRegistryClass {
|
||||||
void (*plugin_added) (GstRegistry *registry, GstPlugin *plugin);
|
void (*plugin_added) (GstRegistry *registry, GstPlugin *plugin);
|
||||||
void (*feature_added) (GstRegistry *registry, GstPluginFeature *feature);
|
void (*feature_added) (GstRegistry *registry, GstPluginFeature *feature);
|
||||||
|
|
||||||
|
/*< private >*/
|
||||||
gpointer _gst_reserved[GST_PADDING];
|
gpointer _gst_reserved[GST_PADDING];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -119,6 +120,11 @@ void _gst_registry_cleanup (void);
|
||||||
#define gst_default_registry_feature_filter(filter,first,user_data) \
|
#define gst_default_registry_feature_filter(filter,first,user_data) \
|
||||||
gst_registry_feature_filter (gst_registry_get_default(),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
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* __GST_REGISTRY_H__ */
|
#endif /* __GST_REGISTRY_H__ */
|
||||||
|
|
|
@ -247,6 +247,49 @@ GST_START_TEST (test_typefind)
|
||||||
GST_END_TEST;
|
GST_END_TEST;
|
||||||
#endif
|
#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 *
|
Suite *
|
||||||
gst_plugin_suite (void)
|
gst_plugin_suite (void)
|
||||||
{
|
{
|
||||||
|
@ -264,12 +307,12 @@ gst_plugin_suite (void)
|
||||||
tcase_add_test (tc_chain, test_find_plugin);
|
tcase_add_test (tc_chain, test_find_plugin);
|
||||||
tcase_add_test (tc_chain, test_find_feature);
|
tcase_add_test (tc_chain, test_find_feature);
|
||||||
tcase_add_test (tc_chain, test_find_element);
|
tcase_add_test (tc_chain, test_find_element);
|
||||||
|
tcase_add_test (tc_chain, test_version_checks);
|
||||||
//tcase_add_test (tc_chain, test_typefind);
|
//tcase_add_test (tc_chain, test_typefind);
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main (int argc, char **argv)
|
main (int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue