Initialize Tizen 2.3
[framework/multimedia/gstreamer0.10.git] / wearable / tests / examples / manual / pad.c
1
2 /*** block a  from ../../../docs/manual/basics-pads.xml ***/
3 #include <gst/gst.h>
4
5 static void
6 cb_new_pad (GstElement *element,
7             GstPad     *pad,
8             gpointer    data)
9 {
10   gchar *name;
11
12   name = gst_pad_get_name (pad);
13   g_print ("A new pad %s was created\n", name);
14   g_free (name);
15
16   /* here, you would setup a new pad link for the newly created pad */
17
18 /*** block b  from ../../../docs/manual/basics-pads.xml ***/
19 }
20
21 int 
22 main (int   argc,
23       char *argv[]) 
24 {
25   GstElement *pipeline, *source, *demux;
26   GMainLoop *loop;
27
28   /* init */
29   gst_init (&argc, &argv);
30
31   /* create elements */
32   pipeline = gst_pipeline_new ("my_pipeline");
33   source = gst_element_factory_make ("filesrc", "source");
34   g_object_set (source, "location", argv[1], NULL);
35   demux = gst_element_factory_make ("oggdemux", "demuxer");
36
37   /* you would normally check that the elements were created properly */
38
39   /* put together a pipeline */
40   gst_bin_add_many (GST_BIN (pipeline), source, demux, NULL);
41   gst_element_link_pads (source, "src", demux, "sink");
42
43   /* listen for newly created pads */
44   g_signal_connect (demux, "pad-added", G_CALLBACK (cb_new_pad), NULL);
45
46   /* start the pipeline */
47   gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING);
48   loop = g_main_loop_new (NULL, FALSE);
49   g_main_loop_run (loop);
50   return 0;
51
52 /*** block d  from ../../../docs/manual/basics-pads.xml ***/
53 }