3 /* This app uses a filter to connect colorspace and videosink
4 * so that only RGB data can pass the connection, colorspace will use
5 * a converter to convert the I420 data to RGB. Without a filter, this
6 * connection would use the I420 format (assuming Xv is enabled) */
9 new_pad_func (GstElement *element, GstPad *newpad, gpointer data)
11 GstElement *pipeline = (GstElement *) data;
12 GstElement *queue = gst_bin_get_by_name (GST_BIN (pipeline), "queue");
14 if (!strcmp (gst_pad_get_name (newpad), "video_00")) {
15 gst_element_set_state (pipeline, GST_STATE_PAUSED);
16 gst_pad_link (newpad, gst_element_get_pad (queue, "sink"));
17 gst_element_set_state (pipeline, GST_STATE_PLAYING);
22 main (gint argc, gchar *argv[])
30 GstElement *colorspace;
31 GstElement *xvideosink;
34 gst_init (&argc, &argv);
37 g_print ("usage: %s <mpeg1 system stream>\n", argv[0]);
41 pipeline = gst_pipeline_new ("main_pipeline");
42 filesrc = gst_element_factory_make ("filesrc", "filesrc");
43 g_return_val_if_fail (filesrc, -1);
44 g_object_set (G_OBJECT (filesrc), "location", argv[1], NULL);
45 demux = gst_element_factory_make ("mpegdemux", "demux");
46 g_return_val_if_fail (demux, -1);
47 g_signal_connect (G_OBJECT (demux), "new_pad", G_CALLBACK (new_pad_func), pipeline);
49 thread = gst_thread_new ("thread");
50 queue = gst_element_factory_make ("queue", "queue");
51 mpeg2dec = gst_element_factory_make ("mpeg2dec", "mpeg2dec");
52 g_return_val_if_fail (mpeg2dec, -1);
53 colorspace = gst_element_factory_make ("colorspace", "colorspace");
54 g_return_val_if_fail (colorspace, -1);
55 xvideosink = gst_element_factory_make ("xvideosink", "xvideosink");
56 g_return_val_if_fail (xvideosink, -1);
57 g_object_set (G_OBJECT (xvideosink), "toplevel", TRUE, NULL);
59 gst_bin_add (GST_BIN (pipeline), filesrc);
60 gst_bin_add (GST_BIN (pipeline), demux);
62 gst_bin_add (GST_BIN (thread), queue);
63 gst_bin_add (GST_BIN (thread), mpeg2dec);
64 gst_bin_add (GST_BIN (thread), colorspace);
65 gst_bin_add (GST_BIN (thread), xvideosink);
66 gst_bin_add (GST_BIN (pipeline), thread);
68 gst_element_link (filesrc, "src", demux, "sink");
69 gst_element_link (queue, "src", mpeg2dec, "sink");
70 gst_element_link (mpeg2dec, "src", colorspace, "sink");
71 /* force RGB data passing between colorspace and xvideosink */
72 res = gst_element_link_filtered (colorspace, "src", xvideosink, "sink",
76 "format", GST_PROPS_FOURCC (GST_STR_FOURCC ("RGB "))
79 g_print ("could not connect colorspace and xvideosink\n");
83 gst_element_set_state (pipeline, GST_STATE_PLAYING);
85 while (gst_bin_iterate (GST_BIN (pipeline)));
87 gst_element_set_state (pipeline, GST_STATE_NULL);