diff options
author | Dave Robillard <dave@drobilla.net> | 2009-05-31 19:26:30 -0400 |
---|---|---|
committer | Dave Robillard <dave@drobilla.net> | 2009-05-31 19:26:30 -0400 |
commit | af14cf34e69e46bfd6544a420b3fdd7e131aa69a (patch) | |
tree | 2bd39ab6ab67995d6e4c69a3e6c6eae2a17f350e /tests | |
parent | bd9a3cbd254714bf71cd87c31d4e5b77f6a96cba (diff) | |
parent | b19dd5920605c0036dacf19591a6feca7a736a50 (diff) | |
download | gst-plugins-bad-af14cf34e69e46bfd6544a420b3fdd7e131aa69a.tar.gz gst-plugins-bad-af14cf34e69e46bfd6544a420b3fdd7e131aa69a.tar.bz2 gst-plugins-bad-af14cf34e69e46bfd6544a420b3fdd7e131aa69a.zip |
Merge branch 'fdo' into lv2
Diffstat (limited to 'tests')
-rw-r--r-- | tests/examples/Makefile.am | 4 | ||||
-rw-r--r-- | tests/examples/shapewipe/Makefile.am | 8 | ||||
-rw-r--r-- | tests/examples/shapewipe/shapewipe-example.c | 128 |
3 files changed, 138 insertions, 2 deletions
diff --git a/tests/examples/Makefile.am b/tests/examples/Makefile.am index e20db8df..b36232de 100644 --- a/tests/examples/Makefile.am +++ b/tests/examples/Makefile.am @@ -10,5 +10,5 @@ else DIRECTFB_DIR= endif -SUBDIRS= $(DIRECTFB_DIR) $(GTK_EXAMPLES) switch -DIST_SUBDIRS= directfb switch scaletempo mxf +SUBDIRS= $(DIRECTFB_DIR) $(GTK_EXAMPLES) switch shapewipe mxf +DIST_SUBDIRS= directfb switch scaletempo shapewipe mxf diff --git a/tests/examples/shapewipe/Makefile.am b/tests/examples/shapewipe/Makefile.am new file mode 100644 index 00000000..0a5eecf1 --- /dev/null +++ b/tests/examples/shapewipe/Makefile.am @@ -0,0 +1,8 @@ +noinst_PROGRAMS = shapewipe-example + +shapewipe_example_SOURCES = shapewipe-example.c +shapewipe_example_CFLAGS = $(GST_CFLAGS) $(GST_CONTROLLER_CFLAGS) +shapewipe_example_LDFLAGS = $(GST_LIBS) $(GST_CONTROLLER_LIBS) + +noinst_HEADERS = + diff --git a/tests/examples/shapewipe/shapewipe-example.c b/tests/examples/shapewipe/shapewipe-example.c new file mode 100644 index 00000000..1179aab3 --- /dev/null +++ b/tests/examples/shapewipe/shapewipe-example.c @@ -0,0 +1,128 @@ +/* GStreamer + * Copyright (C) 2009 Sebastian Dröge <sebastian.droege@collabora.co.uk> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include <gst/gst.h> +#include <gst/controller/gstcontroller.h> +#include <gst/controller/gstlfocontrolsource.h> + +static gboolean +on_message (GstBus * bus, GstMessage * message, gpointer user_data) +{ + GMainLoop *loop = (GMainLoop *) user_data; + + switch (GST_MESSAGE_TYPE (message)) { + case GST_MESSAGE_ERROR: + g_warning ("Got ERROR"); + g_main_loop_quit (loop); + break; + case GST_MESSAGE_WARNING: + g_warning ("Got WARNING"); + g_main_loop_quit (loop); + break; + case GST_MESSAGE_EOS: + g_main_loop_quit (loop); + break; + default: + break; + } + + return TRUE; +} + +gint +main (gint argc, gchar ** argv) +{ + GstElement *pipeline; + GstElement *shapewipe; + GstController *ctrl; + GstLFOControlSource *csource; + GValue val = { 0, }; + GMainLoop *loop; + GstBus *bus; + gchar *pipeline_string; + + if (argc != 2) { + g_print ("Usage: shapewipe mask.png\n"); + return -1; + } + + gst_init (&argc, &argv); + gst_controller_init (&argc, &argv); + + pipeline_string = + g_strdup_printf + ("videotestsrc ! video/x-raw-yuv,width=640,height=480 ! shapewipe name=shape border=0.05 ! videomixer name=mixer ! ffmpegcolorspace ! autovideosink filesrc location=%s ! typefind ! decodebin2 ! ffmpegcolorspace ! videoscale ! queue ! shape.mask_sink videotestsrc pattern=snow ! video/x-raw-yuv,width=640,height=480 ! queue ! mixer.", + argv[1]); + + pipeline = gst_parse_launch (pipeline_string, NULL); + g_free (pipeline_string); + + if (pipeline == NULL) { + g_print ("Failed to create pipeline\n"); + return -2; + } + + shapewipe = gst_bin_get_by_name (GST_BIN (pipeline), "shape"); + + if (!(ctrl = gst_controller_new (G_OBJECT (shapewipe), "position", NULL))) { + g_print ("can't control shapewipe element\n"); + return -3; + } + + csource = gst_lfo_control_source_new (); + + gst_controller_set_control_source (ctrl, "position", + GST_CONTROL_SOURCE (csource)); + + g_value_init (&val, G_TYPE_FLOAT); + g_value_set_float (&val, 0.5); + g_object_set (G_OBJECT (csource), "amplitude", &val, NULL); + g_value_set_float (&val, 0.5); + g_object_set (G_OBJECT (csource), "offset", &val, NULL); + g_value_unset (&val); + + g_object_set (G_OBJECT (csource), "frequency", 0.5, NULL); + g_object_set (G_OBJECT (csource), "timeshift", 500 * GST_MSECOND, NULL); + + g_object_unref (csource); + + loop = g_main_loop_new (NULL, FALSE); + + bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline)); + gst_bus_add_signal_watch (bus); + g_signal_connect (G_OBJECT (bus), "message", G_CALLBACK (on_message), loop); + gst_object_unref (GST_OBJECT (bus)); + + if (gst_element_set_state (pipeline, + GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE) { + g_error ("Failed to go into PLAYING state"); + return -4; + } + + g_main_loop_run (loop); + + gst_element_set_state (pipeline, GST_STATE_NULL); + + g_main_loop_unref (loop); + + g_object_unref (G_OBJECT (ctrl)); + gst_object_unref (G_OBJECT (pipeline)); + + return 0; +} |