From d13417cfa213800c0b9f67e1f7fa7c8c9f273a32 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Sun, 6 Jan 2002 19:30:09 +0000 Subject: Added a check for sidplay Original commit message from CVS: Added a check for sidplay Added a capsfilter example --- examples/capsfilter/Makefile.am | 6 +++ examples/capsfilter/capsfilter1.c | 90 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 96 insertions(+) create mode 100644 examples/capsfilter/Makefile.am create mode 100644 examples/capsfilter/capsfilter1.c (limited to 'examples') diff --git a/examples/capsfilter/Makefile.am b/examples/capsfilter/Makefile.am new file mode 100644 index 00000000..f8562fee --- /dev/null +++ b/examples/capsfilter/Makefile.am @@ -0,0 +1,6 @@ +noinst_PROGRAMS = capsfilter1 + +LDADD = $(GST_LIBS) +AM_CFLAGS = $(GST_CFLAGS) + + diff --git a/examples/capsfilter/capsfilter1.c b/examples/capsfilter/capsfilter1.c new file mode 100644 index 00000000..ab6f4a09 --- /dev/null +++ b/examples/capsfilter/capsfilter1.c @@ -0,0 +1,90 @@ +#include + +/* This app uses a filter to connect colorspace and videosink + * so that only RGB data can pass the connection, colorspace will use + * a converter to convert the I420 data to RGB. Without a filter, this + * connection would use the I420 format (assuming Xv is enabled) */ + +static void +new_pad_func (GstElement *element, GstPad *newpad, gpointer data) +{ + GstElement *pipeline = (GstElement *) data; + GstElement *queue = gst_bin_get_by_name (GST_BIN (pipeline), "queue"); + + if (!strcmp (gst_pad_get_name (newpad), "video_00")) { + gst_element_set_state (pipeline, GST_STATE_PAUSED); + gst_pad_connect (newpad, gst_element_get_pad (queue, "sink")); + gst_element_set_state (pipeline, GST_STATE_PLAYING); + } +} + +gint +main (gint argc, gchar *argv[]) +{ + GstElement *pipeline; + GstElement *filesrc; + GstElement *demux; + GstElement *thread; + GstElement *queue; + GstElement *mpeg2dec; + GstElement *colorspace; + GstElement *xvideosink; + gboolean res; + + gst_init (&argc, &argv); + + if (argc < 2) { + g_print ("usage: %s \n", argv[0]); + return (-1); + } + + pipeline = gst_pipeline_new ("main_pipeline"); + filesrc = gst_elementfactory_make ("filesrc", "filesrc"); + g_return_val_if_fail (filesrc, -1); + g_object_set (G_OBJECT (filesrc), "location", argv[1], NULL); + demux = gst_elementfactory_make ("mpegdemux", "demux"); + g_return_val_if_fail (demux, -1); + g_signal_connect (G_OBJECT (demux), "new_pad", G_CALLBACK (new_pad_func), pipeline); + + thread = gst_thread_new ("thread"); + queue = gst_elementfactory_make ("queue", "queue"); + mpeg2dec = gst_elementfactory_make ("mpeg2dec", "mpeg2dec"); + g_return_val_if_fail (mpeg2dec, -1); + colorspace = gst_elementfactory_make ("colorspace", "colorspace"); + g_return_val_if_fail (colorspace, -1); + xvideosink = gst_elementfactory_make ("xvideosink", "xvideosink"); + g_return_val_if_fail (xvideosink, -1); + g_object_set (G_OBJECT (xvideosink), "toplevel", TRUE, NULL); + + gst_bin_add (GST_BIN (pipeline), filesrc); + gst_bin_add (GST_BIN (pipeline), demux); + + gst_bin_add (GST_BIN (thread), queue); + gst_bin_add (GST_BIN (thread), mpeg2dec); + gst_bin_add (GST_BIN (thread), colorspace); + gst_bin_add (GST_BIN (thread), xvideosink); + gst_bin_add (GST_BIN (pipeline), thread); + + gst_element_connect (filesrc, "src", demux, "sink"); + gst_element_connect (queue, "src", mpeg2dec, "sink"); + gst_element_connect (mpeg2dec, "src", colorspace, "sink"); + /* force RGB data passing between colorspace and xvideosink */ + res = gst_element_connect_filtered (colorspace, "src", xvideosink, "sink", + GST_CAPS_NEW ( + "filtercaps", + "video/raw", + "format", GST_PROPS_FOURCC (GST_STR_FOURCC ("RGB ")) + )); + if (!res) { + g_print ("could not connect colorspace and xvideosink\n"); + return -1; + } + + gst_element_set_state (pipeline, GST_STATE_PLAYING); + + while (gst_bin_iterate (GST_BIN (pipeline))); + + gst_element_set_state (pipeline, GST_STATE_NULL); + + return 0; +} -- cgit v1.2.1