2009-05-29 13:32:24 +00:00
|
|
|
/* 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
|
2012-11-04 00:07:18 +00:00
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
2009-05-29 13:32:24 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <gst/gst.h>
|
|
|
|
#include <gst/controller/gstlfocontrolsource.h>
|
2012-01-30 20:39:34 +00:00
|
|
|
#include <gst/controller/gstdirectcontrolbinding.h>
|
2009-05-29 13:32:24 +00:00
|
|
|
|
2010-09-21 20:23:07 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
2009-05-29 13:32:24 +00:00
|
|
|
static gboolean
|
|
|
|
on_message (GstBus * bus, GstMessage * message, gpointer user_data)
|
|
|
|
{
|
|
|
|
GMainLoop *loop = (GMainLoop *) user_data;
|
|
|
|
|
|
|
|
switch (GST_MESSAGE_TYPE (message)) {
|
2010-02-10 09:34:24 +00:00
|
|
|
case GST_MESSAGE_ERROR:{
|
|
|
|
GError *err = NULL;
|
|
|
|
gchar *debug = NULL;
|
|
|
|
|
2009-05-29 13:32:24 +00:00
|
|
|
g_warning ("Got ERROR");
|
2010-02-10 09:34:24 +00:00
|
|
|
gst_message_parse_error (message, &err, &debug);
|
|
|
|
g_warning ("%s: %s", err->message, debug);
|
2009-05-29 13:32:24 +00:00
|
|
|
g_main_loop_quit (loop);
|
|
|
|
break;
|
2010-02-10 09:34:24 +00:00
|
|
|
}
|
|
|
|
case GST_MESSAGE_WARNING:{
|
|
|
|
GError *err = NULL;
|
|
|
|
gchar *debug = NULL;
|
|
|
|
|
2009-05-29 13:32:24 +00:00
|
|
|
g_warning ("Got WARNING");
|
2010-02-10 09:34:24 +00:00
|
|
|
gst_message_parse_error (message, &err, &debug);
|
|
|
|
g_warning ("%s: %s", err->message, debug);
|
2009-05-29 13:32:24 +00:00
|
|
|
g_main_loop_quit (loop);
|
|
|
|
break;
|
2010-02-10 09:34:24 +00:00
|
|
|
}
|
2009-05-29 13:32:24 +00:00
|
|
|
case GST_MESSAGE_EOS:
|
|
|
|
g_main_loop_quit (loop);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
gint
|
|
|
|
main (gint argc, gchar ** argv)
|
|
|
|
{
|
|
|
|
GstElement *pipeline;
|
|
|
|
GstElement *shapewipe;
|
2012-01-31 11:22:19 +00:00
|
|
|
GstControlSource *cs;
|
2009-05-29 13:32:24 +00:00
|
|
|
GMainLoop *loop;
|
|
|
|
GstBus *bus;
|
|
|
|
gchar *pipeline_string;
|
2010-09-21 20:23:07 +00:00
|
|
|
gfloat border = 0.05;
|
2009-05-29 13:32:24 +00:00
|
|
|
|
2010-09-21 20:23:07 +00:00
|
|
|
if (argc < 2) {
|
|
|
|
g_print ("Usage: shapewipe mask.png <border>\n");
|
2009-05-29 13:32:24 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
gst_init (&argc, &argv);
|
|
|
|
|
2010-09-21 20:23:07 +00:00
|
|
|
if (argc > 2) {
|
|
|
|
border = atof (argv[2]);
|
|
|
|
}
|
|
|
|
|
2009-05-29 13:32:24 +00:00
|
|
|
pipeline_string =
|
|
|
|
g_strdup_printf
|
2015-06-25 09:57:25 +00:00
|
|
|
("videotestsrc ! video/x-raw,format=(string)AYUV,width=640,height=480 ! shapewipe name=shape border=%f ! videomixer name=mixer ! videoconvert ! autovideosink filesrc location=%s ! typefind ! decodebin ! videoconvert ! videoscale ! queue ! shape.mask_sink videotestsrc pattern=snow ! video/x-raw,format=(string)AYUV,width=640,height=480 ! queue ! mixer.",
|
2010-09-21 20:23:07 +00:00
|
|
|
border, argv[1]);
|
2009-05-29 13:32:24 +00:00
|
|
|
|
|
|
|
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");
|
|
|
|
|
2012-01-31 11:22:19 +00:00
|
|
|
cs = gst_lfo_control_source_new ();
|
2009-05-29 13:32:24 +00:00
|
|
|
|
2012-01-20 13:45:01 +00:00
|
|
|
gst_object_add_control_binding (GST_OBJECT_CAST (shapewipe),
|
2012-01-30 20:39:34 +00:00
|
|
|
gst_direct_control_binding_new (GST_OBJECT_CAST (shapewipe), "position",
|
2012-01-31 11:22:19 +00:00
|
|
|
cs));
|
2014-08-08 10:54:30 +00:00
|
|
|
gst_object_unref (shapewipe);
|
2009-05-29 13:32:24 +00:00
|
|
|
|
2012-01-31 11:22:19 +00:00
|
|
|
g_object_set (cs,
|
|
|
|
"amplitude", 0.5,
|
|
|
|
"offset", 0.5, "frequency", 0.25, "timeshift", 500 * GST_MSECOND, NULL);
|
2009-05-29 13:32:24 +00:00
|
|
|
|
2012-01-31 11:22:19 +00:00
|
|
|
g_object_unref (cs);
|
2009-05-29 13:32:24 +00:00
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
gst_object_unref (G_OBJECT (pipeline));
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|