/* try to create a new one */
/* requesting is a little crazy, we need a template. Let's create one */
- /* FIXME: why not gst_pad_get_pad_template (pad); */
templcaps = gst_pad_query_caps (pad, NULL);
+ if (caps) {
+ GstCaps *inter = gst_caps_intersect (templcaps, caps);
+
+ gst_caps_unref (templcaps);
+ templcaps = inter;
+ }
templ = gst_pad_template_new ((gchar *) GST_PAD_NAME (pad),
GST_PAD_DIRECTION (pad), GST_PAD_ALWAYS, templcaps);
gst_caps_unref (templcaps);
/* we need to setup some ghost pads */
root = find_common_root (e1, e2);
if (!root) {
- g_warning ("Trying to connect elements that don't share a common "
- "ancestor: %s and %s", GST_ELEMENT_NAME (e1), GST_ELEMENT_NAME (e2));
+ if (GST_OBJECT_PARENT (e1) == NULL)
+ g_warning ("Trying to link elements %s and %s that don't share a common "
+ "ancestor: %s hasn't been added to a bin or pipeline, but %s is in %s",
+ GST_ELEMENT_NAME (e1), GST_ELEMENT_NAME (e2),
+ GST_ELEMENT_NAME (e1), GST_ELEMENT_NAME (e2),
+ GST_ELEMENT_NAME (GST_OBJECT_PARENT (e2)));
+ else if (GST_OBJECT_PARENT (e2) == NULL)
+ g_warning ("Trying to link elements %s and %s that don't share a common "
+ "ancestor: %s hasn't been added to a bin or pipeline, and %s is in %s",
+ GST_ELEMENT_NAME (e1), GST_ELEMENT_NAME (e2),
+ GST_ELEMENT_NAME (e2), GST_ELEMENT_NAME (e1),
+ GST_ELEMENT_NAME (GST_OBJECT_PARENT (e1)));
+ else
+ g_warning ("Trying to link elements %s and %s that don't share a common "
+ "ancestor: %s is in %s, and %s is in %s",
+ GST_ELEMENT_NAME (e1), GST_ELEMENT_NAME (e2),
+ GST_ELEMENT_NAME (e1), GST_ELEMENT_NAME (GST_OBJECT_PARENT (e1)),
+ GST_ELEMENT_NAME (e2), GST_ELEMENT_NAME (GST_OBJECT_PARENT (e2)));
return FALSE;
}
return pad;
}
+static void
+gst_bin_sync_children_states_foreach (const GValue * value, gpointer user_data)
+{
+ gboolean *success = user_data;
+ GstElement *element = g_value_get_object (value);
+
+ if (gst_element_is_locked_state (element)) {
+ *success = TRUE;
+ } else {
+ *success = *success && gst_element_sync_state_with_parent (element);
+
+ if (GST_IS_BIN (element))
+ *success = *success
+ && gst_bin_sync_children_states (GST_BIN_CAST (element));
+ }
+}
+
+/**
+ * gst_bin_sync_children_states:
+ * @bin: a #GstBin
+ *
+ * Synchronizes the state of every child of @bin with the state
+ * of @bin. See also gst_element_sync_state_with_parent().
+ *
+ * Returns: %TRUE if syncing the state was successful for all children,
+ * otherwise %FALSE.
+ *
+ * Since: 1.6
+ */
+gboolean
+gst_bin_sync_children_states (GstBin * bin)
+{
+ GstIterator *it;
+ GstIteratorResult res = GST_ITERATOR_OK;
+ gboolean success = TRUE;
+
+ it = gst_bin_iterate_sorted (bin);
+
+ do {
+ if (res == GST_ITERATOR_RESYNC) {
+ success = TRUE;
+ gst_iterator_resync (it);
+ }
+ res =
+ gst_iterator_foreach (it, gst_bin_sync_children_states_foreach,
+ &success);
+ } while (res == GST_ITERATOR_RESYNC);
+ gst_iterator_free (it);
+
+ return success;
+}
+
/**
* gst_parse_bin_from_description:
* @bin_description: command line describing the bin