adding simple queue test
authorThomas Vander Stichele <thomas@apestaart.org>
Fri, 3 Oct 2003 15:21:49 +0000 (15:21 +0000)
committerThomas Vander Stichele <thomas@apestaart.org>
Fri, 3 Oct 2003 15:21:49 +0000 (15:21 +0000)
Original commit message from CVS:
adding simple queue test

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

index 76cc2e4..9a9b38a 100644 (file)
@@ -1,8 +1,8 @@
 TOP_BUILDDIR=$(shell cd $(top_builddir) && pwd)
 TESTS_ENVIRONMENT = GST_PLUGIN_PATH=$(TOP_BUILDDIR) GST_REGISTRY=$(TOP_BUILDDIR)/testsuite/test-registry.xml
 
-testprogs = thread1 thread2 thread3 threadb
-testsfailing = threadc threadd threade threadf thread5 thread4
+testprogs = thread1 thread2 thread3 thread5
+testsfailing = threadb threadc threadd threade threadf thread4 queue
 
 TESTS = $(testprogs)
 
@@ -13,6 +13,9 @@ noinst_PROGRAMS = $(testsfailing)
 LDADD = $(GST_LIBS) 
 AM_CFLAGS = $(GST_CFLAGS)
 
+queue_SOURCES = queue.c
+queue_CFLAGS = $(AM_CFLAGS)
+
 thread1_SOURCES = thread.c
 thread1_CFLAGS = -DTESTNUM=1 $(AM_CFLAGS)
 thread2_SOURCES = thread.c
diff --git a/tests/old/testsuite/threads/queue.c b/tests/old/testsuite/threads/queue.c
new file mode 100644 (file)
index 0000000..2435e31
--- /dev/null
@@ -0,0 +1,90 @@
+#include <gst/gst.h>
+
+#include <unistd.h>
+
+/*
+ * queue test code
+ * starts a fakesrc num_buffers=50 ! { queue ! fakesink } thread
+ * by first setting the output thread to play, then the whole pipeline
+ */
+
+static gint handoff_count = 0;
+
+/* handoff callback */
+static void
+handoff (GstElement *element, gpointer data)
+{
+  ++handoff_count;
+  g_print ("handoff (%d) ", handoff_count);
+}
+
+static void
+construct_pipeline (GstElement *pipeline, GstElement *thread) 
+{
+  GstElement *src, *sink, *queue;
+
+  src      = gst_element_factory_make ("fakesrc",  NULL);
+  sink     = gst_element_factory_make ("fakesink", "sink");
+  queue    = gst_element_factory_make ("queue",    NULL);
+
+  gst_bin_add_many (GST_BIN (thread), queue, sink, NULL);
+  gst_bin_add_many (GST_BIN (pipeline), src, thread, NULL);
+
+  gst_element_link_many (src, queue, sink, NULL);
+
+  g_object_set (G_OBJECT (src), "num_buffers", 50, NULL);
+
+  g_object_set (G_OBJECT (sink), "signal-handoffs", TRUE, NULL);
+  g_signal_connect (G_OBJECT (sink), "handoff", G_CALLBACK (handoff), NULL);
+}
+
+void
+change_state (GstElement *element, GstBuffer *buf, GstElement *pipeline) 
+{
+  gst_element_set_state (pipeline, GST_STATE_NULL);
+}
+
+int
+main (gint argc, gchar *argv[])
+{
+  GstElement *pipeline;
+  GstElement *thread = NULL;
+  
+  gst_init (&argc, &argv);
+
+  pipeline = gst_thread_new ("main_pipeline");
+  thread = gst_element_factory_make ("thread", NULL);
+  construct_pipeline (pipeline, thread);
+
+  g_print ("First run: to show the pipeline works\n");
+  gst_element_set_state (pipeline, GST_STATE_PLAYING);
+  g_print ("SLEEPING 1 sec\n");
+  sleep (1);
+
+  g_print ("Pipeline done. Resetting to NULL.\n");
+  gst_element_set_state (pipeline, GST_STATE_NULL);
+
+  if (handoff_count == 0)
+  {
+    g_print ("ERROR: no buffers have passed\n");
+    return -1;
+  }
+
+  handoff_count = 0;
+
+  g_print ("Second run: setting consumer thread to playing, then complete pipeline\n");
+  gst_element_set_state (thread, GST_STATE_PLAYING);
+  g_print ("SLEEPING 1 sec\n");
+  sleep (1);
+  gst_element_set_state (pipeline, GST_STATE_PLAYING);
+  g_print ("SLEEPING 2 sec\n");
+  sleep (2);
+
+  if (handoff_count == 0)
+  {
+    g_print ("ERROR: no buffers have passed\n");
+    return -1;
+  }
+  return 0;
+}
index 76cc2e4..9a9b38a 100644 (file)
@@ -1,8 +1,8 @@
 TOP_BUILDDIR=$(shell cd $(top_builddir) && pwd)
 TESTS_ENVIRONMENT = GST_PLUGIN_PATH=$(TOP_BUILDDIR) GST_REGISTRY=$(TOP_BUILDDIR)/testsuite/test-registry.xml
 
-testprogs = thread1 thread2 thread3 threadb
-testsfailing = threadc threadd threade threadf thread5 thread4
+testprogs = thread1 thread2 thread3 thread5
+testsfailing = threadb threadc threadd threade threadf thread4 queue
 
 TESTS = $(testprogs)
 
@@ -13,6 +13,9 @@ noinst_PROGRAMS = $(testsfailing)
 LDADD = $(GST_LIBS) 
 AM_CFLAGS = $(GST_CFLAGS)
 
+queue_SOURCES = queue.c
+queue_CFLAGS = $(AM_CFLAGS)
+
 thread1_SOURCES = thread.c
 thread1_CFLAGS = -DTESTNUM=1 $(AM_CFLAGS)
 thread2_SOURCES = thread.c
diff --git a/testsuite/threads/queue.c b/testsuite/threads/queue.c
new file mode 100644 (file)
index 0000000..2435e31
--- /dev/null
@@ -0,0 +1,90 @@
+#include <gst/gst.h>
+
+#include <unistd.h>
+
+/*
+ * queue test code
+ * starts a fakesrc num_buffers=50 ! { queue ! fakesink } thread
+ * by first setting the output thread to play, then the whole pipeline
+ */
+
+static gint handoff_count = 0;
+
+/* handoff callback */
+static void
+handoff (GstElement *element, gpointer data)
+{
+  ++handoff_count;
+  g_print ("handoff (%d) ", handoff_count);
+}
+
+static void
+construct_pipeline (GstElement *pipeline, GstElement *thread) 
+{
+  GstElement *src, *sink, *queue;
+
+  src      = gst_element_factory_make ("fakesrc",  NULL);
+  sink     = gst_element_factory_make ("fakesink", "sink");
+  queue    = gst_element_factory_make ("queue",    NULL);
+
+  gst_bin_add_many (GST_BIN (thread), queue, sink, NULL);
+  gst_bin_add_many (GST_BIN (pipeline), src, thread, NULL);
+
+  gst_element_link_many (src, queue, sink, NULL);
+
+  g_object_set (G_OBJECT (src), "num_buffers", 50, NULL);
+
+  g_object_set (G_OBJECT (sink), "signal-handoffs", TRUE, NULL);
+  g_signal_connect (G_OBJECT (sink), "handoff", G_CALLBACK (handoff), NULL);
+}
+
+void
+change_state (GstElement *element, GstBuffer *buf, GstElement *pipeline) 
+{
+  gst_element_set_state (pipeline, GST_STATE_NULL);
+}
+
+int
+main (gint argc, gchar *argv[])
+{
+  GstElement *pipeline;
+  GstElement *thread = NULL;
+  
+  gst_init (&argc, &argv);
+
+  pipeline = gst_thread_new ("main_pipeline");
+  thread = gst_element_factory_make ("thread", NULL);
+  construct_pipeline (pipeline, thread);
+
+  g_print ("First run: to show the pipeline works\n");
+  gst_element_set_state (pipeline, GST_STATE_PLAYING);
+  g_print ("SLEEPING 1 sec\n");
+  sleep (1);
+
+  g_print ("Pipeline done. Resetting to NULL.\n");
+  gst_element_set_state (pipeline, GST_STATE_NULL);
+
+  if (handoff_count == 0)
+  {
+    g_print ("ERROR: no buffers have passed\n");
+    return -1;
+  }
+
+  handoff_count = 0;
+
+  g_print ("Second run: setting consumer thread to playing, then complete pipeline\n");
+  gst_element_set_state (thread, GST_STATE_PLAYING);
+  g_print ("SLEEPING 1 sec\n");
+  sleep (1);
+  gst_element_set_state (pipeline, GST_STATE_PLAYING);
+  g_print ("SLEEPING 2 sec\n");
+  sleep (2);
+
+  if (handoff_count == 0)
+  {
+    g_print ("ERROR: no buffers have passed\n");
+    return -1;
+  }
+  return 0;
+}