diff --git a/docs/pwg/advanced-types.xml b/docs/pwg/advanced-types.xml
index eabf060d0c..491bd6cedd 100644
--- a/docs/pwg/advanced-types.xml
+++ b/docs/pwg/advanced-types.xml
@@ -738,7 +738,7 @@ plugin_init (GstPlugin *plugin)
property does not guarantee in any way that
it will actually come close to this value. If you need a fixed
framerate, please use an element that provides that (such as
- videodrop
). 0 means a variable framerate.
+ videorate
). 0 means a variable framerate.
diff --git a/gst/gstutils.c b/gst/gstutils.c
index 86c4394c0f..4517044541 100644
--- a/gst/gstutils.c
+++ b/gst/gstutils.c
@@ -1271,18 +1271,9 @@ gst_element_state_change_return_get_name (GstStateChangeReturn state_ret)
}
-/**
- * gst_element_factory_can_src_caps:
- * @factory: factory to query
- * @caps: the caps to check
- *
- * Checks if the factory can source the given capability.
- *
- * Returns: true if it can src the capabilities
- */
-gboolean
-gst_element_factory_can_src_caps (GstElementFactory * factory,
- const GstCaps * caps)
+static gboolean
+gst_element_factory_can_accept_all_caps_in_direction (GstElementFactory *
+ factory, const GstCaps * caps, GstPadDirection direction)
{
GList *templates;
@@ -1294,41 +1285,7 @@ gst_element_factory_can_src_caps (GstElementFactory * factory,
while (templates) {
GstStaticPadTemplate *template = (GstStaticPadTemplate *) templates->data;
- if (template->direction == GST_PAD_SRC) {
- if (gst_caps_is_always_compatible (gst_static_caps_get
- (&template->static_caps), caps))
- return TRUE;
- }
- templates = g_list_next (templates);
- }
-
- return FALSE;
-}
-
-/**
- * gst_element_factory_can_sink_caps:
- * @factory: factory to query
- * @caps: the caps to check
- *
- * Checks if the factory can sink the given capability.
- *
- * Returns: true if it can sink the capabilities
- */
-gboolean
-gst_element_factory_can_sink_caps (GstElementFactory * factory,
- const GstCaps * caps)
-{
- GList *templates;
-
- g_return_val_if_fail (factory != NULL, FALSE);
- g_return_val_if_fail (caps != NULL, FALSE);
-
- templates = factory->staticpadtemplates;
-
- while (templates) {
- GstStaticPadTemplate *template = (GstStaticPadTemplate *) templates->data;
-
- if (template->direction == GST_PAD_SINK) {
+ if (template->direction == direction) {
if (gst_caps_is_always_compatible (caps,
gst_static_caps_get (&template->static_caps)))
return TRUE;
@@ -1339,6 +1296,146 @@ gst_element_factory_can_sink_caps (GstElementFactory * factory,
return FALSE;
}
+static gboolean
+gst_element_factory_can_accept_any_caps_in_direction (GstElementFactory *
+ factory, const GstCaps * caps, GstPadDirection direction)
+{
+ GList *templates;
+
+ g_return_val_if_fail (factory != NULL, FALSE);
+ g_return_val_if_fail (caps != NULL, FALSE);
+
+ templates = factory->staticpadtemplates;
+
+ while (templates) {
+ GstStaticPadTemplate *template = (GstStaticPadTemplate *) templates->data;
+
+ if (template->direction == direction) {
+ if (gst_caps_can_intersect (caps,
+ gst_static_caps_get (&template->static_caps)))
+ return TRUE;
+ }
+ templates = g_list_next (templates);
+ }
+
+ return FALSE;
+}
+
+#ifndef GST_DISABLE_DEPRECATED
+/**
+ * gst_element_factory_can_src_caps:
+ * @factory: factory to query
+ * @caps: the caps to check
+ *
+ * Checks if the factory can source the given capability.
+ *
+ * Returns: %TRUE if it can src the capabilities
+ *
+ * Deprecated: use gst_element_factory_can_src_all_caps() instead.
+ */
+gboolean
+gst_element_factory_can_src_caps (GstElementFactory * factory,
+ const GstCaps * caps)
+{
+ return gst_element_factory_can_accept_all_caps_in_direction (factory, caps,
+ GST_PAD_SRC);
+}
+
+/**
+ * gst_element_factory_can_sink_caps:
+ * @factory: factory to query
+ * @caps: the caps to check
+ *
+ * Checks if the factory can sink the given capability.
+ *
+ * Returns: %TRUE if it can sink the capabilities
+ *
+ * Deprecated: use gst_element_factory_can_sink_all_caps() instead.
+ */
+gboolean
+gst_element_factory_can_sink_caps (GstElementFactory * factory,
+ const GstCaps * caps)
+{
+ return gst_element_factory_can_accept_all_caps_in_direction (factory, caps,
+ GST_PAD_SINK);
+}
+#endif /* GST_DISABLE_DEPRECATED */
+
+/**
+ * gst_element_factory_can_sink_all_caps:
+ * @factory: factory to query
+ * @caps: the caps to check
+ *
+ * Checks if the factory can sink all possible capabilities.
+ *
+ * Returns: %TRUE if the caps are fully compatible.
+ *
+ * Since: 0.10.33
+ */
+gboolean
+gst_element_factory_can_sink_all_caps (GstElementFactory * factory,
+ const GstCaps * caps)
+{
+ return gst_element_factory_can_accept_all_caps_in_direction (factory, caps,
+ GST_PAD_SINK);
+}
+
+/**
+ * gst_element_factory_can_src_all_caps:
+ * @factory: factory to query
+ * @caps: the caps to check
+ *
+ * Checks if the factory can src all possible capabilities.
+ *
+ * Returns: %TRUE if the caps are fully compatible.
+ *
+ * Since: 0.10.33
+ */
+gboolean
+gst_element_factory_can_src_all_caps (GstElementFactory * factory,
+ const GstCaps * caps)
+{
+ return gst_element_factory_can_accept_all_caps_in_direction (factory, caps,
+ GST_PAD_SRC);
+}
+
+/**
+ * gst_element_factory_can_sink_any_caps:
+ * @factory: factory to query
+ * @caps: the caps to check
+ *
+ * Checks if the factory can sink any possible capability.
+ *
+ * Returns: %TRUE if the caps have a common subset.
+ *
+ * Since: 0.10.33
+ */
+gboolean
+gst_element_factory_can_sink_any_caps (GstElementFactory * factory,
+ const GstCaps * caps)
+{
+ return gst_element_factory_can_accept_any_caps_in_direction (factory, caps,
+ GST_PAD_SINK);
+}
+
+/**
+ * gst_element_factory_can_src_any_caps:
+ * @factory: factory to query
+ * @caps: the caps to check
+ *
+ * Checks if the factory can src any possible capability.
+ *
+ * Returns: %TRUE if the caps have a common subset.
+ *
+ * Since: 0.10.33
+ */
+gboolean
+gst_element_factory_can_src_any_caps (GstElementFactory * factory,
+ const GstCaps * caps)
+{
+ return gst_element_factory_can_accept_any_caps_in_direction (factory, caps,
+ GST_PAD_SRC);
+}
/* if return val is true, *direct_child is a caller-owned ref on the direct
* child of ancestor that is part of object's ancestry */
diff --git a/gst/gstutils.h b/gst/gstutils.h
index a81a4ea460..3dc30c0fae 100644
--- a/gst/gstutils.h
+++ b/gst/gstutils.h
@@ -1034,8 +1034,14 @@ gboolean gst_element_seek_simple (GstElement *element,
gint64 seek_pos);
/* util elementfactory functions */
-gboolean gst_element_factory_can_src_caps(GstElementFactory *factory, const GstCaps *caps);
-gboolean gst_element_factory_can_sink_caps(GstElementFactory *factory, const GstCaps *caps);
+#ifndef GST_DISABLE_DEPRECATED
+gboolean gst_element_factory_can_src_caps (GstElementFactory *factory, const GstCaps *caps);
+gboolean gst_element_factory_can_sink_caps (GstElementFactory *factory, const GstCaps *caps);
+#endif /* GST_DISABLE_DEPRECATED */
+gboolean gst_element_factory_can_sink_all_caps (GstElementFactory *factory, const GstCaps *caps);
+gboolean gst_element_factory_can_src_all_caps (GstElementFactory *factory, const GstCaps *caps);
+gboolean gst_element_factory_can_sink_any_caps (GstElementFactory *factory, const GstCaps *caps);
+gboolean gst_element_factory_can_src_any_caps (GstElementFactory *factory, const GstCaps *caps);
/* util query functions */
gboolean gst_element_query_position (GstElement *element, GstFormat *format,
diff --git a/tests/check/gst/gstcaps.c b/tests/check/gst/gstcaps.c
index 6fb35e1ea6..d1bbe4bedc 100644
--- a/tests/check/gst/gstcaps.c
+++ b/tests/check/gst/gstcaps.c
@@ -795,6 +795,26 @@ GST_START_TEST (test_normalize)
GST_END_TEST;
+GST_START_TEST (test_broken)
+{
+ GstCaps *c1;
+
+ /* NULL is not valid for media_type */
+ ASSERT_CRITICAL (c1 =
+ gst_caps_new_simple (NULL, "field", G_TYPE_INT, 1, NULL));
+ fail_if (c1);
+
+#ifndef G_DISABLE_CHECKS
+ /* such a name is not valid, see gst_structure_validate_name() */
+ ASSERT_CRITICAL (c1 =
+ gst_caps_new_simple ("1#@abc", "field", G_TYPE_INT, 1, NULL));
+ fail_if (c1);
+#endif
+}
+
+GST_END_TEST;
+
+
static Suite *
gst_caps_suite (void)
{
@@ -815,6 +835,7 @@ gst_caps_suite (void)
tcase_add_test (tc_chain, test_intersect);
tcase_add_test (tc_chain, test_intersect2);
tcase_add_test (tc_chain, test_normalize);
+ tcase_add_test (tc_chain, test_broken);
return s;
}
diff --git a/tests/check/gst/gstelementfactory.c b/tests/check/gst/gstelementfactory.c
index 84a95703a8..25dcfd190a 100644
--- a/tests/check/gst/gstelementfactory.c
+++ b/tests/check/gst/gstelementfactory.c
@@ -77,6 +77,48 @@ GST_START_TEST (test_create)
GST_END_TEST;
+/* test if the factory can accept some caps */
+GST_START_TEST (test_can_sink_any_caps)
+{
+ GstElementFactory *factory;
+ GstCaps *caps;
+ gboolean res;
+
+ factory = setup_factory ();
+ fail_if (factory == NULL);
+
+ caps = gst_caps_new_simple ("audio/x-raw-int", NULL);
+ fail_if (caps == NULL);
+ res = gst_element_factory_can_sink_any_caps (factory, caps);
+ fail_if (!res);
+ gst_caps_unref (caps);
+
+ g_object_unref (factory);
+}
+
+GST_END_TEST;
+
+/* test if the factory is compabible with some caps */
+GST_START_TEST (test_can_sink_all_caps)
+{
+ GstElementFactory *factory;
+ GstCaps *caps;
+ gboolean res;
+
+ factory = setup_factory ();
+ fail_if (factory == NULL);
+
+ caps = gst_caps_new_simple ("audio/x-raw-int", NULL);
+ fail_if (caps == NULL);
+ res = gst_element_factory_can_sink_all_caps (factory, caps);
+ fail_if (res);
+ gst_caps_unref (caps);
+
+ g_object_unref (factory);
+}
+
+GST_END_TEST;
+
/* check if the elementfactory of a class is filled (see #131079) */
GST_START_TEST (test_class)
{
@@ -131,6 +173,8 @@ gst_element_factory_suite (void)
suite_add_tcase (s, tc_chain);
tcase_add_test (tc_chain, test_class);
tcase_add_test (tc_chain, test_create);
+ tcase_add_test (tc_chain, test_can_sink_any_caps);
+ tcase_add_test (tc_chain, test_can_sink_all_caps);
return s;
}
diff --git a/win32/common/libgstreamer.def b/win32/common/libgstreamer.def
index f806345f91..d53a57a1cd 100644
--- a/win32/common/libgstreamer.def
+++ b/win32/common/libgstreamer.def
@@ -305,6 +305,10 @@ EXPORTS
gst_element_create_all_pads
gst_element_factory_can_sink_caps
gst_element_factory_can_src_caps
+ gst_element_factory_can_sink_all_caps
+ gst_element_factory_can_sink_any_caps
+ gst_element_factory_can_src_all_caps
+ gst_element_factory_can_src_any_caps
gst_element_factory_create
gst_element_factory_find
gst_element_factory_get_element_type