#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)
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
{
}
+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)
{
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
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)
{
GESTimeline *timeline;
GESTrack *trackv;
GESTimelineLayer *layer1;
- GESTimelineFileSource *srca, *srcb;
- GESCustomTimelineSource *src;
+ GESTimelineObject *srca, *srcb;
GMainLoop *mainloop;
gint type;
gchar *uri = NULL;
exit (0);
}
+ guint64 tdur = (guint64) transition_duration * GST_SECOND;
+
g_option_context_free (ctx);
ges_init ();
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);
-
- g_free (uri);
-
- ges_timeline_layer_add_object (layer1, GES_TIMELINE_OBJECT (srca));
- ges_timeline_layer_add_object (layer1, GES_TIMELINE_OBJECT (srcb));
+ 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);
- GESTimelineTransition *tr;
+ GESTimelineTransition *tr = NULL;
- 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);