This commit is contained in:
Brandon Lewis 2010-05-25 13:44:57 +02:00 committed by Edward Hervey
parent 60e09c2438
commit c9a2f73579
5 changed files with 148 additions and 31 deletions

View file

@ -89,6 +89,20 @@ GES_IS_TRACK_FILESOURCE_CLASS
ges_track_filesource_get_type
</SECTION>
<SECTION>
<FILE>ges-track-transition</FILE>
<TITLE>GESTrackTransition</TITLE>
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
</SECTION>
<SECTION>
@ -257,7 +271,6 @@ GES_IS_CUSTOM_TIMELINE_SOURCE_CLASS
GES_TYPE_CUSTOM_TIMELINE_SOURCE
</SECTION>
<SECTION>
<FILE>ges-simple-timeline-layer</FILE>
<TITLE>GESSimpleTimelineLayer</TITLE>

View file

@ -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);

View file

@ -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)
{

View file

@ -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

View file

@ -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);