diff --git a/docs/libs/ges-sections.txt b/docs/libs/ges-sections.txt index 76004bec9d..6f9cc97fc2 100644 --- a/docs/libs/ges-sections.txt +++ b/docs/libs/ges-sections.txt @@ -697,3 +697,22 @@ GES_KEYFILE_FORMATTER_GET_CLASS GES_TYPE_KEYFILE_FORMATTER ges_keyfile_formatter_get_type + +
+ges-track-effect +GESTrackEffect +GESTrackEffect +GESTrackEffectClass +ges_track_effect_new +ges_track_effect_new_with_name +ges_track_effect_set_human_name +ges_track_effect_get_human_name + +GES_IS_TRACK_EFFECT +GES_IS_TRACK_EFFECT_CLASS +GES_TRACK_EFFECT +GES_TRACK_EFFECT_CLASS +GES_TRACK_EFFECT_GET_CLASS +GES_TYPE_TRACK_EFFECT +ges_track_effect_get_type +
diff --git a/ges/Makefile.am b/ges/Makefile.am index 31b352c1fb..622c833e39 100644 --- a/ges/Makefile.am +++ b/ges/Makefile.am @@ -39,6 +39,7 @@ libges_@GST_MAJORMINOR@_la_SOURCES = \ ges-track-audio-test-source.c \ ges-track-title-source.c \ ges-track-text-overlay.c \ + ges-track-effect.c \ ges-screenshot.c \ ges-formatter.c \ ges-keyfile-formatter.c \ @@ -65,6 +66,7 @@ libges_@GST_MAJORMINOR@include_HEADERS = \ ges-timeline-title-source.h \ ges-timeline-overlay.h \ ges-timeline-text-overlay.h \ + ges-track-effect.h \ ges-track.h \ ges-track-object.h \ ges-track-source.h \ diff --git a/ges/ges-track-effect.c b/ges/ges-track-effect.c new file mode 100644 index 0000000000..e37663b014 --- /dev/null +++ b/ges/ges-track-effect.c @@ -0,0 +1,175 @@ +/* GStreamer Editing Services + * Copyright (C) 2010 Thibault Saunier + * + * 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. + */ + +/** + * SECTION:ges-track-effect + * @short_description: adds an effect to a stream in a #GESTimelineSource or a + * #GESTimelineLayer + * + */ + +#include "ges-internal.h" +#include "ges-track-object.h" +#include "ges-track-effect.h" + +G_DEFINE_TYPE (GESTrackEffect, ges_track_effect, GES_TYPE_TRACK_OPERATION); + +static void ges_track_effect_dispose (GObject * object); +static void ges_track_effect_finalize (GObject * object); +static GstElement *ges_track_effect_create_element (GESTrackOperation * self); + +struct _GESTrackEffectPrivate +{ + gchar *bin_description; +}; + +enum +{ + PROP_0, + PROP_BIN_DESCRIPTION, +}; + +static void +ges_track_effect_get_property (GObject * object, + guint property_id, GValue * value, GParamSpec * pspec) +{ + switch (property_id) { + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + } +} + +static void +ges_track_effect_set_property (GObject * object, + guint property_id, const GValue * value, GParamSpec * pspec) +{ + GESTrackEffect *self = GES_TRACK_EFFECT (object); + + switch (property_id) { + case PROP_BIN_DESCRIPTION: + self->priv->bin_description = g_value_dup_string (value); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + } +} + +static void +ges_track_effect_class_init (GESTrackEffectClass * klass) +{ + GObjectClass *object_class; + GESTrackObjectClass *obj_bg_class; + + object_class = G_OBJECT_CLASS (klass); + obj_bg_class = GES_TRACK_OBJECT_CLASS (klass); + + g_type_class_add_private (klass, sizeof (GESTrackEffectPrivate)); + + object_class->get_property = ges_track_effect_get_property; + object_class->set_property = ges_track_effect_set_property; + object_class->dispose = ges_track_effect_dispose; + object_class->finalize = ges_track_effect_finalize; + + obj_bg_class->create_element = ges_track_effect_create_element; + + /** + * GESTrackEffect:bin_description: + * + * The description of the effect bin with a gst-launch-style + * pipeline description. + * exemple: videobalance saturation=1.5 hue=+0.5 + */ + g_object_class_install_property (object_class, PROP_BIN_DESCRIPTION, + g_param_spec_string ("bin-description", + "bin description", + "Bin description of the effect", + NULL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); + +} + +static void +ges_track_effect_init (GESTrackEffect * self) +{ + self->priv = + G_TYPE_INSTANCE_GET_PRIVATE (self, GES_TYPE_TRACK_EFFECT, + GESTrackEffectPrivate); +} + +static void +ges_track_effect_dispose (GObject * object) +{ + G_OBJECT_CLASS (ges_track_effect_parent_class)->dispose (object); +} + +static void +ges_track_effect_finalize (GObject * object) +{ + GESTrackEffect *self = GES_TRACK_EFFECT (object); + + if (self->priv->bin_description) + g_free (self->priv->bin_description); + + G_OBJECT_CLASS (ges_track_effect_parent_class)->finalize (object); +} + +static GstElement * +ges_track_effect_create_element (GESTrackOperation * object) +{ + GstElement *csp, *ret, *effect; + GstPad *src_target, *sink_target; + GstPad *src, *sink; + + GError *error = NULL; + GESTrackEffect *self = GES_TRACK_EFFECT (object); + + effect = + gst_parse_bin_from_description (self->priv->bin_description, TRUE, + &error); + if (error != NULL) + return NULL; + + csp = gst_element_factory_make ("ffmpegcolorspace", NULL); + + ret = gst_bin_new ("effect-bin"); + gst_bin_add_many (GST_BIN (ret), effect, csp, NULL); + gst_element_link (csp, ret); + + src_target = gst_element_get_static_pad (effect, "src"); + sink_target = gst_element_get_static_pad (csp, "sink"); + + src = gst_ghost_pad_new ("src", src_target); + sink = gst_ghost_pad_new ("video_sink", sink_target); + + g_object_unref (src_target); + g_object_unref (sink_target); + + gst_element_add_pad (ret, src); + gst_element_add_pad (ret, sink); + + GST_DEBUG ("Created %p", ret); + + return ret; +} + +GESTrackEffect * +ges_track_effect_new (const gchar * bin_description) +{ + return g_object_new (GES_TYPE_TRACK_EFFECT, "bin-description", + bin_description, NULL); +} diff --git a/ges/ges-track-effect.h b/ges/ges-track-effect.h new file mode 100644 index 0000000000..3174122835 --- /dev/null +++ b/ges/ges-track-effect.h @@ -0,0 +1,75 @@ +/* GStreamer Editing Services + * Copyright (C) 2010 Thibault Saunier + * + * 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. + */ + +#ifndef _GES_TRACK_EFFECT +#define _GES_TRACK_EFFECT + +#include +#include +#include + +G_BEGIN_DECLS +#define GES_TYPE_TRACK_EFFECT ges_track_effect_get_type() +#define GES_TRACK_EFFECT(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST ((obj), GES_TYPE_TRACK_EFFECT, GESTrackEffect)) +#define GES_TRACK_EFFECT_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST ((klass), GES_TYPE_TRACK_EFFECT, GESTrackEffectClass)) +#define GES_IS_TRACK_EFFECT(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GES_TYPE_TRACK_EFFECT)) +#define GES_IS_TRACK_EFFECT_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_TYPE ((klass), GES_TYPE_TRACK_EFFECT)) +#define GES_TRACK_EFFECT_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS ((obj), GES_TYPE_TRACK_EFFECT, GESTrackEffectClass)) +/** + * GESTrackEffect: + * + */ + struct _GESTrackEffect +{ + GESTrackOperation parent; + + /*< private > */ + gchar *bin_description; + gchar *human_name; +}; + +/** + * GESTrackEffectClass: + * @parent_class: parent class + */ + +struct _GESTrackEffectClass +{ + GESTrackOperationClass parent_class; + + /*< private > */ +}; + +GType ges_track_effect_get_type (void); + +void ges_track_effect_set_human_name (GESTrackEffect * self, + const gchar * human_name); +gchar *ges_track_effect_get_human_name (GESTrackEffect * self); + +GESTrackEffect *ges_track_effect_new (const gchar * bin_description); +GESTrackEffect *ges_track_effect_new_with_name (const gchar * bin_description, + const gchar * human_name); + +G_END_DECLS +#endif /* _GES_TRACK_EFFECT */ diff --git a/ges/ges-types.h b/ges/ges-types.h index 84f2547e96..a8acce9e9b 100644 --- a/ges/ges-types.h +++ b/ges/ges-types.h @@ -83,6 +83,9 @@ typedef struct _GESTrackSourceClass GESTrackSourceClass; typedef struct _GESTrackOperation GESTrackOperation; typedef struct _GESTrackOperationClass GESTrackOperationClass; +typedef struct _GESTrackEffect GESTrackEffect; +typedef struct _GESTrackEffectClass GESTrackEffectClass; + typedef struct _GESTrackFileSource GESTrackFileSource; typedef struct _GESTrackFileSourceClass GESTrackFileSourceClass; diff --git a/tests/check/Makefile.am b/tests/check/Makefile.am index 23b806e250..59105d039b 100644 --- a/tests/check/Makefile.am +++ b/tests/check/Makefile.am @@ -15,14 +15,15 @@ SUPPRESSIONS = $(top_srcdir)/common/gst.supp # $(srcdir)/gst-plugins-bad.supp clean-local: clean-local-check check_PROGRAMS = \ - ges/basic \ - ges/filesource \ - ges/layer \ - ges/simplelayer \ - ges/transition \ - ges/timelineobject \ ges/backgroundsource\ + ges/basic \ + ges/layer \ + ges/effects \ + ges/filesource \ + ges/simplelayer \ + ges/timelineobject \ ges/titles\ + ges/transition \ ges/overlays\ ges/text_properties\ ges/save_and_load diff --git a/tests/check/ges/effects.c b/tests/check/ges/effects.c new file mode 100644 index 0000000000..37c1200c09 --- /dev/null +++ b/tests/check/ges/effects.c @@ -0,0 +1,69 @@ +/* GStreamer Editing Services + * Copyright (C) 2010 Thibault Saunier + * + * 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 +#include +#include + +GST_START_TEST (test_effect_basic) +{ + GESTrackEffect *effect; + + ges_init (); + + effect = ges_track_effect_new ("identity"); + fail_unless (effect != NULL); + g_object_unref (effect); + + effect = ges_track_effect_new_with_name ("identity", "Identity effect"); + fail_unless (effect != NULL); + g_object_unref (effect); +} + +GST_END_TEST; + +static Suite * +ges_suite (void) +{ + Suite *s = suite_create ("ges"); + TCase *tc_chain = tcase_create ("effect"); + + suite_add_tcase (s, tc_chain); + + tcase_add_test (tc_chain, test_effect_basic); + + return s; +} + +int +main (int argc, char **argv) +{ + int nf; + + Suite *s = ges_suite (); + SRunner *sr = srunner_create (s); + + gst_check_init (&argc, &argv); + + srunner_run_all (sr, CK_NORMAL); + nf = srunner_ntests_failed (sr); + srunner_free (sr); + + return nf; +}