8 #include <gst/app/gstappsrc.h>
9 #include <gst/app/gstappbuffer.h>
10 #include <gst/app/gstappsink.h>
17 typedef struct _App App;
28 static void dont_eat_my_chicken_wings (void *priv);
31 main (int argc, char *argv[])
36 gst_init (&argc, &argv);
38 app->pipe = gst_pipeline_new (NULL);
41 app->src = gst_element_factory_make ("appsrc", NULL);
43 gst_bin_add (GST_BIN (app->pipe), app->src);
45 app->id = gst_element_factory_make ("identity", NULL);
47 gst_bin_add (GST_BIN (app->pipe), app->id);
49 app->sink = gst_element_factory_make ("appsink", NULL);
51 gst_bin_add (GST_BIN (app->pipe), app->sink);
53 gst_element_link (app->src, app->id);
54 gst_element_link (app->id, app->sink);
56 gst_element_set_state (app->pipe, GST_STATE_PLAYING);
58 for (i = 0; i < 10; i++) {
63 memset (data, i, 100);
65 buf = gst_app_buffer_new (data, 100, dont_eat_my_chicken_wings, data);
66 printf ("%d: creating buffer for pointer %p, %p\n", i, data, buf);
67 gst_app_src_push_buffer (GST_APP_SRC (app->src), buf);
71 gst_app_src_end_of_stream (GST_APP_SRC (app->src));
73 /* _is_eos() does not block and returns TRUE if there is not currently an EOS
75 while (!gst_app_sink_is_eos (GST_APP_SINK (app->sink))) {
78 /* pull the next item, this can return NULL when there is no more data and
79 * EOS has been received */
80 buf = gst_app_sink_pull_buffer (GST_APP_SINK (app->sink));
81 printf ("retrieved buffer %p\n", buf);
83 gst_buffer_unref (buf);
85 gst_element_set_state (app->pipe, GST_STATE_NULL);
91 dont_eat_my_chicken_wings (void *priv)
93 printf ("freeing buffer for pointer %p\n", priv);