static gboolean
gst_pad_check_link (GstPad * srcpad, GstPad * sinkpad)
{
- /* FIXME This function is gross. It's almost a direct copy of
- * gst_pad_link_filtered(). Any decent programmer would attempt
- * to merge the two functions, which I will do some day. --ds
- */
-
/* generic checks */
g_return_val_if_fail (GST_IS_PAD (srcpad), FALSE);
g_return_val_if_fail (GST_IS_PAD (sinkpad), FALSE);
GST_CAT_INFO (GST_CAT_PADS, "trying to link %s:%s and %s:%s",
GST_DEBUG_PAD_NAME (srcpad), GST_DEBUG_PAD_NAME (sinkpad));
- /* FIXME: shouldn't we convert this to g_return_val_if_fail? */
if (GST_PAD_PEER (srcpad) != NULL) {
GST_CAT_INFO (GST_CAT_PADS, "Source pad %s:%s has a peer, failed",
GST_DEBUG_PAD_NAME (srcpad));
/* 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
* here is for source elements */
if (!upstream_stream_id) {
GstQuery *query;
+ gchar *uri = NULL;
/* Try to generate one from the URI query and
* if it fails take a random number instead */
query = gst_query_new_uri ();
if (gst_element_query (parent, query)) {
- GChecksum *cs;
- gchar *uri;
-
gst_query_parse_uri (query, &uri);
+ }
+
+ if (uri) {
+ GChecksum *cs;
/* And then generate an SHA256 sum of the URI */
cs = g_checksum_new (G_CHECKSUM_SHA256);