tee test too bad it fails at creating
authorThomas Vander Stichele <thomas@apestaart.org>
Thu, 31 Jan 2002 12:17:46 +0000 (12:17 +0000)
committerThomas Vander Stichele <thomas@apestaart.org>
Thu, 31 Jan 2002 12:17:46 +0000 (12:17 +0000)
Original commit message from CVS:
tee test
too bad it fails at creating

tests/old/testsuite/elements/Makefile.am [new file with mode: 0644]
tests/old/testsuite/elements/tee.c [new file with mode: 0644]
testsuite/elements/Makefile.am [new file with mode: 0644]
testsuite/elements/tee.c [new file with mode: 0644]

diff --git a/tests/old/testsuite/elements/Makefile.am b/tests/old/testsuite/elements/Makefile.am
new file mode 100644 (file)
index 0000000..33ee8e9
--- /dev/null
@@ -0,0 +1,9 @@
+testprogs = tee
+
+TESTS = $(testprogs)
+
+check_PROGRAMS = $(testprogs)
+
+tee_LDADD = $(GST_LIBS) 
+tee_CFLAGS = $(GST_CFLAGS)
+
diff --git a/tests/old/testsuite/elements/tee.c b/tests/old/testsuite/elements/tee.c
new file mode 100644 (file)
index 0000000..0cefa3b
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+ * test for tee element
+ * this tests for proxying of caps from tee sink to src's in various situations
+ * thomas@apestaart.org
+ */
+
+#include <gst/gst.h>
+
+GstElement *
+element_create (char *name, char *element)
+  /*
+   * create the element
+   * print an error if it can't be created
+   * return NULL if it couldn't be created
+   * return element if it did work
+   */
+{
+  GstElement *el = NULL;
+
+  el = (GstElement *) element_create (element, name);
+  if (el == NULL)
+  {
+    fprintf (stderr, "Could not create element %s (%s) !\n", name, element);
+    return NULL;
+  }
+  else
+    return el;
+}
+
+int
+main (int argc, char *argv[])
+{
+  GstElement *pipeline = NULL;
+  GstElement *tee, *src, *sink1, *sink2;
+  GstPad *tee_src;
+
+  /* init */
+  gst_init (&argc, &argv);
+
+  /* create */
+  g_print ("Creating pipeline\n");
+  pipeline = gst_pipeline_new ("pipeline");
+  //g_assert (GST_IS_PIPELINE (pipeline));
+
+  g_print ("Creating elements\n");
+  if (!(tee = element_create ("tee", "tee"))) return 1;
+  if (!(src = element_create ("src", "fakesrc"))) return 1;
+  if (!(sink1 = element_create ("sink1", "fakesink"))) return 1;
+  if (!(sink2 = element_create ("sink2", "fakesink"))) return 1;
+
+  /* add */
+  g_print ("Adding elements to bin\n");
+  gst_bin_add (GST_BIN (pipeline), src);
+  gst_bin_add (GST_BIN (pipeline), tee);
+  
+  /* request one pad from tee */
+  tee_src = gst_element_request_pad_by_name (tee, "src%d");
+
+  /* connect */
+  gst_pad_connect (tee_src, gst_element_get_pad (sink1, "sink"));
+
+  /* set to play */
+  gst_element_set_state (pipeline, GST_STATE_PLAYING);
+  gst_bin_iterate (GST_BIN (pipeline));
+
+  g_print ("Done !\n");
+  return 1;
+}
+
diff --git a/testsuite/elements/Makefile.am b/testsuite/elements/Makefile.am
new file mode 100644 (file)
index 0000000..33ee8e9
--- /dev/null
@@ -0,0 +1,9 @@
+testprogs = tee
+
+TESTS = $(testprogs)
+
+check_PROGRAMS = $(testprogs)
+
+tee_LDADD = $(GST_LIBS) 
+tee_CFLAGS = $(GST_CFLAGS)
+
diff --git a/testsuite/elements/tee.c b/testsuite/elements/tee.c
new file mode 100644 (file)
index 0000000..0cefa3b
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+ * test for tee element
+ * this tests for proxying of caps from tee sink to src's in various situations
+ * thomas@apestaart.org
+ */
+
+#include <gst/gst.h>
+
+GstElement *
+element_create (char *name, char *element)
+  /*
+   * create the element
+   * print an error if it can't be created
+   * return NULL if it couldn't be created
+   * return element if it did work
+   */
+{
+  GstElement *el = NULL;
+
+  el = (GstElement *) element_create (element, name);
+  if (el == NULL)
+  {
+    fprintf (stderr, "Could not create element %s (%s) !\n", name, element);
+    return NULL;
+  }
+  else
+    return el;
+}
+
+int
+main (int argc, char *argv[])
+{
+  GstElement *pipeline = NULL;
+  GstElement *tee, *src, *sink1, *sink2;
+  GstPad *tee_src;
+
+  /* init */
+  gst_init (&argc, &argv);
+
+  /* create */
+  g_print ("Creating pipeline\n");
+  pipeline = gst_pipeline_new ("pipeline");
+  //g_assert (GST_IS_PIPELINE (pipeline));
+
+  g_print ("Creating elements\n");
+  if (!(tee = element_create ("tee", "tee"))) return 1;
+  if (!(src = element_create ("src", "fakesrc"))) return 1;
+  if (!(sink1 = element_create ("sink1", "fakesink"))) return 1;
+  if (!(sink2 = element_create ("sink2", "fakesink"))) return 1;
+
+  /* add */
+  g_print ("Adding elements to bin\n");
+  gst_bin_add (GST_BIN (pipeline), src);
+  gst_bin_add (GST_BIN (pipeline), tee);
+  
+  /* request one pad from tee */
+  tee_src = gst_element_request_pad_by_name (tee, "src%d");
+
+  /* connect */
+  gst_pad_connect (tee_src, gst_element_get_pad (sink1, "sink"));
+
+  /* set to play */
+  gst_element_set_state (pipeline, GST_STATE_PLAYING);
+  gst_bin_iterate (GST_BIN (pipeline));
+
+  g_print ("Done !\n");
+  return 1;
+}
+