mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-09-02 02:03:54 +00:00
add vaid property and unit tests
This commit is contained in:
parent
719c2ad0a5
commit
03e488ac74
3 changed files with 69 additions and 6 deletions
|
@ -61,13 +61,26 @@ enum
|
||||||
LAST_SIGNAL,
|
LAST_SIGNAL,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
PROP_0,
|
||||||
|
PROP_VALID,
|
||||||
|
LAST_PROP,
|
||||||
|
};
|
||||||
|
|
||||||
static guint gstl_signals[LAST_SIGNAL] = { 0 };
|
static guint gstl_signals[LAST_SIGNAL] = { 0 };
|
||||||
|
|
||||||
static void
|
static void
|
||||||
ges_simple_timeline_layer_get_property (GObject * object,
|
ges_simple_timeline_layer_get_property (GObject * object,
|
||||||
guint property_id, GValue * value, GParamSpec * pspec)
|
guint property_id, GValue * value, GParamSpec * pspec)
|
||||||
{
|
{
|
||||||
|
GESSimpleTimelineLayer *self;
|
||||||
|
self = GES_SIMPLE_TIMELINE_LAYER (object);
|
||||||
|
|
||||||
switch (property_id) {
|
switch (property_id) {
|
||||||
|
case PROP_VALID:
|
||||||
|
g_value_set_boolean (value, self->valid);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||||
}
|
}
|
||||||
|
@ -110,6 +123,17 @@ ges_simple_timeline_layer_class_init (GESSimpleTimelineLayerClass * klass)
|
||||||
layer_class->object_removed = ges_simple_timeline_layer_object_removed;
|
layer_class->object_removed = ges_simple_timeline_layer_object_removed;
|
||||||
layer_class->object_added = ges_simple_timeline_layer_object_added;
|
layer_class->object_added = ges_simple_timeline_layer_object_added;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GESSimpleTimelineLayer:valid:
|
||||||
|
*
|
||||||
|
* FALSE when the arrangement of objects in the layer would cause errors or
|
||||||
|
* unexpected output during playback. Do not set the containing pipeline
|
||||||
|
* state to PLAYING when this property is FALSE.
|
||||||
|
*/
|
||||||
|
g_object_class_install_property (object_class, PROP_VALID,
|
||||||
|
g_param_spec_boolean ("valid", "Valid",
|
||||||
|
"Layer is in a valid configuration", FALSE, G_PARAM_READABLE));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GESSimpleTimelineLayer::object-moved
|
* GESSimpleTimelineLayer::object-moved
|
||||||
* @layer: the #GESSimpleTimelineLayer
|
* @layer: the #GESSimpleTimelineLayer
|
||||||
|
@ -145,6 +169,7 @@ gstl_recalculate (GESSimpleTimelineLayer * self)
|
||||||
gint height;
|
gint height;
|
||||||
GESTimelineObject *prev_object = NULL;
|
GESTimelineObject *prev_object = NULL;
|
||||||
GESTimelineObject *prev_transition = NULL;
|
GESTimelineObject *prev_transition = NULL;
|
||||||
|
gboolean valid = TRUE;
|
||||||
|
|
||||||
priority = GES_TIMELINE_LAYER (self)->min_gnl_priority + 2;
|
priority = GES_TIMELINE_LAYER (self)->min_gnl_priority + 2;
|
||||||
|
|
||||||
|
@ -199,14 +224,17 @@ gstl_recalculate (GESSimpleTimelineLayer * self)
|
||||||
|
|
||||||
if (GES_IS_TIMELINE_TRANSITION (prev_object)) {
|
if (GES_IS_TIMELINE_TRANSITION (prev_object)) {
|
||||||
GST_ERROR ("two transitions in sequence!");
|
GST_ERROR ("two transitions in sequence!");
|
||||||
|
valid = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (prev_object && (GES_TIMELINE_OBJECT_DURATION (prev_object) < dur)) {
|
if (prev_object && (GES_TIMELINE_OBJECT_DURATION (prev_object) < dur)) {
|
||||||
GST_ERROR ("transition duration exceeds that of previous neighbor!");
|
GST_ERROR ("transition duration exceeds that of previous neighbor!");
|
||||||
|
valid = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (l_next && (GES_TIMELINE_OBJECT_DURATION (l_next->data) < dur)) {
|
if (l_next && (GES_TIMELINE_OBJECT_DURATION (l_next->data) < dur)) {
|
||||||
GST_ERROR ("transition duration exceeds that of next neighbor!");
|
GST_ERROR ("transition duration exceeds that of next neighbor!");
|
||||||
|
valid = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (prev_transition) {
|
if (prev_transition) {
|
||||||
|
@ -216,8 +244,10 @@ gstl_recalculate (GESSimpleTimelineLayer * self)
|
||||||
|
|
||||||
start = pos;
|
start = pos;
|
||||||
|
|
||||||
if (end > start)
|
if (end > start) {
|
||||||
GST_ERROR ("%d, %d: overlapping transitions!", start, end);
|
GST_ERROR ("%d, %d: overlapping transitions!", start, end);
|
||||||
|
valid = FALSE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
prev_transition = obj;
|
prev_transition = obj;
|
||||||
}
|
}
|
||||||
|
@ -230,6 +260,11 @@ gstl_recalculate (GESSimpleTimelineLayer * self)
|
||||||
GST_TIME_ARGS (pos));
|
GST_TIME_ARGS (pos));
|
||||||
|
|
||||||
GES_TIMELINE_LAYER (self)->max_gnl_priority = priority;
|
GES_TIMELINE_LAYER (self)->max_gnl_priority = priority;
|
||||||
|
|
||||||
|
if (valid != self->valid) {
|
||||||
|
self->valid = valid;
|
||||||
|
g_object_notify (G_OBJECT (self), "valid");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -57,6 +57,7 @@ struct _GESSimpleTimelineLayer {
|
||||||
GList *objects;
|
GList *objects;
|
||||||
|
|
||||||
gboolean adding_object;
|
gboolean adding_object;
|
||||||
|
gboolean valid;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -162,7 +162,8 @@ GST_START_TEST (test_gsl_move_simple)
|
||||||
(layer), GES_TIMELINE_OBJECT (source2), -1));
|
(layer), GES_TIMELINE_OBJECT (source2), -1));
|
||||||
fail_unless_equals_uint64 (GES_TIMELINE_OBJECT_START (source1), 0);
|
fail_unless_equals_uint64 (GES_TIMELINE_OBJECT_START (source1), 0);
|
||||||
fail_unless_equals_uint64 (GES_TIMELINE_OBJECT_START (source2), GST_SECOND);
|
fail_unless_equals_uint64 (GES_TIMELINE_OBJECT_START (source2), GST_SECOND);
|
||||||
fail_unless_equals_int (info.new, -1);
|
/* position will be decremented, this is expected */
|
||||||
|
fail_unless_equals_int (info.new, -2);
|
||||||
fail_unless_equals_int (info.old, 0);
|
fail_unless_equals_int (info.old, 0);
|
||||||
|
|
||||||
/* remove source1, source2 should be moved to the beginning */
|
/* remove source1, source2 should be moved to the beginning */
|
||||||
|
@ -194,6 +195,12 @@ GST_START_TEST (test_gsl_move_simple)
|
||||||
|
|
||||||
GST_END_TEST;
|
GST_END_TEST;
|
||||||
|
|
||||||
|
static void
|
||||||
|
valid_notify_cb (GObject * obj, GParamSpec * unused G_GNUC_UNUSED, gint * count)
|
||||||
|
{
|
||||||
|
(*count)++;
|
||||||
|
}
|
||||||
|
|
||||||
GST_START_TEST (test_gsl_with_transitions)
|
GST_START_TEST (test_gsl_with_transitions)
|
||||||
{
|
{
|
||||||
GESTimeline *timeline;
|
GESTimeline *timeline;
|
||||||
|
@ -202,12 +209,18 @@ GST_START_TEST (test_gsl_with_transitions)
|
||||||
GESCustomTimelineSource *source1, *source2, *source3, *source4;
|
GESCustomTimelineSource *source1, *source2, *source3, *source4;
|
||||||
GESTimelineTransition *tr1, *tr2, *tr3, *tr4, *tr5;
|
GESTimelineTransition *tr1, *tr2, *tr3, *tr4, *tr5;
|
||||||
GESSimpleTimelineLayer *gstl;
|
GESSimpleTimelineLayer *gstl;
|
||||||
|
gboolean valid;
|
||||||
|
gint count = 0;
|
||||||
|
|
||||||
ges_init ();
|
ges_init ();
|
||||||
|
|
||||||
/* Timeline and 1 Layer */
|
/* Timeline and 1 Layer */
|
||||||
timeline = ges_timeline_new ();
|
timeline = ges_timeline_new ();
|
||||||
layer = (GESTimelineLayer *) ges_simple_timeline_layer_new ();
|
layer = (GESTimelineLayer *) ges_simple_timeline_layer_new ();
|
||||||
|
|
||||||
|
g_signal_connect (G_OBJECT (layer), "notify::valid",
|
||||||
|
G_CALLBACK (valid_notify_cb), &count);
|
||||||
|
|
||||||
fail_unless (ges_timeline_add_layer (timeline, layer));
|
fail_unless (ges_timeline_add_layer (timeline, layer));
|
||||||
ges_timeline_layer_set_priority (layer, 0);
|
ges_timeline_layer_set_priority (layer, 0);
|
||||||
|
|
||||||
|
@ -420,15 +433,25 @@ GST_START_TEST (test_gsl_with_transitions)
|
||||||
fail_unless (ges_simple_timeline_layer_add_object (gstl,
|
fail_unless (ges_simple_timeline_layer_add_object (gstl,
|
||||||
GES_TIMELINE_OBJECT (tr5), 0));
|
GES_TIMELINE_OBJECT (tr5), 0));
|
||||||
|
|
||||||
/* check that removals which result in two or more adjacent transitions at
|
/* at this point the layer should still be valid */
|
||||||
* least print a warning. */
|
g_object_get (G_OBJECT (layer), "valid", &valid, NULL);
|
||||||
|
fail_unless (valid);
|
||||||
|
fail_unless_equals_int (count, 1);
|
||||||
|
|
||||||
/* FIXME: this needs to be checked manually in the console output */
|
/* 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 sources");
|
||||||
|
|
||||||
fail_unless (ges_timeline_layer_remove_object (layer,
|
fail_unless (ges_timeline_layer_remove_object (layer,
|
||||||
GES_TIMELINE_OBJECT (source1)));
|
GES_TIMELINE_OBJECT (source1)));
|
||||||
|
|
||||||
|
/* transition should now be invalid */
|
||||||
|
|
||||||
|
g_object_get (G_OBJECT (layer), "valid", &valid, NULL);
|
||||||
|
fail_unless (!valid);
|
||||||
|
fail_unless_equals_int (count, 2)
|
||||||
|
|
||||||
fail_unless (ges_timeline_layer_remove_object (layer,
|
fail_unless (ges_timeline_layer_remove_object (layer,
|
||||||
GES_TIMELINE_OBJECT (source2)));
|
GES_TIMELINE_OBJECT (source2)));
|
||||||
fail_unless (ges_timeline_layer_remove_object (layer,
|
fail_unless (ges_timeline_layer_remove_object (layer,
|
||||||
|
@ -436,6 +459,10 @@ GST_START_TEST (test_gsl_with_transitions)
|
||||||
fail_unless (ges_timeline_layer_remove_object (layer,
|
fail_unless (ges_timeline_layer_remove_object (layer,
|
||||||
GES_TIMELINE_OBJECT (source4)));
|
GES_TIMELINE_OBJECT (source4)));
|
||||||
|
|
||||||
|
g_object_get (G_OBJECT (layer), "valid", &valid, NULL);
|
||||||
|
fail_unless (!valid);
|
||||||
|
fail_unless_equals_int (count, 2);
|
||||||
|
|
||||||
GST_DEBUG ("Removing transitions");
|
GST_DEBUG ("Removing transitions");
|
||||||
|
|
||||||
fail_unless (ges_timeline_layer_remove_object (layer,
|
fail_unless (ges_timeline_layer_remove_object (layer,
|
||||||
|
|
Loading…
Reference in a new issue