Test program for simple queue operations. Good for testing thread/cothread interations.
authorErik Walthinsen <omega@temple-baptist.org>
Fri, 8 Dec 2000 20:31:40 +0000 (20:31 +0000)
committerErik Walthinsen <omega@temple-baptist.org>
Fri, 8 Dec 2000 20:31:40 +0000 (20:31 +0000)
Original commit message from CVS:
Test program for simple queue operations.  Good for testing thread/cothread
interations.

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

index 37212d1..3029f9a 100644 (file)
@@ -1,4 +1,4 @@
-noinst_PROGRAMS = init loadall simplefake states caps
+noinst_PROGRAMS = init loadall simplefake states caps queue
 
 LDADD = $(GLIB_LIBS) $(GTK_LIBS) $(top_builddir)/gst/libgst.la
 CFLAGS = -Wall
diff --git a/tests/queue.c b/tests/queue.c
new file mode 100644 (file)
index 0000000..2329a10
--- /dev/null
@@ -0,0 +1,53 @@
+#include <gst/gst.h>
+
+int main(int argc,char *argv[]) {
+  GstBin *pipeline,*thr1,*thr2;
+  GstElement *src,*queue,*sink;
+  int i;
+
+  gst_init(&argc,&argv);
+
+  pipeline = GST_BIN(gst_pipeline_new("pipeline"));
+  g_return_val_if_fail(1,pipeline != NULL);
+//  thr1 = GST_BIN(gst_thread_new("thr1"));
+  thr1 = gst_bin_new("thr1");
+  g_return_val_if_fail(2,thr1 != NULL);
+//  thr2 = GST_BIN(gst_thread_new("thr2"));
+  thr2 = gst_bin_new("thr2");
+  g_return_val_if_fail(3,thr2 != NULL);
+fprintf(stderr,"QUEUE: fakesrc\n");
+  src = gst_elementfactory_make("fakesrc","src");
+  g_return_val_if_fail(4,src != NULL);
+fprintf(stderr,"QUEUE: queue\n");
+  queue = gst_elementfactory_make("queue","queue");
+  g_return_val_if_fail(4,queue != NULL);
+fprintf(stderr,"QUEUE: fakesink\n");
+  sink = gst_elementfactory_make("fakesink","sink");
+  g_return_val_if_fail(5,sink != NULL);
+  fprintf(stderr,"QUEUE: have elements\n");
+
+  gst_bin_add(thr1,src);
+  fprintf(stderr,"QUEUE: added src to thr1\n");
+  gst_element_add_ghost_pad(GST_ELEMENT(thr1),gst_element_get_pad(src,"src"));
+//  gst_bin_use_cothreads(thr1,TRUE);
+  gst_bin_add(thr2,sink);
+  fprintf(stderr,"QUEUE: added sink to thr2\n");
+  gst_element_add_ghost_pad(GST_ELEMENT(thr2),gst_element_get_pad(sink,"sink"));
+  gst_bin_use_cothreads(thr2,TRUE);
+  fprintf(stderr,"QUEUE: filled in threads\n");
+
+  gst_bin_add(pipeline,GST_ELEMENT(thr1));
+  gst_bin_add(pipeline,GST_ELEMENT(queue));
+  gst_bin_add(pipeline,GST_ELEMENT(thr2));
+  gst_element_connect(thr1,"src",queue,"sink");
+  gst_element_connect(queue,"src",thr2,"sink");
+  printf("QUEUE: constructed outer pipeline\n");
+
+  gst_element_set_state(GST_ELEMENT(pipeline),GST_STATE_PLAYING);
+  if (GST_STATE(src) != GST_STATE_PLAYING) fprintf(stderr,"error: state not set\n");
+
+  fprintf(stderr,"\n\n");
+  gst_bin_iterate(thr1);
+  fprintf(stderr,"\n\n");
+  gst_bin_iterate(thr2);
+}