8 #include <gst/app/gstappsrc.h>
9 #include <gst/app/gstappsink.h>
16 typedef struct _App App;
28 main (int argc, char *argv[])
33 gst_init (&argc, &argv);
35 app->pipe = gst_pipeline_new (NULL);
38 app->src = gst_element_factory_make ("appsrc", NULL);
40 gst_bin_add (GST_BIN (app->pipe), app->src);
42 app->id = gst_element_factory_make ("identity", NULL);
44 gst_bin_add (GST_BIN (app->pipe), app->id);
46 app->sink = gst_element_factory_make ("appsink", NULL);
48 gst_bin_add (GST_BIN (app->pipe), app->sink);
50 gst_element_link (app->src, app->id);
51 gst_element_link (app->id, app->sink);
53 gst_element_set_state (app->pipe, GST_STATE_PLAYING);
55 for (i = 0; i < 10; i++) {
59 buf = gst_buffer_new_and_alloc (100);
60 gst_buffer_map (buf, &map, GST_MAP_WRITE);
61 memset (map.data, i, 100);
62 gst_buffer_unmap (buf, &map);
64 printf ("%d: pushing buffer for pointer %p, %p\n", i, map.data, buf);
65 gst_app_src_push_buffer (GST_APP_SRC (app->src), buf);
69 gst_app_src_end_of_stream (GST_APP_SRC (app->src));
71 /* _is_eos() does not block and returns TRUE if there is not currently an EOS
73 while (!gst_app_sink_is_eos (GST_APP_SINK (app->sink))) {
76 /* pull the next item, this can return NULL when there is no more data and
77 * EOS has been received */
78 sample = gst_app_sink_pull_sample (GST_APP_SINK (app->sink));
79 printf ("retrieved sample %p\n", sample);
81 gst_sample_unref (sample);
83 gst_element_set_state (app->pipe, GST_STATE_NULL);