1 /* GStreamer
2 * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
13 *
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
18 */
20 #include <gst/gst.h>
22 static void
23 fill_queue (GstElement * queue, gint level, GstBin * pipeline)
24 {
25 /* this needs to iterate till something is pushed
26 * in the queue */
27 gst_bin_iterate (pipeline);
28 }
30 gint
31 main (gint argc, gchar * argv[])
32 {
33 GstElement *queue, *src, *pipeline;
34 GstBuffer *buffer;
35 gboolean done = FALSE;
36 GstPad *pad;
38 gst_init (&argc, &argv);
40 queue = gst_element_factory_make ("queue", "queue");
41 g_object_set (G_OBJECT (queue), "signal_marks", TRUE, NULL);
43 src = gst_element_factory_make ("filesrc", "src");
44 g_object_set (G_OBJECT (src), "location", "appreader.c", NULL);
46 pipeline = gst_pipeline_new ("pipeline");
48 gst_bin_add_many (GST_BIN (pipeline), src, queue, NULL);
50 gst_element_link_many (src, queue, NULL);
52 pad = gst_element_get_pad (queue, "src");
53 g_signal_connect (G_OBJECT (queue), "low_watermark", G_CALLBACK (fill_queue),
54 pipeline);
56 gst_element_set_state (pipeline, GST_STATE_PLAYING);
58 do {
59 /* get buffer into the app */
60 buffer = GST_RPAD_GETFUNC (pad) (pad);
62 /* just exit on any event */
63 if (GST_IS_EVENT (buffer)) {
64 done = TRUE;
65 } else {
66 gst_util_dump_mem (GST_BUFFER_DATA (buffer), GST_BUFFER_SIZE (buffer));
67 }
68 gst_data_unref (GST_DATA (buffer));
70 } while (!done);
72 gst_element_set_state (pipeline, GST_STATE_NULL);
73 gst_object_unref (GST_OBJECT (pipeline));
75 return 0;
76 }