Example of how an app could read data from a pipeline, this one wont run before queue...
authorWim Taymans <wim.taymans@gmail.com>
Wed, 12 Feb 2003 23:18:54 +0000 (23:18 +0000)
committerWim Taymans <wim.taymans@gmail.com>
Wed, 12 Feb 2003 23:18:54 +0000 (23:18 +0000)
Original commit message from CVS:
Example of how an app could read data from a pipeline, this one wont run
before queue is changed.

examples/appreader/.gitignore [new file with mode: 0644]
examples/appreader/Makefile.am [new file with mode: 0644]
examples/appreader/appreader.c [new file with mode: 0644]
tests/old/examples/appreader/.gitignore [new file with mode: 0644]
tests/old/examples/appreader/Makefile.am [new file with mode: 0644]
tests/old/examples/appreader/appreader.c [new file with mode: 0644]

diff --git a/examples/appreader/.gitignore b/examples/appreader/.gitignore
new file mode 100644 (file)
index 0000000..2167b1b
--- /dev/null
@@ -0,0 +1 @@
+appreader
diff --git a/examples/appreader/Makefile.am b/examples/appreader/Makefile.am
new file mode 100644 (file)
index 0000000..b05f4a7
--- /dev/null
@@ -0,0 +1,5 @@
+noinst_PROGRAMS = appreader
+
+appreader_LDADD = $(GST_LIBS)
+appreader_CFLAGS = $(GST_CFLAGS)
+
diff --git a/examples/appreader/appreader.c b/examples/appreader/appreader.c
new file mode 100644 (file)
index 0000000..f735b51
--- /dev/null
@@ -0,0 +1,76 @@
+/* GStreamer
+ * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include <gst/gst.h>
+
+static void
+fill_queue (GstElement *queue, gint level, GstBin *pipeline)
+{
+  /* this needs to iterate till something is pushed 
+   * in the queue */
+  gst_bin_iterate (pipeline);
+}
+
+gint 
+main (gint argc, gchar *argv[])
+{
+  GstElement *queue, *src, *pipeline;
+  GstBuffer *buffer;
+  gboolean done = FALSE;
+  GstPad *pad;
+         
+  gst_init (&argc, &argv);
+
+  queue = gst_element_factory_make ("queue", "queue");
+  g_object_set (G_OBJECT (queue), "signal_marks", TRUE, NULL);
+
+  src = gst_element_factory_make ("filesrc", "src");
+  g_object_set (G_OBJECT (src), "location", "appreader.c", NULL);
+
+  pipeline = gst_pipeline_new ("pipeline");
+
+  gst_bin_add_many (GST_BIN (pipeline), src, queue, NULL);
+
+  gst_element_link_many (src, queue, NULL);
+
+  pad = gst_element_get_pad (queue, "src");
+  g_signal_connect (G_OBJECT (queue), "low_watermark", G_CALLBACK (fill_queue), pipeline);
+
+  gst_element_set_state (pipeline, GST_STATE_PLAYING);
+
+  do { 
+    /* get buffer into the app */
+    buffer = GST_RPAD_GETFUNC (pad) (pad);
+
+    /* just exit on any event */
+    if (GST_IS_EVENT (buffer)) {
+      done = TRUE;
+    }
+    else {
+      gst_util_dump_mem (GST_BUFFER_DATA (buffer), GST_BUFFER_SIZE (buffer));
+    }
+    gst_data_unref (GST_DATA (buffer));
+
+  } while (!done);
+
+  gst_element_set_state (pipeline, GST_STATE_NULL);
+  gst_object_unref (GST_OBJECT (pipeline));
+  
+  return 0;
+}
diff --git a/tests/old/examples/appreader/.gitignore b/tests/old/examples/appreader/.gitignore
new file mode 100644 (file)
index 0000000..2167b1b
--- /dev/null
@@ -0,0 +1 @@
+appreader
diff --git a/tests/old/examples/appreader/Makefile.am b/tests/old/examples/appreader/Makefile.am
new file mode 100644 (file)
index 0000000..b05f4a7
--- /dev/null
@@ -0,0 +1,5 @@
+noinst_PROGRAMS = appreader
+
+appreader_LDADD = $(GST_LIBS)
+appreader_CFLAGS = $(GST_CFLAGS)
+
diff --git a/tests/old/examples/appreader/appreader.c b/tests/old/examples/appreader/appreader.c
new file mode 100644 (file)
index 0000000..f735b51
--- /dev/null
@@ -0,0 +1,76 @@
+/* GStreamer
+ * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include <gst/gst.h>
+
+static void
+fill_queue (GstElement *queue, gint level, GstBin *pipeline)
+{
+  /* this needs to iterate till something is pushed 
+   * in the queue */
+  gst_bin_iterate (pipeline);
+}
+
+gint 
+main (gint argc, gchar *argv[])
+{
+  GstElement *queue, *src, *pipeline;
+  GstBuffer *buffer;
+  gboolean done = FALSE;
+  GstPad *pad;
+         
+  gst_init (&argc, &argv);
+
+  queue = gst_element_factory_make ("queue", "queue");
+  g_object_set (G_OBJECT (queue), "signal_marks", TRUE, NULL);
+
+  src = gst_element_factory_make ("filesrc", "src");
+  g_object_set (G_OBJECT (src), "location", "appreader.c", NULL);
+
+  pipeline = gst_pipeline_new ("pipeline");
+
+  gst_bin_add_many (GST_BIN (pipeline), src, queue, NULL);
+
+  gst_element_link_many (src, queue, NULL);
+
+  pad = gst_element_get_pad (queue, "src");
+  g_signal_connect (G_OBJECT (queue), "low_watermark", G_CALLBACK (fill_queue), pipeline);
+
+  gst_element_set_state (pipeline, GST_STATE_PLAYING);
+
+  do { 
+    /* get buffer into the app */
+    buffer = GST_RPAD_GETFUNC (pad) (pad);
+
+    /* just exit on any event */
+    if (GST_IS_EVENT (buffer)) {
+      done = TRUE;
+    }
+    else {
+      gst_util_dump_mem (GST_BUFFER_DATA (buffer), GST_BUFFER_SIZE (buffer));
+    }
+    gst_data_unref (GST_DATA (buffer));
+
+  } while (!done);
+
+  gst_element_set_state (pipeline, GST_STATE_NULL);
+  gst_object_unref (GST_OBJECT (pipeline));
+  
+  return 0;
+}