From: Tim-Philipp Müller Date: Mon, 13 Aug 2007 15:37:29 +0000 (+0000) Subject: tests/icles/: Add a dumb little test for textoverlay alignments. X-Git-Tag: RELEASE-0_10_15~164 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5ff55c7a301ae0fec8803196745e9b5d7fbbe2a9;p=platform%2Fupstream%2Fgst-plugins-base.git tests/icles/: Add a dumb little test for textoverlay alignments. Original commit message from CVS: * tests/icles/.cvsignore: * tests/icles/Makefile.am: * tests/icles/test-textoverlay.c: Add a dumb little test for textoverlay alignments. --- diff --git a/ChangeLog b/ChangeLog index 368f019..2bbb204 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,12 @@ 2007-08-13 Tim-Philipp Müller + * tests/icles/.cvsignore: + * tests/icles/Makefile.am: + * tests/icles/test-textoverlay.c: + Add a dumb little test for textoverlay alignments. + +2007-08-13 Tim-Philipp Müller + Patch by: Dan Williams * ext/pango/gsttextoverlay.c: diff --git a/tests/icles/.gitignore b/tests/icles/.gitignore index 103a124..afaa386 100644 --- a/tests/icles/.gitignore +++ b/tests/icles/.gitignore @@ -1 +1,2 @@ stress-xoverlay +test-textoverlay diff --git a/tests/icles/Makefile.am b/tests/icles/Makefile.am index f5835b9..7934753 100644 --- a/tests/icles/Makefile.am +++ b/tests/icles/Makefile.am @@ -10,5 +10,15 @@ else X_TESTS = endif -noinst_PROGRAMS = $(X_TESTS) +if USE_PANGO +PANGO_TESTS = test-textoverlay +test_textoverlay_SOURCES = test-textoverlay.c +test_textoverlay_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS) +test_textoverlay_LDFLAGS = $(GST_LIBS) $(LIBM) + +else +PANGO_TESTS = +endif + +noinst_PROGRAMS = $(X_TESTS) $(PANGO_TESTS) diff --git a/tests/icles/test-textoverlay.c b/tests/icles/test-textoverlay.c new file mode 100644 index 0000000..c206e80 --- /dev/null +++ b/tests/icles/test-textoverlay.c @@ -0,0 +1,107 @@ +/* GStreamer interactive textoverlay test + * Copyright (C) 2007 Tim-Philipp Müller + * + * 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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include + +static void +set_enum_property_by_name (gpointer object, const gchar * prop, + const gchar * value) +{ + GParamSpec *pspec; + GValue val = { 0, }; + GEnumClass *eclass; + GEnumValue *eval; + + pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (object), prop); + g_return_if_fail (pspec != NULL); + + g_value_init (&val, pspec->value_type); + g_object_get_property (G_OBJECT (object), prop, &val); + eclass = G_ENUM_CLASS (g_type_class_peek (G_VALUE_TYPE (&val))); + g_return_if_fail (eclass != NULL); + eval = g_enum_get_value_by_name (eclass, value); + if (eval == NULL) + eval = g_enum_get_value_by_nick (eclass, value); + g_return_if_fail (eval != NULL); + g_value_set_enum (&val, eval->value); + g_object_set_property (G_OBJECT (object), prop, &val); + g_value_unset (&val); +} + +static void +show_text (GstElement * textoverlay, const gchar * txt, const gchar * valign, + const gchar * halign, const gchar * line_align) +{ + GstElement *pipe; + + g_object_set (textoverlay, "text", txt, NULL); + + set_enum_property_by_name (textoverlay, "valignment", valign); + set_enum_property_by_name (textoverlay, "halignment", halign); + set_enum_property_by_name (textoverlay, "line-alignment", line_align); + + pipe = textoverlay; + while (GST_ELEMENT_PARENT (pipe)) + pipe = GST_ELEMENT_PARENT (pipe); + + gst_element_set_state (pipe, GST_STATE_PLAYING); + gst_bus_poll (GST_ELEMENT_BUS (pipe), GST_MESSAGE_ERROR, 2 * GST_SECOND); + gst_element_set_state (pipe, GST_STATE_NULL); +} + +int +main (int argc, char **argv) +{ + GstElement *pipe, *toverlay; + const gchar *valigns[] = { /* "baseline", */ "bottom", "top" }; + const gchar *haligns[] = { "left", "center", "right" }; + const gchar *linealigns[] = { "left", "center", "right" }; + gint a, b, c; + + gst_init (&argc, &argv); + + pipe = gst_parse_launch ("videotestsrc pattern=black ! textoverlay name=t ! " + " ffmpegcolorspace ! videoscale ! autovideosink", NULL); + g_assert (pipe); + + toverlay = gst_bin_get_by_name (GST_BIN (pipe), "t"); + g_assert (toverlay); + + g_object_set (toverlay, "xpad", 3, "ypad", 3, NULL); + + for (a = 0; a < G_N_ELEMENTS (valigns); ++a) { + for (b = 0; b < G_N_ELEMENTS (haligns); ++b) { + for (c = 0; c < G_N_ELEMENTS (linealigns); ++c) { + gchar *s; + + s = g_strdup_printf ("line-alignment = %s\n" + "<----- halignment = %s ----->\nvalignment = %s", + linealigns[c], haligns[b], valigns[a]); + show_text (toverlay, s, valigns[a], haligns[b], linealigns[c]); + g_free (s); + } + } + } + + return 0; +}