From c9a2f7357904d8e8fc840ce9b3f17f29b925db04 Mon Sep 17 00:00:00 2001 From: Brandon Lewis Date: Tue, 25 May 2010 13:44:57 +0200 Subject: [PATCH] hacking --- docs/libs/ges-sections.txt | 15 ++++++- ges/ges-timeline-layer.c | 8 +++- ges/ges-timeline-transition.c | 22 ++++++++++ ges/ges-track-transition.c | 56 ++++++++++++++++++++++++- tests/examples/transition.c | 78 +++++++++++++++++++++++------------ 5 files changed, 148 insertions(+), 31 deletions(-) diff --git a/docs/libs/ges-sections.txt b/docs/libs/ges-sections.txt index 63b447b109..2b78b59c58 100644 --- a/docs/libs/ges-sections.txt +++ b/docs/libs/ges-sections.txt @@ -89,6 +89,20 @@ GES_IS_TRACK_FILESOURCE_CLASS ges_track_filesource_get_type +
+ges-track-transition +GESTrackTransition +GESTrackTransition +GESTrackTransitionClass +GES_IS_TRACK_TRANSITION +GES_IS_TRACK_TRANSITION_CLASS +GES_TRACK_TRANSITION +GES_TRACK_TRANSITION_CLASS +GES_TRACK_TRANSITION_GET_CLASS +GES_TYPE_TRACK_TRANSITION +ges_track_transition_get_type +ges_track_transition_new +
@@ -257,7 +271,6 @@ GES_IS_CUSTOM_TIMELINE_SOURCE_CLASS GES_TYPE_CUSTOM_TIMELINE_SOURCE
-
ges-simple-timeline-layer GESSimpleTimelineLayer diff --git a/ges/ges-timeline-layer.c b/ges/ges-timeline-layer.c index 4aa57d2162..663ddb1775 100644 --- a/ges/ges-timeline-layer.c +++ b/ges/ges-timeline-layer.c @@ -224,7 +224,13 @@ ges_timeline_layer_add_object (GESTimelineLayer * layer, ges_timeline_object_set_layer (object, layer); /* Set the priority. */ - ges_timeline_object_set_priority (object, layer->min_gnl_priority); + if (GES_TIMELINE_OBJECT_PRIORITY (object) > (layer->max_gnl_priority)) { + ges_timeline_object_set_priority (object, layer->max_gnl_priority); + } + + else if (GES_TIMELINE_OBJECT_PRIORITY (object) < (layer->min_gnl_priority)) { + ges_timeline_object_set_priority (object, layer->min_gnl_priority); + } /* emit 'object-added' */ g_signal_emit (layer, ges_timeline_layer_signals[OBJECT_ADDED], 0, object); diff --git a/ges/ges-timeline-transition.c b/ges/ges-timeline-transition.c index 67e40e167a..ec29f4957a 100644 --- a/ges/ges-timeline-transition.c +++ b/ges/ges-timeline-transition.c @@ -25,10 +25,14 @@ #include "ges-internal.h" #include "ges-timeline-transition.h" +#include "ges-track-transition.h" G_DEFINE_TYPE (GESTimelineTransition, ges_timeline_transition, GES_TYPE_TIMELINE_OBJECT); +static GESTrackObject *ges_tl_transition_create_track_object (GESTimelineObject + *, GESTrack *); + static void ges_timeline_transition_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) @@ -65,11 +69,15 @@ static void ges_timeline_transition_class_init (GESTimelineTransitionClass * klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); + GESTimelineObjectClass *timobj_class = GES_TIMELINE_OBJECT_CLASS (klass); object_class->get_property = ges_timeline_transition_get_property; object_class->set_property = ges_timeline_transition_set_property; object_class->dispose = ges_timeline_transition_dispose; object_class->finalize = ges_timeline_transition_finalize; + + timobj_class->create_track_object = ges_tl_transition_create_track_object; + timobj_class->need_fill_track = FALSE; } static void @@ -77,6 +85,20 @@ ges_timeline_transition_init (GESTimelineTransition * self) { } +static GESTrackObject * +ges_tl_transition_create_track_object (GESTimelineObject * obj, + GESTrack * track) +{ + GESTimelineTransition *transition = (GESTimelineTransition *) obj; + GESTrackObject *res; + + GST_DEBUG ("Creating a GESTrackTransition"); + + res = GES_TRACK_OBJECT (ges_track_transition_new ()); + + return res; +} + GESTimelineTransition * ges_timeline_transition_new (void) { diff --git a/ges/ges-track-transition.c b/ges/ges-track-transition.c index 6ababc77c8..33bd2b03e9 100644 --- a/ges/ges-track-transition.c +++ b/ges/ges-track-transition.c @@ -56,12 +56,64 @@ ges_track_transition_finalize (GObject * object) G_OBJECT_CLASS (ges_track_transition_parent_class)->dispose (object); } +GstPad * +link_element_to_mixer (GstElement * element, GstElement * mixer) +{ + GstPad *sinkpad = gst_element_get_request_pad (mixer, "sink_%d"); + GstPad *srcpad = gst_element_get_static_pad (element, "src"); + + g_assert (sinkpad); + g_assert (srcpad); + + gst_pad_link (srcpad, sinkpad); + + return sinkpad; +} + static gboolean ges_track_transition_create_gnl_object (GESTrackObject * object) { - object->gnlobject = gst_element_factory_make ("gnloperation", NULL); + object->gnlobject = gst_element_factory_make ("gnloperation", + "transition-operation"); + g_object_set (object->gnlobject, "priority", 0, NULL); + + if ((object->track->type) == GES_TRACK_TYPE_VIDEO) { + GstElement *topbin = gst_bin_new ("transition-bin"); + GstElement *iconva = gst_element_factory_make ("ffmpegcolorspace", + "tr-csp-a"); + GstElement *iconvb = gst_element_factory_make ("ffmpegcolorspace", + "tr-csp-b"); + GstElement *oconv = gst_element_factory_make ("ffmpegcolorspace", + "tr-csp-output"); + GstElement *mixer = gst_element_factory_make ("videomixer", NULL); + + gst_bin_add_many (GST_BIN (topbin), iconva, iconvb, mixer, oconv, NULL); + GstPad *a_pad = link_element_to_mixer (iconva, mixer); + GstPad *b_pad = link_element_to_mixer (iconvb, mixer); + gst_element_link (mixer, oconv); + + GstPad *sinka_target = gst_element_get_static_pad (iconva, "sink"); + GstPad *sinkb_target = gst_element_get_static_pad (iconvb, "sink"); + GstPad *src_target = gst_element_get_static_pad (oconv, "src"); + + GstPad *sinka = gst_ghost_pad_new ("sinka", sinka_target); + GstPad *sinkb = gst_ghost_pad_new ("sinkb", sinkb_target); + GstPad *src = gst_ghost_pad_new ("src", src_target); + + gst_element_add_pad (topbin, src); + gst_element_add_pad (topbin, sinka); + gst_element_add_pad (topbin, sinkb); + + gst_bin_add (GST_BIN (object->gnlobject), topbin); + + //g_object_set(a_pad, "alpha", 0.5, NULL); + g_object_set (b_pad, "alpha", 0.5, NULL); + + return TRUE; + } + + return FALSE; - return TRUE; } static void diff --git a/tests/examples/transition.c b/tests/examples/transition.c index bbc5b9ae5d..548d240d1c 100644 --- a/tests/examples/transition.c +++ b/tests/examples/transition.c @@ -46,6 +46,41 @@ notify_max_duration_cb (GObject * object) g_print ("got here\n"); } +GESTimelineObject * +make_source (char *path, guint64 start, guint64 duration, gint priority) +{ + char *uri = g_strdup_printf ("file://%s", path); + + GESTimelineObject *ret = + GES_TIMELINE_OBJECT (ges_timeline_filesource_new (uri)); + + g_object_set (ret, "start", start, "duration", duration, + "priority", priority, "in-point", 0, NULL); + + g_free (uri); + + return ret; +} + +gboolean +print_transition_data (GESTimelineObject * tr) +{ + if (!tr) + return FALSE; + + GESTrackObject *trackobj = GES_TRACK_OBJECT (tr->trackobjects->data); + GstElement *gnlobj = trackobj->gnlobject; + guint64 start, duration; + gint priority; + char *name; + + g_object_get (gnlobj, "start", &start, "duration", &duration, + "priority", &priority, "name", &name, NULL); + g_print ("gnlobject for %s: %ld %ld %d\n", name, start, duration, priority); + + return FALSE; +} + int main (int argc, char **argv) { @@ -55,8 +90,7 @@ main (int argc, char **argv) GESTimeline *timeline; GESTrack *trackv; GESTimelineLayer *layer1; - GESTimelineFileSource *srca, *srcb; - GESCustomTimelineSource *src; + GESTimelineObject *srca, *srcb; GMainLoop *mainloop; gint type; gchar *uri = NULL; @@ -87,6 +121,8 @@ main (int argc, char **argv) exit (0); } + guint64 tdur = (guint64) transition_duration * GST_SECOND; + g_option_context_free (ctx); ges_init (); @@ -101,42 +137,30 @@ main (int argc, char **argv) ges_timeline_add_track (timeline, trackv); layer1 = GES_TIMELINE_LAYER (ges_timeline_layer_new ()); - g_object_set (layer1, "priority", 1, NULL); + g_object_set (layer1, "priority", 0, NULL); if (!ges_timeline_add_layer (timeline, layer1)) return -1; - uri = g_strdup_printf ("file://%s", argv[1]); - srca = ges_timeline_filesource_new (uri); - guint64 aduration = (guint64) (atof (argv[2]) * GST_SECOND); - g_object_set (srca, "start", 0, "duration", aduration, NULL); - g_signal_connect (srca, "notify::max_duration", - G_CALLBACK (notify_max_duration_cb), NULL); - - g_free (uri); - - uri = g_strdup_printf ("file://%s", argv[3]); - srcb = ges_timeline_filesource_new (uri); guint64 bduration = (guint64) (atof (argv[4]) * GST_SECOND); - g_object_set (srcb, "start", aduration, "duration", bduration, NULL); - g_signal_connect (srcb, "notify::max_duration", - G_CALLBACK (notify_max_duration_cb), NULL); + guint64 tstart = aduration - tdur; + srca = make_source (argv[1], 0, aduration, 1); + srcb = make_source (argv[3], tstart, bduration, 2); + ges_timeline_layer_add_object (layer1, srca); + ges_timeline_layer_add_object (layer1, srcb); + g_timeout_add_seconds (1, (GSourceFunc) print_transition_data, srca); + g_timeout_add_seconds (1, (GSourceFunc) print_transition_data, srcb); - g_free (uri); + GESTimelineTransition *tr = NULL; - ges_timeline_layer_add_object (layer1, GES_TIMELINE_OBJECT (srca)); - ges_timeline_layer_add_object (layer1, GES_TIMELINE_OBJECT (srcb)); - - GESTimelineTransition *tr; - - guint64 tdur = (guint64) transition_duration * GST_SECOND; if (tdur != 0) { - g_print ("creating transition of %f duration (%ld ns)", - transition_duration, tdur); + g_print ("creating transition at %ld of %f duration (%ld ns)\n", + tstart, transition_duration, tdur); tr = ges_timeline_transition_new (); + g_object_set (tr, "start", tstart, "duration", tdur, "in-point", 0, NULL); ges_timeline_layer_add_object (layer1, GES_TIMELINE_OBJECT (tr)); - g_object_set (tr, "start", aduration - tdur, "duration", tdur, NULL); + g_timeout_add_seconds (1, (GSourceFunc) print_transition_data, tr); } mainloop = g_main_loop_new (NULL, FALSE);