cleaning up duplicated code in gstbin.c added some sanity checks in gstpad.c added...
authorAndy Wingo <wingo@pobox.com>
Fri, 18 Jan 2002 22:44:19 +0000 (22:44 +0000)
committerAndy Wingo <wingo@pobox.com>
Fri, 18 Jan 2002 22:44:19 +0000 (22:44 +0000)
Original commit message from CVS:
* cleaning up duplicated code in gstbin.c
* added some sanity checks in gstpad.c
* added checks for failed connections in gstparse.c
* better docs in gstxml.c

gst/gstbin.c
gst/gstpad.c
gst/gstparse.c
gst/gstparse.h
gst/gstxml.c

index 4a936da..2c68a31 100644 (file)
@@ -114,10 +114,8 @@ gst_bin_class_init (GstBinClass * klass)
                  G_STRUCT_OFFSET (GstBinClass, object_added), NULL, NULL,
                  gst_marshal_VOID__POINTER, G_TYPE_NONE, 1, G_TYPE_POINTER);
 
-  klass->change_state_type =           GST_DEBUG_FUNCPTR (gst_bin_change_state_type);
-  klass->iterate =                     GST_DEBUG_FUNCPTR (gst_bin_iterate_func);
-
   gobject_class->dispose               = GST_DEBUG_FUNCPTR (gst_bin_dispose);
+
 #ifndef GST_DISABLE_LOADSAVE
   gstobject_class->save_thyself        = GST_DEBUG_FUNCPTR (gst_bin_save_thyself);
   gstobject_class->restore_thyself     = GST_DEBUG_FUNCPTR (gst_bin_restore_thyself);
@@ -739,7 +737,8 @@ static gboolean
 gst_bin_iterate_func (GstBin * bin)
 {
   /* only iterate if this is the manager bin */
-  if (GST_ELEMENT_SCHED (bin)->parent == GST_ELEMENT (bin)) {
+  if (GST_ELEMENT_SCHED (bin) &&
+      GST_ELEMENT_SCHED (bin)->parent == GST_ELEMENT (bin)) {
     GstSchedulerState state;
 
     state = gst_scheduler_iterate (GST_ELEMENT_SCHED (bin));
index cb2bf30..04ca54e 100644 (file)
@@ -587,6 +587,7 @@ gst_pad_connect_filtered (GstPad *srcpad, GstPad *sinkpad, GstCaps *filtercaps)
 {
   GstRealPad *realsrc, *realsink;
   gboolean negotiated = FALSE;
+  gint num_decoupled = 0;
 
   /* generic checks */
   g_return_val_if_fail (srcpad != NULL, FALSE);
@@ -607,6 +608,25 @@ gst_pad_connect_filtered (GstPad *srcpad, GstPad *sinkpad, GstCaps *filtercaps)
 
   g_return_val_if_fail (GST_RPAD_PEER (realsrc) == NULL, FALSE);
   g_return_val_if_fail (GST_RPAD_PEER (realsink) == NULL, FALSE);
+  g_return_val_if_fail (GST_PAD_PARENT (realsrc) != NULL, FALSE);
+  g_return_val_if_fail (GST_PAD_PARENT (realsink) != NULL, FALSE);
+
+  if (realsrc->sched && realsink->sched) {
+    if (GST_FLAG_IS_SET (GST_PAD_PARENT (realsrc), GST_ELEMENT_DECOUPLED))
+      num_decoupled++;
+    if (GST_FLAG_IS_SET (GST_PAD_PARENT (realsink), GST_ELEMENT_DECOUPLED))
+      num_decoupled++;
+
+    if (realsrc->sched == realsink->sched && num_decoupled != 0) {
+      g_warning ("cannot connect pads from decoupled elements with the same sched\n");
+      return FALSE;
+    } else if (realsrc->sched != realsink->sched && num_decoupled != 1) {
+      g_warning ("connecting pads with different scheds requires one decoupled element (queue)\n");
+      return FALSE;
+    }
+  } else if (realsrc->sched || realsink->sched) {
+    g_warning ("you can't connect to a non-managed element");
+  }
 
   /* check for reversed directions and swap if necessary */
   if ((GST_RPAD_DIRECTION (realsrc) == GST_PAD_SINK) &&
index 7ae3312..f162533 100644 (file)
@@ -68,7 +68,9 @@ dynamic_connect (GstElement * element, GstPad * newpad, gpointer data)
 
   if (!strcmp (gst_pad_get_name (newpad), connect->srcpadname)) {
     gst_element_set_state (connect->pipeline, GST_STATE_PAUSED);
-    gst_pad_connect (newpad, connect->target);
+    if (!gst_pad_connect (newpad, connect->target))
+      g_warning ("could not connect %s:%s to %s:%s", GST_DEBUG_PAD_NAME (newpad), 
+                 GST_DEBUG_PAD_NAME (connect->target));
     gst_element_set_state (connect->pipeline, GST_STATE_PLAYING);
   }
 }
@@ -422,8 +424,13 @@ gst_parse_launchv_recurse (const gchar **argv, GstBin * parent, gst_parse_priv *
           GST_DEBUG (0, "CONNECTING %s:%s and %s:%s\n",
                      GST_DEBUG_PAD_NAME (GST_PARSE_LISTPAD (g_slist_nth (srcpads, j))),
                      GST_DEBUG_PAD_NAME (GST_PARSE_LISTPAD (g_slist_nth (sinkpads, j))));
-          gst_pad_connect (GST_PARSE_LISTPAD (g_slist_nth (srcpads, j)),
-                           GST_PARSE_LISTPAD (g_slist_nth (sinkpads, j)));
+          if (!gst_pad_connect (GST_PARSE_LISTPAD (g_slist_nth (srcpads, j)),
+                                GST_PARSE_LISTPAD (g_slist_nth (sinkpads, j)))) {
+            g_warning ("could not connect %s:%s to %s:%s",
+                       GST_DEBUG_PAD_NAME (GST_PARSE_LISTPAD (g_slist_nth (srcpads, j))), 
+                       GST_DEBUG_PAD_NAME (GST_PARSE_LISTPAD (g_slist_nth (sinkpads, j))));
+            return GST_PARSE_ERROR_CONNECT;
+          }
         }
       }
       
index bc1526e..f32eec1 100644 (file)
@@ -35,7 +35,8 @@ typedef enum {
   GST_PARSE_ERROR_SYNTAX = -1, 
   GST_PARSE_ERROR_CREATING_ELEMENT = -2,
   GST_PARSE_ERROR_NOSUCH_ELEMENT = -3,
-  GST_PARSE_ERROR_INTERNAL = -4
+  GST_PARSE_ERROR_INTERNAL = -4,
+  GST_PARSE_ERROR_CONNECT = -5,
 } GstParseErrors;
   
 GstPipeline*   gst_parse_launch        (const gchar *pipeline_description);
index f5b64df..08de28a 100644 (file)
@@ -254,6 +254,9 @@ gst_xml_parse_doc (GstXML *xml, xmlDocPtr doc, const guchar *root)
  * if you only want to build a specific element from an XML file
  * but not the pipeline it is embedded in.
  *
+ * Pass "-" as fname to read from stdin. You can also pass a URI
+ * of any format that libxml supports, including http.
+ *
  * Returns: TRUE on success, FALSE otherwise
  */
 gboolean