#include "ges-timeline-object.h"
#include "ges-timeline-source.h"
#include "ges-track-source.h"
-#include "ges-track-text-overlay.h"
-/* FIXME: really need to put this in a common header file */
-
-#define DEFAULT_PROP_TEXT ""
-#define DEFAULT_PROP_FONT_DESC "Serif 36"
-#define DEFAULT_PROP_VALIGNMENT GES_TEXT_VALIGN_BASELINE
-#define DEFAULT_PROP_HALIGNMENT GES_TEXT_HALIGN_CENTER
struct _GESTimelineSourcePrivate
{
enum
{
PROP_0,
- PROP_TEXT,
- PROP_FONT_DESC,
- PROP_HALIGNMENT,
- PROP_VALIGNMENT,
};
G_DEFINE_TYPE (GESTimelineSource, ges_timeline_source,
GES_TYPE_TIMELINE_OBJECT);
-static gboolean
-ges_timeline_source_create_track_objects (GESTimelineObject * obj,
- GESTrack * track);
-
-static void
-ges_timeline_source_set_text (GESTimelineSource * self, const gchar * text);
-
-static void
-ges_timeline_source_set_font_desc (GESTimelineSource * self, const gchar *
- font_desc);
-
-static void
-ges_timeline_source_set_valign (GESTimelineSource * self, GESTextVAlign valign);
-
-static void
-ges_timeline_source_set_halign (GESTimelineSource * self, GESTextHAlign halign);
-
static void
ges_timeline_source_get_property (GObject * object, guint property_id,
GValue * value, GParamSpec * pspec)
{
- GESTimelineSource *ts = (GESTimelineSource *) object;
switch (property_id) {
- case PROP_TEXT:
- g_value_set_string (value, ts->text);
- break;
- case PROP_FONT_DESC:
- g_value_set_string (value, ts->font_desc);
- break;
- case PROP_HALIGNMENT:
- g_value_set_enum (value, ts->halign);
- break;
- case PROP_VALIGNMENT:
- g_value_set_enum (value, ts->valign);
- break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}
ges_timeline_source_set_property (GObject * object, guint property_id,
const GValue * value, GParamSpec * pspec)
{
- GESTimelineSource *ts = (GESTimelineSource *) object;
switch (property_id) {
- case PROP_TEXT:
- ges_timeline_source_set_text (ts, g_value_get_string (value));
- break;
- case PROP_FONT_DESC:
- ges_timeline_source_set_font_desc (ts, g_value_get_string (value));
- break;
- case PROP_HALIGNMENT:
- ges_timeline_source_set_halign (ts, g_value_get_enum (value));
- break;
- case PROP_VALIGNMENT:
- ges_timeline_source_set_valign (ts, g_value_get_enum (value));
- break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}
static void
ges_timeline_source_finalize (GObject * object)
{
- GESTimelineSource *source = (GESTimelineSource *) object;
-
- if (source->text)
- g_free (source->text);
- if (source->font_desc)
- g_free (source->font_desc);
-
G_OBJECT_CLASS (ges_timeline_source_parent_class)->finalize (object);
}
ges_timeline_source_class_init (GESTimelineSourceClass * klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GESTimelineObjectClass *timobj_class = GES_TIMELINE_OBJECT_CLASS (klass);
g_type_class_add_private (klass, sizeof (GESTimelineSourcePrivate));
object_class->get_property = ges_timeline_source_get_property;
object_class->set_property = ges_timeline_source_set_property;
object_class->finalize = ges_timeline_source_finalize;
-
- /**
- * GESTimelineTextOverlay:text
- *
- * The text to diplay
- */
-
- g_object_class_install_property (object_class, PROP_TEXT,
- g_param_spec_string ("text", "Text", "The text to display",
- NULL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
-
- /**
- * GESTimelineTextOverlay:font-desc
- *
- * Pango font description string
- */
-
- g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_FONT_DESC,
- g_param_spec_string ("font-desc", "font description",
- "Pango font description of font to be used for rendering. "
- "See documentation of pango_font_description_from_string "
- "for syntax.", DEFAULT_PROP_FONT_DESC,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS));
-
- /**
- * GESTimelineTextOverlay:valignment
- *
- * Vertical alignent of the text
- */
- g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_VALIGNMENT,
- g_param_spec_enum ("valignment", "vertical alignment",
- "Vertical alignment of the text", GES_TEXT_VALIGN_TYPE,
- DEFAULT_PROP_VALIGNMENT, G_PARAM_READWRITE | G_PARAM_CONSTRUCT |
- G_PARAM_STATIC_STRINGS));
- /**
- * GESTimelineTextOverlay:halignment
- *
- * Horizontal alignment of the text
- */
- g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_HALIGNMENT,
- g_param_spec_enum ("halignment", "horizontal alignment",
- "Horizontal alignment of the text",
- GES_TEXT_HALIGN_TYPE, DEFAULT_PROP_HALIGNMENT,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS));
-
-
- timobj_class->create_track_objects = ges_timeline_source_create_track_objects;
}
static void
{
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
GES_TYPE_TIMELINE_SOURCE, GESTimelineSourcePrivate);
-
- self->halign = DEFAULT_PROP_HALIGNMENT;
- self->valign = DEFAULT_PROP_VALIGNMENT;
-}
-
-static gboolean
-ges_timeline_source_create_track_objects (GESTimelineObject * obj,
- GESTrack * track)
-{
- GESTrackObject *primary, *overlay;
- GESTimelineSource *self;
- gboolean success = FALSE;
-
- self = (GESTimelineSource *) obj;
-
- /* calls add_track_object() for us. we already own this reference */
- primary = ges_timeline_object_create_track_object (obj, track);
- if (!primary) {
- GST_WARNING ("couldn't create primary track object");
- return FALSE;
- }
-
- success = ges_track_add_object (track, primary);
-
- /* create priority space for the text overlay. do this regardless of
- * wthether we create an overlay so that track objects have a consistent
- * priority between tracks. */
- g_object_set (primary, "priority-offset", (guint) 1, NULL);
-
- if (track->type == GES_TRACK_TYPE_VIDEO) {
- overlay = (GESTrackObject *) ges_track_text_overlay_new ();
- /* will check for null */
- if (!ges_timeline_object_add_track_object (obj, overlay)) {
- GST_ERROR ("couldn't add textoverlay");
- return FALSE;
- }
-
- success = ges_track_add_object (track, overlay);
-
- if ((self->text) && *(self->text)) {
- ges_track_text_overlay_set_text ((GESTrackTextOverlay *) overlay,
- self->text);
- }
-
- else {
- ges_track_object_set_active (overlay, FALSE);
- }
-
- if (self->font_desc)
- ges_track_text_overlay_set_font_desc ((GESTrackTextOverlay *) overlay,
- self->font_desc);
- ges_track_text_overlay_set_halignment ((GESTrackTextOverlay *) overlay,
- self->halign);
- ges_track_text_overlay_set_valignment ((GESTrackTextOverlay *) overlay,
- self->valign);
-
- }
-
- return success;
-}
-
-static void
-ges_timeline_source_set_text (GESTimelineSource * self, const gchar * text)
-{
- GList *tmp, *trackobjects;
- GESTimelineObject *object = (GESTimelineObject *) self;
-
- GST_DEBUG ("self:%p, text:%s", self, text);
-
- if (self->text)
- g_free (self->text);
-
- self->text = g_strdup (text);
-
- trackobjects = ges_timeline_object_get_track_objects (object);
- for (tmp = trackobjects; tmp; tmp = tmp->next) {
- GESTrackObject *trackobject = (GESTrackObject *) tmp->data;
-
- if (GES_IS_TRACK_TEXT_OVERLAY (trackobject)) {
- ges_track_text_overlay_set_text ((GESTrackTextOverlay *)
- (trackobject), self->text);
- ges_track_object_set_active (trackobject, (text && (*text)) ? TRUE :
- FALSE);
- }
-
- g_object_unref (GES_TRACK_OBJECT (tmp->data));
- }
- g_list_free (trackobjects);
-}
-
-static void
-ges_timeline_source_set_font_desc (GESTimelineSource * self, const gchar *
- font_desc)
-{
- GList *tmp, *trackobjects;
- GESTimelineObject *object = (GESTimelineObject *) self;
-
- GST_DEBUG ("self:%p, font_desc:%s", self, font_desc);
-
- if (self->font_desc)
- g_free (self->font_desc);
-
- self->font_desc = g_strdup (font_desc);
-
- trackobjects = ges_timeline_object_get_track_objects (object);
- for (tmp = trackobjects; tmp; tmp = tmp->next) {
- GESTrackObject *trackobject = (GESTrackObject *) tmp->data;
-
- if (GES_IS_TRACK_TEXT_OVERLAY (trackobject))
- ges_track_text_overlay_set_font_desc ((GESTrackTextOverlay *)
- (trackobject), self->font_desc);
-
- g_object_unref (GES_TRACK_OBJECT (tmp->data));
- }
- g_list_free (trackobjects);
-
-}
-
-static void
-ges_timeline_source_set_halign (GESTimelineSource * self, GESTextHAlign halign)
-{
- GList *tmp, *trackobjects;
- GESTimelineObject *object = (GESTimelineObject *) self;
-
- GST_DEBUG ("self:%p, halign:%d", self, halign);
-
- self->halign = halign;
-
- trackobjects = ges_timeline_object_get_track_objects (object);
- for (tmp = trackobjects; tmp; tmp = tmp->next) {
- GESTrackObject *trackobject = (GESTrackObject *) tmp->data;
-
- if (GES_IS_TRACK_TEXT_OVERLAY (trackobject))
- ges_track_text_overlay_set_halignment ((GESTrackTextOverlay *)
- (trackobject), self->halign);
-
- g_object_unref (GES_TRACK_OBJECT (tmp->data));
- }
- g_list_free (trackobjects);
-
-}
-
-static void
-ges_timeline_source_set_valign (GESTimelineSource * self, GESTextVAlign valign)
-{
- GList *tmp, *trackobjects;
- GESTimelineObject *object = (GESTimelineObject *) self;
-
- GST_DEBUG ("self:%p, valign:%d", self, valign);
-
- self->valign = valign;
-
- trackobjects = ges_timeline_object_get_track_objects (object);
- for (tmp = trackobjects; tmp; tmp = tmp->next) {
- GESTrackObject *trackobject = (GESTrackObject *) tmp->data;
-
- if (GES_IS_TRACK_TEXT_OVERLAY (trackobject))
- ges_track_text_overlay_set_valignment ((GESTrackTextOverlay *)
- (trackobject), self->valign);
-
- g_object_unref (GES_TRACK_OBJECT (tmp->data));
- }
- g_list_free (trackobjects);
-
}
GESTimelineObject parent;
/*< private >*/
- gchar *text;
- gchar *font_desc;
- GESTextHAlign halign;
- GESTextVAlign valign;
-
GESTimelineSourcePrivate *priv;
/* Padding for API extension */
assert_equals_uint64 (GES_TIMELINE_OBJECT_DURATION (object), 51);
assert_equals_uint64 (GES_TIMELINE_OBJECT_INPOINT (object), 12);
assert_equals_uint64 (GES_TIMELINE_OBJECT_PRIORITY (object), 0);
- gnl_object_check (trackobject->gnlobject, 42, 51, 12, 51, 1, TRUE);
+ gnl_object_check (trackobject->gnlobject, 42, 51, 12, 51, 0, TRUE);
/* Change the priority of the layer */
g_object_set (layer, "priority", 1, NULL);
assert_equals_int (layer->priority, 1);
assert_equals_uint64 (GES_TIMELINE_OBJECT_PRIORITY (object), 10);
- gnl_object_check (trackobject->gnlobject, 42, 51, 12, 51, 11, TRUE);
+ gnl_object_check (trackobject->gnlobject, 42, 51, 12, 51, 10, TRUE);
/* Change it to an insanely high value */
g_object_set (layer, "priority", 1000000, NULL);
assert_equals_int (layer->priority, 1000000);
assert_equals_uint64 (GES_TIMELINE_OBJECT_PRIORITY (object), 10000000);
- gnl_object_check (trackobject->gnlobject, 42, 51, 12, 51, 10000001, TRUE);
+ gnl_object_check (trackobject->gnlobject, 42, 51, 12, 51, 10000000, TRUE);
/* and back to 0 */
g_object_set (layer, "priority", 0, NULL);
assert_equals_int (layer->priority, 0);
assert_equals_uint64 (GES_TIMELINE_OBJECT_PRIORITY (object), 0);
- gnl_object_check (trackobject->gnlobject, 42, 51, 12, 51, 1, TRUE);
+ gnl_object_check (trackobject->gnlobject, 42, 51, 12, 51, 0, TRUE);
/* check priority offsets */
- assert_equals_int (GES_TIMELINE_OBJECT_HEIGHT (object), 2);
+ assert_equals_int (GES_TIMELINE_OBJECT_HEIGHT (object), 1);
g_object_set (trackobject, "priority-offset", (guint32) 3, NULL);
gnl_object_check (trackobject->gnlobject, 42, 51, 12, 51, 3, TRUE);
g_object_set (object, "priority", 5, NULL);
KEY ("Object0", "in-point", "0");
KEY ("Object0", "duration", "2000000000");
KEY ("Object0", "priority", "2");
- KEY ("Object0", "font-desc", "\"Serif\\\\ 36\"");
- KEY ("Object0", "halignment", "center");
- KEY ("Object0", "valignment", "baseline");
KEY ("Object0", "mute", "false");
KEY ("Object0", "vpattern", "100% Black");
KEY ("Object0", "freq", "440");
KEY ("Object2", "start", "1500000000");
KEY ("Object2", "in-point", "0");
KEY ("Object2", "duration", "2000000000");
- /* This object will be under the other object and transition */
- KEY ("Object2", "priority", "4");
- KEY ("Object2", "font-desc", "\"Serif\\\\ 36\"");
- KEY ("Object2", "halignment", "center");
- KEY ("Object2", "valignment", "baseline");
+ KEY ("Object2", "priority", "3");
KEY ("Object2", "mute", "false");
KEY ("Object2", "vpattern", "100% Black");
KEY ("Object2", "freq", "440");
"in-point=0\n"
"duration=2000000000\n"
"priority=2\n"
- "font-desc=\"Serif\\\\ 36\"\n"
- "halignment=center\n"
- "valignment=baseline\n"
"mute=false\n"
"vpattern=100% Black\n"
"freq=440\n"
"in-point=0\n"
"duration=2000000000\n"
"priority=2\n"
- "font-desc=\"Serif\\\\ 36\"\n"
- "halignment=center\n"
- "valignment=baseline\n"
"mute=false\n"
"vpattern=100% Black\n"
"freq=440\n"
/* [0 0.5 1 1.5 2 2.5 3] */
/* 0 */
/* 1 [1-tr1--] */
- /* 2 [0--source1----] */
- /* 3 [0--source1----][3-tr2--] */
+ /* 2 [0--source1----][3-tr2--] */
+ /* 3 [2---source2-----] */
/* 4 [2---source2-----] */
/* 5 [2---source2-----] */
/* 6 [2---source2-----] */
- /* 7 [2---source2-----] */
- /* 8 [4---source3---] */
- /* 9 [4---source3---] */
- /*10 [5---source4-----] */
- /*11 [5---source4-----] */
+ /* 7 [4---source3---] */
+ /* 8 [5---source4-----] */
+
gstl = GES_SIMPLE_TIMELINE_LAYER (layer);
/* add objects in sequence */
+ GST_DEBUG ("Adding source1");
+
fail_unless (ges_simple_timeline_layer_add_object (gstl,
GES_TIMELINE_OBJECT (source1), -1));
fail_unless_equals_uint64 (GES_TIMELINE_OBJECT_DURATION (source1),
fail_unless_equals_uint64 (GES_TIMELINE_OBJECT_START (source1), 0);
fail_unless_equals_uint64 (GES_TIMELINE_OBJECT_PRIORITY (source1), 2);
+ GST_DEBUG ("Adding tr1");
+
fail_unless (ges_simple_timeline_layer_add_object (gstl,
GES_TIMELINE_OBJECT (tr1), -1));
fail_unless_equals_uint64 (GES_TIMELINE_OBJECT_DURATION (source1),
fail_unless_equals_uint64 (GES_TIMELINE_OBJECT_START (tr1), HALF_SECOND);
fail_unless_equals_uint64 (GES_TIMELINE_OBJECT_PRIORITY (tr1), 1);
+ GST_DEBUG ("Adding source2");
+
fail_unless (ges_simple_timeline_layer_add_object (gstl,
GES_TIMELINE_OBJECT (source2), -1));
fail_unless_equals_uint64 (GES_TIMELINE_OBJECT_DURATION (source1),
fail_unless_equals_uint64 (GES_TIMELINE_OBJECT_DURATION (source2),
GST_SECOND);
fail_unless_equals_uint64 (GES_TIMELINE_OBJECT_START (source2), HALF_SECOND);
- fail_unless_equals_uint64 (GES_TIMELINE_OBJECT_PRIORITY (source2), 4);
+ fail_unless_equals_uint64 (GES_TIMELINE_OBJECT_PRIORITY (source2), 3);
/* add the third source before the second transition */
+ GST_DEBUG ("Adding source3");
+
fail_unless (ges_simple_timeline_layer_add_object (gstl,
GES_TIMELINE_OBJECT (source3), -1));
fail_unless_equals_uint64 (GES_TIMELINE_OBJECT_DURATION (source1),
fail_unless_equals_uint64 (GES_TIMELINE_OBJECT_DURATION (source2),
GST_SECOND);
fail_unless_equals_uint64 (GES_TIMELINE_OBJECT_START (source2), HALF_SECOND);
- fail_unless_equals_uint64 (GES_TIMELINE_OBJECT_PRIORITY (source2), 4);
+ fail_unless_equals_uint64 (GES_TIMELINE_OBJECT_PRIORITY (source2), 3);
fail_unless_equals_uint64 (GES_TIMELINE_OBJECT_DURATION (source3),
GST_SECOND);
fail_unless_equals_uint64 (GES_TIMELINE_OBJECT_START (source3), SECOND (1.5));
- fail_unless_equals_uint64 (GES_TIMELINE_OBJECT_PRIORITY (source3), 8);
+ fail_unless_equals_uint64 (GES_TIMELINE_OBJECT_PRIORITY (source3), 7);
/* now add the second transition */
+ GST_DEBUG ("Adding tr2");
+
fail_unless (ges_simple_timeline_layer_add_object (gstl,
GES_TIMELINE_OBJECT (tr2), 3));
fail_unless_equals_uint64 (GES_TIMELINE_OBJECT_DURATION (source1),
fail_unless_equals_uint64 (GES_TIMELINE_OBJECT_DURATION (source2),
GST_SECOND);
fail_unless_equals_uint64 (GES_TIMELINE_OBJECT_START (source2), HALF_SECOND);
- fail_unless_equals_uint64 (GES_TIMELINE_OBJECT_PRIORITY (source2), 4);
+ fail_unless_equals_uint64 (GES_TIMELINE_OBJECT_PRIORITY (source2), 3);
fail_unless_equals_uint64 (GES_TIMELINE_OBJECT_DURATION (tr2), HALF_SECOND);
fail_unless_equals_uint64 (GES_TIMELINE_OBJECT_START (tr2), GST_SECOND);
- fail_unless_equals_uint64 (GES_TIMELINE_OBJECT_PRIORITY (tr2), 3);
+ fail_unless_equals_uint64 (GES_TIMELINE_OBJECT_PRIORITY (tr2), 2);
fail_unless_equals_uint64 (GES_TIMELINE_OBJECT_DURATION (source3),
GST_SECOND);
fail_unless_equals_uint64 (GES_TIMELINE_OBJECT_START (source3), GST_SECOND);
- fail_unless_equals_uint64 (GES_TIMELINE_OBJECT_PRIORITY (source3), 8);
+ fail_unless_equals_uint64 (GES_TIMELINE_OBJECT_PRIORITY (source3), 7);
/* fourth source */
+ GST_DEBUG ("Adding source4");
+
fail_unless (ges_simple_timeline_layer_add_object (gstl,
GES_TIMELINE_OBJECT (source4), -1));
fail_unless_equals_uint64 (GES_TIMELINE_OBJECT_DURATION (source1),
fail_unless_equals_uint64 (GES_TIMELINE_OBJECT_DURATION (source2),
GST_SECOND);
fail_unless_equals_uint64 (GES_TIMELINE_OBJECT_START (source2), HALF_SECOND);
- fail_unless_equals_uint64 (GES_TIMELINE_OBJECT_PRIORITY (source2), 4);
+ fail_unless_equals_uint64 (GES_TIMELINE_OBJECT_PRIORITY (source2), 3);
fail_unless_equals_uint64 (GES_TIMELINE_OBJECT_DURATION (tr2), HALF_SECOND);
fail_unless_equals_uint64 (GES_TIMELINE_OBJECT_START (tr2), GST_SECOND);
- fail_unless_equals_uint64 (GES_TIMELINE_OBJECT_PRIORITY (tr2), 3);
+ fail_unless_equals_uint64 (GES_TIMELINE_OBJECT_PRIORITY (tr2), 2);
fail_unless_equals_uint64 (GES_TIMELINE_OBJECT_DURATION (source3),
GST_SECOND);
fail_unless_equals_uint64 (GES_TIMELINE_OBJECT_START (source3), GST_SECOND);
- fail_unless_equals_uint64 (GES_TIMELINE_OBJECT_PRIORITY (source3), 8);
+ fail_unless_equals_uint64 (GES_TIMELINE_OBJECT_PRIORITY (source3), 7);
fail_unless_equals_uint64 (GES_TIMELINE_OBJECT_DURATION (source4),
GST_SECOND);
fail_unless_equals_uint64 (GES_TIMELINE_OBJECT_START (source4), SECOND (2));
- fail_unless_equals_uint64 (GES_TIMELINE_OBJECT_PRIORITY (source4), 10);
+ fail_unless_equals_uint64 (GES_TIMELINE_OBJECT_PRIORITY (source4), 8);
/* check that any insertion which might result in two adjacent transitions
* will fail */
+ GST_DEBUG ("Checking wrong insertion of tr3");
+
fail_if (ges_simple_timeline_layer_add_object (gstl,
GES_TIMELINE_OBJECT (tr3), 1));
/* check that insertions which don't cause problems still work */
+ GST_DEBUG ("Checking correct insertion of tr3");
+
fail_unless (ges_simple_timeline_layer_add_object (gstl,
GES_TIMELINE_OBJECT (tr3), 5));
fail_unless (valid);
fail_unless_equals_int (count, 3);
+ GST_DEBUG ("Checking correct insertion of tr4");
+
fail_unless (ges_simple_timeline_layer_add_object (gstl,
GES_TIMELINE_OBJECT (tr4), -1));
+ GST_DEBUG ("Checking correct insertion of tr5");
+
fail_unless (ges_simple_timeline_layer_add_object (gstl,
GES_TIMELINE_OBJECT (tr5), 0));
/* removals which result in two or more adjacent transitions will also
* print a warning on the console. This is expected */
- GST_DEBUG ("Removing sources");
+ GST_DEBUG ("Removing source1");
fail_unless (ges_timeline_layer_remove_object (layer,
GES_TIMELINE_OBJECT (source1)));
fail_unless (!valid);
fail_unless_equals_int (count, 4);
+ GST_DEBUG ("Removing source2/3/4");
+
fail_unless (ges_timeline_layer_remove_object (layer,
GES_TIMELINE_OBJECT (source2)));
fail_unless (ges_timeline_layer_remove_object (layer,
ges_timeline_object_find_track_object (GES_TIMELINE_OBJECT (source), v,
GES_TYPE_TRACK_TEXT_OVERLAY);
+ fail_unless (trobj != NULL);
assert_equals_int (trobj->active, FALSE);
/* specifically test the text property */