mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-23 23:58:17 +00:00
elementfactory: Fail if no valid element factory metadata is set
This commit is contained in:
parent
cfc7661f65
commit
24cad1a91c
2 changed files with 22 additions and 10 deletions
|
@ -1283,6 +1283,10 @@ gst_element_class_set_metadata (GstElementClass * klass,
|
||||||
const gchar * description, const gchar * author)
|
const gchar * description, const gchar * author)
|
||||||
{
|
{
|
||||||
g_return_if_fail (GST_IS_ELEMENT_CLASS (klass));
|
g_return_if_fail (GST_IS_ELEMENT_CLASS (klass));
|
||||||
|
g_return_if_fail (longname != NULL && *longname != '\0');
|
||||||
|
g_return_if_fail (classification != NULL && *classification != '\0');
|
||||||
|
g_return_if_fail (description != NULL && *description != '\0');
|
||||||
|
g_return_if_fail (author != NULL && *author != '\0');
|
||||||
|
|
||||||
gst_structure_id_set ((GstStructure *) klass->metadata,
|
gst_structure_id_set ((GstStructure *) klass->metadata,
|
||||||
GST_QUARK (ELEMENT_METADATA_LONGNAME), G_TYPE_STRING, longname,
|
GST_QUARK (ELEMENT_METADATA_LONGNAME), G_TYPE_STRING, longname,
|
||||||
|
@ -1320,6 +1324,10 @@ gst_element_class_set_static_metadata (GstElementClass * klass,
|
||||||
GValue val = G_VALUE_INIT;
|
GValue val = G_VALUE_INIT;
|
||||||
|
|
||||||
g_return_if_fail (GST_IS_ELEMENT_CLASS (klass));
|
g_return_if_fail (GST_IS_ELEMENT_CLASS (klass));
|
||||||
|
g_return_if_fail (longname != NULL && *longname != '\0');
|
||||||
|
g_return_if_fail (classification != NULL && *classification != '\0');
|
||||||
|
g_return_if_fail (description != NULL && *description != '\0');
|
||||||
|
g_return_if_fail (author != NULL && *author != '\0');
|
||||||
|
|
||||||
g_value_init (&val, G_TYPE_STRING);
|
g_value_init (&val, G_TYPE_STRING);
|
||||||
|
|
||||||
|
|
|
@ -177,6 +177,15 @@ gst_element_factory_cleanup (GstElementFactory * factory)
|
||||||
factory->interfaces = NULL;
|
factory->interfaces = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define CHECK_METADATA_FIELD(klass, name, key) \
|
||||||
|
G_STMT_START { \
|
||||||
|
const gchar *metafield = gst_element_class_get_metadata (klass, key); \
|
||||||
|
if (G_UNLIKELY (metafield == NULL || *metafield == '\0')) { \
|
||||||
|
g_warning ("Element factory metadata for '%s' has no valid %s field", name, key); \
|
||||||
|
goto detailserror; \
|
||||||
|
} \
|
||||||
|
} G_STMT_END;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gst_element_register:
|
* gst_element_register:
|
||||||
* @plugin: (allow-none): #GstPlugin to register the element with, or NULL for
|
* @plugin: (allow-none): #GstPlugin to register the element with, or NULL for
|
||||||
|
@ -233,12 +242,11 @@ gst_element_register (GstPlugin * plugin, const gchar * name, guint rank,
|
||||||
/* provide info needed during class structure setup */
|
/* provide info needed during class structure setup */
|
||||||
g_type_set_qdata (type, __gst_elementclass_factory, factory);
|
g_type_set_qdata (type, __gst_elementclass_factory, factory);
|
||||||
klass = GST_ELEMENT_CLASS (g_type_class_ref (type));
|
klass = GST_ELEMENT_CLASS (g_type_class_ref (type));
|
||||||
#if 0
|
|
||||||
/* FIXME */
|
CHECK_METADATA_FIELD (klass, name, GST_ELEMENT_METADATA_LONGNAME);
|
||||||
if ((klass->details.longname == NULL) ||
|
CHECK_METADATA_FIELD (klass, name, GST_ELEMENT_METADATA_KLASS);
|
||||||
(klass->details.klass == NULL) || (klass->details.author == NULL))
|
CHECK_METADATA_FIELD (klass, name, GST_ELEMENT_METADATA_DESCRIPTION);
|
||||||
goto detailserror;
|
CHECK_METADATA_FIELD (klass, name, GST_ELEMENT_METADATA_AUTHOR);
|
||||||
#endif
|
|
||||||
|
|
||||||
factory->type = type;
|
factory->type = type;
|
||||||
factory->metadata = gst_structure_copy ((GstStructure *) klass->metadata);
|
factory->metadata = gst_structure_copy ((GstStructure *) klass->metadata);
|
||||||
|
@ -312,15 +320,11 @@ urierror:
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
detailserror:
|
detailserror:
|
||||||
{
|
{
|
||||||
GST_WARNING_OBJECT (factory,
|
|
||||||
"The GstElementDetails don't seem to have been set properly");
|
|
||||||
gst_element_factory_cleanup (factory);
|
gst_element_factory_cleanup (factory);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue