summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorWim Taymans <wim.taymans@gmail.com>2002-01-06 19:30:09 +0000
committerWim Taymans <wim.taymans@gmail.com>2002-01-06 19:30:09 +0000
commitd13417cfa213800c0b9f67e1f7fa7c8c9f273a32 (patch)
tree6429307d80bf78cbb162ca2d8ba1448ab8e41f0c /examples
parentdea4419a80b2c88f3685d6bcfbcde6873dd13cdc (diff)
downloadgst-plugins-bad-d13417cfa213800c0b9f67e1f7fa7c8c9f273a32.tar.gz
gst-plugins-bad-d13417cfa213800c0b9f67e1f7fa7c8c9f273a32.tar.bz2
gst-plugins-bad-d13417cfa213800c0b9f67e1f7fa7c8c9f273a32.zip
Added a check for sidplay
Original commit message from CVS: Added a check for sidplay Added a capsfilter example
Diffstat (limited to 'examples')
-rw-r--r--examples/capsfilter/Makefile.am6
-rw-r--r--examples/capsfilter/capsfilter1.c90
2 files changed, 96 insertions, 0 deletions
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 <gst/gst.h>
+
+/* 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 <mpeg1 system stream>\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;
+}